net/iavf: support priority of flow rule

Add flow rule attribute "priority" support for AVF.

Lower values denote higher priority, the highest priority for
a flow rule is 0.

All subscription rule will have a lower priority than the rules
that be created by host.

Signed-off-by: Jie Wang <jie1x.wang@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
This commit is contained in:
Jie Wang 2022-09-07 13:10:40 +08:00 committed by Qi Zhang
parent 7b902af499
commit 19147456ac
6 changed files with 34 additions and 17 deletions

View File

@ -1583,6 +1583,7 @@ iavf_fdir_parse(struct iavf_adapter *ad,
uint32_t array_len,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
uint32_t priority,
void **meta,
struct rte_flow_error *error)
{
@ -1593,6 +1594,9 @@ iavf_fdir_parse(struct iavf_adapter *ad,
memset(filter, 0, sizeof(*filter));
if (priority >= 1)
return -rte_errno;
item = iavf_search_pattern_match_item(pattern, array, array_len, error);
if (!item)
return -rte_errno;

View File

@ -649,13 +649,13 @@ iavf_fsub_parse(struct iavf_adapter *ad,
uint32_t array_len,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
uint32_t priority,
void **meta,
struct rte_flow_error *error)
{
struct iavf_fsub_conf *filter;
struct iavf_pattern_match_item *pattern_match_item = NULL;
int ret = 0;
uint32_t priority = 0;
filter = rte_zmalloc(NULL, sizeof(*filter), 0);
if (!filter) {

View File

@ -1785,6 +1785,7 @@ enum rte_flow_item_type iavf_pattern_eth_ipv6_udp_l2tpv2_ppp_ipv6_tcp[] = {
typedef struct iavf_flow_engine * (*parse_engine_t)(struct iavf_adapter *ad,
struct rte_flow *flow,
struct iavf_parser_list *parser_list,
uint32_t priority,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
struct rte_flow_error *error);
@ -1951,11 +1952,11 @@ iavf_flow_valid_attr(const struct rte_flow_attr *attr,
return -rte_errno;
}
/* Not supported */
if (attr->priority) {
/* support priority for flow subscribe */
if (attr->priority > 1) {
rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
attr, "Not support priority.");
attr, "Only support priority 0 and 1.");
return -rte_errno;
}
@ -2098,6 +2099,7 @@ static struct iavf_flow_engine *
iavf_parse_engine_create(struct iavf_adapter *ad,
struct rte_flow *flow,
struct iavf_parser_list *parser_list,
uint32_t priority,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
struct rte_flow_error *error)
@ -2111,7 +2113,7 @@ iavf_parse_engine_create(struct iavf_adapter *ad,
if (parser_node->parser->parse_pattern_action(ad,
parser_node->parser->array,
parser_node->parser->array_len,
pattern, actions, &meta, error) < 0)
pattern, actions, priority, &meta, error) < 0)
continue;
engine = parser_node->parser->engine;
@ -2127,6 +2129,7 @@ static struct iavf_flow_engine *
iavf_parse_engine_validate(struct iavf_adapter *ad,
struct rte_flow *flow,
struct iavf_parser_list *parser_list,
uint32_t priority,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
struct rte_flow_error *error)
@ -2140,7 +2143,7 @@ iavf_parse_engine_validate(struct iavf_adapter *ad,
if (parser_node->parser->parse_pattern_action(ad,
parser_node->parser->array,
parser_node->parser->array_len,
pattern, actions, &meta, error) < 0)
pattern, actions, priority, &meta, error) < 0)
continue;
engine = parser_node->parser->engine;
@ -2201,18 +2204,18 @@ iavf_flow_process_filter(struct rte_eth_dev *dev,
if (ret)
return ret;
*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list, pattern,
actions, error);
*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list,
attr->priority, pattern, actions, error);
if (*engine)
return 0;
*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list, pattern,
actions, error);
*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list,
attr->priority, pattern, actions, error);
if (*engine)
return 0;
*engine = iavf_parse_engine(ad, flow, &vf->ipsec_crypto_parser_list,
pattern, actions, error);
attr->priority, pattern, actions, error);
if (*engine)
return 0;

View File

@ -471,6 +471,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,
uint32_t array_len,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
uint32_t priority,
void **meta,
struct rte_flow_error *error);

View File

@ -86,6 +86,7 @@ iavf_hash_parse_pattern_action(struct iavf_adapter *ad,
uint32_t array_len,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
uint32_t priority,
void **meta,
struct rte_flow_error *error);
@ -1509,6 +1510,7 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
uint32_t array_len,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
uint32_t priority,
void **meta,
struct rte_flow_error *error)
{
@ -1517,6 +1519,9 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
uint64_t phint = IAVF_PHINT_NONE;
int ret = 0;
if (priority >= 1)
return -rte_errno;
rss_meta_ptr = rte_zmalloc(NULL, sizeof(*rss_meta_ptr), 0);
if (!rss_meta_ptr) {
rte_flow_error_set(error, EINVAL,

View File

@ -1933,16 +1933,20 @@ static struct iavf_flow_engine iavf_ipsec_flow_engine = {
static int
iavf_ipsec_flow_parse(struct iavf_adapter *ad,
struct iavf_pattern_match_item *array,
uint32_t array_len,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
void **meta,
struct rte_flow_error *error)
struct iavf_pattern_match_item *array,
uint32_t array_len,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
uint32_t priority,
void **meta,
struct rte_flow_error *error)
{
struct iavf_pattern_match_item *item = NULL;
int ret = -1;
if (priority >= 1)
return -rte_errno;
item = iavf_search_pattern_match_item(pattern, array, array_len, error);
if (item && item->meta) {
uint32_t type = (uint64_t)(item->meta);