[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100525135548.GA12749@mtldesk030.lab.mtl.com>
Date: Tue, 25 May 2010 16:55:48 +0300
From: Eli Cohen <eli@...lanox.co.il>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org,
Linux RDMA list <linux-rdma@...r.kernel.org>,
Roland Dreier <rdreier@...co.com>, yevgenyp@...lanox.co.il
Subject: [PATCH] mlx4_en: show device's port used
Add a sysfs file under /sys/class/net/<ethx> to show the port number within the
device that this network interface is using. This is needed as ConnectX devices
have two ports and it is useful to know which port the ethernet devices uses.
Signed-off-by: Eli Cohen <eli@...lanox.co.il>
---
drivers/net/mlx4/en_netdev.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index 73c3d20..5d6f811 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -871,6 +871,16 @@ err:
return -ENOMEM;
}
+static ssize_t show_port(struct device *d, struct device_attribute *attr,
+ char *buf)
+{
+ struct mlx4_en_priv *priv = netdev_priv(to_net_dev(d));
+
+ return sprintf(buf, "%d\n", priv->port);
+ return 0;
+}
+
+static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
void mlx4_en_destroy_netdev(struct net_device *dev)
{
@@ -1067,6 +1077,12 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
en_warn(priv, "Using %d TX rings\n", prof->tx_ring_num);
en_warn(priv, "Using %d RX rings\n", prof->rx_ring_num);
+ err = device_create_file(&dev->dev, &dev_attr_port);
+ if (err) {
+ mlx4_err(mdev, "failed to create sysfs file\n");
+ goto out;
+ }
+
priv->registered = 1;
queue_delayed_work(mdev->workqueue, &priv->stats_task, STATS_DELAY);
return 0;
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists