net/mlx5: enlarge maximal flow priority value
PATCH 1/1 net/mlx5: enlarge maximal flow priority value
Currently, the maximal flow priority in non-root table to user is 4, it's not enough for user to do some flow match by priority, such as LPM, for one IPV4 address, we need 32 priorities for each bit of 32 mask length.
PMD will manage 3 sub-priorities per user priority according to L2, L3 and L4. The internal priority is 16 bits, user can use priorities from 0 - 21843.
Those enlarged flow priorities are only used for ingress or egress flow groups greater than 0 and for any transfer flow group.
--- doc/guides/nics/mlx5.rst | 2 ++ doc/guides/rel_notes/release_21_02.rst | 7 ++++ drivers/net/mlx5/mlx5_flow.c | 62 +++++++++++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow.h | 16 +++++++-- drivers/net/mlx5/mlx5_flow_dv.c | 14 +++----- drivers/net/mlx5/mlx5_flow_verbs.c | 9 +++-- 6 files changed, 91 insertions(+), 19 deletions(-)
doc/guides/nics/mlx5.rst +2 -0
@@ -98,6 +98,8 @@ Features - Hardware LRO. - Hairpin. - Multiple-thread flow insertion. +- 21844 flow priorities for ingress or egress flow groups greater than 0 and for any transfer + flow group. Limitations -----------
doc/guides/rel_notes/release_21_02.rst +7 -0
@@ -55,6 +55,13 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated Mellanox mlx5 driver.** + + Updated the Mellanox mlx5 driver with new features and improvements, including: + + * Enlarge the number of flow priorities to 21844(0 - 21843) for ingress or egress + flow groups greater than 0 and for any transfer flow group. + Removed Items -------------
drivers/net/mlx5/mlx5_flow.c +57 -5
98 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +14 -2
@@ -266,8 +266,15 @@ enum mlx5_feature_name {/* UDP port numbers for GENEVE. */ #define MLX5_UDP_PORT_GENEVE 6081 -/* Priority reserved for default flows. */ -#define MLX5_FLOW_PRIO_RSVD ((uint32_t)-1) +/* Lowest priority indicator. */ +#define MLX5_FLOW_LOWEST_PRIO_INDICATOR ((uint32_t)-1) + +/* +* Max priority for ingress\egress flow groups +* greater than 0 and for any transfer flow group. +* From user configation: 0 - 21843. +*/ +#define MLX5_NON_ROOT_FLOW_MAX_PRIO (21843 + 1)/* * Number of sub priorities.
@@ -1284,6 +1291,11 @@ uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow_rss_desc *rss_desc,int mlx5_flow_discover_priorities (struct rte_eth_dev *dev);uint32_t mlx5_flow_adjust_priority (struct rte_eth_dev *dev,int32_t priority,uint32_t subpriority); +uint32_t mlx5_get_lowest_prority (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr); +uint16_t mlx5_get_matcher_priority (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +uint32_t subpriority); int mlx5_flow_get_reg_id(struct rte_eth_dev *dev, enum mlx5_feature_name feature, uint32_t id,
drivers/net/mlx5/mlx5_flow_dv.c +5 -9
@@ -5150,7 +5150,7 @@ struct mlx5_hlist_entry * struct rte_flow_error *error) {struct mlx5_priv *priv = dev->data->dev_private; -uint32_t priority_max = priv->config.flow_prio -1 ; +uint32_t lowest_priority =mlx5_get_lowest_prority (dev, attributes);int ret =0 ;#ifndef HAVE_MLX5DV_DR
@@ -5171,8 +5171,8 @@ struct mlx5_hlist_entry *if (!table) ret =MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL ;#endif -if (attributes->priority !=MLX5_FLOW_PRIO_RSVD && - attributes->priority >= priority_max) +if (attributes->priority !=MLX5_FLOW_LOWEST_PRIO_INDICATOR && + attributes->priority > lowest_priority) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, NULL,
@@ -9665,7 +9665,6 @@ struct mlx5_cache_entry *uint64_t item_flags =0 ;uint64_t last_item =0 ;uint64_t action_flags =0 ; -uint64_t priority = attr->priority;struct mlx5_flow_dv_matcher matcher = { .mask = { .size = sizeof(matcher.mask.buf) -
@@ -9736,8 +9735,6 @@ struct mlx5_cache_entry * dev_flow->dv.group = table;if (attr->transfer) mhdr_res->ft_type =MLX5DV_FLOW_TABLE_TYPE_FDB ; -if (priority ==MLX5_FLOW_PRIO_RSVD ) - priority = dev_conf->flow_prio -1 ;/* number of actions must be set to 0 in case of dirty stack. */ mhdr_res->actions_num =0 ;if (is_flow_tunnel_match_rule (dev, attr, items, actions)) {
@@ -10591,9 +10588,8 @@ struct mlx5_cache_entry */* Register matcher. */ matcher.crc =rte_raw_cksum ((const void *)matcher.mask.buf, matcher.mask.size); - matcher.priority =mlx5_os_flow_adjust_priority (dev, - priority, - matcher.priority); + matcher.priority =mlx5_get_matcher_priority (dev, attr, + matcher.priority);/* reserved field no needs to be set to 0 here. */ tbl_key.domain = attr->transfer; tbl_key.direction = attr->egress;
drivers/net/mlx5/mlx5_flow_verbs.c +6 -3
@@ -109,8 +109,11 @@ struct ibv_spec_header { dev->data->port_id, priority);return -rte_errno; } -DRV_LOG (INFO ,"port %u flow maximum priority: %d" , - dev->data->port_id, priority); +DRV_LOG (INFO ,"port %u supported flow priorities:" +" 0-%d for ingress or egress root table," +" 0-%d for non-root table or transfer root table." , + dev->data->port_id, priority -2 , +MLX5_NON_ROOT_FLOW_MAX_PRIO -1 );return priority; }
@@ -1710,7 +1713,7 @@ struct ibv_spec_header {MLX5_ASSERT (wks); rss_desc = &wks->rss_desc; -if (priority ==MLX5_FLOW_PRIO_RSVD ) +if (priority ==MLX5_FLOW_LOWEST_PRIO_INDICATOR ) priority = priv->config.flow_prio -1 ;for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) {int ret;
Signature · 1 line
1.8.3.1
PATCH v2 1/1 net/mlx5: enlarge maximal flow priority value
Currently, the maximal flow priority in non-root table to user is 4, it's not enough for user to do some flow match by priority, such as LPM, for one IPV4 address, we need 32 priorities for each bit of 32 mask length.
PMD will manage 3 sub-priorities per user priority according to L2, L3 and L4. The internal priority is 16 bits, user can use priorities from 0 - 21843.
Those enlarged flow priorities are only used for ingress or egress flow groups greater than 0 and for any transfer flow group.
---
v2:
* fix coding style issues, 'prority' to 'priority'.
--- doc/guides/nics/mlx5.rst | 2 ++ doc/guides/rel_notes/release_21_02.rst | 7 ++++ drivers/net/mlx5/mlx5_flow.c | 62 +++++++++++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow.h | 16 +++++++-- drivers/net/mlx5/mlx5_flow_dv.c | 14 +++----- drivers/net/mlx5/mlx5_flow_verbs.c | 9 +++-- 6 files changed, 91 insertions(+), 19 deletions(-)
doc/guides/nics/mlx5.rst +2 -0
@@ -98,6 +98,8 @@ Features - Hardware LRO. - Hairpin. - Multiple-thread flow insertion. +- 21844 flow priorities for ingress or egress flow groups greater than 0 and for any transfer + flow group. Limitations -----------
doc/guides/rel_notes/release_21_02.rst +7 -0
@@ -55,6 +55,13 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated Mellanox mlx5 driver.** + + Updated the Mellanox mlx5 driver with new features and improvements, including: + + * Enlarge the number of flow priorities to 21844(0 - 21843) for ingress or egress + flow groups greater than 0 and for any transfer flow group. + Removed Items -------------
drivers/net/mlx5/mlx5_flow.c +57 -5
98 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +14 -2
@@ -266,8 +266,15 @@ enum mlx5_feature_name {/* UDP port numbers for GENEVE. */ #define MLX5_UDP_PORT_GENEVE 6081 -/* Priority reserved for default flows. */ -#define MLX5_FLOW_PRIO_RSVD ((uint32_t)-1) +/* Lowest priority indicator. */ +#define MLX5_FLOW_LOWEST_PRIO_INDICATOR ((uint32_t)-1) + +/* +* Max priority for ingress\egress flow groups +* greater than 0 and for any transfer flow group. +* From user configation: 0 - 21843. +*/ +#define MLX5_NON_ROOT_FLOW_MAX_PRIO (21843 + 1)/* * Number of sub priorities.
@@ -1284,6 +1291,11 @@ uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow_rss_desc *rss_desc,int mlx5_flow_discover_priorities (struct rte_eth_dev *dev);uint32_t mlx5_flow_adjust_priority (struct rte_eth_dev *dev,int32_t priority,uint32_t subpriority); +uint32_t mlx5_get_lowest_priority (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr); +uint16_t mlx5_get_matcher_priority (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +uint32_t subpriority); int mlx5_flow_get_reg_id(struct rte_eth_dev *dev, enum mlx5_feature_name feature, uint32_t id,
drivers/net/mlx5/mlx5_flow_dv.c +5 -9
@@ -5150,7 +5150,7 @@ struct mlx5_hlist_entry * struct rte_flow_error *error) {struct mlx5_priv *priv = dev->data->dev_private; -uint32_t priority_max = priv->config.flow_prio -1 ; +uint32_t lowest_priority =mlx5_get_lowest_priority (dev, attributes);int ret =0 ;#ifndef HAVE_MLX5DV_DR
@@ -5171,8 +5171,8 @@ struct mlx5_hlist_entry *if (!table) ret =MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL ;#endif -if (attributes->priority !=MLX5_FLOW_PRIO_RSVD && - attributes->priority >= priority_max) +if (attributes->priority !=MLX5_FLOW_LOWEST_PRIO_INDICATOR && + attributes->priority > lowest_priority) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, NULL,
@@ -9665,7 +9665,6 @@ struct mlx5_cache_entry *uint64_t item_flags =0 ;uint64_t last_item =0 ;uint64_t action_flags =0 ; -uint64_t priority = attr->priority;struct mlx5_flow_dv_matcher matcher = { .mask = { .size = sizeof(matcher.mask.buf) -
@@ -9736,8 +9735,6 @@ struct mlx5_cache_entry * dev_flow->dv.group = table;if (attr->transfer) mhdr_res->ft_type =MLX5DV_FLOW_TABLE_TYPE_FDB ; -if (priority ==MLX5_FLOW_PRIO_RSVD ) - priority = dev_conf->flow_prio -1 ;/* number of actions must be set to 0 in case of dirty stack. */ mhdr_res->actions_num =0 ;if (is_flow_tunnel_match_rule (dev, attr, items, actions)) {
@@ -10591,9 +10588,8 @@ struct mlx5_cache_entry */* Register matcher. */ matcher.crc =rte_raw_cksum ((const void *)matcher.mask.buf, matcher.mask.size); - matcher.priority =mlx5_os_flow_adjust_priority (dev, - priority, - matcher.priority); + matcher.priority =mlx5_get_matcher_priority (dev, attr, + matcher.priority);/* reserved field no needs to be set to 0 here. */ tbl_key.domain = attr->transfer; tbl_key.direction = attr->egress;
drivers/net/mlx5/mlx5_flow_verbs.c +6 -3
@@ -109,8 +109,11 @@ struct ibv_spec_header { dev->data->port_id, priority);return -rte_errno; } -DRV_LOG (INFO ,"port %u flow maximum priority: %d" , - dev->data->port_id, priority); +DRV_LOG (INFO ,"port %u supported flow priorities:" +" 0-%d for ingress or egress root table," +" 0-%d for non-root table or transfer root table." , + dev->data->port_id, priority -2 , +MLX5_NON_ROOT_FLOW_MAX_PRIO -1 );return priority; }
@@ -1710,7 +1713,7 @@ struct ibv_spec_header {MLX5_ASSERT (wks); rss_desc = &wks->rss_desc; -if (priority ==MLX5_FLOW_PRIO_RSVD ) +if (priority ==MLX5_FLOW_LOWEST_PRIO_INDICATOR ) priority = priv->config.flow_prio -1 ;for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) {int ret;
Signature · 1 line
1.8.3.1
Hi,
Quoted 20 lines
-----Original Message-----
From: Dong Zhou <[email protected]>
Sent: Tuesday, January 12, 2021 8:40 AM
To: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>
Subject: [PATCH v2] net/mlx5: enlarge maximal flow priority valueCurrently, the maximal flow priority in non-root table to user is 4, it's not enough for user to do some flow match by priority, such as LPM, for one IPV4 address, we need 32 priorities for each bit of 32 mask length.
PMD will manage 3 sub-priorities per user priority according to L2, L3 and L4. The internal priority is 16 bits, user can use priorities from 0 - 21843.
Those enlarged flow priorities are only used for ingress or egress flow groups greater than 0 and for any transfer flow group.
Quoted 6 lines
Signed-off-by Dong Zhou <[email protected]>Acked-by Matan Azrad <[email protected]>---
v2:
* fix coding style issues, 'prority' to 'priority'.
---
Patch rebased and applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh