Skip to content

Commit

Permalink
net/i40e: fix flow director input set conflict
Browse files Browse the repository at this point in the history
[ upstream commit 2fefa09 ]

Currently, there'll be conflict error when running
the following commands:
1. flow create 0 ingress
     pattern eth / ipv4 / udp src is 32 / end
     actions queue index 2 / end
2. flow destroy 0 rule 0
3. flow create 0 ingress
     pattern eth / ipv4 / udp dst is 32 / end
     actions queue index 2 / end

This patch fixes the input set conflict issue.

Fixes: 42044b6 ("net/i40e: support input set selection for FDIR")
Fixes: 4a072ad ("net/i40e: fix flow director config after flow validate")

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Tested-by: Lingli Chen <linglix.chen@intel.com>
  • Loading branch information
beileix authored and bluca committed Jul 12, 2021
1 parent d2db814 commit 5299dc3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions drivers/net/i40e/i40e_ethdev.c
Expand Up @@ -1082,6 +1082,7 @@ i40e_init_fdir_filter_list(struct rte_eth_dev *dev)
char fdir_hash_name[RTE_HASH_NAMESIZE];
uint32_t alloc = hw->func_caps.fd_filters_guaranteed;
uint32_t best = hw->func_caps.fd_filters_best_effort;
enum i40e_filter_pctype pctype;
struct rte_bitmap *bmp = NULL;
uint32_t bmp_size;
void *mem = NULL;
Expand Down Expand Up @@ -1130,6 +1131,10 @@ i40e_init_fdir_filter_list(struct rte_eth_dev *dev)
goto err_fdir_filter_array_alloc;
}

for (pctype = I40E_FILTER_PCTYPE_NONF_IPV4_UDP;
pctype <= I40E_FILTER_PCTYPE_L2_PAYLOAD; pctype++)
pf->fdir.flow_count[pctype] = 0;

fdir_info->fdir_space_size = alloc + best;
fdir_info->fdir_actual_cnt = 0;
fdir_info->fdir_guarantee_total_space = alloc;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/i40e/i40e_ethdev.h
Expand Up @@ -786,7 +786,7 @@ struct i40e_fdir_info {
bool flex_pit_flag[I40E_MAX_FLXPLD_LAYER];
bool flex_mask_flag[I40E_FILTER_PCTYPE_MAX];

bool inset_flag[I40E_FILTER_PCTYPE_MAX]; /* Mark if input set is set */
uint32_t flow_count[I40E_FILTER_PCTYPE_MAX];

uint32_t flex_flow_count[I40E_MAX_FLXPLD_LAYER];
};
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/i40e/i40e_fdir.c
Expand Up @@ -1606,13 +1606,13 @@ i40e_flow_set_fdir_inset(struct i40e_pf *pf,
}

/* Check if the configuration is conflicted */
if (pf->fdir.inset_flag[pctype] &&
if (pf->fdir.flow_count[pctype] &&
memcmp(&pf->fdir.input_set[pctype], &input_set, sizeof(uint64_t))) {
PMD_DRV_LOG(ERR, "Conflict with the first rule's input set.");
return -EINVAL;
}

if (pf->fdir.inset_flag[pctype] &&
if (pf->fdir.flow_count[pctype] &&
!memcmp(&pf->fdir.input_set[pctype], &input_set, sizeof(uint64_t)))
return 0;

Expand Down Expand Up @@ -1665,7 +1665,6 @@ i40e_flow_set_fdir_inset(struct i40e_pf *pf,
I40E_WRITE_FLUSH(hw);

pf->fdir.input_set[pctype] = input_set;
pf->fdir.inset_flag[pctype] = 1;
return 0;
}

Expand Down Expand Up @@ -1889,11 +1888,13 @@ i40e_flow_add_del_fdir_filter(struct rte_eth_dev *dev,
}

if (add) {
fdir_info->flow_count[pctype]++;
fdir_info->fdir_actual_cnt++;
if (fdir_info->fdir_invalprio == 1 &&
fdir_info->fdir_guarantee_free_space > 0)
fdir_info->fdir_guarantee_free_space--;
} else {
fdir_info->flow_count[pctype]--;
fdir_info->fdir_actual_cnt--;
if (fdir_info->fdir_invalprio == 1 &&
fdir_info->fdir_guarantee_free_space <
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/i40e/i40e_flow.c
Expand Up @@ -5501,7 +5501,7 @@ i40e_flow_flush_fdir_filter(struct i40e_pf *pf)

for (pctype = I40E_FILTER_PCTYPE_NONF_IPV4_UDP;
pctype <= I40E_FILTER_PCTYPE_L2_PAYLOAD; pctype++) {
pf->fdir.inset_flag[pctype] = 0;
pf->fdir.flow_count[pctype] = 0;
pf->fdir.flex_mask_flag[pctype] = 0;
}

Expand Down

0 comments on commit 5299dc3

Please sign in to comment.