From patchwork Mon Dec 3 18:40:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 10710361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F9A518A7 for ; Mon, 3 Dec 2018 18:40:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8324B2B0D0 for ; Mon, 3 Dec 2018 18:40:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 776C52B13A; Mon, 3 Dec 2018 18:40:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 120422B0D0 for ; Mon, 3 Dec 2018 18:40:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726870AbeLCSkl (ORCPT ); Mon, 3 Dec 2018 13:40:41 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36009 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbeLCSkk (ORCPT ); Mon, 3 Dec 2018 13:40:40 -0500 Received: by mail-lf1-f68.google.com with SMTP id a16so9966646lfg.3 for ; Mon, 03 Dec 2018 10:40:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AqR+/tdvN+T03MfMl2BZakLvSSDhyowAZhzj7me3ZY0=; b=YaD4BKzhs0h80iAS6DLry0wrLCOm+kNnEJBcvZO8qowRaipNimLGISvXZTTISIAQBd 4wgK7t6/ElreUMZowwv6K6eqM/v2dATuPJg9MaTdBYCC6fG68dEbhz7Vy/by4wgPjz28 Ayx7AiZ6U+wjM60HgTE8O7y6xOs9aXl/b76jY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AqR+/tdvN+T03MfMl2BZakLvSSDhyowAZhzj7me3ZY0=; b=KuKlN7tAnL5MVcMYch6QP0QM+U2GIyr4xAmgQ0NJwHxSV58B5m959fojKVrnxKEXh7 HJaYZusK/zzseoKZ+z5g1Prru34XyvN+MLalyP4SD2n8EMso0cm+5POpGT+inVZ6k3Pr caN7RH4qJDuLYb5NX3B+RGjvUctzoLOy1stDDskWofQk8Gc5vEACF+nj0JaXtDuitMTr Kd6RoZPt4TRGj/j0jJ5lz7JtlExpsVuQiS3N62gbfVCZKxm3wZP8p9VLb9bqRFL2yEPy O0TLCwzECT5h4Ug5ZPVW/YvagFpQw37hPwx1TFc+MryB67wFTH1d4BnX/1UV1Q7thn/0 i/RA== X-Gm-Message-State: AA+aEWblakgWDQRf+cARMGqco8uQTOGTmzTqS56Ux9aV3sPQD+JZn5JQ ZPPBcWYwt5Yp9USNjKcL2SLViQ== X-Google-Smtp-Source: AFSGD/WuA0Ki0SJfIvQBbk9ywQ8RcQEjitFRR+Gh0ivVr+aKQhOB0EyqkBXV6ldkFLi9yGuAWY8JZQ== X-Received: by 2002:a19:920a:: with SMTP id u10mr9678312lfd.122.1543862433315; Mon, 03 Dec 2018 10:40:33 -0800 (PST) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id d23sm2518513lfc.11.2018.12.03.10.40.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 10:40:32 -0800 (PST) From: Ivan Khoronzhuk To: davem@davemloft.net, grygorii.strashko@ti.com Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jiri@mellanox.com, Ivan Khoronzhuk Subject: [RFC PATCH net-next 4/5] net: ethernet: add default vid len for all ehternet kind devices Date: Mon, 3 Dec 2018 20:40:22 +0200 Message-Id: <20181203184023.3430-5-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181203184023.3430-1-ivan.khoronzhuk@linaro.org> References: <20181203184023.3430-1-ivan.khoronzhuk@linaro.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP By default every ethernet netdev needs vid len = 2 bytes to be able to hold up to 4096 vids. So set it for every eth device to be correct, except vlan devs. In order to shrink all addresses of devices above vlan, the vid_len for vlan dev = 0, as result all suckers sync their addresses to common base not taking in to account vid part (vid_len of "to" devices is important only). And only vlan device is the source of addresses with actual its vid set, propagating it to parent devices while rx_mode(). Also, don't bother those devices that at this moment not moved to vlan addressing scheme, so while end ethernet device is created - set vid_len to 0, thus, while syncing, its address space is concatenated to one dimensional like usual, and who needs vlan addresses to be separate - set it to VLAN_VID_TYPE_SIZE. When number of devices supporting new vlan addressing scheme becomes more than simple ones, it can be reversed, disabling it for those who don't need. This vid_len should be placed under smth like CONFIG_8021Q_ADDR_FLT. There is another decision - is to inherit vid_len or some feature flag from end root device in order to all upper devices have vlan extended address space only if exact end real device have such capability. But I didn't, because it requires more changes and probably I'm not familiar with all places where it should be inherited, I would appreciate if someone can guid where it's applicable, then it could become a little bit more limited. Signed-off-by: Ivan Khoronzhuk --- net/8021q/vlan_dev.c | 1 + net/ethernet/eth.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index f6bcd847509e..c2d934251e77 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -896,6 +896,7 @@ void vlan_setup(struct net_device *dev) dev->min_mtu = 0; dev->max_mtu = ETH_MAX_MTU; + dev->vid_len = 0; eth_zero_addr(dev->broadcast); } diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index 58933fa50bb5..52f90cefb6de 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -363,6 +363,7 @@ void ether_setup(struct net_device *dev) dev->min_mtu = ETH_MIN_MTU; dev->max_mtu = ETH_DATA_LEN; dev->addr_len = ETH_ALEN; + dev->vid_len = NET_802Q_VID_TSIZE; dev->tx_queue_len = DEFAULT_TX_QUEUE_LEN; dev->flags = IFF_BROADCAST|IFF_MULTICAST; dev->priv_flags |= IFF_TX_SKB_SHARING; @@ -390,8 +391,18 @@ EXPORT_SYMBOL(ether_setup); struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs, unsigned int rxqs) { - return alloc_netdev_mqs(sizeof_priv, "eth%d", NET_NAME_UNKNOWN, - ether_setup, txqs, rxqs); + struct net_device *dev; + + dev = alloc_netdev_mqs(sizeof_priv, "eth%d", NET_NAME_UNKNOWN, + ether_setup, txqs, rxqs); + + /* TODO: When number of real ehternet devices supporting vlan + * addressing scheme becomes more than simple ones, it should + * be removed, disabling it (by dev->vid_len = 0) for those + * who doesn't support it + */ + dev->vid_len = 0; + return dev; } EXPORT_SYMBOL(alloc_etherdev_mqs);