Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp384649lqp; Tue, 11 Jun 2024 07:23:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXO/T3DWo466efukinnYL+LiXBBREpqWRX6x1EE7HL4lpUDeYa0Bhpbf8zYyMUDjR5m0KSB9thBF38ItAaB9LdH3sIscQ5UTELwB+fTYg== X-Google-Smtp-Source: AGHT+IEZNHuix8ds58QI0krxvZahCcHMxYPSHMXLPWOHQsEQuuOD4MiTRwxIhjVGP34cqMmqtkg4 X-Received: by 2002:a05:6871:694:b0:254:97b8:4ea8 with SMTP id 586e51a60fabf-25497b86f52mr11602997fac.54.1718115826582; Tue, 11 Jun 2024 07:23:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718115826; cv=pass; d=google.com; s=arc-20160816; b=Ort1e5hVa41JllM/zZYL+N7niTyRgvaHTU9hGZhvbiSLuHiBFSyO0IkXJGvXZXhdr2 a9yP/LeDI7dEDMCdCCL+rk5sYxh8I6FA684F9RciGP8oRzu3q1fdmEIfYLbi+22G4707 y2FlA5NkbvB4sNCCr55XnN+Fe+rEGMBf+IUrwHJ+VkrBr3IwNA72gH9p5nfkwQtbZKeG 6uYFx6Vsk08OF+HM1GizqD8FCnbnGpkgsTjnNJgQsTHjHSDIM20NP+zuBUeF5mqqHb+X OGGzueY6UYGuVAHX8FgZW/C900BIe31zch8Qx0kJ6FgGnJdw77poZWWmH/3l7bSCJsqb f6qA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=S+CMB6lWjKFzbLIOgWH8nlNdbz3i9Pj1Fs1OPoID1VQ=; fh=Lh+JMPZo65h8qJAnE5jHWvKtvWM25xS7kSTjy8t+qRE=; b=cQ0ClHrG7VexQhbGL6kYYu+v5MR9N15+C1Jgbgd/qVtCpLvjA/5vT3/bj50rCTwXyn ZmRiFOmItP6bLAVpuJhSRrtOT8vVLNy9724TTmHKXPR8uB5IckdOhbBi4hCsCSxPdkRi /o6P/vGxQaOFq6PNiZRAyYABZQUAojgnKlyanpnuah36rY6MvvID9n3Bl84vAHsMTwZ4 XbDYntE0dMHnAC9EdfDWOfsnuOwdk6UPy297unUO8HFmZ/B6jwrG/9TmHWYo6EXKvln9 7mZkSb8OHbtTrpiQoTFa/Lwk4BKFgqdJO2HNPv1GWXSVr0xZeudKusMokpfvHq3jB9tX RlxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=dev.tdt.de); spf=pass (google.com: domain of linux-kernel+bounces-210018-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210018-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e3d7e2822csi5569683a12.364.2024.06.11.07.23.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 07:23:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210018-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=dev.tdt.de); spf=pass (google.com: domain of linux-kernel+bounces-210018-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210018-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8C5AB289899 for ; Tue, 11 Jun 2024 13:58:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D37CA17FACF; Tue, 11 Jun 2024 13:56:00 +0000 (UTC) Received: from mxout70.expurgate.net (mxout70.expurgate.net [91.198.224.70]) (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 D6CD417D354; Tue, 11 Jun 2024 13:55:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.198.224.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718114160; cv=none; b=SiI800N09jm5wFArjTCBORoF7zPoBxEHZILOpA+60Hrkur8bInuVNTCRaTLdq80bbrRIQO2ibfruQtJCnfaiGQipVLEvFTU81t1TJwio/mEjJ5H/itdZWbTm75q9kSAIoYkprw+CHy0WftMRjVqFL3giSy3TcFz4dejlSLINDcQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718114160; c=relaxed/simple; bh=FiiIio8sTmC0ZNB6lxOWtu001Alpp8KjInwbWP3BENA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hA9rZ1pIT0+JD8DkpgQJl0vH+hrCI2mrJblAVLHuPKvzceL0ESeZY+N0pByq1y5d8TCN0gRDBUvITsBV0mD/OOpGkwBB5KobN72zhH9QGH9cCfT/I12EYjguqsohAIazIhiGUbVht7upfF9VfO6g5pELxjsOgxIWO8TOgbeOip0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dev.tdt.de; spf=pass smtp.mailfrom=dev.tdt.de; arc=none smtp.client-ip=91.198.224.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dev.tdt.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dev.tdt.de Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1sH1ye-003Zkw-SK; Tue, 11 Jun 2024 15:55:56 +0200 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sH1ye-00FImn-A5; Tue, 11 Jun 2024 15:55:56 +0200 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 07248240053; Tue, 11 Jun 2024 15:55:56 +0200 (CEST) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 8AA55240050; Tue, 11 Jun 2024 15:55:55 +0200 (CEST) Received: from mschiller1.dev.tdt.de (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 2BBB5376FA; Tue, 11 Jun 2024 15:55:55 +0200 (CEST) From: Martin Schiller To: martin.blumenstingl@googlemail.com, hauke@hauke-m.de, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, ms@dev.tdt.de Subject: [PATCH net-next v5 09/12] net: dsa: lantiq_gswip: Consistently use macros for the mac bridge table Date: Tue, 11 Jun 2024 15:54:31 +0200 Message-ID: <20240611135434.3180973-10-ms@dev.tdt.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240611135434.3180973-1-ms@dev.tdt.de> References: <20240611135434.3180973-1-ms@dev.tdt.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-type: clean X-purgate-ID: 151534::1718114156-366B3D11-FD8C46A2/0/0 X-purgate: clean From: Martin Blumenstingl Only bits [5:0] in mac_bridge.key[3] are reserved for the FID. Also, for dynamic (learned) entries, bits [7:4] in mac_bridge.val[0] represents the port. Introduce new macros GSWIP_TABLE_MAC_BRIDGE_KEY3_FID and GSWIP_TABLE_MAC_BRIDGE_VAL0_PORT macro and use it throughout the driver. Also rename and update GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC to use the BIT() macro. This makes the driver code easier to understand. Signed-off-by: Martin Blumenstingl Signed-off-by: Martin Schiller Acked-by: Hauke Mehrtens --- drivers/net/dsa/lantiq_gswip.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswi= p.c index 525a62a21601..cd88b00cfdc1 100644 --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c @@ -236,7 +236,9 @@ #define GSWIP_TABLE_ACTIVE_VLAN 0x01 #define GSWIP_TABLE_VLAN_MAPPING 0x02 #define GSWIP_TABLE_MAC_BRIDGE 0x0b -#define GSWIP_TABLE_MAC_BRIDGE_STATIC 0x01 /* Static not, aging entry *= / +#define GSWIP_TABLE_MAC_BRIDGE_KEY3_FID GENMASK(5, 0) /* Filtering iden= tifier */ +#define GSWIP_TABLE_MAC_BRIDGE_VAL0_PORT GENMASK(7, 4) /* Port on learn= ed entries */ +#define GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC BIT(0) /* Static, non-aging= entry */ =20 #define XRX200_GPHY_FW_ALIGN (16 * 1024) =20 @@ -1304,10 +1306,11 @@ static void gswip_port_fast_age(struct dsa_switch= *ds, int port) if (!mac_bridge.valid) continue; =20 - if (mac_bridge.val[1] & GSWIP_TABLE_MAC_BRIDGE_STATIC) + if (mac_bridge.val[1] & GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC) continue; =20 - if (((mac_bridge.val[0] & GENMASK(7, 4)) >> 4) !=3D port) + if (port !=3D FIELD_GET(GSWIP_TABLE_MAC_BRIDGE_VAL0_PORT, + mac_bridge.val[0])) continue; =20 mac_bridge.valid =3D false; @@ -1382,9 +1385,9 @@ static int gswip_port_fdb(struct dsa_switch *ds, in= t port, mac_bridge.key[0] =3D addr[5] | (addr[4] << 8); mac_bridge.key[1] =3D addr[3] | (addr[2] << 8); mac_bridge.key[2] =3D addr[1] | (addr[0] << 8); - mac_bridge.key[3] =3D fid; + mac_bridge.key[3] =3D FIELD_PREP(GSWIP_TABLE_MAC_BRIDGE_KEY3_FID, fid); mac_bridge.val[0] =3D add ? BIT(port) : 0; /* port map */ - mac_bridge.val[1] =3D GSWIP_TABLE_MAC_BRIDGE_STATIC; + mac_bridge.val[1] =3D GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC; mac_bridge.valid =3D add; =20 err =3D gswip_pce_table_entry_write(priv, &mac_bridge); @@ -1438,14 +1441,15 @@ static int gswip_port_fdb_dump(struct dsa_switch = *ds, int port, addr[2] =3D (mac_bridge.key[1] >> 8) & 0xff; addr[1] =3D mac_bridge.key[2] & 0xff; addr[0] =3D (mac_bridge.key[2] >> 8) & 0xff; - if (mac_bridge.val[1] & GSWIP_TABLE_MAC_BRIDGE_STATIC) { + if (mac_bridge.val[1] & GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC) { if (mac_bridge.val[0] & BIT(port)) { err =3D cb(addr, 0, true, data); if (err) return err; } } else { - if (((mac_bridge.val[0] & GENMASK(7, 4)) >> 4) =3D=3D port) { + if (port =3D=3D FIELD_GET(GSWIP_TABLE_MAC_BRIDGE_VAL0_PORT, + mac_bridge.val[0])) { err =3D cb(addr, 0, false, data); if (err) return err; --=20 2.39.2