diff mbox

mlx4_en: show device's port used

Message ID 20100525135548.GA12749@mtldesk030.lab.mtl.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Eli Cohen May 25, 2010, 1:55 p.m. UTC
None
diff mbox

Patch

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;