Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp975536rwb; Wed, 28 Sep 2022 11:27:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM68L5tWKo5804ju0x/0Lm+Aq6GRJ4GQ1GKLVPntgtO0mHflMcAqXzxEN+FwBEoerVAvTHHD X-Received: by 2002:a17:907:7633:b0:781:96f0:1bfa with SMTP id jy19-20020a170907763300b0078196f01bfamr29058164ejc.321.1664389643051; Wed, 28 Sep 2022 11:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664389643; cv=none; d=google.com; s=arc-20160816; b=ugbAtt9FzMOJMDc1qSd9aZwpiiNfzhSv84ynt0aiPRkk3Zx0UT7StygIk/nNb5QSKn HBwqO1YKkwfrOubBE7FYRXNtHtxJPPo+vbGh6YUZZB9ApO8U788ebmFeBrIA5ITxJ9By pze/YVIYYkNc6Ib2dU60p55QxW/Q2HHllsv9gih1njFAKz/qswQ2c31wtjN87a7tUal7 4jBB1L44A6wFVpCpMzNS8bUaXwTM1M0lu09ZhsU6xbvseHBPPHqsCHREaj7TDR5QEhR2 UYXsWn53aJHT8wIQYCNxzTtphxWS5Kwv61oyB0VeIII19fvSZ4EbDoE9s2R0AUIfnEEY 0+Qw== 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 :message-id:date:subject:cc:to:from; bh=v3guaK/6qbTxdEvCjMWtly0gnipbt4g8iO5Cgv//8QU=; b=VAi1k2gf/tnR1XnRu7qtb1RpQ6EFxqoDXCSEGVxBS5IekT7titROZnAXT+UJFlxShY 3akQJd5by49YaQUQn/i4uEQ3cqIBHLmV3Wr9dn+dQYDYOt6DxYWYn11ogJw9huVbqVcF sSM2YlpFmK7/0Bsb5xk6Y0b68K6Ux12FwKNZ3+wCFdeMVV+vFNSiAvgOlKGlRmtMqqoX Uw80bvJFRHMGnlfXyTyB769nvFifIAd62a2ABMJS9dDw+OklzEVY37NuU8SN0ToTNBoT vszmZJNwQHCwED7ZVoZTKMwW3Ixgh9YQdgj1zr5XtJcIqlir3g3JrPGZPt0UuQGzHmP1 lxeA== 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 e13-20020a17090658cd00b00781b5892d43si7438863ejs.112.2022.09.28.11.26.58; Wed, 28 Sep 2022 11:27:23 -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 S234481AbiI1SQT (ORCPT + 99 others); Wed, 28 Sep 2022 14:16:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234315AbiI1SPw (ORCPT ); Wed, 28 Sep 2022 14:15:52 -0400 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 707F7DED6F; Wed, 28 Sep 2022 11:15:50 -0700 (PDT) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id ADE2A1884BC7; 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 962D62500709; Wed, 28 Sep 2022 18:15:41 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 0) id 7613E9EC000D; 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 C4F429120FED; Wed, 28 Sep 2022 17:52:03 +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 19:48:54 +0200 Message-Id: <20220928174854.117101-1-netdev@kapio-technology.com> X-Mailer: git-send-email 2.34.1 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