-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net/mlx5e: TC, Support offloading police action
Add parsing support by implementing struct mlx5e_tc_act for police action. TC rule with police actions is broken down into several rules in different tables. One rule with the original match in the original flow table, which set fte_id, do metering, and jump to the post_meter table. If there are more police actions, more rules are created for each of them. Besides, a last rule is created in the end. In post_meter table, there are two pre-defined rules, one is to drop packet if its packet color is RED, the other is to jump back to post_act table. As fte_id is updated before jumping, the rule for next meter is matched to do another round of metering (if there are multiple meters in the flow rule). Otherwise, last fte_id is matched and do the original actions. Signed-off-by: Jianbo Liu <jianbol@nvidia.com> Reviewed-by: Roi Dayan <roid@nvidia.com> Reviewed-by: Ariel Levkovich <lariel@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
- Loading branch information
Jianbo Liu
authored and
Saeed Mahameed
committed
Jul 2, 2022
1 parent
03a92a9
commit a8d52b0
Showing
9 changed files
with
124 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB | ||
// Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
|
||
#include "act.h" | ||
#include "en/tc_priv.h" | ||
|
||
static bool | ||
tc_act_can_offload_police(struct mlx5e_tc_act_parse_state *parse_state, | ||
const struct flow_action_entry *act, | ||
int act_index, | ||
struct mlx5_flow_attr *attr) | ||
{ | ||
if (mlx5e_policer_validate(parse_state->flow_action, act, | ||
parse_state->extack)) | ||
return false; | ||
|
||
return !!mlx5e_get_flow_meters(parse_state->flow->priv->mdev); | ||
} | ||
|
||
static int | ||
tc_act_parse_police(struct mlx5e_tc_act_parse_state *parse_state, | ||
const struct flow_action_entry *act, | ||
struct mlx5e_priv *priv, | ||
struct mlx5_flow_attr *attr) | ||
{ | ||
struct mlx5e_flow_meter_params *params; | ||
|
||
params = &attr->meter_attr.params; | ||
params->index = act->hw_index; | ||
if (act->police.rate_bytes_ps) { | ||
params->mode = MLX5_RATE_LIMIT_BPS; | ||
/* change rate to bits per second */ | ||
params->rate = act->police.rate_bytes_ps << 3; | ||
params->burst = act->police.burst; | ||
} else if (act->police.rate_pkt_ps) { | ||
params->mode = MLX5_RATE_LIMIT_PPS; | ||
params->rate = act->police.rate_pkt_ps; | ||
params->burst = act->police.burst_pkt; | ||
} else { | ||
return -EOPNOTSUPP; | ||
} | ||
|
||
attr->action |= MLX5_FLOW_CONTEXT_ACTION_EXECUTE_ASO; | ||
attr->exe_aso_type = MLX5_EXE_ASO_FLOW_METER; | ||
|
||
return 0; | ||
} | ||
|
||
static bool | ||
tc_act_is_multi_table_act_police(struct mlx5e_priv *priv, | ||
const struct flow_action_entry *act, | ||
struct mlx5_flow_attr *attr) | ||
{ | ||
return true; | ||
} | ||
|
||
struct mlx5e_tc_act mlx5e_tc_act_police = { | ||
.can_offload = tc_act_can_offload_police, | ||
.parse_action = tc_act_parse_police, | ||
.is_multi_table_act = tc_act_is_multi_table_act_police, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters