From patchwork Mon Jul 24 03:25:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13324380 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C47F2108 for ; Mon, 24 Jul 2023 10:54:31 +0000 (UTC) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E442A90; Mon, 24 Jul 2023 03:54:29 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fd190065a7so32623325e9.2; Mon, 24 Jul 2023 03:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690196068; x=1690800868; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jm2AmYXeSq7Hv1D3EYH8vxoR54aZLC/z7y6TUDXlfXw=; b=d9UMgBhPwr9+yS0cB8RgNScyWl6BhHVnRy8vrVAfOBKNk6b2xc+GWR5P56tHAcVBZT ckIoK4Eqrokqg700VJ3UnLuEVrOCK8jrRwCBv3BOS8u8NST3tSx+CltWurz5swA81Mfv A2Es1/fkBb+zs4Tv2VY8QEmqRZhwg4BZ7Ym4fqUQjP5d9XBO1OHi9GojHgOGw7V46DGX de/BS6iskM9gQnfDrdHjzG4mi4aQBOC5HguEkLHuomkhX6N0kordNQlWGky/OwvcKisN iP0OG97pozmINDmZ8dHhnrLnq4o534AgT29943ny4cLzpbvknbksrSq+f82ZoOIHFO7I vu+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690196068; x=1690800868; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jm2AmYXeSq7Hv1D3EYH8vxoR54aZLC/z7y6TUDXlfXw=; b=dSvhFHEwvlz2I0V269xO062qdp8QOI2MzyVlgYj3efoQaUvETQ1eusOnVd8RhJyuDK 4slC2GKD02JoDQ7MCTBWXKlaG2KednNL13hU0EGxV3EUl/L98U4S2iRRVpa4b0NH6O09 y8EHRROeNuq77Hch3YVyOapK8ptr06cObWiAIx3MVRQ9uAHlam5eQ7NbLiuRuNjKExhq ECJ6W9JJPPMiNB6TqrSnAfnk8H0MReI3RbzISD+T15GnuoghloOWnOv21z33sCj7kVhv WdMZ1LmZOLbcI84jkiZNoVl4puK9LuRM0e68DQXD49gyIhNP4n8omuPc85QeV962xOe7 Uw1g== X-Gm-Message-State: ABy/qLaTscQvWstrY4BOU4IeHt9qbUgAVP2F/z8OZa/hX18dvUgtPNLo PzBfanXjIuiZrMKLN0+wSX4= X-Google-Smtp-Source: APBJJlH/2BbzxEZghaykXJzZO9SLi2QkikMnuGRruKqHnDxO2xRWHD+bs5wItOEpHv6nJW1vwwaEmA== X-Received: by 2002:a5d:5909:0:b0:317:60ae:2ef5 with SMTP id v9-20020a5d5909000000b0031760ae2ef5mr1036070wrd.31.1690196068041; Mon, 24 Jul 2023 03:54:28 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id j6-20020adfff86000000b0031274a184d5sm12529631wrr.109.2023.07.24.03.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 03:54:27 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , Atin Bainada , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mark Brown , stable@vger.kernel.org Subject: [net PATCH 1/4] net: dsa: qca8k: enable use_single_write for qca8xxx Date: Mon, 24 Jul 2023 05:25:28 +0200 Message-Id: <20230724032531.15998-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The qca8xxx switch supports 2 way to write reg values, a slow way using mdio and a fast way by sending specially crafted mgmt packet to read/write reg. The fast way can support up to 32 bytes of data as eth packet are used to send/receive. This correctly works for almost the entire regmap of the switch but with the use of some kernel selftests for dsa drivers it was found a funny and interesting hw defect/limitation. For some specific reg, bulk write won't work and will result in writing only part of the requested regs resulting in half data written. This was especially hard to track and discover due to the total strangeness of the problem and also by the specific regs where this occurs. This occurs in the specific regs of the ATU table, where multiple entry needs to be written to compose the entire entry. It was discovered that with a bulk write of 12 bytes on QCA8K_REG_ATU_DATA0 only QCA8K_REG_ATU_DATA0 and QCA8K_REG_ATU_DATA2 were written, but QCA8K_REG_ATU_DATA1 was always zero. Tcpdump was used to make sure the specially crafted packet was correct and this was confirmed. The problem was hard to track as the lack of QCA8K_REG_ATU_DATA1 resulted in an entry somehow possible as the first bytes of the mac address are set in QCA8K_REG_ATU_DATA0 and the entry type is set in QCA8K_REG_ATU_DATA2. Funlly enough writing QCA8K_REG_ATU_DATA1 results in the same problem with QCA8K_REG_ATU_DATA2 empty and QCA8K_REG_ATU_DATA1 and QCA8K_REG_ATU_FUNC correctly written. A speculation on the problem might be that there are some kind of indirection internally when accessing these regs and they can't be accessed all together, due to the fact that it's really a table mapped somewhere in the switch SRAM. Even more funny is the fact that every other reg was tested with all kind of combination and they are not affected by this problem. Read operation was also tested and always worked so it's not affected by this problem. The problem is not present if we limit writing a single reg at times. To handle this hardware defect, enable use_single_write so that bulk api can correctly split the write in multiple different operation effectively reverting to a non-bulk write. Cc: Mark Brown Fixes: c766e077d927 ("net: dsa: qca8k: convert to regmap read/write API") Signed-off-by: Christian Marangi Cc: stable@vger.kernel.org --- drivers/net/dsa/qca/qca8k-8xxx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c index dee7b6579916..ae088a4df794 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -576,8 +576,11 @@ static struct regmap_config qca8k_regmap_config = { .rd_table = &qca8k_readable_table, .disable_locking = true, /* Locking is handled by qca8k read/write */ .cache_type = REGCACHE_NONE, /* Explicitly disable CACHE */ - .max_raw_read = 32, /* mgmt eth can read/write up to 8 registers at time */ - .max_raw_write = 32, + .max_raw_read = 32, /* mgmt eth can read up to 8 registers at time */ + /* ATU regs suffer from a bug where some data are not correctly + * written. Disable bulk write to correctly write ATU entry. + */ + .use_single_write = true, }; static int From patchwork Mon Jul 24 03:25:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13324381 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45DDE539F for ; Mon, 24 Jul 2023 10:54:32 +0000 (UTC) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D10BEE6; Mon, 24 Jul 2023 03:54:30 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31751d7d96eso978073f8f.1; Mon, 24 Jul 2023 03:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690196069; x=1690800869; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZuukWSSIlqBsc+jjkqa9IHelgU4HEBkAlLZYUDelO8M=; b=qKBwUn9uzu/b+NKMwT8JHRsWh7mw0jMgRMxpcirBzwnwd180sqhjHJ8Kw4W84xy7MK 1JbJGud4GyC49w7bT7EZ1DOf2BbdEqAyuAP+XjaYwo0obaQQpScUq5eWKnf+QH5lkWdS Pjf/l+l6N8uYqik3JqmZ2lzf9ZTZQIMPXQPmKLI1T3D01NIC4mbHEjFlIYQK6Bi6bouy 1rQJHm62iBoSLuPIAgLRa5Q9ItREg5lBZhNXF2znv6kSYYCTditN9Lfz45K7BgrSf5EG Muco895fHevbWPg7Nb9jM9JvTbM75QjbKosW6lkQAhS65Hmj1YDoQzKtUOgN7gqJk/nD 12gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690196069; x=1690800869; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZuukWSSIlqBsc+jjkqa9IHelgU4HEBkAlLZYUDelO8M=; b=FhVPQMlH3tqfKKLJVgeBoBqEjY9T1HRnagHEKUz8Q4Mojcc/iGWifAWUhMQHAE3MtR GuAAebxWH276ZJCF5Q/qzXV+MGK9hLZQ/eFgDG0QyzaM58MWE5/ycyTKU/lXwGHNIFGQ si/dyGyL8nwNPbWM1e/HsZXkB4rNwA7nV6u23x9n+OPFwZ3i4g56ByxY9oOEmJGX/wpl CGgQn322QasrzNdyf7VKf0fDkeZbKfVStbl7GLaa0rI3bmJS4CxLqPh2YTUGYKbQkVP+ Pj+bB3Sln71QgLLnIUdy9wZn+LC0BJ1AFZBpfQbaKXHOAygvhOIKDkFOhta462YYWrLM Hy3g== X-Gm-Message-State: ABy/qLZwbLJG61FhVxmqeExJVnUlSDWinbazNQctJlntL0auAv1RwfB/ 9PzgQ9mqDG3tlNsDnpHkFgM= X-Google-Smtp-Source: APBJJlFpKYZ0rfl6BcoKmne1Hm7Zln371bZfCqmtU+360RsDDJSJgeO+gcrcAQcXSBlI6XVqOIx9/w== X-Received: by 2002:a5d:638c:0:b0:314:10d8:b483 with SMTP id p12-20020a5d638c000000b0031410d8b483mr7199581wru.64.1690196069066; Mon, 24 Jul 2023 03:54:29 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id j6-20020adfff86000000b0031274a184d5sm12529631wrr.109.2023.07.24.03.54.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 03:54:28 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , Atin Bainada , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Subject: [net PATCH 2/4] net: dsa: qca8k: fix search_and_insert wrong handling of new rule Date: Mon, 24 Jul 2023 05:25:29 +0200 Message-Id: <20230724032531.15998-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230724032531.15998-1-ansuelsmth@gmail.com> References: <20230724032531.15998-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org On inserting a mdb entry, fdb_search_and_insert is used to add a port to the qca8k target entry in the FDB db. A FDB entry can't be modified so it needs to be removed and insert again with the new values. To detect if an entry already exist, the SEARCH operation is used and we check the aging of the entry. If the entry is not 0, the entry exist and we proceed to delete it. Current code have 2 main problem: - The condition to check if the FDB entry exist is wrong and should be the opposite. - When a FDB entry doesn't exist, aging was never actually set to the STATIC value resulting in allocating an invalid entry. Fix both problem by adding aging support to the function, calling the function with STATIC as aging by default and finally by correct the condition to check if the entry actually exist. Fixes: ba8f870dfa63 ("net: dsa: qca8k: add support for mdb_add/del") Signed-off-by: Christian Marangi Cc: stable@vger.kernel.org --- drivers/net/dsa/qca/qca8k-common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c index 8c2dc0e48ff4..4909603d07c8 100644 --- a/drivers/net/dsa/qca/qca8k-common.c +++ b/drivers/net/dsa/qca/qca8k-common.c @@ -244,7 +244,7 @@ void qca8k_fdb_flush(struct qca8k_priv *priv) } static int qca8k_fdb_search_and_insert(struct qca8k_priv *priv, u8 port_mask, - const u8 *mac, u16 vid) + const u8 *mac, u16 vid, u8 aging) { struct qca8k_fdb fdb = { 0 }; int ret; @@ -261,10 +261,12 @@ static int qca8k_fdb_search_and_insert(struct qca8k_priv *priv, u8 port_mask, goto exit; /* Rule exist. Delete first */ - if (!fdb.aging) { + if (fdb.aging) { ret = qca8k_fdb_access(priv, QCA8K_FDB_PURGE, -1); if (ret) goto exit; + } else { + fdb.aging = aging; } /* Add port to fdb portmask */ @@ -810,7 +812,8 @@ int qca8k_port_mdb_add(struct dsa_switch *ds, int port, const u8 *addr = mdb->addr; u16 vid = mdb->vid; - return qca8k_fdb_search_and_insert(priv, BIT(port), addr, vid); + return qca8k_fdb_search_and_insert(priv, BIT(port), addr, vid, + QCA8K_ATU_STATUS_STATIC); } int qca8k_port_mdb_del(struct dsa_switch *ds, int port, From patchwork Mon Jul 24 03:25:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13324382 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 589C0539E for ; Mon, 24 Jul 2023 10:54:33 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECA1990; Mon, 24 Jul 2023 03:54:31 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-31765aee31bso128007f8f.1; Mon, 24 Jul 2023 03:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690196070; x=1690800870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OEyWGecSm4CuQ74zs3MLXEg5kzDp90u6LK+sKJXsB/Y=; b=B07Xq67Ah++90WKhMX1GMpNC+E4X9DXk7Lz+6CBjPwH+uZ9JOMyCvW4oVr3tCfboZy H4soUZeTOOhYteIOmvZI3DV9oo3uMAvHkF5sf8LVeTQKpVu9+D4yXMiyEPnkJrBQZs5G lw7QHISG6LTo8Mav2202xrUQS5UigmCMtHIrAwkLmaKui1qvc3dVGNHZB+twCfMb8i7p So2k3vhM4sjwB1RG4gMN4cZoGofNIEV/MIRAU17hir4DWFqFhhlRm+qpy28tC49r6/IY Wpiw+LEUCifV5skNSHXp6s0RiKJ28Kcahw2oClXRuVEDKoMKDlU8SZHiKJsn+muSpjUj 7cwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690196070; x=1690800870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OEyWGecSm4CuQ74zs3MLXEg5kzDp90u6LK+sKJXsB/Y=; b=OgWbdeeh5aF/wj7YsiL3WCZNInLK8HKbgbAz9nEE9jV0waWd/kPSR7aW1flXGGhSN3 8mVeDYw/PAQ0xlVQTx+sTfqrrrhVSvKpDwj1ZwmrItqELfmwJPfyKB28ru3aY31U+75J roQZSRHF12BL+0dTrPOmZxo77AMyscnldhODwBsAGbLKzM8YeezpGtSGIjcyafW/aKN/ sSVN3r6UyakPQ93OFmi5TQezzGulKaG+B0ppfoLVFxcUHLZREiAsez4pvHSh2xUmdLtp ySwW3D6+tv3PFbivEUw392ZwcUXbUnkqcjJVc9FFBwhUrH029jhEqZ01Q23MYq6ejN3O r52Q== X-Gm-Message-State: ABy/qLbp7uIZmoYO7cAVaTnL1j1tv0/8nQSMB1qqCV0fZN/hTFHHmXYu IZIMhT+lZGrqhtKFLpUrgE8= X-Google-Smtp-Source: APBJJlGy2kE8D1SFU2thsf2H+b7Wre6gbhmnESK+alrHjr1iFzxm+EDmn8w9Z4MaKp0jwVQ6Qc3vag== X-Received: by 2002:adf:e94b:0:b0:315:a6a5:fe95 with SMTP id m11-20020adfe94b000000b00315a6a5fe95mr6070624wrn.52.1690196070065; Mon, 24 Jul 2023 03:54:30 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id j6-20020adfff86000000b0031274a184d5sm12529631wrr.109.2023.07.24.03.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 03:54:29 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , Atin Bainada , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Subject: [net PATCH 3/4] net: dsa: qca8k: fix broken search_and_del Date: Mon, 24 Jul 2023 05:25:30 +0200 Message-Id: <20230724032531.15998-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230724032531.15998-1-ansuelsmth@gmail.com> References: <20230724032531.15998-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org On deleting an MDB entry for a port, fdb_search_and_del is used. An FDB entry can't be modified so it needs to be deleted and readded again with the new portmap (and the port deleted as requested) We use the SEARCH operator to search the entry to edit by vid and mac address and then we check the aging if we actually found an entry. Currently the code suffer from a bug where the searched fdb entry is never read again with the found values (if found) resulting in the code always returning -EINVAL as aging was always 0. Fix this by correctly read the fdb entry after it was searched. Fixes: ba8f870dfa63 ("net: dsa: qca8k: add support for mdb_add/del") Signed-off-by: Christian Marangi Cc: stable@vger.kernel.org --- drivers/net/dsa/qca/qca8k-common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c index 4909603d07c8..b644c05337c5 100644 --- a/drivers/net/dsa/qca/qca8k-common.c +++ b/drivers/net/dsa/qca/qca8k-common.c @@ -293,6 +293,10 @@ static int qca8k_fdb_search_and_del(struct qca8k_priv *priv, u8 port_mask, if (ret < 0) goto exit; + ret = qca8k_fdb_read(priv, &fdb); + if (ret < 0) + goto exit; + /* Rule doesn't exist. Why delete? */ if (!fdb.aging) { ret = -EINVAL; From patchwork Mon Jul 24 03:25:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13324383 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A62AF5670 for ; Mon, 24 Jul 2023 10:54:34 +0000 (UTC) Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B06FBD; Mon, 24 Jul 2023 03:54:33 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-307d20548adso2924415f8f.0; Mon, 24 Jul 2023 03:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690196072; x=1690800872; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rf/Qc5DLJ/sURnSwOUoxd8QFaQVoKAa+14ueKRK2tOA=; b=nleeeYxFcHqL8srl5QGaYkU6wrOH5DoOGmiLLnSsSrXb06qA85CpS0i0B9l7cYujfF +9PbJsVOLM3razuOW/6Lnw8cw1rl7KIh4heSfVFDzWOWuHRkbVyzGKZTK6KgcRty5GYa naM0Hp1s6rBw2atG6o2o2LGaQRtztWrk5dkn0KX9w5spvoja10a5Fq8hTomNPrKdAXgn UtTyIU5QuF7mfenGFuxUTMYGKTb/g9XvQIsB1LwwgNTpB6UG9jnDOrsttczBAj4fRFUa DnBGLnaoYBgdoJw99fK9rBySONYouEMYw8C8kB7EsGS1n/mEugnj2TDHl5f87rSkKOo7 UeMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690196072; x=1690800872; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rf/Qc5DLJ/sURnSwOUoxd8QFaQVoKAa+14ueKRK2tOA=; b=L3w+0k7gypZqQsJ3vzYoDqvFUvLs6QQn1Zv1oc5jntRxO4Wn17KY8M08mSOA8b0Jyx A9TgsWDkn0esRE+xphBPjYcalaxZ5UC+dCEPnBd0PUvly07/6eBYzebB5rlCAtIPh0Nf Clb//ReoA6YFw4C7EvHCwaPJbcQ8NKvsL9BVidMRzt/sFDz3ewGPWk6/xEaNlr+1db6x cToEH7sA6MYf6MR0aodc1hi4fFLrgioMPXmxx1gX4Bw8Z0ACa26YYDW6C8+mSRi9kvK6 UgP7CagnTyd7EDauVtw1ykKn6ubPTz+8UOzamFweLWOhTCkM3azHCGMWbo5/ZJ+O3s5+ G6bw== X-Gm-Message-State: ABy/qLZuHBuUmmuy6HQxdcyg/l4EwSok+YTHlcq29iaWTS/ZG3VPt47u heb/9S6Wzac7EBNd/6Lcwks= X-Google-Smtp-Source: APBJJlHK3bok5QHzMzxZRNGwjnTbaJJhwuFS/9L0M8X72BtJuel/e6ii84jcbFxbAh7cYysuN/2iSw== X-Received: by 2002:a5d:4cc2:0:b0:315:a1bb:4d7b with SMTP id c2-20020a5d4cc2000000b00315a1bb4d7bmr5154424wrt.35.1690196071249; Mon, 24 Jul 2023 03:54:31 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id j6-20020adfff86000000b0031274a184d5sm12529631wrr.109.2023.07.24.03.54.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 03:54:30 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , Atin Bainada , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Subject: [net PATCH 4/4] net: dsa: qca8k: fix mdb add/del case with 0 VID Date: Mon, 24 Jul 2023 05:25:31 +0200 Message-Id: <20230724032531.15998-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230724032531.15998-1-ansuelsmth@gmail.com> References: <20230724032531.15998-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The qca8k switch doesn't support using 0 as VID and require a default VID to be always set. MDB add/del function doesn't currently handle this and are currently setting the default VID. Fix this by correctly handling this corner case and internally use the default VID for VID 0 case. Fixes: ba8f870dfa63 ("net: dsa: qca8k: add support for mdb_add/del") Signed-off-by: Christian Marangi Cc: stable@vger.kernel.org --- drivers/net/dsa/qca/qca8k-common.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c index b644c05337c5..13b8452ce5b2 100644 --- a/drivers/net/dsa/qca/qca8k-common.c +++ b/drivers/net/dsa/qca/qca8k-common.c @@ -816,6 +816,9 @@ int qca8k_port_mdb_add(struct dsa_switch *ds, int port, const u8 *addr = mdb->addr; u16 vid = mdb->vid; + if (!vid) + vid = QCA8K_PORT_VID_DEF; + return qca8k_fdb_search_and_insert(priv, BIT(port), addr, vid, QCA8K_ATU_STATUS_STATIC); } @@ -828,6 +831,9 @@ int qca8k_port_mdb_del(struct dsa_switch *ds, int port, const u8 *addr = mdb->addr; u16 vid = mdb->vid; + if (!vid) + vid = QCA8K_PORT_VID_DEF; + return qca8k_fdb_search_and_del(priv, BIT(port), addr, vid); }