mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:04:41 +01:00
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>
This commit is contained in:
parent
86dbebfb90
commit
c22ba07c82
5 changed files with 24 additions and 29 deletions
|
|
@ -2003,11 +2003,11 @@ static int felix_cls_flower_stats(struct dsa_switch *ds, int port,
|
|||
}
|
||||
|
||||
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 = ds->priv;
|
||||
struct ocelot_policer pol = {
|
||||
.rate = div_u64(policer->rate_bytes_per_sec, 1000) * 8,
|
||||
.rate = div_u64(policer->rate_bytes_ps, 1000) * 8,
|
||||
.burst = policer->burst,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2841,7 +2841,7 @@ static void sja1105_mirror_del(struct dsa_switch *ds, int port,
|
|||
}
|
||||
|
||||
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 = 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 = div_u64(512 * policer->rate_bytes_per_sec,
|
||||
policing[port].rate = div_u64(512 * policer->rate_bytes_ps,
|
||||
1000000);
|
||||
policing[port].smax = policer->burst;
|
||||
|
||||
|
|
|
|||
|
|
@ -216,12 +216,6 @@ struct dsa_mall_mirror_tc_entry {
|
|||
bool ingress;
|
||||
};
|
||||
|
||||
/* 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;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -231,6 +231,21 @@ struct flow_action_cookie *flow_action_cookie_create(void *data,
|
|||
gfp_t gfp);
|
||||
void flow_action_cookie_destroy(struct flow_action_cookie *cookie);
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -1459,8 +1459,8 @@ dsa_user_add_cls_matchall_police(struct net_device *dev,
|
|||
struct netlink_ext_ack *extack = cls->common.extack;
|
||||
struct dsa_port *dp = dsa_user_to_port(dev);
|
||||
struct dsa_user_priv *p = 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 = dp->ds;
|
||||
struct flow_action_entry *act;
|
||||
int err;
|
||||
|
|
@ -1497,8 +1497,7 @@ dsa_user_add_cls_matchall_police(struct net_device *dev,
|
|||
mall_tc_entry->cookie = cls->cookie;
|
||||
mall_tc_entry->type = DSA_PORT_MALL_POLICER;
|
||||
policer = &mall_tc_entry->policer;
|
||||
policer->rate_bytes_per_sec = act->police.rate_bytes_ps;
|
||||
policer->burst = act->police.burst;
|
||||
*policer = act->police;
|
||||
|
||||
err = ds->ops->port_policer_add(ds, dp->index, policer);
|
||||
if (err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue