Skip to content

Commit 65ccacc

Browse files
sodarraslandarawsheh
authored andcommitted
net/mlx5: rework root flow group checks in table create
Before this patch, during flow actions translation done in template table create, there were a lot of checks for group with index 0. This group is special, because flow rules in that group are created through mlx5 kernel driver. For this reason, this group is referred to as root group or root table. This patch reworks these group index checks for clarity: - A dedicated function for checking if group index refers to root group is added. - All direct group index checks in actions translation are replaced with a check for result of that function. - Redundant group translation checks in actions translation is removed. Group indexes are already translated at that point. - Root group check for internal default miss action is removed. This action is supported on root group assuming rdma-core supports it. If rdma-core core does not support it, then HWS layer will reject accordingly. Signed-off-by: Dariusz Sosnowski <[email protected]> Acked-by: Bing Zhao <[email protected]>
1 parent 21a82be commit 65ccacc

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

drivers/net/mlx5/mlx5_flow.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,23 @@ struct mlx5_flow_group {
16481648
struct mlx5_list *matchers;
16491649
};
16501650

1651+
/**
1652+
* Returns true if a group with the given index is a root group.
1653+
*
1654+
* @param group_id
1655+
* Group index.
1656+
* It is assumed that provided index is already translated from user index to PMD index
1657+
* (as is for transfer groups for example).
1658+
*
1659+
* @returns
1660+
* True if group is a root group.
1661+
* False otherwise.
1662+
*/
1663+
static inline bool
1664+
mlx5_group_id_is_root(uint32_t group_id)
1665+
{
1666+
return group_id == 0;
1667+
}
16511668

16521669
#define MLX5_HW_TBL_MAX_ITEM_TEMPLATE 32
16531670
#define MLX5_HW_TBL_MAX_ACTION_TEMPLATE 32

drivers/net/mlx5/mlx5_flow_hw.c

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
25252525
unsigned int of_vlan_offset;
25262526
uint32_t ct_idx;
25272527
int ret, err;
2528-
uint32_t target_grp = 0;
2528+
bool is_root = mlx5_group_id_is_root(cfg->attr.flow_attr.group);
25292529
bool unified_fdb = is_unified_fdb(priv);
25302530

25312531
flow_hw_modify_field_init(&mhdr, at);
@@ -2537,7 +2537,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
25372537

25382538
switch ((int)actions->type) {
25392539
case RTE_FLOW_ACTION_TYPE_INDIRECT_LIST:
2540-
if (!attr->group) {
2540+
if (is_root) {
25412541
DRV_LOG(ERR, "Indirect action is not supported in root table.");
25422542
goto err;
25432543
}
@@ -2547,7 +2547,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
25472547
goto err;
25482548
break;
25492549
case RTE_FLOW_ACTION_TYPE_INDIRECT:
2550-
if (!attr->group) {
2550+
if (is_root) {
25512551
DRV_LOG(ERR, "Indirect action is not supported in root table.");
25522552
goto err;
25532553
}
@@ -2568,7 +2568,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
25682568
priv->hw_drop[!!attr->group];
25692569
break;
25702570
case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR:
2571-
if (!attr->group) {
2571+
if (is_root) {
25722572
DRV_LOG(ERR, "Port representor is not supported in root table.");
25732573
goto err;
25742574
}
@@ -2763,11 +2763,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
27632763
recom_type = MLX5DR_ACTION_TYP_POP_IPV6_ROUTE_EXT;
27642764
break;
27652765
case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL:
2766-
ret = flow_hw_translate_group(dev, cfg, attr->group,
2767-
&target_grp, &sub_error);
2768-
if (ret)
2769-
goto err;
2770-
if (target_grp == 0) {
2766+
if (is_root) {
27712767
__flow_hw_action_template_destroy(dev, acts);
27722768
rte_flow_error_set(&sub_error, ENOTSUP,
27732769
RTE_FLOW_ERROR_TYPE_ACTION,
@@ -2791,11 +2787,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
27912787
goto err;
27922788
break;
27932789
case RTE_FLOW_ACTION_TYPE_AGE:
2794-
ret = flow_hw_translate_group(dev, cfg, attr->group,
2795-
&target_grp, &sub_error);
2796-
if (ret)
2797-
goto err;
2798-
if (target_grp == 0) {
2790+
if (is_root) {
27992791
__flow_hw_action_template_destroy(dev, acts);
28002792
rte_flow_error_set(&sub_error, ENOTSUP,
28012793
RTE_FLOW_ERROR_TYPE_ACTION,
@@ -2810,11 +2802,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
28102802
goto err;
28112803
break;
28122804
case RTE_FLOW_ACTION_TYPE_COUNT:
2813-
ret = flow_hw_translate_group(dev, cfg, attr->group,
2814-
&target_grp, &sub_error);
2815-
if (ret)
2816-
goto err;
2817-
if (target_grp == 0) {
2805+
if (is_root) {
28182806
__flow_hw_action_template_destroy(dev, acts);
28192807
rte_flow_error_set(&sub_error, ENOTSUP,
28202808
RTE_FLOW_ERROR_TYPE_ACTION,
@@ -2873,12 +2861,6 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
28732861
goto err;
28742862
break;
28752863
case MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS:
2876-
/* Internal, can be skipped. */
2877-
if (!!attr->group) {
2878-
DRV_LOG(ERR, "DEFAULT MISS action is only"
2879-
" supported in root table.");
2880-
goto err;
2881-
}
28822864
acts->rule_acts[dr_pos].action = priv->hw_def_miss;
28832865
break;
28842866
case RTE_FLOW_ACTION_TYPE_NAT64:

0 commit comments

Comments
 (0)