summaryrefslogtreecommitdiffstats
path: root/drivers/net/mlx4/intf.c
diff options
context:
space:
mode:
authorEli Cohen2010-08-26 16:18:43 +0200
committerRoland Dreier2010-10-25 19:20:39 +0200
commit33c87f0af60146b375220809c1cb745ac1a86edf (patch)
treef22e0a1f8fbe6b05f2f15c517d3b8e9b77581662 /drivers/net/mlx4/intf.c
parentIB/uverbs: Return link layer type to userspace for query port operation (diff)
downloadkernel-qcow2-linux-33c87f0af60146b375220809c1cb745ac1a86edf.tar.gz
kernel-qcow2-linux-33c87f0af60146b375220809c1cb745ac1a86edf.tar.xz
kernel-qcow2-linux-33c87f0af60146b375220809c1cb745ac1a86edf.zip
mlx4_core: Allow protocol drivers to find corresponding interfaces
Add a mechanism for mlx4 protocol drivers to get a pointer to other drivers's device objects. For this, an exported function, mlx4_get_protocol_dev() is added, which allows a driver to get some other driver's device based on the protocol that the driver implements. Two protocols are added: MLX4_PROTOCOL_IB and MLX4_PROTOCOL_EN. This will be used in mlx4 IBoE support so that mlx4_ib can find the corresponding mlx4_en netdev. Signed-off-by: Eli Cohen <eli@mellanox.co.il> [ Clean up and rename a few things. - Roland ] Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/net/mlx4/intf.c')
-rw-r--r--drivers/net/mlx4/intf.c21
1 files changed, 21 insertions, 0 deletions
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)
mutex_unlock(&intf_mutex);
}
+
+void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port)
+{
+ struct mlx4_priv *priv = mlx4_priv(dev);
+ struct mlx4_device_context *dev_ctx;
+ unsigned long flags;
+ void *result = NULL;
+
+ spin_lock_irqsave(&priv->ctx_lock, flags);
+
+ list_for_each_entry(dev_ctx, &priv->ctx_list, list)
+ if (dev_ctx->intf->protocol == proto && dev_ctx->intf->get_dev) {
+ result = dev_ctx->intf->get_dev(dev, dev_ctx->context, port);
+ break;
+ }
+
+ spin_unlock_irqrestore(&priv->ctx_lock, flags);
+
+ return result;
+}
+EXPORT_SYMBOL_GPL(mlx4_get_protocol_dev);