Skip to content

Commit ef01ada

Browse files
ummakynesdavem330
authored andcommitted
net: sched: use major priority number as hardware priority
tc transparently maps the software priority number to hardware. Update it to pass the major priority which is what most drivers expect. Update drivers too so they do not need to lshift the priority field of the flow_cls_common_offload object. The stmmac driver is an exception, since this code assumes the tc software priority is fine, therefore, lshift it just to be conservative. Signed-off-by: Pablo Neira Ayuso <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 44ef3a0 commit ef01ada

File tree

6 files changed

+8
-14
lines changed

6 files changed

+8
-14
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3167,7 +3167,7 @@ mlx5e_flow_esw_attr_init(struct mlx5_esw_flow_attr *esw_attr,
31673167

31683168
esw_attr->parse_attr = parse_attr;
31693169
esw_attr->chain = f->common.chain_index;
3170-
esw_attr->prio = TC_H_MAJ(f->common.prio) >> 16;
3170+
esw_attr->prio = f->common.prio;
31713171

31723172
esw_attr->in_rep = in_rep;
31733173
esw_attr->in_mdev = in_mdev;

drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei)
471471
void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei,
472472
unsigned int priority)
473473
{
474-
rulei->priority = priority >> 16;
474+
rulei->priority = priority;
475475
}
476476

477477
void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei,

drivers/net/ethernet/mscc/ocelot_flower.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ struct ocelot_port_block {
1313
struct ocelot_port *port;
1414
};
1515

16-
static u16 get_prio(u32 prio)
17-
{
18-
/* prio starts from 0x1000 while the ids starts from 0 */
19-
return prio >> 16;
20-
}
21-
2216
static int ocelot_flower_parse_action(struct flow_cls_offload *f,
2317
struct ocelot_ace_rule *rule)
2418
{
@@ -168,7 +162,7 @@ static int ocelot_flower_parse(struct flow_cls_offload *f,
168162
}
169163

170164
finished_key_parsing:
171-
ocelot_rule->prio = get_prio(f->common.prio);
165+
ocelot_rule->prio = f->common.prio;
172166
ocelot_rule->id = f->cookie;
173167
return ocelot_flower_parse_action(f, ocelot_rule);
174168
}
@@ -218,7 +212,7 @@ static int ocelot_flower_destroy(struct flow_cls_offload *f,
218212
struct ocelot_ace_rule rule;
219213
int ret;
220214

221-
rule.prio = get_prio(f->common.prio);
215+
rule.prio = f->common.prio;
222216
rule.port = port_block->port;
223217
rule.id = f->cookie;
224218

@@ -236,7 +230,7 @@ static int ocelot_flower_stats_update(struct flow_cls_offload *f,
236230
struct ocelot_ace_rule rule;
237231
int ret;
238232

239-
rule.prio = get_prio(f->common.prio);
233+
rule.prio = f->common.prio;
240234
rule.port = port_block->port;
241235
rule.id = f->cookie;
242236
ret = ocelot_ace_rule_stats_update(&rule);

drivers/net/ethernet/netronome/nfp/flower/qos_conf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ nfp_flower_install_rate_limiter(struct nfp_app *app, struct net_device *netdev,
9393
return -EOPNOTSUPP;
9494
}
9595

96-
if (flow->common.prio != (1 << 16)) {
96+
if (flow->common.prio != 1) {
9797
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: qos rate limit offload requires highest priority");
9898
return -EOPNOTSUPP;
9999
}

drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static int tc_fill_entry(struct stmmac_priv *priv,
9494
struct stmmac_tc_entry *entry, *frag = NULL;
9595
struct tc_u32_sel *sel = cls->knode.sel;
9696
u32 off, data, mask, real_off, rem;
97-
u32 prio = cls->common.prio;
97+
u32 prio = cls->common.prio << 16;
9898
int ret;
9999

100100
/* Only 1 match per entry */

include/net/pkt_cls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ tc_cls_common_offload_init(struct flow_cls_common_offload *cls_common,
646646
{
647647
cls_common->chain_index = tp->chain->index;
648648
cls_common->protocol = tp->protocol;
649-
cls_common->prio = tp->prio;
649+
cls_common->prio = tp->prio >> 16;
650650
if (tc_skip_sw(flags) || flags & TCA_CLS_FLAGS_VERBOSE)
651651
cls_common->extack = extack;
652652
}

0 commit comments

Comments
 (0)