From patchwork Tue Feb 26 18:45:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 10830701 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 95FC41515 for ; Tue, 26 Feb 2019 18:47:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 854CB2D58C for ; Tue, 26 Feb 2019 18:47:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 797E42D6CC; Tue, 26 Feb 2019 18:47:26 +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 040292D58C for ; Tue, 26 Feb 2019 18:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729155AbfBZSqa (ORCPT ); Tue, 26 Feb 2019 13:46:30 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:40589 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728645AbfBZSqa (ORCPT ); Tue, 26 Feb 2019 13:46:30 -0500 Received: by mail-lj1-f196.google.com with SMTP id w6so11706122ljd.7 for ; Tue, 26 Feb 2019 10:46:29 -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; bh=ehPWfRVfK1p99dYox//webXUAklCK+7Ufmh1dOaEe+Y=; b=ILrAno4mM9tahTLrOcBdadOTIiUxI4PHdflVrHrcckIYitpumxGkRp0rBgo61bX34f RfpfYJ4MiLi+xU4iLOcHDcupGxq6AWsYNoBDZwbiZteNManCzuhujW0+na8YZhb2bUZT wF+bfMzHbSDPVez+BsPPK+f/OdUfSZOwdsrY6d2gQnrAzAmQU9/6+iWJN1bQfU3QyOtc X9dwoVWMzgy503gkboTMMFaX4Hh3bl9fABSvVlMJz7/VAIF04AIYSr1yeVsg4kSkmH19 5rXh7J32qtAmkPtRyiNxBLVX7ORTwSSzUt0vZKO7wBVJaUljc7QIUgJ7bQ4bQ2vgCmKg H0ZA== 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; bh=ehPWfRVfK1p99dYox//webXUAklCK+7Ufmh1dOaEe+Y=; b=k3D0adp8kLPyV/3FloH+4rrjCuekoTKCOoJZ5PJcmWXNQlHik9t8Dp088GIF85jmFy s6HduED+iFPkhkrB+ldLPgMnhaasUtBSi8wFjJGpStdxr+Im3g8lp+pKv8G4N7B4AIXG 8Di235i3YbMIDtC90a/jVQr01LFRGHro9TZpnjt+lW+NbxKb16r/l3dMceVbLKJAzFj9 giU5C+lXDSEWt3/1AwdmmNU9hAh8IsJwKDHkXRasEm9QG5usxWuAa0u0IRxZ70khulsW TX6T67KPZIFmFpZJr86F4haiiRnUWVc3H6BIn24+mYIjw6HcaUnfGKBHkkTfYvbL1Kgt Pl0g== X-Gm-Message-State: AHQUAuYmivkishfwU57ApywLEjoOEyP9IDJ0h3dHTHgRBNqfrUy0OVB+ YpUMAH3iPiKcpDoKQFhg6hnBiT8g3nI= X-Google-Smtp-Source: AHgI3Ia4lzOchB5cU6yO1VIBEX1Fqvjnp3CCQGJTZd2DwkO1jDotcuhXPbn9bFWtKH+AdsucFMOQjw== X-Received: by 2002:a2e:9d83:: with SMTP id c3mr14138162ljj.171.1551206788079; Tue, 26 Feb 2019 10:46:28 -0800 (PST) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id s129sm3015190lja.49.2019.02.26.10.46.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 10:46:27 -0800 (PST) From: Ivan Khoronzhuk To: davem@davemloft.net, grygorii.strashko@ti.com, f.fainelli@gmail.com Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jiri@mellanox.com, ilias.apalodimas@linaro.org, Ivan Khoronzhuk Subject: [PATCH net-next 0/6] net: add individual virtual device filtering Date: Tue, 26 Feb 2019 20:45:50 +0200 Message-Id: <20190226184556.16082-1-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 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 One of the reasons of this proposition is safety and performance - host should not receive traffic which is not designated for it. Some network devices can hold separate address tables for vlans and real device, but for some reason there is no possibility to apply it with generic net addressing scheme easily. At this moment the fastest solution is to add mcast/ucast entries for every created vlan including real device. But it not only consumes forwarding table but also adds holes in the filtering and thus wastes cpus cycles. This patchseries tries to correct core to assign mcast and ucast addresses only for vlans that really require it and as result an end driver can exclusively and simply set its rx filters. As an example it's implemented on cpsw TI driver, but generic changes provided by this series can be reused by other ethernet drivers having similar rx filter address possibilities. An address+vid is considered as separate address. The reserved device address length is 32 Bytes, for ethernet devices it's additional opportunity to pass auxiliary address info, like virtual ID identifying a device the address belongs to. This series makes it possible at least for ETH_P_8021Q. Thus end real device can setup separate tables for virtual devices just retrieving VID from the address. A device address space can maintain addresses and references on them separately for each virtual device if it needs so, or only addresses for real device (and all its vlans) it holds usually. A vlan device can be in any place of device chain upper real device, say smth like rdevice/bonding/vlan or even rdevice/macvlan/vlan. This series is verified on TI am572x EVM that can hold separate tables for vlans. Potentially it can be easily extended to netcp driver for keystone 2 boards (including k2g) and also new am6 chipsets. As a simple test case, different combinations of vlan+macvlan, macvlan+vlan were used and tested as with unicast as multicast addresses. Based on net-next/master It's continuation of RFC: [RFC PATCH net-next 0/5] net: allow hw addresses for virtual device https://lkml.org/lkml/2018/12/3/817 Ivan Khoronzhuk (6): net: core: dev_addr_lists: add VID to device address net: 8021q: vlan_dev: add vid tag to addresses of uc and mc lists net: 8021q: vlan_dev: add vid tag for vlan device own address ethernet: eth: add default vid len for all ehternet kind devices net: ethernet: ti: cpsw: update mc filtering to use IVDF net: ethernet: ti: cpsw: add macvlan and ucast/vlan filtering support drivers/net/ethernet/ti/Kconfig | 1 + drivers/net/ethernet/ti/cpsw.c | 139 ++++++++++++-------------------- include/linux/if_vlan.h | 2 + include/linux/netdevice.h | 4 + net/8021q/Kconfig | 12 +++ net/8021q/vlan.c | 3 + net/8021q/vlan.h | 2 + net/8021q/vlan_core.c | 25 ++++++ net/8021q/vlan_dev.c | 103 ++++++++++++++++++----- net/core/dev_addr_lists.c | 124 ++++++++++++++++++++++------ net/ethernet/eth.c | 10 ++- 11 files changed, 292 insertions(+), 133 deletions(-)