From nobody Sat Feb 7 19:41:24 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC32731D371 for ; Tue, 3 Feb 2026 17:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770139491; cv=none; b=lBqsnU7aAewUJvT5Do9igPzPRS1/5kcLCffCGnh59WL8NXqopD8+b9K5ISlWEj4uqkJTn6WJZowHxRrM1Mc9olwhqI0nxtF46W2tOd0yDzf1ghClDyH7l2BwNBJc+NBX5K4rYaLsNJDMzXkZ8l6ZUmEuKDcpHaXYr1Z+ozBfTPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770139491; c=relaxed/simple; bh=NwQadxIsbAVicBdlN5JoSnhWAwdMRsWYGibuwLb2uqw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gCw96I6VdKTP4auL5Dy8khQfqGTmu8UWsW92tOj9b2s6fcSx2UGUYg3sFgzrn69p9PKFUt3xWeXtefiQb8YbhtBxdDyMGHJd5ztRz+JlDFQy6OA5hZBm4/ZSe8cIt22iU2K0LZ96SMB/E4D8YZSnSPkpCjSe3fu2H4oDlPT25UU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ksiHnGVP; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ksiHnGVP" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2a09757004cso47619535ad.3 for ; Tue, 03 Feb 2026 09:24:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770139489; x=1770744289; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LF/dpo4BeQSytcLLWoC5FgkTqSqyB60iXXH6RwLfoVg=; b=ksiHnGVPU3C4rLF57d2ord97g3XGYtyds1LuQFPD1dTYgVmPn9u8Hhkx1pBel8P+Db 47qB0tetJINtuIoAee7tuQUBp/zLBsOAMgdlWoB5VAWKqqe3DmgiZaG2+lvDn0xh28gX Qg2veIOHW7xEIveCjxMG4BjhZepdj4wOJ31m9Rgu1GNlem+X7ut+Zyw6nZI+yEGkQI1A 6SFkeWr0IRNw5Z7x8qTpAFvO2RfOhsZjrL/CcEMFRaluaMWWMNGLJkEjpwdy61XdRPz1 qTvW0u369Zo0xSV00FDFmdxtG/dC7GntccY4RpFfECwNvTbUsh3Nisy4TsKvg0/3rIVj 3lqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770139489; x=1770744289; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LF/dpo4BeQSytcLLWoC5FgkTqSqyB60iXXH6RwLfoVg=; b=efV8miEy0Qmd4p15UPhJWNuN4R+3RH+oyhCFwDnYhZkbqwW26cHWp+lCXXrzo5FP/Y gZbpbQikdOOD+zYbiBGpE7Go6RoD6kDxSnrf78zsmZSf6dxJNZ98vk9OTWs0ugXkHqd8 Kuq9j5jcbrScsCjZ1d+physlviIpIivn3X2QyTVDVt2t9a74euxiuP2wVJW9eR7TS1yF VzPjtVwqB+H1B4CN+su4lf3NLvT3yb4OLIplfe2iIx2b4Me6TihMtXspA1FooQZaz9z1 Y5ZkiBy/ZosFDJYAbCijqUoj1wALPys+78oWi+PU+2qJ+THAktw8Pm+hDnbc1/5vXjmd ZIYg== X-Forwarded-Encrypted: i=1; AJvYcCXe3lkunwzHDYePAhdU+HJrbo63PJLFctmJbJ8SaI3UPMMkU5LJEkigfPyMQ0MNibiu5Pop4xq3sL3n6BQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzwxEpNBdir5/WmcIWeJFx0oZt6Ix8+8Y/CsunutZ6SQv8Cxu7B uDuebNMBKXnRl4qUqx0D/OIDlPihAZJp81s/YWxbZ3pHakd8HNILC6oP X-Gm-Gg: AZuq6aLOe0XkPF8JSLGXlvEXuGz62mZGGtyXgixoZ5TgZQSHbx3gQY8i2OmX4Wr3/4w Ltv0/tWlc6GRTb2x4ZHrgO9gjL2vwFJlVYn+KRyxNEHDr/pmLipttTRPjV0h672xcWR27nxMExf 0xnXywOS5Gg5Vy4X24WayvCQMV2P6MnVUYMGLAVxAbfSjtYIjX+uqA2bjjOfdw2YlBNu8fyNu8c VyZALzyKO2ocy5AgfgwHZTnV+RLWgoMF+9z22fWdKffvYxnoZtHnLO5ltu8jzNKoIQXinmJqnZ1 zRysfr+gJtbgNPbk5OO6YpeSSIBGfTwYWUZxglRMa63oBw0LEUnPH63+r13lod62CNyrS2FZ4k9 7pvu0vz2zBLRq2eBwRevgEhUbx8SMeHDlGBc6X1qhtVjZ6bzc3k4vfYOxRNjcOM+OUUt+9E43qL yD26N1/ASo82JMAQBOVJh0MB+njL0osoDVwEb3M7ZW6Xkm3dOGDPco8YW+KgUvhZRoCUx3PgCk9 YSQs6BgnGZRNCzWfxkXWt4= X-Received: by 2002:a17:902:d585:b0:2a9:2942:e15d with SMTP id d9443c01a7336-2a933cdbaa3mr472525ad.5.1770139489167; Tue, 03 Feb 2026 09:24:49 -0800 (PST) Received: from d.home.mmyangfl.win (tunnel997320-pt.tunnel.tserv3.fmt2.ipv6.he.net. [2001:470:1f04:2c7::2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a933966f12sm506025ad.76.2026.02.03.09.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 09:24:48 -0800 (PST) From: David Yang To: netdev@vger.kernel.org Cc: Vladimir Oltean , David Yang , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-kernel@vger.kernel.org Subject: [PATCH net-next v3] net: dsa: eliminate local type for tc policers Date: Wed, 4 Feb 2026 01:22:02 +0800 Message-ID: <20260203172207.98533-1-mmyangfl@gmail.com> X-Mailer: git-send-email 2.51.0 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 Content-Type: text/plain; charset="utf-8" From: Vladimir Oltean David Yang is saying that struct flow_action_entry in include/net/flow_offload.h has gained new fields and DSA's struct dsa_mall_policer_tc_entry, derived from that, isn't keeping up. This structure is passed to drivers and they are completely oblivious to the values of fields they don't see. This has happened before, and almost always the solution was to make the DSA layer thinner and use the upstream data structures. Here, the reason why we didn't do that is because struct flow_action_entry :: police is an anonymous structure. That is easily enough fixable, just name those fields "struct flow_action_police" and reference them from DSA. Make the according transformations to the two users (sja1105 and felix): "rate_bytes_per_sec" -> "rate_bytes_ps". Signed-off-by: Vladimir Oltean Co-developed-by: David Yang Signed-off-by: David Yang --- v2: https://lore.kernel.org/r/20260131045821.3451873-1-mmyangfl@gmail.com - use Oltean's version and export struct flow_action_police v1: https://lore.kernel.org/r/20260126061340.757543-1-mmyangfl@gmail.com - fix DSA core only drivers/net/dsa/ocelot/felix.c | 4 ++-- drivers/net/dsa/sja1105/sja1105_main.c | 4 ++-- include/net/dsa.h | 10 ++-------- include/net/flow_offload.h | 2 +- net/dsa/user.c | 5 ++--- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 9e5ede932b42..5d34eb82e639 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -2003,11 +2003,11 @@ static int felix_cls_flower_stats(struct dsa_switch= *ds, int port, } =20 static int felix_port_policer_add(struct dsa_switch *ds, int port, - struct dsa_mall_policer_tc_entry *policer) + const struct flow_action_police *policer) { struct ocelot *ocelot =3D ds->priv; struct ocelot_policer pol =3D { - .rate =3D div_u64(policer->rate_bytes_per_sec, 1000) * 8, + .rate =3D div_u64(policer->rate_bytes_ps, 1000) * 8, .burst =3D policer->burst, }; =20 diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja11= 05/sja1105_main.c index 2a4a0fe20dae..71a817c07a90 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -2841,7 +2841,7 @@ static void sja1105_mirror_del(struct dsa_switch *ds,= int port, } =20 static int sja1105_port_policer_add(struct dsa_switch *ds, int port, - struct dsa_mall_policer_tc_entry *policer) + const struct flow_action_police *policer) { struct sja1105_l2_policing_entry *policing; struct sja1105_private *priv =3D ds->priv; @@ -2852,7 +2852,7 @@ static int sja1105_port_policer_add(struct dsa_switch= *ds, int port, * the value of RATE bytes divided by 64, up to a maximum of SMAX * bytes. */ - policing[port].rate =3D div_u64(512 * policer->rate_bytes_per_sec, + policing[port].rate =3D div_u64(512 * policer->rate_bytes_ps, 1000000); policing[port].smax =3D policer->burst; =20 diff --git a/include/net/dsa.h b/include/net/dsa.h index 6b2b5ed64ea4..656990365798 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -216,12 +216,6 @@ struct dsa_mall_mirror_tc_entry { bool ingress; }; =20 -/* TC port policer entry */ -struct dsa_mall_policer_tc_entry { - u32 burst; - u64 rate_bytes_per_sec; -}; - /* TC matchall entry */ struct dsa_mall_tc_entry { struct list_head list; @@ -229,7 +223,7 @@ struct dsa_mall_tc_entry { enum dsa_port_mall_action_type type; union { struct dsa_mall_mirror_tc_entry mirror; - struct dsa_mall_policer_tc_entry policer; + struct flow_action_police policer; }; }; =20 @@ -1110,7 +1104,7 @@ struct dsa_switch_ops { void (*port_mirror_del)(struct dsa_switch *ds, int port, struct dsa_mall_mirror_tc_entry *mirror); int (*port_policer_add)(struct dsa_switch *ds, int port, - struct dsa_mall_policer_tc_entry *policer); + const struct flow_action_police *policer); void (*port_policer_del)(struct dsa_switch *ds, int port); int (*port_setup_tc)(struct dsa_switch *ds, int port, enum tc_setup_type type, void *type_data); diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 596ab9791e4d..a2b1b752958a 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -275,7 +275,7 @@ struct flow_action_entry { u32 trunc_size; bool truncate; } sample; - struct { /* FLOW_ACTION_POLICE */ + struct flow_action_police { /* FLOW_ACTION_POLICE */ u32 burst; u64 rate_bytes_ps; u64 peakrate_bytes_ps; diff --git a/net/dsa/user.c b/net/dsa/user.c index f59d66f0975d..df25a8891c01 100644 --- a/net/dsa/user.c +++ b/net/dsa/user.c @@ -1459,8 +1459,8 @@ dsa_user_add_cls_matchall_police(struct net_device *d= ev, struct netlink_ext_ack *extack =3D cls->common.extack; struct dsa_port *dp =3D dsa_user_to_port(dev); struct dsa_user_priv *p =3D netdev_priv(dev); - struct dsa_mall_policer_tc_entry *policer; struct dsa_mall_tc_entry *mall_tc_entry; + struct flow_action_police *policer; struct dsa_switch *ds =3D dp->ds; struct flow_action_entry *act; int err; @@ -1497,8 +1497,7 @@ dsa_user_add_cls_matchall_police(struct net_device *d= ev, mall_tc_entry->cookie =3D cls->cookie; mall_tc_entry->type =3D DSA_PORT_MALL_POLICER; policer =3D &mall_tc_entry->policer; - policer->rate_bytes_per_sec =3D act->police.rate_bytes_ps; - policer->burst =3D act->police.burst; + memcpy(policer, &act->police, sizeof(*policer)); =20 err =3D ds->ops->port_policer_add(ds, dp->index, policer); if (err) { --=20 2.51.0