* [PATCH net-next v3] net: mlx5: Allow police as the last action of a TC rule
@ 2026-11-24 22:02 Mohsin Bashir
2026-11-26 16:04 ` netdev-bot+sashiko
0 siblings, 1 reply; 3+ messages in thread
From: Mohsin Bashir @ 2026-11-24 22:02 UTC (permalink / raw)
To: netdev
Cc: saeedm, leon, tariqt, mbloch, cjubran, andrew+netdev, davem,
edumazet, kuba, pabeni, mohsin.bashr, linux-rdma, linux-kernel
From: Mohsin Bashir <hmohsin@meta.com>
In switchdev mode, mlx5 does not offload a rule where police is the last
action, although TC needs no other action for such a rule. The upcoming
selftest series relies on these rules. With nothing after police, the
police result alone decides where the packet goes, so each result must
be offloaded as TC executes it. The driver does not do that today. An ok
result is handled as pipe and runs the actions after police, a pipe
result always returns to the post action table, and a jump is counted
from police while TC counts it from the start of the action list. A rate
police is also rejected by verify_attr_actions(), as its forward to the
post meter table is added only after the check.
Make the offloaded rule behave as it does in TC. An ok result ends
processing in TC. A pipe result does the same when police is the last
action. Send both to the end of the TC chains as the driver already does
for gact ok. For jump, offload only the simple case where police is the
first action and the skipped actions are all drop or all ok. Reject the
rest. Existing rules where police is followed by other actions also
change. An ok result now accepts the packet instead of running those
actions. Finally set the forward to the post meter table while parsing
police. This is already done for police with mtu and lets a police-only
rule pass verify_attr_actions().
Tested on a ConnectX-7 in switchdev mode with the commands below. The
hardware drop counter showed that the rules are offloaded and limit the
traffic to the configured rate, that the second police only sees the
packets conforming to the first, and that the jump lands on its target.
tc filter add dev eth0 ingress pref 100 protocol ipv6 flower skip_sw \
ip_proto udp dst_port 5201 \
action police rate 100mbit burst 1m conform-exceed drop/ok
tc filter add dev eth0 ingress pref 100 protocol ipv6 flower skip_sw \
ip_proto udp dst_port 5201 \
action police rate 200mbit burst 1m conform-exceed drop/pipe \
action police rate 100mbit burst 1m conform-exceed drop/pipe
tc filter add dev eth0 ingress pref 100 protocol ipv6 flower skip_sw \
ip_proto udp dst_port 5201 \
action police rate 100mbit burst 1m conform-exceed drop / jump 2 \
action drop action ok
Cc: Carolina Jubran <cjubran@nvidia.com>
Signed-off-by: Mohsin Bashir <hmohsin@meta.com>
---
Changelog:
v3:
- Offload jump only when police is the first action, the target is a
later action, the skipped actions are all drop or all ok, and the
same action is not used twice in a row, as discussed on v2:
https://lore.kernel.org/netdev/5c493bd0-31f5-430a-844a-ad011a5f0ba8@nvidia.com
- Update commit message
v2: https://lore.kernel.org/netdev/20261119040010.1405900-1-mohsin.bashr@gmail.com
v1: https://lore.kernel.org/netdev/20261117031337.4126403-1-mohsin.bashr@gmail.com
---
.../mellanox/mlx5/core/en/tc/act/police.c | 59 ++++++++++++++++++-
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 26 +++++---
2 files changed, 75 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
index 1bd1c94fb977..f03a992cbc27 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
@@ -37,6 +37,52 @@ static int police_act_validate(const struct flow_action_entry *act,
return 0;
}
+static bool
+police_act_can_offload_jump(struct mlx5e_tc_act_parse_state *parse_state,
+ const struct flow_action_entry *act,
+ int act_index, u32 target)
+{
+ const struct flow_action *flow_action = parse_state->flow_action;
+ struct netlink_ext_ack *extack = parse_state->extack;
+ const struct flow_action_entry *prev, *entry;
+ u32 i;
+
+ if (act_index) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Jump is only supported when police is the first action");
+ return false;
+ }
+
+ if (!target || target >= flow_action->num_entries) {
+ NL_SET_ERR_MSG_MOD(extack, "Jump target must be a later action");
+ return false;
+ }
+
+ prev = act;
+ for (i = 1; i <= target; i++) {
+ entry = &flow_action->entries[i];
+
+ if (i < target &&
+ ((entry->id != FLOW_ACTION_DROP &&
+ entry->id != FLOW_ACTION_ACCEPT) ||
+ entry->id != flow_action->entries[1].id)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Jump can only skip actions that are all drop or all ok");
+ return false;
+ }
+
+ if (entry->id == prev->id && entry->hw_index == prev->hw_index) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Jump over the same action twice in a row is not supported");
+ return false;
+ }
+
+ prev = entry;
+ }
+
+ return true;
+}
+
static bool
tc_act_can_offload_police(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
@@ -49,6 +95,16 @@ tc_act_can_offload_police(struct mlx5e_tc_act_parse_state *parse_state,
if (err)
return false;
+ if (act->police.exceed.act_id == FLOW_ACTION_JUMP &&
+ !police_act_can_offload_jump(parse_state, act, act_index,
+ act->police.exceed.extval))
+ return false;
+
+ if (act->police.notexceed.act_id == FLOW_ACTION_JUMP &&
+ !police_act_can_offload_jump(parse_state, act, act_index,
+ act->police.notexceed.extval))
+ return false;
+
return !!mlx5e_get_flow_meters(parse_state->flow->priv->mdev);
}
@@ -94,13 +150,14 @@ tc_act_parse_police(struct mlx5e_tc_act_parse_state *parse_state,
MLX5_FLOW_STEERING_CAP_MATCH_RANGES))
return -EOPNOTSUPP;
- attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
attr->flags |= MLX5_ATTR_FLAG_MTU;
} else {
attr->action |= MLX5_FLOW_CONTEXT_ACTION_EXECUTE_ASO;
attr->exe_aso_type = MLX5_EXE_ASO_FLOW_METER;
}
+ attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
+
return 0;
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 1d35c97aea0b..7e7111e6d058 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -3874,7 +3874,7 @@ static int
alloc_branch_attr(struct mlx5e_tc_flow *flow,
struct mlx5e_tc_act_branch_ctrl *cond,
struct mlx5_flow_attr **cond_attr,
- u32 *jump_count,
+ u32 *jump_count, bool last,
struct netlink_ext_ack *extack)
{
struct mlx5_flow_attr *attr;
@@ -3891,11 +3891,17 @@ alloc_branch_attr(struct mlx5e_tc_flow *flow,
case FLOW_ACTION_DROP:
attr->action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
break;
- case FLOW_ACTION_ACCEPT:
case FLOW_ACTION_PIPE:
- err = set_branch_dest_ft(flow->priv, attr);
- if (err)
- goto out_err;
+ if (!last) {
+ err = set_branch_dest_ft(flow->priv, attr);
+ if (err)
+ goto out_err;
+ break;
+ }
+ fallthrough;
+ case FLOW_ACTION_ACCEPT:
+ attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
+ attr->flags |= MLX5_ATTR_FLAG_ACCEPT;
break;
case FLOW_ACTION_JUMP:
if (*jump_count) {
@@ -3967,7 +3973,7 @@ dec_jump_count(struct flow_action_entry *act, struct mlx5e_tc_act *tc_act,
static int
parse_branch_ctrl(struct flow_action_entry *act, struct mlx5e_tc_act *tc_act,
struct mlx5e_tc_flow *flow, struct mlx5_flow_attr *attr,
- struct mlx5e_tc_jump_state *jump_state,
+ struct mlx5e_tc_jump_state *jump_state, bool last,
struct netlink_ext_ack *extack)
{
struct mlx5e_tc_act_branch_ctrl cond_true, cond_false;
@@ -3980,7 +3986,7 @@ parse_branch_ctrl(struct flow_action_entry *act, struct mlx5e_tc_act *tc_act,
tc_act->get_branch_ctrl(act, &cond_true, &cond_false);
err = alloc_branch_attr(flow, &cond_true,
- &attr->branch_true, &jump_count, extack);
+ &attr->branch_true, &jump_count, last, extack);
if (err)
goto out_err;
@@ -3988,7 +3994,7 @@ parse_branch_ctrl(struct flow_action_entry *act, struct mlx5e_tc_act *tc_act,
jump_state->jumping_attr = attr->branch_true;
err = alloc_branch_attr(flow, &cond_false,
- &attr->branch_false, &jump_count, extack);
+ &attr->branch_false, &jump_count, last, extack);
if (err)
goto err_branch_false;
@@ -4052,7 +4058,9 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
dec_jump_count(act, tc_act, attr, priv, &jump_state);
- err = parse_branch_ctrl(act, tc_act, flow, attr, &jump_state, extack);
+ err = parse_branch_ctrl(act, tc_act, flow, attr, &jump_state,
+ flow_action_is_last_entry(flow_action, act),
+ extack);
if (err)
goto out_free_post_acts;
--
2.53.1-Meta
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next v3] net: mlx5: Allow police as the last action of a TC rule
2026-11-24 22:02 [PATCH net-next v3] net: mlx5: Allow police as the last action of a TC rule Mohsin Bashir
@ 2026-11-26 16:04 ` netdev-bot+sashiko
2026-11-26 21:54 ` Mohsin Bashir
0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-11-26 16:04 UTC (permalink / raw)
To: mohsin.bashr
Cc: netdev, saeedm, leon, tariqt, mbloch, cjubran, andrew+netdev,
davem, edumazet, kuba, pabeni, linux-rdma, linux-kernel
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] In police_act_can_offload_jump()
(drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c), every…
- [Low] Besides adding police-as-last-action support, the patch fixes two
hardware/software mismatches in existing offloaded rules, both present…
--
net: mlx5: Allow police as the last action of a TC rule
This patch lets mlx5 offload TC rules in switchdev mode where police is
the last action. It also changes how police results are offloaded: ok is
now accept, pipe as the last action is accept, and a jump is only
offloaded when police is the first action and the skipped actions are all
drop or all ok. The forward to the post meter table is now set for rate
police as well as mtu police.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
> index 1bd1c94fb9776..f03a992cbc270 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
> @@ -37,6 +37,52 @@ static int police_act_validate(const struct flow_action_entry *act,
> return 0;
> }
>
> +static bool
> +police_act_can_offload_jump(struct mlx5e_tc_act_parse_state *parse_state,
> + const struct flow_action_entry *act,
> + int act_index, u32 target)
> +{
[ ... ]
> + prev = act;
> + for (i = 1; i <= target; i++) {
> + entry = &flow_action->entries[i];
> +
> + if (i < target &&
> + ((entry->id != FLOW_ACTION_DROP &&
> + entry->id != FLOW_ACTION_ACCEPT) ||
> + entry->id != flow_action->entries[1].id)) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Jump can only skip actions that are all drop or all ok");
> + return false;
> + }
[Severity: Medium]
Does this check stop offloading police-first jump rules that were offloaded
correctly before this patch?
tc_act_can_offload_police() calls police_act_can_offload_jump() for each
jump result of both rate and mtu police. With police at index 0, any
skipped action other than drop or ok is now rejected. For example:
action police mtu 1500 conform-exceed pipe/jump 2 \
action mirred egress redirect dev A \
action mirred egress redirect dev B
Before this patch, dec_jump_count() already handled this case when police
is at index 0. jump_count is set to extval and decremented once per
distinct TC action, so the jump lands on the same entry where
tcf_action_exec() restarts.
The last skipped action is either marked terminating or forwarded to the
post action table (as for mirror):
dec_jump_count() {
...
if (tc_act->is_terminating_action) { /* the branch ends here */
attr->flags |= MLX5_ATTR_FLAG_TERMINATING;
...
} else { /* the branch continues executing the rest of the actions */
attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
...
}
With this patch these rules fail can_offload with "Jump can only skip
actions that are all drop or all ok". With skip_sw the filter add fails.
Without skip_sw (for example with OVS) the traffic goes to the software
datapath.
The only flaw the commit message names in the old jump handling is that
the jump is counted from police instead of from the start of the action
list. That cannot happen when police is at index 0, and the act_index
check above already rejects the other case.
Is the extra all drop or all ok restriction needed? If it is intentional,
could the commit message say that rules which offload today will stop
offloading, instead of only "Reject the rest"?
> +
> + if (entry->id == prev->id && entry->hw_index == prev->hw_index) {
[ ... ]
> @@ -49,6 +95,16 @@ tc_act_can_offload_police(struct mlx5e_tc_act_parse_state *parse_state,
> if (err)
> return false;
>
> + if (act->police.exceed.act_id == FLOW_ACTION_JUMP &&
> + !police_act_can_offload_jump(parse_state, act, act_index,
> + act->police.exceed.extval))
> + return false;
> +
> + if (act->police.notexceed.act_id == FLOW_ACTION_JUMP &&
> + !police_act_can_offload_jump(parse_state, act, act_index,
> + act->police.notexceed.extval))
> + return false;
> +
> return !!mlx5e_get_flow_meters(parse_state->flow->priv->mdev);
> }
[ ... ]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 1d35c97aea0bc..7e7111e6d058b 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
[ ... ]
> @@ -3891,11 +3891,17 @@ alloc_branch_attr(struct mlx5e_tc_flow *flow,
> case FLOW_ACTION_DROP:
> attr->action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
> break;
> - case FLOW_ACTION_ACCEPT:
> case FLOW_ACTION_PIPE:
> - err = set_branch_dest_ft(flow->priv, attr);
> - if (err)
> - goto out_err;
> + if (!last) {
> + err = set_branch_dest_ft(flow->priv, attr);
> + if (err)
> + goto out_err;
> + break;
> + }
> + fallthrough;
> + case FLOW_ACTION_ACCEPT:
> + attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
> + attr->flags |= MLX5_ATTR_FLAG_ACCEPT;
> break;
[Severity: Low]
This isn't a runtime bug in the patch. However, this hunk and the
act_index check in police_act_can_offload_jump() also fix two
hardware/software mismatches in rules that are already offloaded.
First, alloc_branch_attr() handled an ok police result like pipe. For
"police ... conform-exceed drop/ok action mirred ...", the hardware ran
the following actions for conforming packets, while tcf_action_exec()
stops at TC_ACT_OK.
Second, dec_jump_count() counts a police jump from the police action,
while TC counts from the start of the list. With police at a non-zero
index, the hardware ran different actions than software did.
Both seem to date back to the branching support in commit f86488cb4685
("net/mlx5e: TC, initialize branch flow attributes") and its follow-up
c84fa1ab94a77c ("net/mlx5e: TC, initialize branching action with target
attr").
The commit message describes the behavior change, but there is no Fixes:
tag, and the fixes are mixed with the new police-as-last-action support.
Could these fixes be split out and sent to net with Fixes: tags, so that
stable trees pick them up?
> case FLOW_ACTION_JUMP:
> if (*jump_count) {
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124220251.776944-1-mohsin.bashr%40gmail.com
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next v3] net: mlx5: Allow police as the last action of a TC rule
2026-11-26 16:04 ` netdev-bot+sashiko
@ 2026-11-26 21:54 ` Mohsin Bashir
0 siblings, 0 replies; 3+ messages in thread
From: Mohsin Bashir @ 2026-11-26 21:54 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: netdev, saeedm, leon, tariqt, mbloch, cjubran, andrew+netdev,
davem, edumazet, kuba, pabeni, linux-rdma, linux-kernel
On 11/26/26 8:04 AM, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 1
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] In police_act_can_offload_jump()
> (drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c), every…
> - [Low] Besides adding police-as-last-action support, the patch fixes two
> hardware/software mismatches in existing offloaded rules, both present…
>
> --
>
> net: mlx5: Allow police as the last action of a TC rule
>
> This patch lets mlx5 offload TC rules in switchdev mode where police is
> the last action. It also changes how police results are offloaded: ok is
> now accept, pipe as the last action is accept, and a jump is only
> offloaded when police is the first action and the skipped actions are all
> drop or all ok. The forward to the post meter table is now set for rate
> police as well as mtu police.
>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
>> index 1bd1c94fb9776..f03a992cbc270 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
>> @@ -37,6 +37,52 @@ static int police_act_validate(const struct flow_action_entry *act,
>> return 0;
>> }
>>
>> +static bool
>> +police_act_can_offload_jump(struct mlx5e_tc_act_parse_state *parse_state,
>> + const struct flow_action_entry *act,
>> + int act_index, u32 target)
>> +{
>
> [ ... ]
>
>> + prev = act;
>> + for (i = 1; i <= target; i++) {
>> + entry = &flow_action->entries[i];
>> +
>> + if (i < target &&
>> + ((entry->id != FLOW_ACTION_DROP &&
>> + entry->id != FLOW_ACTION_ACCEPT) ||
>> + entry->id != flow_action->entries[1].id)) {
>> + NL_SET_ERR_MSG_MOD(extack,
>> + "Jump can only skip actions that are all drop or all ok");
>> + return false;
>> + }
>
> [Severity: Medium]
>
> Does this check stop offloading police-first jump rules that were offloaded
> correctly before this patch?
>
> tc_act_can_offload_police() calls police_act_can_offload_jump() for each
> jump result of both rate and mtu police. With police at index 0, any
> skipped action other than drop or ok is now rejected. For example:
>
> action police mtu 1500 conform-exceed pipe/jump 2 \
> action mirred egress redirect dev A \
> action mirred egress redirect dev B
>
> Before this patch, dec_jump_count() already handled this case when police
> is at index 0. jump_count is set to extval and decremented once per
> distinct TC action, so the jump lands on the same entry where
> tcf_action_exec() restarts.
>
> The last skipped action is either marked terminating or forwarded to the
> post action table (as for mirror):
>
> dec_jump_count() {
> ...
> if (tc_act->is_terminating_action) { /* the branch ends here */
> attr->flags |= MLX5_ATTR_FLAG_TERMINATING;
> ...
> } else { /* the branch continues executing the rest of the actions */
> attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
> ...
> }
>
> With this patch these rules fail can_offload with "Jump can only skip
> actions that are all drop or all ok". With skip_sw the filter add fails.
> Without skip_sw (for example with OVS) the traffic goes to the software
> datapath.
>
> The only flaw the commit message names in the old jump handling is that
> the jump is counted from police instead of from the start of the action
> list. That cannot happen when police is at index 0, and the act_index
> check above already rejects the other case.
>
> Is the extra all drop or all ok restriction needed? If it is intentional,
> could the commit message say that rules which offload today will stop
> offloading, instead of only "Reject the rest"?
>
Thanks for the review. Yes, this is intentional. Please see the
discussion on v1 and v2
https://lore.kernel.org/netdev/20261117031337.4126403-1-mohsin.bashr@gmail.com
https://lore.kernel.org/netdev/20261119040010.1405900-1-mohsin.bashr@gmail.com
In summary, we discussed that a jump either executes the correct target
or the offload is rejected.
Police first alone does not meet this expectation. My understanding is
that the driver counts a jump in flow action entries, while TC counts it
in TC actions, and the two do not always match. This can be an issue
when one TC action gives entries of different types, for example a pedit
with a set and an add key. I have not tested this on HW though. Maybe
Mark or someone else from NVIDIA can correct me here.
>> +
>> + if (entry->id == prev->id && entry->hw_index == prev->hw_index) {
>
> [ ... ]
>
>> @@ -49,6 +95,16 @@ tc_act_can_offload_police(struct mlx5e_tc_act_parse_state *parse_state,
>> if (err)
>> return false;
>>
>> + if (act->police.exceed.act_id == FLOW_ACTION_JUMP &&
>> + !police_act_can_offload_jump(parse_state, act, act_index,
>> + act->police.exceed.extval))
>> + return false;
>> +
>> + if (act->police.notexceed.act_id == FLOW_ACTION_JUMP &&
>> + !police_act_can_offload_jump(parse_state, act, act_index,
>> + act->police.notexceed.extval))
>> + return false;
>> +
>> return !!mlx5e_get_flow_meters(parse_state->flow->priv->mdev);
>> }
>
> [ ... ]
>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
>> index 1d35c97aea0bc..7e7111e6d058b 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
>
> [ ... ]
>
>> @@ -3891,11 +3891,17 @@ alloc_branch_attr(struct mlx5e_tc_flow *flow,
>> case FLOW_ACTION_DROP:
>> attr->action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
>> break;
>> - case FLOW_ACTION_ACCEPT:
>> case FLOW_ACTION_PIPE:
>> - err = set_branch_dest_ft(flow->priv, attr);
>> - if (err)
>> - goto out_err;
>> + if (!last) {
>> + err = set_branch_dest_ft(flow->priv, attr);
>> + if (err)
>> + goto out_err;
>> + break;
>> + }
>> + fallthrough;
>> + case FLOW_ACTION_ACCEPT:
>> + attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
>> + attr->flags |= MLX5_ATTR_FLAG_ACCEPT;
>> break;
>
> [Severity: Low]
>
> This isn't a runtime bug in the patch. However, this hunk and the
> act_index check in police_act_can_offload_jump() also fix two
> hardware/software mismatches in rules that are already offloaded.
>
> First, alloc_branch_attr() handled an ok police result like pipe. For
> "police ... conform-exceed drop/ok action mirred ...", the hardware ran
> the following actions for conforming packets, while tcf_action_exec()
> stops at TC_ACT_OK.
>
> Second, dec_jump_count() counts a police jump from the police action,
> while TC counts from the start of the list. With police at a non-zero
> index, the hardware ran different actions than software did.
>
> Both seem to date back to the branching support in commit f86488cb4685
> ("net/mlx5e: TC, initialize branch flow attributes") and its follow-up
> c84fa1ab94a77c ("net/mlx5e: TC, initialize branching action with target
> attr").
>
> The commit message describes the behavior change, but there is no Fixes:
> tag, and the fixes are mixed with the new police-as-last-action support.
> Could these fixes be split out and sent to net with Fixes: tags, so that
> stable trees pick them up?
>
I kept them in net-next on purpose, since both change the behavior of
rules that are offloaded today. That said, if the maintainers prefer, I
can split them out to net with appropriate fixes tags.
>> case FLOW_ACTION_JUMP:
>> if (*jump_count) {
>
> [ ... ]
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-26 21:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 22:02 [PATCH net-next v3] net: mlx5: Allow police as the last action of a TC rule Mohsin Bashir
2026-11-26 16:04 ` netdev-bot+sashiko
2026-11-26 21:54 ` Mohsin Bashir
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®