Skip to content

Commit 5cbe910

Browse files
committed
Merge branch 'flow_offload-hardware-priority-fixes'
Pablo Neira Ayuso says: ==================== flow_offload hardware priority fixes This patchset contains two updates for the flow_offload users: 1) Pass the major tc priority to drivers so they do not have to lshift it. This is a preparation patch for the fix coming in patch #2. 2) Set the hardware priority from the netfilter basechain priority, some drivers break when using the existing hardware priority number that is set to zero. v5: fix patch 2/2 to address a clang warning and to simplify the priority mapping. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 44ef3a0 + 3bc158f commit 5cbe910

File tree

9 files changed

+28
-17
lines changed

9 files changed

+28
-17
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/netfilter/nf_tables_offload.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,6 @@ int nft_flow_rule_offload_commit(struct net *net);
7373
(__reg)->key = __key; \
7474
memset(&(__reg)->mask, 0xff, (__reg)->len);
7575

76+
int nft_chain_offload_priority(struct nft_base_chain *basechain);
77+
7678
#endif

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
}

net/netfilter/nf_tables_api.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,10 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
16671667

16681668
chain->flags |= NFT_BASE_CHAIN | flags;
16691669
basechain->policy = NF_ACCEPT;
1670+
if (chain->flags & NFT_CHAIN_HW_OFFLOAD &&
1671+
nft_chain_offload_priority(basechain) < 0)
1672+
return -EOPNOTSUPP;
1673+
16701674
flow_block_init(&basechain->flow_block);
16711675
} else {
16721676
chain = kzalloc(sizeof(*chain), GFP_KERNEL);

net/netfilter/nf_tables_offload.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ void nft_offload_update_dependency(struct nft_offload_ctx *ctx,
103103
}
104104

105105
static void nft_flow_offload_common_init(struct flow_cls_common_offload *common,
106-
__be16 proto,
107-
struct netlink_ext_ack *extack)
106+
__be16 proto, int priority,
107+
struct netlink_ext_ack *extack)
108108
{
109109
common->protocol = proto;
110+
common->prio = priority;
110111
common->extack = extack;
111112
}
112113

@@ -124,6 +125,15 @@ static int nft_setup_cb_call(struct nft_base_chain *basechain,
124125
return 0;
125126
}
126127

128+
int nft_chain_offload_priority(struct nft_base_chain *basechain)
129+
{
130+
if (basechain->ops.priority <= 0 ||
131+
basechain->ops.priority > USHRT_MAX)
132+
return -1;
133+
134+
return 0;
135+
}
136+
127137
static int nft_flow_offload_rule(struct nft_trans *trans,
128138
enum flow_cls_command command)
129139
{
@@ -142,7 +152,8 @@ static int nft_flow_offload_rule(struct nft_trans *trans,
142152
if (flow)
143153
proto = flow->proto;
144154

145-
nft_flow_offload_common_init(&cls_flow.common, proto, &extack);
155+
nft_flow_offload_common_init(&cls_flow.common, proto,
156+
basechain->ops.priority, &extack);
146157
cls_flow.command = command;
147158
cls_flow.cookie = (unsigned long) rule;
148159
if (flow)

0 commit comments

Comments
 (0)