From mboxrd@z Thu Jan 1 00:00:00 1970 From: ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman) Subject: Re: [patch net-next RFC 07/12] dsa: implement ndo_swdev_get_id Date: Sat, 23 Aug 2014 06:33:22 -0500 Message-ID: <87ioljv3st.fsf@x220.int.ebiederm.org> References: <1408637945-10390-1-git-send-email-jiri@resnulli.us> <1408637945-10390-8-git-send-email-jiri@resnulli.us> <20140821170645.GB10633@nanopsycho.lan> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Sergey Ryazanov , "jasowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org" , John Fastabend , Neil Jerram , Eric Dumazet , Andy Gospodarek , dev , Felix Fietkau , Florian Fainelli , ronye-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org, Jeff Kirsher , ogerlitz , Ben Hutchings , Lennert Buytenhek , Roopa Prabhu , Jamal Hadi Salim , Aviad Raveh , Nicolas Dichtel , vyasevic , Neil Horman , netdev , Stephen Hemminger , dborkman , David Miller To: Jiri Pirko Return-path: In-Reply-To: <20140821170645.GB10633-6KJVSR23iU5sFDB2n11ItA@public.gmane.org> (Jiri Pirko's message of "Thu, 21 Aug 2014 19:06:45 +0200") List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-yBygre7rU0TnMu66kgdUjQ@public.gmane.org Sender: "dev" List-Id: netdev.vger.kernel.org Jiri Pirko writes: > Thu, Aug 21, 2014 at 06:56:13PM CEST, f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: >>2014-08-21 9:19 GMT-07:00 Jiri Pirko : >>> Signed-off-by: Jiri Pirko >>> --- >>> net/dsa/Kconfig | 2 +- >>> net/dsa/slave.c | 16 ++++++++++++++++ >>> 2 files changed, 17 insertions(+), 1 deletion(-) >>> >>> diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig >>> index f5eede1..66c445a 100644 >>> --- a/net/dsa/Kconfig >>> +++ b/net/dsa/Kconfig >>> @@ -1,6 +1,6 @@ >>> config HAVE_NET_DSA >>> def_bool y >>> - depends on NETDEVICES && !S390 >>> + depends on NETDEVICES && NET_SWITCHDEV && !S390 >>> >>> # Drivers must select NET_DSA and the appropriate tagging format >>> >>> diff --git a/net/dsa/slave.c b/net/dsa/slave.c >>> index 45a1e34..e069ba3 100644 >>> --- a/net/dsa/slave.c >>> +++ b/net/dsa/slave.c >>> @@ -171,6 +171,19 @@ static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) >>> return -EOPNOTSUPP; >>> } >>> >>> +static int dsa_slave_swdev_get_id(struct net_device *dev, >>> + struct netdev_phys_item_id *psid) >>> +{ >>> + struct dsa_slave_priv *p = netdev_priv(dev); >>> + struct dsa_switch *ds = p->parent; >>> + u64 tmp = (u64) ds; >>> + >>> + /* TODO: add more sophisticated id generation */ >>> + memcpy(&psid->id, &tmp, sizeof(tmp)); >>> + psid->id_len = sizeof(tmp); >> >>There is already an unique id generated, which is the index in the >>switch tree, and which is stored in struct dsa_switch, so this could >>probably be simplified to: >> >>psid->id = ds->index > > That index is 0..n if I understand that correctly. That is not enough. > The point is to have unique id for every chip in the system. If we would > have 0,1,2... the collision is very likely. I am just kibitzing but ethernet switches capable of speaking stp require a mac address per port. So if you want a unique id I would pick one of your mac addresses, which should be uniuqe. I can understand low end devices where sophisticated things will never happen fudging on the mac address requirements but by the time you care I expect you have a mac address. Eric