Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp212707rwi; Sun, 9 Oct 2022 22:01:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5phPx8XKCziLic9YiTPLIhJbJZGNvpKGI4d8FMh/xJayYvRtvPVHaCphe1ZCcCzVSmA25n X-Received: by 2002:aa7:db4d:0:b0:458:908f:a372 with SMTP id n13-20020aa7db4d000000b00458908fa372mr15999824edt.248.1665378079798; Sun, 09 Oct 2022 22:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665378079; cv=none; d=google.com; s=arc-20160816; b=xCjYBEPSeL1A38IfeExNDMPki5eZW6FKA+7DfzcGHJstM8WifUI11YsIU1m94+NzJh Ol7NcFPybU0QwszkJFWprricYxnWucR8rUTQcU/EGQqTjCXCeo7nYNz7KmyfyTF10v/I 56XwXbMFTe+5CQnR+sNHp8LNPnsYRgmqfr9l3bYm95oaqEgO6pJYXDRAQpqAudxWQZ3u H9cb/4/rgMQ6PNKW/cCKM6TcznfSYEqFEAzwX0/AYrYMNJVOL5RFEsRy1/lrBOTMBAvk d7l7pAGX1Zai6W+HwmGKr+yCK5dFGnr2SNkoSKBooez0gASpxpTKSc78aWcVyMVAaLqY yfkw== 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=ZfYCZFJ4/yPzUuuycev/29H8k+cUPjNLZ6E8iaeVWjY=; b=Xkt0rSIkEABR+vka/Npt5VfR1+bUF/rjWWcKM9YZ6d9KNtABxjDM5MXJcEYSd66Qmn VfH5Qh/MgDMSxzBx935YthPQQ8qrSYMRKFl19q2kCwEEa17d7DDZ1l8OrejPW/mz3yDY eVFs0z5H/cnICrg/34LtZ5IUwCybvxdwYyn3cbtSpvbrYWarxLBmX+NkC99Jsjscqdae cOLDHwToj4+X7fpzWgNfahym6iJOZ1uhW23YFni8xkqPObNmlDMN3S7HXnZtzd/DS9Lq n0RXGc4CroSfIZzqU+VbXg0xcQFSTrBBRHao35ipgvjh3k5w2hPhar546916mtXcK6M0 fIYQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a056402191000b00450bda7e3fdsi10862550edz.28.2022.10.09.22.00.53; Sun, 09 Oct 2022 22:01:19 -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 S231352AbiJJE4i (ORCPT + 99 others); Mon, 10 Oct 2022 00:56:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231259AbiJJE4T (ORCPT ); Mon, 10 Oct 2022 00:56:19 -0400 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93533520AE; Sun, 9 Oct 2022 21:56:07 -0700 (PDT) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id 5811418843CD; Mon, 10 Oct 2022 04:56:03 +0000 (UTC) Received: from smtp.gigahost.dk (smtp.gigahost.dk [89.186.169.109]) by mailout.gigahost.dk (Postfix) with ESMTP id 1C041250556A; Mon, 10 Oct 2022 04:56:03 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 0) id 0EB5F9EC0001; Mon, 10 Oct 2022 04:56:03 +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 CCB289120FED; Sun, 9 Oct 2022 17:41:35 +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 v7 net-next 8/9] net: dsa: mv88e6xxx: add blackhole ATU entries Date: Sun, 9 Oct 2022 19:40:51 +0200 Message-Id: <20221009174052.1927483-9-netdev@kapio-technology.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221009174052.1927483-1-netdev@kapio-technology.com> References: <20221009174052.1927483-1-netdev@kapio-technology.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Content-Transfer-Encoding: 8bit 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 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 | 60 +++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 71843fe87f77..3c4ebb2a5301 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2735,6 +2735,56 @@ 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; +} + +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); +} + +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 +2792,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 +2816,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); -- 2.34.1