Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp999138rwb; Wed, 28 Sep 2022 11:47:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6LrMLJ1fNn9ylyOhKdPemQU5ArrvArlclPQ/oA1wPecjLSQuCaZcPEc6GFucJgPNq5Mkd9 X-Received: by 2002:aa7:c9c4:0:b0:452:1d98:1be3 with SMTP id i4-20020aa7c9c4000000b004521d981be3mr34588374edt.289.1664390846232; Wed, 28 Sep 2022 11:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664390846; cv=none; d=google.com; s=arc-20160816; b=qSTH9BfqGS76LZYuOXJ/c04+HfruHqAq7pebPRGSAECiRECpm9unj2CMEX0gjhSUzf 2SM2clirPqWxWHE1YhLrGqFdaS0+/9xLOzhdhwxiFnVCqq602fq2r/RiFSvxkQccxX4B xmryggeJq7wZ8f0oJM2Bsb9mZ4fQvNf08P/bYQGfF4eMFYp+W1JG0iy2T57WA21tv1m4 RR9uQrzHoXDNuSuYy2pdyTdqf9bCN0asf9SufqZtkq1cPlYkNrqz12flpbwHl4KBqaA7 zxQqN+D2gjSwh1oMvYc4m4JKbpp7Nwv8CmhTxpLYPec76mIxUUg+QuNF4ORNoB5YBpu6 KP1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=v3guaK/6qbTxdEvCjMWtly0gnipbt4g8iO5Cgv//8QU=; b=QYReQ/QBPpW1id+GdllB7uNMXZN0Q5QM9+zTmDesDdQBb9rTb937HsT3a5BCBf35lp 7sxxdJ9jPP4n9aPfXY6VW1//Uy0eqNoVfmpJxyUH5CXaO+uYtAO3VQDQ2Lb6E0OfSjaL qZTYmW6zY3KteKM/hnVWIFZyUPwz+jrU3wzv9WuoTPLKGnV5td4lcaaQfxWo3axoTUWg TrfmNDnLpEkOuD3zkpMr2aXCiCtFpC07vtmAuFrsTRlR3Vd70MegSj+Rm9o15Gtt7QUs TbwWPsNcwXVB/3LELEiHK9/bTVsFpe9hRKZJpK7CJ2cPdt1dGfKoSLvTta1asc/ZqHuc qoqw== 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 v7-20020a50a447000000b00454bae0cee0si5712935edb.406.2022.09.28.11.47.01; Wed, 28 Sep 2022 11:47:26 -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 S234222AbiI1SPv (ORCPT + 99 others); Wed, 28 Sep 2022 14:15:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233816AbiI1SPs (ORCPT ); Wed, 28 Sep 2022 14:15:48 -0400 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC82C889B; Wed, 28 Sep 2022 11:15:45 -0700 (PDT) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id 881BE1884BE7; Wed, 28 Sep 2022 18:15:41 +0000 (UTC) Received: from smtp.gigahost.dk (smtp.gigahost.dk [89.186.169.109]) by mailout.gigahost.dk (Postfix) with ESMTP id 7B72A25005A8; Wed, 28 Sep 2022 18:15:41 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 0) id 4CDAA9120FED; Wed, 28 Sep 2022 18:15:41 +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 CC68D9120FED; Wed, 28 Sep 2022 15:06:30 +0000 (UTC) From: Hans 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 v6 net-next 8/9] net: dsa: mv88e6xxx: add blackhole ATU entries Date: Wed, 28 Sep 2022 17:02:55 +0200 Message-Id: <20220928150256.115248-9-netdev@kapio-technology.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928150256.115248-1-netdev@kapio-technology.com> References: <20220928150256.115248-1-netdev@kapio-technology.com> MIME-Version: 1.0 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 From: "Hans J. Schultz" 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 | 78 ++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 71843fe87f77..a17f30e5d4a6 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2735,6 +2735,72 @@ static int mv88e6xxx_vlan_msti_set(struct dsa_switch *ds, return err; } +struct mv88e6xxx_vid_search_ctx { + u16 vid_search; + u16 fid_found; +}; + +static int mv88e6xxx_find_fid_on_matching_vid(struct mv88e6xxx_chip *chip, + const struct mv88e6xxx_vtu_entry *entry, + void *priv) +{ + struct mv88e6xxx_vid_search_ctx *ctx = priv; + + if (ctx->vid_search == entry->vid) { + ctx->fid_found = entry->fid; + return 1; + } + + return 0; +} + +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_vid_search_ctx ctx; + struct mv88e6xxx_atu_entry entry; + u16 fid = 0; + int err; + + ether_addr_copy(entry.mac, addr); + entry.portvec = MV88E6XXX_G1_ATU_DATA_PORT_VECTOR_NO_EGRESS; + entry.state = state; + entry.trunk = false; + + ctx.vid_search = vid; + mv88e6xxx_reg_lock(chip); + err = mv88e6xxx_vtu_walk(chip, mv88e6xxx_find_fid_on_matching_vid, &ctx); + mv88e6xxx_reg_unlock(chip); + if (err < 0) + return err; + if (err == 1) + fid = ctx.fid_found; + else + return -ENODATA; + + if (!fid) + return -ENODATA; + + 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 +2808,12 @@ 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) { + mv88e6xxx_blackhole_fdb_del(ds, addr, vid); + 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 +2834,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