Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: dsa: eliminate local type for tc policers

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 <vladimir.oltean@nxp.com>
Co-developed-by: David Yang <mmyangfl@gmail.com>
Signed-off-by: David Yang <mmyangfl@gmail.com>
Link: https://patch.msgid.link/20260206075427.44733-1-mmyangfl@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Vladimir Oltean and committed by
Paolo Abeni
c22ba07c 86dbebfb

+24 -29
+2 -2
drivers/net/dsa/ocelot/felix.c
··· 2003 2003 } 2004 2004 2005 2005 static int felix_port_policer_add(struct dsa_switch *ds, int port, 2006 - struct dsa_mall_policer_tc_entry *policer) 2006 + const struct flow_action_police *policer) 2007 2007 { 2008 2008 struct ocelot *ocelot = ds->priv; 2009 2009 struct ocelot_policer pol = { 2010 - .rate = div_u64(policer->rate_bytes_per_sec, 1000) * 8, 2010 + .rate = div_u64(policer->rate_bytes_ps, 1000) * 8, 2011 2011 .burst = policer->burst, 2012 2012 }; 2013 2013
+2 -2
drivers/net/dsa/sja1105/sja1105_main.c
··· 2841 2841 } 2842 2842 2843 2843 static int sja1105_port_policer_add(struct dsa_switch *ds, int port, 2844 - struct dsa_mall_policer_tc_entry *policer) 2844 + const struct flow_action_police *policer) 2845 2845 { 2846 2846 struct sja1105_l2_policing_entry *policing; 2847 2847 struct sja1105_private *priv = ds->priv; ··· 2852 2852 * the value of RATE bytes divided by 64, up to a maximum of SMAX 2853 2853 * bytes. 2854 2854 */ 2855 - policing[port].rate = div_u64(512 * policer->rate_bytes_per_sec, 2855 + policing[port].rate = div_u64(512 * policer->rate_bytes_ps, 2856 2856 1000000); 2857 2857 policing[port].smax = policer->burst; 2858 2858
+2 -8
include/net/dsa.h
··· 216 216 bool ingress; 217 217 }; 218 218 219 - /* TC port policer entry */ 220 - struct dsa_mall_policer_tc_entry { 221 - u32 burst; 222 - u64 rate_bytes_per_sec; 223 - }; 224 - 225 219 /* TC matchall entry */ 226 220 struct dsa_mall_tc_entry { 227 221 struct list_head list; ··· 223 229 enum dsa_port_mall_action_type type; 224 230 union { 225 231 struct dsa_mall_mirror_tc_entry mirror; 226 - struct dsa_mall_policer_tc_entry policer; 232 + struct flow_action_police policer; 227 233 }; 228 234 }; 229 235 ··· 1104 1110 void (*port_mirror_del)(struct dsa_switch *ds, int port, 1105 1111 struct dsa_mall_mirror_tc_entry *mirror); 1106 1112 int (*port_policer_add)(struct dsa_switch *ds, int port, 1107 - struct dsa_mall_policer_tc_entry *policer); 1113 + const struct flow_action_police *policer); 1108 1114 void (*port_policer_del)(struct dsa_switch *ds, int port); 1109 1115 int (*port_setup_tc)(struct dsa_switch *ds, int port, 1110 1116 enum tc_setup_type type, void *type_data);
+16 -14
include/net/flow_offload.h
··· 231 231 gfp_t gfp); 232 232 void flow_action_cookie_destroy(struct flow_action_cookie *cookie); 233 233 234 + struct flow_action_police { 235 + u32 burst; 236 + u64 rate_bytes_ps; 237 + u64 peakrate_bytes_ps; 238 + u32 avrate; 239 + u16 overhead; 240 + u64 burst_pkt; 241 + u64 rate_pkt_ps; 242 + u32 mtu; 243 + struct { 244 + enum flow_action_id act_id; 245 + u32 extval; 246 + } exceed, notexceed; 247 + }; 248 + 234 249 struct flow_action_entry { 235 250 enum flow_action_id id; 236 251 u32 hw_index; ··· 290 275 u32 trunc_size; 291 276 bool truncate; 292 277 } sample; 293 - struct { /* FLOW_ACTION_POLICE */ 294 - u32 burst; 295 - u64 rate_bytes_ps; 296 - u64 peakrate_bytes_ps; 297 - u32 avrate; 298 - u16 overhead; 299 - u64 burst_pkt; 300 - u64 rate_pkt_ps; 301 - u32 mtu; 302 - struct { 303 - enum flow_action_id act_id; 304 - u32 extval; 305 - } exceed, notexceed; 306 - } police; 278 + struct flow_action_police police; /* FLOW_ACTION_POLICE */ 307 279 struct { /* FLOW_ACTION_CT */ 308 280 int action; 309 281 u16 zone;
+2 -3
net/dsa/user.c
··· 1459 1459 struct netlink_ext_ack *extack = cls->common.extack; 1460 1460 struct dsa_port *dp = dsa_user_to_port(dev); 1461 1461 struct dsa_user_priv *p = netdev_priv(dev); 1462 - struct dsa_mall_policer_tc_entry *policer; 1463 1462 struct dsa_mall_tc_entry *mall_tc_entry; 1463 + struct flow_action_police *policer; 1464 1464 struct dsa_switch *ds = dp->ds; 1465 1465 struct flow_action_entry *act; 1466 1466 int err; ··· 1497 1497 mall_tc_entry->cookie = cls->cookie; 1498 1498 mall_tc_entry->type = DSA_PORT_MALL_POLICER; 1499 1499 policer = &mall_tc_entry->policer; 1500 - policer->rate_bytes_per_sec = act->police.rate_bytes_ps; 1501 - policer->burst = act->police.burst; 1500 + *policer = act->police; 1502 1501 1503 1502 err = ds->ops->port_policer_add(ds, dp->index, policer); 1504 1503 if (err) {