Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2006 Cisco Systems, Inc.  All rights reserved.
0003  *
0004  * This software is available to you under a choice of one of two
0005  * licenses.  You may choose to be licensed under the terms of the GNU
0006  * General Public License (GPL) Version 2, available from the file
0007  * COPYING in the main directory of this source tree, or the
0008  * OpenIB.org BSD license below:
0009  *
0010  *     Redistribution and use in source and binary forms, with or
0011  *     without modification, are permitted provided that the following
0012  *     conditions are met:
0013  *
0014  *      - Redistributions of source code must retain the above
0015  *        copyright notice, this list of conditions and the following
0016  *        disclaimer.
0017  *
0018  *      - Redistributions in binary form must reproduce the above
0019  *        copyright notice, this list of conditions and the following
0020  *        disclaimer in the documentation and/or other materials
0021  *        provided with the distribution.
0022  *
0023  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0024  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0025  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0026  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0027  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0028  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0029  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0030  * SOFTWARE.
0031  */
0032 
0033 #ifndef MLX4_DRIVER_H
0034 #define MLX4_DRIVER_H
0035 
0036 #include <net/devlink.h>
0037 #include <linux/mlx4/device.h>
0038 
0039 struct mlx4_dev;
0040 
0041 #define MLX4_MAC_MASK      0xffffffffffffULL
0042 
0043 enum mlx4_dev_event {
0044     MLX4_DEV_EVENT_CATASTROPHIC_ERROR,
0045     MLX4_DEV_EVENT_PORT_UP,
0046     MLX4_DEV_EVENT_PORT_DOWN,
0047     MLX4_DEV_EVENT_PORT_REINIT,
0048     MLX4_DEV_EVENT_PORT_MGMT_CHANGE,
0049     MLX4_DEV_EVENT_SLAVE_INIT,
0050     MLX4_DEV_EVENT_SLAVE_SHUTDOWN,
0051 };
0052 
0053 enum {
0054     MLX4_INTFF_BONDING  = 1 << 0
0055 };
0056 
0057 struct mlx4_interface {
0058     void *          (*add)   (struct mlx4_dev *dev);
0059     void            (*remove)(struct mlx4_dev *dev, void *context);
0060     void            (*event) (struct mlx4_dev *dev, void *context,
0061                       enum mlx4_dev_event event, unsigned long param);
0062     void *          (*get_dev)(struct mlx4_dev *dev, void *context, u8 port);
0063     void            (*activate)(struct mlx4_dev *dev, void *context);
0064     struct list_head    list;
0065     enum mlx4_protocol  protocol;
0066     int         flags;
0067 };
0068 
0069 int mlx4_register_interface(struct mlx4_interface *intf);
0070 void mlx4_unregister_interface(struct mlx4_interface *intf);
0071 
0072 int mlx4_bond(struct mlx4_dev *dev);
0073 int mlx4_unbond(struct mlx4_dev *dev);
0074 static inline int mlx4_is_bonded(struct mlx4_dev *dev)
0075 {
0076     return !!(dev->flags & MLX4_FLAG_BONDED);
0077 }
0078 
0079 static inline int mlx4_is_mf_bonded(struct mlx4_dev *dev)
0080 {
0081     return (mlx4_is_bonded(dev) && mlx4_is_mfunc(dev));
0082 }
0083 
0084 struct mlx4_port_map {
0085     u8  port1;
0086     u8  port2;
0087 };
0088 
0089 int mlx4_port_map_set(struct mlx4_dev *dev, struct mlx4_port_map *v2p);
0090 
0091 void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port);
0092 
0093 struct devlink_port *mlx4_get_devlink_port(struct mlx4_dev *dev, int port);
0094 
0095 #endif /* MLX4_DRIVER_H */