Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3772490pxt; Tue, 10 Aug 2021 10:59:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4frJ4QNVo2MFqwOhyIizNJySgkivtNaiX1H5SUeXwR3n2GGADXzHOo37bZsl4s1/JquyX X-Received: by 2002:a05:6402:1c1d:: with SMTP id ck29mr6361244edb.39.1628618364124; Tue, 10 Aug 2021 10:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628618364; cv=none; d=google.com; s=arc-20160816; b=iwm3anjVWBDM+ypbuJZjbVfDVEzoLKp2hrdY6DjRiWc0qBoJ2goc8F/AclmM/TglK9 ccP6PgY97KIL458iLEVeW4IXXKd/mP9C3dogCTD18vRa69M6JirkaWVgOwrK0KafNRcq muCCUWDfPS+wizs0R8zEzdKPLNKqTm+VnV0wU5uSPYwhiexAl4YvuUdMOeYSu9/wegLf QJFsVQa9CDQnE11V09nSQdbRtFS9k10bAYol9DYutGznySc2EErKLslBiAds4zUXDMFL caIeX4RRBAr7/yS3jl6VTAZrbqY6Z/lfVAs62YJ0uTx6+jm9PEIJN8NFmvg68S0c78Rt K61A== 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=czq1N85Ge2fqPJLYhStJ7EM+xNn4JbpdnmDNDz4TuNk=; b=fMF6O0/XnuRLl7BE3rm6IZaep87YG/8T4tEaHNX5v/Y5zAIM+y7b3eEAI/0SRsczNS XnisSlUbl4Q2Pc48wfWCVrxe4xe3nY9S4sIITbkPALRGMBDiSR6CMXxUkn+dKvEu+Oli SvKl8R7f3d6QkggrAGO9uscKB8BpzKN4aglTs1jjKnEfeZyJs4ZRn+Te08F1p2YpofCa nXaU4tipHyhmZtjpblnlfiIWt+t61L5pWseidYSv3MMkzt1po93ugjErn7z1s1sFv2wC Kh18Ym9jdQqIC65O7XQ3Vk02INzchJ/ohnhKsyy2PgrR4B+EBCOtiKlwuPzZ0+YzQgvF hU4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UWo+M8MO; 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 hs3si22148347ejc.368.2021.08.10.10.58.59; Tue, 10 Aug 2021 10:59:24 -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=UWo+M8MO; 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 S235701AbhHJRzR (ORCPT + 99 others); Tue, 10 Aug 2021 13:55:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:49726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236118AbhHJRwC (ORCPT ); Tue, 10 Aug 2021 13:52:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CCA5E6120E; Tue, 10 Aug 2021 17:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617397; bh=oRSVPSAgKSVqWnse4DMNlvkh/d6b7ROfQ3TB22gBaCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UWo+M8MOO0uj0fICAatejZM87jDZduJK346kpDctPuOzEqIskA+VBviSQql7NCDp1 mpnbJ9krYabDg6cJme97tnS6m2yNWWCvKeeAd9HwePqmbJ130x6kuYYFZr2R+/Izl3 hOjN94kZNTtDiB5372uMJSaa5RfhP5DwPhUYGvrI= 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.13 041/175] net: dsa: sja1105: overwrite dynamic FDB entries with static ones in .port_fdb_add Date: Tue, 10 Aug 2021 19:29:09 +0200 Message-Id: <20210810173002.304047010@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810173000.928681411@linuxfoundation.org> References: <20210810173000.928681411@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 5b7947832b87..c671d43a4724 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1323,7 +1323,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 { @@ -1354,6 +1354,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, @@ -1424,10 +1425,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. @@ -1450,10 +1451,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