From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: davem@davemloft.net, grygorii.strashko@ti.com,
linux-omap@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, jiri@mellanox.com,
ilias.apalodimas@linaro.org
Subject: Re: [PATCH net-next 1/6] net: core: dev_addr_lists: add VID to device address
Date: Fri, 1 Mar 2019 14:21:08 +0200 [thread overview]
Message-ID: <20190301122107.GA4851@khorivan> (raw)
In-Reply-To: <462e8b28-fc15-9321-2144-038a18e37170@gmail.com>
On Wed, Feb 27, 2019 at 08:24:00PM -0800, Florian Fainelli wrote:
>On 2/26/2019 10:45 AM, Ivan Khoronzhuk wrote:
>> Despite this is supposed to be used for Ethernet VLANs, not Ethernet
>> addresses with space for VID also can reuse this, so VID is considered
>> as virtual ID extension, not belonging strictly to Ethernet VLAN VIDs,
>> and overall change can be named individual virtual device filtering
>> (IVDF).
>>
>> This patch adds VID tag at the end of each address. The actual
>> reserved address size is 32 bytes. For Ethernet addresses with 6 bytes
>> long that's possible to add tag w/o increasing address size. Thus,
>> each address for the case has 32 - 6 = 26 bytes to hold additional
>> info, say VID for virtual device addresses.
>>
>> Therefore, when addresses are synced to the address list of parent
>> device the address list of latter can contain separate addresses for
>> virtual devices. It allows to track separate address tables for
>> virtual devices if they present and the device can be placed on
>> any place of device tree as the address is propagated to to the end
>> real device thru *_sync()/ndo_set_rx_mode() APIs. Also it simplifies
>> handling VID addresses at real device when it supports IVDF.
>>
>> If parent device doesn't want to have virtual addresses in its address
>> space the vid_len has to be 0, thus its address space is "shrunk" to
>> the state as before this patch. For now it's 0 for every device. It
>> allows two devices with and w/o IVDF to be part of same bond device
>> for instance.
>>
>> The end real device supporting IVDF can retrieve VID tag from an
>> address and set it for a given virtual device only. By default, vid 0
>> is used for real devices to distinguish it from virtual addresses.
>>
>> See next patches to see how it's used.
>>
>> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
>> ---
>
>[snip]
>
>
>> @@ -1889,6 +1890,7 @@ struct net_device {
>> unsigned char perm_addr[MAX_ADDR_LEN];
>> unsigned char addr_assign_type;
>> unsigned char addr_len;
>> + unsigned char vid_len;
>
>Have not compiled or tested this patch series yet, but did you check
>that adding this member does not change the structure layout (you can
>use pahole for that purpose).
For ARM 32, on 1 hole less:
---------------------------
before (https://pastebin.com/DG1SVpFR):
/* size: 1344, cachelines: 21, members: 123 */
/* sum members: 1304, holes: 5, sum holes: 28 */
/* padding: 12 */
/* bit_padding: 31 bits */
after (https://pastebin.com/ZUMhxGkA):
/* size: 1344, cachelines: 21, members: 124 */
/* sum members: 1305, holes: 5, sum holes: 27 */
/* padding: 12 */
/* bit_padding: 31 bits */
For ARM 64, on 1 hole less:
---------------------------
before (https://pastebin.com/5CdTQWkc):
/* size: 2048, cachelines: 32, members: 120 */
/* sum members: 1972, holes: 7, sum holes: 48 */
/* padding: 28 */
/* bit_padding: 31 bits */
after (https://pastebin.com/32ktb1iV):
/* size: 2048, cachelines: 32, members: 121 */
/* sum members: 1973, holes: 7, sum holes: 47 */
/* padding: 28 */
/* bit_padding: 31 bits */
Looks Ok, but it depends on configuration ...
>
>> unsigned short neigh_priv_len;
>> unsigned short dev_id;
>> unsigned short dev_port;
>> @@ -4141,8 +4143,10 @@ int dev_addr_init(struct net_device *dev);
>>
>> /* Functions used for unicast addresses handling */
>> int dev_uc_add(struct net_device *dev, const unsigned char *addr);
>> +int dev_vid_uc_add(struct net_device *dev, const unsigned char *addr);
>> int dev_uc_add_excl(struct net_device *dev, const unsigned char *addr);
>> int dev_uc_del(struct net_device *dev, const unsigned char *addr);
>> +int dev_vid_uc_del(struct net_device *dev, const unsigned char *addr);
>> int dev_uc_sync(struct net_device *to, struct net_device *from);
>> int dev_uc_sync_multiple(struct net_device *to, struct net_device *from);
>> void dev_uc_unsync(struct net_device *to, struct net_device *from);
>> diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
>> index a6723b306717..e3c80e044b8c 100644
>> --- a/net/core/dev_addr_lists.c
>> +++ b/net/core/dev_addr_lists.c
>> @@ -545,6 +545,26 @@ int dev_addr_del(struct net_device *dev, const unsigned char *addr,
>> }
>> EXPORT_SYMBOL(dev_addr_del);
>>
>> +static int get_addr_len(struct net_device *dev)
>> +{
>> + return dev->addr_len + dev->vid_len;
>> +}
>> +
>> +static int set_vid_addr(struct net_device *dev, const unsigned char *addr,
>> + unsigned char *naddr)
>
>Having some kernel doc comments here would be nice to indicate that the
>return value is dev->addr_len, it was not obvious until I saw in the
>next function how you used it.
Agree
>
>> +{
>> + int i;
>> +
>> + if (!dev->vid_len)
>> + return dev->addr_len;
>> +
>> + memcpy(naddr, addr, dev->addr_len);
>> + for (i = 0; i < dev->vid_len; i++)
>> + naddr[dev->addr_len + i] = 0;
>
>memset(naddr + dev->addr_len, 0, dev->vid_len) would be more compact and
>maybe a little less error prone too?
Yes, would be
--
Regards,
Ivan Khoronzhuk
next prev parent reply other threads:[~2019-03-01 12:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-26 18:45 [PATCH net-next 0/6] net: add individual virtual device filtering Ivan Khoronzhuk
2019-02-26 18:45 ` [PATCH net-next 1/6] net: core: dev_addr_lists: add VID to device address Ivan Khoronzhuk
2019-02-28 4:24 ` Florian Fainelli
2019-03-01 12:21 ` Ivan Khoronzhuk [this message]
2019-02-26 18:45 ` [PATCH net-next 2/6] net: 8021q: vlan_dev: add vid tag to addresses of uc and mc lists Ivan Khoronzhuk
2019-02-28 4:09 ` Florian Fainelli
2019-03-01 12:24 ` Ivan Khoronzhuk
2019-03-02 3:19 ` Florian Fainelli
2019-02-26 18:45 ` [PATCH net-next 3/6] net: 8021q: vlan_dev: add vid tag for vlan device own address Ivan Khoronzhuk
2019-02-28 4:13 ` Florian Fainelli
2019-03-01 12:28 ` Ivan Khoronzhuk
2019-03-02 3:24 ` Florian Fainelli
2019-02-26 18:45 ` [PATCH net-next 4/6] ethernet: eth: add default vid len for all ehternet kind devices Ivan Khoronzhuk
2019-02-28 4:29 ` Florian Fainelli
2019-03-01 13:11 ` Ivan Khoronzhuk
2019-03-02 3:33 ` Florian Fainelli
2019-02-26 18:45 ` [PATCH net-next 5/6] net: ethernet: ti: cpsw: update mc filtering to use IVDF Ivan Khoronzhuk
2019-02-28 4:17 ` Florian Fainelli
2019-02-26 18:45 ` [PATCH net-next 6/6] net: ethernet: ti: cpsw: add macvlan and ucast/vlan filtering support Ivan Khoronzhuk
2019-02-28 0:23 ` [PATCH net-next 0/6] net: add individual virtual device filtering Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190301122107.GA4851@khorivan \
--to=ivan.khoronzhuk@linaro.org \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=grygorii.strashko@ti.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jiri@mellanox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).