Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3761538pxt; Tue, 10 Aug 2021 10:42:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJ/8mVElr99KOLe03Ll4byHtk4M7+OkjTmqvLP7c4hjD9lejWehDbS/UDNAadx/SLhq0VY X-Received: by 2002:a17:906:58c7:: with SMTP id e7mr28178559ejs.197.1628617360151; Tue, 10 Aug 2021 10:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617360; cv=none; d=google.com; s=arc-20160816; b=F4SHjjSf9j8uVDxXq8Gq0z80oXuOaGQYs+xN53Au4lD0uhFgsICAbXSuoX9Pa0A/Lm PY7Wd8Fl2uB9gzFRRhpmdfoCSdP+9kV+1WoqZ+2xRYMKu/LlZGkhTz0+gC4xj1HC1KMG Oi96s1tH7ZE3nlo9Ojioeykf46qrUM94a9lMHm6RIEgnpjVWSYHqueOhvbgAej5yI30O 7PW5RahXPPFeFLuHr2G90HOkzjARfMFYlTfjBCOJx1RNhfouQ8dsv0lXED2Pl+jlXGW7 vaspNmki1ggwcnPLLK/kmItcCX9zEPjxFbQQKhKvLkDVL28Tuodjl0e+sZk+AMoewZpD 0Cfw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KJ0Tp4hLCUFqPpa9WWs9UVw9qKxop25bPNRjI7VD4uw=; b=Cz5dAcERkPeOCuXrl+j/NZKXsupVtd+5KMJCrDqb4oAhLWKmTV9mTRpiSj/6fleTR9 wEkXxE1Qb1qDPGiSaaJ90ko2DpmLxgnoxKk2mypeRiWtFPRx2xF370cV/oHD99EDSwCc v317BPi/4mm9+QnvIIfOQpNp1tdmNy1Olb7M1HzCyoM9PvVFY7LsV3lPwvBjVs754tjx GUPkEzAgVCVMoc7tfHiC1xytHwzmR8+itjf6HtMi2skYZ+Cdgt7byrZvksz/qMShVUTF qRGELZeixTB1UrnETgaejZfvKoVOGIEdc4e8W8io4ojd1FfFEGWnizasMLIXCVVf91W3 DpTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B22WRzdB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h8si22943574ejj.422.2021.08.10.10.42.15; Tue, 10 Aug 2021 10:42:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B22WRzdB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231851AbhHJRhv (ORCPT + 99 others); Tue, 10 Aug 2021 13:37:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:43594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233965AbhHJRgJ (ORCPT ); Tue, 10 Aug 2021 13:36:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7F046610E9; Tue, 10 Aug 2021 17:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628616931; bh=ql3WK06ce4y9XwlSZdJk4v6L9Na7PFGpHvHYh5uojO8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B22WRzdByhWvfEOjcklLeCk+WUpYqI9RAkQHiC3XWMIT2DAjMvMEL/HqqowiXUnZv 85qQPbS18iLkTtre/9qkPlPzimnC7K7ns/z6p+F+MxHhJxoGn2pbIEvPYS8OR9vZM3 5PHHKvkTTmvqDLtbOuOT+V50MqvYTsXZ6vNi6d5A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 21/85] net: dsa: sja1105: overwrite dynamic FDB entries with static ones in .port_fdb_add Date: Tue, 10 Aug 2021 19:29:54 +0200 Message-Id: <20210810172948.913290545@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172948.192298392@linuxfoundation.org> References: <20210810172948.192298392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit e11e865bf84e3c6ea91563ff3e858cfe0e184bd2 ] The SJA1105 switch family leaves it up to software to decide where within the FDB to install a static entry, and to concatenate destination ports for already existing entries (the FDB is also used for multicast entries), it is not as simple as just saying "please add this entry". This means we first need to search for an existing FDB entry before adding a new one. The driver currently manages to fool itself into thinking that if an FDB entry already exists, there is nothing to be done. But that FDB entry might be dynamically learned, case in which it should be replaced with a static entry, but instead it is left alone. This patch checks the LOCKEDS ("locked/static") bit from found FDB entries, and lets the code "goto skip_finding_an_index;" if the FDB entry was not static. So we also need to move the place where we set LOCKEDS = true, to cover the new case where a dynamic FDB entry existed but was dynamic. Fixes: 291d1e72b756 ("net: dsa: sja1105: Add support for FDB and MDB management") Fixes: 1da73821343c ("net: dsa: sja1105: Add FDB operations for P/Q/R/S series") Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/sja1105/sja1105_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 034f1b50ab28..54b77eafdf63 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1007,7 +1007,7 @@ int sja1105et_fdb_add(struct dsa_switch *ds, int port, * mask? If yes, we need to do nothing. If not, we need * to rewrite the entry by adding this port to it. */ - if (l2_lookup.destports & BIT(port)) + if ((l2_lookup.destports & BIT(port)) && l2_lookup.lockeds) return 0; l2_lookup.destports |= BIT(port); } else { @@ -1038,6 +1038,7 @@ int sja1105et_fdb_add(struct dsa_switch *ds, int port, index, NULL, false); } } + l2_lookup.lockeds = true; l2_lookup.index = sja1105et_fdb_index(bin, way); rc = sja1105_dynamic_config_write(priv, BLK_IDX_L2_LOOKUP, @@ -1108,10 +1109,10 @@ int sja1105pqrs_fdb_add(struct dsa_switch *ds, int port, rc = sja1105_dynamic_config_read(priv, BLK_IDX_L2_LOOKUP, SJA1105_SEARCH, &l2_lookup); if (rc == 0) { - /* Found and this port is already in the entry's + /* Found a static entry and this port is already in the entry's * port mask => job done */ - if (l2_lookup.destports & BIT(port)) + if ((l2_lookup.destports & BIT(port)) && l2_lookup.lockeds) return 0; /* l2_lookup.index is populated by the switch in case it * found something. @@ -1134,10 +1135,11 @@ int sja1105pqrs_fdb_add(struct dsa_switch *ds, int port, dev_err(ds->dev, "FDB is full, cannot add entry.\n"); return -EINVAL; } - l2_lookup.lockeds = true; l2_lookup.index = i; skip_finding_an_index: + l2_lookup.lockeds = true; + rc = sja1105_dynamic_config_write(priv, BLK_IDX_L2_LOOKUP, l2_lookup.index, &l2_lookup, true); -- 2.30.2