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: 152725 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7150421ljp; Mon, 3 Dec 2018 10:40:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ujed9LwNKOrkxxqg/gluC/v1NCIL2RFrzKy5Fco6DDucU3m6Bn3J4iHCd2v91pOMFNi0GN X-Received: by 2002:a62:a1a:: with SMTP id s26mr17078101pfi.31.1543862438560; Mon, 03 Dec 2018 10:40:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543862438; cv=none; d=google.com; s=arc-20160816; b=XQR/Fictccx7dy62kH4817tDNsK31+xUIMpmEAV47x3z14e7J5EcS51d7y/0dntmk9 rM1qTiMoyIHPcXl8feBAuVOBWjjOuja5gUD0Twfj/7gUS6eLlOJtLFYIIFSdTkvcLbaQ cZAumqrhsZtDm/F9oUOVr2B6rhnfE1zTwHOxzlTmZ6jKtHZWb0akvtjYZzHCjGCK8abd WBltG+RxD7BkBWFQFhpdiE+GHf8rBisXYqD3i3oJ6+wII7ViUEO3ev6yQyX76Pml5rwj ECKD8c9etFuXWXoUtf+RbvqV46mGHcIC8/Fdt5TBg7rNaDliSoJABrEjCLxm47W/gBag TdBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=AqR+/tdvN+T03MfMl2BZakLvSSDhyowAZhzj7me3ZY0=; b=XnXBXaGsVweWSHMNglfnI4DiCdyB8GrU60a4H2x6kPpTUSpuWZp01atRs2eemKIMzV M8fyz3MwL1g0JoBcwzaefy6CJ3IsEylmhyPWvQGy9edZNRhhOQuN5SX9EfSZo0JHJfmi 6wu/RaPrwf+fC2/l3Zwfofwo/x/8S523wc5MCVjnzOvfC1dvjMlV8jWWZqLm1autfJ3x fM9w6zQmEQrZgbhrCb1W03O6/NDDgrKvKrLndTsV/oxuDsnPpaBc4n7rORi5ot+KSeDO iiRziqoVTkxVtGeob+2bvMZp7CbhibIgvPrr+IP9gnk9MTe5LtpavNoQxmU01OxFIVun gLJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YaD4BKzh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h67si16366734pfb.146.2018.12.03.10.40.38; Mon, 03 Dec 2018 10:40:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YaD4BKzh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727037AbeLCSkk (ORCPT + 32 others); Mon, 3 Dec 2018 13:40:40 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:42865 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbeLCSkj (ORCPT ); Mon, 3 Dec 2018 13:40:39 -0500 Received: by mail-lf1-f65.google.com with SMTP id l10so9935942lfh.9 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=Ggd7ffGJnNuMWNNvK4P1fXe19m35Qa7eI8x4CK9WlsEpE/dYZ9tlq2u0xJ2ZHXTugh bGFZHWf1pnBmuUe1jUm2vnPubWDqSiLUFllzxBI4GTqFzkItSSzh7rbF8P8nfiCDRzd+ a5mr3npTnUQvnqrEAOWJSs38Jx47PK+5CoikEWfgKoogjTq/LA7lZEnFzazXHW70H6PE 5l04K15qRb461gXPoDR34ke8rLo2bh0ocdLSTHYw7zdXEAzWkm4mcbOAnNsxar2IBLBr Fe/r+CvqUkTb9gfSdcMkS/cIqNaMrjL1NzZc1487kXGQ20Dya3POsKRylp9/yKEiQNMo IqZg== X-Gm-Message-State: AA+aEWbZKhSiAnUUzgQd3N5yn31iVG24RwT4hllJDrcOnxuOyxdtBcmF N7ZVw4GAMcINtT7XO1olDMQDL1yadXyH0A== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.17.1 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);