From nobody Sat Feb 7 16:39:21 2026 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 C026F345CCD for ; Fri, 6 Feb 2026 07:55:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770364550; cv=none; b=MeDk+fg2kv1vBff0YGPZpjH7dEr3Ms/hpiVKtYYlAMchD1Z5Bb3X6P2aoVnTSpOplXJOOyVgSWemgWzm+wjREpGQ5OwqfKuiSUyhey09xULreuIDF7CnYpe4N+yEy0ZWEvWzuXfBooSddO4/NE/pMP/lGua1eYZ5sF8hXMirOBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770364550; c=relaxed/simple; bh=v2d1blaGRcf8ijbWbljWEUVT02oGtckSRGq8JJ6vdwo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MnVO0uJVfqGYtnStTs402rh8fL/TBcTWcXQaAxlmoIWkRzFBmOMgCJOQO9Sym7OlNM1hpTBrJop99cbjvhvqWIbTUYlg0qni5zknIvzdTZ+AJhSoi3BhQ0dZsQN70DgABiPqte0OFmopELH1uHleA0Rhh4W9fYlkMgwM/CjUrPE= 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=WYEYAbHZ; arc=none smtp.client-ip=209.85.210.179 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="WYEYAbHZ" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-8217f2ad01eso1602069b3a.2 for ; Thu, 05 Feb 2026 23:55:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770364550; x=1770969350; 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=3ye++DxatwQlokJ3JNJAjWad+kly5kE+X16yBsy9Mh4=; b=WYEYAbHZxO8uUwgFazqD6CBgeTIh2xv2DpcqTfZ2WLX+ue5Ss3uTMbnYMOfGWUYDln AXyd6gu2QzhH0qClVBl8J7zupWUwBXYn21VDf2HfIBDfBsGXVTDuoFNG0BnQJ1kjHOmQ fs5zmBS6Pab47JUghQnBdUK2n0W63zebQIkwZsx/7XtgURXjOe47yy1cuNN5Tkxu5cTP V3ZNJRj8AbfeU9Cwr/LTfsEsGrLEYDidjB7hwaglt8MFS6sdgrSTzzG0As48Pewt/0if HSC+GX3rvvEpbNyDNzPuCYnrXy0nynlctdySde7HvgBPEM1YDuNa1ErjpZHiUtdRCwRW t5bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770364550; x=1770969350; 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=3ye++DxatwQlokJ3JNJAjWad+kly5kE+X16yBsy9Mh4=; b=w3ENrjVtCdu8nRi3pg1cLO8SR0kpF264HafvAHr5U5mwcz4poJLUd/LNVtTYLv38cF fNNFfRjfY6eefjvJl4df0pv+MUAIHD0mLGyGWK/ip9rXQmttaqzmPi6lQ81xfP5iHpjL S+DZ5JS9KMKkypEuLX68K3a59eEeWEXVS79p5goPMRVuWVBS+Z/QguV0gWbriYIPFoB7 VP+7FiAatGSBT93haZ+D7KrTd+kFcQzkQez+/0waBhe9SnrEau8/II/WFPWPhGhkBlx0 3pHq54oWSh/al9v+H77tmZToE1DXzgnEnP6Ga2eRNHGV86hx+Oa2v10ZKkR6jUeaHZvT VtJg== X-Forwarded-Encrypted: i=1; AJvYcCUctY0aNRir4EPwdyg4CQSkIaz64gqciLWzp6rh5riAKCVDSC+Kmt3dksjRxBxf5ZP93G0hsmww9wwrLX4=@vger.kernel.org X-Gm-Message-State: AOJu0YzUyCuvPLJWblU+1HjUdiertH4/tQAZGnnwmEizUTdQYiKKIH4y NJB2GtZS5HXNYdIx1foNMohQHWWkxJJEB2meB20rHe6WJnglHNE6/tPHJ2FfVGY4 X-Gm-Gg: AZuq6aI97xrO9wPYTfPqVd0HPlHHi3i7Go1692vVhaymdypDAkH4BIurOz7S60T5xZD FqtMSnEcXDBxCyZYhZkiP+ITQ7FnB1O3L6P72kEjB0Ui7SodO4J/cmu+Pa/H+jPVcrI6LwLefDq ta1RvM03RUBaFZooc2oqw4hSuVNAvApHPb8fzh6p5RhwC/vIVQfXJrD8Rt7DTZZhnkp0iIspMYg Q6uIf/KfNMoDnQLn1LtuUzKSals6+ACB6yY9ZKFDhUAL5GNLhKXb32WWQxFoz6o7QSpAORw/Og+ FqcM5+rDekP/cq3Wh9eeUgOJrO2bnEvrgZMzluTNLC780E+h4HATIUY8Q6/hmtJdDzf4mrjsPjN DlwdTpk7Non88E3KT880EID14SHhsUpmuGkMz0yTTMK1bbCYziVWW6+aFxBIw4wUkDW61ghCsX1 YCRa4zNvkExlg5ityCHDOYkD7LyUGNxlTl5rTWKg== X-Received: by 2002:a05:6a21:138f:b0:38d:f623:f876 with SMTP id adf61e73a8af0-393ad41a179mr1704979637.79.1770364550083; Thu, 05 Feb 2026 23:55:50 -0800 (PST) Received: from d.home.yangfl.dn42 ([2a09:bac5:6619:1250::1d3:c3]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c6dcb5249a0sm1391881a12.11.2026.02.05.23.55.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Feb 2026 23:55:49 -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 v4] net: dsa: eliminate local type for tc policers Date: Fri, 6 Feb 2026 15:54:21 +0800 Message-ID: <20260206075427.44733-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 --- v3: https://lore.kernel.org/r/20260203172207.98533-1-mmyangfl@gmail.com - move struct flow_action_police standalone 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 | 30 ++++++++++++++------------ net/dsa/user.c | 5 ++--- 5 files changed, 24 insertions(+), 29 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 5637747019c1..70a02ee14308 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -231,6 +231,21 @@ struct flow_action_cookie *flow_action_cookie_create(v= oid *data, gfp_t gfp); void flow_action_cookie_destroy(struct flow_action_cookie *cookie); =20 +struct flow_action_police { + u32 burst; + u64 rate_bytes_ps; + u64 peakrate_bytes_ps; + u32 avrate; + u16 overhead; + u64 burst_pkt; + u64 rate_pkt_ps; + u32 mtu; + struct { + enum flow_action_id act_id; + u32 extval; + } exceed, notexceed; +}; + struct flow_action_entry { enum flow_action_id id; u32 hw_index; @@ -275,20 +290,7 @@ struct flow_action_entry { u32 trunc_size; bool truncate; } sample; - struct { /* FLOW_ACTION_POLICE */ - u32 burst; - u64 rate_bytes_ps; - u64 peakrate_bytes_ps; - u32 avrate; - u16 overhead; - u64 burst_pkt; - u64 rate_pkt_ps; - u32 mtu; - struct { - enum flow_action_id act_id; - u32 extval; - } exceed, notexceed; - } police; + struct flow_action_police police; /* FLOW_ACTION_POLICE */ struct { /* FLOW_ACTION_CT */ int action; u16 zone; diff --git a/net/dsa/user.c b/net/dsa/user.c index f59d66f0975d..5697291d43cf 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; + *policer =3D act->police; =20 err =3D ds->ops->port_policer_add(ds, dp->index, policer); if (err) { --=20 2.51.0