Skip to contentSkip to conversation

mlx4_en: show device's port used

PATCH In review Eli Cohen 6 participants 6 messages May 25, 2010 – May 26, 2010 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

Eli Cohen

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/net/mlx4/en_netdev.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
drivers/net/mlx4/en_netdev.c +16 -0
index 73c3d20..5d6f811 100644
@@ -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;
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw
Quoted 3 lines

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.

How do other multi-port ethernet devices handle this? Seems that the cleanest way to handle this would be to add a place for drivers to set the port number, and export it to userspace in generic code (so everyone does it the same way).

Signature · 2 lines
Roland Dreier <[email protected]> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html

A message that is not in the archive (sent off-list or not yet received): adaaarnzzsc.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org

#3 lore raw
Quoted 8 lines · On Tue, 25 May 2010 09:55:47 -0700 Roland Dreier…
Quoted 3 lines

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.

How do other multi-port ethernet devices handle this? Seems that the cleanest way to handle this would be to add a place for drivers to set the port number, and export it to userspace in generic code (so everyone does it the same way).

There is a rarely used field in net_device called dev_id that looks like it was intended for this.

Signature · 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
In reply to a message not in the archive
Quoted 2 lines · Roland Dreier

How do other multi-port ethernet devices handle this?

I don't think there are many devices out there which have more than one port.

Quoted 3 lines

Seems that the
cleanest way to handle this would be to add a place for drivers to set the port number,

So this will require changing all the drivers to put some value there or we would need to use a default value of 1 for drivers that don't explicitly set a value.

Quoted 2 lines

and export it to userspace in generic code (so everyone does it the same way).

Something like ethtool? But we still need an entry under /sys/class/net/ethx/, right?

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20100525174214.GA14745-8YAHvHwT2UEvbXDkjdHOrw/[email protected]

#6 lore raw
Quoted 2 lines

I don't think there are many devices out there which have more than one port.

??

http://developer.intel.com/network/connectivity/solutions/gigabit.htm
http://www.broadcom.com/products/Ethernet-Controllers/Enterprise-Server/BCM5704C

etc

Quoted 3 lines

So this will require changing all the drivers to put some value there or we would need to use a default value of 1 for drivers that don't explicitly set a value.

Yes, just set a default value.

Quoted 5 lines
Quoted 2 lines

and export it to userspace in generic code (so everyone does it the same way).

Something like ethtool? But we still need an entry under /sys/class/net/ethx/, right?

It could be ethtool or a sysfs attr.

- R.

Signature · 6 lines
Roland Dreier <[email protected]> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): adask5fy8et.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org

#8 lore raw
Quoted 11 lines · Roland Dreier
Quoted 2 lines

I don't think there are many devices out there which have more than one port.

??

http://developer.intel.com/network/connectivity/solutions/gigabit.htm
http://www.broadcom.com/products/Ethernet-Controllers/Enterprise-Server/BCM5704C

etc

But they have different PCI function for each port and we have 2 ports on same PCI device

Tziporet

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html