diff options
| -rw-r--r-- | drivers/net/mlx4/en_main.c | 15 | ||||
| -rw-r--r-- | drivers/net/mlx4/intf.c | 21 | ||||
| -rw-r--r-- | include/linux/mlx4/driver.h | 9 |
3 files changed, 42 insertions, 3 deletions
diff --git a/drivers/net/mlx4/en_main.c b/drivers/net/mlx4/en_main.c index 97934f1ec53a..b2df3eeb1598 100644 --- a/drivers/net/mlx4/en_main.c +++ b/drivers/net/mlx4/en_main.c | |||
| @@ -124,6 +124,13 @@ static int mlx4_en_get_profile(struct mlx4_en_dev *mdev) | |||
| 124 | return 0; | 124 | return 0; |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | static void *mlx4_en_get_netdev(struct mlx4_dev *dev, void *ctx, u8 port) | ||
| 128 | { | ||
| 129 | struct mlx4_en_dev *endev = ctx; | ||
| 130 | |||
| 131 | return endev->pndev[port]; | ||
| 132 | } | ||
| 133 | |||
| 127 | static void mlx4_en_event(struct mlx4_dev *dev, void *endev_ptr, | 134 | static void mlx4_en_event(struct mlx4_dev *dev, void *endev_ptr, |
| 128 | enum mlx4_dev_event event, int port) | 135 | enum mlx4_dev_event event, int port) |
| 129 | { | 136 | { |
| @@ -282,9 +289,11 @@ err_free_res: | |||
| 282 | } | 289 | } |
| 283 | 290 | ||
| 284 | static struct mlx4_interface mlx4_en_interface = { | 291 | static struct mlx4_interface mlx4_en_interface = { |
| 285 | .add = mlx4_en_add, | 292 | .add = mlx4_en_add, |
| 286 | .remove = mlx4_en_remove, | 293 | .remove = mlx4_en_remove, |
| 287 | .event = mlx4_en_event, | 294 | .event = mlx4_en_event, |
| 295 | .get_dev = mlx4_en_get_netdev, | ||
| 296 | .protocol = MLX4_PROTOCOL_EN, | ||
| 288 | }; | 297 | }; |
| 289 | 298 | ||
| 290 | static int __init mlx4_en_init(void) | 299 | static int __init mlx4_en_init(void) |
diff --git a/drivers/net/mlx4/intf.c b/drivers/net/mlx4/intf.c index 555067802751..73c94fcdfddf 100644 --- a/drivers/net/mlx4/intf.c +++ b/drivers/net/mlx4/intf.c | |||
| @@ -161,3 +161,24 @@ void mlx4_unregister_device(struct mlx4_dev *dev) | |||
| 161 | 161 | ||
| 162 | mutex_unlock(&intf_mutex); | 162 | mutex_unlock(&intf_mutex); |
| 163 | } | 163 | } |
| 164 | |||
| 165 | void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port) | ||
| 166 | { | ||
| 167 | struct mlx4_priv *priv = mlx4_priv(dev); | ||
| 168 | struct mlx4_device_context *dev_ctx; | ||
| 169 | unsigned long flags; | ||
| 170 | void *result = NULL; | ||
| 171 | |||
| 172 | spin_lock_irqsave(&priv->ctx_lock, flags); | ||
| 173 | |||
| 174 | list_for_each_entry(dev_ctx, &priv->ctx_list, list) | ||
| 175 | if (dev_ctx->intf->protocol == proto && dev_ctx->intf->get_dev) { | ||
| 176 | result = dev_ctx->intf->get_dev(dev, dev_ctx->context, port); | ||
| 177 | break; | ||
| 178 | } | ||
| 179 | |||
| 180 | spin_unlock_irqrestore(&priv->ctx_lock, flags); | ||
| 181 | |||
| 182 | return result; | ||
| 183 | } | ||
| 184 | EXPORT_SYMBOL_GPL(mlx4_get_protocol_dev); | ||
diff --git a/include/linux/mlx4/driver.h b/include/linux/mlx4/driver.h index 53c5fdb6eac4..f407cd4bfb34 100644 --- a/include/linux/mlx4/driver.h +++ b/include/linux/mlx4/driver.h | |||
| @@ -44,15 +44,24 @@ enum mlx4_dev_event { | |||
| 44 | MLX4_DEV_EVENT_PORT_REINIT, | 44 | MLX4_DEV_EVENT_PORT_REINIT, |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | enum mlx4_protocol { | ||
| 48 | MLX4_PROTOCOL_IB, | ||
| 49 | MLX4_PROTOCOL_EN, | ||
| 50 | }; | ||
| 51 | |||
| 47 | struct mlx4_interface { | 52 | struct mlx4_interface { |
| 48 | void * (*add) (struct mlx4_dev *dev); | 53 | void * (*add) (struct mlx4_dev *dev); |
| 49 | void (*remove)(struct mlx4_dev *dev, void *context); | 54 | void (*remove)(struct mlx4_dev *dev, void *context); |
| 50 | void (*event) (struct mlx4_dev *dev, void *context, | 55 | void (*event) (struct mlx4_dev *dev, void *context, |
| 51 | enum mlx4_dev_event event, int port); | 56 | enum mlx4_dev_event event, int port); |
| 57 | void * (*get_dev)(struct mlx4_dev *dev, void *context, u8 port); | ||
| 52 | struct list_head list; | 58 | struct list_head list; |
| 59 | enum mlx4_protocol protocol; | ||
| 53 | }; | 60 | }; |
| 54 | 61 | ||
| 55 | int mlx4_register_interface(struct mlx4_interface *intf); | 62 | int mlx4_register_interface(struct mlx4_interface *intf); |
| 56 | void mlx4_unregister_interface(struct mlx4_interface *intf); | 63 | void mlx4_unregister_interface(struct mlx4_interface *intf); |
| 57 | 64 | ||
| 65 | void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port); | ||
| 66 | |||
| 58 | #endif /* MLX4_DRIVER_H */ | 67 | #endif /* MLX4_DRIVER_H */ |
