From patchwork Tue Oct 18 16:56:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Schultz X-Patchwork-Id: 5680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp385220wrs; Wed, 19 Oct 2022 08:22:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4A2WIoo66VxKVMADUjkdKn8VZ7VurTYoybesi8hfYjZL+V8RU/rc+F8qpuCj6Xw//QE2w/ X-Received: by 2002:a17:906:8a61:b0:78d:9d00:c906 with SMTP id hy1-20020a1709068a6100b0078d9d00c906mr7243028ejc.321.1666192925623; Wed, 19 Oct 2022 08:22:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192925; cv=none; d=google.com; s=arc-20160816; b=LwDbTGWZyarpvtPzyHRrK/4mleoeYCWDXRAJX4kkNxGEbb65HmjzAVxhg8c1zInW4q qUYHKl5+jn6OK7xB9YvbJAGV54MErQMxhtY5YnxiYOgDjhz1uQuP7A8CWHJEFh1LbnRH Aw73gf8/N96p5YG+H3hBQanA5voJj6z+hvVFAxRqi6DWR3CmuQCaZWxAUFqHuY3FkyI5 x/ymoN0B+JPPzQBuTW43LqmWY025aXcIK6PFmHHUKQnIWxAl6CT3UixdUdag5LaVh5uG oll536QU27zC1aFZ5zTgjpZdL8Zw4B0olen/c/6a0JvzKu2t95kkoQqpKXF9RKMjLs1b mqJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=e0MfRQTrkNvMFhzePHNKiHyVMQtWiqTpE2d1mf1SVcY=; b=Rpt0K9kvBzfHf9Y2cWp/oMuMSNFqwkWIi6cjC1TvE5e9LMX1PD+XUh0HJI3A7YYZxE pBYNJTbhZ+YGjCwNkhJUz4uDDNlHWXcwVUF8UjTR2B68n64rm1oSJM1ux69xOKTy+fBz pzOG+1eXezsQHyenzBmy4PTbnrIUvuOS08aROEbm8QRb1uOfCUmtn0LylDHZjmqdkDQt uoopqTWaANpjHggG+7gOanSeBrJLqkInijAPqH+nW7Nu0t+15LzWVPQFttfE0kPtMjd8 nImBwo/5Wkd9xzkF+tekpwb8zJGMqbb7KNP708GJoQJOjAWd6hFXyBTAdv8wqDsWiPbD YgHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du6-20020a17090772c600b0078c0c866a18si15452804ejc.19.2022.10.19.08.21.40; Wed, 19 Oct 2022 08:22:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbiJSPUt (ORCPT + 99 others); Wed, 19 Oct 2022 11:20:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232406AbiJSPUd (ORCPT ); Wed, 19 Oct 2022 11:20:33 -0400 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83A4418B485; Wed, 19 Oct 2022 08:14:14 -0700 (PDT) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id 58AB51884ADE; Wed, 19 Oct 2022 15:12:49 +0000 (UTC) Received: from smtp.gigahost.dk (smtp.gigahost.dk [89.186.169.109]) by mailout.gigahost.dk (Postfix) with ESMTP id EF72C250052C; Wed, 19 Oct 2022 15:12:48 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 0) id D86329EC0002; Wed, 19 Oct 2022 15:12:48 +0000 (UTC) X-Screener-Id: 413d8c6ce5bf6eab4824d0abaab02863e8e3f662 Received: from fujitsu.vestervang (2-104-116-184-cable.dk.customer.tdc.net [2.104.116.184]) by smtp.gigahost.dk (Postfix) with ESMTPSA id F21D89120FED; Tue, 18 Oct 2022 16:57:01 +0000 (UTC) From: "Hans J. Schultz" To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, "Hans J. Schultz" , Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , Eric Dumazet , Paolo Abeni , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , UNGLinuxDriver@microchip.com, Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , Claudiu Manoil , Alexandre Belloni , Jiri Pirko , Ivan Vecera , Roopa Prabhu , Nikolay Aleksandrov , Shuah Khan , Russell King , Christian Marangi , Daniel Borkmann , Yuwei Wang , Petr Machata , Ido Schimmel , Florent Fourcot , Hans Schultz , Joachim Wiberg , Amit Cohen , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, bridge@lists.linux-foundation.org, linux-kselftest@vger.kernel.org Subject: [PATCH v8 net-next 11/12] net: dsa: mv88e6xxx: add blackhole ATU entries Date: Tue, 18 Oct 2022 18:56:18 +0200 Message-Id: <20221018165619.134535-12-netdev@kapio-technology.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018165619.134535-1-netdev@kapio-technology.com> References: <20221018165619.134535-1-netdev@kapio-technology.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747129912767924212?= X-GMAIL-MSGID: =?utf-8?q?1747129912767924212?= Blackhole FDB entries can now be added, deleted or replaced in the driver ATU. Signed-off-by: Hans J. Schultz --- drivers/net/dsa/mv88e6xxx/chip.c | 62 +++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 71843fe87f77..7a7cd1f0e735 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2735,6 +2735,58 @@ static int mv88e6xxx_vlan_msti_set(struct dsa_switch *ds, return err; } +static int mv88e6xxx_blackhole_fdb_loadpurge(struct dsa_switch *ds, + const unsigned char *addr, u16 vid, u8 state) +{ + struct mv88e6xxx_chip *chip = ds->priv; + struct mv88e6xxx_atu_entry entry; + struct mv88e6xxx_vtu_entry vlan; + + u16 fid = 0; + int err; + + if (vid == 0) { + fid = MV88E6XXX_FID_BRIDGED; + } else { + mv88e6xxx_reg_lock(chip); + err = mv88e6xxx_vtu_get(chip, vid, &vlan); + mv88e6xxx_reg_unlock(chip); + if (err) + return err; + + /* switchdev expects -EOPNOTSUPP to honor software VLANs */ + if (!vlan.valid) + return -EOPNOTSUPP; + + fid = vlan.fid; + } + + ether_addr_copy(entry.mac, addr); + entry.portvec = MV88E6XXX_G1_ATU_DATA_PORT_VECTOR_NO_EGRESS; + entry.state = state; + entry.trunk = false; + + mv88e6xxx_reg_lock(chip); + err = mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry); + mv88e6xxx_reg_unlock(chip); + + return err; +} + +static int mv88e6xxx_blackhole_fdb_add(struct dsa_switch *ds, + const unsigned char *addr, u16 vid) +{ + return mv88e6xxx_blackhole_fdb_loadpurge(ds, addr, vid, + MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); +} + +static int mv88e6xxx_blackhole_fdb_del(struct dsa_switch *ds, + const unsigned char *addr, u16 vid) +{ + return mv88e6xxx_blackhole_fdb_loadpurge(ds, addr, vid, + MV88E6XXX_G1_ATU_DATA_STATE_UC_UNUSED); +} + static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, u16 fdb_flags, struct dsa_db db) @@ -2742,9 +2794,10 @@ static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, struct mv88e6xxx_chip *chip = ds->priv; int err; - /* Ignore entries with flags set */ - if (fdb_flags) + if (fdb_flags & DSA_FDB_FLAG_LOCKED) return 0; + if (fdb_flags & DSA_FDB_FLAG_BLACKHOLE) + return mv88e6xxx_blackhole_fdb_add(ds, addr, vid); if (mv88e6xxx_port_is_locked(chip, port)) mv88e6xxx_atu_locked_entry_find_purge(ds, port, addr, vid); @@ -2765,9 +2818,10 @@ static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, bool locked_found = false; int err = 0; - /* Ignore entries with flags set */ - if (fdb_flags) + if (fdb_flags & DSA_FDB_FLAG_LOCKED) return 0; + if (fdb_flags & DSA_FDB_FLAG_BLACKHOLE) + return mv88e6xxx_blackhole_fdb_del(ds, addr, vid); if (mv88e6xxx_port_is_locked(chip, port)) locked_found = mv88e6xxx_atu_locked_entry_find_purge(ds, port, addr, vid);