提交 64613d94 编写于 作者: S Saeed Mahameed 提交者: David S. Miller

net/mlx5_core: Extend struct mlx5_interface to support multiple protocols

Preparation for ethernet driver.
Signed-off-by: NAchiad Shochat <achiad@mellanox.com>
Signed-off-by: NSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: NEli Cohen <eli@mellanox.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 ce0f7509
...@@ -1362,6 +1362,7 @@ static struct mlx5_interface mlx5_ib_interface = { ...@@ -1362,6 +1362,7 @@ static struct mlx5_interface mlx5_ib_interface = {
.add = mlx5_ib_add, .add = mlx5_ib_add,
.remove = mlx5_ib_remove, .remove = mlx5_ib_remove,
.event = mlx5_ib_event, .event = mlx5_ib_event,
.protocol = MLX5_INTERFACE_PROTOCOL_IB,
}; };
static int __init mlx5_ib_init(void) static int __init mlx5_ib_init(void)
......
...@@ -908,6 +908,28 @@ void mlx5_unregister_interface(struct mlx5_interface *intf) ...@@ -908,6 +908,28 @@ void mlx5_unregister_interface(struct mlx5_interface *intf)
} }
EXPORT_SYMBOL(mlx5_unregister_interface); EXPORT_SYMBOL(mlx5_unregister_interface);
void *mlx5_get_protocol_dev(struct mlx5_core_dev *mdev, int protocol)
{
struct mlx5_priv *priv = &mdev->priv;
struct mlx5_device_context *dev_ctx;
unsigned long flags;
void *result = NULL;
spin_lock_irqsave(&priv->ctx_lock, flags);
list_for_each_entry(dev_ctx, &mdev->priv.ctx_list, list)
if ((dev_ctx->intf->protocol == protocol) &&
dev_ctx->intf->get_dev) {
result = dev_ctx->intf->get_dev(dev_ctx->context);
break;
}
spin_unlock_irqrestore(&priv->ctx_lock, flags);
return result;
}
EXPORT_SYMBOL(mlx5_get_protocol_dev);
static void mlx5_core_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event, static void mlx5_core_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event,
unsigned long param) unsigned long param)
{ {
......
...@@ -781,14 +781,22 @@ enum { ...@@ -781,14 +781,22 @@ enum {
MAX_MR_CACHE_ENTRIES = 16, MAX_MR_CACHE_ENTRIES = 16,
}; };
enum {
MLX5_INTERFACE_PROTOCOL_IB = 0,
MLX5_INTERFACE_PROTOCOL_ETH = 1,
};
struct mlx5_interface { struct mlx5_interface {
void * (*add)(struct mlx5_core_dev *dev); void * (*add)(struct mlx5_core_dev *dev);
void (*remove)(struct mlx5_core_dev *dev, void *context); void (*remove)(struct mlx5_core_dev *dev, void *context);
void (*event)(struct mlx5_core_dev *dev, void *context, void (*event)(struct mlx5_core_dev *dev, void *context,
enum mlx5_dev_event event, unsigned long param); enum mlx5_dev_event event, unsigned long param);
void * (*get_dev)(void *context);
int protocol;
struct list_head list; struct list_head list;
}; };
void *mlx5_get_protocol_dev(struct mlx5_core_dev *mdev, int protocol);
int mlx5_register_interface(struct mlx5_interface *intf); int mlx5_register_interface(struct mlx5_interface *intf);
void mlx5_unregister_interface(struct mlx5_interface *intf); void mlx5_unregister_interface(struct mlx5_interface *intf);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册