Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3763969pxt; Tue, 10 Aug 2021 10:46:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxykhGvrx5XEEl3L00UtkkQnx5banbHGMJAn08jlMK46MGKhe2DXx1yE2QNd4Vt2eEHm4Gs X-Received: by 2002:a92:d84f:: with SMTP id h15mr64820ilq.12.1628617568130; Tue, 10 Aug 2021 10:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617568; cv=none; d=google.com; s=arc-20160816; b=Em1BUttu37vi+Fjn9TA1Ux+nMNDLxhuIWadtP3sC148G5a+l3C/OvW94klbsyxogae bHJ+2Oa3bjiRRlP3qKZna0f676ZhEkCACqpdSqTgwBgPObQfo6TMa/+vpyVPHV9CcOsK vhRWe2w9oeH+ArZVMvh93DtasVY236myBoAYWTLJ465S7HsB1qBXETZbnNu+uQMqIdMq DMGVqIOK0cmjkHpDxVIFSaqk9ITGZuwAPma/CAmFUHy4wqRIMyOIfVj5L8O1vKvWSNkI 5kVrqiIddfupH8ilpZm4xKYs7SqxaHz9rHYpTV2E67rrPtgWJJvoGbemPHqSlR3TwRP3 p4jw== 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=jRcyZmA7J9urpB2XJQdqmqccC6P55nFqDwPVDglvors=; b=SJRWUsgQU7ih+f9cMSEFt2B8JP9vFu0gCtiam8vp54Ew2b6U9kQ7x+qTM1ni86Eeqr JT3F7GMIP3pwey/tOHxdZRkcNGwJ7k/JQjlfQaynCf0QnMXtq2kAuv1XUqZ+OP+K5Swt XfRY25CKVYVzhNWw/eUJ5rydlry6yKfXIQx4TYGkqYt6TggG9htJsp4kKiJpdLsLeqOK Y7W+JGPlDmVwFv51ysAULXgvnDUK7JJPJqdRmRTvqIW1LHYIV71pkPFBtkU7LWKPF6j2 Ver9Fe+EMC4Pt6DfIZTzX4YCvdHOUJyG0lYXH7HwsiPSFdwvmXcDrWJG1OBGie9SSRX8 KgRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rClkmiDz; 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 ay15si3882477jab.111.2021.08.10.10.45.54; Tue, 10 Aug 2021 10:46:08 -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=rClkmiDz; 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 S234975AbhHJRnt (ORCPT + 99 others); Tue, 10 Aug 2021 13:43:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:44144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235752AbhHJRkH (ORCPT ); Tue, 10 Aug 2021 13:40:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BDF1061207; Tue, 10 Aug 2021 17:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617072; bh=1YRovlHyuGHekNcw7oq23eueJPkxeHpYFmQmvhWr8QM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rClkmiDz/z3OTrGVUWGg+8UmlM3UV/SNgdMuGC5/JfQQ+7umpunXfp4PNfYfkQFYK Y2QNVRDjg8WD5lzt//hC1FMK3pGIquCcTAczwMmsW1CMKR1NFcvR/VnEIEL14iixHZ 9XqLpV6THcl8ckWQrEmgwDxYMvG0TVypCDLpdzi4= 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.10 031/135] net: dsa: sja1105: overwrite dynamic FDB entries with static ones in .port_fdb_add Date: Tue, 10 Aug 2021 19:29:25 +0200 Message-Id: <20210810172956.725109184@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@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 82b918d36117..469d123772a6 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1275,7 +1275,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 { @@ -1306,6 +1306,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, @@ -1376,10 +1377,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. @@ -1402,10 +1403,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