api to query mlx4_en device for given mlx4 device
PATCH 2/10 api to query mlx4_en device for given mlx4 device
mlx4_en: Add API to query interfaces for given internal device
Updated mlx4_en interface to provide a query function for it's internal net_device structure.
Signed-off-by Oren Duer <oren-VPRAkNaXOzVS1MOuV/[email protected]>
Signed-off-by Vu Pham <[email protected]>
drivers/net/mlx4/en_main.c | 14 ++++++++++++++ drivers/net/mlx4/intf.c | 30 ++++++++++++++++++++++++++++++ include/linux/mlx4/driver.h | 7 +++++++ 3 files changed, 51 insertions(+), 0 deletions(-)
mlx4: Add API to query interfaces for given internal device
Updated mlx4_en interface to provide a query function for it's internal net_device structure.
Signed-off-by Oren Duer <oren-VPRAkNaXOzVS1MOuV/[email protected]>
Signed-off-by Vu Pham <[email protected]>
drivers/net/mlx4/en_main.c | 14 ++++++++++++++ drivers/net/mlx4/intf.c | 30 ++++++++++++++++++++++++++++++ include/linux/mlx4/driver.h | 7 +++++++ 3 files changed, 51 insertions(+), 0 deletions(-)
drivers/net/mlx4/en_main.c +14 -0
@@ -262,10 +262,24 @@ err_free_res:return NULL ; } +enum mlx4_query_reply mlx4_en_query (void *endev_ptr,void *int_dev) +{ +struct mlx4_en_dev *mdev = endev_ptr; +struct net_device *netdev = int_dev; +int p; + +for (p =1 ; p <=MLX4_MAX_PORTS ; ++p) +if (mdev->pndev[p] == netdev) +return p; + +return MLX4_QUERY_NOT_MINE ; +} +static struct mlx4_interface mlx4_en_interface = { .add = mlx4_en_add, .remove = mlx4_en_remove, .event = mlx4_en_event, + .query = mlx4_en_query };static int __init mlx4_en_init (void )
drivers/net/mlx4/intf.c +30 -0
@@ -114,6 +114,36 @@ void mlx4_unregister_interface(struct mlx4_interface *intf) }EXPORT_SYMBOL_GPL (mlx4_unregister_interface); +struct mlx4_dev *mlx4_query_interface (void *int_dev,int *port) +{ +struct mlx4_priv *priv; +struct mlx4_device_context *dev_ctx; +enum mlx4_query_reply r; +unsigned long flags; + +mutex_lock (&intf_mutex); + +list_for_each_entry (priv, &dev_list, dev_list) { +spin_lock_irqsave (&priv->ctx_lock, flags); +list_for_each_entry (dev_ctx, &priv->ctx_list, list) { +if (!dev_ctx->intf->query) +continue ; + r = dev_ctx->intf->query (dev_ctx->context, int_dev); +if (r !=MLX4_QUERY_NOT_MINE ) { + *port = r; +spin_unlock_irqrestore (&priv->ctx_lock, flags); +mutex_unlock (&intf_mutex); +return &priv->dev; + } + } +spin_unlock_irqrestore (&priv->ctx_lock, flags); + } + +mutex_unlock (&intf_mutex); +return NULL ; +} +EXPORT_SYMBOL_GPL (mlx4_query_interface); +void mlx4_dispatch_event (struct mlx4_dev *dev,enum mlx4_dev_event type,int port) {struct mlx4_priv *priv =mlx4_priv (dev);
include/linux/mlx4/driver.h +7 -0
@@ -44,15 +44,22 @@ enum mlx4_dev_event { MLX4_DEV_EVENT_PORT_REINIT, }; +enum mlx4_query_reply { +MLX4_QUERY_NOT_MINE =-1 , +MLX4_QUERY_MINE_NOPORT =0 +}; +struct mlx4_interface {void * (*add) (struct mlx4_dev *dev);void (*remove)(struct mlx4_dev *dev,void *context);void (*event) (struct mlx4_dev *dev,void *context,enum mlx4_dev_event event,int port); +enum mlx4_query_reply (*query) (void *context,void *);struct list_head list; };int mlx4_register_interface (struct mlx4_interface *intf);void mlx4_unregister_interface (struct mlx4_interface *intf); +struct mlx4_dev *mlx4_query_interface (void *,int *port);#endif /* MLX4_DRIVER_H */
_______________________________________________
ewg mailing list [email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ewg