* [PATCH] net/core: use net_device dev_id to indicate port number
@ 2010-05-26 9:52 Eli Cohen
[not found] ` <20100526095200.GA7370-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Eli Cohen @ 2010-05-26 9:52 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. struct net_device conatins a field, dev_id, that can be used
for that. This patch adds a new macro, SET_NETDEV_DEV_ID(), to provide a
standard way to set the value of this field.
Also also make use of this feature in the mlx4_en driver to set the port
number; port numbers are zero based.
Signed-off-by: Eli Cohen <eli@mellanox.co.il>
---
drivers/net/mlx4/en_netdev.c | 1 +
include/linux/netdevice.h | 5 +++++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index 6c2b15b..612df1e 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_DEV_ID(dev, port - 1);
/*
* Initialize driver private data
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 3857517..8d5f2c7 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1080,6 +1080,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_DEV_ID(net, devid) ((net)->dev_id = (devid))
+
/**
* netif_napi_add - initialize a napi context
* @dev: network device
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <20100526095200.GA7370-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>]
* Re: [PATCH] net/core: use net_device dev_id to indicate port number [not found] ` <20100526095200.GA7370-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org> @ 2010-05-26 15:23 ` Stephen Hemminger 2010-05-26 15:27 ` Eli Cohen 0 siblings, 1 reply; 5+ messages in thread From: Stephen Hemminger @ 2010-05-26 15:23 UTC (permalink / raw) To: Eli Cohen Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA, rdreier-FYB4Gu1CFyUAvxtiuMwx3w, yevgenyp-VPRAkNaXOzVS1MOuV/RT9w On Wed, 26 May 2010 12:52:00 +0300 Eli Cohen <eli-VPRAkNaXOzVS1MOuV/RT9w@public.gmane.org> wrote: > Today, there are no means to know which port of a hardware device a netdev > interface uses. struct net_device conatins a field, dev_id, that can be used > for that. This patch adds a new macro, SET_NETDEV_DEV_ID(), to provide a > standard way to set the value of this field. > Also also make use of this feature in the mlx4_en driver to set the port > number; port numbers are zero based. Why is a macro wrapper needed? -- -- 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] 5+ messages in thread
* Re: [PATCH] net/core: use net_device dev_id to indicate port number 2010-05-26 15:23 ` Stephen Hemminger @ 2010-05-26 15:27 ` Eli Cohen 2010-05-26 15:33 ` Stephen Hemminger 0 siblings, 1 reply; 5+ messages in thread From: Eli Cohen @ 2010-05-26 15:27 UTC (permalink / raw) To: Stephen Hemminger; +Cc: Eli Cohen, davem, netdev, linux-rdma, rdreier, yevgenyp On Wed, May 26, 2010 at 08:23:06AM -0700, Stephen Hemminger wrote: > On Wed, 26 May 2010 12:52:00 +0300 > Eli Cohen <eli@mellanox.co.il> wrote: > > > Today, there are no means to know which port of a hardware device a netdev > > interface uses. struct net_device conatins a field, dev_id, that can be used > > for that. This patch adds a new macro, SET_NETDEV_DEV_ID(), to provide a > > standard way to set the value of this field. > > Also also make use of this feature in the mlx4_en driver to set the port > > number; port numbers are zero based. > > Why is a macro wrapper needed? > I guess for the same reason we use SET_NETDEV_DEV - to provide a consistent interface for setting this value... ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/core: use net_device dev_id to indicate port number 2010-05-26 15:27 ` Eli Cohen @ 2010-05-26 15:33 ` Stephen Hemminger 2010-05-26 16:09 ` Eli Cohen 0 siblings, 1 reply; 5+ messages in thread From: Stephen Hemminger @ 2010-05-26 15:33 UTC (permalink / raw) To: Eli Cohen; +Cc: Eli Cohen, davem, netdev, linux-rdma, rdreier, yevgenyp On Wed, 26 May 2010 18:27:30 +0300 Eli Cohen <eli@dev.mellanox.co.il> wrote: > On Wed, May 26, 2010 at 08:23:06AM -0700, Stephen Hemminger wrote: > > On Wed, 26 May 2010 12:52:00 +0300 > > Eli Cohen <eli@mellanox.co.il> wrote: > > > > > Today, there are no means to know which port of a hardware device a netdev > > > interface uses. struct net_device conatins a field, dev_id, that can be used > > > for that. This patch adds a new macro, SET_NETDEV_DEV_ID(), to provide a > > > standard way to set the value of this field. > > > Also also make use of this feature in the mlx4_en driver to set the port > > > number; port numbers are zero based. > > > > Why is a macro wrapper needed? > > > > I guess for the same reason we use SET_NETDEV_DEV - to provide a > consistent interface for setting this value... SET_NETDEV_DEV macro exists because at the time 2.5 kernel was being developed it was important to be able to maintain source compatibility between 2.4 and 2.6 (nee 2.5) drivers. Since 2.4 did not have sysfs, the macro was a mechanism to allow the same code to run on both kernel versions. Your situation is different, just use dev_id and update documentation if you need to. -- ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/core: use net_device dev_id to indicate port number 2010-05-26 15:33 ` Stephen Hemminger @ 2010-05-26 16:09 ` Eli Cohen 0 siblings, 0 replies; 5+ messages in thread From: Eli Cohen @ 2010-05-26 16:09 UTC (permalink / raw) To: Stephen Hemminger Cc: Eli Cohen, davem-fT/PcQaiUtIeIZ0/mPfg9Q, netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA, rdreier-FYB4Gu1CFyUAvxtiuMwx3w, yevgenyp-VPRAkNaXOzVS1MOuV/RT9w On Wed, May 26, 2010 at 08:33:18AM -0700, Stephen Hemminger wrote: > > SET_NETDEV_DEV macro exists because at the time 2.5 kernel was being developed > it was important to be able to maintain source compatibility between 2.4 and > 2.6 (nee 2.5) drivers. Since 2.4 did not have sysfs, the macro was a mechanism > to allow the same code to run on both kernel versions. > > Your situation is different, just use dev_id and update documentation if > you need to. > OK, great. Things get much much simpler :-) I'll send another patch for mlx4_en only. -- 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] 5+ messages in thread
end of thread, other threads:[~2010-05-26 16:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-26 9:52 [PATCH] net/core: use net_device dev_id to indicate port number Eli Cohen
[not found] ` <20100526095200.GA7370-8YAHvHwT2UEvbXDkjdHOrw/a8Rv0c6iv@public.gmane.org>
2010-05-26 15:23 ` Stephen Hemminger
2010-05-26 15:27 ` Eli Cohen
2010-05-26 15:33 ` Stephen Hemminger
2010-05-26 16:09 ` Eli Cohen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox