X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fnet%2Fmlx5%2Fmlx5_flow.c;h=c914a7120cca61e092ee7c5b9b7525bd579fc9fd;hb=250e2ed8d85d038ce864052ebd6f9af51db40df2;hp=2dba207d2756e9a672559e67da6d8f07dfdf2a71;hpb=6d5735c1cba2e3b7e9eca781fbd79213e176a6c6;p=dpdk.git diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 2dba207d27..c914a7120c 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -100,10 +100,25 @@ struct mlx5_flow_expand_node { * RSS types bit-field associated with this node * (see ETH_RSS_* definitions). */ - uint8_t optional; - /**< optional expand field. Default 0 to expand, 1 not go deeper. */ + uint64_t node_flags; + /**< + * Bit-fields that define how the node is used in the expansion. + * (see MLX5_EXPANSION_NODE_* definitions). + */ }; +/* Optional expand field. The expansion alg will not go deeper. */ +#define MLX5_EXPANSION_NODE_OPTIONAL (UINT64_C(1) << 0) + +/* The node is not added implicitly as expansion to the flow pattern. + * If the node type does not match the flow pattern item type, the + * expansion alg will go deeper to its next items. + * In the current implementation, the list of next nodes indexes can + * have up to one node with this flag set and it has to be the last + * node index (before the list terminator). + */ +#define MLX5_EXPANSION_NODE_EXPLICIT (UINT64_C(1) << 1) + /** Object returned by mlx5_flow_expand_rss(). */ struct mlx5_flow_expand_rss { uint32_t entries; @@ -135,6 +150,7 @@ mlx5_flow_is_rss_expandable_item(const struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_VXLAN_GPE: case RTE_FLOW_ITEM_TYPE_GRE_KEY: case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT: + case RTE_FLOW_ITEM_TYPE_GTP: return true; default: break; @@ -243,6 +259,26 @@ mlx5_flow_expand_rss_item_complete(const struct rte_flow_item *item) return ret; } +static const int * +mlx5_flow_expand_rss_skip_explicit(const struct mlx5_flow_expand_node graph[], + const int *next_node) +{ + const struct mlx5_flow_expand_node *node = NULL; + const int *next = next_node; + + while (next && *next) { + /* + * Skip the nodes with the MLX5_EXPANSION_NODE_EXPLICIT + * flag set, because they were not found in the flow pattern. + */ + node = &graph[*next]; + if (!(node->node_flags & MLX5_EXPANSION_NODE_EXPLICIT)) + break; + next = node->next; + } + return next; +} + #define MLX5_RSS_EXP_ELT_N 16 /** @@ -307,10 +343,17 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, continue; } last_item = item; - for (i = 0; node->next && node->next[i]; ++i) { + i = 0; + while (node->next && node->next[i]) { next = &graph[node->next[i]]; if (next->type == item->type) break; + if (next->node_flags & MLX5_EXPANSION_NODE_EXPLICIT) { + node = next; + i = 0; + } else { + ++i; + } } if (next) node = next; @@ -368,7 +411,8 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, } } memset(flow_items, 0, sizeof(flow_items)); - next_node = node->next; + next_node = mlx5_flow_expand_rss_skip_explicit(graph, + node->next); stack[stack_pos] = next_node; node = next_node ? &graph[*next_node] : NULL; while (node) { @@ -403,8 +447,10 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, addr = (void *)(((uintptr_t)addr) + n); } /* Go deeper. */ - if (!node->optional && node->next) { - next_node = node->next; + if (!(node->node_flags & MLX5_EXPANSION_NODE_OPTIONAL) && + node->next) { + next_node = mlx5_flow_expand_rss_skip_explicit(graph, + node->next); if (stack_pos++ == MLX5_RSS_EXP_ELT_N) { rte_errno = E2BIG; return -rte_errno; @@ -412,15 +458,27 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, stack[stack_pos] = next_node; } else if (*(next_node + 1)) { /* Follow up with the next possibility. */ + next_node = mlx5_flow_expand_rss_skip_explicit(graph, + ++next_node); + } else if (!stack_pos) { + /* + * Completing the traverse over the different paths. + * The next_node is advanced to the terminator. + */ ++next_node; } else { /* Move to the next path. */ - if (stack_pos) + while (stack_pos) { next_node = stack[--stack_pos]; - next_node++; + next_node++; + if (*next_node) + break; + } + next_node = mlx5_flow_expand_rss_skip_explicit(graph, + next_node); stack[stack_pos] = next_node; } - node = *next_node ? &graph[*next_node] : NULL; + node = next_node && *next_node ? &graph[*next_node] : NULL; }; return lsize; } @@ -428,10 +486,7 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, enum mlx5_expansion { MLX5_EXPANSION_ROOT, MLX5_EXPANSION_ROOT_OUTER, - MLX5_EXPANSION_ROOT_ETH_VLAN, - MLX5_EXPANSION_ROOT_OUTER_ETH_VLAN, MLX5_EXPANSION_OUTER_ETH, - MLX5_EXPANSION_OUTER_ETH_VLAN, MLX5_EXPANSION_OUTER_VLAN, MLX5_EXPANSION_OUTER_IPV4, MLX5_EXPANSION_OUTER_IPV4_UDP, @@ -446,7 +501,6 @@ enum mlx5_expansion { MLX5_EXPANSION_GRE_KEY, MLX5_EXPANSION_MPLS, MLX5_EXPANSION_ETH, - MLX5_EXPANSION_ETH_VLAN, MLX5_EXPANSION_VLAN, MLX5_EXPANSION_IPV4, MLX5_EXPANSION_IPV4_UDP, @@ -455,6 +509,7 @@ enum mlx5_expansion { MLX5_EXPANSION_IPV6_UDP, MLX5_EXPANSION_IPV6_TCP, MLX5_EXPANSION_IPV6_FRAG_EXT, + MLX5_EXPANSION_GTP }; /** Supported expansion of items. */ @@ -471,22 +526,7 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { MLX5_EXPANSION_OUTER_IPV6), .type = RTE_FLOW_ITEM_TYPE_END, }, - [MLX5_EXPANSION_ROOT_ETH_VLAN] = { - .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_ETH_VLAN), - .type = RTE_FLOW_ITEM_TYPE_END, - }, - [MLX5_EXPANSION_ROOT_OUTER_ETH_VLAN] = { - .next = MLX5_FLOW_EXPAND_RSS_NEXT - (MLX5_EXPANSION_OUTER_ETH_VLAN), - .type = RTE_FLOW_ITEM_TYPE_END, - }, [MLX5_EXPANSION_OUTER_ETH] = { - .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_IPV4, - MLX5_EXPANSION_OUTER_IPV6), - .type = RTE_FLOW_ITEM_TYPE_ETH, - .rss_types = 0, - }, - [MLX5_EXPANSION_OUTER_ETH_VLAN] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_VLAN), .type = RTE_FLOW_ITEM_TYPE_ETH, .rss_types = 0, @@ -495,6 +535,7 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_IPV4, MLX5_EXPANSION_OUTER_IPV6), .type = RTE_FLOW_ITEM_TYPE_VLAN, + .node_flags = MLX5_EXPANSION_NODE_EXPLICIT, }, [MLX5_EXPANSION_OUTER_IPV4] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT @@ -511,7 +552,8 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { [MLX5_EXPANSION_OUTER_IPV4_UDP] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_VXLAN, MLX5_EXPANSION_VXLAN_GPE, - MLX5_EXPANSION_MPLS), + MLX5_EXPANSION_MPLS, + MLX5_EXPANSION_GTP), .type = RTE_FLOW_ITEM_TYPE_UDP, .rss_types = ETH_RSS_NONFRAG_IPV4_UDP, }, @@ -534,7 +576,8 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { [MLX5_EXPANSION_OUTER_IPV6_UDP] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_VXLAN, MLX5_EXPANSION_VXLAN_GPE, - MLX5_EXPANSION_MPLS), + MLX5_EXPANSION_MPLS, + MLX5_EXPANSION_GTP), .type = RTE_FLOW_ITEM_TYPE_UDP, .rss_types = ETH_RSS_NONFRAG_IPV6_UDP, }, @@ -566,7 +609,7 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { MLX5_EXPANSION_IPV6, MLX5_EXPANSION_MPLS), .type = RTE_FLOW_ITEM_TYPE_GRE_KEY, - .optional = 1, + .node_flags = MLX5_EXPANSION_NODE_OPTIONAL, }, [MLX5_EXPANSION_NVGRE] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_ETH), @@ -577,13 +620,9 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { MLX5_EXPANSION_IPV6, MLX5_EXPANSION_ETH), .type = RTE_FLOW_ITEM_TYPE_MPLS, + .node_flags = MLX5_EXPANSION_NODE_OPTIONAL, }, [MLX5_EXPANSION_ETH] = { - .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4, - MLX5_EXPANSION_IPV6), - .type = RTE_FLOW_ITEM_TYPE_ETH, - }, - [MLX5_EXPANSION_ETH_VLAN] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_VLAN), .type = RTE_FLOW_ITEM_TYPE_ETH, }, @@ -591,6 +630,7 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4, MLX5_EXPANSION_IPV6), .type = RTE_FLOW_ITEM_TYPE_VLAN, + .node_flags = MLX5_EXPANSION_NODE_EXPLICIT, }, [MLX5_EXPANSION_IPV4] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4_UDP, @@ -626,6 +666,11 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { [MLX5_EXPANSION_IPV6_FRAG_EXT] = { .type = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT, }, + [MLX5_EXPANSION_GTP] = { + .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4, + MLX5_EXPANSION_IPV6), + .type = RTE_FLOW_ITEM_TYPE_GTP, + }, }; static struct rte_flow_action_handle * @@ -1990,6 +2035,10 @@ mlx5_flow_validate_item_eth(const struct rte_flow_item *item, return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "L2 layer should not follow VLAN"); + if (item_flags & MLX5_FLOW_LAYER_GTP) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "L2 layer should not follow GTP"); if (!mask) mask = &rte_flow_item_eth_mask; ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask, @@ -2418,6 +2467,8 @@ mlx5_flow_validate_item_tcp(const struct rte_flow_item *item, * * @param[in] dev * Pointer to the Ethernet device structure. + * @param[in] udp_dport + * UDP destination port * @param[in] item * Item specification. * @param[in] item_flags @@ -2432,6 +2483,7 @@ mlx5_flow_validate_item_tcp(const struct rte_flow_item *item, */ int mlx5_flow_validate_item_vxlan(struct rte_eth_dev *dev, + uint16_t udp_dport, const struct rte_flow_item *item, uint64_t item_flags, const struct rte_flow_attr *attr, @@ -2467,12 +2519,18 @@ mlx5_flow_validate_item_vxlan(struct rte_eth_dev *dev, "no outer UDP layer found"); if (!mask) mask = &rte_flow_item_vxlan_mask; - /* FDB domain & NIC domain non-zero group */ - if ((attr->transfer || attr->group) && priv->sh->misc5_cap) - valid_mask = &nic_mask; - /* Group zero in NIC domain */ - if (!attr->group && !attr->transfer && priv->sh->tunnel_header_0_1) - valid_mask = &nic_mask; + + if (priv->sh->steering_format_version != + MLX5_STEERING_LOGIC_FORMAT_CONNECTX_5 || + !udp_dport || udp_dport == MLX5_UDP_PORT_VXLAN) { + /* FDB domain & NIC domain non-zero group */ + if ((attr->transfer || attr->group) && priv->sh->misc5_cap) + valid_mask = &nic_mask; + /* Group zero in NIC domain */ + if (!attr->group && !attr->transfer && + priv->sh->tunnel_header_0_1) + valid_mask = &nic_mask; + } ret = mlx5_flow_item_acceptable (item, (const uint8_t *)mask, (const uint8_t *)valid_mask, @@ -3751,20 +3809,8 @@ flow_get_shared_rss_action(struct rte_eth_dev *dev, } static unsigned int -find_graph_root(const struct rte_flow_item pattern[], uint32_t rss_level) +find_graph_root(uint32_t rss_level) { - const struct rte_flow_item *item; - unsigned int has_vlan = 0; - - for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { - if (item->type == RTE_FLOW_ITEM_TYPE_VLAN) { - has_vlan = 1; - break; - } - } - if (has_vlan) - return rss_level < 2 ? MLX5_EXPANSION_ROOT_ETH_VLAN : - MLX5_EXPANSION_ROOT_OUTER_ETH_VLAN; return rss_level < 2 ? MLX5_EXPANSION_ROOT : MLX5_EXPANSION_ROOT_OUTER; } @@ -4696,7 +4742,7 @@ get_meter_sub_policy(struct rte_eth_dev *dev, uint8_t fate = final_policy->act_cnt[i].fate_action; if (fate == MLX5_FLOW_FATE_SHARED_RSS) { - const void *rss_act = + const struct rte_flow_action_rss *rss_act = final_policy->act_cnt[i].rss->conf; struct rte_flow_action rss_actions[2] = { [0] = { @@ -4732,6 +4778,9 @@ get_meter_sub_policy(struct rte_eth_dev *dev, rss_desc_v[i].tunnel = !!(dev_flow.handle->layers & MLX5_FLOW_LAYER_TUNNEL); + /* Use the RSS queues in the containers. */ + rss_desc_v[i].queue = + (uint16_t *)(uintptr_t)rss_act->queue; rss_desc[i] = &rss_desc_v[i]; } else if (fate == MLX5_FLOW_FATE_QUEUE) { /* This is queue action. */ @@ -5246,6 +5295,7 @@ flow_check_match_action(const struct rte_flow_action actions[], int *modify_after_mirror) { const struct rte_flow_action_sample *sample; + const struct rte_flow_action_raw_decap *decap; int actions_n = 0; uint32_t ratio = 0; int sub_type = 0; @@ -5298,12 +5348,29 @@ flow_check_match_action(const struct rte_flow_action actions[], case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP: case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: case RTE_FLOW_ACTION_TYPE_NVGRE_DECAP: - case RTE_FLOW_ACTION_TYPE_RAW_DECAP: case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD: case RTE_FLOW_ACTION_TYPE_METER: if (fdb_mirror) *modify_after_mirror = 1; break; + case RTE_FLOW_ACTION_TYPE_RAW_DECAP: + decap = actions->conf; + while ((++actions)->type == RTE_FLOW_ACTION_TYPE_VOID) + ; + actions_n++; + if (actions->type == RTE_FLOW_ACTION_TYPE_RAW_ENCAP) { + const struct rte_flow_action_raw_encap *encap = + actions->conf; + if (decap->size <= + MLX5_ENCAPSULATION_DECISION_SIZE && + encap->size > + MLX5_ENCAPSULATION_DECISION_SIZE) + /* L3 encap. */ + break; + } + if (fdb_mirror) + *modify_after_mirror = 1; + break; default: break; } @@ -6237,7 +6304,7 @@ flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, int indir_actions_n = MLX5_MAX_INDIRECT_ACTIONS; union { struct mlx5_flow_expand_rss buf; - uint8_t buffer[2048]; + uint8_t buffer[4096]; } expand_buffer; union { struct rte_flow_action actions[MLX5_MAX_SPLIT_ACTIONS]; @@ -6328,7 +6395,7 @@ flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, if (rss && rss->types) { unsigned int graph_root; - graph_root = find_graph_root(items, rss->level); + graph_root = find_graph_root(rss->level); ret = mlx5_flow_expand_rss(buf, sizeof(expand_buffer.buffer), items, rss->types, mlx5_support_expansion, graph_root);