* [PATCH] net/core: Save the port number a netdevice uses
@ 2010-05-26 8:17 Eli Cohen
2010-05-26 8:39 ` David Miller
0 siblings, 1 reply; 9+ messages in thread
From: Eli Cohen @ 2010-05-26 8:17 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-rdma, rdreier, yevgenyp
Today, there are no means to know which port of a hardware device a netdev
interface uses. This patch adds a new field to struct net_device that is used
to store this value. The network driver should use the SET_NETDEV_PORT_NUM()
macro to set the port number for the device it manages. For drivers that do not
set a value, a default value of 1 is set at alloc_netdev_mq().
This patch also makes use of this feature in the mlx4_en driver.
Signed-off-by: Eli Cohen <eli@mellanox.co.il>
---
drivers/net/mlx4/en_netdev.c | 1 +
include/linux/netdevice.h | 6 ++++++
net/core/dev.c | 1 +
net/core/net-sysfs.c | 2 ++
4 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index 6c2b15b..d3df609 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -978,6 +978,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
}
SET_NETDEV_DEV(dev, &mdev->dev->pdev->dev);
+ SET_NETDEV_PORT_NUM(dev, port);
/*
* Initialize driver private data
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 3857517..2a52a6a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -843,6 +843,7 @@ struct net_device {
unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
unsigned char addr_len; /* hardware address length */
unsigned short dev_id; /* for shared network cards */
+ unsigned short port_num; /* for multiport devices */
struct netdev_hw_addr_list uc; /* Secondary unicast
mac addresses */
@@ -1080,6 +1081,11 @@ static inline void *netdev_priv(const struct net_device *dev)
*/
#define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype))
+/*
+ * Set the port number of the physical device that this port net device uses
+ */
+#define SET_NETDEV_PORT_NUM(net, portnum) ((net)->port_num = (portnum))
+
/**
* netif_napi_add - initialize a napi context
* @dev: network device
diff --git a/net/core/dev.c b/net/core/dev.c
index 264137f..8e2f5df 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5471,6 +5471,7 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
dev->_tx = tx;
dev->num_tx_queues = queue_count;
dev->real_num_tx_queues = queue_count;
+ dev->port_num = 1;
dev->gso_max_size = GSO_MAX_SIZE;
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 59cfc7d..c3d9b39 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -97,6 +97,7 @@ NETDEVICE_SHOW(ifindex, fmt_dec);
NETDEVICE_SHOW(features, fmt_long_hex);
NETDEVICE_SHOW(type, fmt_dec);
NETDEVICE_SHOW(link_mode, fmt_dec);
+NETDEVICE_SHOW(port_num, fmt_dec);
/* use same locking rules as GIFHWADDR ioctl's */
static ssize_t show_address(struct device *dev, struct device_attribute *attr,
@@ -299,6 +300,7 @@ static struct device_attribute net_class_attributes[] = {
__ATTR(features, S_IRUGO, show_features, NULL),
__ATTR(type, S_IRUGO, show_type, NULL),
__ATTR(link_mode, S_IRUGO, show_link_mode, NULL),
+ __ATTR(port_num, S_IRUGO, show_port_num, NULL),
__ATTR(address, S_IRUGO, show_address, NULL),
__ATTR(broadcast, S_IRUGO, show_broadcast, NULL),
__ATTR(carrier, S_IRUGO, show_carrier, NULL),
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] net/core: Save the port number a netdevice uses
2010-05-26 8:17 [PATCH] net/core: Save the port number a netdevice uses Eli Cohen
@ 2010-05-26 8:39 ` David Miller
[not found] ` <20100526.013926.28807066.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2010-05-26 8:39 UTC (permalink / raw)
To: eli; +Cc: netdev, linux-rdma, rdreier, yevgenyp
From: Eli Cohen <eli@mellanox.co.il>
Date: Wed, 26 May 2010 11:17:02 +0300
> Today, there are no means to know which port of a hardware device a netdev
> interface uses. This patch adds a new field to struct net_device that is used
> to store this value. The network driver should use the SET_NETDEV_PORT_NUM()
> macro to set the port number for the device it manages. For drivers that do not
> set a value, a default value of 1 is set at alloc_netdev_mq().
> This patch also makes use of this feature in the mlx4_en driver.
>
> Signed-off-by: Eli Cohen <eli@mellanox.co.il>
We have an existing dev_id, use it.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] net/core: Save the port number a netdevice uses
[not found] ` <20100526.013926.28807066.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2010-05-26 8:45 ` Eli Cohen
[not found] ` <20100526084523.GA28748-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: Eli Cohen @ 2010-05-26 8:45 UTC (permalink / raw)
To: David Miller
Cc: eli-VPRAkNaXOzVS1MOuV/RT9w, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA, rdreier-FYB4Gu1CFyUAvxtiuMwx3w,
yevgenyp-VPRAkNaXOzVS1MOuV/RT9w
On Wed, May 26, 2010 at 01:39:26AM -0700, David Miller wrote:
> From: Eli Cohen <eli-VPRAkNaXOzVS1MOuV/RT9w@public.gmane.org>
> Date: Wed, 26 May 2010 11:17:02 +0300
>
> > Today, there are no means to know which port of a hardware device a netdev
> > interface uses. This patch adds a new field to struct net_device that is used
> > to store this value. The network driver should use the SET_NETDEV_PORT_NUM()
> > macro to set the port number for the device it manages. For drivers that do not
> > set a value, a default value of 1 is set at alloc_netdev_mq().
> > This patch also makes use of this feature in the mlx4_en driver.
> >
> > Signed-off-by: Eli Cohen <eli-VPRAkNaXOzVS1MOuV/RT9w@public.gmane.org>
>
> We have an existing dev_id, use it.
Do you think we should use dev_id also for the sysfs file name so
every driver can choose to interpret this field as it chooses to, or
should I keep the sysfs file name as "port_number"?
--
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] 9+ messages in thread
* Re: [PATCH] net/core: Save the port number a netdevice uses
[not found] ` <20100526084523.GA28748-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>
@ 2010-05-26 8:55 ` David Miller
2010-05-26 9:08 ` Eli Cohen
0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2010-05-26 8:55 UTC (permalink / raw)
To: eli-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb
Cc: eli-VPRAkNaXOzVS1MOuV/RT9w, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA, rdreier-FYB4Gu1CFyUAvxtiuMwx3w,
yevgenyp-VPRAkNaXOzVS1MOuV/RT9w
From: Eli Cohen <eli-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
Date: Wed, 26 May 2010 11:45:23 +0300
> Do you think we should use dev_id also for the sysfs file name so
> every driver can choose to interpret this field as it chooses to, or
> should I keep the sysfs file name as "port_number"?
What's wrong with using the existing dev_id sysfs file name and saying
that it means the port number of the card?
Nobody, and I really mean nobody, uses this thing any more.
It used to be a way for devices like the qeth driver to get it's
IPV6 EUI48 value set properly for local IPV6 addresses assigned
to the device, but that got fixed in a different way.
So we can use this value however we wish now, and it defaults to zero
for every single device now, and is propagated across VLAN devices,
which is perfect.
--
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] 9+ messages in thread
* Re: [PATCH] net/core: Save the port number a netdevice uses
2010-05-26 8:55 ` David Miller
@ 2010-05-26 9:08 ` Eli Cohen
[not found] ` <20100526090850.GB28748-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: Eli Cohen @ 2010-05-26 9:08 UTC (permalink / raw)
To: David Miller; +Cc: eli, netdev, linux-rdma, rdreier, yevgenyp
On Wed, May 26, 2010 at 01:55:26AM -0700, David Miller wrote:
> From: Eli Cohen <eli@dev.mellanox.co.il>
> Date: Wed, 26 May 2010 11:45:23 +0300
>
>
> What's wrong with using the existing dev_id sysfs file name and saying
> that it means the port number of the card?
>
> Nobody, and I really mean nobody, uses this thing any more.
>
> It used to be a way for devices like the qeth driver to get it's
> IPV6 EUI48 value set properly for local IPV6 addresses assigned
> to the device, but that got fixed in a different way.
>
> So we can use this value however we wish now, and it defaults to zero
> for every single device now, and is propagated across VLAN devices,
> which is perfect.
OK. So if I understand you correctly, you think that I should not
bother to set a default value of 1. Each driver that cares about the
value of this field, will set it however they want.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] net/core: Save the port number a netdevice uses
[not found] ` <20100526090850.GB28748-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>
@ 2010-05-26 9:16 ` David Miller
[not found] ` <20100526.021635.179940939.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2010-06-02 16:42 ` Ben Hutchings
0 siblings, 2 replies; 9+ messages in thread
From: David Miller @ 2010-05-26 9:16 UTC (permalink / raw)
To: eli-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb
Cc: eli-VPRAkNaXOzVS1MOuV/RT9w, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA, rdreier-FYB4Gu1CFyUAvxtiuMwx3w,
yevgenyp-VPRAkNaXOzVS1MOuV/RT9w
From: Eli Cohen <eli-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
Date: Wed, 26 May 2010 12:08:52 +0300
> So if I understand you correctly, you think that I should not bother
> to set a default value of 1. Each driver that cares about the value
> of this field, will set it however they want.
I actually mean that the value "0" should mean the first port,
the value "1" should mean the second port, etc.
--
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] 9+ messages in thread
* Re: [PATCH] net/core: Save the port number a netdevice uses
[not found] ` <20100526.021635.179940939.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2010-05-26 9:19 ` Eli Cohen
0 siblings, 0 replies; 9+ messages in thread
From: Eli Cohen @ 2010-05-26 9:19 UTC (permalink / raw)
To: David Miller
Cc: eli-VPRAkNaXOzVS1MOuV/RT9w, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA, rdreier-FYB4Gu1CFyUAvxtiuMwx3w,
yevgenyp-VPRAkNaXOzVS1MOuV/RT9w
On Wed, May 26, 2010 at 02:16:35AM -0700, David Miller wrote:
>
> I actually mean that the value "0" should mean the first port,
> the value "1" should mean the second port, etc.
OK, thanks for clarifying. I'll send a new patch soon.
--
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] 9+ messages in thread
* Re: [PATCH] net/core: Save the port number a netdevice uses
2010-05-26 9:16 ` David Miller
[not found] ` <20100526.021635.179940939.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2010-06-02 16:42 ` Ben Hutchings
[not found] ` <1275496949.2115.18.camel-xQnnTUlwzDrdvaEqJLTMTA9jg9n5Vt1AMm0uRHvK7Nw@public.gmane.org>
1 sibling, 1 reply; 9+ messages in thread
From: Ben Hutchings @ 2010-06-02 16:42 UTC (permalink / raw)
To: David Miller
Cc: Eli Cohen, netdev, linux-rdma, Roland Dreier, Yevgeny Petrilin
On Wed, 2010-05-26 at 02:16 -0700, David Miller wrote:
> From: Eli Cohen <eli@dev.mellanox.co.il>
> Date: Wed, 26 May 2010 12:08:52 +0300
>
> > So if I understand you correctly, you think that I should not bother
> > to set a default value of 1. Each driver that cares about the value
> > of this field, will set it however they want.
>
> I actually mean that the value "0" should mean the first port,
> the value "1" should mean the second port, etc.
There's a compatibility problem here though: when user-space looks at
this number it can't tell whether "0" really means the first port or
that the driver isn't setting dev_id. In order to tell that it would
have to check the driver or kernel version too, and this is really nasty
(what if the driver was backported?). So I think that 1-based numbering
for drivers that previously didn't set dev_id.
Why does this matter? I'm maintaining the firmware update program for
Solarflare NICs under Linux. Some of the firmware it updates is
per-port and some of it is per-board. It needs to be able to tell which
net and PCI devices are associated with the same board. At the moment
it works on the basis of PCI addresses, but this is unreliable in the
presence of virtualisation. It would be better to use board serial
number and the port identifier that I just changed the driver to use,
but since there are existing driver versions always leave dev_id = 0, I
it needs to be able to tell whether dev_id is meaningful.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] net/core: Save the port number a netdevice uses
[not found] ` <1275496949.2115.18.camel-xQnnTUlwzDrdvaEqJLTMTA9jg9n5Vt1AMm0uRHvK7Nw@public.gmane.org>
@ 2010-06-02 17:12 ` David Miller
0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2010-06-02 17:12 UTC (permalink / raw)
To: bhutchings-s/n/eUQHGBpZroRs9YW3xA
Cc: eli-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
rdreier-FYB4Gu1CFyUAvxtiuMwx3w, yevgenyp-VPRAkNaXOzVS1MOuV/RT9w
From: Ben Hutchings <bhutchings-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org>
Date: Wed, 02 Jun 2010 17:42:29 +0100
> On Wed, 2010-05-26 at 02:16 -0700, David Miller wrote:
>> From: Eli Cohen <eli-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
>> Date: Wed, 26 May 2010 12:08:52 +0300
>>
>> > So if I understand you correctly, you think that I should not bother
>> > to set a default value of 1. Each driver that cares about the value
>> > of this field, will set it however they want.
>>
>> I actually mean that the value "0" should mean the first port,
>> the value "1" should mean the second port, etc.
>
> There's a compatibility problem here though: when user-space looks at
> this number it can't tell whether "0" really means the first port or
> that the driver isn't setting dev_id.
That's perfect, it means we don't have to add explicit settings to
drivers which driver only one port. Ie. the vast majority of
cases.
--
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] 9+ messages in thread
end of thread, other threads:[~2010-06-02 17:12 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-26 8:17 [PATCH] net/core: Save the port number a netdevice uses Eli Cohen
2010-05-26 8:39 ` David Miller
[not found] ` <20100526.013926.28807066.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2010-05-26 8:45 ` Eli Cohen
[not found] ` <20100526084523.GA28748-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>
2010-05-26 8:55 ` David Miller
2010-05-26 9:08 ` Eli Cohen
[not found] ` <20100526090850.GB28748-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>
2010-05-26 9:16 ` David Miller
[not found] ` <20100526.021635.179940939.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2010-05-26 9:19 ` Eli Cohen
2010-06-02 16:42 ` Ben Hutchings
[not found] ` <1275496949.2115.18.camel-xQnnTUlwzDrdvaEqJLTMTA9jg9n5Vt1AMm0uRHvK7Nw@public.gmane.org>
2010-06-02 17:12 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).