* [PATCH] mlx4_en: show device's port used
@ 2010-05-25 13:55 Eli Cohen
2010-05-25 16:55 ` Roland Dreier
0 siblings, 1 reply; 6+ messages in thread
From: Eli Cohen @ 2010-05-25 13:55 UTC (permalink / raw)
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Linux RDMA list, Roland Dreier,
yevgenyp-VPRAkNaXOzVS1MOuV/RT9w
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-VPRAkNaXOzVS1MOuV/RT9w@public.gmane.org>
---
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 linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mlx4_en: show device's port used
2010-05-25 13:55 [PATCH] mlx4_en: show device's port used Eli Cohen
@ 2010-05-25 16:55 ` Roland Dreier
[not found] ` <adaaarnzzsc.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Roland Dreier @ 2010-05-25 16:55 UTC (permalink / raw)
To: Eli Cohen; +Cc: davem, netdev, Linux RDMA list, yevgenyp
> 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).
--
Roland Dreier <rolandd@cisco.com> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mlx4_en: show device's port used
[not found] ` <adaaarnzzsc.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
@ 2010-05-25 17:12 ` Stephen Hemminger
2010-05-25 17:42 ` Eli Cohen
1 sibling, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2010-05-25 17:12 UTC (permalink / raw)
To: Roland Dreier
Cc: Eli Cohen, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
netdev-u79uwXL29TY76Z2rM5mHXA, Linux RDMA list,
yevgenyp-VPRAkNaXOzVS1MOuV/RT9w
On Tue, 25 May 2010 09:55:47 -0700
Roland Dreier <rdreier-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org> wrote:
> > 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.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mlx4_en: show device's port used
[not found] ` <adaaarnzzsc.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
2010-05-25 17:12 ` Stephen Hemminger
@ 2010-05-25 17:42 ` Eli Cohen
[not found] ` <20100525174214.GA14745-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>
1 sibling, 1 reply; 6+ messages in thread
From: Eli Cohen @ 2010-05-25 17:42 UTC (permalink / raw)
To: Roland Dreier
Cc: Eli Cohen, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
netdev-u79uwXL29TY76Z2rM5mHXA, Linux RDMA list,
yevgenyp-VPRAkNaXOzVS1MOuV/RT9w
On Tue, May 25, 2010 at 09:55:47AM -0700, Roland Dreier wrote:
>
> 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.
> 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.
> 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mlx4_en: show device's port used
[not found] ` <20100525174214.GA14745-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>
@ 2010-05-25 21:32 ` Roland Dreier
[not found] ` <adask5fy8et.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Roland Dreier @ 2010-05-25 21:32 UTC (permalink / raw)
To: Eli Cohen
Cc: Eli Cohen, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
netdev-u79uwXL29TY76Z2rM5mHXA, Linux RDMA list,
yevgenyp-VPRAkNaXOzVS1MOuV/RT9w
> 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
> 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.
> > 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.
--
Roland Dreier <rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org> || 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mlx4_en: show device's port used
[not found] ` <adask5fy8et.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
@ 2010-05-26 11:35 ` Tziporet Koren
0 siblings, 0 replies; 6+ messages in thread
From: Tziporet Koren @ 2010-05-26 11:35 UTC (permalink / raw)
To: Roland Dreier
Cc: Eli Cohen, Eli Cohen,
davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Linux RDMA list,
Yevgeny Petrilin
On 5/26/2010 12:32 AM, Roland Dreier wrote:
> > 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-05-26 11:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-25 13:55 [PATCH] mlx4_en: show device's port used Eli Cohen
2010-05-25 16:55 ` Roland Dreier
[not found] ` <adaaarnzzsc.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
2010-05-25 17:12 ` Stephen Hemminger
2010-05-25 17:42 ` Eli Cohen
[not found] ` <20100525174214.GA14745-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>
2010-05-25 21:32 ` Roland Dreier
[not found] ` <adask5fy8et.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
2010-05-26 11:35 ` Tziporet Koren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox