net/mlx5: HW steering PMD update
Subsystems (2)
cover net/mlx5: HW steering PMD update
The skeleton of mlx5 HW steering(HWS) has been updated into upstream for pretty a long time, but not updated anymore due to missing of the low-level steering layer code. Luckily, better late than never, the steering layer finnaly comes[1].
This series will add more features to the existing PMD code:
- FDB and metadata copy.
- Modify field.
- Meter.
- Counter.
- Aging.
- Action template pre-parser optimization.
- Connection tracking.
Some features such as meter/aging/ct touches the public API, and public API changes have been sent to ML much earily in other threads in order not to be swallowed by this big series.
The dpends patches as below:
[1]https://patches.dpdk.org/project/dpdk/cover/[email protected]/ [2]https://patches.dpdk.org/project/dpdk/cover/[email protected]/ [3]https://patches.dpdk.org/project/dpdk/cover/[email protected]/ [4]https://patches.dpdk.org/project/dpdk/patch/[email protected]/ [5]https://patches.dpdk.org/project/dpdk/patch/[email protected]/ [6]https://patches.dpdk.org/project/dpdk/patch/[email protected]/
Alexander Kozyrev (7):
ethdev: add meter profiles/policies config net/mlx5: add HW steering meter action net/mlx5: add meter color flow matching in dv net/mlx5: add meter color flow matching in hws net/mlx5: implement profile/policy get net/mlx5: implement METER MARK action for HWS net/mlx5: implement METER MARK indirect action for HWS
Bing Zhao (3):
net/mlx5: enable mark flag for all ports in the same domain net/mlx5: add extended metadata mode for hardware steering net/mlx5: add support for ASO return register
Dariusz Sosnowski (5):
net/mlx5: validate modify field action template net/mlx5: create port actions
net/mlx5: support DR action template API net/mlx5: add pattern and table attribute validation net/mlx5: add meta item support in egress
Gregory Etelson (1):
net/mlx5: add HW steering VLAN push, pop and VID modify flow actions
Suanming Mou (8):
net/mlx5: fix invalid flow attributes net/mlx5: fix IPv6 and TCP RSS hash fields net/mlx5: add shared header reformat support net/mlx5: add modify field hws support net/mlx5: support caching queue action net/mlx5: fix indirect action validate lib/ethdev: add connection tracking configuration net/mlx5: add HW steering connection tracking support
Xiaoyu Min (3):
net/mlx5: add HW steering counter action net/mlx5: update indirect actions ops to HW variation net/mlx5: support indirect count action for HW steering
doc/guides/nics/mlx5.rst | 9 + drivers/common/mlx5/mlx5_devx_cmds.c | 50 + drivers/common/mlx5/mlx5_devx_cmds.h | 27 + drivers/common/mlx5/mlx5_prm.h | 21 +- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/linux/mlx5_os.c | 41 +- drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 39 +- drivers/net/mlx5/mlx5.h | 160 +- drivers/net/mlx5/mlx5_defs.h | 2 + drivers/net/mlx5/mlx5_flow.c | 247 +- drivers/net/mlx5/mlx5_flow.h | 265 +- drivers/net/mlx5/mlx5_flow_aso.c | 313 +- drivers/net/mlx5/mlx5_flow_dv.c | 840 ++-- drivers/net/mlx5/mlx5_flow_hw.c | 5434 +++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_meter.c | 967 ++++- drivers/net/mlx5/mlx5_flow_verbs.c | 4 +- drivers/net/mlx5/mlx5_hws_cnt.c | 523 +++ drivers/net/mlx5/mlx5_hws_cnt.h | 558 +++ drivers/net/mlx5/mlx5_trigger.c | 80 +- lib/ethdev/rte_flow.h | 27 +- 21 files changed, 8556 insertions(+), 1053 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.c create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.h
Signature · 1 line
2.25.1
PATCH 1/27 net/mlx5: fix invalid flow attributes
In the function flow_get_drv_type(), attr will be read in non-HWS mode. In case user call the HWS API in SWS mode, attr should be placed in HWS functions, or it will cause crash.
--- drivers/net/mlx5/mlx5_flow.c | 38 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-)
drivers/net/mlx5/mlx5_flow.c +26 -12
@@ -3740,6 +3740,8 @@ flow_get_drv_type(struct rte_eth_dev *dev, const struct rte_flow_attr *attr)*/ if (priv->sh->config.dv_flow_en ==2 )return MLX5_FLOW_TYPE_HW ; +if (!attr) +return MLX5_FLOW_TYPE_MIN ;/* If no OS specific type - continue with DV/VERBS selection */ if (attr->transfer && priv->sh->config.dv_esw_en) type =MLX5_FLOW_TYPE_DV ;
@@ -8252,8 +8254,9 @@ mlx5_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8287,8 +8290,9 @@ mlx5_flow_port_configure(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8319,8 +8323,9 @@ mlx5_flow_pattern_template_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8350,8 +8355,9 @@ mlx5_flow_pattern_template_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8385,8 +8391,9 @@ mlx5_flow_actions_template_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8416,8 +8423,9 @@ mlx5_flow_actions_template_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8457,8 +8465,9 @@ mlx5_flow_table_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8494,8 +8503,9 @@ mlx5_flow_table_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8542,8 +8552,9 @@ mlx5_flow_async_flow_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8585,8 +8596,9 @@ mlx5_flow_async_flow_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8621,8 +8633,9 @@ mlx5_flow_pull(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8650,8 +8663,9 @@ mlx5_flow_push(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
Signature · 1 line
2.25.1
PATCH 2/27 net/mlx5: fix IPv6 and TCP RSS hash fields
In reply to Suanming MouIn the flow_dv_hashfields_set() function, while item_flags was 0, the code went directly to the first if and the else case would never have chance be checked. This caused the IPv6 and TCP hash fileds in the else case would never be set.
This commit adds the dedicate HW steering hash field set function to generate the RSS hash fields.
--- drivers/net/mlx5/mlx5_flow_dv.c | 12 +++---- drivers/net/mlx5/mlx5_flow_hw.c | 59 ++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 9 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +4 -8
@@ -11302,8 +11302,7 @@ flow_dv_hashfields_set(uint64_t item_flags, rss_inner =1 ;#endif if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L3_IPV4 )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV4 )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV4 ))) {if (rss_types &MLX5_IPV4_LAYER_TYPES ) {if (rss_types &RTE_ETH_RSS_L3_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_IPV4 ;
@@ -11313,8 +11312,7 @@ flow_dv_hashfields_set(uint64_t item_flags, fields |=MLX5_IPV4_IBV_RX_HASH ; } }else if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L3_IPV6 )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV6 )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV6 ))) {if (rss_types &MLX5_IPV6_LAYER_TYPES ) {if (rss_types &RTE_ETH_RSS_L3_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_IPV6 ;
@@ -11337,8 +11335,7 @@ flow_dv_hashfields_set(uint64_t item_flags,return ; }if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L4_UDP )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_UDP )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_UDP ))) {if (rss_types &RTE_ETH_RSS_UDP ) {if (rss_types &RTE_ETH_RSS_L4_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_PORT_UDP ;
@@ -11348,8 +11345,7 @@ flow_dv_hashfields_set(uint64_t item_flags, fields |=MLX5_UDP_IBV_RX_HASH ; } }else if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L4_TCP )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_TCP )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_TCP ))) {if (rss_types &RTE_ETH_RSS_TCP ) {if (rss_types &RTE_ETH_RSS_L4_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_PORT_TCP ;
drivers/net/mlx5/mlx5_flow_hw.c +58 -1
71 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 3/27 net/mlx5: add shared header reformat support
In reply to Suanming MouAs the rte_flow_async API defines, the action mask with field value not be 0 means the action will be used as shared in all the flows in the table.
The header reformat action with action mask field not be 0 will be created as constant shared action. For encapsulation header reformat action, there are two kinds of encapsulation data, raw_encap_data and rte_flow_item encap_data. Both of these two kinds of data can be identified from the action mask conf as constant or not.
Examples:
1. VXLAN encap (encap_data: rte_flow_item)
action conf (eth/ipv4/udp/vxlan_hdr)
a. action mask conf (eth/ipv4/udp/vxlan_hdr)
- items are constant.
b. action mask conf (NULL)
- items will change.
2. RAW encap (encap_data: raw)
action conf (raw_data)
a. action mask conf (not NULL)
- encap_data constant.
b. action mask conf (NULL)
- encap_data will change.
--- drivers/net/mlx5/mlx5_flow.h | 6 +- drivers/net/mlx5/mlx5_flow_hw.c | 124 ++++++++++---------------------- 2 files changed, 39 insertions(+), 91 deletions(-)
drivers/net/mlx5/mlx5_flow.h +2 -4
@@ -1065,10 +1065,6 @@ struct mlx5_action_construct_data {uint16_t action_dst;/* mlx5dr_rule_action dst offset. */ union {struct { -/* encap src(item) offset. */ -uint16_t src; -/* encap dst data offset. */ -uint16_t dst;/* encap data len. */ uint16_t len; } encap;
@@ -1111,6 +1107,8 @@ struct mlx5_hw_jump_action {/* Encap decap action struct. */ struct mlx5_hw_encap_decap_action {struct mlx5dr_action *action;/* Action object. */ +/* Is header_reformat action shared across flows in table. */ +bool shared;size_t data_size;/* Action metadata size. */ uint8_t data[];/* Action data. */ };
drivers/net/mlx5/mlx5_flow_hw.c +37 -87
226 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 4/27 net/mlx5: add modify field hws support
In reply to Suanming MouThis patch introduces support for modify_field rte_flow actions in HWS mode. Support includes:
- Ingress and egress domains,
- SET and ADD operations,
- usage of arbitrary bit offsets and widths for packet and metadata fields.
Support is implemented in two phases:
1. On flow table creation the hardware commands are generated, based on rte_flow action templates, and stored alongside action template.
2. On flow rule creation/queueing the hardware commands are updated with values provided by the user. Any masks over immediate values, provided in action templates, are applied to these values before enqueueing rules for creation.
--- drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/linux/mlx5_os.c | 18 +- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.h | 96 ++++++ drivers/net/mlx5/mlx5_flow_dv.c | 538 ++++++++++++++++--------------- drivers/net/mlx5/mlx5_flow_hw.c | 445 ++++++++++++++++++++++++- 6 files changed, 825 insertions(+), 274 deletions(-)
drivers/common/mlx5/mlx5_prm.h +1 -0
@@ -751,6 +751,7 @@ enum mlx5_modification_field {MLX5_MODI_IN_TCP_ACK_NUM =0x5C ,MLX5_MODI_GTP_TEID =0x6E ,MLX5_MODI_OUT_IP_ECN =0x73 , + MLX5_MODI_TUNNEL_HDR_DW_1 = 0x75, };/* Total number of metadata reg_c's. */
drivers/net/mlx5/linux/mlx5_os.c +9 -9
@@ -1539,6 +1539,15 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, mlx5_hrxq_clone_free_cb);if (!priv->hrxqs) goto error; +mlx5_set_metadata_mask (eth_dev); +if (sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + !priv->sh->dv_regc0_mask) { +DRV_LOG (ERR ,"metadata mode %u is not supported " +"(no metadata reg_c[0] is available)" , + sh->config.dv_xmeta_en); + err =ENOTSUP ; + goto error; + }rte_rwlock_init (&priv->ind_tbls_lock);if (priv->vport_meta_mask)flow_hw_set_port_info (eth_dev);
@@ -1560,15 +1569,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err = -err; goto error; } -mlx5_set_metadata_mask (eth_dev); -if (sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && - !priv->sh->dv_regc0_mask) { -DRV_LOG (ERR ,"metadata mode %u is not supported " -"(no metadata reg_c[0] is available)" , - sh->config.dv_xmeta_en); - err =ENOTSUP ; - goto error; - }/* Query availability of metadata reg_c's. */ if (!priv->sh->metadata_regc_check_flag) { err =mlx5_flow_discover_mreg_c (eth_dev);
drivers/net/mlx5/mlx5.h +1 -0
@@ -343,6 +343,7 @@ struct mlx5_hw_q_job {struct rte_flow_hw *flow;/* Flow attached to the job. */ void *user_data;/* Job user data. */ uint8_t *encap_data;/* Encap data. */ +struct mlx5_modification_cmd *mhdr_cmd; };/* HW steering job descriptor LIFO pool. */
drivers/net/mlx5/mlx5_flow.h +96 -0
132 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +274 -264
713 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +444 -1
528 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 5/27 net/mlx5: validate modify field action template
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch adds validation step for action templates and validates if RTE_FLOW_ACTION_TYPE_MODIFY_FIELD actions' fields are properly masked.
--- drivers/net/mlx5/mlx5_flow_hw.c | 132 ++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+)
drivers/net/mlx5/mlx5_flow_hw.c +132 -0
@@ -2047,6 +2047,136 @@ flow_hw_table_destroy(struct rte_eth_dev *dev,return 0 ; } +static int +flow_hw_validate_action_modify_field (const struct rte_flow_action *action, +const struct rte_flow_action *mask, +struct rte_flow_error *error) +{ +const struct rte_flow_action_modify_field *action_conf = + action->conf; +const struct rte_flow_action_modify_field *mask_conf = + mask->conf; + +if (action_conf->operation != mask_conf->operation) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"modify_field operation mask and template are not equal" ); +if (action_conf->dst.field != mask_conf->dst.field) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"destination field mask and template are not equal" ); +if (action_conf->dst.field ==RTE_FLOW_FIELD_POINTER || + action_conf->dst.field ==RTE_FLOW_FIELD_VALUE ) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"immediate value and pointer cannot be used as destination" ); +if (mask_conf->dst.level !=UINT32_MAX ) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"destination encapsulation level must be fully masked" ); +if (mask_conf->dst.offset !=UINT32_MAX ) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"destination offset level must be fully masked" ); +if (action_conf->src.field != mask_conf->src.field) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"destination field mask and template are not equal" ); +if (action_conf->src.field !=RTE_FLOW_FIELD_POINTER && + action_conf->src.field !=RTE_FLOW_FIELD_VALUE ) { +if (mask_conf->src.level !=UINT32_MAX ) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"source encapsulation level must be fully masked" ); +if (mask_conf->src.offset !=UINT32_MAX ) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"source offset level must be fully masked" ); + } +if (mask_conf->width !=UINT32_MAX ) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"modify_field width field must be fully masked" ); +return 0 ; +} + +static int +flow_hw_action_validate (const struct rte_flow_action actions[], +const struct rte_flow_action masks[], +struct rte_flow_error *error) +{ +int i; +bool actions_end = false; +int ret; + +for (i =0 ; !actions_end; ++i) { +const struct rte_flow_action *action = &actions[i]; +const struct rte_flow_action *mask = &masks[i]; + +if (action->type != mask->type) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , + action, +"mask type does not match action type" ); +switch (action->type) { +case RTE_FLOW_ACTION_TYPE_VOID : +break ; +case RTE_FLOW_ACTION_TYPE_INDIRECT : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_MARK : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_DROP : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_JUMP : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_RSS : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_NVGRE_DECAP : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_RAW_ENCAP : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_RAW_DECAP : +/* TODO: Validation logic */ +break ; +case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD : + ret =flow_hw_validate_action_modify_field (action, + mask, + error); +if (ret <0 ) +return ret; +break ; +case RTE_FLOW_ACTION_TYPE_END : + actions_end = true; +break ; +default : +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , + action, +"action not supported in template API" ); + } + } +return 0 ; +} +/** * Create flow action template. *
@@ -2075,6 +2205,8 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev,int len, act_len, mask_len, i;struct rte_flow_actions_template *at; +if (flow_hw_action_validate (actions, masks, error)) +return NULL ; act_len =rte_flow_conv (RTE_FLOW_CONV_OP_ACTIONS ,NULL ,0 , actions, error);if (act_len <=0 )
Signature · 1 line
2.25.1
PATCH 6/27 net/mlx5: enable mark flag for all ports in the same domain
In reply to Suanming MouFrom: Bing Zhao <[email protected]>
In the switchdev mode, there is a unique FDB domain for all the representors and only the eswitch manager can insert the rule into this domain.
If a flow rule is like below:
flow create 0 ingress transfer pattern port_id id is X / eth / end actions mark id 25 ...
It is used for representor X and the mark flag was not enabled for the queues of this port.
To fix this, once the mark flag needs to be enabled, in a FDB case, all the queues' mark flag belonging to the same domain will be engaged for only once.
--- drivers/net/mlx5/mlx5.h | 2 ++ drivers/net/mlx5/mlx5_flow.c | 28 ++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5.h +2 -0
@@ -1202,6 +1202,8 @@ struct mlx5_dev_ctx_shared { uint32_t flow_priority_check_flag:1; /* Check Flag for flow priority. */ uint32_t metadata_regc_check_flag:1; /* Check Flag for metadata REGC. */ uint32_t hws_tags:1; /* Check if tags info for HWS initialized. */ + uint32_t shared_mark_enabled:1; +/* If mark action is enabled on Rxqs (shared E-Switch domain). */ uint32_t max_port;/* Maximal IB device port index. */ struct mlx5_bond_info bond;/* Bonding information. */ struct mlx5_common_device *cdev;/* Backend mlx5 device. */
drivers/net/mlx5/mlx5_flow.c +24 -4
@@ -1481,13 +1481,32 @@ flow_rxq_mark_flag_set(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_rxq_ctrl *rxq_ctrl; +uint16_t port_id; -if (priv->mark_enabled) +if (priv->sh->shared_mark_enabled)return ; - LIST_FOREACH(rxq_ctrl, &priv->rxqsctrl, next) { - rxq_ctrl->rxq.mark =1 ; +if (priv->master || priv->representor) { + MLX5_ETH_FOREACH_DEV(port_id, dev->device) { +struct mlx5_priv *opriv = + rte_eth_devices[port_id].data->dev_private; + +if (!opriv || + opriv->sh != priv->sh || + opriv->domain_id != priv->domain_id || + opriv->mark_enabled) +continue ; + LIST_FOREACH(rxq_ctrl, &opriv->rxqsctrl, next) { + rxq_ctrl->rxq.mark =1 ; + } + opriv->mark_enabled =1 ; + } + }else { + LIST_FOREACH(rxq_ctrl, &priv->rxqsctrl, next) { + rxq_ctrl->rxq.mark =1 ; + } + priv->mark_enabled =1 ; } - priv->mark_enabled =1 ; + priv->sh->shared_mark_enabled =1 ; }/**
@@ -1623,6 +1642,7 @@ flow_rxq_flags_clear(struct rte_eth_dev *dev) rxq->ctrl->rxq.tunnel =0 ; } priv->mark_enabled =0 ; + priv->sh->shared_mark_enabled =0 ; }/**
Signature · 1 line
2.25.1
PATCH 7/27 net/mlx5: create port actions
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch implements creating and caching of port actions for use with HW Steering FDB flows.
Actions are created on flow template API configuration and created only on the port designated as master. Attaching and detaching of ports in the same switching domain causes an update to the port actions cache by, respectively, creating and destroying actions.
A new devarg fdb_def_rule_en is being added and it's used to control the default dedicated E-Switch rule is created by PMD implicitly or not, and PMD sets this value to 1 by default.
If set to 0, the default E-Switch rule will not be created and user can create the specific E-Switch rule on root table if needed.
--- doc/guides/nics/mlx5.rst | 9 + drivers/net/mlx5/linux/mlx5_os.c | 12 + drivers/net/mlx5/mlx5.c | 14 + drivers/net/mlx5/mlx5.h | 24 +- drivers/net/mlx5/mlx5_flow.c | 68 +- drivers/net/mlx5/mlx5_flow.h | 22 +- drivers/net/mlx5/mlx5_flow_dv.c | 93 +- drivers/net/mlx5/mlx5_flow_hw.c | 1350 +++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_flow_verbs.c | 4 +- drivers/net/mlx5/mlx5_trigger.c | 69 +- 10 files changed, 1554 insertions(+), 111 deletions(-)
doc/guides/nics/mlx5.rst +9 -0
@@ -1118,6 +1118,15 @@ for an additional list of options shared with other mlx5 drivers. By default, the PMD will set this value to 1. +- ``fdb_def_rule_en`` parameter [int] + + A non-zero value enables the PMD to create a dedicated rule on E-Switch root + table, this dedicated rule forwards all incoming packets into table 1, other + rules will be created in E-Switch table original table level plus one, to + improve the flow insertion rate due to skip root table managed by firmware. + If set to 0, all rules will be created on the original E-Switch table level. + + By default, the PMD will set this value to 1. Supported NICs --------------
drivers/net/mlx5/linux/mlx5_os.c +12 -0
@@ -1554,6 +1554,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,if (priv->sh->config.dv_flow_en ==2 ) {/* Only HWS requires this information. */ flow_hw_init_tags_set (eth_dev); +if (priv->sh->config.dv_esw_en && +flow_hw_create_vport_action (eth_dev)) { +DRV_LOG (ERR ,"port %u failed to create vport action" , + eth_dev->data->port_id); + err =EINVAL ; + goto error; + }return eth_dev; }/* Port representor shares the same max priority with pf port. */
@@ -1614,6 +1621,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,return eth_dev; error:if (priv) { +if (eth_dev && + priv->sh && + priv->sh->config.dv_flow_en ==2 && + priv->sh->config.dv_esw_en) +flow_hw_destroy_vport_action (eth_dev);if (priv->mreg_cp_tbl)mlx5_hlist_destroy (priv->mreg_cp_tbl);if (priv->sh)
drivers/net/mlx5/mlx5.c +14 -0
@@ -172,6 +172,9 @@/* Device parameter to configure the delay drop when creating Rxqs. */ #define MLX5_DELAY_DROP "delay_drop" +/* Device parameter to create the fdb default rule in PMD */ +#define MLX5_FDB_DEFAULT_RULE_EN "fdb_def_rule_en" +/* Shared memory between primary and secondary processes. */ struct mlx5_shared_data *mlx5_shared_data;
@@ -1239,6 +1242,8 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque) config->decap_en = !!tmp; }else if (strcmp (MLX5_ALLOW_DUPLICATE_PATTERN , key) ==0 ) { config->allow_duplicate_pattern = !!tmp; + }else if (strcmp (MLX5_FDB_DEFAULT_RULE_EN , key) ==0 ) { + config->fdb_def_rule = !!tmp; }return 0 ; }
@@ -1274,6 +1279,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,MLX5_RECLAIM_MEM ,MLX5_DECAP_EN ,MLX5_ALLOW_DUPLICATE_PATTERN , +MLX5_FDB_DEFAULT_RULE_EN , NULL, };int ret =0 ;
@@ -1285,6 +1291,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->dv_flow_en =1 ; config->decap_en =1 ; config->allow_duplicate_pattern =1 ; + config->fdb_def_rule =1 ;if (mkvlist !=NULL ) {/* Process parameters. */ ret = mlx5_kvargs_process(mkvlist, params,
@@ -1360,6 +1367,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,DRV_LOG (DEBUG ,"\"decap_en\" is %u." , config->decap_en);DRV_LOG (DEBUG ,"\"allow_duplicate_pattern\" is %u." , config->allow_duplicate_pattern); +DRV_LOG (DEBUG ,"\"fdb_def_rule_en\" is %u." , config->fdb_def_rule);return 0 ; }
@@ -1943,6 +1951,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)mlx5_flex_parser_ecpri_release (dev);mlx5_flex_item_port_cleanup (dev);#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H ) +flow_hw_destroy_vport_action (dev);flow_hw_resource_release (dev);#endif flow_hw_clear_port_info (dev);
@@ -2644,6 +2653,11 @@ mlx5_probe_again_args_validate(struct mlx5_common_device *cdev, sh->ibdev_name); goto error; } +if (sh->config.fdb_def_rule ^ config->fdb_def_rule) { +DRV_LOG (ERR ,"\"fdb_def_rule_en\" configuration mismatch for shared %s context." , + sh->ibdev_name); + goto error; + }if (sh->config.l3_vxlan_en ^ config->l3_vxlan_en) { DRV_LOG(ERR, "\"l3_vxlan_en\" " "configuration mismatch for shared %s context.",
drivers/net/mlx5/mlx5.h +20 -4
@@ -309,6 +309,7 @@ struct mlx5_sh_config { uint32_t allow_duplicate_pattern:1; uint32_t lro_allowed:1; /* Whether LRO is allowed. *//* Allow/Prevent the duplicate rules pattern. */ + uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ };
@@ -337,6 +338,8 @@ enum { MLX5_HW_Q_JOB_TYPE_DESTROY, /* Flow destroy job type. */ }; +#define MLX5_HW_MAX_ITEMS (16) +/* HW steering flow management job descriptor. */ struct mlx5_hw_q_job {uint32_t type;/* Job type. */
@@ -344,6 +347,8 @@ struct mlx5_hw_q_job {void *user_data;/* Job user data. */ uint8_t *encap_data;/* Encap data. */ struct mlx5_modification_cmd *mhdr_cmd; +struct rte_flow_item *items; +struct rte_flow_item_ethdev port_spec; };/* HW steering job descriptor LIFO pool. */
@@ -1452,6 +1457,12 @@ struct mlx5_obj_ops {#define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields) +struct mlx5_hw_ctrl_flow { +LIST_ENTRY (mlx5_hw_ctrl_flow) next; +struct rte_eth_dev *owner_dev; +struct rte_flow *flow; +}; +struct mlx5_priv {struct rte_eth_dev_data *dev_data;/* Pointer to device data. */ struct mlx5_dev_ctx_shared *sh;/* Shared device context. */
@@ -1492,6 +1503,12 @@ struct mlx5_priv {unsigned int reta_idx_n;/* RETA index size. */ struct mlx5_drop drop_queue;/* Flow drop queues. */ void *root_drop_action;/* Pointer to root drop action. */ +rte_spinlock_t hw_ctrl_lock; + LIST_HEAD(hw_ctrl_flow, mlx5_hw_ctrl_flow) hw_ctrl_flows; +struct mlx5dr_action **hw_vport; +struct rte_flow_template_table *hw_esw_sq_miss_root_tbl; +struct rte_flow_template_table *hw_esw_sq_miss_tbl; +struct rte_flow_template_table *hw_esw_zero_tbl;struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI ];/* RTE Flow rules. */ uint32_t ctrl_flows;/* Control flow rules. */
@@ -1553,10 +1570,9 @@ struct mlx5_priv {/* HW steering rte flow table list header. */ LIST_HEAD(flow_hw_tbl, rte_flow_template_table) flow_hw_tbl;/* HW steering global drop action. */ -struct mlx5dr_action *hw_drop[MLX5_HW_ACTION_FLAG_MAX ] - [MLX5DR_TABLE_TYPE_MAX ]; -/* HW steering global drop action. */ -struct mlx5dr_action *hw_tag[MLX5_HW_ACTION_FLAG_MAX ]; +struct mlx5dr_action *hw_drop[2 ]; +/* HW steering global tag action. */ +struct mlx5dr_action *hw_tag[2 ];struct mlx5_indexed_pool *acts_ipool;/* Action data indexed pool. */ #endif };
drivers/net/mlx5/mlx5_flow.c +56 -12
128 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +21 -1
@@ -1152,6 +1152,11 @@ struct rte_flow_pattern_template {struct mlx5dr_match_template *mt;/* mlx5 match template. */ uint64_t item_flags;/* Item layer flags. */ uint32_t refcnt;/* Reference counter. */ +/* +* If true, then rule pattern should be prepended with +* represented_port pattern item. +*/ +bool implicit_port; };/* Flow action template struct. */
@@ -1227,6 +1232,7 @@ struct mlx5_hw_action_template {/* mlx5 flow group struct. */ struct mlx5_flow_group {struct mlx5_list_entry entry; +struct rte_eth_dev *dev;/* Reference to corresponding device. */ struct mlx5dr_table *tbl;/* HWS table object. */ struct mlx5_hw_jump_action jump;/* Jump action. */ enum mlx5dr_table_type type;/* Table type. */
@@ -1483,6 +1489,9 @@ void flow_hw_clear_port_info(struct rte_eth_dev *dev);void flow_hw_init_tags_set (struct rte_eth_dev *dev);void flow_hw_clear_tags_set (struct rte_eth_dev *dev); +int flow_hw_create_vport_action (struct rte_eth_dev *dev); +void flow_hw_destroy_vport_action (struct rte_eth_dev *dev); + typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2055,7 +2064,7 @@ 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, + bool root, struct rte_flow_error *error); int mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item, uint64_t item_flags,
@@ -2312,4 +2321,15 @@ int flow_dv_translate_items_hws(const struct rte_flow_item *items, uint32_t key_type, uint64_t *item_flags, uint8_t *match_criteria, struct rte_flow_error *error); + +int mlx5_flow_pick_transfer_proxy (struct rte_eth_dev *dev, +uint16_t *proxy_port_id, +struct rte_flow_error *error); + +int mlx5_flow_hw_flush_ctrl_flows (struct rte_eth_dev *dev); + +int mlx5_flow_hw_esw_create_mgr_sq_miss_flow (struct rte_eth_dev *dev); +int mlx5_flow_hw_esw_create_sq_miss_flow (struct rte_eth_dev *dev, +uint32_t txq); +int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +53 -40
297 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +1305 -45
1,597 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +3 -1
@@ -1245,12 +1245,14 @@ flow_verbs_validate(struct rte_eth_dev *dev,uint16_t ether_type =0 ;bool is_empty_vlan = false;uint16_t udp_dport =0 ; +bool is_root;if (items ==NULL )return -1 ; ret =mlx5_flow_validate_attributes (dev, attr, error);if (ret <0 )return ret; + is_root = ret;for (; items->type !=RTE_FLOW_ITEM_TYPE_END ; items++) {int tunnel = !!(item_flags &MLX5_FLOW_LAYER_TUNNEL );int ret =0 ;
@@ -1380,7 +1382,7 @@ flow_verbs_validate(struct rte_eth_dev *dev,case RTE_FLOW_ITEM_TYPE_VXLAN : ret =mlx5_flow_validate_item_vxlan (dev, udp_dport, items, item_flags, - attr, error); + is_root, error);if (ret <0 )return ret; last_item =MLX5_FLOW_LAYER_VXLAN ;
drivers/net/mlx5/mlx5_trigger.c +61 -8
93 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 8/27 net/mlx5: add extended metadata mode for hardware steering
In reply to Suanming MouFrom: Bing Zhao <[email protected]>
The new mode 4 of devarg "dv_xmeta_en" is added for HWS only. In this mode, the Rx / Tx metadata with 32b width copy between FDB and NIC is supported. The mark is only supported in NIC and there is no copy supported.
--- drivers/net/mlx5/linux/mlx5_os.c | 10 +- drivers/net/mlx5/mlx5.c | 7 +- drivers/net/mlx5/mlx5.h | 8 +- drivers/net/mlx5/mlx5_flow.c | 8 +- drivers/net/mlx5/mlx5_flow.h | 14 + drivers/net/mlx5/mlx5_flow_dv.c | 21 +- drivers/net/mlx5/mlx5_flow_hw.c | 862 ++++++++++++++++++++++++++++--- drivers/net/mlx5/mlx5_trigger.c | 3 + 8 files changed, 851 insertions(+), 82 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +9 -1
@@ -1552,6 +1552,15 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,if (priv->vport_meta_mask)flow_hw_set_port_info (eth_dev);if (priv->sh->config.dv_flow_en ==2 ) { +if (priv->sh->config.dv_esw_en && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_META32_HWS ) { +DRV_LOG (ERR , +"metadata mode %u is not supported in HWS eswitch mode" , + priv->sh->config.dv_xmeta_en); + err =ENOTSUP ; + goto error; + }/* Only HWS requires this information. */ flow_hw_init_tags_set (eth_dev); if (priv->sh->config.dv_esw_en &&
@@ -1563,7 +1572,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, }return eth_dev; } -/* Port representor shares the same max priority with pf port. */ if (!priv->sh->flow_priority_check_flag) {/* Supported Verbs flow priority number detection. */ err =mlx5_flow_discover_priorities (eth_dev);
drivers/net/mlx5/mlx5.c +6 -1
@@ -1218,7 +1218,8 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque)if (tmp !=MLX5_XMETA_MODE_LEGACY && tmp !=MLX5_XMETA_MODE_META16 && tmp !=MLX5_XMETA_MODE_META32 && - tmp !=MLX5_XMETA_MODE_MISS_INFO ) { + tmp !=MLX5_XMETA_MODE_MISS_INFO && + tmp !=MLX5_XMETA_MODE_META32_HWS ) {DRV_LOG (ERR ,"Invalid extensive metadata parameter." ); rte_errno =EINVAL ;return -rte_errno;
@@ -2849,6 +2850,10 @@ mlx5_set_metadata_mask(struct rte_eth_dev *dev) meta =UINT32_MAX ; mark = (reg_c0 >>rte_bsf32 (reg_c0)) &MLX5_FLOW_MARK_MASK ;break ; +case MLX5_XMETA_MODE_META32_HWS : + meta =UINT32_MAX ; + mark =MLX5_FLOW_MARK_MASK ; +break ;default : meta =0 ; mark =0 ;
drivers/net/mlx5/mlx5.h +4 -4
@@ -298,8 +298,8 @@ struct mlx5_sh_config { uint32_t reclaim_mode:2; /* Memory reclaim mode. */ uint32_t dv_esw_en:1; /* Enable E-Switch DV flow. *//* Enable DV flow. 1 means SW steering, 2 means HW steering. */ - unsigned int dv_flow_en:2; - uint32_t dv_xmeta_en:2; /* Enable extensive flow metadata. */ + uint32_t dv_flow_en:2; /* Enable DV flow. */ + uint32_t dv_xmeta_en:3; /* Enable extensive flow metadata. */ uint32_t dv_miss_info:1; /* Restore packet after partial hw miss. */ uint32_t l3_vxlan_en:1; /* Enable L3 VXLAN flow creation. */ uint32_t vf_nl_en:1; /* Enable Netlink requests in VF mode. */
@@ -312,7 +312,6 @@ struct mlx5_sh_config { uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ }; -/* Structure for VF VLAN workaround. */ struct mlx5_vf_vlan {uint32_t tag:12 ;
@@ -1279,12 +1278,12 @@ struct mlx5_dev_ctx_shared {struct mlx5_lb_ctx self_lb;/* QP to enable self loopback for Devx. */ unsigned int flow_max_priority;enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM ]; +/* Availability of mreg_c's. */ void *devx_channel_lwm;struct rte_intr_handle *intr_handle_lwm;pthread_mutex_t lwm_config_lock; uint32_t host_shaper_rate:8; uint32_t lwm_triggered:1; -/* Availability of mreg_c's. */ struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1509,6 +1508,7 @@ struct mlx5_priv {struct rte_flow_template_table *hw_esw_sq_miss_root_tbl;struct rte_flow_template_table *hw_esw_sq_miss_tbl;struct rte_flow_template_table *hw_esw_zero_tbl; +struct rte_flow_template_table *hw_tx_meta_cpy_tbl;struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI ];/* RTE Flow rules. */ uint32_t ctrl_flows;/* Control flow rules. */
drivers/net/mlx5/mlx5_flow.c +7 -1
@@ -1107,6 +1107,8 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,return REG_C_0 ;case MLX5_XMETA_MODE_META32 :return REG_C_1 ; +case MLX5_XMETA_MODE_META32_HWS : +return REG_C_1 ; }break ;case MLX5_METADATA_TX :
@@ -1119,11 +1121,14 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,return REG_C_0 ;case MLX5_XMETA_MODE_META32 :return REG_C_1 ; +case MLX5_XMETA_MODE_META32_HWS : +return REG_C_1 ; }break ;case MLX5_FLOW_MARK :switch (config->dv_xmeta_en) {case MLX5_XMETA_MODE_LEGACY : +case MLX5_XMETA_MODE_META32_HWS :return REG_NON ;case MLX5_XMETA_MODE_META16 :return REG_C_1 ;
@@ -4442,7 +4447,8 @@ static bool flow_check_modify_action_type(struct rte_eth_dev *dev,return true;case RTE_FLOW_ACTION_TYPE_FLAG :case RTE_FLOW_ACTION_TYPE_MARK : -if (priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY ) +if (priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_META32_HWS )return true;else return false;
drivers/net/mlx5/mlx5_flow.h +14 -0
@@ -49,6 +49,12 @@ enum mlx5_rte_flow_action_type { MLX5_RTE_FLOW_ACTION_TYPE_RSS, }; +/* Private (internal) Field IDs for MODIFY_FIELD action. */ +enum mlx5_rte_flow_field_id { +MLX5_RTE_FLOW_FIELD_END =INT_MIN , +MLX5_RTE_FLOW_FIELD_META_REG , +}; +#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 30enum {
@@ -1168,6 +1174,7 @@ struct rte_flow_actions_template {struct rte_flow_action *masks;/* Cached action masks.*/ uint16_t mhdr_off;/* Offset of DR modify header action. */ uint32_t refcnt;/* Reference counter. */ +uint16_t rx_cpy_pos;/* Action position of Rx metadata to be copied. */ };/* Jump action struct. */
@@ -1244,6 +1251,11 @@ struct mlx5_flow_group {#define MLX5_HW_TBL_MAX_ITEM_TEMPLATE 2#define MLX5_HW_TBL_MAX_ACTION_TEMPLATE 32 +struct mlx5_flow_template_table_cfg { +struct rte_flow_template_table_attr attr;/* Table attributes passed through flow API. */ +bool external;/* True if created by flow API, false if table is internal to PMD. */ +}; +struct rte_flow_template_table {LIST_ENTRY (rte_flow_template_table) next;struct mlx5_flow_group *grp;/* The group rte_flow_template_table uses. */
@@ -1253,6 +1265,7 @@ struct rte_flow_template_table {/* Action templates bind to the table. */ struct mlx5_hw_action_template ats[MLX5_HW_TBL_MAX_ACTION_TEMPLATE ];struct mlx5_indexed_pool *flow;/* The table's flow ipool. */ +struct mlx5_flow_template_table_cfg cfg;uint32_t type;/* Flow table type RX/TX/FDB. */ uint8_t nb_item_templates;/* Item template number. */ uint8_t nb_action_templates;/* Action template number. */
@@ -2332,4 +2345,5 @@ int mlx5_flow_hw_esw_create_mgr_sq_miss_flow(struct rte_eth_dev *dev);int mlx5_flow_hw_esw_create_sq_miss_flow (struct rte_eth_dev *dev,uint32_t txq);int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev); +int mlx5_flow_hw_create_tx_default_mreg_copy_flow (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +20 -1
@@ -1783,7 +1783,8 @@ mlx5_flow_field_id_to_modify_infoint reg;if (priv->sh->config.dv_flow_en ==2 ) - reg =REG_C_1 ; + reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_TAG , + data->level);else reg =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG , data->level, error);
@@ -1852,6 +1853,24 @@ mlx5_flow_field_id_to_modify_infoelse info[idx].offset = off_be;break ; +case MLX5_RTE_FLOW_FIELD_META_REG : + { +uint32_t meta_mask = priv->sh->dv_meta_mask; +uint32_t meta_count =__builtin_popcount (meta_mask); +uint32_t reg = data->level; + +RTE_SET_USED (meta_count); +MLX5_ASSERT (data->offset + width <= meta_count); +MLX5_ASSERT (reg !=REG_NON ); +MLX5_ASSERT (reg <RTE_DIM (reg_to_field)); + info[idx] = (struct field_modify_info ){4 ,0 , reg_to_field[reg]}; +if (mask) + mask[idx] =flow_modify_info_mask_32_masked + (width, data->offset, meta_mask); +else + info[idx].offset = data->offset; + } +break ;case RTE_FLOW_FIELD_POINTER :case RTE_FLOW_FIELD_VALUE :default :
drivers/net/mlx5/mlx5_flow_hw.c +788 -74
1,287 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +3 -0
@@ -1290,6 +1290,9 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev)if (priv->sh->config.dv_esw_en && priv->master) {if (mlx5_flow_hw_esw_create_mgr_sq_miss_flow (dev)) goto error; +if (priv->sh->config.dv_xmeta_en ==MLX5_XMETA_MODE_META32_HWS ) +if (mlx5_flow_hw_create_tx_default_mreg_copy_flow (dev)) + goto error; }for (i =0 ; i < priv->txqs_n; ++i) {struct mlx5_txq_ctrl *txq =mlx5_txq_get (dev, i);
Signature · 1 line
2.25.1
PATCH 9/27 ethdev: add meter profiles/policies config
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
Provide an ability to specify the number of meter profiles/policies alongside with the number of meters during the Flow engine configuration.
--- lib/ethdev/rte_flow.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
lib/ethdev/rte_flow.h +21 -1
@@ -4898,10 +4898,20 @@ struct rte_flow_port_info {*/ uint32_t max_nb_aging_objects;/** -* Maximum number traffic meters. +* Maximum number of traffic meters. * @see RTE_FLOW_ACTION_TYPE_METER */ uint32_t max_nb_meters; +/** +* Maximum number of traffic meter profiles. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t max_nb_meter_profiles; +/** +* Maximum number of traffic meter policies. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t max_nb_meter_policies; };/**
@@ -4971,6 +4981,16 @@ struct rte_flow_port_attr {* @see RTE_FLOW_ACTION_TYPE_METER */ uint32_t nb_meters; +/** +* Number of traffic meter profiles to configure. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meter_profiles; +/** +* Number of traffic meter policies to configure. +* @see RTE_FLOW_ACTION_TYPE_METER +*/ +uint32_t nb_meter_policies; };/**
Signature · 1 line
2.25.1
PATCH 10/27 net/mlx5: add HW steering meter action
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
This commit adds meter action for HWS steering.
HW steering meter is based on ASO. The number of meters will be used by flows should be specified in advanced in the flow configure API.
--- drivers/net/mlx5/mlx5.h | 58 +- drivers/net/mlx5/mlx5_flow.c | 71 +++ drivers/net/mlx5/mlx5_flow.h | 50 ++ drivers/net/mlx5/mlx5_flow_aso.c | 30 +- drivers/net/mlx5/mlx5_flow_dv.c | 25 - drivers/net/mlx5/mlx5_flow_hw.c | 113 +++- drivers/net/mlx5/mlx5_flow_meter.c | 851 ++++++++++++++++++++++++++++- 7 files changed, 1138 insertions(+), 60 deletions(-)
drivers/net/mlx5/mlx5.h +56 -2
@@ -357,6 +357,9 @@ struct mlx5_hw_q {struct mlx5_hw_q_job **job;/* LIFO header. */ } __rte_cache_aligned; + + +#define MLX5_COUNTERS_PER_POOL 512#define MLX5_MAX_PENDING_QUERIES 4#define MLX5_CNT_CONTAINER_RESIZE 64
@@ -782,15 +785,29 @@ struct mlx5_flow_meter_policy {/* Is meter action in policy table. */ uint32_t hierarchy_drop_cnt:1;/* Is any meter in hierarchy contains drop_cnt. */ + uint32_t skip_r:1; +/* If red color policy is skipped. */ uint32_t skip_y:1;/* If yellow color policy is skipped. */ uint32_t skip_g:1;/* If green color policy is skipped. */ uint32_t mark:1;/* If policy contains mark action. */ + uint32_t initialized:1; +/* Initialized. */ +uint16_t group; +/* The group. */ rte_spinlock_t sl;uint32_t ref_cnt;/* Use count. */ +struct rte_flow_pattern_template *hws_item_templ; +/* Hardware steering item templates. */ +struct rte_flow_actions_template *hws_act_templ[MLX5_MTR_DOMAIN_MAX ]; +/* Hardware steering action templates. */ +struct rte_flow_template_table *hws_flow_table[MLX5_MTR_DOMAIN_MAX ]; +/* Hardware steering tables. */ +struct rte_flow *hws_flow_rule[MLX5_MTR_DOMAIN_MAX ][RTE_COLORS ]; +/* Hardware steering rules. */ struct mlx5_meter_policy_action_container act_cnt[MLX5_MTR_RTE_COLORS ];/* Policy actions container. */ void *dr_drop_action[MLX5_MTR_DOMAIN_MAX ];
@@ -865,6 +882,7 @@ struct mlx5_flow_meter_info {*/ uint32_t transfer:1; uint32_t def_policy:1; + uint32_t initialized:1;/* Meter points to default policy. */ uint32_t color_aware:1;/* Meter is color aware mode. */
@@ -880,6 +898,10 @@ struct mlx5_flow_meter_info {/**< Flow meter action. */ void *meter_action_y;/**< Flow meter action for yellow init_color. */ +uint32_t meter_offset; +/**< Flow meter offset. */ +uint16_t group; +/**< Flow meter group. */ };/* PPS(packets per second) map to BPS(Bytes per second).
@@ -914,6 +936,7 @@ struct mlx5_flow_meter_profile {uint32_t ref_cnt;/**< Use count. */ uint32_t g_support:1; /**< If G color will be generated. */ uint32_t y_support:1; /**< If Y color will be generated. */ + uint32_t initialized:1; /**< Initialized. */ };/* 2 meters in each ASO cache line */
@@ -934,13 +957,20 @@ enum mlx5_aso_mtr_state { ASO_METER_READY, /* CQE received. */ }; +/*aso flow meter type*/ +enum mlx5_aso_mtr_type { +ASO_METER_INDIRECT , +ASO_METER_DIRECT , +}; +/* Generic aso_flow_meter information. */ struct mlx5_aso_mtr {LIST_ENTRY (mlx5_aso_mtr) next; +enum mlx5_aso_mtr_type type;struct mlx5_flow_meter_info fm;/**< Pointer to the next aso flow meter structure. */ uint8_t state;/**< ASO flow meter state. */ -uint8_t offset; +uint32_t offset; };/* Generic aso_flow_meter pool structure. */
@@ -964,6 +994,14 @@ struct mlx5_aso_mtr_pools_mng {struct mlx5_aso_mtr_pool **pools;/* ASO flow meter pool array. */ }; +/* Bulk management structure for ASO flow meter. */ +struct mlx5_mtr_bulk { +uint32_t size;/* Number of ASO objects. */ +struct mlx5dr_action *action;/* HWS action */ +struct mlx5_devx_obj *devx_obj;/* DEVX object. */ +struct mlx5_aso_mtr *aso;/* Array of ASO objects. */ +}; +/* Meter management structure for global flow meter resource. */ struct mlx5_flow_mtr_mng {struct mlx5_aso_mtr_pools_mng pools_mng;
@@ -1017,6 +1055,7 @@ struct mlx5_flow_tbl_resource {#define MLX5_FLOW_TABLE_LEVEL_METER (MLX5_MAX_TABLES - 3)#define MLX5_FLOW_TABLE_LEVEL_POLICY (MLX5_MAX_TABLES - 4)#define MLX5_MAX_TABLES_EXTERNAL MLX5_FLOW_TABLE_LEVEL_POLICY +#define MLX5_FLOW_TABLE_HWS_POLICY (MLX5_MAX_TABLES - 10)#define MLX5_MAX_TABLES_FDB UINT16_MAX#define MLX5_FLOW_TABLE_FACTOR 10
@@ -1303,6 +1342,12 @@ TAILQ_HEAD(mlx5_mtr_profiles, mlx5_flow_meter_profile);/* MTR list. */ TAILQ_HEAD (mlx5_legacy_flow_meters, mlx5_legacy_flow_meter); +struct mlx5_mtr_config { +uint32_t nb_meters;/**< Number of configured meters */ +uint32_t nb_meter_profiles;/**< Number of configured meter profiles */ +uint32_t nb_meter_policies;/**< Number of configured meter policies */ +}; +/* RSS description. */ struct mlx5_flow_rss_desc {uint32_t level;
@@ -1539,12 +1584,16 @@ struct mlx5_priv {struct mlx5_nl_vlan_vmwa_context *vmwa_context;/* VLAN WA context. */ struct mlx5_hlist *mreg_cp_tbl;/* Hash table of Rx metadata register copy table. */ +struct mlx5_mtr_config mtr_config;/* Meter configuration */ uint8_t mtr_sfx_reg;/* Meter prefix-suffix flow match REG_C. */ uint8_t mtr_color_reg;/* Meter color match REG_C. */ struct mlx5_legacy_flow_meters flow_meters;/* MTR list. */ struct mlx5_l3t_tbl *mtr_profile_tbl;/* Meter index lookup table. */ +struct mlx5_flow_meter_profile *mtr_profile_arr;/* Profile array. */ struct mlx5_l3t_tbl *policy_idx_tbl;/* Policy index lookup table. */ +struct mlx5_flow_meter_policy *mtr_policy_arr;/* Policy array. */ struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ +struct mlx5_mtr_bulk mtr_bulk;/* Meter index mapping for HWS */ uint8_t skip_default_rss_reta;/* Skip configuration of default reta. */ uint8_t fdb_def_rule;/* Whether fdb jump to table 1 is configured. */ struct mlx5_mp_id mp_id;/* ID of a multi-process process */
@@ -1579,6 +1628,7 @@ struct mlx5_priv {#define PORT_ID (priv) ((priv)->dev_data->port_id)#define ETH_DEV (priv) (&rte_eth_devices[PORT_ID(priv)]) +#define CTRL_QUEUE_ID (priv) ((priv)->nb_queue - 1)struct rte_hairpin_peer_info {uint32_t qp_id;
@@ -1890,6 +1940,10 @@ void mlx5_pmd_socket_uninit(void);/* mlx5_flow_meter.c */ +int mlx5_flow_meter_init (struct rte_eth_dev *dev, +uint32_t nb_meters, +uint32_t nb_meter_profiles, +uint32_t nb_meter_policies);int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg);struct mlx5_flow_meter_info *mlx5_flow_meter_find (struct mlx5_priv *priv,uint32_t meter_id,uint32_t *mtr_idx);
@@ -1964,7 +2018,7 @@ int mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh);void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh,enum mlx5_access_aso_opc_mod aso_opc_mod);int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh, -struct mlx5_aso_mtr *mtr); +struct mlx5_aso_mtr *mtr,struct mlx5_mtr_bulk *bulk);int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh,struct mlx5_aso_mtr *mtr); int mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh,
drivers/net/mlx5/mlx5_flow.c +71 -0
83 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +50 -0
86 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_aso.c +19 -11
@@ -642,7 +642,8 @@ mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh)static uint16_t mlx5_aso_mtr_sq_enqueue_single (struct mlx5_dev_ctx_shared *sh,struct mlx5_aso_sq *sq, -struct mlx5_aso_mtr *aso_mtr) +struct mlx5_aso_mtr *aso_mtr, +struct mlx5_mtr_bulk *bulk) {volatile struct mlx5_aso_wqe *wqe =NULL ;struct mlx5_flow_meter_info *fm =NULL ;
@@ -653,6 +654,7 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_dev_ctx_shared *sh,uint32_t dseg_idx =0 ;struct mlx5_aso_mtr_pool *pool =NULL ;uint32_t param_le; +int id;rte_spinlock_lock (&sq->sqsl); res = size - (uint16_t )(sq->head - sq->tail);
@@ -666,14 +668,19 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_dev_ctx_shared *sh,/* Fill next WQE. */ fm = &aso_mtr->fm; sq->elts[sq->head & mask].mtr = aso_mtr; - pool = container_of(aso_mtr, struct mlx5_aso_mtr_pool, - mtrs[aso_mtr->offset]); - wqe->general_cseg.misc =rte_cpu_to_be_32 (pool->devx_obj->id + - (aso_mtr->offset >>1 )); - wqe->general_cseg.opcode =rte_cpu_to_be_32 (MLX5_OPCODE_ACCESS_ASO | - (ASO_OPC_MOD_POLICER << -WQE_CSEG_OPC_MOD_OFFSET ) | - sq->pi <<WQE_CSEG_WQE_INDEX_OFFSET ); +if (aso_mtr->type ==ASO_METER_INDIRECT ) { + pool = container_of(aso_mtr, struct mlx5_aso_mtr_pool, + mtrs[aso_mtr->offset]); + id = pool->devx_obj->id; + }else { + id = bulk->devx_obj->id; + } + wqe->general_cseg.misc =rte_cpu_to_be_32 (id + + (aso_mtr->offset >>1 )); + wqe->general_cseg.opcode = +rte_cpu_to_be_32 (MLX5_OPCODE_ACCESS_ASO | + (ASO_OPC_MOD_POLICER <<WQE_CSEG_OPC_MOD_OFFSET ) | + sq->pi <<WQE_CSEG_WQE_INDEX_OFFSET );/* There are 2 meters in one ASO cache line. */ dseg_idx = aso_mtr->offset &0x1 ; wqe->aso_cseg.data_mask =
@@ -811,14 +818,15 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)*/ int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh, -struct mlx5_aso_mtr *mtr) +struct mlx5_aso_mtr *mtr, +struct mlx5_mtr_bulk *bulk) {struct mlx5_aso_sq *sq = &sh->mtrmng->pools_mng.sq;uint32_t poll_wqe_times =MLX5_MTR_POLL_WQE_CQE_TIMES ; do { mlx5_aso_mtr_completion_handle(sq); - if (mlx5_aso_mtr_sq_enqueue_single(sh, sq, mtr)) + if (mlx5_aso_mtr_sq_enqueue_single(sh, sq, mtr, bulk)) return 0; /* Waiting for wqe resource. */ rte_delay_us_sleep(MLX5_ASO_WQE_CQE_RESPONSE_DELAY);
drivers/net/mlx5/mlx5_flow_dv.c +0 -25
@@ -216,31 +216,6 @@ flow_dv_attr_init(const struct rte_flow_item *item, union flow_dv_attr *attr, attr->valid =1 ; } -/* -* Convert rte_mtr_color to mlx5 color. -* -* @param[in] rcol -* rte_mtr_color. -* -* @return -* mlx5 color. -*/ -static inline int -rte_col_2_mlx5_col (enum rte_color rcol) -{ -switch (rcol) { -case RTE_COLOR_GREEN : -return MLX5_FLOW_COLOR_GREEN ; -case RTE_COLOR_YELLOW : -return MLX5_FLOW_COLOR_YELLOW ; -case RTE_COLOR_RED : -return MLX5_FLOW_COLOR_RED ; -default : -break ; - } -return MLX5_FLOW_COLOR_UNDEFINED ; -} -struct field_modify_info modify_eth[] = { {4 ,0 ,MLX5_MODI_OUT_DMAC_47_16 }, {2 ,4 ,MLX5_MODI_OUT_DMAC_15_0 },
drivers/net/mlx5/mlx5_flow_hw.c +105 -8
198 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +837 -14
962 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 11/27 net/mlx5: add HW steering counter action
In reply to Suanming MouFrom: Xiaoyu Min <[email protected]>
This commit adds HW steering counter action support.
Pool mechanism is the basic data structure for the HW steering counter.
The HW steering's counter pool is based on the rte_ring of zero-copy variation.
There are two global rte_rings:
1. free_list:
Store the counters indexes, which are ready for use.
2. wait_reset_list:
Store the counters indexes, which are just freed from the user and need to query the hardware counter to get the reset value before this counter can be reused again.
The counter pool also supports cache per HW steering's queues, which are also based on rte_ring of zero-copy variation.
The cache can be configured in size, preload, threshold, and fetch size, they are all exposed via device args.
The main operations of the counter pool are as follows:
- Get one counter from the pool:
1. The user call _get_* API.
2. If the cache is enabled, dequeue one counter index from the local cache:
2.A: if the dequeued one from the local cache is still in reset
status (counter's query_gen_when_free is equal to pool's query gen):
I. Flush all counters in local cache back to global
wait_reset_list.
II. Fetch _fetch_sz_ counters into the cache from the global
free list.
III. Fetch one counter from the cache.
3. If the cache is empty, fetch _fetch_sz_ counters from the global free list into the cache and fetch one counter from the cache.
- Free one counter into the pool:
1. The user calls _put_* API.
2. Put the counter into the local cache.
3. If the local cache is full:
3.A: Write back all counters above _threshold_ into the global
wait_reset_list.
3.B: Also, write back this counter into the global wait_reset_list.
When the local cache is disabled, _get_/_put_ cache directly from/into global list.
net/mlx5: move ASO query counter into ASO file
Move the ASO counter query logical into the dedicated ASO file. The function name is changed accordingly.
Also use the max SQ size for ASO counter query.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 50 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 27 ++ drivers/common/mlx5/mlx5_prm.h | 20 +- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 14 + drivers/net/mlx5/mlx5.h | 27 ++ drivers/net/mlx5/mlx5_defs.h | 2 + drivers/net/mlx5/mlx5_flow.c | 27 +- drivers/net/mlx5/mlx5_flow.h | 2 + drivers/net/mlx5/mlx5_flow_aso.c | 261 ++++++++++++- drivers/net/mlx5/mlx5_flow_hw.c | 142 ++++++- drivers/net/mlx5/mlx5_flow_meter.c | 8 +- drivers/net/mlx5/mlx5_hws_cnt.c | 523 +++++++++++++++++++++++++ drivers/net/mlx5/mlx5_hws_cnt.h | 558 +++++++++++++++++++++++++++ 15 files changed, 1635 insertions(+), 28 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.c create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.h
drivers/common/mlx5/mlx5_devx_cmds.c +50 -0
@@ -176,6 +176,41 @@ mlx5_devx_cmd_register_write(void *ctx, uint16_t reg_id, uint32_t arg,return 0 ; } +struct mlx5_devx_obj * +mlx5_devx_cmd_flow_counter_alloc_general (void *ctx, +struct mlx5_devx_counter_attr *attr) +{ +struct mlx5_devx_obj *dcs =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*dcs), +0 ,SOCKET_ID_ANY ); +uint32_t in[MLX5_ST_SZ_DW (alloc_flow_counter_in)] = {0 }; +uint32_t out[MLX5_ST_SZ_DW (alloc_flow_counter_out)] = {0 }; + +if (!dcs) { + rte_errno =ENOMEM ; +return NULL ; + } +MLX5_SET (alloc_flow_counter_in, in, opcode, +MLX5_CMD_OP_ALLOC_FLOW_COUNTER ); +if (attr->bulk_log_max_alloc) +MLX5_SET (alloc_flow_counter_in, in, flow_counter_bulk_log_size, + attr->flow_counter_bulk_log_size); +else +MLX5_SET (alloc_flow_counter_in, in, flow_counter_bulk, + attr->bulk_n_128); +if (attr->pd_valid) +MLX5_SET (alloc_flow_counter_in, in, pd, attr->pd); + dcs->obj = mlx5_glue->devx_obj_create (ctx, in, +sizeof (in), out,sizeof (out)); +if (!dcs->obj) { +DRV_LOG (ERR ,"Can't allocate counters - error %d" , errno); + rte_errno = errno; +mlx5_free (dcs); +return NULL ; + } + dcs->id =MLX5_GET (alloc_flow_counter_out, out, flow_counter_id); +return dcs; +} +/** * Allocate flow counters via devx interface. *
@@ -967,6 +1002,16 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, general_obj_types) & MLX5_GENERAL_OBJ_TYPES_CAP_CONN_TRACK_OFFLOAD); attr->rq_delay_drop =MLX5_GET (cmd_hca_cap, hcattr, rq_delay_drop); + attr->max_flow_counter_15_0 =MLX5_GET (cmd_hca_cap, hcattr, + max_flow_counter_15_0); + attr->max_flow_counter_31_16 =MLX5_GET (cmd_hca_cap, hcattr, + max_flow_counter_31_16); + attr->alloc_flow_counter_pd =MLX5_GET (cmd_hca_cap, hcattr, + alloc_flow_counter_pd); + attr->flow_counter_access_aso =MLX5_GET (cmd_hca_cap, hcattr, + flow_counter_access_aso); + attr->flow_access_aso_opc_mod =MLX5_GET (cmd_hca_cap, hcattr, + flow_access_aso_opc_mod);if (attr->crypto) { attr->aes_xts =MLX5_GET (cmd_hca_cap, hcattr, aes_xts); hcattr = mlx5_devx_get_hca_cap(ctx, in, out, &rc,
@@ -989,6 +1034,11 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, } attr->log_min_stride_wqe_sz =MLX5_GET (cmd_hca_cap_2, hcattr, log_min_stride_wqe_sz); + attr->flow_counter_bulk_log_max_alloc =MLX5_GET (cmd_hca_cap_2, + hcattr, flow_counter_bulk_log_max_alloc); + attr->flow_counter_bulk_log_granularity = +MLX5_GET (cmd_hca_cap_2, hcattr, + flow_counter_bulk_log_granularity); }if (attr->log_min_stride_wqe_sz ==0 ) attr->log_min_stride_wqe_sz =MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE ;
drivers/common/mlx5/mlx5_devx_cmds.h +27 -0
@@ -15,6 +15,16 @@#define MLX5_DEVX_MAX_KLM_ENTRIES ((UINT16_MAX - \ MLX5_ST_SZ_DW(create_mkey_in) * 4) / (MLX5_ST_SZ_DW(klm) * 4)) +struct mlx5_devx_counter_attr { +uint32_t pd_valid:1 ; +uint32_t pd:24 ; +uint32_t bulk_log_max_alloc:1 ; +union { +uint8_t flow_counter_bulk_log_size; +uint8_t bulk_n_128; + }; +}; +struct mlx5_devx_mkey_attr {uint64_t addr;uint64_t size;
@@ -263,6 +273,18 @@ struct mlx5_hca_attr { uint32_t set_reg_c:8; uint32_t nic_flow_table:1; uint32_t modify_outer_ip_ecn:1; +union { +uint32_t max_flow_counter; +struct { +uint16_t max_flow_counter_15_0; +uint16_t max_flow_counter_31_16; + }; + }; + uint32_t flow_counter_bulk_log_max_alloc:5; + uint32_t flow_counter_bulk_log_granularity:5; + uint32_t alloc_flow_counter_pd:1; + uint32_t flow_counter_access_aso:1; + uint32_t flow_access_aso_opc_mod:8; };/* LAG Context. */
@@ -593,6 +615,11 @@ struct mlx5_devx_crypto_login_attr {/* mlx5_devx_cmds.c */ +__rte_internal +struct mlx5_devx_obj * +mlx5_devx_cmd_flow_counter_alloc_general (void *ctx, +struct mlx5_devx_counter_attr *attr); +__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_flow_counter_alloc(void *ctx,uint32_t bulk_sz);
drivers/common/mlx5/mlx5_prm.h +16 -4
@@ -1169,8 +1169,10 @@ struct mlx5_ifc_alloc_flow_counter_in_bits {u8 reserved_at_10[0x10 ];u8 reserved_at_20[0x10 ];u8 op_mod[0x10 ]; -u8 flow_counter_id[0x20 ]; -u8 reserved_at_40[0x18 ]; +u8 reserved_at_40[0x8 ]; +u8 pd[0x18 ]; +u8 reserved_at_60[0x13 ]; +u8 flow_counter_bulk_log_size[0x5 ];u8 flow_counter_bulk[0x8 ]; };
@@ -1404,7 +1406,13 @@ enum {#define MLX5_STEERING_LOGIC_FORMAT_CONNECTX_6DX 0x1struct mlx5_ifc_cmd_hca_cap_bits { -u8 reserved_at_0[0x20 ]; +u8 access_other_hca_roce[0x1 ]; +u8 alloc_flow_counter_pd[0x1 ]; +u8 flow_counter_access_aso[0x1 ]; +u8 reserved_at_3[0x5 ]; +u8 flow_access_aso_opc_mod[0x8 ]; +u8 reserved_at_10[0xf ]; +u8 vhca_resource_manager[0x1 ];u8 hca_cap_2[0x1 ];u8 reserved_at_21[0xf ];u8 vhca_id[0x10 ];
@@ -2111,7 +2119,11 @@ struct mlx5_ifc_cmd_hca_cap_2_bits {u8 format_select_dw_8_6_ext[0x1 ];u8 reserved_at_1ac[0x14 ];u8 general_obj_types_127_64[0x40 ]; -u8 reserved_at_200[0x80 ]; +u8 reserved_at_200[0x53 ]; +u8 flow_counter_bulk_log_max_alloc[0x5 ]; +u8 reserved_at_258[0x3 ]; +u8 flow_counter_bulk_log_granularity[0x5 ]; +u8 reserved_at_260[0x20 ];u8 format_select_dw_gtpu_dw_0[0x8 ];u8 format_select_dw_gtpu_dw_1[0x8 ];u8 format_select_dw_gtpu_dw_2[0x8 ];
drivers/common/mlx5/version.map +1 -0
@@ -40,6 +40,7 @@ INTERNAL { mlx5_devx_cmd_create_virtq; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc; + mlx5_devx_cmd_flow_counter_alloc_general; mlx5_devx_cmd_flow_counter_query; mlx5_devx_cmd_flow_dump; mlx5_devx_cmd_flow_single_dump;
drivers/net/mlx5/meson.build +1 -0
@@ -37,6 +37,7 @@ sources = files( 'mlx5_vlan.c', 'mlx5_utils.c', 'mlx5_devx.c', + 'mlx5_hws_cnt.c', ) if is_linux
drivers/net/mlx5/mlx5.c +14 -0
@@ -175,6 +175,12 @@/* Device parameter to create the fdb default rule in PMD */ #define MLX5_FDB_DEFAULT_RULE_EN "fdb_def_rule_en" +/* HW steering counter configuration. */ +#define MLX5_HWS_CNT_SERVICE_CORE "service_core" + +/* HW steering counter's query interval. */ +#define MLX5_HWS_CNT_CYCLE_TIME "svc_cycle_time" +/* Shared memory between primary and secondary processes. */ struct mlx5_shared_data *mlx5_shared_data;
@@ -1245,6 +1251,10 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque) config->allow_duplicate_pattern = !!tmp; }else if (strcmp (MLX5_FDB_DEFAULT_RULE_EN , key) ==0 ) { config->fdb_def_rule = !!tmp; + }else if (strcmp (MLX5_HWS_CNT_SERVICE_CORE , key) ==0 ) { + config->cnt_svc.service_core = tmp; + }else if (strcmp (MLX5_HWS_CNT_CYCLE_TIME , key) ==0 ) { + config->cnt_svc.cycle_time = tmp; }return 0 ; }
@@ -1281,6 +1291,8 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,MLX5_DECAP_EN ,MLX5_ALLOW_DUPLICATE_PATTERN ,MLX5_FDB_DEFAULT_RULE_EN , +MLX5_HWS_CNT_SERVICE_CORE , +MLX5_HWS_CNT_CYCLE_TIME , NULL, };int ret =0 ;
@@ -1293,6 +1305,8 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->decap_en =1 ; config->allow_duplicate_pattern =1 ; config->fdb_def_rule =1 ; + config->cnt_svc.cycle_time =MLX5_CNT_SVC_CYCLE_TIME_DEFAULT ; + config->cnt_svc.service_core =rte_get_main_lcore ();if (mkvlist !=NULL ) {/* Process parameters. */ ret = mlx5_kvargs_process(mkvlist, params,
drivers/net/mlx5/mlx5.h +27 -0
@@ -308,6 +308,10 @@ struct mlx5_sh_config { uint32_t hw_fcs_strip:1; /* FCS stripping is supported. */ uint32_t allow_duplicate_pattern:1; uint32_t lro_allowed:1; /* Whether LRO is allowed. */ +struct { +uint16_t service_core; +uint32_t cycle_time;/* query cycle time in milli-second. */ + } cnt_svc;/* configure for HW steering's counter's service. */ /* Allow/Prevent the duplicate rules pattern. */ uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ };
@@ -1224,6 +1228,22 @@ struct mlx5_flex_item {struct mlx5_flex_pattern_field map[MLX5_FLEX_ITEM_MAPPING_NUM ]; }; +#define HWS_CNT_ASO_SQ_NUM 4 + +struct mlx5_hws_aso_mng { +uint16_t sq_num; +struct mlx5_aso_sq sqs[HWS_CNT_ASO_SQ_NUM ]; +}; + +struct mlx5_hws_cnt_svc_mng { +uint32_t refcnt; +uint32_t service_core; +uint32_t query_interval; +pthread_t service_thread; +uint8_t svc_running; + struct mlx5_hws_aso_mng aso_mng __rte_cache_aligned; +}; +/* * Shared Infiniband device context for Master/Representors * which belong to same IB device with multiple IB ports.
@@ -1323,6 +1343,7 @@ struct mlx5_dev_ctx_shared {pthread_mutex_t lwm_config_lock; uint32_t host_shaper_rate:8; uint32_t lwm_triggered:1; +struct mlx5_hws_cnt_svc_mng *cnt_svc;struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1623,6 +1644,7 @@ struct mlx5_priv {/* HW steering global tag action. */ struct mlx5dr_action *hw_tag[2 ];struct mlx5_indexed_pool *acts_ipool;/* Action data indexed pool. */ +struct mlx5_hws_cnt_pool *hws_cpool;/* HW steering's counter pool. */ #endif };
@@ -2036,6 +2058,11 @@ mlx5_get_supported_sw_parsing_offloads(const struct mlx5_hca_attr *attr);uint32_t mlx5_get_supported_tunneling_offloads (const struct mlx5_hca_attr *attr); +int mlx5_aso_cnt_queue_init (struct mlx5_dev_ctx_shared *sh); +void mlx5_aso_cnt_queue_uninit (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_cnt_query (struct mlx5_dev_ctx_shared *sh, +struct mlx5_hws_cnt_pool *cpool); +/* mlx5_flow_flex.c */ struct rte_flow_item_flex_handle *
drivers/net/mlx5/mlx5_defs.h +2 -0
@@ -188,4 +188,6 @@#define static_assert _Static_assert#endif +#define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#endif /* RTE_PMD_MLX5_DEFS_H_ */
drivers/net/mlx5/mlx5_flow.c +15 -12
@@ -7832,24 +7832,33 @@ mlx5_flow_isolate(struct rte_eth_dev *dev,*/ static int flow_drv_query (struct rte_eth_dev *dev, -uint32_t flow_idx, +struct rte_flow *eflow,const struct rte_flow_action *actions,void *data,struct rte_flow_error *error) {struct mlx5_priv *priv = dev->data->dev_private;const struct mlx5_flow_driver_ops *fops; -struct rte_flow *flow =mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], - flow_idx); -enum mlx5_flow_drv_type ftype; +struct rte_flow *flow =NULL ; +enum mlx5_flow_drv_type ftype =MLX5_FLOW_TYPE_MIN ; +if (priv->sh->config.dv_flow_en ==2 ) { +#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H ) + flow = eflow; + ftype =MLX5_FLOW_TYPE_HW ; +#endif + }else { + flow = (struct rte_flow *)mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], + (uintptr_t )(void *)eflow); + }if (!flow) {return rte_flow_error_set (error,ENOENT ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL ,"invalid flow handle" ); } - ftype = flow->drv_type; +if (ftype ==MLX5_FLOW_TYPE_MIN ) + ftype = flow->drv_type;MLX5_ASSERT (ftype >MLX5_FLOW_TYPE_MIN && ftype <MLX5_FLOW_TYPE_MAX ); fops =flow_get_drv_ops (ftype);
@@ -7870,14 +7879,8 @@ mlx5_flow_query(struct rte_eth_dev *dev, struct rte_flow_error *error) {int ret; -struct mlx5_priv *priv = dev->data->dev_private; -if (priv->sh->config.dv_flow_en ==2 ) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"Flow non-Q query not supported" ); - ret =flow_drv_query (dev, (uintptr_t )(void *)flow, actions, data, + ret =flow_drv_query (dev, flow, actions, data, error);if (ret <0 )return ret;
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -1104,6 +1104,7 @@ struct rte_flow_hw { };struct rte_flow_template_table *table;/* The table flow allcated from. */ struct mlx5dr_rule rule;/* HWS layer data struct. */ +uint32_t cnt_id; } __rte_packed;/* rte flow action translate to DR action struct. */
@@ -1225,6 +1226,7 @@ struct mlx5_hw_actions {uint16_t encap_decap_pos;/* Encap/Decap action position. */ uint32_t acts_num:4; /* Total action number. */ uint32_t mark:1; /* Indicate the mark action. */ +uint32_t cnt_id;/* Counter id. */ /* Translated DR action array from action template. */ struct mlx5dr_rule_action rule_acts[MLX5_HW_MAX_ACTS ]; };
drivers/net/mlx5/mlx5_flow_aso.c +254 -7
309 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +140 -2
232 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +5 -3
@@ -61,6 +61,7 @@ mlx5_flow_meter_init(struct rte_eth_dev *dev,struct mlx5_aso_mtr *aso;uint32_t i;struct rte_mtr_error error; +uint32_t flags;if (!nb_meters || !nb_meter_profiles || !nb_meter_policies) { ret =ENOTSUP ;
@@ -104,11 +105,12 @@ mlx5_flow_meter_init(struct rte_eth_dev *dev, NULL, "Meter register is not available."); goto err; } + flags =MLX5DR_ACTION_FLAG_HWS_RX |MLX5DR_ACTION_FLAG_HWS_TX ; +if (priv->sh->config.dv_esw_en && priv->master) + flags |=MLX5DR_ACTION_FLAG_HWS_FDB ; priv->mtr_bulk.action =mlx5dr_action_create_aso_meter (priv->dr_ctx, (struct mlx5dr_devx_obj *)dcs, - reg_id -REG_C_0 ,MLX5DR_ACTION_FLAG_HWS_RX | -MLX5DR_ACTION_FLAG_HWS_TX | -MLX5DR_ACTION_FLAG_HWS_FDB ); + reg_id -REG_C_0 , flags);if (!priv->mtr_bulk.action) { ret =ENOMEM ; rte_mtr_error_set(&error, ENOMEM,
drivers/net/mlx5/mlx5_hws_cnt.c new file +523 -0
523 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h new file +558 -0
558 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 12/27 net/mlx5: support caching queue action
In reply to Suanming MouIf the port is stopped, the Rx queue data will also be destroyed. At that time, create table with RSS action would be failed due to lack of Rx queue data.
This commit adds the cache of queue create operation while port stopped. In case port is stopped, add tables to the ongoing list first, then do action translate only when port starts.
--- drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow.h | 2 + drivers/net/mlx5/mlx5_flow_hw.c | 95 +++++++++++++++++++++++++++++---- drivers/net/mlx5/mlx5_trigger.c | 8 +++ 4 files changed, 97 insertions(+), 10 deletions(-)
drivers/net/mlx5/mlx5.h +2 -0
@@ -1643,6 +1643,8 @@ struct mlx5_priv {struct mlx5dr_action *hw_drop[2 ];/* HW steering global tag action. */ struct mlx5dr_action *hw_tag[2 ]; +/* HW steering create ongoing rte flow table list header. */ + LIST_HEAD(flow_hw_tbl_ongo, rte_flow_template_table) flow_hw_tbl_ongo;struct mlx5_indexed_pool *acts_ipool;/* Action data indexed pool. */ struct mlx5_hws_cnt_pool *hws_cpool;/* HW steering's counter pool. */ #endif
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -2398,4 +2398,6 @@ int mlx5_flow_pattern_validate(struct rte_eth_dev *dev,const struct rte_flow_pattern_template_attr *attr, const struct rte_flow_item items[], struct rte_flow_error *error); +int flow_hw_table_update (struct rte_eth_dev *dev, +struct rte_flow_error *error);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_hw.c +85 -10
147 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +8 -0
@@ -1170,6 +1170,14 @@ mlx5_dev_start(struct rte_eth_dev *dev) dev->data->port_id, rte_strerror(rte_errno)); goto error; } +if (priv->sh->config.dv_flow_en ==2 ) { + ret =flow_hw_table_update (dev,NULL ); +if (ret) { +DRV_LOG (ERR ,"port %u failed to update HWS tables" , + dev->data->port_id); + goto error; + } + } ret =mlx5_traffic_enable (dev);if (ret) { DRV_LOG(ERR, "port %u failed to set defaults flows",
Signature · 1 line
2.25.1
PATCH 13/27 net/mlx5: support DR action template API
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch adapts mlx5 PMD to changes in mlx5dr API regarding action templates. It changes the following:
1. Actions template creation:
- Flow actions types are translated to mlx5dr action types in order to create mlx5dr_action_template object.
- An offset is assigned to each flow action. This offset is used to predetermine action's location in rule_acts array passed on rule creation.
2. Template table creation:
- Fixed actions are created and put in rule_acts cache using predetermined offsets
- mlx5dr matcher is parametrized by action templates bound to template table.
- mlx5dr matcher is configured to optimize rule creation based on passed rule indices.
3. Flow rule creation:
- mlx5dr rule is parametrized by action template on which these rule's actions are based.
- Rule index hint is provided to mlx5dr.
--- drivers/net/mlx5/mlx5_flow.h | 6 +- drivers/net/mlx5/mlx5_flow_hw.c | 351 ++++++++++++++++++++++++-------- 2 files changed, 268 insertions(+), 89 deletions(-)
drivers/net/mlx5/mlx5_flow.h +5 -1
@@ -1173,6 +1173,11 @@ struct rte_flow_actions_template {struct rte_flow_actions_template_attr attr;struct rte_flow_action *actions;/* Cached flow actions. */ struct rte_flow_action *masks;/* Cached action masks.*/ +struct mlx5dr_action_template *tmpl;/* mlx5dr action template. */ +uint16_t dr_actions_num;/* Amount of DR rules actions. */ +uint16_t actions_num;/* Amount of flow actions */ +uint16_t *actions_off;/* DR action offset for given rte action offset. */ +uint16_t reformat_off;/* Offset of DR reformat action. */ uint16_t mhdr_off;/* Offset of DR modify header action. */ uint32_t refcnt;/* Reference counter. */ uint16_t rx_cpy_pos;/* Action position of Rx metadata to be copied. */
@@ -1224,7 +1229,6 @@ struct mlx5_hw_actions {/* Encap/Decap action. */ struct mlx5_hw_encap_decap_action *encap_decap;uint16_t encap_decap_pos;/* Encap/Decap action position. */ - uint32_t acts_num:4; /* Total action number. */ uint32_t mark:1; /* Indicate the mark action. */uint32_t cnt_id;/* Counter id. */ /* Translated DR action array from action template. */
drivers/net/mlx5/mlx5_flow_hw.c +263 -88
689 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 14/27 net/mlx5: fix indirect action validate
In reply to Suanming MouFor indirect actions, the action mask type indicates the indirect action type. And action mask conf be NULL means the indirect action will be provided by flow action conf.
This commit fixes the indirect action validate.
--- drivers/net/mlx5/mlx5_flow_hw.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +10 -6
@@ -2726,7 +2726,8 @@ flow_hw_actions_validate(struct rte_eth_dev *dev,const struct rte_flow_action *mask = &masks[i];MLX5_ASSERT (i <MLX5_HW_MAX_ACTS ); -if (action->type != mask->type) +if (action->type !=RTE_FLOW_ACTION_TYPE_INDIRECT && + action->type != mask->type) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, action,
@@ -2824,22 +2825,25 @@ flow_hw_dr_actions_template_handle_shared(const struct rte_flow_action *mask,uint16_t *curr_off, struct rte_flow_actions_template *at) { - uint32_t act_idx; uint32_t type; -if (!mask->conf) { +if (!mask) {DRV_LOG (WARNING ,"Unable to determine indirect action type " "without a mask specified" );return -EINVAL ; } - act_idx = (uint32_t )(uintptr_t )mask->conf; - type = act_idx >>MLX5_INDIRECT_ACTION_TYPE_OFFSET ; + type = mask->type;switch (type) { -case MLX5_INDIRECT_ACTION_TYPE_RSS : +case RTE_FLOW_ACTION_TYPE_RSS : at->actions_off[action_src] = *curr_off; action_types[*curr_off] =MLX5DR_ACTION_TYP_TIR ; *curr_off = *curr_off +1 ;break ; +case RTE_FLOW_ACTION_TYPE_COUNT : + at->actions_off[action_src] = *curr_off; + action_types[*curr_off] =MLX5DR_ACTION_TYP_CTR ; + *curr_off = *curr_off +1 ; +break ;default :DRV_LOG (WARNING ,"Unsupported shared action type: %d" , type);return -EINVAL ;
Signature · 1 line
2.25.1
PATCH 15/27 net/mlx5: update indirect actions ops to HW variation
In reply to Suanming MouFrom: Xiaoyu Min <[email protected]>
Each flow engine should have its own callback functions for each flow's ops.
Create new callback functions for indirect actions' ops which actually are wrppers of their mlx5_hw_async_* counter parts.
--- drivers/net/mlx5/mlx5_flow_hw.c | 98 +++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +94 -4
@@ -4988,6 +4988,96 @@ flow_hw_query(struct rte_eth_dev *dev,return ret; } +/** +* Create indirect action. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in] conf +* Shared action configuration. +* @param[in] action +* Action specification used to create indirect action. +* @param[out] error +* Perform verbose error reporting if not NULL. Initialized in case of +* error only. +* +* @return +* A valid shared action handle in case of success, NULL otherwise and +* rte_errno is set. +*/ +static struct rte_flow_action_handle * +flow_hw_action_create (struct rte_eth_dev *dev, +const struct rte_flow_indir_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *err) +{ +return flow_hw_action_handle_create (dev,UINT32_MAX ,NULL , conf, action, +NULL , err); +} + +/** +* Destroy the indirect action. +* Release action related resources on the NIC and the memory. +* Lock free, (mutex should be acquired by caller). +* Dispatcher for action type specific call. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in] handle +* The indirect action object handle to be removed. +* @param[out] error +* Perform verbose error reporting if not NULL. Initialized in case of +* error only. +* +* @return +* 0 on success, otherwise negative errno value. +*/ +static int +flow_hw_action_destroy (struct rte_eth_dev *dev, +struct rte_flow_action_handle *handle, +struct rte_flow_error *error) +{ +return flow_hw_action_handle_destroy (dev,UINT32_MAX ,NULL , handle, +NULL , error); +} + +/** +* Updates in place shared action configuration. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in] handle +* The indirect action object handle to be updated. +* @param[in] update +* Action specification used to modify the action pointed by *handle*. +* *update* could be of same type with the action pointed by the *handle* +* handle argument, or some other structures like a wrapper, depending on +* the indirect action type. +* @param[out] error +* Perform verbose error reporting if not NULL. Initialized in case of +* error only. +* +* @return +* 0 on success, otherwise negative errno value. +*/ +static int +flow_hw_action_update (struct rte_eth_dev *dev, +struct rte_flow_action_handle *handle, +const void *update, +struct rte_flow_error *err) +{ +return flow_hw_action_handle_update (dev,UINT32_MAX ,NULL , handle, + update,NULL , err); +} + +static int +flow_hw_action_query (struct rte_eth_dev *dev, +const struct rte_flow_action_handle *handle,void *data, +struct rte_flow_error *error) +{ +return flow_dv_action_query (dev, handle, data, error); +} +const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = { .info_get = flow_hw_info_get, .configure = flow_hw_configure,
@@ -5007,10 +5097,10 @@ const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = { .async_action_destroy = flow_hw_action_handle_destroy, .async_action_update = flow_hw_action_handle_update, .action_validate = flow_dv_action_validate, - .action_create = flow_dv_action_create, - .action_destroy = flow_dv_action_destroy, - .action_update = flow_dv_action_update, - .action_query = flow_dv_action_query, + .action_create = flow_hw_action_create, + .action_destroy = flow_hw_action_destroy, + .action_update = flow_hw_action_update, + .action_query = flow_hw_action_query, .query = flow_hw_query, };
Signature · 1 line
2.25.1
PATCH 16/27 net/mlx5: support indirect count action for HW steering
In reply to Suanming MouFrom: Xiaoyu Min <[email protected]>
The indirect counter action is taked as _shared_ counter between the flows use it.
This _shared_ counter is gotten from counter pool at time the indirect action is created. And be put back to counter pool when indirect action is destroyed.
--- drivers/net/mlx5/mlx5_flow.h | 3 + drivers/net/mlx5/mlx5_flow_hw.c | 104 +++++++++++++++++++++++++++++++- 2 files changed, 104 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -1148,6 +1148,9 @@ struct mlx5_action_construct_data {uint32_t level;/* RSS level. */ uint32_t idx;/* Shared action index. */ } shared_rss; +struct { +uint32_t id; + } shared_counter; }; };
drivers/net/mlx5/mlx5_flow_hw.c +101 -3
152 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 17/27 net/mlx5: add pattern and table attribute validation
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch adds validation of direction attributes of pattern templates and template tables.
In case of pattern templates the following configurations are allowed (and if this configuration requires addition of implicit pattern items):
1. If E-Switch is enabled (i.e. dv_esw_en devarg is set to 1):
1. If a port is a VF/SF representor:
1. Ingress only - implicit pattern items are added.
2. Egress only - implicit pattern items are added.
2. If a port is a transfer proxy port (E-Switch Manager/PF representor):
1. Ingress, egress and transfer - no implicit items are added. This setting is useful for applications which require to receive traffic from devices connected to the E-Switch and did not hit any transfer flow rules.
2. Ingress only - implicit pattern items are added.
3. Egress only - implicit pattern items are added.
4. Transfer only - no implicit pattern items are added.
2. If E-Switch is disabled (i.e. dv_esw_en devarg is set to 0):
1. Ingress only - no implicit pattern items are added.
2. Egress only - no implicit pattern items are added.
3. Ingress and egress - no implicit pattern items are added.
4. Transfer is not allowed.
In case of template tables, the table attributes must be consistent with attributes associated with pattern template attributes.
--- drivers/net/mlx5/mlx5_flow_hw.c | 80 +++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 18 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +62 -18
@@ -2379,6 +2379,13 @@ flow_hw_table_create(struct rte_eth_dev *dev,for (i =0 ; i < nb_item_templates; i++) {uint32_t ret; +if ((flow_attr.ingress && !item_templates[i]->attr.ingress) || + (flow_attr.egress && !item_templates[i]->attr.egress) || + (flow_attr.transfer && !item_templates[i]->attr.transfer)) { +DRV_LOG (ERR ,"pattern template and template table attribute mismatch" ); + rte_errno =EINVAL ; + goto it_error; + } ret =__atomic_add_fetch (&item_templates[i]->refcnt,1 , __ATOMIC_RELAXED);if (ret <=1 ) {
@@ -2557,6 +2564,7 @@ flow_hw_template_table_create(struct rte_eth_dev *dev,uint8_t nb_action_templates, struct rte_flow_error *error) { + struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_flow_template_table_cfg cfg = { .attr = *attr, .external = true,
@@ -2565,6 +2573,12 @@ flow_hw_template_table_create(struct rte_eth_dev *dev,if (flow_hw_translate_group (dev, &cfg, group, &cfg.attr.flow_attr.group, error))return NULL ; +if (priv->sh->config.dv_esw_en && cfg.attr.flow_attr.egress) { +rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ATTR ,NULL , +"egress flows are not supported with HW Steering" +" when E-Switch is enabled" ); +return NULL ; + }return flow_hw_table_create (dev, &cfg, item_templates, nb_item_templates, action_templates, nb_action_templates, error); }
@@ -3254,11 +3268,48 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], struct rte_flow_error *error) { + struct mlx5_priv *priv = dev->data->dev_private;int i;bool items_end = false; -RTE_SET_USED (dev); -RTE_SET_USED (attr); +if (!attr->ingress && !attr->egress && !attr->transfer) +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ATTR ,NULL , +"at least one of the direction attributes" +" must be specified" ); +if (priv->sh->config.dv_esw_en) { +MLX5_ASSERT (priv->master || priv->representor); +if (priv->master) { +/* +* It is allowed to specify ingress, egress and transfer attributes +* at the same time, in order to construct flows catching all missed +* FDB traffic and forwarding it to the master port. +*/ +if (!(attr->ingress ^ attr->egress ^ attr->transfer)) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR ,NULL , +"only one or all direction attributes" +" at once can be used on transfer proxy" +" port" ); + }else { +if (attr->transfer) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER ,NULL , +"transfer attribute cannot be used with" +" port representors" ); +if (attr->ingress && attr->egress) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR ,NULL , +"ingress and egress direction attributes" +" cannot be used at the same time on" +" port representors" ); + } + }else { +if (attr->transfer) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER ,NULL , +"transfer attribute cannot be used when" +" E-Switch is disabled" ); + }for (i =0 ; !items_end; i++) {int type = items[i].type;
@@ -3289,7 +3340,15 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , "Unsupported internal tag index"); +break ; } +case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT : +if (attr->ingress || attr->egress) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM ,NULL , +"represented port item cannot be used" +" when transfer attribute is set" ); +break ;case RTE_FLOW_ITEM_TYPE_VOID :case RTE_FLOW_ITEM_TYPE_ETH :case RTE_FLOW_ITEM_TYPE_VLAN :
@@ -3299,7 +3358,6 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,case RTE_FLOW_ITEM_TYPE_TCP :case RTE_FLOW_ITEM_TYPE_GTP :case RTE_FLOW_ITEM_TYPE_GTP_PSC : -case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT :case RTE_FLOW_ITEM_TYPE_VXLAN :case MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE :case RTE_FLOW_ITEM_TYPE_META :
@@ -3350,21 +3408,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,if (flow_hw_pattern_validate (dev, attr, items, error))return NULL ; -if (priv->sh->config.dv_esw_en && attr->ingress) { -/* -* Disallow pattern template with ingress and egress/transfer -* attributes in order to forbid implicit port matching -* on egress and transfer traffic. -*/ -if (attr->egress || attr->transfer) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"item template for ingress traffic" -" cannot be used for egress/transfer" -" traffic when E-Switch is enabled" ); -return NULL ; - } +if (priv->sh->config.dv_esw_en && attr->ingress && !attr->egress && !attr->transfer) { copied_items =flow_hw_copy_prepend_port_item (items, error);if (!copied_items)return NULL ;
Signature · 1 line
2.25.1
PATCH 18/27 net/mlx5: add meta item support in egress
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch adds support for META item in HW Steering mode, in NIC TX domain.
Due to API limitations, usage of META item requires that all mlx5 ports use the same configuration of dv_esw_en and dv_xmeta_en device arguments in order to consistently translate META item to appropriate register. If mlx5 ports use different configurations, then configuration of the first probed device is used.
--- drivers/net/mlx5/linux/mlx5_os.c | 1 + drivers/net/mlx5/mlx5.c | 4 ++- drivers/net/mlx5/mlx5_flow.h | 22 +++++++++++- drivers/net/mlx5/mlx5_flow_hw.c | 61 ++++++++++++++++++++++++++++++-- 4 files changed, 84 insertions(+), 4 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +1 -0
@@ -1563,6 +1563,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, }/* Only HWS requires this information. */ flow_hw_init_tags_set (eth_dev); +flow_hw_init_flow_metadata_config (eth_dev);if (priv->sh->config.dv_esw_en &&flow_hw_create_vport_action (eth_dev)) { DRV_LOG(ERR, "port %u failed to create vport action",
drivers/net/mlx5/mlx5.c +3 -1
@@ -1970,8 +1970,10 @@ mlx5_dev_close(struct rte_eth_dev *dev)flow_hw_resource_release (dev);#endif flow_hw_clear_port_info (dev); -if (priv->sh->config.dv_flow_en ==2 ) +if (priv->sh->config.dv_flow_en ==2 ) { +flow_hw_clear_flow_metadata_config ();flow_hw_clear_tags_set (dev); + }if (priv->rxq_privs !=NULL ) {/* XXX race condition if mlx5_rx_burst() is still running. */ rte_delay_us_sleep (1000 );
drivers/net/mlx5/mlx5_flow.h +21 -1
@@ -1485,6 +1485,13 @@ flow_hw_get_wire_port(struct ibv_context *ibctx)return NULL ; } +extern uint32_t mlx5_flow_hw_flow_metadata_config_refcnt; +extern uint8_t mlx5_flow_hw_flow_metadata_esw_en; +extern uint8_t mlx5_flow_hw_flow_metadata_xmeta_en; + +void flow_hw_init_flow_metadata_config (struct rte_eth_dev *dev); +void flow_hw_clear_flow_metadata_config (void ); +/* * Convert metadata or tag to the actual register. * META: Can only be used to match in the FDB in this stage, fixed C_1.
@@ -1496,7 +1503,20 @@ flow_hw_get_reg_id(enum rte_flow_item_type type, uint32_t id) {switch (type) {case RTE_FLOW_ITEM_TYPE_META : -return REG_C_1 ; +if (mlx5_flow_hw_flow_metadata_esw_en && + mlx5_flow_hw_flow_metadata_xmeta_en ==MLX5_XMETA_MODE_META32_HWS ) { +return REG_C_1 ; + } +/* +* On root table - PMD allows only egress META matching, thus +* REG_A matching is sufficient. +* +* On non-root tables - REG_A corresponds to general_purpose_lookup_field, +* which translates to REG_A in NIC TX and to REG_B in NIC RX. +* However, current FW does not implement REG_B case right now, so +* REG_B case should be rejected on pattern template validation. +*/ +return REG_A ;case RTE_FLOW_ITEM_TYPE_TAG :MLX5_ASSERT (id <MLX5_FLOW_HW_TAGS_MAX );return mlx5_flow_hw_avl_tags[id];
drivers/net/mlx5/mlx5_flow_hw.c +59 -2
85 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 19/27 net/mlx5: add support for ASO return register
In reply to Suanming MouFrom: Bing Zhao <[email protected]>
A REG_C_x metadata register is needed to store the result after an ASO action. Like in the SWS, the meter color register is used for all the ASO actions right now and this register was already filtered out from the available tags.
It is assumed that all the devices are using the same meter color register inside one application now.
In the next stage, the available tags and other metadata registers allocation will be stored per device.
--- drivers/net/mlx5/mlx5_flow.c | 1 + drivers/net/mlx5/mlx5_flow.h | 3 +++ drivers/net/mlx5/mlx5_flow_hw.c | 2 ++ 3 files changed, 6 insertions(+)
drivers/net/mlx5/mlx5_flow.c +1 -0
@@ -49,6 +49,7 @@ struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS];*/ uint32_t mlx5_flow_hw_avl_tags_init_cnt;enum modify_reg mlx5_flow_hw_avl_tags[MLX5_FLOW_HW_TAGS_MAX ] = {REG_NON }; +enum modify_reg mlx5_flow_hw_aso_tag;struct tunnel_default_miss_ctx {uint16_t *queue;
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -1445,6 +1445,7 @@ extern struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS];#define MLX5_FLOW_HW_TAGS_MAX 8extern uint32_t mlx5_flow_hw_avl_tags_init_cnt;extern enum modify_reg mlx5_flow_hw_avl_tags[]; +extern enum modify_reg mlx5_flow_hw_aso_tag;/* * Get metadata match tag and mask for given rte_eth_dev port.
@@ -1517,6 +1518,8 @@ flow_hw_get_reg_id(enum rte_flow_item_type type, uint32_t id)* REG_B case should be rejected on pattern template validation. */ return REG_A ; +case RTE_FLOW_ITEM_TYPE_CONNTRACK : +return mlx5_flow_hw_aso_tag;case RTE_FLOW_ITEM_TYPE_TAG :MLX5_ASSERT (id <MLX5_FLOW_HW_TAGS_MAX );return mlx5_flow_hw_avl_tags[id];
drivers/net/mlx5/mlx5_flow_hw.c +2 -0
@@ -4903,6 +4903,7 @@ void flow_hw_init_tags_set(struct rte_eth_dev *dev) unset |=1 << (REG_C_1 -REG_C_0 ); masks &= ~unset;if (mlx5_flow_hw_avl_tags_init_cnt) { +MLX5_ASSERT (mlx5_flow_hw_aso_tag == priv->mtr_color_reg);for (i =0 ; i <MLX5_FLOW_HW_TAGS_MAX ; i++) {if (mlx5_flow_hw_avl_tags[i] !=REG_NON && !!((1 << i) & masks)) { copy[mlx5_flow_hw_avl_tags[i] - REG_C_0] =
@@ -4925,6 +4926,7 @@ void flow_hw_init_tags_set(struct rte_eth_dev *dev) } } priv->sh->hws_tags =1 ; + mlx5_flow_hw_aso_tag = (enum modify_reg )priv->mtr_color_reg; mlx5_flow_hw_avl_tags_init_cnt++; }
Signature · 1 line
2.25.1
PATCH 20/27 lib/ethdev: add connection tracking configuration
In reply to Suanming MouThis commit adds the maximum connection tracking number configuration for async flow engine.
--- lib/ethdev/rte_flow.h | 5 +++++ 1 file changed, 5 insertions(+)
lib/ethdev/rte_flow.h +5 -0
@@ -4991,6 +4991,11 @@ struct rte_flow_port_attr {* @see RTE_FLOW_ACTION_TYPE_METER */ uint32_t nb_meter_policies; +/** +* Number of connection tracking to configure. +* @see RTE_FLOW_ACTION_TYPE_CONNTRACK +*/ +uint32_t nb_cts; };/**
Signature · 1 line
2.25.1
PATCH 21/27 net/mlx5: add HW steering connection tracking support
In reply to Suanming MouThis commit adds the support of connection tracking to HW steering as SW steering did before.
Different with SW steering implementation, take advantage of HW steering bulk action allocation support, in HW steering only one single CT pool is needed.
An indexed pool is introduced to record allocated actions from bulk and CT action state etc. Once one CT action is allocated from bulk, one indexed object will also be allocated from the indexed pool, similar for deallocate. That makes mlx5_aso_ct_action can also be managed by that indexed pool, no need to be reserved from mlx5_aso_ct_pool. The single CT pool is also saved to mlx5_aso_ct_action struct directly.
The ASO operation functions are shared with SW steering implementation.
--- drivers/net/mlx5/mlx5.h | 27 ++- drivers/net/mlx5/mlx5_flow.h | 4 + drivers/net/mlx5/mlx5_flow_aso.c | 19 +- drivers/net/mlx5/mlx5_flow_dv.c | 6 +- drivers/net/mlx5/mlx5_flow_hw.c | 342 ++++++++++++++++++++++++++++++- 5 files changed, 388 insertions(+), 10 deletions(-)
drivers/net/mlx5/mlx5.h +24 -3
@@ -1159,7 +1159,12 @@ enum mlx5_aso_ct_state {/* Generic ASO connection tracking structure. */ struct mlx5_aso_ct_action { -LIST_ENTRY (mlx5_aso_ct_action) next;/* Pointer to the next ASO CT. */ +union { +LIST_ENTRY (mlx5_aso_ct_action) next; +/* Pointer to the next ASO CT. Used only in SWS. */ +struct mlx5_aso_ct_pool *pool; +/* Pointer to action pool. Used only in HWS. */ + };void *dr_action_orig;/* General action object for original dir. */ void *dr_action_rply;/* General action object for reply dir. */ uint32_t refcnt;/* Action used count in device flows. */
@@ -1173,15 +1178,30 @@ struct mlx5_aso_ct_action {#define MLX5_ASO_CT_UPDATE_STATE (c, s) \ __atomic_store_n(&((c)->state), (s), __ATOMIC_RELAXED) +#ifdef PEDANTIC +#pragma GCC diagnostic ignored "-Wpedantic" +#endif +/* ASO connection tracking software pool definition. */ struct mlx5_aso_ct_pool {uint16_t index;/* Pool index in pools array. */ +/* Free ASO CT index in the pool. Used by HWS. */ +struct mlx5_indexed_pool *cts;struct mlx5_devx_obj *devx_obj; -/* The first devx object in the bulk, used for freeing (not yet). */ -struct mlx5_aso_ct_action actions[MLX5_ASO_CT_ACTIONS_PER_POOL ]; +union { +void *dummy_action; +/* Dummy action to increase the reference count in the driver. */ +struct mlx5dr_action *dr_action; +/* HWS action. */ + }; +struct mlx5_aso_ct_action actions[0 ];/* CT action structures bulk. */ }; +#ifdef PEDANTIC +#pragma GCC diagnostic error "-Wpedantic" +#endif +LIST_HEAD (aso_ct_list, mlx5_aso_ct_action);/* Pools management structure for ASO connection tracking pools. */
@@ -1647,6 +1667,7 @@ struct mlx5_priv { LIST_HEAD(flow_hw_tbl_ongo, rte_flow_template_table) flow_hw_tbl_ongo;struct mlx5_indexed_pool *acts_ipool;/* Action data indexed pool. */ struct mlx5_hws_cnt_pool *hws_cpool;/* HW steering's counter pool. */ +struct mlx5_aso_ct_pool *hws_ctpool;/* HW steering's CT pool. */ #endif };
drivers/net/mlx5/mlx5_flow.h +4 -0
@@ -83,6 +83,10 @@ enum {#define MLX5_INDIRECT_ACT_CT_GET_IDX (index) \ ((index) & ((1 << MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) - 1)) +#define MLX5_ACTION_CTX_CT_GET_IDX MLX5_INDIRECT_ACT_CT_GET_IDX +#define MLX5_ACTION_CTX_CT_GET_OWNER MLX5_INDIRECT_ACT_CT_GET_OWNER +#define MLX5_ACTION_CTX_CT_GEN_IDX MLX5_INDIRECT_ACT_CT_GEN_IDX +/* Matches on selected register. */ struct mlx5_rte_flow_item_tag {enum modify_reg id;
drivers/net/mlx5/mlx5_flow_aso.c +14 -5
@@ -903,6 +903,15 @@ mlx5_aso_mtr_wait(struct mlx5_dev_ctx_shared *sh,return -1 ; } +static inline struct mlx5_aso_ct_pool * +__mlx5_aso_ct_get_pool (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_ct_action *ct) +{ +if (likely (sh->config.dv_flow_en ==2 )) +return ct->pool; + return container_of(ct, struct mlx5_aso_ct_pool, actions[ct->offset]); +} +/* * Post a WQE to the ASO CT SQ to modify the context. *
@@ -945,7 +954,7 @@ mlx5_aso_ct_sq_enqueue_single(struct mlx5_dev_ctx_shared *sh,MLX5_ASO_CT_UPDATE_STATE (ct,ASO_CONNTRACK_WAIT ); sq->elts[sq->head & mask].ct = ct; sq->elts[sq->head & mask].query_data =NULL ; - pool = container_of(ct, struct mlx5_aso_ct_pool, actions[ct->offset]); + pool =__mlx5_aso_ct_get_pool (sh, ct);/* Each WQE will have a single CT object. */ wqe->general_cseg.misc =rte_cpu_to_be_32 (pool->devx_obj->id + ct->offset);
@@ -1113,7 +1122,7 @@ mlx5_aso_ct_sq_query_single(struct mlx5_dev_ctx_shared *sh, wqe_idx = sq->head & mask; sq->elts[wqe_idx].ct = ct; sq->elts[wqe_idx].query_data = data; - pool = container_of(ct, struct mlx5_aso_ct_pool, actions[ct->offset]); + pool =__mlx5_aso_ct_get_pool (sh, ct);/* Each WQE will have a single CT object. */ wqe->general_cseg.misc =rte_cpu_to_be_32 (pool->devx_obj->id + ct->offset);
@@ -1231,7 +1240,7 @@ mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh,/* Waiting for wqe resource. */ rte_delay_us_sleep (10u ); }while (--poll_wqe_times); - pool = container_of(ct, struct mlx5_aso_ct_pool, actions[ct->offset]); + pool =__mlx5_aso_ct_get_pool (sh, ct);DRV_LOG (ERR ,"Fail to send WQE for ASO CT %d in pool %d" , ct->offset, pool->index);return -1 ;
@@ -1267,7 +1276,7 @@ mlx5_aso_ct_wait_ready(struct mlx5_dev_ctx_shared *sh,/* Waiting for CQE ready, consider should block or sleep. */ rte_delay_us_sleep (MLX5_ASO_WQE_CQE_RESPONSE_DELAY ); }while (--poll_cqe_times); - pool = container_of(ct, struct mlx5_aso_ct_pool, actions[ct->offset]); + pool =__mlx5_aso_ct_get_pool (sh, ct);DRV_LOG (ERR ,"Fail to poll CQE for ASO CT %d in pool %d" , ct->offset, pool->index);return -1 ;
@@ -1383,7 +1392,7 @@ mlx5_aso_ct_query_by_wqe(struct mlx5_dev_ctx_shared *sh,else rte_delay_us_sleep (10u ); }while (--poll_wqe_times); - pool = container_of(ct, struct mlx5_aso_ct_pool, actions[ct->offset]); + pool =__mlx5_aso_ct_get_pool (sh, ct);DRV_LOG (ERR ,"Fail to send WQE for ASO CT %d in pool %d" , ct->offset, pool->index);return -1 ;
drivers/net/mlx5/mlx5_flow_dv.c +5 -1
@@ -12790,6 +12790,7 @@ flow_dv_ct_pool_create(struct rte_eth_dev *dev,struct mlx5_devx_obj *obj =NULL ;uint32_t i;uint32_t log_obj_size =rte_log2_u32 (MLX5_ASO_CT_ACTIONS_PER_POOL ); +size_t mem_size; obj = mlx5_devx_cmd_create_conn_track_offload_obj(priv->sh->cdev->ctx, priv->sh->cdev->pdn,
@@ -12799,7 +12800,10 @@ flow_dv_ct_pool_create(struct rte_eth_dev *dev,DRV_LOG (ERR ,"Failed to create conn_track_offload_obj using DevX." );return NULL ; } - pool =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*pool),0 ,SOCKET_ID_ANY ); + mem_size =sizeof (struct mlx5_aso_ct_action ) * +MLX5_ASO_CT_ACTIONS_PER_POOL + +sizeof (*pool); + pool =mlx5_malloc (MLX5_MEM_ZERO , mem_size,0 ,SOCKET_ID_ANY );if (!pool) { rte_errno =ENOMEM ;claim_zero (mlx5_devx_cmd_destroy (obj));
drivers/net/mlx5/mlx5_flow_hw.c +341 -1
480 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 22/27 net/mlx5: add HW steering VLAN push, pop and VID modify flow actions
In reply to Suanming MouFrom: Gregory Etelson <[email protected]>
Add PMD implementation for HW steering VLAN push, pop and modify flow actions.
HWS VLAN push flow action is triggered by a sequence of mandatory OF_PUSH_VLAN, OF_SET_VLAN_VID and optional OF_SET_VLAN_PCP flow actions commands.
The commands must be arranged in the exact order:OF_PUSH_VLAN / OF_SET_VLAN_VID [ / OF_SET_VLAN_PCP ].
In masked HWS VLAN push flow action template *ALL* the above flow actions must be masked.
In non-masked HWS VLAN push flow action template *ALL* the above flow actions must not be masked.
Example:
flow actions_template <port id> create \actions_template_id <action id> \
template \
of_push_vlan / \
of_set_vlan_vid \
[ / of_set_vlan_pcp ] / end \
mask \
of_push_vlan ethertype 0 / \
of_set_vlan_vid vlan_vid 0 \
[ / of_set_vlan_pcp vlan_pcp 0 ] / end\
flow actions_template <port id> create \actions_template_id <action id> \
template \
of_push_vlan ethertype <E>/ \
of_set_vlan_vid vlan_vid <VID>\
[ / of_set_vlan_pcp <PCP>] / end \
mask \
of_push_vlan ethertype <type != 0> / \
of_set_vlan_vid vlan_vid <vid_mask != 0>\
[ / of_set_vlan_pcp vlan_pcp <pcp_mask != 0> ] / end\
HWS VLAN pop flow action is triggered by OF_POP_VLAN flow action command.
HWS VLAN pop action template is always non-masked.
Example:
flow actions_template <port id> create \actions_template_id <action id> \
template of_pop_vlan / end mask of_pop_vlan / end
HWS VLAN VID modify flow action is triggered by a standalone OF_SET_VLAN_VID flow action command.
HWS VLAN VID modify action template can be ether masked or non-masked.
Example:
flow actions_template <port id> create \actions_template_id <action id> \
template of_set_vlan_vid / end mask of_set_vlan_vid vlan_vid 0 / end
flow actions_template <port id> create \actions_template_id <action id> \
template of_set_vlan_vid vlan_vid 0x101 / end \
mask of_set_vlan_vid vlan_vid 0xffff / end
--- drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow.h | 4 + drivers/net/mlx5/mlx5_flow_dv.c | 2 +- drivers/net/mlx5/mlx5_flow_hw.c | 360 ++++++++++++++++++++++++++++++-- 4 files changed, 348 insertions(+), 20 deletions(-)
drivers/net/mlx5/mlx5.h +2 -0
@@ -1590,6 +1590,8 @@ struct mlx5_priv {void *root_drop_action;/* Pointer to root drop action. */ rte_spinlock_t hw_ctrl_lock; LIST_HEAD(hw_ctrl_flow, mlx5_hw_ctrl_flow) hw_ctrl_flows; +struct mlx5dr_action *hw_push_vlan[MLX5DR_TABLE_TYPE_MAX ]; +struct mlx5dr_action *hw_pop_vlan[MLX5DR_TABLE_TYPE_MAX ];struct mlx5dr_action **hw_vport;struct rte_flow_template_table *hw_esw_sq_miss_root_tbl;struct rte_flow_template_table *hw_esw_sq_miss_tbl;
drivers/net/mlx5/mlx5_flow.h +4 -0
@@ -2434,4 +2434,8 @@ int mlx5_flow_pattern_validate(struct rte_eth_dev *dev, struct rte_flow_error *error);int flow_hw_table_update (struct rte_eth_dev *dev,struct rte_flow_error *error); +int mlx5_flow_item_field_width (struct rte_eth_dev *dev, +enum rte_flow_field_id field,int inherit, +const struct rte_flow_attr *attr, +struct rte_flow_error *error);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -1326,7 +1326,7 @@ flow_dv_convert_action_modify_ipv6_dscp MLX5_MODIFICATION_TYPE_SET, error); } -static int +int mlx5_flow_item_field_width(struct rte_eth_dev *dev, enum rte_flow_field_id field, int inherit, const struct rte_flow_attr *attr,
drivers/net/mlx5/mlx5_flow_hw.c +341 -19
483 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 23/27 net/mlx5: add meter color flow matching in dv
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
Create firmware and software steering meter color support. Allow matching on a meter color in both root and non-root groups.
--- drivers/net/mlx5/mlx5_flow.h | 3 + drivers/net/mlx5/mlx5_flow_dv.c | 113 ++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+)
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -208,6 +208,9 @@ enum mlx5_feature_name {#define MLX5_FLOW_ITEM_PORT_REPRESENTOR (UINT64_C(1) << 41)#define MLX5_FLOW_ITEM_REPRESENTED_PORT (UINT64_C(1) << 42) +/* Meter color item */ +#define MLX5_FLOW_ITEM_METER_COLOR (UINT64_C(1) << 44) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
drivers/net/mlx5/mlx5_flow_dv.c +113 -0
137 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 24/27 net/mlx5: add meter color flow matching in hws
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
Create hardware steering meter color support. Allow matching on a meter color using hardware steering.
--- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 32 ++++++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_hw.c | 12 ++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -1526,6 +1526,7 @@ flow_hw_get_reg_id(enum rte_flow_item_type type, uint32_t id)*/ return REG_A ;case RTE_FLOW_ITEM_TYPE_CONNTRACK : +case RTE_FLOW_ITEM_TYPE_METER_COLOR :return mlx5_flow_hw_aso_tag;case RTE_FLOW_ITEM_TYPE_TAG :MLX5_ASSERT (id <MLX5_FLOW_HW_TAGS_MAX );
drivers/net/mlx5/mlx5_flow_dv.c +30 -2
@@ -1387,6 +1387,7 @@ mlx5_flow_item_field_width(struct rte_eth_dev *dev,return inherit <0 ?0 : inherit;case RTE_FLOW_FIELD_IPV4_ECN :case RTE_FLOW_FIELD_IPV6_ECN : +case RTE_FLOW_FIELD_METER_COLOR return 2; default:MLX5_ASSERT (false);
@@ -1846,6 +1847,31 @@ mlx5_flow_field_id_to_modify_info info[idx].offset = data->offset; }break ; +case RTE_FLOW_FIELD_METER_COLOR : + { +const uint32_t color_mask = + (UINT32_C (1 ) <<MLX5_MTR_COLOR_BITS ) -1 ; +int reg; + +if (priv->sh->config.dv_flow_en ==2 ) + reg =flow_hw_get_reg_id + (RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 ); +else + reg =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR , +0 , error); +if (reg <0 ) +return ; +MLX5_ASSERT (reg !=REG_NON ); +MLX5_ASSERT ((unsigned int )reg <RTE_DIM (reg_to_field)); + info[idx] = (struct field_modify_info ){4 ,0 , + reg_to_field[reg]}; +if (mask) + mask[idx] =flow_modify_info_mask_32_masked + (width, data->offset, color_mask); +else + info[idx].offset = data->offset; + } +break ;case RTE_FLOW_FIELD_POINTER :case RTE_FLOW_FIELD_VALUE :default :
@@ -1893,7 +1919,7 @@ flow_dv_convert_action_modify_fielduint32_t type, meta =0 ;if (conf->src.field ==RTE_FLOW_FIELD_POINTER || - conf->src.field ==RTE_FLOW_FIELD_VALUE ) { + conf->src.field == RTE_FLOW_FIELD_VALUE) {/ type =MLX5_MODIFICATION_TYPE_SET ;/** For SET fill the destination field (field) first. */ mlx5_flow_field_id_to_modify_info(&conf->dst, field, mask,
@@ -1902,7 +1928,9 @@ flow_dv_convert_action_modify_field item.spec = conf->src.field ==RTE_FLOW_FIELD_POINTER ? (void *)(uintptr_t )conf->src.pvalue : (void *)(uintptr_t )&conf->src.value; -if (conf->dst.field ==RTE_FLOW_FIELD_META ) { +if (conf->dst.field ==RTE_FLOW_FIELD_META || + conf->dst.field ==RTE_FLOW_FIELD_TAG || + conf->dst.field ==RTE_FLOW_FIELD_METER_COLOR ) { meta = *(const unaligned_uint32_t *)item.spec; meta =rte_cpu_to_be_32 (meta); item.spec = &meta;
drivers/net/mlx5/mlx5_flow_hw.c +12 -0
@@ -870,6 +870,7 @@ flow_hw_modify_field_compile(struct rte_eth_dev *dev, (void *)(uintptr_t )&conf->src.value;if (conf->dst.field ==RTE_FLOW_FIELD_META || conf->dst.field ==RTE_FLOW_FIELD_TAG || + conf->dst.field ==RTE_FLOW_FIELD_METER_COLOR || conf->dst.field == (enum rte_flow_field_id )MLX5_RTE_FLOW_FIELD_META_REG ) { value = *(const unaligned_uint32_t *)item.spec; value =rte_cpu_to_be_32 (value);
@@ -1702,6 +1703,7 @@ flow_hw_modify_field_construct(struct mlx5_hw_q_job *job,rte_memcpy (values, mhdr_action->src.pvalue,sizeof (values));if (mhdr_action->dst.field ==RTE_FLOW_FIELD_META || mhdr_action->dst.field ==RTE_FLOW_FIELD_TAG || + mhdr_action->dst.field ==RTE_FLOW_FIELD_METER_COLOR || mhdr_action->dst.field == (enum rte_flow_field_id )MLX5_RTE_FLOW_FIELD_META_REG ) { value_p = (unaligned_uint32_t *)values; *value_p =rte_cpu_to_be_32 (*value_p);
@@ -3704,6 +3706,16 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev, " attribute"); }break ; +case RTE_FLOW_ITEM_TYPE_METER_COLOR : + { +int reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 ); +if (reg ==REG_NON ) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL , +"Unsupported meter color register" ); +break ; + }case RTE_FLOW_ITEM_TYPE_VOID :case RTE_FLOW_ITEM_TYPE_ETH :case RTE_FLOW_ITEM_TYPE_VLAN :
Signature · 1 line
2.25.1
PATCH 25/27 net/mlx5: implement profile/policy get
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
Add callback functions for both software and hardware steering to get a pointers to Meter profile/policy by their IDs.
--- drivers/net/mlx5/mlx5_flow_meter.c | 65 ++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
drivers/net/mlx5/mlx5_flow_meter.c +65 -0
@@ -741,6 +741,36 @@ mlx5_flow_meter_profile_delete(struct rte_eth_dev *dev,return 0 ; } +/** +* Callback to get MTR profile. +* +* @param[in] dev +* Pointer to Ethernet device. +* @param[in] meter_profile_id +* Meter profile id. +* @param[out] error +* Pointer to the error structure. +* +* @return +* A valid handle in case of success, NULL otherwise. +*/ +static struct rte_flow_meter_profile * +mlx5_flow_meter_profile_get (struct rte_eth_dev *dev, +uint32_t meter_profile_id, +struct rte_mtr_error *error) +{ +struct mlx5_priv *priv = dev->data->dev_private; + +if (!priv->mtr_en) { +rte_mtr_error_set (error,ENOTSUP , +RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL , +"Meter is not supported" ); +return NULL ; + } +return (void *)(uintptr_t )mlx5_flow_meter_profile_find (priv, + meter_profile_id); +} +/** * Callback to add MTR profile with HWS. *
@@ -1303,6 +1333,37 @@ mlx5_flow_meter_policy_delete(struct rte_eth_dev *dev,return 0 ; } +/** +* Callback to get MTR policy. +* +* @param[in] dev +* Pointer to Ethernet device. +* @param[in] policy_id +* Meter policy id. +* @param[out] error +* Pointer to the error structure. +* +* @return +* A valid handle in case of success, NULL otherwise. +*/ +static struct rte_flow_meter_policy * +mlx5_flow_meter_policy_get (struct rte_eth_dev *dev, +uint32_t policy_id, +struct rte_mtr_error *error) +{ +struct mlx5_priv *priv = dev->data->dev_private; +uint32_t policy_idx; + +if (!priv->mtr_en) { +rte_mtr_error_set (error,ENOTSUP , +RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL , +"Meter is not supported" ); +return NULL ; + } +return (void *)(uintptr_t )mlx5_flow_meter_policy_find (dev, policy_id, + &policy_idx); +} +/** * Callback to delete MTR policy for HWS. *
@@ -2554,9 +2615,11 @@ static const struct rte_mtr_ops mlx5_flow_mtr_ops = { .capabilities_get = mlx5_flow_mtr_cap_get, .meter_profile_add = mlx5_flow_meter_profile_add, .meter_profile_delete = mlx5_flow_meter_profile_delete, + .meter_profile_get = mlx5_flow_meter_profile_get, .meter_policy_validate = mlx5_flow_meter_policy_validate, .meter_policy_add = mlx5_flow_meter_policy_add, .meter_policy_delete = mlx5_flow_meter_policy_delete, + .meter_policy_get = mlx5_flow_meter_policy_get, .create = mlx5_flow_meter_create, .destroy = mlx5_flow_meter_destroy, .meter_enable = mlx5_flow_meter_enable,
@@ -2571,9 +2634,11 @@ static const struct rte_mtr_ops mlx5_flow_mtr_hws_ops = { .capabilities_get = mlx5_flow_mtr_cap_get, .meter_profile_add = mlx5_flow_meter_profile_hws_add, .meter_profile_delete = mlx5_flow_meter_profile_hws_delete, + .meter_profile_get = mlx5_flow_meter_profile_get, .meter_policy_validate = mlx5_flow_meter_policy_hws_validate, .meter_policy_add = mlx5_flow_meter_policy_hws_add, .meter_policy_delete = mlx5_flow_meter_policy_hws_delete, + .meter_policy_get = mlx5_flow_meter_policy_get, .create = mlx5_flow_meter_hws_create, .destroy = mlx5_flow_meter_hws_destroy, .meter_enable = mlx5_flow_meter_enable,
Signature · 1 line
2.25.1
PATCH 26/27 net/mlx5: implement METER MARK action for HWS
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
Implement METER_MARK action for hardware steering case.
--- drivers/net/mlx5/mlx5.h | 9 ++- drivers/net/mlx5/mlx5_flow.h | 2 + drivers/net/mlx5/mlx5_flow_aso.c | 7 +- drivers/net/mlx5/mlx5_flow_hw.c | 116 +++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_meter.c | 107 ++++++++++++++++++-------- 5 files changed, 204 insertions(+), 37 deletions(-)
drivers/net/mlx5/mlx5.h +8 -1
@@ -969,12 +969,16 @@ enum mlx5_aso_mtr_type {/* Generic aso_flow_meter information. */ struct mlx5_aso_mtr { -LIST_ENTRY (mlx5_aso_mtr) next; +union { +LIST_ENTRY (mlx5_aso_mtr) next; +struct mlx5_aso_mtr_pool *pool; + };enum mlx5_aso_mtr_type type;struct mlx5_flow_meter_info fm;/**< Pointer to the next aso flow meter structure. */ uint8_t state;/**< ASO flow meter state. */ uint32_t offset; +enum rte_color init_color; };/* Generic aso_flow_meter pool structure. */
@@ -983,6 +987,8 @@ struct mlx5_aso_mtr_pool {/*Must be the first in pool*/ struct mlx5_devx_obj *devx_obj;/* The devx object of the minimum aso flow meter ID. */ +struct mlx5dr_action *action;/* HWS action. */ +struct mlx5_indexed_pool *idx_pool;/* HWS index pool. */ uint32_t index;/* Pool index in management structure. */ };
@@ -1670,6 +1676,7 @@ struct mlx5_priv {struct mlx5_indexed_pool *acts_ipool;/* Action data indexed pool. */ struct mlx5_hws_cnt_pool *hws_cpool;/* HW steering's counter pool. */ struct mlx5_aso_ct_pool *hws_ctpool;/* HW steering's CT pool. */ +struct mlx5_aso_mtr_pool *hws_mpool;/* Meter mark indexed pool. */ #endif };
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -1112,6 +1112,7 @@ struct rte_flow_hw {struct rte_flow_template_table *table;/* The table flow allcated from. */ struct mlx5dr_rule rule;/* HWS layer data struct. */ uint32_t cnt_id; +uint32_t mtr_id; } __rte_packed;/* rte flow action translate to DR action struct. */
@@ -1241,6 +1242,7 @@ struct mlx5_hw_actions {uint16_t encap_decap_pos;/* Encap/Decap action position. */ uint32_t mark:1; /* Indicate the mark action. */uint32_t cnt_id;/* Counter id. */ +uint32_t mtr_id;/* Meter id. */ /* Translated DR action array from action template. */ struct mlx5dr_rule_action rule_acts[MLX5_HW_MAX_ACTS ]; };
drivers/net/mlx5/mlx5_flow_aso.c +5 -2
@@ -700,8 +700,11 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_dev_ctx_shared *sh, fm = &aso_mtr->fm; sq->elts[sq->head & mask].mtr = aso_mtr;if (aso_mtr->type ==ASO_METER_INDIRECT ) { - pool = container_of(aso_mtr, struct mlx5_aso_mtr_pool, - mtrs[aso_mtr->offset]); +if (likely (sh->config.dv_flow_en ==2 )) + pool = aso_mtr->pool; +else + pool = container_of(aso_mtr, struct mlx5_aso_mtr_pool, + mtrs[aso_mtr->offset]); id = pool->devx_obj->id; }else { id = bulk->devx_obj->id;
drivers/net/mlx5/mlx5_flow_hw.c +111 -5
192 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +78 -29
184 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 27/27 net/mlx5: implement METER MARK indirect action for HWS
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
Add ability to create an indirect action handle for METER_MARK. It allows to share one Meter between several different actions.
--- drivers/net/mlx5/mlx5_flow.c | 6 ++ drivers/net/mlx5/mlx5_flow.h | 25 ++++- drivers/net/mlx5/mlx5_flow_hw.c | 160 +++++++++++++++++++++++++++++++- 3 files changed, 183 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5_flow.c +6 -0
@@ -4221,6 +4221,12 @@ flow_action_handles_translate(struct rte_eth_dev *dev,MLX5_RTE_FLOW_ACTION_TYPE_COUNT ; translated[handle->index].conf = (void *)(uintptr_t )idx;break ; +case MLX5_INDIRECT_ACTION_TYPE_METER_MARK : + translated[handle->index].type = + (enum rte_flow_action_type ) +MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK ; + translated[handle->index].conf = (void *)(uintptr_t )idx; +break ;case MLX5_INDIRECT_ACTION_TYPE_AGE :if (priv->sh->flow_hit_aso_en) { translated[handle->index].type =
drivers/net/mlx5/mlx5_flow.h +21 -4
@@ -47,6 +47,7 @@ enum mlx5_rte_flow_action_type {MLX5_RTE_FLOW_ACTION_TYPE_COUNT ,MLX5_RTE_FLOW_ACTION_TYPE_JUMP ,MLX5_RTE_FLOW_ACTION_TYPE_RSS , + MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK, };/* Private (internal) Field IDs for MODIFY_FIELD action. */
@@ -55,22 +56,35 @@ enum mlx5_rte_flow_field_id { MLX5_RTE_FLOW_FIELD_META_REG, }; -#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 30 +#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 29enum {MLX5_INDIRECT_ACTION_TYPE_RSS ,MLX5_INDIRECT_ACTION_TYPE_AGE ,MLX5_INDIRECT_ACTION_TYPE_COUNT ,MLX5_INDIRECT_ACTION_TYPE_CT , +MLX5_INDIRECT_ACTION_TYPE_METER_MARK , }; -/* Now, the maximal ports will be supported is 256, action number is 4M. */ -#define MLX5_INDIRECT_ACT_CT_MAX_PORT 0x100 +enum MLX5_SET_MATCHER { +MLX5_SET_MATCHER_SW_V =1 <<0 , +MLX5_SET_MATCHER_SW_M =1 <<1 , +MLX5_SET_MATCHER_HS_V =1 <<2 , +MLX5_SET_MATCHER_HS_M =1 <<3 , +}; + +#define MLX5_SET_MATCHER_SW (MLX5_SET_MATCHER_SW_V | MLX5_SET_MATCHER_SW_M) +#define MLX5_SET_MATCHER_HS (MLX5_SET_MATCHER_HS_V | MLX5_SET_MATCHER_HS_M) +#define MLX5_SET_MATCHER_V (MLX5_SET_MATCHER_SW_V | MLX5_SET_MATCHER_HS_V) +#define MLX5_SET_MATCHER_M (MLX5_SET_MATCHER_SW_M | MLX5_SET_MATCHER_HS_M) + +/* Now, the maximal ports will be supported is 16, action number is 32M. */ +#define MLX5_ACTION_CTX_CT_MAX_PORT 0x10#define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 22#define MLX5_INDIRECT_ACT_CT_OWNER_MASK (MLX5_INDIRECT_ACT_CT_MAX_PORT - 1) -/* 30-31: type, 22-29: owner port, 0-21: index. */ +/* 29-31: type, 25-28: owner port, 0-24: index */ #define MLX5_INDIRECT_ACT_CT_GEN_IDX (owner, index) \ ((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | \ (((owner) & MLX5_INDIRECT_ACT_CT_OWNER_MASK) << \
@@ -1159,6 +1173,9 @@ struct mlx5_action_construct_data {struct {uint32_t id; } shared_counter; +struct { +uint32_t id; + } shared_meter; }; };
drivers/net/mlx5/mlx5_flow_hw.c +156 -4
244 lines not on this page · raw message
Signature · 1 line
2.25.1
v2 cover net/mlx5: HW steering PMD update
In reply to Suanming MouThe skeleton of mlx5 HW steering(HWS) has been updated into upstream for pretty a long time, but not updated anymore due to missing of the low-level steering layer code. Luckily, better late than never, the steering layer finnaly comes[1].
This series will add more features to the existing PMD code:
- FDB and metadata copy.
- Modify field.
- Meter color.
- Counter.
- Aging.
- Action template pre-parser optimization.
- Connection tracking.
Some features such as meter/aging/ct touches the public API, and public API changes have been sent to ML much earily in other threads in order not to be swallowed by this big series.
The dpends patches as below:
[1]https://patches.dpdk.org/project/dpdk/cover/[email protected]/ [2]https://patches.dpdk.org/project/dpdk/cover/[email protected]/ [3]https://patches.dpdk.org/project/dpdk/cover/[email protected]/ [4]https://patches.dpdk.org/project/dpdk/patch/[email protected]/ [5]https://patches.dpdk.org/project/dpdk/patch/[email protected]/ [6]https://patches.dpdk.org/project/dpdk/patch/[email protected]/
---
v2:
- Remove the rte_flow patches as they will be integrated in other thread.
- Fix compilation issues.
- Make the patches be better organized.
---
Alexander Kozyrev (2):
net/mlx5: add HW steering meter action net/mlx5: implement METER MARK indirect action for HWS
Bing Zhao (1):
net/mlx5: add extended metadata mode for hardware steering
Dariusz Sosnowski (4):
net/mlx5: add HW steering port action
net/mlx5: support DR action template API net/mlx5: support device control for E-Switch default rule net/mlx5: support device control of representor matching
Gregory Etelson (2):
net/mlx5: add HW steering VLAN push, pop and VID modify flow actions net/mlx5: support flow integrity in HWS group 0
Michael Baum (1):
net/mlx5: add HWS AGE action support
Suanming Mou (6):
net/mlx5: fix invalid flow attributes net/mlx5: fix IPv6 and TCP RSS hash fields net/mlx5: add shared header reformat support net/mlx5: add modify field hws support net/mlx5: add HW steering connection tracking support net/mlx5: add async action push and pull support
Xiaoyu Min (1):
net/mlx5: add HW steering counter action
doc/guides/nics/mlx5.rst | 9 + drivers/common/mlx5/mlx5_devx_cmds.c | 50 + drivers/common/mlx5/mlx5_devx_cmds.h | 27 + drivers/common/mlx5/mlx5_prm.h | 64 +- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/linux/mlx5_os.c | 76 +- drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 126 +- drivers/net/mlx5/mlx5.h | 318 +- drivers/net/mlx5/mlx5_defs.h | 5 + drivers/net/mlx5/mlx5_flow.c | 415 +- drivers/net/mlx5/mlx5_flow.h | 312 +- drivers/net/mlx5/mlx5_flow_aso.c | 793 ++- drivers/net/mlx5/mlx5_flow_dv.c | 1115 ++-- drivers/net/mlx5/mlx5_flow_hw.c | 7874 +++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_meter.c | 771 ++- drivers/net/mlx5/mlx5_flow_verbs.c | 8 +- drivers/net/mlx5/mlx5_hws_cnt.c | 1198 ++++ drivers/net/mlx5/mlx5_hws_cnt.h | 703 +++ drivers/net/mlx5/mlx5_trigger.c | 254 +- drivers/net/mlx5/mlx5_tx.h | 1 + drivers/net/mlx5/mlx5_txq.c | 47 + drivers/net/mlx5/rte_pmd_mlx5.h | 17 + drivers/net/mlx5/version.map | 1 + 24 files changed, 12536 insertions(+), 1650 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.c create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.h
Signature · 1 line
2.25.1
PATCH v2 1/17 net/mlx5: fix invalid flow attributes
In the function flow_get_drv_type(), attr will be read in non-HWS mode. In case user call the HWS API in SWS mode, attr should be placed in HWS functions, or it will cause crash.
--- drivers/net/mlx5/mlx5_flow.c | 38 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-)
drivers/net/mlx5/mlx5_flow.c +26 -12
@@ -3740,6 +3740,8 @@ flow_get_drv_type(struct rte_eth_dev *dev, const struct rte_flow_attr *attr)*/ if (priv->sh->config.dv_flow_en ==2 )return MLX5_FLOW_TYPE_HW ; +if (!attr) +return MLX5_FLOW_TYPE_MIN ;/* If no OS specific type - continue with DV/VERBS selection */ if (attr->transfer && priv->sh->config.dv_esw_en) type =MLX5_FLOW_TYPE_DV ;
@@ -8252,8 +8254,9 @@ mlx5_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8287,8 +8290,9 @@ mlx5_flow_port_configure(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8319,8 +8323,9 @@ mlx5_flow_pattern_template_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8350,8 +8355,9 @@ mlx5_flow_pattern_template_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8385,8 +8391,9 @@ mlx5_flow_actions_template_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8416,8 +8423,9 @@ mlx5_flow_actions_template_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8457,8 +8465,9 @@ mlx5_flow_table_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8494,8 +8503,9 @@ mlx5_flow_table_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8542,8 +8552,9 @@ mlx5_flow_async_flow_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8585,8 +8596,9 @@ mlx5_flow_async_flow_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8621,8 +8633,9 @@ mlx5_flow_pull(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8650,8 +8663,9 @@ mlx5_flow_push(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
Signature · 1 line
2.25.1
PATCH v2 2/17 net/mlx5: fix IPv6 and TCP RSS hash fields
In reply to Suanming MouIn the flow_dv_hashfields_set() function, while item_flags was 0, the code went directly to the first if and the else case would never have chance be checked. This caused the IPv6 and TCP hash fileds in the else case would never be set.
This commit adds the dedicate HW steering hash field set function to generate the RSS hash fields.
--- drivers/net/mlx5/mlx5_flow_dv.c | 12 +++---- drivers/net/mlx5/mlx5_flow_hw.c | 59 ++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 9 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +4 -8
@@ -11302,8 +11302,7 @@ flow_dv_hashfields_set(uint64_t item_flags, rss_inner =1 ;#endif if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L3_IPV4 )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV4 )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV4 ))) {if (rss_types &MLX5_IPV4_LAYER_TYPES ) {if (rss_types &RTE_ETH_RSS_L3_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_IPV4 ;
@@ -11313,8 +11312,7 @@ flow_dv_hashfields_set(uint64_t item_flags, fields |=MLX5_IPV4_IBV_RX_HASH ; } }else if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L3_IPV6 )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV6 )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV6 ))) {if (rss_types &MLX5_IPV6_LAYER_TYPES ) {if (rss_types &RTE_ETH_RSS_L3_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_IPV6 ;
@@ -11337,8 +11335,7 @@ flow_dv_hashfields_set(uint64_t item_flags,return ; }if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L4_UDP )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_UDP )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_UDP ))) {if (rss_types &RTE_ETH_RSS_UDP ) {if (rss_types &RTE_ETH_RSS_L4_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_PORT_UDP ;
@@ -11348,8 +11345,7 @@ flow_dv_hashfields_set(uint64_t item_flags, fields |=MLX5_UDP_IBV_RX_HASH ; } }else if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L4_TCP )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_TCP )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_TCP ))) {if (rss_types &RTE_ETH_RSS_TCP ) {if (rss_types &RTE_ETH_RSS_L4_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_PORT_TCP ;
drivers/net/mlx5/mlx5_flow_hw.c +58 -1
71 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 3/17 net/mlx5: add shared header reformat support
In reply to Suanming MouAs the rte_flow_async API defines, the action mask with field value not be 0 means the action will be used as shared in all the flows in the table.
The header reformat action with action mask field not be 0 will be created as constant shared action. For encapsulation header reformat action, there are two kinds of encapsulation data, raw_encap_data and rte_flow_item encap_data. Both of these two kinds of data can be identified from the action mask conf as constant or not.
Examples:
1. VXLAN encap (encap_data: rte_flow_item)
action conf (eth/ipv4/udp/vxlan_hdr)
a. action mask conf (eth/ipv4/udp/vxlan_hdr)
- items are constant.
b. action mask conf (NULL)
- items will change.
2. RAW encap (encap_data: raw)
action conf (raw_data)
a. action mask conf (not NULL)
- encap_data constant.
b. action mask conf (NULL)
- encap_data will change.
--- drivers/net/mlx5/mlx5_flow.h | 6 +- drivers/net/mlx5/mlx5_flow_hw.c | 124 ++++++++++---------------------- 2 files changed, 39 insertions(+), 91 deletions(-)
drivers/net/mlx5/mlx5_flow.h +2 -4
@@ -1064,10 +1064,6 @@ struct mlx5_action_construct_data {uint16_t action_dst;/* mlx5dr_rule_action dst offset. */ union {struct { -/* encap src(item) offset. */ -uint16_t src; -/* encap dst data offset. */ -uint16_t dst;/* encap data len. */ uint16_t len; } encap;
@@ -1110,6 +1106,8 @@ struct mlx5_hw_jump_action {/* Encap decap action struct. */ struct mlx5_hw_encap_decap_action {struct mlx5dr_action *action;/* Action object. */ +/* Is header_reformat action shared across flows in table. */ +bool shared;size_t data_size;/* Action metadata size. */ uint8_t data[];/* Action data. */ };
drivers/net/mlx5/mlx5_flow_hw.c +37 -87
226 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 4/17 net/mlx5: add modify field hws support
In reply to Suanming MouThis patch introduces support for modify_field rte_flow actions in HWS mode. Support includes:
- Ingress and egress domains,
- SET and ADD operations,
- usage of arbitrary bit offsets and widths for packet and metadata fields.
Support is implemented in two phases:
1. On flow table creation the hardware commands are generated, based on rte_flow action templates, and stored alongside action template.
2. On flow rule creation/queueing the hardware commands are updated with values provided by the user. Any masks over immediate values, provided in action templates, are applied to these values before enqueueing rules for creation.
--- drivers/common/mlx5/mlx5_prm.h | 2 + drivers/net/mlx5/linux/mlx5_os.c | 18 +- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.h | 96 +++++ drivers/net/mlx5/mlx5_flow_dv.c | 551 ++++++++++++++-------------- drivers/net/mlx5/mlx5_flow_hw.c | 595 ++++++++++++++++++++++++++++++- 6 files changed, 988 insertions(+), 275 deletions(-)
drivers/common/mlx5/mlx5_prm.h +2 -0
@@ -746,6 +746,8 @@ enum mlx5_modification_field {MLX5_MODI_IN_TCP_ACK_NUM =0x5C ,MLX5_MODI_GTP_TEID =0x6E ,MLX5_MODI_OUT_IP_ECN =0x73 , +MLX5_MODI_TUNNEL_HDR_DW_1 =0x75 , + MLX5_MODI_GTPU_FIRST_EXT_DW_0 = 0x76, };/* Total number of metadata reg_c's. */
drivers/net/mlx5/linux/mlx5_os.c +9 -9
@@ -1540,6 +1540,15 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, mlx5_hrxq_clone_free_cb);if (!priv->hrxqs) goto error; +mlx5_set_metadata_mask (eth_dev); +if (sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + !priv->sh->dv_regc0_mask) { +DRV_LOG (ERR ,"metadata mode %u is not supported " +"(no metadata reg_c[0] is available)" , + sh->config.dv_xmeta_en); + err =ENOTSUP ; + goto error; + }rte_rwlock_init (&priv->ind_tbls_lock);if (priv->sh->config.dv_flow_en ==2 ) {#ifdef HAVE_IBV_FLOW_DV_SUPPORT
@@ -1566,15 +1575,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err = -err; goto error; } -mlx5_set_metadata_mask (eth_dev); -if (sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && - !priv->sh->dv_regc0_mask) { -DRV_LOG (ERR ,"metadata mode %u is not supported " -"(no metadata reg_c[0] is available)" , - sh->config.dv_xmeta_en); - err =ENOTSUP ; - goto error; - }/* Query availability of metadata reg_c's. */ if (!priv->sh->metadata_regc_check_flag) { err =mlx5_flow_discover_mreg_c (eth_dev);
drivers/net/mlx5/mlx5.h +1 -0
@@ -343,6 +343,7 @@ struct mlx5_hw_q_job {struct rte_flow_hw *flow;/* Flow attached to the job. */ void *user_data;/* Job user data. */ uint8_t *encap_data;/* Encap data. */ +struct mlx5_modification_cmd *mhdr_cmd; };/* HW steering job descriptor LIFO pool. */
drivers/net/mlx5/mlx5_flow.h +96 -0
132 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +286 -265
732 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +594 -1
690 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 5/17 net/mlx5: add HW steering port action
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch implements creating and caching of port actions for use with HW Steering FDB flows.
Actions are created on flow template API configuration and created only on the port designated as master. Attaching and detaching of ports in the same switching domain causes an update to the port actions cache by, respectively, creating and destroying actions.
A new devarg fdb_def_rule_en is being added and it's used to control the default dedicated E-Switch rule is created by PMD implicitly or not, and PMD sets this value to 1 by default.
If set to 0, the default E-Switch rule will not be created and user can create the specific E-Switch rule on root table if needed.
--- doc/guides/nics/mlx5.rst | 9 + drivers/net/mlx5/linux/mlx5_os.c | 14 + drivers/net/mlx5/mlx5.c | 14 + drivers/net/mlx5/mlx5.h | 26 +- drivers/net/mlx5/mlx5_flow.c | 96 +- drivers/net/mlx5/mlx5_flow.h | 22 +- drivers/net/mlx5/mlx5_flow_dv.c | 93 +- drivers/net/mlx5/mlx5_flow_hw.c | 1356 +++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_flow_verbs.c | 4 +- drivers/net/mlx5/mlx5_trigger.c | 77 +- 10 files changed, 1594 insertions(+), 117 deletions(-)
doc/guides/nics/mlx5.rst +9 -0
@@ -1118,6 +1118,15 @@ for an additional list of options shared with other mlx5 drivers. By default, the PMD will set this value to 1. +- ``fdb_def_rule_en`` parameter [int] + + A non-zero value enables the PMD to create a dedicated rule on E-Switch root + table, this dedicated rule forwards all incoming packets into table 1, other + rules will be created in E-Switch table original table level plus one, to + improve the flow insertion rate due to skip root table managed by firmware. + If set to 0, all rules will be created on the original E-Switch table level. + + By default, the PMD will set this value to 1. Supported NICs --------------
drivers/net/mlx5/linux/mlx5_os.c +14 -0
@@ -1556,6 +1556,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,flow_hw_set_port_info (eth_dev);/* Only HWS requires this information. */ flow_hw_init_tags_set (eth_dev); +if (priv->sh->config.dv_esw_en && +flow_hw_create_vport_action (eth_dev)) { +DRV_LOG (ERR ,"port %u failed to create vport action" , + eth_dev->data->port_id); + err =EINVAL ; + goto error; + }return eth_dev;#else DRV_LOG (ERR ,"DV support is missing for HWS." );
@@ -1620,6 +1627,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,return eth_dev; error:if (priv) { +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +if (eth_dev && + priv->sh && + priv->sh->config.dv_flow_en ==2 && + priv->sh->config.dv_esw_en) +flow_hw_destroy_vport_action (eth_dev); +#endif if (priv->mreg_cp_tbl)mlx5_hlist_destroy (priv->mreg_cp_tbl);if (priv->sh)
drivers/net/mlx5/mlx5.c +14 -0
@@ -172,6 +172,9 @@/* Device parameter to configure the delay drop when creating Rxqs. */ #define MLX5_DELAY_DROP "delay_drop" +/* Device parameter to create the fdb default rule in PMD */ +#define MLX5_FDB_DEFAULT_RULE_EN "fdb_def_rule_en" +/* Shared memory between primary and secondary processes. */ struct mlx5_shared_data *mlx5_shared_data;
@@ -1239,6 +1242,8 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque) config->decap_en = !!tmp; }else if (strcmp (MLX5_ALLOW_DUPLICATE_PATTERN , key) ==0 ) { config->allow_duplicate_pattern = !!tmp; + }else if (strcmp (MLX5_FDB_DEFAULT_RULE_EN , key) ==0 ) { + config->fdb_def_rule = !!tmp; }return 0 ; }
@@ -1274,6 +1279,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,MLX5_RECLAIM_MEM ,MLX5_DECAP_EN ,MLX5_ALLOW_DUPLICATE_PATTERN , +MLX5_FDB_DEFAULT_RULE_EN , NULL, };int ret =0 ;
@@ -1285,6 +1291,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->dv_flow_en =1 ; config->decap_en =1 ; config->allow_duplicate_pattern =1 ; + config->fdb_def_rule =1 ;if (mkvlist !=NULL ) {/* Process parameters. */ ret = mlx5_kvargs_process(mkvlist, params,
@@ -1360,6 +1367,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,DRV_LOG (DEBUG ,"\"decap_en\" is %u." , config->decap_en);DRV_LOG (DEBUG ,"\"allow_duplicate_pattern\" is %u." , config->allow_duplicate_pattern); +DRV_LOG (DEBUG ,"\"fdb_def_rule_en\" is %u." , config->fdb_def_rule);return 0 ; }
@@ -1943,6 +1951,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)mlx5_flex_parser_ecpri_release (dev);mlx5_flex_item_port_cleanup (dev);#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H ) +flow_hw_destroy_vport_action (dev);flow_hw_resource_release (dev);flow_hw_clear_port_info (dev);if (priv->sh->config.dv_flow_en ==2 )
@@ -2644,6 +2653,11 @@ mlx5_probe_again_args_validate(struct mlx5_common_device *cdev, sh->ibdev_name); goto error; } +if (sh->config.fdb_def_rule ^ config->fdb_def_rule) { +DRV_LOG (ERR ,"\"fdb_def_rule_en\" configuration mismatch for shared %s context." , + sh->ibdev_name); + goto error; + }if (sh->config.l3_vxlan_en ^ config->l3_vxlan_en) { DRV_LOG(ERR, "\"l3_vxlan_en\" " "configuration mismatch for shared %s context.",
drivers/net/mlx5/mlx5.h +22 -4
@@ -309,6 +309,7 @@ struct mlx5_sh_config { uint32_t allow_duplicate_pattern:1; uint32_t lro_allowed:1; /* Whether LRO is allowed. *//* Allow/Prevent the duplicate rules pattern. */ + uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ };
@@ -337,6 +338,8 @@ enum { MLX5_HW_Q_JOB_TYPE_DESTROY, /* Flow destroy job type. */ }; +#define MLX5_HW_MAX_ITEMS (16) +/* HW steering flow management job descriptor. */ struct mlx5_hw_q_job {uint32_t type;/* Job type. */
@@ -344,6 +347,8 @@ struct mlx5_hw_q_job {void *user_data;/* Job user data. */ uint8_t *encap_data;/* Encap data. */ struct mlx5_modification_cmd *mhdr_cmd; +struct rte_flow_item *items; +struct rte_flow_item_ethdev port_spec; };/* HW steering job descriptor LIFO pool. */
@@ -1202,6 +1207,8 @@ struct mlx5_dev_ctx_shared { uint32_t flow_priority_check_flag:1; /* Check Flag for flow priority. */ uint32_t metadata_regc_check_flag:1; /* Check Flag for metadata REGC. */ uint32_t hws_tags:1; /* Check if tags info for HWS initialized. */ + uint32_t shared_mark_enabled:1; +/* If mark action is enabled on Rxqs (shared E-Switch domain). */ uint32_t max_port;/* Maximal IB device port index. */ struct mlx5_bond_info bond;/* Bonding information. */ struct mlx5_common_device *cdev;/* Backend mlx5 device. */
@@ -1450,6 +1457,12 @@ struct mlx5_obj_ops {#define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields) +struct mlx5_hw_ctrl_flow { +LIST_ENTRY (mlx5_hw_ctrl_flow) next; +struct rte_eth_dev *owner_dev; +struct rte_flow *flow; +}; +struct mlx5_priv {struct rte_eth_dev_data *dev_data;/* Pointer to device data. */ struct mlx5_dev_ctx_shared *sh;/* Shared device context. */
@@ -1490,6 +1503,11 @@ struct mlx5_priv {unsigned int reta_idx_n;/* RETA index size. */ struct mlx5_drop drop_queue;/* Flow drop queues. */ void *root_drop_action;/* Pointer to root drop action. */ +rte_spinlock_t hw_ctrl_lock; + LIST_HEAD(hw_ctrl_flow, mlx5_hw_ctrl_flow) hw_ctrl_flows; +struct rte_flow_template_table *hw_esw_sq_miss_root_tbl; +struct rte_flow_template_table *hw_esw_sq_miss_tbl; +struct rte_flow_template_table *hw_esw_zero_tbl;struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI ];/* RTE Flow rules. */ uint32_t ctrl_flows;/* Control flow rules. */
@@ -1550,11 +1568,11 @@ struct mlx5_priv {struct mlx5_hw_q *hw_q;/* HW steering rte flow table list header. */ LIST_HEAD(flow_hw_tbl, rte_flow_template_table) flow_hw_tbl; +struct mlx5dr_action **hw_vport;/* HW steering global drop action. */ -struct mlx5dr_action *hw_drop[MLX5_HW_ACTION_FLAG_MAX ] - [MLX5DR_TABLE_TYPE_MAX ]; -/* HW steering global drop action. */ -struct mlx5dr_action *hw_tag[MLX5_HW_ACTION_FLAG_MAX ]; +struct mlx5dr_action *hw_drop[2 ]; +/* HW steering global tag action. */ +struct mlx5dr_action *hw_tag[2 ];struct mlx5_indexed_pool *acts_ipool;/* Action data indexed pool. */ #endif };
drivers/net/mlx5/mlx5_flow.c +80 -16
171 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +21 -1
@@ -1151,6 +1151,11 @@ struct rte_flow_pattern_template {struct mlx5dr_match_template *mt;/* mlx5 match template. */ uint64_t item_flags;/* Item layer flags. */ uint32_t refcnt;/* Reference counter. */ +/* +* If true, then rule pattern should be prepended with +* represented_port pattern item. +*/ +bool implicit_port; };/* Flow action template struct. */
@@ -1226,6 +1231,7 @@ struct mlx5_hw_action_template {/* mlx5 flow group struct. */ struct mlx5_flow_group {struct mlx5_list_entry entry; +struct rte_eth_dev *dev;/* Reference to corresponding device. */ struct mlx5dr_table *tbl;/* HWS table object. */ struct mlx5_hw_jump_action jump;/* Jump action. */ enum mlx5dr_table_type type;/* Table type. */
@@ -1484,6 +1490,9 @@ void flow_hw_clear_port_info(struct rte_eth_dev *dev);void flow_hw_init_tags_set (struct rte_eth_dev *dev);void flow_hw_clear_tags_set (struct rte_eth_dev *dev); +int flow_hw_create_vport_action (struct rte_eth_dev *dev); +void flow_hw_destroy_vport_action (struct rte_eth_dev *dev); + typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2056,7 +2065,7 @@ 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, + bool root, struct rte_flow_error *error); int mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item, uint64_t item_flags,
@@ -2313,4 +2322,15 @@ int flow_dv_translate_items_hws(const struct rte_flow_item *items, uint32_t key_type, uint64_t *item_flags, uint8_t *match_criteria, struct rte_flow_error *error); + +int mlx5_flow_pick_transfer_proxy (struct rte_eth_dev *dev, +uint16_t *proxy_port_id, +struct rte_flow_error *error); + +int mlx5_flow_hw_flush_ctrl_flows (struct rte_eth_dev *dev); + +int mlx5_flow_hw_esw_create_mgr_sq_miss_flow (struct rte_eth_dev *dev); +int mlx5_flow_hw_esw_create_sq_miss_flow (struct rte_eth_dev *dev, +uint32_t txq); +int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +53 -40
297 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +1309 -47
1,615 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +3 -1
@@ -1245,12 +1245,14 @@ flow_verbs_validate(struct rte_eth_dev *dev,uint16_t ether_type =0 ;bool is_empty_vlan = false;uint16_t udp_dport =0 ; +bool is_root;if (items ==NULL )return -1 ; ret =mlx5_flow_validate_attributes (dev, attr, error);if (ret <0 )return ret; + is_root = ret;for (; items->type !=RTE_FLOW_ITEM_TYPE_END ; items++) {int tunnel = !!(item_flags &MLX5_FLOW_LAYER_TUNNEL );int ret =0 ;
@@ -1380,7 +1382,7 @@ flow_verbs_validate(struct rte_eth_dev *dev,case RTE_FLOW_ITEM_TYPE_VXLAN : ret =mlx5_flow_validate_item_vxlan (dev, udp_dport, items, item_flags, - attr, error); + is_root, error);if (ret <0 )return ret; last_item =MLX5_FLOW_LAYER_VXLAN ;
drivers/net/mlx5/mlx5_trigger.c +69 -8
101 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 6/17 net/mlx5: add extended metadata mode for hardware steering
In reply to Suanming MouFrom: Bing Zhao <[email protected]>
The new mode 4 of devarg "dv_xmeta_en" is added for HWS only. In this mode, the Rx / Tx metadata with 32b width copy between FDB and NIC is supported. The mark is only supported in NIC and there is no copy supported.
--- drivers/net/mlx5/linux/mlx5_os.c | 10 +- drivers/net/mlx5/mlx5.c | 7 +- drivers/net/mlx5/mlx5.h | 8 +- drivers/net/mlx5/mlx5_flow.c | 8 +- drivers/net/mlx5/mlx5_flow.h | 14 + drivers/net/mlx5/mlx5_flow_dv.c | 21 +- drivers/net/mlx5/mlx5_flow_hw.c | 862 ++++++++++++++++++++++++++++--- drivers/net/mlx5/mlx5_trigger.c | 3 + 8 files changed, 851 insertions(+), 82 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +9 -1
@@ -1554,6 +1554,15 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,#ifdef HAVE_IBV_FLOW_DV_SUPPORT if (priv->vport_meta_mask)flow_hw_set_port_info (eth_dev); +if (priv->sh->config.dv_esw_en && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_META32_HWS ) { +DRV_LOG (ERR , +"metadata mode %u is not supported in HWS eswitch mode" , + priv->sh->config.dv_xmeta_en); + err =ENOTSUP ; + goto error; + }/* Only HWS requires this information. */ flow_hw_init_tags_set (eth_dev); if (priv->sh->config.dv_esw_en &&
@@ -1569,7 +1578,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, goto error;#endif } -/* Port representor shares the same max priority with pf port. */ if (!priv->sh->flow_priority_check_flag) {/* Supported Verbs flow priority number detection. */ err =mlx5_flow_discover_priorities (eth_dev);
drivers/net/mlx5/mlx5.c +6 -1
@@ -1218,7 +1218,8 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque)if (tmp !=MLX5_XMETA_MODE_LEGACY && tmp !=MLX5_XMETA_MODE_META16 && tmp !=MLX5_XMETA_MODE_META32 && - tmp !=MLX5_XMETA_MODE_MISS_INFO ) { + tmp !=MLX5_XMETA_MODE_MISS_INFO && + tmp !=MLX5_XMETA_MODE_META32_HWS ) {DRV_LOG (ERR ,"Invalid extensive metadata parameter." ); rte_errno =EINVAL ;return -rte_errno;
@@ -2849,6 +2850,10 @@ mlx5_set_metadata_mask(struct rte_eth_dev *dev) meta =UINT32_MAX ; mark = (reg_c0 >>rte_bsf32 (reg_c0)) &MLX5_FLOW_MARK_MASK ;break ; +case MLX5_XMETA_MODE_META32_HWS : + meta =UINT32_MAX ; + mark =MLX5_FLOW_MARK_MASK ; +break ;default : meta =0 ; mark =0 ;
drivers/net/mlx5/mlx5.h +4 -4
@@ -298,8 +298,8 @@ struct mlx5_sh_config { uint32_t reclaim_mode:2; /* Memory reclaim mode. */ uint32_t dv_esw_en:1; /* Enable E-Switch DV flow. *//* Enable DV flow. 1 means SW steering, 2 means HW steering. */ - unsigned int dv_flow_en:2; - uint32_t dv_xmeta_en:2; /* Enable extensive flow metadata. */ + uint32_t dv_flow_en:2; /* Enable DV flow. */ + uint32_t dv_xmeta_en:3; /* Enable extensive flow metadata. */ uint32_t dv_miss_info:1; /* Restore packet after partial hw miss. */ uint32_t l3_vxlan_en:1; /* Enable L3 VXLAN flow creation. */ uint32_t vf_nl_en:1; /* Enable Netlink requests in VF mode. */
@@ -312,7 +312,6 @@ struct mlx5_sh_config { uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ }; -/* Structure for VF VLAN workaround. */ struct mlx5_vf_vlan {uint32_t tag:12 ;
@@ -1279,12 +1278,12 @@ struct mlx5_dev_ctx_shared {struct mlx5_lb_ctx self_lb;/* QP to enable self loopback for Devx. */ unsigned int flow_max_priority;enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM ]; +/* Availability of mreg_c's. */ void *devx_channel_lwm;struct rte_intr_handle *intr_handle_lwm;pthread_mutex_t lwm_config_lock; uint32_t host_shaper_rate:8; uint32_t lwm_triggered:1; -/* Availability of mreg_c's. */ struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1508,6 +1507,7 @@ struct mlx5_priv {struct rte_flow_template_table *hw_esw_sq_miss_root_tbl;struct rte_flow_template_table *hw_esw_sq_miss_tbl;struct rte_flow_template_table *hw_esw_zero_tbl; +struct rte_flow_template_table *hw_tx_meta_cpy_tbl;struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI ];/* RTE Flow rules. */ uint32_t ctrl_flows;/* Control flow rules. */
drivers/net/mlx5/mlx5_flow.c +7 -1
@@ -1107,6 +1107,8 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,return REG_C_0 ;case MLX5_XMETA_MODE_META32 :return REG_C_1 ; +case MLX5_XMETA_MODE_META32_HWS : +return REG_C_1 ; }break ;case MLX5_METADATA_TX :
@@ -1119,11 +1121,14 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,return REG_C_0 ;case MLX5_XMETA_MODE_META32 :return REG_C_1 ; +case MLX5_XMETA_MODE_META32_HWS : +return REG_C_1 ; }break ;case MLX5_FLOW_MARK :switch (config->dv_xmeta_en) {case MLX5_XMETA_MODE_LEGACY : +case MLX5_XMETA_MODE_META32_HWS :return REG_NON ;case MLX5_XMETA_MODE_META16 :return REG_C_1 ;
@@ -4442,7 +4447,8 @@ static bool flow_check_modify_action_type(struct rte_eth_dev *dev,return true;case RTE_FLOW_ACTION_TYPE_FLAG :case RTE_FLOW_ACTION_TYPE_MARK : -if (priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY ) +if (priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_META32_HWS )return true;else return false;
drivers/net/mlx5/mlx5_flow.h +14 -0
@@ -48,6 +48,12 @@ enum mlx5_rte_flow_action_type { MLX5_RTE_FLOW_ACTION_TYPE_RSS, }; +/* Private (internal) Field IDs for MODIFY_FIELD action. */ +enum mlx5_rte_flow_field_id { +MLX5_RTE_FLOW_FIELD_END =INT_MIN , +MLX5_RTE_FLOW_FIELD_META_REG , +}; +#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 30enum {
@@ -1167,6 +1173,7 @@ struct rte_flow_actions_template {struct rte_flow_action *masks;/* Cached action masks.*/ uint16_t mhdr_off;/* Offset of DR modify header action. */ uint32_t refcnt;/* Reference counter. */ +uint16_t rx_cpy_pos;/* Action position of Rx metadata to be copied. */ };/* Jump action struct. */
@@ -1243,6 +1250,11 @@ struct mlx5_flow_group {#define MLX5_HW_TBL_MAX_ITEM_TEMPLATE 2#define MLX5_HW_TBL_MAX_ACTION_TEMPLATE 32 +struct mlx5_flow_template_table_cfg { +struct rte_flow_template_table_attr attr;/* Table attributes passed through flow API. */ +bool external;/* True if created by flow API, false if table is internal to PMD. */ +}; +struct rte_flow_template_table {LIST_ENTRY (rte_flow_template_table) next;struct mlx5_flow_group *grp;/* The group rte_flow_template_table uses. */
@@ -1252,6 +1264,7 @@ struct rte_flow_template_table {/* Action templates bind to the table. */ struct mlx5_hw_action_template ats[MLX5_HW_TBL_MAX_ACTION_TEMPLATE ];struct mlx5_indexed_pool *flow;/* The table's flow ipool. */ +struct mlx5_flow_template_table_cfg cfg;uint32_t type;/* Flow table type RX/TX/FDB. */ uint8_t nb_item_templates;/* Item template number. */ uint8_t nb_action_templates;/* Action template number. */
@@ -2333,4 +2346,5 @@ int mlx5_flow_hw_esw_create_mgr_sq_miss_flow(struct rte_eth_dev *dev);int mlx5_flow_hw_esw_create_sq_miss_flow (struct rte_eth_dev *dev,uint32_t txq);int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev); +int mlx5_flow_hw_create_tx_default_mreg_copy_flow (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +20 -1
@@ -1783,7 +1783,8 @@ mlx5_flow_field_id_to_modify_infoint reg;if (priv->sh->config.dv_flow_en ==2 ) - reg =REG_C_1 ; + reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_TAG , + data->level);else reg =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG , data->level, error);
@@ -1862,6 +1863,24 @@ mlx5_flow_field_id_to_modify_infoelse info[idx].offset = off_be;break ; +case MLX5_RTE_FLOW_FIELD_META_REG : + { +uint32_t meta_mask = priv->sh->dv_meta_mask; +uint32_t meta_count =__builtin_popcount (meta_mask); +uint32_t reg = data->level; + +RTE_SET_USED (meta_count); +MLX5_ASSERT (data->offset + width <= meta_count); +MLX5_ASSERT (reg !=REG_NON ); +MLX5_ASSERT (reg <RTE_DIM (reg_to_field)); + info[idx] = (struct field_modify_info ){4 ,0 , reg_to_field[reg]}; +if (mask) + mask[idx] =flow_modify_info_mask_32_masked + (width, data->offset, meta_mask); +else + info[idx].offset = data->offset; + } +break ;case RTE_FLOW_FIELD_POINTER :case RTE_FLOW_FIELD_VALUE :default :
drivers/net/mlx5/mlx5_flow_hw.c +788 -74
1,287 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +3 -0
@@ -1292,6 +1292,9 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev)if (priv->sh->config.dv_esw_en && priv->master) {if (mlx5_flow_hw_esw_create_mgr_sq_miss_flow (dev)) goto error; +if (priv->sh->config.dv_xmeta_en ==MLX5_XMETA_MODE_META32_HWS ) +if (mlx5_flow_hw_create_tx_default_mreg_copy_flow (dev)) + goto error; }for (i =0 ; i < priv->txqs_n; ++i) {struct mlx5_txq_ctrl *txq =mlx5_txq_get (dev, i);
Signature · 1 line
2.25.1
PATCH v2 7/17 net/mlx5: add HW steering meter action
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
This commit adds meter action for HWS steering.
HW steering meter is based on ASO. The number of meters will be used by flows should be specified in advanced in the flow configure API.
--- drivers/net/mlx5/mlx5.h | 61 ++- drivers/net/mlx5/mlx5_flow.c | 71 +++ drivers/net/mlx5/mlx5_flow.h | 50 ++ drivers/net/mlx5/mlx5_flow_aso.c | 30 +- drivers/net/mlx5/mlx5_flow_dv.c | 25 - drivers/net/mlx5/mlx5_flow_hw.c | 264 ++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 702 ++++++++++++++++++++++++++++- 7 files changed, 1142 insertions(+), 61 deletions(-)
drivers/net/mlx5/mlx5.h +58 -3
@@ -357,6 +357,9 @@ struct mlx5_hw_q {struct mlx5_hw_q_job **job;/* LIFO header. */ } __rte_cache_aligned; + + +#define MLX5_COUNTERS_PER_POOL 512#define MLX5_MAX_PENDING_QUERIES 4#define MLX5_CNT_CONTAINER_RESIZE 64
@@ -782,15 +785,29 @@ struct mlx5_flow_meter_policy {/* Is meter action in policy table. */ uint32_t hierarchy_drop_cnt:1;/* Is any meter in hierarchy contains drop_cnt. */ + uint32_t skip_r:1; +/* If red color policy is skipped. */ uint32_t skip_y:1;/* If yellow color policy is skipped. */ uint32_t skip_g:1;/* If green color policy is skipped. */ uint32_t mark:1;/* If policy contains mark action. */ + uint32_t initialized:1; +/* Initialized. */ +uint16_t group; +/* The group. */ rte_spinlock_t sl;uint32_t ref_cnt;/* Use count. */ +struct rte_flow_pattern_template *hws_item_templ; +/* Hardware steering item templates. */ +struct rte_flow_actions_template *hws_act_templ[MLX5_MTR_DOMAIN_MAX ]; +/* Hardware steering action templates. */ +struct rte_flow_template_table *hws_flow_table[MLX5_MTR_DOMAIN_MAX ]; +/* Hardware steering tables. */ +struct rte_flow *hws_flow_rule[MLX5_MTR_DOMAIN_MAX ][RTE_COLORS ]; +/* Hardware steering rules. */ struct mlx5_meter_policy_action_container act_cnt[MLX5_MTR_RTE_COLORS ];/* Policy actions container. */ void *dr_drop_action[MLX5_MTR_DOMAIN_MAX ];
@@ -865,6 +882,7 @@ struct mlx5_flow_meter_info {*/ uint32_t transfer:1; uint32_t def_policy:1; + uint32_t initialized:1;/* Meter points to default policy. */ uint32_t color_aware:1;/* Meter is color aware mode. */
@@ -880,6 +898,10 @@ struct mlx5_flow_meter_info {/**< Flow meter action. */ void *meter_action_y;/**< Flow meter action for yellow init_color. */ +uint32_t meter_offset; +/**< Flow meter offset. */ +uint16_t group; +/**< Flow meter group. */ };/* PPS(packets per second) map to BPS(Bytes per second).
@@ -914,6 +936,7 @@ struct mlx5_flow_meter_profile {uint32_t ref_cnt;/**< Use count. */ uint32_t g_support:1; /**< If G color will be generated. */ uint32_t y_support:1; /**< If Y color will be generated. */ + uint32_t initialized:1; /**< Initialized. */ };/* 2 meters in each ASO cache line */
@@ -934,13 +957,20 @@ enum mlx5_aso_mtr_state { ASO_METER_READY, /* CQE received. */ }; +/*aso flow meter type*/ +enum mlx5_aso_mtr_type { +ASO_METER_INDIRECT , +ASO_METER_DIRECT , +}; +/* Generic aso_flow_meter information. */ struct mlx5_aso_mtr {LIST_ENTRY (mlx5_aso_mtr) next; +enum mlx5_aso_mtr_type type;struct mlx5_flow_meter_info fm;/**< Pointer to the next aso flow meter structure. */ uint8_t state;/**< ASO flow meter state. */ -uint8_t offset; +uint32_t offset; };/* Generic aso_flow_meter pool structure. */
@@ -964,6 +994,14 @@ struct mlx5_aso_mtr_pools_mng {struct mlx5_aso_mtr_pool **pools;/* ASO flow meter pool array. */ }; +/* Bulk management structure for ASO flow meter. */ +struct mlx5_mtr_bulk { +uint32_t size;/* Number of ASO objects. */ +struct mlx5dr_action *action;/* HWS action */ +struct mlx5_devx_obj *devx_obj;/* DEVX object. */ +struct mlx5_aso_mtr *aso;/* Array of ASO objects. */ +}; +/* Meter management structure for global flow meter resource. */ struct mlx5_flow_mtr_mng {struct mlx5_aso_mtr_pools_mng pools_mng;
@@ -1017,6 +1055,7 @@ struct mlx5_flow_tbl_resource {#define MLX5_FLOW_TABLE_LEVEL_METER (MLX5_MAX_TABLES - 3)#define MLX5_FLOW_TABLE_LEVEL_POLICY (MLX5_MAX_TABLES - 4)#define MLX5_MAX_TABLES_EXTERNAL MLX5_FLOW_TABLE_LEVEL_POLICY +#define MLX5_FLOW_TABLE_HWS_POLICY (MLX5_MAX_TABLES - 10)#define MLX5_MAX_TABLES_FDB UINT16_MAX#define MLX5_FLOW_TABLE_FACTOR 10
@@ -1303,6 +1342,12 @@ TAILQ_HEAD(mlx5_mtr_profiles, mlx5_flow_meter_profile);/* MTR list. */ TAILQ_HEAD (mlx5_legacy_flow_meters, mlx5_legacy_flow_meter); +struct mlx5_mtr_config { +uint32_t nb_meters;/**< Number of configured meters */ +uint32_t nb_meter_profiles;/**< Number of configured meter profiles */ +uint32_t nb_meter_policies;/**< Number of configured meter policies */ +}; +/* RSS description. */ struct mlx5_flow_rss_desc {uint32_t level;
@@ -1538,12 +1583,16 @@ struct mlx5_priv {struct mlx5_nl_vlan_vmwa_context *vmwa_context;/* VLAN WA context. */ struct mlx5_hlist *mreg_cp_tbl;/* Hash table of Rx metadata register copy table. */ +struct mlx5_mtr_config mtr_config;/* Meter configuration */ uint8_t mtr_sfx_reg;/* Meter prefix-suffix flow match REG_C. */ uint8_t mtr_color_reg;/* Meter color match REG_C. */ struct mlx5_legacy_flow_meters flow_meters;/* MTR list. */ struct mlx5_l3t_tbl *mtr_profile_tbl;/* Meter index lookup table. */ +struct mlx5_flow_meter_profile *mtr_profile_arr;/* Profile array. */ struct mlx5_l3t_tbl *policy_idx_tbl;/* Policy index lookup table. */ +struct mlx5_flow_meter_policy *mtr_policy_arr;/* Policy array. */ struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ +struct mlx5_mtr_bulk mtr_bulk;/* Meter index mapping for HWS */ uint8_t skip_default_rss_reta;/* Skip configuration of default reta. */ uint8_t fdb_def_rule;/* Whether fdb jump to table 1 is configured. */ struct mlx5_mp_id mp_id;/* ID of a multi-process process */
@@ -1557,13 +1606,13 @@ struct mlx5_priv {struct mlx5_flex_item flex_item[MLX5_PORT_FLEX_ITEM_NUM ];/* Flex items have been created on the port. */ uint32_t flex_item_map;/* Map of allocated flex item elements. */ +uint32_t nb_queue;/* HW steering queue number. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )/* Item template list. */ LIST_HEAD(flow_hw_itt, rte_flow_pattern_template) flow_hw_itt;/* Action template list. */ LIST_HEAD(flow_hw_at, rte_flow_actions_template) flow_hw_at;struct mlx5dr_context *dr_ctx;/**< HW steering DR context. */ -uint32_t nb_queue;/* HW steering queue number. */ /* HW steering queue polling mechanism job descriptor LIFO. */ struct mlx5_hw_q *hw_q;/* HW steering rte flow table list header. */
@@ -1579,6 +1628,7 @@ struct mlx5_priv {#define PORT_ID (priv) ((priv)->dev_data->port_id)#define ETH_DEV (priv) (&rte_eth_devices[PORT_ID(priv)]) +#define CTRL_QUEUE_ID (priv) ((priv)->nb_queue - 1)struct rte_hairpin_peer_info {uint32_t qp_id;
@@ -1890,6 +1940,11 @@ void mlx5_pmd_socket_uninit(void);/* mlx5_flow_meter.c */ +int mlx5_flow_meter_init (struct rte_eth_dev *dev, +uint32_t nb_meters, +uint32_t nb_meter_profiles, +uint32_t nb_meter_policies); +void mlx5_flow_meter_uninit (struct rte_eth_dev *dev);int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg);struct mlx5_flow_meter_info *mlx5_flow_meter_find (struct mlx5_priv *priv,uint32_t meter_id,uint32_t *mtr_idx);
@@ -1964,7 +2019,7 @@ int mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh);void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh,enum mlx5_access_aso_opc_mod aso_opc_mod);int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh, -struct mlx5_aso_mtr *mtr); +struct mlx5_aso_mtr *mtr,struct mlx5_mtr_bulk *bulk);int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh,struct mlx5_aso_mtr *mtr); int mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh,
drivers/net/mlx5/mlx5_flow.c +71 -0
83 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +50 -0
86 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_aso.c +19 -11
@@ -642,7 +642,8 @@ mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh)static uint16_t mlx5_aso_mtr_sq_enqueue_single (struct mlx5_dev_ctx_shared *sh,struct mlx5_aso_sq *sq, -struct mlx5_aso_mtr *aso_mtr) +struct mlx5_aso_mtr *aso_mtr, +struct mlx5_mtr_bulk *bulk) {volatile struct mlx5_aso_wqe *wqe =NULL ;struct mlx5_flow_meter_info *fm =NULL ;
@@ -653,6 +654,7 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_dev_ctx_shared *sh,uint32_t dseg_idx =0 ;struct mlx5_aso_mtr_pool *pool =NULL ;uint32_t param_le; +int id;rte_spinlock_lock (&sq->sqsl); res = size - (uint16_t )(sq->head - sq->tail);
@@ -666,14 +668,19 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_dev_ctx_shared *sh,/* Fill next WQE. */ fm = &aso_mtr->fm; sq->elts[sq->head & mask].mtr = aso_mtr; - pool = container_of(aso_mtr, struct mlx5_aso_mtr_pool, - mtrs[aso_mtr->offset]); - wqe->general_cseg.misc =rte_cpu_to_be_32 (pool->devx_obj->id + - (aso_mtr->offset >>1 )); - wqe->general_cseg.opcode =rte_cpu_to_be_32 (MLX5_OPCODE_ACCESS_ASO | - (ASO_OPC_MOD_POLICER << -WQE_CSEG_OPC_MOD_OFFSET ) | - sq->pi <<WQE_CSEG_WQE_INDEX_OFFSET ); +if (aso_mtr->type ==ASO_METER_INDIRECT ) { + pool = container_of(aso_mtr, struct mlx5_aso_mtr_pool, + mtrs[aso_mtr->offset]); + id = pool->devx_obj->id; + }else { + id = bulk->devx_obj->id; + } + wqe->general_cseg.misc =rte_cpu_to_be_32 (id + + (aso_mtr->offset >>1 )); + wqe->general_cseg.opcode = +rte_cpu_to_be_32 (MLX5_OPCODE_ACCESS_ASO | + (ASO_OPC_MOD_POLICER <<WQE_CSEG_OPC_MOD_OFFSET ) | + sq->pi <<WQE_CSEG_WQE_INDEX_OFFSET );/* There are 2 meters in one ASO cache line. */ dseg_idx = aso_mtr->offset &0x1 ; wqe->aso_cseg.data_mask =
@@ -811,14 +818,15 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)*/ int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh, -struct mlx5_aso_mtr *mtr) +struct mlx5_aso_mtr *mtr, +struct mlx5_mtr_bulk *bulk) {struct mlx5_aso_sq *sq = &sh->mtrmng->pools_mng.sq;uint32_t poll_wqe_times =MLX5_MTR_POLL_WQE_CQE_TIMES ; do { mlx5_aso_mtr_completion_handle(sq); - if (mlx5_aso_mtr_sq_enqueue_single(sh, sq, mtr)) + if (mlx5_aso_mtr_sq_enqueue_single(sh, sq, mtr, bulk)) return 0; /* Waiting for wqe resource. */ rte_delay_us_sleep(MLX5_ASO_WQE_CQE_RESPONSE_DELAY);
drivers/net/mlx5/mlx5_flow_dv.c +0 -25
@@ -216,31 +216,6 @@ flow_dv_attr_init(const struct rte_flow_item *item, union flow_dv_attr *attr, attr->valid =1 ; } -/* -* Convert rte_mtr_color to mlx5 color. -* -* @param[in] rcol -* rte_mtr_color. -* -* @return -* mlx5 color. -*/ -static inline int -rte_col_2_mlx5_col (enum rte_color rcol) -{ -switch (rcol) { -case RTE_COLOR_GREEN : -return MLX5_FLOW_COLOR_GREEN ; -case RTE_COLOR_YELLOW : -return MLX5_FLOW_COLOR_YELLOW ; -case RTE_COLOR_RED : -return MLX5_FLOW_COLOR_RED ; -default : -break ; - } -return MLX5_FLOW_COLOR_UNDEFINED ; -} -struct field_modify_info modify_eth[] = { {4 ,0 ,MLX5_MODI_OUT_DMAC_47_16 }, {2 ,4 ,MLX5_MODI_OUT_DMAC_15_0 },
drivers/net/mlx5/mlx5_flow_hw.c +256 -8
353 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +688 -14
807 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 8/17 net/mlx5: add HW steering counter action
In reply to Suanming MouFrom: Xiaoyu Min <[email protected]>
This commit adds HW steering counter action support.
Pool mechanism is the basic data structure for the HW steering counter.
The HW steering's counter pool is based on the rte_ring of zero-copy variation.
There are two global rte_rings:
1. free_list:
Store the counters indexes, which are ready for use.
2. wait_reset_list:
Store the counters indexes, which are just freed from the user and need to query the hardware counter to get the reset value before this counter can be reused again.
The counter pool also supports cache per HW steering's queues, which are also based on rte_ring of zero-copy variation.
The cache can be configured in size, preload, threshold, and fetch size, they are all exposed via device args.
The main operations of the counter pool are as follows:
- Get one counter from the pool:
1. The user call _get_* API.
2. If the cache is enabled, dequeue one counter index from the local cache:
2.A: if the dequeued one from the local cache is still in reset
status (counter's query_gen_when_free is equal to pool's query gen):
I. Flush all counters in local cache back to global
wait_reset_list.
II. Fetch _fetch_sz_ counters into the cache from the global
free list.
III. Fetch one counter from the cache.
3. If the cache is empty, fetch _fetch_sz_ counters from the global free list into the cache and fetch one counter from the cache.
- Free one counter into the pool:
1. The user calls _put_* API.
2. Put the counter into the local cache.
3. If the local cache is full:
3.A: Write back all counters above _threshold_ into the global
wait_reset_list.
3.B: Also, write back this counter into the global wait_reset_list.
When the local cache is disabled, _get_/_put_ cache directly from/into global list.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 50 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 27 ++ drivers/common/mlx5/mlx5_prm.h | 62 ++- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 14 + drivers/net/mlx5/mlx5.h | 27 ++ drivers/net/mlx5/mlx5_defs.h | 2 + drivers/net/mlx5/mlx5_flow.c | 27 +- drivers/net/mlx5/mlx5_flow.h | 5 + drivers/net/mlx5/mlx5_flow_aso.c | 261 ++++++++++++- drivers/net/mlx5/mlx5_flow_hw.c | 340 +++++++++++++++- drivers/net/mlx5/mlx5_hws_cnt.c | 528 +++++++++++++++++++++++++ drivers/net/mlx5/mlx5_hws_cnt.h | 558 +++++++++++++++++++++++++++ 14 files changed, 1871 insertions(+), 32 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.c create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.h
drivers/common/mlx5/mlx5_devx_cmds.c +50 -0
@@ -176,6 +176,41 @@ mlx5_devx_cmd_register_write(void *ctx, uint16_t reg_id, uint32_t arg,return 0 ; } +struct mlx5_devx_obj * +mlx5_devx_cmd_flow_counter_alloc_general (void *ctx, +struct mlx5_devx_counter_attr *attr) +{ +struct mlx5_devx_obj *dcs =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*dcs), +0 ,SOCKET_ID_ANY ); +uint32_t in[MLX5_ST_SZ_DW (alloc_flow_counter_in)] = {0 }; +uint32_t out[MLX5_ST_SZ_DW (alloc_flow_counter_out)] = {0 }; + +if (!dcs) { + rte_errno =ENOMEM ; +return NULL ; + } +MLX5_SET (alloc_flow_counter_in, in, opcode, +MLX5_CMD_OP_ALLOC_FLOW_COUNTER ); +if (attr->bulk_log_max_alloc) +MLX5_SET (alloc_flow_counter_in, in, flow_counter_bulk_log_size, + attr->flow_counter_bulk_log_size); +else +MLX5_SET (alloc_flow_counter_in, in, flow_counter_bulk, + attr->bulk_n_128); +if (attr->pd_valid) +MLX5_SET (alloc_flow_counter_in, in, pd, attr->pd); + dcs->obj = mlx5_glue->devx_obj_create (ctx, in, +sizeof (in), out,sizeof (out)); +if (!dcs->obj) { +DRV_LOG (ERR ,"Can't allocate counters - error %d" , errno); + rte_errno = errno; +mlx5_free (dcs); +return NULL ; + } + dcs->id =MLX5_GET (alloc_flow_counter_out, out, flow_counter_id); +return dcs; +} +/** * Allocate flow counters via devx interface. *
@@ -967,6 +1002,16 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, general_obj_types) & MLX5_GENERAL_OBJ_TYPES_CAP_CONN_TRACK_OFFLOAD); attr->rq_delay_drop =MLX5_GET (cmd_hca_cap, hcattr, rq_delay_drop); + attr->max_flow_counter_15_0 =MLX5_GET (cmd_hca_cap, hcattr, + max_flow_counter_15_0); + attr->max_flow_counter_31_16 =MLX5_GET (cmd_hca_cap, hcattr, + max_flow_counter_31_16); + attr->alloc_flow_counter_pd =MLX5_GET (cmd_hca_cap, hcattr, + alloc_flow_counter_pd); + attr->flow_counter_access_aso =MLX5_GET (cmd_hca_cap, hcattr, + flow_counter_access_aso); + attr->flow_access_aso_opc_mod =MLX5_GET (cmd_hca_cap, hcattr, + flow_access_aso_opc_mod);if (attr->crypto) { attr->aes_xts =MLX5_GET (cmd_hca_cap, hcattr, aes_xts); hcattr = mlx5_devx_get_hca_cap(ctx, in, out, &rc,
@@ -989,6 +1034,11 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, } attr->log_min_stride_wqe_sz =MLX5_GET (cmd_hca_cap_2, hcattr, log_min_stride_wqe_sz); + attr->flow_counter_bulk_log_max_alloc =MLX5_GET (cmd_hca_cap_2, + hcattr, flow_counter_bulk_log_max_alloc); + attr->flow_counter_bulk_log_granularity = +MLX5_GET (cmd_hca_cap_2, hcattr, + flow_counter_bulk_log_granularity); }if (attr->log_min_stride_wqe_sz ==0 ) attr->log_min_stride_wqe_sz =MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE ;
drivers/common/mlx5/mlx5_devx_cmds.h +27 -0
@@ -15,6 +15,16 @@#define MLX5_DEVX_MAX_KLM_ENTRIES ((UINT16_MAX - \ MLX5_ST_SZ_DW(create_mkey_in) * 4) / (MLX5_ST_SZ_DW(klm) * 4)) +struct mlx5_devx_counter_attr { +uint32_t pd_valid:1 ; +uint32_t pd:24 ; +uint32_t bulk_log_max_alloc:1 ; +union { +uint8_t flow_counter_bulk_log_size; +uint8_t bulk_n_128; + }; +}; +struct mlx5_devx_mkey_attr {uint64_t addr;uint64_t size;
@@ -263,6 +273,18 @@ struct mlx5_hca_attr { uint32_t set_reg_c:8; uint32_t nic_flow_table:1; uint32_t modify_outer_ip_ecn:1; +union { +uint32_t max_flow_counter; +struct { +uint16_t max_flow_counter_15_0; +uint16_t max_flow_counter_31_16; + }; + }; + uint32_t flow_counter_bulk_log_max_alloc:5; + uint32_t flow_counter_bulk_log_granularity:5; + uint32_t alloc_flow_counter_pd:1; + uint32_t flow_counter_access_aso:1; + uint32_t flow_access_aso_opc_mod:8; };/* LAG Context. */
@@ -593,6 +615,11 @@ struct mlx5_devx_crypto_login_attr {/* mlx5_devx_cmds.c */ +__rte_internal +struct mlx5_devx_obj * +mlx5_devx_cmd_flow_counter_alloc_general (void *ctx, +struct mlx5_devx_counter_attr *attr); +__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_flow_counter_alloc(void *ctx,uint32_t bulk_sz);
drivers/common/mlx5/mlx5_prm.h +57 -5
80 lines not on this page · raw message
drivers/common/mlx5/version.map +1 -0
@@ -40,6 +40,7 @@ INTERNAL { mlx5_devx_cmd_create_virtq; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc; + mlx5_devx_cmd_flow_counter_alloc_general; mlx5_devx_cmd_flow_counter_query; mlx5_devx_cmd_flow_dump; mlx5_devx_cmd_flow_single_dump;
drivers/net/mlx5/meson.build +1 -0
@@ -38,6 +38,7 @@ sources = files( 'mlx5_vlan.c', 'mlx5_utils.c', 'mlx5_devx.c', + 'mlx5_hws_cnt.c', ) if is_linux
drivers/net/mlx5/mlx5.c +14 -0
@@ -175,6 +175,12 @@/* Device parameter to create the fdb default rule in PMD */ #define MLX5_FDB_DEFAULT_RULE_EN "fdb_def_rule_en" +/* HW steering counter configuration. */ +#define MLX5_HWS_CNT_SERVICE_CORE "service_core" + +/* HW steering counter's query interval. */ +#define MLX5_HWS_CNT_CYCLE_TIME "svc_cycle_time" +/* Shared memory between primary and secondary processes. */ struct mlx5_shared_data *mlx5_shared_data;
@@ -1245,6 +1251,10 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque) config->allow_duplicate_pattern = !!tmp; }else if (strcmp (MLX5_FDB_DEFAULT_RULE_EN , key) ==0 ) { config->fdb_def_rule = !!tmp; + }else if (strcmp (MLX5_HWS_CNT_SERVICE_CORE , key) ==0 ) { + config->cnt_svc.service_core = tmp; + }else if (strcmp (MLX5_HWS_CNT_CYCLE_TIME , key) ==0 ) { + config->cnt_svc.cycle_time = tmp; }return 0 ; }
@@ -1281,6 +1291,8 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,MLX5_DECAP_EN ,MLX5_ALLOW_DUPLICATE_PATTERN ,MLX5_FDB_DEFAULT_RULE_EN , +MLX5_HWS_CNT_SERVICE_CORE , +MLX5_HWS_CNT_CYCLE_TIME , NULL, };int ret =0 ;
@@ -1293,6 +1305,8 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->decap_en =1 ; config->allow_duplicate_pattern =1 ; config->fdb_def_rule =1 ; + config->cnt_svc.cycle_time =MLX5_CNT_SVC_CYCLE_TIME_DEFAULT ; + config->cnt_svc.service_core =rte_get_main_lcore ();if (mkvlist !=NULL ) {/* Process parameters. */ ret = mlx5_kvargs_process(mkvlist, params,
drivers/net/mlx5/mlx5.h +27 -0
@@ -308,6 +308,10 @@ struct mlx5_sh_config { uint32_t hw_fcs_strip:1; /* FCS stripping is supported. */ uint32_t allow_duplicate_pattern:1; uint32_t lro_allowed:1; /* Whether LRO is allowed. */ +struct { +uint16_t service_core; +uint32_t cycle_time;/* query cycle time in milli-second. */ + } cnt_svc;/* configure for HW steering's counter's service. */ /* Allow/Prevent the duplicate rules pattern. */ uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ };
@@ -1224,6 +1228,22 @@ struct mlx5_flex_item {struct mlx5_flex_pattern_field map[MLX5_FLEX_ITEM_MAPPING_NUM ]; }; +#define HWS_CNT_ASO_SQ_NUM 4 + +struct mlx5_hws_aso_mng { +uint16_t sq_num; +struct mlx5_aso_sq sqs[HWS_CNT_ASO_SQ_NUM ]; +}; + +struct mlx5_hws_cnt_svc_mng { +uint32_t refcnt; +uint32_t service_core; +uint32_t query_interval; +pthread_t service_thread; +uint8_t svc_running; + struct mlx5_hws_aso_mng aso_mng __rte_cache_aligned; +}; +/* * Shared Infiniband device context for Master/Representors * which belong to same IB device with multiple IB ports.
@@ -1323,6 +1343,7 @@ struct mlx5_dev_ctx_shared {pthread_mutex_t lwm_config_lock; uint32_t host_shaper_rate:8; uint32_t lwm_triggered:1; +struct mlx5_hws_cnt_svc_mng *cnt_svc;struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1607,6 +1628,7 @@ struct mlx5_priv {/* Flex items have been created on the port. */ uint32_t flex_item_map;/* Map of allocated flex item elements. */ uint32_t nb_queue;/* HW steering queue number. */ +struct mlx5_hws_cnt_pool *hws_cpool;/* HW steering's counter pool. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )/* Item template list. */ LIST_HEAD(flow_hw_itt, rte_flow_pattern_template) flow_hw_itt;
@@ -2037,6 +2059,11 @@ mlx5_get_supported_sw_parsing_offloads(const struct mlx5_hca_attr *attr);uint32_t mlx5_get_supported_tunneling_offloads (const struct mlx5_hca_attr *attr); +int mlx5_aso_cnt_queue_init (struct mlx5_dev_ctx_shared *sh); +void mlx5_aso_cnt_queue_uninit (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_cnt_query (struct mlx5_dev_ctx_shared *sh, +struct mlx5_hws_cnt_pool *cpool); +/* mlx5_flow_flex.c */ struct rte_flow_item_flex_handle *
drivers/net/mlx5/mlx5_defs.h +2 -0
@@ -188,4 +188,6 @@#define static_assert _Static_assert#endif +#define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#endif /* RTE_PMD_MLX5_DEFS_H_ */
drivers/net/mlx5/mlx5_flow.c +15 -12
@@ -7832,24 +7832,33 @@ mlx5_flow_isolate(struct rte_eth_dev *dev,*/ static int flow_drv_query (struct rte_eth_dev *dev, -uint32_t flow_idx, +struct rte_flow *eflow,const struct rte_flow_action *actions,void *data,struct rte_flow_error *error) {struct mlx5_priv *priv = dev->data->dev_private;const struct mlx5_flow_driver_ops *fops; -struct rte_flow *flow =mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], - flow_idx); -enum mlx5_flow_drv_type ftype; +struct rte_flow *flow =NULL ; +enum mlx5_flow_drv_type ftype =MLX5_FLOW_TYPE_MIN ; +if (priv->sh->config.dv_flow_en ==2 ) { +#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H ) + flow = eflow; + ftype =MLX5_FLOW_TYPE_HW ; +#endif + }else { + flow = (struct rte_flow *)mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], + (uintptr_t )(void *)eflow); + }if (!flow) {return rte_flow_error_set (error,ENOENT ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL ,"invalid flow handle" ); } - ftype = flow->drv_type; +if (ftype ==MLX5_FLOW_TYPE_MIN ) + ftype = flow->drv_type;MLX5_ASSERT (ftype >MLX5_FLOW_TYPE_MIN && ftype <MLX5_FLOW_TYPE_MAX ); fops =flow_get_drv_ops (ftype);
@@ -7870,14 +7879,8 @@ mlx5_flow_query(struct rte_eth_dev *dev, struct rte_flow_error *error) {int ret; -struct mlx5_priv *priv = dev->data->dev_private; -if (priv->sh->config.dv_flow_en ==2 ) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"Flow non-Q query not supported" ); - ret =flow_drv_query (dev, (uintptr_t )(void *)flow, actions, data, + ret =flow_drv_query (dev, flow, actions, data, error);if (ret <0 )return ret;
drivers/net/mlx5/mlx5_flow.h +5 -0
@@ -1103,6 +1103,7 @@ struct rte_flow_hw { };struct rte_flow_template_table *table;/* The table flow allcated from. */ struct mlx5dr_rule rule;/* HWS layer data struct. */ +uint32_t cnt_id; } __rte_packed;/* rte flow action translate to DR action struct. */
@@ -1146,6 +1147,9 @@ struct mlx5_action_construct_data {uint32_t level;/* RSS level. */ uint32_t idx;/* Shared action index. */ } shared_rss; +struct { +uint32_t id; + } shared_counter; }; };
@@ -1224,6 +1228,7 @@ struct mlx5_hw_actions {uint16_t encap_decap_pos;/* Encap/Decap action position. */ uint32_t acts_num:4; /* Total action number. */ uint32_t mark:1; /* Indicate the mark action. */ +uint32_t cnt_id;/* Counter id. */ /* Translated DR action array from action template. */ struct mlx5dr_rule_action rule_acts[MLX5_HW_MAX_ACTS ]; };
drivers/net/mlx5/mlx5_flow_aso.c +254 -7
309 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +332 -8
460 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.c new file +528 -0
528 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h new file +558 -0
558 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 9/17 net/mlx5: support DR action template API
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch adapts mlx5 PMD to changes in mlx5dr API regarding action templates. It changes the following:
1. Actions template creation:
- Flow actions types are translated to mlx5dr action types in order to create mlx5dr_action_template object.
- An offset is assigned to each flow action. This offset is used to predetermine action's location in rule_acts array passed on rule creation.
2. Template table creation:
- Fixed actions are created and put in rule_acts cache using predetermined offsets
- mlx5dr matcher is parametrized by action templates bound to template table.
- mlx5dr matcher is configured to optimize rule creation based on passed rule indices.
3. Flow rule creation:
- mlx5dr rule is parametrized by action template on which these rule's actions are based.
- Rule index hint is provided to mlx5dr.
--- drivers/net/mlx5/linux/mlx5_os.c | 1 + drivers/net/mlx5/mlx5.c | 4 +- drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow.h | 30 +- drivers/net/mlx5/mlx5_flow_hw.c | 598 +++++++++++++++++++++++++------ drivers/net/mlx5/mlx5_trigger.c | 10 + 6 files changed, 523 insertions(+), 122 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +1 -0
@@ -1565,6 +1565,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, }/* Only HWS requires this information. */ flow_hw_init_tags_set (eth_dev); +flow_hw_init_flow_metadata_config (eth_dev);if (priv->sh->config.dv_esw_en &&flow_hw_create_vport_action (eth_dev)) { DRV_LOG(ERR, "port %u failed to create vport action",
drivers/net/mlx5/mlx5.c +3 -1
@@ -1969,8 +1969,10 @@ mlx5_dev_close(struct rte_eth_dev *dev)flow_hw_destroy_vport_action (dev);flow_hw_resource_release (dev);flow_hw_clear_port_info (dev); -if (priv->sh->config.dv_flow_en ==2 ) +if (priv->sh->config.dv_flow_en ==2 ) { +flow_hw_clear_flow_metadata_config ();flow_hw_clear_tags_set (dev); + }#endif if (priv->rxq_privs !=NULL ) {/* XXX race condition if mlx5_rx_burst() is still running. */
drivers/net/mlx5/mlx5.h +2 -0
@@ -1644,6 +1644,8 @@ struct mlx5_priv {struct mlx5dr_action *hw_drop[2 ];/* HW steering global tag action. */ struct mlx5dr_action *hw_tag[2 ]; +/* HW steering create ongoing rte flow table list header. */ + LIST_HEAD(flow_hw_tbl_ongo, rte_flow_template_table) flow_hw_tbl_ongo;struct mlx5_indexed_pool *acts_ipool;/* Action data indexed pool. */ #endif };
drivers/net/mlx5/mlx5_flow.h +28 -2
@@ -1175,6 +1175,11 @@ struct rte_flow_actions_template {struct rte_flow_actions_template_attr attr;struct rte_flow_action *actions;/* Cached flow actions. */ struct rte_flow_action *masks;/* Cached action masks.*/ +struct mlx5dr_action_template *tmpl;/* mlx5dr action template. */ +uint16_t dr_actions_num;/* Amount of DR rules actions. */ +uint16_t actions_num;/* Amount of flow actions */ +uint16_t *actions_off;/* DR action offset for given rte action offset. */ +uint16_t reformat_off;/* Offset of DR reformat action. */ uint16_t mhdr_off;/* Offset of DR modify header action. */ uint32_t refcnt;/* Reference counter. */ uint16_t rx_cpy_pos;/* Action position of Rx metadata to be copied. */
@@ -1226,7 +1231,6 @@ struct mlx5_hw_actions {/* Encap/Decap action. */ struct mlx5_hw_encap_decap_action *encap_decap;uint16_t encap_decap_pos;/* Encap/Decap action position. */ - uint32_t acts_num:4; /* Total action number. */ uint32_t mark:1; /* Indicate the mark action. */uint32_t cnt_id;/* Counter id. */ /* Translated DR action array from action template. */
@@ -1482,6 +1486,13 @@ flow_hw_get_wire_port(struct ibv_context *ibctx) }#endif +extern uint32_t mlx5_flow_hw_flow_metadata_config_refcnt; +extern uint8_t mlx5_flow_hw_flow_metadata_esw_en; +extern uint8_t mlx5_flow_hw_flow_metadata_xmeta_en; + +void flow_hw_init_flow_metadata_config (struct rte_eth_dev *dev); +void flow_hw_clear_flow_metadata_config (void ); +/* * Convert metadata or tag to the actual register. * META: Can only be used to match in the FDB in this stage, fixed C_1.
@@ -1493,7 +1504,20 @@ flow_hw_get_reg_id(enum rte_flow_item_type type, uint32_t id) {switch (type) {case RTE_FLOW_ITEM_TYPE_META : -return REG_C_1 ; +if (mlx5_flow_hw_flow_metadata_esw_en && + mlx5_flow_hw_flow_metadata_xmeta_en ==MLX5_XMETA_MODE_META32_HWS ) { +return REG_C_1 ; + } +/* +* On root table - PMD allows only egress META matching, thus +* REG_A matching is sufficient. +* +* On non-root tables - REG_A corresponds to general_purpose_lookup_field, +* which translates to REG_A in NIC TX and to REG_B in NIC RX. +* However, current FW does not implement REG_B case right now, so +* REG_B case should be rejected on pattern template validation. +*/ +return REG_A ;case RTE_FLOW_ITEM_TYPE_TAG :MLX5_ASSERT (id <MLX5_FLOW_HW_TAGS_MAX );return mlx5_flow_hw_avl_tags[id];
@@ -2402,4 +2426,6 @@ int mlx5_flow_pattern_validate(struct rte_eth_dev *dev,const struct rte_flow_pattern_template_attr *attr, const struct rte_flow_item items[], struct rte_flow_error *error); +int flow_hw_table_update (struct rte_eth_dev *dev, +struct rte_flow_error *error);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_hw.c +479 -119
1,038 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +10 -0
@@ -1170,6 +1170,16 @@ mlx5_dev_start(struct rte_eth_dev *dev) dev->data->port_id, rte_strerror(rte_errno)); goto error; } +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) { + ret =flow_hw_table_update (dev,NULL ); +if (ret) { +DRV_LOG (ERR ,"port %u failed to update HWS tables" , + dev->data->port_id); + goto error; + } + } +#endif ret =mlx5_traffic_enable (dev);if (ret) { DRV_LOG(ERR, "port %u failed to set defaults flows",
Signature · 1 line
2.25.1
PATCH v2 10/17 net/mlx5: add HW steering connection tracking support
In reply to Suanming MouThis commit adds the support of connection tracking to HW steering as SW steering did before.
Different with SW steering implementation, take advantage of HW steering bulk action allocation support, in HW steering only one single CT pool is needed.
An indexed pool is introduced to record allocated actions from bulk and CT action state etc. Once one CT action is allocated from bulk, one indexed object will also be allocated from the indexed pool, similar for deallocate. That makes mlx5_aso_ct_action can also be managed by that indexed pool, no need to be reserved from mlx5_aso_ct_pool. The single CT pool is also saved to mlx5_aso_ct_action struct directly.
The ASO operation functions are shared with SW steering implementation.
--- drivers/net/mlx5/linux/mlx5_os.c | 8 +- drivers/net/mlx5/mlx5.c | 3 +- drivers/net/mlx5/mlx5.h | 54 ++++- drivers/net/mlx5/mlx5_flow.c | 1 + drivers/net/mlx5/mlx5_flow.h | 7 + drivers/net/mlx5/mlx5_flow_aso.c | 212 +++++++++++++---- drivers/net/mlx5/mlx5_flow_dv.c | 28 ++- drivers/net/mlx5/mlx5_flow_hw.c | 381 ++++++++++++++++++++++++++++++- 8 files changed, 617 insertions(+), 77 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +5 -3
@@ -1349,9 +1349,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,DRV_LOG (DEBUG ,"Flow Hit ASO is supported." ); }#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ -#if defined(HAVE_MLX5_DR_CREATE_ACTION_ASO ) && \ - defined(HAVE_MLX5_DR_ACTION_ASO_CT ) -if (hca_attr->ct_offload && priv->mtr_color_reg ==REG_C_3 ) { +#if defined (HAVE_MLX5_DR_CREATE_ACTION_ASO ) && \ + defined (HAVE_MLX5_DR_ACTION_ASO_CT ) +/* HWS create CT ASO SQ based on HWS configure queue number. */ +if (sh->config.dv_flow_en !=2 && + hca_attr->ct_offload && priv->mtr_color_reg ==REG_C_3 ) { err =mlx5_flow_aso_ct_mng_init (sh);if (err) { err = -err;
drivers/net/mlx5/mlx5.c +2 -1
@@ -755,7 +755,8 @@ mlx5_flow_aso_ct_mng_init(struct mlx5_dev_ctx_shared *sh)if (sh->ct_mng)return 0 ; - sh->ct_mng =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*sh->ct_mng), + sh->ct_mng =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*sh->ct_mng) + +sizeof (struct mlx5_aso_sq ) *MLX5_ASO_CT_SQ_NUM ,RTE_CACHE_LINE_SIZE ,SOCKET_ID_ANY );if (!sh->ct_mng) {DRV_LOG (ERR ,"ASO CT management allocation failed." );
drivers/net/mlx5/mlx5.h +44 -10
120 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.c +1 -0
@@ -49,6 +49,7 @@ struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS];*/ uint32_t mlx5_flow_hw_avl_tags_init_cnt;enum modify_reg mlx5_flow_hw_avl_tags[MLX5_FLOW_HW_TAGS_MAX ] = {REG_NON }; +enum modify_reg mlx5_flow_hw_aso_tag;struct tunnel_default_miss_ctx {uint16_t *queue;
drivers/net/mlx5/mlx5_flow.h +7 -0
@@ -82,6 +82,10 @@ enum {#define MLX5_INDIRECT_ACT_CT_GET_IDX (index) \ ((index) & ((1 << MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) - 1)) +#define MLX5_ACTION_CTX_CT_GET_IDX MLX5_INDIRECT_ACT_CT_GET_IDX +#define MLX5_ACTION_CTX_CT_GET_OWNER MLX5_INDIRECT_ACT_CT_GET_OWNER +#define MLX5_ACTION_CTX_CT_GEN_IDX MLX5_INDIRECT_ACT_CT_GEN_IDX +/* Matches on selected register. */ struct mlx5_rte_flow_item_tag {enum modify_reg id;
@@ -1444,6 +1448,7 @@ extern struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS];#define MLX5_FLOW_HW_TAGS_MAX 8extern uint32_t mlx5_flow_hw_avl_tags_init_cnt;extern enum modify_reg mlx5_flow_hw_avl_tags[]; +extern enum modify_reg mlx5_flow_hw_aso_tag;/* * Get metadata match tag and mask for given rte_eth_dev port.
@@ -1518,6 +1523,8 @@ flow_hw_get_reg_id(enum rte_flow_item_type type, uint32_t id)* REG_B case should be rejected on pattern template validation. */ return REG_A ; +case RTE_FLOW_ITEM_TYPE_CONNTRACK : +return mlx5_flow_hw_aso_tag;case RTE_FLOW_ITEM_TYPE_TAG :MLX5_ASSERT (id <MLX5_FLOW_HW_TAGS_MAX );return mlx5_flow_hw_avl_tags[id];
drivers/net/mlx5/mlx5_flow_aso.c +162 -50
415 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +18 -10
@@ -12801,6 +12801,7 @@ flow_dv_ct_pool_create(struct rte_eth_dev *dev,struct mlx5_devx_obj *obj =NULL ;uint32_t i;uint32_t log_obj_size =rte_log2_u32 (MLX5_ASO_CT_ACTIONS_PER_POOL ); +size_t mem_size; obj = mlx5_devx_cmd_create_conn_track_offload_obj(priv->sh->cdev->ctx, priv->sh->cdev->pdn,
@@ -12810,7 +12811,10 @@ flow_dv_ct_pool_create(struct rte_eth_dev *dev,DRV_LOG (ERR ,"Failed to create conn_track_offload_obj using DevX." );return NULL ; } - pool =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*pool),0 ,SOCKET_ID_ANY ); + mem_size =sizeof (struct mlx5_aso_ct_action ) * +MLX5_ASO_CT_ACTIONS_PER_POOL + +sizeof (*pool); + pool =mlx5_malloc (MLX5_MEM_ZERO , mem_size,0 ,SOCKET_ID_ANY );if (!pool) { rte_errno =ENOMEM ;claim_zero (mlx5_devx_cmd_destroy (obj));
@@ -12950,10 +12954,13 @@ flow_dv_translate_create_conntrack(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Failed to allocate CT object"); ct =flow_aso_ct_get_by_dev_idx (dev, idx); -if (mlx5_aso_ct_update_by_wqe (sh, ct, pro)) -return rte_flow_error_set (error,EBUSY , -RTE_FLOW_ERROR_TYPE_ACTION ,NULL , -"Failed to update CT" ); +if (mlx5_aso_ct_update_by_wqe (sh,MLX5_HW_INV_QUEUE , ct, pro)) { +flow_dv_aso_ct_dev_release (dev, idx); +rte_flow_error_set (error,EBUSY , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Failed to update CT" ); +return 0 ; + } ct->is_original = !!pro->is_original_dir; ct->peer = pro->peer_port;return idx;
@@ -14147,7 +14154,7 @@ flow_dv_translate(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Failed to get CT object."); -if (mlx5_aso_ct_available (priv->sh, ct)) +if (mlx5_aso_ct_available (priv->sh,MLX5_HW_INV_QUEUE , ct)) return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -15755,14 +15762,15 @@ __flow_dv_action_ct_update(struct rte_eth_dev *dev, uint32_t idx, ret =mlx5_validate_action_ct (dev, new_prf, error);if (ret)return ret; - ret =mlx5_aso_ct_update_by_wqe (priv->sh, ct, new_prf); + ret =mlx5_aso_ct_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , + ct, new_prf);if (ret)return rte_flow_error_set (error,EIO ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL ,"Failed to send CT context update WQE" ); -/* Block until ready or a failure. */ - ret =mlx5_aso_ct_available (priv->sh, ct); +/* Block until ready or a failure, default is asynchronous. */ + ret =mlx5_aso_ct_available (priv->sh,MLX5_HW_INV_QUEUE , ct);if (ret) rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -16591,7 +16599,7 @@ flow_dv_action_query(struct rte_eth_dev *dev, ct->peer; ((struct rte_flow_action_conntrack *)data)->is_original_dir = ct->is_original; -if (mlx5_aso_ct_query_by_wqe (priv->sh, ct, data)) +if (mlx5_aso_ct_query_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , ct, data)) return rte_flow_error_set(error, EIO, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
drivers/net/mlx5/mlx5_flow_hw.c +378 -3
546 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 11/17 net/mlx5: add HW steering VLAN push, pop and VID modify flow actions
In reply to Suanming MouFrom: Gregory Etelson <[email protected]>
Add PMD implementation for HW steering VLAN push, pop and modify flow actions.
HWS VLAN push flow action is triggered by a sequence of mandatory OF_PUSH_VLAN, OF_SET_VLAN_VID and optional OF_SET_VLAN_PCP flow actions commands.
The commands must be arranged in the exact order:OF_PUSH_VLAN / OF_SET_VLAN_VID [ / OF_SET_VLAN_PCP ].
In masked HWS VLAN push flow action template *ALL* the above flow actions must be masked.
In non-masked HWS VLAN push flow action template *ALL* the above flow actions must not be masked.
Example:
flow actions_template <port id> create \actions_template_id <action id> \
template \
of_push_vlan / \
of_set_vlan_vid \
[ / of_set_vlan_pcp ] / end \
mask \
of_push_vlan ethertype 0 / \
of_set_vlan_vid vlan_vid 0 \
[ / of_set_vlan_pcp vlan_pcp 0 ] / end\
flow actions_template <port id> create \actions_template_id <action id> \
template \
of_push_vlan ethertype <E>/ \
of_set_vlan_vid vlan_vid <VID>\
[ / of_set_vlan_pcp <PCP>] / end \
mask \
of_push_vlan ethertype <type != 0> / \
of_set_vlan_vid vlan_vid <vid_mask != 0>\
[ / of_set_vlan_pcp vlan_pcp <pcp_mask != 0> ] / end\
HWS VLAN pop flow action is triggered by OF_POP_VLAN flow action command.
HWS VLAN pop action template is always non-masked.
Example:
flow actions_template <port id> create \actions_template_id <action id> \
template of_pop_vlan / end mask of_pop_vlan / end
HWS VLAN VID modify flow action is triggered by a standalone OF_SET_VLAN_VID flow action command.
HWS VLAN VID modify action template can be ether masked or non-masked.
Example:
flow actions_template <port id> create \actions_template_id <action id> \
template of_set_vlan_vid / end mask of_set_vlan_vid vlan_vid 0 / end
flow actions_template <port id> create \actions_template_id <action id> \
template of_set_vlan_vid vlan_vid 0x101 / end \
mask of_set_vlan_vid vlan_vid 0xffff / end
--- drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow.h | 4 + drivers/net/mlx5/mlx5_flow_dv.c | 2 +- drivers/net/mlx5/mlx5_flow_hw.c | 492 +++++++++++++++++++++++++++++--- 4 files changed, 463 insertions(+), 37 deletions(-)
drivers/net/mlx5/mlx5.h +2 -0
@@ -1665,6 +1665,8 @@ struct mlx5_priv {struct mlx5_hw_q *hw_q;/* HW steering rte flow table list header. */ LIST_HEAD(flow_hw_tbl, rte_flow_template_table) flow_hw_tbl; +struct mlx5dr_action *hw_push_vlan[MLX5DR_TABLE_TYPE_MAX ]; +struct mlx5dr_action *hw_pop_vlan[MLX5DR_TABLE_TYPE_MAX ];struct mlx5dr_action **hw_vport;/* HW steering global drop action. */ struct mlx5dr_action *hw_drop[2 ];
drivers/net/mlx5/mlx5_flow.h +4 -0
@@ -2435,4 +2435,8 @@ int mlx5_flow_pattern_validate(struct rte_eth_dev *dev, struct rte_flow_error *error);int flow_hw_table_update (struct rte_eth_dev *dev,struct rte_flow_error *error); +int mlx5_flow_item_field_width (struct rte_eth_dev *dev, +enum rte_flow_field_id field,int inherit, +const struct rte_flow_attr *attr, +struct rte_flow_error *error);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -1326,7 +1326,7 @@ flow_dv_convert_action_modify_ipv6_dscp MLX5_MODIFICATION_TYPE_SET, error); } -static int +int mlx5_flow_item_field_width(struct rte_eth_dev *dev, enum rte_flow_field_id field, int inherit, const struct rte_flow_attr *attr,
drivers/net/mlx5/mlx5_flow_hw.c +456 -36
647 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 12/17 net/mlx5: implement METER MARK indirect action for HWS
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
Add ability to create an indirect action handle for METER_MARK. It allows to share one Meter between several different actions.
--- drivers/net/mlx5/mlx5.c | 4 +- drivers/net/mlx5/mlx5.h | 33 ++- drivers/net/mlx5/mlx5_flow.c | 6 + drivers/net/mlx5/mlx5_flow.h | 19 +- drivers/net/mlx5/mlx5_flow_aso.c | 139 +++++++-- drivers/net/mlx5/mlx5_flow_dv.c | 145 +++++++++- drivers/net/mlx5/mlx5_flow_hw.c | 438 +++++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 79 +++++- 8 files changed, 764 insertions(+), 99 deletions(-)
drivers/net/mlx5/mlx5.c +2 -2
@@ -442,7 +442,7 @@ mlx5_flow_aso_age_mng_init(struct mlx5_dev_ctx_shared *sh) rte_errno =ENOMEM ;return -ENOMEM ; } - err =mlx5_aso_queue_init (sh,ASO_OPC_MOD_FLOW_HIT ); + err =mlx5_aso_queue_init (sh,ASO_OPC_MOD_FLOW_HIT ,1 );if (err) {mlx5_free (sh->aso_age_mng);return -1 ;
@@ -763,7 +763,7 @@ mlx5_flow_aso_ct_mng_init(struct mlx5_dev_ctx_shared *sh) rte_errno =ENOMEM ;return -rte_errno; } - err =mlx5_aso_queue_init (sh,ASO_OPC_MOD_CONNECTION_TRACKING ); + err =mlx5_aso_queue_init (sh,ASO_OPC_MOD_CONNECTION_TRACKING ,MLX5_ASO_CT_SQ_NUM );if (err) {mlx5_free (sh->ct_mng);/* rte_errno should be extracted from the failure. */
drivers/net/mlx5/mlx5.h +26 -7
@@ -971,12 +971,16 @@ enum mlx5_aso_mtr_type {/* Generic aso_flow_meter information. */ struct mlx5_aso_mtr { -LIST_ENTRY (mlx5_aso_mtr) next; +union { +LIST_ENTRY (mlx5_aso_mtr) next; +struct mlx5_aso_mtr_pool *pool; + };enum mlx5_aso_mtr_type type;struct mlx5_flow_meter_info fm;/**< Pointer to the next aso flow meter structure. */ uint8_t state;/**< ASO flow meter state. */ uint32_t offset; +enum rte_color init_color; };/* Generic aso_flow_meter pool structure. */
@@ -985,7 +989,11 @@ struct mlx5_aso_mtr_pool {/*Must be the first in pool*/ struct mlx5_devx_obj *devx_obj;/* The devx object of the minimum aso flow meter ID. */ +struct mlx5dr_action *action;/* HWS action. */ +struct mlx5_indexed_pool *idx_pool;/* HWS index pool. */ uint32_t index;/* Pool index in management structure. */ +uint32_t nb_sq;/* Number of ASO SQ. */ +struct mlx5_aso_sq *sq;/* ASO SQs. */ };LIST_HEAD (aso_meter_list, mlx5_aso_mtr);
@@ -1678,6 +1686,7 @@ struct mlx5_priv {struct mlx5_aso_ct_pools_mng *ct_mng;/* Management data for ASO connection tracking. */ struct mlx5_aso_ct_pool *hws_ctpool;/* HW steering's CT pool. */ +struct mlx5_aso_mtr_pool *hws_mpool;/* HW steering's Meter pool. */ #endif };
@@ -1998,7 +2007,8 @@ void mlx5_pmd_socket_uninit(void);int mlx5_flow_meter_init (struct rte_eth_dev *dev,uint32_t nb_meters,uint32_t nb_meter_profiles, -uint32_t nb_meter_policies); +uint32_t nb_meter_policies, +uint32_t nb_queues);void mlx5_flow_meter_uninit (struct rte_eth_dev *dev);int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg); struct mlx5_flow_meter_info *mlx5_flow_meter_find(struct mlx5_priv *priv,
@@ -2067,15 +2077,24 @@ eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);/* mlx5_flow_aso.c */ +int mlx5_aso_mtr_queue_init (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_mtr_pool *hws_pool, +struct mlx5_aso_mtr_pools_mng *pool_mng, +uint32_t nb_queues); +void mlx5_aso_mtr_queue_uninit (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_mtr_pool *hws_pool, +struct mlx5_aso_mtr_pools_mng *pool_mng);int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh, -enum mlx5_access_aso_opc_mod aso_opc_mod); +enum mlx5_access_aso_opc_mod aso_opc_mode, +uint32_t nb_queues);int mlx5_aso_flow_hit_queue_poll_start (struct mlx5_dev_ctx_shared *sh);int mlx5_aso_flow_hit_queue_poll_stop (struct mlx5_dev_ctx_shared *sh);void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh, -enum mlx5_access_aso_opc_mod aso_opc_mod); -int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh, -struct mlx5_aso_mtr *mtr,struct mlx5_mtr_bulk *bulk); -int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh, +enum mlx5_access_aso_opc_mod aso_opc_mod); +int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh,uint32_t queue, +struct mlx5_aso_mtr *mtr, +struct mlx5_mtr_bulk *bulk); +int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_mtr *mtr); int mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh, uint32_t queue, struct mlx5_aso_ct_action *ct,
drivers/net/mlx5/mlx5_flow.c +6 -0
@@ -4221,6 +4221,12 @@ flow_action_handles_translate(struct rte_eth_dev *dev,MLX5_RTE_FLOW_ACTION_TYPE_COUNT ; translated[handle->index].conf = (void *)(uintptr_t )idx;break ; +case MLX5_INDIRECT_ACTION_TYPE_METER_MARK : + translated[handle->index].type = + (enum rte_flow_action_type ) +MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK ; + translated[handle->index].conf = (void *)(uintptr_t )idx; +break ;case MLX5_INDIRECT_ACTION_TYPE_AGE :if (priv->sh->flow_hit_aso_en) { translated[handle->index].type =
drivers/net/mlx5/mlx5_flow.h +15 -4
@@ -46,6 +46,7 @@ enum mlx5_rte_flow_action_type {MLX5_RTE_FLOW_ACTION_TYPE_COUNT ,MLX5_RTE_FLOW_ACTION_TYPE_JUMP ,MLX5_RTE_FLOW_ACTION_TYPE_RSS , + MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK, };/* Private (internal) Field IDs for MODIFY_FIELD action. */
@@ -54,22 +55,23 @@ enum mlx5_rte_flow_field_id { MLX5_RTE_FLOW_FIELD_META_REG, }; -#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 30 +#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 29enum {MLX5_INDIRECT_ACTION_TYPE_RSS ,MLX5_INDIRECT_ACTION_TYPE_AGE ,MLX5_INDIRECT_ACTION_TYPE_COUNT ,MLX5_INDIRECT_ACTION_TYPE_CT , +MLX5_INDIRECT_ACTION_TYPE_METER_MARK , }; -/* Now, the maximal ports will be supported is 256, action number is 4M. */ -#define MLX5_INDIRECT_ACT_CT_MAX_PORT 0x100 +/* Now, the maximal ports will be supported is 16, action number is 32M. */ +#define MLX5_INDIRECT_ACT_CT_MAX_PORT 0x10#define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 22#define MLX5_INDIRECT_ACT_CT_OWNER_MASK (MLX5_INDIRECT_ACT_CT_MAX_PORT - 1) -/* 30-31: type, 22-29: owner port, 0-21: index. */ +/* 29-31: type, 25-28: owner port, 0-24: index */ #define MLX5_INDIRECT_ACT_CT_GEN_IDX (owner, index) \ ((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | \ (((owner) & MLX5_INDIRECT_ACT_CT_OWNER_MASK) << \
@@ -207,6 +209,9 @@ enum mlx5_feature_name {#define MLX5_FLOW_ITEM_PORT_REPRESENTOR (UINT64_C(1) << 41)#define MLX5_FLOW_ITEM_REPRESENTED_PORT (UINT64_C(1) << 42) +/* Meter color item */ +#define MLX5_FLOW_ITEM_METER_COLOR (UINT64_C(1) << 44) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
@@ -1108,6 +1113,7 @@ struct rte_flow_hw {struct rte_flow_template_table *table;/* The table flow allcated from. */ struct mlx5dr_rule rule;/* HWS layer data struct. */ uint32_t cnt_id; +uint32_t mtr_id; } __rte_packed;/* rte flow action translate to DR action struct. */
@@ -1154,6 +1160,9 @@ struct mlx5_action_construct_data {struct {uint32_t id; } shared_counter; +struct { +uint32_t id; + } shared_meter; }; };
@@ -1237,6 +1246,7 @@ struct mlx5_hw_actions {uint16_t encap_decap_pos;/* Encap/Decap action position. */ uint32_t mark:1; /* Indicate the mark action. */uint32_t cnt_id;/* Counter id. */ +uint32_t mtr_id;/* Meter id. */ /* Translated DR action array from action template. */ struct mlx5dr_rule_action rule_acts[MLX5_HW_MAX_ACTS ]; };
@@ -1524,6 +1534,7 @@ flow_hw_get_reg_id(enum rte_flow_item_type type, uint32_t id)*/ return REG_A ;case RTE_FLOW_ITEM_TYPE_CONNTRACK : +case RTE_FLOW_ITEM_TYPE_METER_COLOR :return mlx5_flow_hw_aso_tag;case RTE_FLOW_ITEM_TYPE_TAG :MLX5_ASSERT (id <MLX5_FLOW_HW_TAGS_MAX );
drivers/net/mlx5/mlx5_flow_aso.c +118 -21
241 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +143 -2
193 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +382 -56
715 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +72 -7
135 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 13/17 net/mlx5: add HWS AGE action support
In reply to Suanming MouFrom: Michael Baum <[email protected]>
Add support for AGE action for HW steering.
This patch includes:
1. Add new structures to manage the aging.
2. Initialize all them in configure function.
3. Implement per second aging check using CNT background thread.
4. Enable AGE action in flow create/destroy operations.
5. Implement queue-based function to report aged flow rules.
--- drivers/net/mlx5/mlx5.c | 67 +- drivers/net/mlx5/mlx5.h | 51 +- drivers/net/mlx5/mlx5_defs.h | 3 + drivers/net/mlx5/mlx5_flow.c | 89 ++- drivers/net/mlx5/mlx5_flow.h | 33 +- drivers/net/mlx5/mlx5_flow_dv.c | 30 +- drivers/net/mlx5/mlx5_flow_hw.c | 1104 ++++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow_verbs.c | 4 +- drivers/net/mlx5/mlx5_hws_cnt.c | 704 +++++++++++++++++- drivers/net/mlx5/mlx5_hws_cnt.h | 193 ++++- 10 files changed, 2013 insertions(+), 265 deletions(-)
drivers/net/mlx5/mlx5.c +47 -20
@@ -497,6 +497,12 @@ mlx5_flow_aging_init(struct mlx5_dev_ctx_shared *sh)uint32_t i;struct mlx5_age_info *age_info; +/* +* In HW steering, aging information structure is initialized later +* during configure function. +*/ +if (sh->config.dv_flow_en ==2 ) +return ;for (i =0 ; i < sh->max_port; i++) { age_info = &sh->port[i].age_info; age_info->flags =0 ;
@@ -540,8 +546,8 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused) hca_attr->flow_counter_bulk_alloc_bitmap);/* Initialize fallback mode only on the port initializes sh. */ if (sh->refcnt ==1 ) - sh->cmng.counter_fallback = fallback; -else if (fallback != sh->cmng.counter_fallback) + sh->sws_cmng.counter_fallback = fallback; +else if (fallback != sh->sws_cmng.counter_fallback)DRV_LOG (WARNING ,"Port %d in sh has different fallback mode " "with others:%d." ,PORT_ID (priv), fallback);#endif
@@ -556,17 +562,38 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused)static void mlx5_flow_counters_mng_init (struct mlx5_dev_ctx_shared *sh) { -int i; +int i, j; + +if (sh->config.dv_flow_en <2 ) { +memset (&sh->sws_cmng,0 ,sizeof (sh->sws_cmng)); +TAILQ_INIT (&sh->sws_cmng.flow_counters); + sh->sws_cmng.min_id =MLX5_CNT_BATCH_OFFSET ; + sh->sws_cmng.max_id =-1 ; + sh->sws_cmng.last_pool_idx =POOL_IDX_INVALID ; +rte_spinlock_init (&sh->sws_cmng.pool_update_sl); +for (i =0 ; i <MLX5_COUNTER_TYPE_MAX ; i++) { +TAILQ_INIT (&sh->sws_cmng.counters[i]); +rte_spinlock_init (&sh->sws_cmng.csl[i]); + } + }else { +struct mlx5_hca_attr *attr = &sh->cdev->config.hca_attr; +uint32_t fw_max_nb_cnts = attr->max_flow_counter; +uint8_t log_dcs =log2above (fw_max_nb_cnts) -1 ; +uint32_t max_nb_cnts =0 ; + +for (i =0 , j =0 ; j <MLX5_HWS_CNT_DCS_NUM ; ++i) { +int log_dcs_i = log_dcs - i; -memset (&sh->cmng,0 ,sizeof (sh->cmng)); -TAILQ_INIT (&sh->cmng.flow_counters); - sh->cmng.min_id =MLX5_CNT_BATCH_OFFSET ; - sh->cmng.max_id =-1 ; - sh->cmng.last_pool_idx =POOL_IDX_INVALID ; -rte_spinlock_init (&sh->cmng.pool_update_sl); -for (i =0 ; i <MLX5_COUNTER_TYPE_MAX ; i++) { -TAILQ_INIT (&sh->cmng.counters[i]); -rte_spinlock_init (&sh->cmng.csl[i]); +if (log_dcs_i <0 ) +break ; +if ((max_nb_cnts |RTE_BIT32 (log_dcs_i)) > + fw_max_nb_cnts) +continue ; + max_nb_cnts |=RTE_BIT32 (log_dcs_i); + j++; + } + sh->hws_max_log_bulk_sz = log_dcs; + sh->hws_max_nb_counters = max_nb_cnts; } }
@@ -607,13 +634,13 @@ mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh)rte_pause (); } -if (sh->cmng.pools) { +if (sh->sws_cmng.pools) {struct mlx5_flow_counter_pool *pool; -uint16_t n_valid = sh->cmng.n_valid; -bool fallback = sh->cmng.counter_fallback; +uint16_t n_valid = sh->sws_cmng.n_valid; +bool fallback = sh->sws_cmng.counter_fallback;for (i =0 ; i < n_valid; ++i) { - pool = sh->cmng.pools[i]; + pool = sh->sws_cmng.pools[i];if (!fallback && pool->min_dcs)claim_zero (mlx5_devx_cmd_destroy (pool->min_dcs));
@@ -632,14 +659,14 @@ mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh) }mlx5_free (pool); } -mlx5_free (sh->cmng.pools); +mlx5_free (sh->sws_cmng.pools); } - mng =LIST_FIRST (&sh->cmng.mem_mngs); + mng =LIST_FIRST (&sh->sws_cmng.mem_mngs);while (mng) {mlx5_flow_destroy_counter_stat_mem_mng (mng); - mng =LIST_FIRST (&sh->cmng.mem_mngs); + mng =LIST_FIRST (&sh->sws_cmng.mem_mngs); } -memset (&sh->cmng,0 ,sizeof (sh->cmng)); +memset (&sh->sws_cmng,0 ,sizeof (sh->sws_cmng)); }/**
drivers/net/mlx5/mlx5.h +47 -4
84 lines not on this page · raw message
drivers/net/mlx5/mlx5_defs.h +3 -0
@@ -43,6 +43,9 @@#define MLX5_PMD_SOFT_COUNTERS 1#endif +/* Maximum number of DCS created per port. */ +#define MLX5_HWS_CNT_DCS_NUM 4 +/* Alarm timeout. */ #define MLX5_ALARM_TIMEOUT_US 100000
drivers/net/mlx5/mlx5_flow.c +65 -24
175 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +30 -3
@@ -293,6 +293,8 @@ enum mlx5_feature_name {#define MLX5_FLOW_ACTION_MODIFY_FIELD (1ull << 39)#define MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY (1ull << 40)#define MLX5_FLOW_ACTION_CT (1ull << 41) +#define MLX5_FLOW_ACTION_INDIRECT_COUNT (1ull << 42) +#define MLX5_FLOW_ACTION_INDIRECT_AGE (1ull << 43)#define MLX5_FLOW_FATE_ACTIONS \ (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
@@ -1099,6 +1101,22 @@ struct rte_flow {uint32_t geneve_tlv_option;/**< Holds Geneve TLV option id. > */ } __rte_packed; +/* +* HWS COUNTER ID's layout +* 3 2 1 0 +* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +* | T | | D | | +* ~ Y | | C | IDX ~ +* | P | | S | | +* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +* +* Bit 31:29 = TYPE = MLX5_INDIRECT_ACTION_TYPE_COUNT = b'10 +* Bit 25:24 = DCS index +* Bit 23:00 = IDX in this counter belonged DCS bulk. +*/ +typedef uint32_t cnt_id_t ; +#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )/* HWS flow struct. */
@@ -1112,7 +1130,8 @@ struct rte_flow_hw { };struct rte_flow_template_table *table;/* The table flow allcated from. */ struct mlx5dr_rule rule;/* HWS layer data struct. */ -uint32_t cnt_id; +uint32_t age_idx; +cnt_id_t cnt_id;uint32_t mtr_id; } __rte_packed;
@@ -1158,7 +1177,7 @@ struct mlx5_action_construct_data {uint32_t idx;/* Shared action index. */ } shared_rss;struct { -uint32_t id; +cnt_id_t id; } shared_counter;struct {uint32_t id;
@@ -1189,6 +1208,7 @@ struct rte_flow_actions_template {struct rte_flow_action *actions;/* Cached flow actions. */ struct rte_flow_action *masks;/* Cached action masks.*/ struct mlx5dr_action_template *tmpl;/* mlx5dr action template. */ +uint64_t action_flags;/* Bit-map of all valid action in template. */ uint16_t dr_actions_num;/* Amount of DR rules actions. */ uint16_t actions_num;/* Amount of flow actions */ uint16_t *actions_off;/* DR action offset for given rte action offset. */
@@ -1245,7 +1265,7 @@ struct mlx5_hw_actions {struct mlx5_hw_encap_decap_action *encap_decap;uint16_t encap_decap_pos;/* Encap/Decap action position. */ uint32_t mark:1; /* Indicate the mark action. */ -uint32_t cnt_id;/* Counter id. */ +cnt_id_t cnt_id;/* Counter id. */ uint32_t mtr_id;/* Meter id. */ /* Translated DR action array from action template. */ struct mlx5dr_rule_action rule_acts[MLX5_HW_MAX_ACTS ];
@@ -1619,6 +1639,12 @@ typedef int (*mlx5_flow_get_aged_flows_t)void **context, uint32_t nb_contexts, struct rte_flow_error *error); +typedef int (*mlx5_flow_get_q_aged_flows_t ) + (struct rte_eth_dev *dev, +uint32_t queue_id, +void **context, +uint32_t nb_contexts, +struct rte_flow_error *error);typedef int (*mlx5_flow_action_validate_t ) (struct rte_eth_dev *dev, const struct rte_flow_indir_action_conf *conf,
@@ -1825,6 +1851,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_counter_free_t counter_free;mlx5_flow_counter_query_t counter_query;mlx5_flow_get_aged_flows_t get_aged_flows; +mlx5_flow_get_q_aged_flows_t get_q_aged_flows;mlx5_flow_action_validate_t action_validate;mlx5_flow_action_create_t action_create;mlx5_flow_action_destroy_t action_destroy;
drivers/net/mlx5/mlx5_flow_dv.c +15 -15
@@ -5524,7 +5524,7 @@ flow_dv_validate_action_age(uint64_t action_flags,const struct rte_flow_action_age *age = action->conf;if (!priv->sh->cdev->config.devx || - (priv->sh->cmng.counter_fallback && !priv->sh->aso_age_mng)) + (priv->sh->sws_cmng.counter_fallback && !priv->sh->aso_age_mng)) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -6085,7 +6085,7 @@ flow_dv_counter_get_by_idx(struct rte_eth_dev *dev, struct mlx5_flow_counter_pool **ppool) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;struct mlx5_flow_counter_pool *pool;/* Decrease to original index and clear shared bit. */
@@ -6179,7 +6179,7 @@ static int flow_dv_container_resize(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;void *old_pools = cmng->pools;uint32_t resize = cmng->n +MLX5_CNT_CONTAINER_RESIZE ;uint32_t mem_size =sizeof (struct mlx5_flow_counter_pool *) * resize;
@@ -6225,7 +6225,7 @@ _flow_dv_query_count(struct rte_eth_dev *dev, uint32_t counter, uint64_t *pkts, cnt =flow_dv_counter_get_by_idx (dev, counter, &pool);MLX5_ASSERT (pool); -if (priv->sh->cmng.counter_fallback) +if (priv->sh->sws_cmng.counter_fallback)return mlx5_devx_cmd_flow_counter_query (cnt->dcs_when_active,0 ,0 , pkts, bytes,0 ,NULL ,NULL ,0 );rte_spinlock_lock (&pool->sl);
@@ -6262,8 +6262,8 @@ flow_dv_pool_create(struct rte_eth_dev *dev, struct mlx5_devx_obj *dcs, {struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_counter_pool *pool; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; -bool fallback = priv->sh->cmng.counter_fallback; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng; +bool fallback = priv->sh->sws_cmng.counter_fallback;uint32_t size =sizeof (*pool); size +=MLX5_COUNTERS_PER_POOL *MLX5_CNT_SIZE ;
@@ -6324,14 +6324,14 @@ flow_dv_counter_pool_prepare(struct rte_eth_dev *dev, uint32_t age) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;struct mlx5_flow_counter_pool *pool;struct mlx5_counters tmp_tq;struct mlx5_devx_obj *dcs =NULL ;struct mlx5_flow_counter *cnt;enum mlx5_counter_type cnt_type = age ?MLX5_COUNTER_TYPE_AGE :MLX5_COUNTER_TYPE_ORIGIN ; -bool fallback = priv->sh->cmng.counter_fallback; +bool fallback = priv->sh->sws_cmng.counter_fallback;uint32_t i;if (fallback) {
@@ -6395,8 +6395,8 @@ flow_dv_counter_alloc(struct rte_eth_dev *dev, uint32_t age)struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_counter_pool *pool =NULL ;struct mlx5_flow_counter *cnt_free =NULL ; -bool fallback = priv->sh->cmng.counter_fallback; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +bool fallback = priv->sh->sws_cmng.counter_fallback; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;enum mlx5_counter_type cnt_type = age ?MLX5_COUNTER_TYPE_AGE :MLX5_COUNTER_TYPE_ORIGIN ;uint32_t cnt_idx;
@@ -6442,7 +6442,7 @@ flow_dv_counter_alloc(struct rte_eth_dev *dev, uint32_t age)if (_flow_dv_query_count (dev, cnt_idx, &cnt_free->hits, &cnt_free->bytes)) goto err; -if (!fallback && !priv->sh->cmng.query_thread_on) +if (!fallback && !priv->sh->sws_cmng.query_thread_on)/* Start the asynchronous batch query by the host thread. */ mlx5_set_query_alarm (priv->sh);/*
@@ -6570,7 +6570,7 @@ flow_dv_counter_free(struct rte_eth_dev *dev, uint32_t counter)* this case, lock will not be needed as query callback and release * function both operate with the different list. */ -if (!priv->sh->cmng.counter_fallback) { +if (!priv->sh->sws_cmng.counter_fallback) {rte_spinlock_lock (&pool->csl);TAILQ_INSERT_TAIL (&pool->counters[pool->query_gen], cnt, next);rte_spinlock_unlock (&pool->csl);
@@ -6578,10 +6578,10 @@ flow_dv_counter_free(struct rte_eth_dev *dev, uint32_t counter) cnt->dcs_when_free = cnt->dcs_when_active; cnt_type = pool->is_aged ?MLX5_COUNTER_TYPE_AGE :MLX5_COUNTER_TYPE_ORIGIN ; -rte_spinlock_lock (&priv->sh->cmng.csl[cnt_type]); -TAILQ_INSERT_TAIL (&priv->sh->cmng.counters[cnt_type], +rte_spinlock_lock (&priv->sh->sws_cmng.csl[cnt_type]); +TAILQ_INSERT_TAIL (&priv->sh->sws_cmng.counters[cnt_type], cnt, next); -rte_spinlock_unlock (&priv->sh->cmng.csl[cnt_type]); +rte_spinlock_unlock (&priv->sh->sws_cmng.csl[cnt_type]); } }
drivers/net/mlx5/mlx5_flow_hw.c +948 -156
1,611 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -2
@@ -122,7 +122,7 @@ flow_verbs_counter_get_by_idx(struct rte_eth_dev *dev, struct mlx5_flow_counter_pool **ppool) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;struct mlx5_flow_counter_pool *pool; idx = (idx -1 ) & (MLX5_CNT_SHARED_OFFSET -1 );
@@ -215,7 +215,7 @@ static uint32_t flow_verbs_counter_new(struct rte_eth_dev *dev, uint32_t id __rte_unused) { struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;struct mlx5_flow_counter_pool *pool =NULL ;struct mlx5_flow_counter *cnt =NULL ;uint32_t n_valid = cmng->n_valid;
drivers/net/mlx5/mlx5_hws_cnt.c +687 -17
803 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h +169 -24
19 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH v2 14/17 net/mlx5: add async action push and pull support
In reply to Suanming MouThe queue based rte_flow_async_action_* functions work same as queue based async flow functions. The operations can be pushed asynchronously, so is the pull.
This commit adds the async action missing push and pull support.
--- drivers/net/mlx5/mlx5.h | 62 ++++- drivers/net/mlx5/mlx5_flow.c | 45 ++++ drivers/net/mlx5/mlx5_flow.h | 17 ++ drivers/net/mlx5/mlx5_flow_aso.c | 181 +++++++++++-- drivers/net/mlx5/mlx5_flow_dv.c | 7 +- drivers/net/mlx5/mlx5_flow_hw.c | 412 +++++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 6 +- 7 files changed, 626 insertions(+), 104 deletions(-)
drivers/net/mlx5/mlx5.h +50 -12
@@ -341,6 +341,8 @@ struct mlx5_lb_ctx {enum {MLX5_HW_Q_JOB_TYPE_CREATE ,/* Flow create job type. */ MLX5_HW_Q_JOB_TYPE_DESTROY ,/* Flow destroy job type. */ +MLX5_HW_Q_JOB_TYPE_UPDATE , +MLX5_HW_Q_JOB_TYPE_QUERY , };#define MLX5_HW_MAX_ITEMS (16)
@@ -348,12 +350,23 @@ enum {/* HW steering flow management job descriptor. */ struct mlx5_hw_q_job {uint32_t type;/* Job type. */ -struct rte_flow_hw *flow;/* Flow attached to the job. */ +union { +struct rte_flow_hw *flow;/* Flow attached to the job. */ +const void *action;/* Indirect action attached to the job. */ + };void *user_data;/* Job user data. */ uint8_t *encap_data;/* Encap data. */ struct mlx5_modification_cmd *mhdr_cmd;struct rte_flow_item *items; -struct rte_flow_item_ethdev port_spec; +union { +struct { +/* Pointer to ct query user memory. */ +struct rte_flow_action_conntrack *profile; +/* Pointer to ct ASO query out memory. */ +void *out_data; + } __rte_packed; +struct rte_flow_item_ethdev port_spec; + } __rte_packed; };/* HW steering job descriptor LIFO pool. */
@@ -361,6 +374,8 @@ struct mlx5_hw_q {uint32_t job_idx;/* Free job index. */ uint32_t size;/* LIFO size. */ struct mlx5_hw_q_job **job;/* LIFO header. */ +struct rte_ring *indir_cq;/* Indirect action SW completion queue. */ +struct rte_ring *indir_iq;/* Indirect action SW in progress queue. */ } __rte_cache_aligned;
@@ -569,6 +584,7 @@ struct mlx5_aso_sq_elem {struct mlx5_aso_ct_action *ct;char *query_data; }; +void *user_data; }; };
@@ -578,7 +594,9 @@ struct mlx5_aso_sq {struct mlx5_aso_cq cq;struct mlx5_devx_sq sq_obj;struct mlx5_pmd_mr mr; +volatile struct mlx5_aso_wqe *db;uint16_t pi; +uint16_t db_pi;uint32_t head;uint32_t tail;uint32_t sqn;
@@ -993,6 +1011,7 @@ struct mlx5_flow_meter_profile {enum mlx5_aso_mtr_state {ASO_METER_FREE ,/* In free list. */ ASO_METER_WAIT ,/* ACCESS_ASO WQE in progress. */ +ASO_METER_WAIT_ASYNC ,/* CQE will be handled by async pull. */ ASO_METER_READY ,/* CQE received. */ };
@@ -1195,6 +1214,7 @@ struct mlx5_bond_info {enum mlx5_aso_ct_state {ASO_CONNTRACK_FREE ,/* Inactive, in the free list. */ ASO_CONNTRACK_WAIT ,/* WQE sent in the SQ. */ +ASO_CONNTRACK_WAIT_ASYNC ,/* CQE will be handled by async pull. */ ASO_CONNTRACK_READY ,/* CQE received w/o error. */ ASO_CONNTRACK_QUERY ,/* WQE for query sent. */ ASO_CONNTRACK_MAX ,/* Guard. */
@@ -1203,13 +1223,21 @@ enum mlx5_aso_ct_state {/* Generic ASO connection tracking structure. */ struct mlx5_aso_ct_action {union { -LIST_ENTRY (mlx5_aso_ct_action) next; -/* Pointer to the next ASO CT. Used only in SWS. */ -struct mlx5_aso_ct_pool *pool; -/* Pointer to action pool. Used only in HWS. */ +/* SWS mode struct. */ +struct { +/* Pointer to the next ASO CT. Used only in SWS. */ +LIST_ENTRY (mlx5_aso_ct_action) next; + }; +/* HWS mode struct. */ +struct { +/* Pointer to action pool. Used only in HWS. */ +struct mlx5_aso_ct_pool *pool; + }; }; -void *dr_action_orig;/* General action object for original dir. */ -void *dr_action_rply;/* General action object for reply dir. */ +/* General action object for original dir. */ +void *dr_action_orig; +/* General action object for reply dir. */ +void *dr_action_rply;uint32_t refcnt;/* Action used count in device flows. */ uint16_t offset;/* Offset of ASO CT in DevX objects bulk. */ uint16_t peer;/* The only peer port index could also use this CT. */
@@ -2135,18 +2163,21 @@ int mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh);void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh,enum mlx5_access_aso_opc_mod aso_opc_mod);int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh,uint32_t queue, -struct mlx5_aso_mtr *mtr, -struct mlx5_mtr_bulk *bulk); +struct mlx5_aso_mtr *mtr,struct mlx5_mtr_bulk *bulk, +void *user_data,bool push);int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_mtr *mtr);int mlx5_aso_ct_update_by_wqe (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_ct_action *ct, -const struct rte_flow_action_conntrack *profile); +const struct rte_flow_action_conntrack *profile, +void *user_data, +bool push);int mlx5_aso_ct_wait_ready (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_ct_action *ct);int mlx5_aso_ct_query_by_wqe (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_ct_action *ct, -struct rte_flow_action_conntrack *profile); +struct rte_flow_action_conntrack *profile, +void *user_data,bool push);int mlx5_aso_ct_available (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_ct_action *ct);uint32_t
@@ -2154,6 +2185,13 @@ mlx5_get_supported_sw_parsing_offloads(const struct mlx5_hca_attr *attr);uint32_t mlx5_get_supported_tunneling_offloads (const struct mlx5_hca_attr *attr); +void mlx5_aso_ct_obj_analyze (struct rte_flow_action_conntrack *profile, +char *wdata); +void mlx5_aso_push_wqe (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_sq *sq); +int mlx5_aso_pull_completion (struct mlx5_aso_sq *sq, +struct rte_flow_op_result res[], +uint16_t n_res);int mlx5_aso_cnt_queue_init (struct mlx5_dev_ctx_shared *sh);void mlx5_aso_cnt_queue_uninit (struct mlx5_dev_ctx_shared *sh); int mlx5_aso_cnt_query(struct mlx5_dev_ctx_shared *sh,
drivers/net/mlx5/mlx5_flow.c +45 -0
63 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +17 -0
@@ -57,6 +57,13 @@ enum mlx5_rte_flow_field_id {#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 29 +#define MLX5_INDIRECT_ACTION_TYPE_GET (handle) \ + (((uint32_t)(uintptr_t)(handle)) >> MLX5_INDIRECT_ACTION_TYPE_OFFSET) + +#define MLX5_INDIRECT_ACTION_IDX_GET (handle) \ + (((uint32_t)(uintptr_t)(handle)) & \ + ((1u << MLX5_INDIRECT_ACTION_TYPE_OFFSET) - 1)) +enum {MLX5_INDIRECT_ACTION_TYPE_RSS ,MLX5_INDIRECT_ACTION_TYPE_AGE ,
@@ -1816,6 +1823,15 @@ typedef int (*mlx5_flow_async_action_handle_update_t)void *user_data, struct rte_flow_error *error); +typedef int (*mlx5_flow_async_action_handle_query_t ) + (struct rte_eth_dev *dev, +uint32_t queue, +const struct rte_flow_op_attr *attr, +const struct rte_flow_action_handle *handle, +void *data, +void *user_data, +struct rte_flow_error *error); +typedef int (*mlx5_flow_async_action_handle_destroy_t ) (struct rte_eth_dev *dev, uint32_t queue,
@@ -1878,6 +1894,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_push_t push;mlx5_flow_async_action_handle_create_t async_action_create;mlx5_flow_async_action_handle_update_t async_action_update; +mlx5_flow_async_action_handle_query_t async_action_query;mlx5_flow_async_action_handle_destroy_t async_action_destroy; };
drivers/net/mlx5/mlx5_flow_aso.c +152 -29
322 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +4 -3
@@ -13091,7 +13091,7 @@ flow_dv_translate_create_conntrack(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Failed to allocate CT object"); ct =flow_aso_ct_get_by_dev_idx (dev, idx); -if (mlx5_aso_ct_update_by_wqe (sh,MLX5_HW_INV_QUEUE , ct, pro)) { +if (mlx5_aso_ct_update_by_wqe (sh,MLX5_HW_INV_QUEUE , ct, pro,NULL , true)) {flow_dv_aso_ct_dev_release (dev, idx); rte_flow_error_set(error, EBUSY, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -15904,7 +15904,7 @@ __flow_dv_action_ct_update(struct rte_eth_dev *dev, uint32_t idx,if (ret)return ret; ret =mlx5_aso_ct_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , - ct, new_prf); + ct, new_prf,NULL , true);if (ret) return rte_flow_error_set(error, EIO, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -16740,7 +16740,8 @@ flow_dv_action_query(struct rte_eth_dev *dev, ct->peer; ((struct rte_flow_action_conntrack *)data)->is_original_dir = ct->is_original; -if (mlx5_aso_ct_query_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , ct, data)) +if (mlx5_aso_ct_query_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , ct, + data,NULL , true)) return rte_flow_error_set(error, EIO, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
drivers/net/mlx5/mlx5_flow_hw.c +355 -57
677 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +3 -3
@@ -1627,7 +1627,7 @@ mlx5_flow_meter_action_modify(struct mlx5_priv *priv, fm->is_enable = !!is_enable; aso_mtr = container_of(fm, struct mlx5_aso_mtr, fm); ret =mlx5_aso_meter_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , - aso_mtr, &priv->mtr_bulk); + aso_mtr, &priv->mtr_bulk,NULL , true);if (ret)return ret; ret =mlx5_aso_mtr_wait (priv->sh,MLX5_HW_INV_QUEUE , aso_mtr);
@@ -1877,7 +1877,7 @@ mlx5_flow_meter_create(struct rte_eth_dev *dev, uint32_t meter_id,if (priv->sh->meter_aso_en) { aso_mtr = container_of(fm, struct mlx5_aso_mtr, fm); ret =mlx5_aso_meter_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , - aso_mtr, &priv->mtr_bulk); + aso_mtr, &priv->mtr_bulk,NULL , true);if (ret) goto error;if (!priv->mtr_idx_tbl) {
@@ -1983,7 +1983,7 @@ mlx5_flow_meter_hws_create(struct rte_eth_dev *dev, uint32_t meter_id, fm->initialized =1 ;/* Update ASO flow meter by wqe. */ ret =mlx5_aso_meter_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , aso_mtr, - &priv->mtr_bulk); + &priv->mtr_bulk,NULL , true);if (ret) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_UNSPECIFIED,
Signature · 1 line
2.25.1
PATCH v2 15/17 net/mlx5: support flow integrity in HWS group 0
In reply to Suanming MouFrom: Gregory Etelson <[email protected]>
- Reformat flow integrity item translation for HWS code.
- Support flow integrity bits in HWS group 0.
- Update integrity item translation to match positive semantics only. Positive flow semantics was described in patch [ae37c0f60c].
--- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 163 ++++++++++++++++---------------- drivers/net/mlx5/mlx5_flow_hw.c | 8 ++ 3 files changed, 90 insertions(+), 82 deletions(-)
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -1462,6 +1462,7 @@ struct mlx5_dv_matcher_workspace {struct mlx5_flow_rss_desc *rss_desc;/* RSS descriptor. */ const struct rte_flow_item *tunnel_item;/* Flow tunnel item. */ const struct rte_flow_item *gre_item;/* Flow GRE item. */ +const struct rte_flow_item *integrity_items[2 ]; };struct mlx5_flow_split_info {
drivers/net/mlx5/mlx5_flow_dv.c +81 -82
251 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +8 -0
@@ -4618,6 +4618,14 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,case RTE_FLOW_ITEM_TYPE_ICMP6 :case RTE_FLOW_ITEM_TYPE_CONNTRACK :break ; +case RTE_FLOW_ITEM_TYPE_INTEGRITY : +/* +* Integrity flow item validation require access to +* both item mask and spec. +* Current HWS model allows item mask in pattern +* template and item spec in flow rule. +*/ +break ;case RTE_FLOW_ITEM_TYPE_END : items_end = true;break ;
Signature · 1 line
2.25.1
PATCH v2 16/17 net/mlx5: support device control for E-Switch default rule
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch introduces
This patch adds support for fdb_def_rule_en device argument to HW Steering, which controls:
- creation of default FDB jump flow rule,
- ability of the user to create transfer flow rules in root table.
A new PMD API to allow user application to enable traffic with port ID and SQ number is also added to direct packet to wire.
--- drivers/net/mlx5/linux/mlx5_os.c | 14 ++ drivers/net/mlx5/mlx5.h | 4 +- drivers/net/mlx5/mlx5_flow.c | 28 ++-- drivers/net/mlx5/mlx5_flow.h | 11 +- drivers/net/mlx5/mlx5_flow_dv.c | 46 ++--- drivers/net/mlx5/mlx5_flow_hw.c | 279 +++++++++++++++---------------- drivers/net/mlx5/mlx5_trigger.c | 31 ++-- drivers/net/mlx5/mlx5_tx.h | 1 + drivers/net/mlx5/mlx5_txq.c | 47 ++++++ drivers/net/mlx5/rte_pmd_mlx5.h | 17 ++ drivers/net/mlx5/version.map | 1 + 11 files changed, 274 insertions(+), 205 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +14 -0
@@ -1554,6 +1554,20 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,rte_rwlock_init (&priv->ind_tbls_lock);if (priv->sh->config.dv_flow_en ==2 ) {#ifdef HAVE_IBV_FLOW_DV_SUPPORT +if (priv->sh->config.dv_esw_en) { +if (priv->sh->dv_regc0_mask ==UINT32_MAX ) { +DRV_LOG (ERR ,"E-Switch port metadata is required when using HWS " +"but it is disabled (configure it through devlink)" ); + err =ENOTSUP ; + goto error; + } +if (priv->sh->dv_regc0_mask ==0 ) { +DRV_LOG (ERR ,"E-Switch with HWS is not supported " +"(no available bits in reg_c[0])" ); + err =ENOTSUP ; + goto error; + } + }if (priv->vport_meta_mask)flow_hw_set_port_info (eth_dev); if (priv->sh->config.dv_esw_en &&
drivers/net/mlx5/mlx5.h +2 -2
@@ -2015,7 +2015,7 @@ int mlx5_flow_ops_get(struct rte_eth_dev *dev, const struct rte_flow_ops **ops);int mlx5_flow_start_default (struct rte_eth_dev *dev);void mlx5_flow_stop_default (struct rte_eth_dev *dev);int mlx5_flow_verify (struct rte_eth_dev *dev); -int mlx5_ctrl_flow_source_queue (struct rte_eth_dev *dev,uint32_t queue); +int mlx5_ctrl_flow_source_queue (struct rte_eth_dev *dev,uint32_t sq_num); int mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, struct rte_flow_item_eth *eth_spec, struct rte_flow_item_eth *eth_mask,
@@ -2027,7 +2027,7 @@ int mlx5_ctrl_flow(struct rte_eth_dev *dev,int mlx5_flow_lacp_miss (struct rte_eth_dev *dev);struct rte_flow *mlx5_flow_create_esw_table_zero_flow (struct rte_eth_dev *dev);uint32_t mlx5_flow_create_devx_sq_miss_flow (struct rte_eth_dev *dev, -uint32_t txq); +uint32_t sq_num);void mlx5_flow_async_pool_query_handle (struct mlx5_dev_ctx_shared *sh,uint64_t async_id,int status);void mlx5_set_query_alarm (struct mlx5_dev_ctx_shared *sh);
drivers/net/mlx5/mlx5_flow.c +14 -14
@@ -7155,14 +7155,14 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev)* * @param dev * Pointer to Ethernet device. -* @param txq -* Txq index. +* @param sq_num +* SQ number. * * @return * Flow ID on success, 0 otherwise and rte_errno is set. */ uint32_t -mlx5_flow_create_devx_sq_miss_flow (struct rte_eth_dev *dev,uint32_t txq) +mlx5_flow_create_devx_sq_miss_flow (struct rte_eth_dev *dev,uint32_t sq_num) {struct rte_flow_attr attr = { .group =0 ,
@@ -7174,8 +7174,8 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t txq)struct rte_flow_item_port_id port_spec = { .id =MLX5_PORT_ESW_MGR , }; -struct mlx5_rte_flow_item_tx_queue txq_spec = { - .queue = txq, +struct mlx5_rte_flow_item_sq sq_spec = { + .queue = sq_num, };struct rte_flow_item pattern[] = { {
@@ -7184,8 +7184,8 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t txq) }, { .type = (enum rte_flow_item_type) - MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE, - .spec = &txq_spec, + MLX5_RTE_FLOW_ITEM_TYPE_SQ, + .spec = &sq_spec, }, { .type = RTE_FLOW_ITEM_TYPE_END,
@@ -7556,30 +7556,30 @@ mlx5_flow_verify(struct rte_eth_dev *dev __rte_unused)* * @param dev * Pointer to Ethernet device. -* @param queue -* The queue index. +* @param sq_num +* The SQ hw number. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ int mlx5_ctrl_flow_source_queue (struct rte_eth_dev *dev, -uint32_t queue) +uint32_t sq_num) {const struct rte_flow_attr attr = { .egress =1 , .priority =0 , }; -struct mlx5_rte_flow_item_tx_queue queue_spec = { - .queue = queue, +struct mlx5_rte_flow_item_sq queue_spec = { + .queue = sq_num, }; -struct mlx5_rte_flow_item_tx_queue queue_mask = { +struct mlx5_rte_flow_item_sq queue_mask = { .queue =UINT32_MAX , };struct rte_flow_item items[] = { { .type = (enum rte_flow_item_type ) -MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE , +MLX5_RTE_FLOW_ITEM_TYPE_SQ , .spec = &queue_spec, .last =NULL , .mask = &queue_mask,
drivers/net/mlx5/mlx5_flow.h +5 -6
@@ -29,7 +29,7 @@enum mlx5_rte_flow_item_type {MLX5_RTE_FLOW_ITEM_TYPE_END =INT_MIN ,MLX5_RTE_FLOW_ITEM_TYPE_TAG , -MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE , +MLX5_RTE_FLOW_ITEM_TYPE_SQ ,MLX5_RTE_FLOW_ITEM_TYPE_VLAN ,MLX5_RTE_FLOW_ITEM_TYPE_TUNNEL , };
@@ -115,8 +115,8 @@ struct mlx5_flow_action_copy_mreg { };/* Matches on source queue. */ -struct mlx5_rte_flow_item_tx_queue { -uint32_t queue; +struct mlx5_rte_flow_item_sq { +uint32_t queue;/* DevX SQ number */ };/* Feature name to allocate metadata register. */
@@ -179,7 +179,7 @@ enum mlx5_feature_name {#define MLX5_FLOW_LAYER_GENEVE (1u << 26)/* Queue items. */ -#define MLX5_FLOW_ITEM_TX_QUEUE (1u << 27) +#define MLX5_FLOW_ITEM_SQ (1u << 27)/* Pattern tunnel Layer bits (continued). */ #define MLX5_FLOW_LAYER_GTP (1u << 28)
@@ -2475,9 +2475,8 @@ int mlx5_flow_pick_transfer_proxy(struct rte_eth_dev *dev,int mlx5_flow_hw_flush_ctrl_flows (struct rte_eth_dev *dev); -int mlx5_flow_hw_esw_create_mgr_sq_miss_flow (struct rte_eth_dev *dev);int mlx5_flow_hw_esw_create_sq_miss_flow (struct rte_eth_dev *dev, -uint32_t txq); +uint32_t sqn);int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev);int mlx5_flow_hw_create_tx_default_mreg_copy_flow (struct rte_eth_dev *dev); int mlx5_flow_actions_validate(struct rte_eth_dev *dev,
drivers/net/mlx5/mlx5_flow_dv.c +17 -29
98 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +138 -141
423 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +18 -13
@@ -426,7 +426,7 @@ mlx5_hairpin_queue_peer_update(struct rte_eth_dev *dev, uint16_t peer_queue,mlx5_txq_release (dev, peer_queue);return -rte_errno; } - peer_info->qp_id = txq_ctrl->obj->sq->id; + peer_info->qp_id =mlx5_txq_get_sqn (txq_ctrl); peer_info->vhca_id = priv->sh->cdev->config.hca_attr.vhca_id;/* 1-to-1 mapping, only the first one is used. */ peer_info->peer_q = txq_ctrl->hairpin_conf.peers[0 ].queue;
@@ -818,7 +818,7 @@ mlx5_hairpin_bind_single_port(struct rte_eth_dev *dev, uint16_t rx_port) }/* Pass TxQ's information to peer RxQ and try binding. */ cur.peer_q = rx_queue; - cur.qp_id = txq_ctrl->obj->sq->id; + cur.qp_id =mlx5_txq_get_sqn (txq_ctrl); cur.vhca_id = priv->sh->cdev->config.hca_attr.vhca_id; cur.tx_explicit = txq_ctrl->hairpin_conf.tx_explicit; cur.manual_bind = txq_ctrl->hairpin_conf.manual_bind;
@@ -1300,8 +1300,6 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev)int ret;if (priv->sh->config.dv_esw_en && priv->master) { -if (mlx5_flow_hw_esw_create_mgr_sq_miss_flow (dev)) - goto error;if (priv->sh->config.dv_xmeta_en ==MLX5_XMETA_MODE_META32_HWS )if (mlx5_flow_hw_create_tx_default_mreg_copy_flow (dev)) goto error;
@@ -1312,10 +1310,7 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev)if (!txq)continue ; -if (txq->is_hairpin) - queue = txq->obj->sq->id; -else - queue = txq->obj->sq_obj.sq->id; + queue =mlx5_txq_get_sqn (txq);if ((priv->representor || priv->master) && priv->sh->config.dv_esw_en) {if (mlx5_flow_hw_esw_create_sq_miss_flow (dev, queue)) {
@@ -1325,9 +1320,15 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev) }mlx5_txq_release (dev, i); } -if ((priv->master || priv->representor) && priv->sh->config.dv_esw_en) { -if (mlx5_flow_hw_esw_create_default_jump_flow (dev)) - goto error; +if (priv->sh->config.fdb_def_rule) { +if ((priv->master || priv->representor) && priv->sh->config.dv_esw_en) { +if (!mlx5_flow_hw_esw_create_default_jump_flow (dev)) + priv->fdb_def_rule =1 ; +else + goto error; + } + }else { +DRV_LOG (INFO ,"port %u FDB default rule is disabled" , dev->data->port_id); }return 0 ; error:
@@ -1393,14 +1394,18 @@ mlx5_traffic_enable(struct rte_eth_dev *dev) txq_ctrl->hairpin_conf.tx_explicit == 0 && txq_ctrl->hairpin_conf.peers[0].port == priv->dev_data->port_id) { - ret =mlx5_ctrl_flow_source_queue (dev, i); + ret =mlx5_ctrl_flow_source_queue (dev, +mlx5_txq_get_sqn (txq_ctrl));if (ret) {mlx5_txq_release (dev, i); goto error; } }if (priv->sh->config.dv_esw_en) { -if (mlx5_flow_create_devx_sq_miss_flow (dev, i) ==0 ) { +uint32_t q =mlx5_txq_get_sqn (txq_ctrl); + +if (mlx5_flow_create_devx_sq_miss_flow (dev, q) ==0 ) { +mlx5_txq_release (dev, i);DRV_LOG (ERR ,"Port %u Tx queue %u SQ create representor devx default miss rule failed." , dev->data->port_id, i);
drivers/net/mlx5/mlx5_tx.h +1 -0
@@ -213,6 +213,7 @@ struct mlx5_txq_ctrl *mlx5_txq_get(struct rte_eth_dev *dev, uint16_t idx);int mlx5_txq_release (struct rte_eth_dev *dev,uint16_t idx);int mlx5_txq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_txq_verify (struct rte_eth_dev *dev); +int mlx5_txq_get_sqn (struct mlx5_txq_ctrl *txq);void txq_alloc_elts (struct mlx5_txq_ctrl *txq_ctrl);void txq_free_elts (struct mlx5_txq_ctrl *txq_ctrl);uint64_t mlx5_get_tx_port_offloads (struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_txq.c +47 -0
59 lines not on this page · raw message
drivers/net/mlx5/rte_pmd_mlx5.h +17 -0
@@ -139,6 +139,23 @@ int rte_pmd_mlx5_external_rx_queue_id_unmap(uint16_t port_id,__rte_experimental int rte_pmd_mlx5_host_shaper_config(int port_id, uint8_t rate, uint32_t flags); +/** +* Enable traffic for external SQ. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] sq_num +* SQ HW number. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +* Possible values for rte_errno: +* - EINVAL - invalid sq_number or port type. +* - ENODEV - there is no Ethernet device for this port id. +*/ +__rte_experimental +int rte_pmd_mlx5_external_sq_enable(uint16_t port_id, uint32_t sq_num); + #ifdef __cplusplus }#endif
drivers/net/mlx5/version.map +1 -0
@@ -14,4 +14,5 @@ EXPERIMENTAL { rte_pmd_mlx5_external_rx_queue_id_unmap; # added in 22.07 rte_pmd_mlx5_host_shaper_config; + rte_pmd_mlx5_external_sq_enable; };
Signature · 1 line
2.25.1
PATCH v2 17/17 net/mlx5: support device control of representor matching
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
In some E-Switch use cases applications want to receive all traffic on a single port. Since currently flow API does not provide a way to match traffic forwarded to any port representor, this patch adds support for controlling representor matching on ingress flow rules.
Representor matching is controlled through new device argument repr_matching_en.
- If representor matching is enabled (default setting), then each ingress pattern template has an implicit REPRESENTED_PORT item added. Flow rules based on this pattern template will match the vport associated with port on which rule is created.
- If representor matching is disabled, then there will be no implicit item added. As a result ingress flow rules will match traffic coming to any port, not only the port on which flow rule is created.
Representor matching is enabled by default, to provide an expected default behavior.
This patch enables egress flow rules on representors when E-Switch is enabled in the following configurations:
- repr_matching_en=1 and dv_xmeta_en=4
- repr_matching_en=1 and dv_xmeta_en=0
- repr_matching_en=0 and dv_xmeta_en=0
When representor matching is enabled, the following logic is implemented:
1. Creating an egress template table in group 0 for each port. These tables will hold default flow rules defined as follows:
pattern SQ
actions MODIFY_FIELD (set available bits in REG_C_0 to
vport_meta_tag)
MODIFY_FIELD (copy REG_A to REG_C_1, only when
dv_xmeta_en == 4)
JUMP (group 1)
2. Egress pattern templates created by an application have an implicit MLX5_RTE_FLOW_ITEM_TYPE_TAG item prepended to pattern, which matches available bits of REG_C_0.
3. Egress flow rules created by an application have an implicit MLX5_RTE_FLOW_ITEM_TYPE_TAG item prepended to pattern, which matches vport_meta_tag placed in available bits of REG_C_0.
4. Egress template tables created by an application, which are in group n, are placed in group n + 1.
5. Items and actions related to META are operating on REG_A when dv_xmeta_en == 0 or REG_C_1 when dv_xmeta_en == 4.
When representor matching is disabled and extended metadata is disabled, no changes to current logic are required.
--- drivers/net/mlx5/linux/mlx5_os.c | 11 + drivers/net/mlx5/mlx5.c | 13 + drivers/net/mlx5/mlx5.h | 5 + drivers/net/mlx5/mlx5_flow.c | 8 +- drivers/net/mlx5/mlx5_flow.h | 7 + drivers/net/mlx5/mlx5_flow_hw.c | 718 ++++++++++++++++++++++++------- drivers/net/mlx5/mlx5_trigger.c | 167 ++++++- 7 files changed, 771 insertions(+), 158 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +11 -0
@@ -1555,6 +1555,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,if (priv->sh->config.dv_flow_en ==2 ) {#ifdef HAVE_IBV_FLOW_DV_SUPPORT if (priv->sh->config.dv_esw_en) { +uint32_t usable_bits; +uint32_t required_bits; +if (priv->sh->dv_regc0_mask ==UINT32_MAX ) {DRV_LOG (ERR ,"E-Switch port metadata is required when using HWS " "but it is disabled (configure it through devlink)" );
@@ -1567,6 +1570,14 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err =ENOTSUP ; goto error; } + usable_bits =__builtin_popcount (priv->sh->dv_regc0_mask); + required_bits =__builtin_popcount (priv->vport_meta_mask); +if (usable_bits < required_bits) { +DRV_LOG (ERR ,"Not enough bits available in reg_c[0] to provide " +"representor matching." ); + err =ENOTSUP ; + goto error; + } }if (priv->vport_meta_mask)flow_hw_set_port_info (eth_dev);
drivers/net/mlx5/mlx5.c +13 -0
@@ -181,6 +181,9 @@/* HW steering counter's query interval. */ #define MLX5_HWS_CNT_CYCLE_TIME "svc_cycle_time" +/* Device parameter to control representor matching in ingress/egress flows with HWS. */ +#define MLX5_REPR_MATCHING_EN "repr_matching_en" +/* Shared memory between primary and secondary processes. */ struct mlx5_shared_data *mlx5_shared_data;
@@ -1283,6 +1286,8 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque) config->cnt_svc.service_core = tmp; }else if (strcmp (MLX5_HWS_CNT_CYCLE_TIME , key) ==0 ) { config->cnt_svc.cycle_time = tmp; + }else if (strcmp (MLX5_REPR_MATCHING_EN , key) ==0 ) { + config->repr_matching = !!tmp; }return 0 ; }
@@ -1321,6 +1326,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,MLX5_FDB_DEFAULT_RULE_EN ,MLX5_HWS_CNT_SERVICE_CORE ,MLX5_HWS_CNT_CYCLE_TIME , +MLX5_REPR_MATCHING_EN , NULL, };int ret =0 ;
@@ -1335,6 +1341,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->fdb_def_rule =1 ; config->cnt_svc.cycle_time =MLX5_CNT_SVC_CYCLE_TIME_DEFAULT ; config->cnt_svc.service_core =rte_get_main_lcore (); + config->repr_matching =1 ;if (mkvlist !=NULL ) {/* Process parameters. */ ret = mlx5_kvargs_process(mkvlist, params,
@@ -1368,6 +1375,11 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->dv_xmeta_en); config->dv_xmeta_en =MLX5_XMETA_MODE_LEGACY ; } +if (config->dv_flow_en !=2 && !config->repr_matching) { +DRV_LOG (DEBUG ,"Disabling representor matching is valid only " +"when HW Steering is enabled." ); + config->repr_matching =1 ; + }if (config->tx_pp && !sh->dev_cap.txpp_en) {DRV_LOG (ERR ,"Packet pacing is not supported." ); rte_errno =ENODEV ;
@@ -1411,6 +1423,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,DRV_LOG (DEBUG ,"\"allow_duplicate_pattern\" is %u." , config->allow_duplicate_pattern);DRV_LOG (DEBUG ,"\"fdb_def_rule_en\" is %u." , config->fdb_def_rule); +DRV_LOG (DEBUG ,"\"repr_matching_en\" is %u." , config->repr_matching);return 0 ; }
drivers/net/mlx5/mlx5.h +5 -0
@@ -316,6 +316,7 @@ struct mlx5_sh_config { } cnt_svc;/* configure for HW steering's counter's service. */ /* Allow/Prevent the duplicate rules pattern. */ uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ + uint32_t repr_matching:1; /* Enable implicit vport matching in HWS FDB. */ };/* Structure for VF VLAN workaround. */
@@ -366,6 +367,7 @@ struct mlx5_hw_q_job {void *out_data; } __rte_packed;struct rte_flow_item_ethdev port_spec; +struct rte_flow_item_tag tag_spec; } __rte_packed; };
@@ -1673,6 +1675,9 @@ struct mlx5_priv {struct rte_flow_template_table *hw_esw_sq_miss_tbl;struct rte_flow_template_table *hw_esw_zero_tbl;struct rte_flow_template_table *hw_tx_meta_cpy_tbl; +struct rte_flow_pattern_template *hw_tx_repr_tagging_pt; +struct rte_flow_actions_template *hw_tx_repr_tagging_at; +struct rte_flow_template_table *hw_tx_repr_tagging_tbl;struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI ];/* RTE Flow rules. */ uint32_t ctrl_flows;/* Control flow rules. */
drivers/net/mlx5/mlx5_flow.c +6 -2
@@ -1123,7 +1123,11 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev, }break ;case MLX5_METADATA_TX : -return REG_A ; +if (config->dv_flow_en ==2 && config->dv_xmeta_en ==MLX5_XMETA_MODE_META32_HWS ) { +return REG_C_1 ; + }else { +return REG_A ; + }case MLX5_METADATA_FDB :switch (config->dv_xmeta_en) {case MLX5_XMETA_MODE_LEGACY :
@@ -11319,7 +11323,7 @@ mlx5_flow_pick_transfer_proxy(struct rte_eth_dev *dev,return 0 ; } } -return rte_flow_error_set (error,EINVAL , +return rte_flow_error_set (error,ENODEV ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL ,"unable to find a proxy port" ); }
drivers/net/mlx5/mlx5_flow.h +7 -0
@@ -1199,12 +1199,18 @@ struct rte_flow_pattern_template {struct rte_flow_pattern_template_attr attr;struct mlx5dr_match_template *mt;/* mlx5 match template. */ uint64_t item_flags;/* Item layer flags. */ +uint64_t orig_item_nb;/* Number of pattern items provided by the user (with END item). */ uint32_t refcnt;/* Reference counter. */ /* * If true, then rule pattern should be prepended with * represented_port pattern item. */ bool implicit_port; +/* +* If true, then rule pattern should be prepended with +* tag pattern item for representor matching. +*/ +bool implicit_tag; };/* Flow action template struct. */
@@ -2479,6 +2485,7 @@ int mlx5_flow_hw_esw_create_sq_miss_flow(struct rte_eth_dev *dev, uint32_t sqn);int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev);int mlx5_flow_hw_create_tx_default_mreg_copy_flow (struct rte_eth_dev *dev); +int mlx5_flow_hw_tx_repr_matching_flow (struct rte_eth_dev *dev,uint32_t sqn); int mlx5_flow_actions_validate(struct rte_eth_dev *dev, const struct rte_flow_actions_template_attr *attr, const struct rte_flow_action actions[],
drivers/net/mlx5/mlx5_flow_hw.c +570 -148
978 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +159 -8
213 lines not on this page · raw message
Signature · 1 line
2.25.1
v3 cover net/mlx5: HW steering PMD update
In reply to Suanming MouThe skeleton of mlx5 HW steering(HWS) has been updated into upstream for pretty a long time, but not updated anymore due to missing of the low-level steering layer code. Luckily, better late than never, the steering layer finnaly comes[1].
This series will add more features to the existing PMD code:
- FDB and metadata copy.
- Modify field.
- Meter color.
- Counter.
- Aging.
- Action template pre-parser optimization.
- Connection tracking.
Some features such as meter/aging/ct touches the public API, and public API changes have been sent to ML much earily in other threads in order not to be swallowed by this big series.
The dpends patches as below:
[1]https://inbox.dpdk.org/dev/[email protected]/ [2]https://inbox.dpdk.org/dev/[email protected]/
---
v3:
- Fixed flow can't be aged out.
- Fix error not be filled properly while table creat failed.
- Remove transfer_mode in flow attributes before ethdev layer applied.
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
v2:
- Remove the rte_flow patches as they will be integrated in other thread.
- Fix compilation issues.
- Make the patches be better organized.
---
Alexander Kozyrev (2):
net/mlx5: add HW steering meter action net/mlx5: implement METER MARK indirect action for HWS
Bing Zhao (1):
net/mlx5: add extended metadata mode for hardware steering
Dariusz Sosnowski (4):
net/mlx5: add HW steering port action
net/mlx5: support DR action template API net/mlx5: support device control for E-Switch default rule net/mlx5: support device control of representor matching
Gregory Etelson (2):
net/mlx5: add HW steering VLAN push, pop and VID modify flow actions net/mlx5: support flow integrity in HWS group 0
Michael Baum (1):
net/mlx5: add HWS AGE action support
Suanming Mou (6):
net/mlx5: fix invalid flow attributes net/mlx5: fix IPv6 and TCP RSS hash fields net/mlx5: add shared header reformat support net/mlx5: add modify field hws support net/mlx5: add HW steering connection tracking support net/mlx5: add async action push and pull support
Xiaoyu Min (1):
net/mlx5: add HW steering counter action
doc/guides/nics/mlx5.rst | 9 + drivers/common/mlx5/mlx5_devx_cmds.c | 50 + drivers/common/mlx5/mlx5_devx_cmds.h | 27 + drivers/common/mlx5/mlx5_prm.h | 64 +- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/linux/mlx5_os.c | 76 +- drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 126 +- drivers/net/mlx5/mlx5.h | 318 +- drivers/net/mlx5/mlx5_defs.h | 5 + drivers/net/mlx5/mlx5_flow.c | 415 +- drivers/net/mlx5/mlx5_flow.h | 312 +- drivers/net/mlx5/mlx5_flow_aso.c | 793 ++- drivers/net/mlx5/mlx5_flow_dv.c | 1169 ++-- drivers/net/mlx5/mlx5_flow_hw.c | 7898 +++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_meter.c | 771 ++- drivers/net/mlx5/mlx5_flow_verbs.c | 8 +- drivers/net/mlx5/mlx5_hws_cnt.c | 1198 ++++ drivers/net/mlx5/mlx5_hws_cnt.h | 703 +++ drivers/net/mlx5/mlx5_trigger.c | 254 +- drivers/net/mlx5/mlx5_tx.h | 1 + drivers/net/mlx5/mlx5_txq.c | 47 + drivers/net/mlx5/rte_pmd_mlx5.h | 17 + drivers/net/mlx5/version.map | 1 + 24 files changed, 12619 insertions(+), 1645 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.c create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.h
Signature · 1 line
2.25.1
PATCH v3 1/17 net/mlx5: fix invalid flow attributes
In the function flow_get_drv_type(), attr will be read in non-HWS mode. In case user call the HWS API in SWS mode, attr should be placed in HWS functions, or it will cause crash.
--- drivers/net/mlx5/mlx5_flow.c | 38 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-)
drivers/net/mlx5/mlx5_flow.c +26 -12
@@ -3740,6 +3740,8 @@ flow_get_drv_type(struct rte_eth_dev *dev, const struct rte_flow_attr *attr)*/ if (priv->sh->config.dv_flow_en ==2 )return MLX5_FLOW_TYPE_HW ; +if (!attr) +return MLX5_FLOW_TYPE_MIN ;/* If no OS specific type - continue with DV/VERBS selection */ if (attr->transfer && priv->sh->config.dv_esw_en) type =MLX5_FLOW_TYPE_DV ;
@@ -8252,8 +8254,9 @@ mlx5_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8287,8 +8290,9 @@ mlx5_flow_port_configure(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8319,8 +8323,9 @@ mlx5_flow_pattern_template_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8350,8 +8355,9 @@ mlx5_flow_pattern_template_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8385,8 +8391,9 @@ mlx5_flow_actions_template_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8416,8 +8423,9 @@ mlx5_flow_actions_template_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8457,8 +8465,9 @@ mlx5_flow_table_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8494,8 +8503,9 @@ mlx5_flow_table_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8542,8 +8552,9 @@ mlx5_flow_async_flow_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8585,8 +8596,9 @@ mlx5_flow_async_flow_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8621,8 +8633,9 @@ mlx5_flow_pull(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8650,8 +8663,9 @@ mlx5_flow_push(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
Signature · 1 line
2.25.1
PATCH v3 2/17 net/mlx5: fix IPv6 and TCP RSS hash fields
In reply to Suanming MouIn the flow_dv_hashfields_set() function, while item_flags was 0, the code went directly to the first if and the else case would never have chance be checked. This caused the IPv6 and TCP hash fileds in the else case would never be set.
This commit adds the dedicate HW steering hash field set function to generate the RSS hash fields.
--- drivers/net/mlx5/mlx5_flow_dv.c | 12 +++---- drivers/net/mlx5/mlx5_flow_hw.c | 59 ++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 9 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +4 -8
@@ -11299,8 +11299,7 @@ flow_dv_hashfields_set(uint64_t item_flags, rss_inner =1 ;#endif if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L3_IPV4 )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV4 )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV4 ))) {if (rss_types &MLX5_IPV4_LAYER_TYPES ) {if (rss_types &RTE_ETH_RSS_L3_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_IPV4 ;
@@ -11310,8 +11309,7 @@ flow_dv_hashfields_set(uint64_t item_flags, fields |=MLX5_IPV4_IBV_RX_HASH ; } }else if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L3_IPV6 )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV6 )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV6 ))) {if (rss_types &MLX5_IPV6_LAYER_TYPES ) {if (rss_types &RTE_ETH_RSS_L3_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_IPV6 ;
@@ -11334,8 +11332,7 @@ flow_dv_hashfields_set(uint64_t item_flags,return ; }if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L4_UDP )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_UDP )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_UDP ))) {if (rss_types &RTE_ETH_RSS_UDP ) {if (rss_types &RTE_ETH_RSS_L4_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_PORT_UDP ;
@@ -11345,8 +11342,7 @@ flow_dv_hashfields_set(uint64_t item_flags, fields |=MLX5_UDP_IBV_RX_HASH ; } }else if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L4_TCP )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_TCP )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_TCP ))) {if (rss_types &RTE_ETH_RSS_TCP ) {if (rss_types &RTE_ETH_RSS_L4_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_PORT_TCP ;
drivers/net/mlx5/mlx5_flow_hw.c +58 -1
71 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 3/17 net/mlx5: add shared header reformat support
In reply to Suanming MouAs the rte_flow_async API defines, the action mask with field value not be 0 means the action will be used as shared in all the flows in the table.
The header reformat action with action mask field not be 0 will be created as constant shared action. For encapsulation header reformat action, there are two kinds of encapsulation data, raw_encap_data and rte_flow_item encap_data. Both of these two kinds of data can be identified from the action mask conf as constant or not.
Examples:
1. VXLAN encap (encap_data: rte_flow_item)
action conf (eth/ipv4/udp/vxlan_hdr)
a. action mask conf (eth/ipv4/udp/vxlan_hdr)
- items are constant.
b. action mask conf (NULL)
- items will change.
2. RAW encap (encap_data: raw)
action conf (raw_data)
a. action mask conf (not NULL)
- encap_data constant.
b. action mask conf (NULL)
- encap_data will change.
--- drivers/net/mlx5/mlx5_flow.h | 6 +- drivers/net/mlx5/mlx5_flow_hw.c | 124 ++++++++++---------------------- 2 files changed, 39 insertions(+), 91 deletions(-)
drivers/net/mlx5/mlx5_flow.h +2 -4
@@ -1064,10 +1064,6 @@ struct mlx5_action_construct_data {uint16_t action_dst;/* mlx5dr_rule_action dst offset. */ union {struct { -/* encap src(item) offset. */ -uint16_t src; -/* encap dst data offset. */ -uint16_t dst;/* encap data len. */ uint16_t len; } encap;
@@ -1110,6 +1106,8 @@ struct mlx5_hw_jump_action {/* Encap decap action struct. */ struct mlx5_hw_encap_decap_action {struct mlx5dr_action *action;/* Action object. */ +/* Is header_reformat action shared across flows in table. */ +bool shared;size_t data_size;/* Action metadata size. */ uint8_t data[];/* Action data. */ };
drivers/net/mlx5/mlx5_flow_hw.c +37 -87
226 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 4/17 net/mlx5: add modify field hws support
In reply to Suanming MouThis patch introduces support for modify_field rte_flow actions in HWS mode. Support includes:
- Ingress and egress domains,
- SET and ADD operations,
- usage of arbitrary bit offsets and widths for packet and metadata fields.
Support is implemented in two phases:
1. On flow table creation the hardware commands are generated, based on rte_flow action templates, and stored alongside action template.
2. On flow rule creation/queueing the hardware commands are updated with values provided by the user. Any masks over immediate values, provided in action templates, are applied to these values before enqueueing rules for creation.
--- drivers/common/mlx5/mlx5_prm.h | 2 + drivers/net/mlx5/linux/mlx5_os.c | 18 +- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.h | 96 +++++ drivers/net/mlx5/mlx5_flow_dv.c | 551 ++++++++++++++------------- drivers/net/mlx5/mlx5_flow_hw.c | 614 ++++++++++++++++++++++++++++++- 6 files changed, 1007 insertions(+), 275 deletions(-)
drivers/common/mlx5/mlx5_prm.h +2 -0
@@ -746,6 +746,8 @@ enum mlx5_modification_field {MLX5_MODI_IN_TCP_ACK_NUM =0x5C ,MLX5_MODI_GTP_TEID =0x6E ,MLX5_MODI_OUT_IP_ECN =0x73 , +MLX5_MODI_TUNNEL_HDR_DW_1 =0x75 , + MLX5_MODI_GTPU_FIRST_EXT_DW_0 = 0x76, };/* Total number of metadata reg_c's. */
drivers/net/mlx5/linux/mlx5_os.c +9 -9
@@ -1540,6 +1540,15 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, mlx5_hrxq_clone_free_cb);if (!priv->hrxqs) goto error; +mlx5_set_metadata_mask (eth_dev); +if (sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + !priv->sh->dv_regc0_mask) { +DRV_LOG (ERR ,"metadata mode %u is not supported " +"(no metadata reg_c[0] is available)" , + sh->config.dv_xmeta_en); + err =ENOTSUP ; + goto error; + }rte_rwlock_init (&priv->ind_tbls_lock);if (priv->sh->config.dv_flow_en ==2 ) {#ifdef HAVE_IBV_FLOW_DV_SUPPORT
@@ -1566,15 +1575,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err = -err; goto error; } -mlx5_set_metadata_mask (eth_dev); -if (sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && - !priv->sh->dv_regc0_mask) { -DRV_LOG (ERR ,"metadata mode %u is not supported " -"(no metadata reg_c[0] is available)" , - sh->config.dv_xmeta_en); - err =ENOTSUP ; - goto error; - }/* Query availability of metadata reg_c's. */ if (!priv->sh->metadata_regc_check_flag) { err =mlx5_flow_discover_mreg_c (eth_dev);
drivers/net/mlx5/mlx5.h +1 -0
@@ -343,6 +343,7 @@ struct mlx5_hw_q_job {struct rte_flow_hw *flow;/* Flow attached to the job. */ void *user_data;/* Job user data. */ uint8_t *encap_data;/* Encap data. */ +struct mlx5_modification_cmd *mhdr_cmd; };/* HW steering job descriptor LIFO pool. */
drivers/net/mlx5/mlx5_flow.h +96 -0
132 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +286 -265
732 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +613 -1
709 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 5/17 net/mlx5: add HW steering port action
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch implements creating and caching of port actions for use with HW Steering FDB flows.
Actions are created on flow template API configuration and created only on the port designated as master. Attaching and detaching of ports in the same switching domain causes an update to the port actions cache by, respectively, creating and destroying actions.
A new devarg fdb_def_rule_en is being added and it's used to control the default dedicated E-Switch rule is created by PMD implicitly or not, and PMD sets this value to 1 by default.
If set to 0, the default E-Switch rule will not be created and user can create the specific E-Switch rule on root table if needed.
--- doc/guides/nics/mlx5.rst | 9 + drivers/net/mlx5/linux/mlx5_os.c | 14 + drivers/net/mlx5/mlx5.c | 14 + drivers/net/mlx5/mlx5.h | 26 +- drivers/net/mlx5/mlx5_flow.c | 96 +- drivers/net/mlx5/mlx5_flow.h | 22 +- drivers/net/mlx5/mlx5_flow_dv.c | 93 +- drivers/net/mlx5/mlx5_flow_hw.c | 1356 +++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_flow_verbs.c | 4 +- drivers/net/mlx5/mlx5_trigger.c | 77 +- 10 files changed, 1594 insertions(+), 117 deletions(-)
doc/guides/nics/mlx5.rst +9 -0
@@ -1118,6 +1118,15 @@ for an additional list of options shared with other mlx5 drivers. By default, the PMD will set this value to 1. +- ``fdb_def_rule_en`` parameter [int] + + A non-zero value enables the PMD to create a dedicated rule on E-Switch root + table, this dedicated rule forwards all incoming packets into table 1, other + rules will be created in E-Switch table original table level plus one, to + improve the flow insertion rate due to skip root table managed by firmware. + If set to 0, all rules will be created on the original E-Switch table level. + + By default, the PMD will set this value to 1. Supported NICs --------------
drivers/net/mlx5/linux/mlx5_os.c +14 -0
@@ -1556,6 +1556,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,flow_hw_set_port_info (eth_dev);/* Only HWS requires this information. */ flow_hw_init_tags_set (eth_dev); +if (priv->sh->config.dv_esw_en && +flow_hw_create_vport_action (eth_dev)) { +DRV_LOG (ERR ,"port %u failed to create vport action" , + eth_dev->data->port_id); + err =EINVAL ; + goto error; + }return eth_dev;#else DRV_LOG (ERR ,"DV support is missing for HWS." );
@@ -1620,6 +1627,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,return eth_dev; error:if (priv) { +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +if (eth_dev && + priv->sh && + priv->sh->config.dv_flow_en ==2 && + priv->sh->config.dv_esw_en) +flow_hw_destroy_vport_action (eth_dev); +#endif if (priv->mreg_cp_tbl)mlx5_hlist_destroy (priv->mreg_cp_tbl);if (priv->sh)
drivers/net/mlx5/mlx5.c +14 -0
@@ -172,6 +172,9 @@/* Device parameter to configure the delay drop when creating Rxqs. */ #define MLX5_DELAY_DROP "delay_drop" +/* Device parameter to create the fdb default rule in PMD */ +#define MLX5_FDB_DEFAULT_RULE_EN "fdb_def_rule_en" +/* Shared memory between primary and secondary processes. */ struct mlx5_shared_data *mlx5_shared_data;
@@ -1239,6 +1242,8 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque) config->decap_en = !!tmp; }else if (strcmp (MLX5_ALLOW_DUPLICATE_PATTERN , key) ==0 ) { config->allow_duplicate_pattern = !!tmp; + }else if (strcmp (MLX5_FDB_DEFAULT_RULE_EN , key) ==0 ) { + config->fdb_def_rule = !!tmp; }return 0 ; }
@@ -1274,6 +1279,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,MLX5_RECLAIM_MEM ,MLX5_DECAP_EN ,MLX5_ALLOW_DUPLICATE_PATTERN , +MLX5_FDB_DEFAULT_RULE_EN , NULL, };int ret =0 ;
@@ -1285,6 +1291,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->dv_flow_en =1 ; config->decap_en =1 ; config->allow_duplicate_pattern =1 ; + config->fdb_def_rule =1 ;if (mkvlist !=NULL ) {/* Process parameters. */ ret = mlx5_kvargs_process(mkvlist, params,
@@ -1360,6 +1367,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,DRV_LOG (DEBUG ,"\"decap_en\" is %u." , config->decap_en);DRV_LOG (DEBUG ,"\"allow_duplicate_pattern\" is %u." , config->allow_duplicate_pattern); +DRV_LOG (DEBUG ,"\"fdb_def_rule_en\" is %u." , config->fdb_def_rule);return 0 ; }
@@ -1943,6 +1951,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)mlx5_flex_parser_ecpri_release (dev);mlx5_flex_item_port_cleanup (dev);#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H ) +flow_hw_destroy_vport_action (dev);flow_hw_resource_release (dev);flow_hw_clear_port_info (dev);if (priv->sh->config.dv_flow_en ==2 )
@@ -2644,6 +2653,11 @@ mlx5_probe_again_args_validate(struct mlx5_common_device *cdev, sh->ibdev_name); goto error; } +if (sh->config.fdb_def_rule ^ config->fdb_def_rule) { +DRV_LOG (ERR ,"\"fdb_def_rule_en\" configuration mismatch for shared %s context." , + sh->ibdev_name); + goto error; + }if (sh->config.l3_vxlan_en ^ config->l3_vxlan_en) { DRV_LOG(ERR, "\"l3_vxlan_en\" " "configuration mismatch for shared %s context.",
drivers/net/mlx5/mlx5.h +22 -4
@@ -309,6 +309,7 @@ struct mlx5_sh_config { uint32_t allow_duplicate_pattern:1; uint32_t lro_allowed:1; /* Whether LRO is allowed. *//* Allow/Prevent the duplicate rules pattern. */ + uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ };
@@ -337,6 +338,8 @@ enum { MLX5_HW_Q_JOB_TYPE_DESTROY, /* Flow destroy job type. */ }; +#define MLX5_HW_MAX_ITEMS (16) +/* HW steering flow management job descriptor. */ struct mlx5_hw_q_job {uint32_t type;/* Job type. */
@@ -344,6 +347,8 @@ struct mlx5_hw_q_job {void *user_data;/* Job user data. */ uint8_t *encap_data;/* Encap data. */ struct mlx5_modification_cmd *mhdr_cmd; +struct rte_flow_item *items; +struct rte_flow_item_ethdev port_spec; };/* HW steering job descriptor LIFO pool. */
@@ -1202,6 +1207,8 @@ struct mlx5_dev_ctx_shared { uint32_t flow_priority_check_flag:1; /* Check Flag for flow priority. */ uint32_t metadata_regc_check_flag:1; /* Check Flag for metadata REGC. */ uint32_t hws_tags:1; /* Check if tags info for HWS initialized. */ + uint32_t shared_mark_enabled:1; +/* If mark action is enabled on Rxqs (shared E-Switch domain). */ uint32_t max_port;/* Maximal IB device port index. */ struct mlx5_bond_info bond;/* Bonding information. */ struct mlx5_common_device *cdev;/* Backend mlx5 device. */
@@ -1450,6 +1457,12 @@ struct mlx5_obj_ops {#define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields) +struct mlx5_hw_ctrl_flow { +LIST_ENTRY (mlx5_hw_ctrl_flow) next; +struct rte_eth_dev *owner_dev; +struct rte_flow *flow; +}; +struct mlx5_priv {struct rte_eth_dev_data *dev_data;/* Pointer to device data. */ struct mlx5_dev_ctx_shared *sh;/* Shared device context. */
@@ -1490,6 +1503,11 @@ struct mlx5_priv {unsigned int reta_idx_n;/* RETA index size. */ struct mlx5_drop drop_queue;/* Flow drop queues. */ void *root_drop_action;/* Pointer to root drop action. */ +rte_spinlock_t hw_ctrl_lock; + LIST_HEAD(hw_ctrl_flow, mlx5_hw_ctrl_flow) hw_ctrl_flows; +struct rte_flow_template_table *hw_esw_sq_miss_root_tbl; +struct rte_flow_template_table *hw_esw_sq_miss_tbl; +struct rte_flow_template_table *hw_esw_zero_tbl;struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI ];/* RTE Flow rules. */ uint32_t ctrl_flows;/* Control flow rules. */
@@ -1550,11 +1568,11 @@ struct mlx5_priv {struct mlx5_hw_q *hw_q;/* HW steering rte flow table list header. */ LIST_HEAD(flow_hw_tbl, rte_flow_template_table) flow_hw_tbl; +struct mlx5dr_action **hw_vport;/* HW steering global drop action. */ -struct mlx5dr_action *hw_drop[MLX5_HW_ACTION_FLAG_MAX ] - [MLX5DR_TABLE_TYPE_MAX ]; -/* HW steering global drop action. */ -struct mlx5dr_action *hw_tag[MLX5_HW_ACTION_FLAG_MAX ]; +struct mlx5dr_action *hw_drop[2 ]; +/* HW steering global tag action. */ +struct mlx5dr_action *hw_tag[2 ];struct mlx5_indexed_pool *acts_ipool;/* Action data indexed pool. */ #endif };
drivers/net/mlx5/mlx5_flow.c +80 -16
171 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +21 -1
@@ -1151,6 +1151,11 @@ struct rte_flow_pattern_template {struct mlx5dr_match_template *mt;/* mlx5 match template. */ uint64_t item_flags;/* Item layer flags. */ uint32_t refcnt;/* Reference counter. */ +/* +* If true, then rule pattern should be prepended with +* represented_port pattern item. +*/ +bool implicit_port; };/* Flow action template struct. */
@@ -1226,6 +1231,7 @@ struct mlx5_hw_action_template {/* mlx5 flow group struct. */ struct mlx5_flow_group {struct mlx5_list_entry entry; +struct rte_eth_dev *dev;/* Reference to corresponding device. */ struct mlx5dr_table *tbl;/* HWS table object. */ struct mlx5_hw_jump_action jump;/* Jump action. */ enum mlx5dr_table_type type;/* Table type. */
@@ -1484,6 +1490,9 @@ void flow_hw_clear_port_info(struct rte_eth_dev *dev);void flow_hw_init_tags_set (struct rte_eth_dev *dev);void flow_hw_clear_tags_set (struct rte_eth_dev *dev); +int flow_hw_create_vport_action (struct rte_eth_dev *dev); +void flow_hw_destroy_vport_action (struct rte_eth_dev *dev); + typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2056,7 +2065,7 @@ 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, + bool root, struct rte_flow_error *error); int mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item, uint64_t item_flags,
@@ -2313,4 +2322,15 @@ int flow_dv_translate_items_hws(const struct rte_flow_item *items, uint32_t key_type, uint64_t *item_flags, uint8_t *match_criteria, struct rte_flow_error *error); + +int mlx5_flow_pick_transfer_proxy (struct rte_eth_dev *dev, +uint16_t *proxy_port_id, +struct rte_flow_error *error); + +int mlx5_flow_hw_flush_ctrl_flows (struct rte_eth_dev *dev); + +int mlx5_flow_hw_esw_create_mgr_sq_miss_flow (struct rte_eth_dev *dev); +int mlx5_flow_hw_esw_create_sq_miss_flow (struct rte_eth_dev *dev, +uint32_t txq); +int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +53 -40
297 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +1309 -47
1,615 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +3 -1
@@ -1245,12 +1245,14 @@ flow_verbs_validate(struct rte_eth_dev *dev,uint16_t ether_type =0 ;bool is_empty_vlan = false;uint16_t udp_dport =0 ; +bool is_root;if (items ==NULL )return -1 ; ret =mlx5_flow_validate_attributes (dev, attr, error);if (ret <0 )return ret; + is_root = ret;for (; items->type !=RTE_FLOW_ITEM_TYPE_END ; items++) {int tunnel = !!(item_flags &MLX5_FLOW_LAYER_TUNNEL );int ret =0 ;
@@ -1380,7 +1382,7 @@ flow_verbs_validate(struct rte_eth_dev *dev,case RTE_FLOW_ITEM_TYPE_VXLAN : ret =mlx5_flow_validate_item_vxlan (dev, udp_dport, items, item_flags, - attr, error); + is_root, error);if (ret <0 )return ret; last_item =MLX5_FLOW_LAYER_VXLAN ;
drivers/net/mlx5/mlx5_trigger.c +69 -8
101 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 6/17 net/mlx5: add extended metadata mode for hardware steering
In reply to Suanming MouFrom: Bing Zhao <[email protected]>
The new mode 4 of devarg "dv_xmeta_en" is added for HWS only. In this mode, the Rx / Tx metadata with 32b width copy between FDB and NIC is supported. The mark is only supported in NIC and there is no copy supported.
--- drivers/net/mlx5/linux/mlx5_os.c | 10 +- drivers/net/mlx5/mlx5.c | 7 +- drivers/net/mlx5/mlx5.h | 8 +- drivers/net/mlx5/mlx5_flow.c | 8 +- drivers/net/mlx5/mlx5_flow.h | 14 + drivers/net/mlx5/mlx5_flow_dv.c | 43 +- drivers/net/mlx5/mlx5_flow_hw.c | 864 ++++++++++++++++++++++++++++--- drivers/net/mlx5/mlx5_trigger.c | 3 + 8 files changed, 872 insertions(+), 85 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +9 -1
@@ -1554,6 +1554,15 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,#ifdef HAVE_IBV_FLOW_DV_SUPPORT if (priv->vport_meta_mask)flow_hw_set_port_info (eth_dev); +if (priv->sh->config.dv_esw_en && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_META32_HWS ) { +DRV_LOG (ERR , +"metadata mode %u is not supported in HWS eswitch mode" , + priv->sh->config.dv_xmeta_en); + err =ENOTSUP ; + goto error; + }/* Only HWS requires this information. */ flow_hw_init_tags_set (eth_dev); if (priv->sh->config.dv_esw_en &&
@@ -1569,7 +1578,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, goto error;#endif } -/* Port representor shares the same max priority with pf port. */ if (!priv->sh->flow_priority_check_flag) {/* Supported Verbs flow priority number detection. */ err =mlx5_flow_discover_priorities (eth_dev);
drivers/net/mlx5/mlx5.c +6 -1
@@ -1218,7 +1218,8 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque)if (tmp !=MLX5_XMETA_MODE_LEGACY && tmp !=MLX5_XMETA_MODE_META16 && tmp !=MLX5_XMETA_MODE_META32 && - tmp !=MLX5_XMETA_MODE_MISS_INFO ) { + tmp !=MLX5_XMETA_MODE_MISS_INFO && + tmp !=MLX5_XMETA_MODE_META32_HWS ) {DRV_LOG (ERR ,"Invalid extensive metadata parameter." ); rte_errno =EINVAL ;return -rte_errno;
@@ -2849,6 +2850,10 @@ mlx5_set_metadata_mask(struct rte_eth_dev *dev) meta =UINT32_MAX ; mark = (reg_c0 >>rte_bsf32 (reg_c0)) &MLX5_FLOW_MARK_MASK ;break ; +case MLX5_XMETA_MODE_META32_HWS : + meta =UINT32_MAX ; + mark =MLX5_FLOW_MARK_MASK ; +break ;default : meta =0 ; mark =0 ;
drivers/net/mlx5/mlx5.h +4 -4
@@ -298,8 +298,8 @@ struct mlx5_sh_config { uint32_t reclaim_mode:2; /* Memory reclaim mode. */ uint32_t dv_esw_en:1; /* Enable E-Switch DV flow. *//* Enable DV flow. 1 means SW steering, 2 means HW steering. */ - unsigned int dv_flow_en:2; - uint32_t dv_xmeta_en:2; /* Enable extensive flow metadata. */ + uint32_t dv_flow_en:2; /* Enable DV flow. */ + uint32_t dv_xmeta_en:3; /* Enable extensive flow metadata. */ uint32_t dv_miss_info:1; /* Restore packet after partial hw miss. */ uint32_t l3_vxlan_en:1; /* Enable L3 VXLAN flow creation. */ uint32_t vf_nl_en:1; /* Enable Netlink requests in VF mode. */
@@ -312,7 +312,6 @@ struct mlx5_sh_config { uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ }; -/* Structure for VF VLAN workaround. */ struct mlx5_vf_vlan {uint32_t tag:12 ;
@@ -1279,12 +1278,12 @@ struct mlx5_dev_ctx_shared {struct mlx5_lb_ctx self_lb;/* QP to enable self loopback for Devx. */ unsigned int flow_max_priority;enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM ]; +/* Availability of mreg_c's. */ void *devx_channel_lwm;struct rte_intr_handle *intr_handle_lwm;pthread_mutex_t lwm_config_lock; uint32_t host_shaper_rate:8; uint32_t lwm_triggered:1; -/* Availability of mreg_c's. */ struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1508,6 +1507,7 @@ struct mlx5_priv {struct rte_flow_template_table *hw_esw_sq_miss_root_tbl;struct rte_flow_template_table *hw_esw_sq_miss_tbl;struct rte_flow_template_table *hw_esw_zero_tbl; +struct rte_flow_template_table *hw_tx_meta_cpy_tbl;struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI ];/* RTE Flow rules. */ uint32_t ctrl_flows;/* Control flow rules. */
drivers/net/mlx5/mlx5_flow.c +7 -1
@@ -1107,6 +1107,8 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,return REG_C_0 ;case MLX5_XMETA_MODE_META32 :return REG_C_1 ; +case MLX5_XMETA_MODE_META32_HWS : +return REG_C_1 ; }break ;case MLX5_METADATA_TX :
@@ -1119,11 +1121,14 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,return REG_C_0 ;case MLX5_XMETA_MODE_META32 :return REG_C_1 ; +case MLX5_XMETA_MODE_META32_HWS : +return REG_C_1 ; }break ;case MLX5_FLOW_MARK :switch (config->dv_xmeta_en) {case MLX5_XMETA_MODE_LEGACY : +case MLX5_XMETA_MODE_META32_HWS :return REG_NON ;case MLX5_XMETA_MODE_META16 :return REG_C_1 ;
@@ -4442,7 +4447,8 @@ static bool flow_check_modify_action_type(struct rte_eth_dev *dev,return true;case RTE_FLOW_ACTION_TYPE_FLAG :case RTE_FLOW_ACTION_TYPE_MARK : -if (priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY ) +if (priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_META32_HWS )return true;else return false;
drivers/net/mlx5/mlx5_flow.h +14 -0
@@ -48,6 +48,12 @@ enum mlx5_rte_flow_action_type { MLX5_RTE_FLOW_ACTION_TYPE_RSS, }; +/* Private (internal) Field IDs for MODIFY_FIELD action. */ +enum mlx5_rte_flow_field_id { +MLX5_RTE_FLOW_FIELD_END =INT_MIN , +MLX5_RTE_FLOW_FIELD_META_REG , +}; +#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 30enum {
@@ -1167,6 +1173,7 @@ struct rte_flow_actions_template {struct rte_flow_action *masks;/* Cached action masks.*/ uint16_t mhdr_off;/* Offset of DR modify header action. */ uint32_t refcnt;/* Reference counter. */ +uint16_t rx_cpy_pos;/* Action position of Rx metadata to be copied. */ };/* Jump action struct. */
@@ -1243,6 +1250,11 @@ struct mlx5_flow_group {#define MLX5_HW_TBL_MAX_ITEM_TEMPLATE 2#define MLX5_HW_TBL_MAX_ACTION_TEMPLATE 32 +struct mlx5_flow_template_table_cfg { +struct rte_flow_template_table_attr attr;/* Table attributes passed through flow API. */ +bool external;/* True if created by flow API, false if table is internal to PMD. */ +}; +struct rte_flow_template_table {LIST_ENTRY (rte_flow_template_table) next;struct mlx5_flow_group *grp;/* The group rte_flow_template_table uses. */
@@ -1252,6 +1264,7 @@ struct rte_flow_template_table {/* Action templates bind to the table. */ struct mlx5_hw_action_template ats[MLX5_HW_TBL_MAX_ACTION_TEMPLATE ];struct mlx5_indexed_pool *flow;/* The table's flow ipool. */ +struct mlx5_flow_template_table_cfg cfg;uint32_t type;/* Flow table type RX/TX/FDB. */ uint8_t nb_item_templates;/* Item template number. */ uint8_t nb_action_templates;/* Action template number. */
@@ -2333,4 +2346,5 @@ int mlx5_flow_hw_esw_create_mgr_sq_miss_flow(struct rte_eth_dev *dev);int mlx5_flow_hw_esw_create_sq_miss_flow (struct rte_eth_dev *dev,uint32_t txq);int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev); +int mlx5_flow_hw_create_tx_default_mreg_copy_flow (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +39 -4
73 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +790 -74
1,295 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +3 -0
@@ -1292,6 +1292,9 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev)if (priv->sh->config.dv_esw_en && priv->master) {if (mlx5_flow_hw_esw_create_mgr_sq_miss_flow (dev)) goto error; +if (priv->sh->config.dv_xmeta_en ==MLX5_XMETA_MODE_META32_HWS ) +if (mlx5_flow_hw_create_tx_default_mreg_copy_flow (dev)) + goto error; }for (i =0 ; i < priv->txqs_n; ++i) {struct mlx5_txq_ctrl *txq =mlx5_txq_get (dev, i);
Signature · 1 line
2.25.1
PATCH v3 7/17 net/mlx5: add HW steering meter action
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
This commit adds meter action for HWS steering.
HW steering meter is based on ASO. The number of meters will be used by flows should be specified in advanced in the flow configure API.
--- drivers/net/mlx5/mlx5.h | 61 ++- drivers/net/mlx5/mlx5_flow.c | 71 +++ drivers/net/mlx5/mlx5_flow.h | 50 ++ drivers/net/mlx5/mlx5_flow_aso.c | 30 +- drivers/net/mlx5/mlx5_flow_dv.c | 25 - drivers/net/mlx5/mlx5_flow_hw.c | 264 ++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 702 ++++++++++++++++++++++++++++- 7 files changed, 1142 insertions(+), 61 deletions(-)
drivers/net/mlx5/mlx5.h +58 -3
@@ -357,6 +357,9 @@ struct mlx5_hw_q {struct mlx5_hw_q_job **job;/* LIFO header. */ } __rte_cache_aligned; + + +#define MLX5_COUNTERS_PER_POOL 512#define MLX5_MAX_PENDING_QUERIES 4#define MLX5_CNT_CONTAINER_RESIZE 64
@@ -782,15 +785,29 @@ struct mlx5_flow_meter_policy {/* Is meter action in policy table. */ uint32_t hierarchy_drop_cnt:1;/* Is any meter in hierarchy contains drop_cnt. */ + uint32_t skip_r:1; +/* If red color policy is skipped. */ uint32_t skip_y:1;/* If yellow color policy is skipped. */ uint32_t skip_g:1;/* If green color policy is skipped. */ uint32_t mark:1;/* If policy contains mark action. */ + uint32_t initialized:1; +/* Initialized. */ +uint16_t group; +/* The group. */ rte_spinlock_t sl;uint32_t ref_cnt;/* Use count. */ +struct rte_flow_pattern_template *hws_item_templ; +/* Hardware steering item templates. */ +struct rte_flow_actions_template *hws_act_templ[MLX5_MTR_DOMAIN_MAX ]; +/* Hardware steering action templates. */ +struct rte_flow_template_table *hws_flow_table[MLX5_MTR_DOMAIN_MAX ]; +/* Hardware steering tables. */ +struct rte_flow *hws_flow_rule[MLX5_MTR_DOMAIN_MAX ][RTE_COLORS ]; +/* Hardware steering rules. */ struct mlx5_meter_policy_action_container act_cnt[MLX5_MTR_RTE_COLORS ];/* Policy actions container. */ void *dr_drop_action[MLX5_MTR_DOMAIN_MAX ];
@@ -865,6 +882,7 @@ struct mlx5_flow_meter_info {*/ uint32_t transfer:1; uint32_t def_policy:1; + uint32_t initialized:1;/* Meter points to default policy. */ uint32_t color_aware:1;/* Meter is color aware mode. */
@@ -880,6 +898,10 @@ struct mlx5_flow_meter_info {/**< Flow meter action. */ void *meter_action_y;/**< Flow meter action for yellow init_color. */ +uint32_t meter_offset; +/**< Flow meter offset. */ +uint16_t group; +/**< Flow meter group. */ };/* PPS(packets per second) map to BPS(Bytes per second).
@@ -914,6 +936,7 @@ struct mlx5_flow_meter_profile {uint32_t ref_cnt;/**< Use count. */ uint32_t g_support:1; /**< If G color will be generated. */ uint32_t y_support:1; /**< If Y color will be generated. */ + uint32_t initialized:1; /**< Initialized. */ };/* 2 meters in each ASO cache line */
@@ -934,13 +957,20 @@ enum mlx5_aso_mtr_state { ASO_METER_READY, /* CQE received. */ }; +/*aso flow meter type*/ +enum mlx5_aso_mtr_type { +ASO_METER_INDIRECT , +ASO_METER_DIRECT , +}; +/* Generic aso_flow_meter information. */ struct mlx5_aso_mtr {LIST_ENTRY (mlx5_aso_mtr) next; +enum mlx5_aso_mtr_type type;struct mlx5_flow_meter_info fm;/**< Pointer to the next aso flow meter structure. */ uint8_t state;/**< ASO flow meter state. */ -uint8_t offset; +uint32_t offset; };/* Generic aso_flow_meter pool structure. */
@@ -964,6 +994,14 @@ struct mlx5_aso_mtr_pools_mng {struct mlx5_aso_mtr_pool **pools;/* ASO flow meter pool array. */ }; +/* Bulk management structure for ASO flow meter. */ +struct mlx5_mtr_bulk { +uint32_t size;/* Number of ASO objects. */ +struct mlx5dr_action *action;/* HWS action */ +struct mlx5_devx_obj *devx_obj;/* DEVX object. */ +struct mlx5_aso_mtr *aso;/* Array of ASO objects. */ +}; +/* Meter management structure for global flow meter resource. */ struct mlx5_flow_mtr_mng {struct mlx5_aso_mtr_pools_mng pools_mng;
@@ -1017,6 +1055,7 @@ struct mlx5_flow_tbl_resource {#define MLX5_FLOW_TABLE_LEVEL_METER (MLX5_MAX_TABLES - 3)#define MLX5_FLOW_TABLE_LEVEL_POLICY (MLX5_MAX_TABLES - 4)#define MLX5_MAX_TABLES_EXTERNAL MLX5_FLOW_TABLE_LEVEL_POLICY +#define MLX5_FLOW_TABLE_HWS_POLICY (MLX5_MAX_TABLES - 10)#define MLX5_MAX_TABLES_FDB UINT16_MAX#define MLX5_FLOW_TABLE_FACTOR 10
@@ -1303,6 +1342,12 @@ TAILQ_HEAD(mlx5_mtr_profiles, mlx5_flow_meter_profile);/* MTR list. */ TAILQ_HEAD (mlx5_legacy_flow_meters, mlx5_legacy_flow_meter); +struct mlx5_mtr_config { +uint32_t nb_meters;/**< Number of configured meters */ +uint32_t nb_meter_profiles;/**< Number of configured meter profiles */ +uint32_t nb_meter_policies;/**< Number of configured meter policies */ +}; +/* RSS description. */ struct mlx5_flow_rss_desc {uint32_t level;
@@ -1538,12 +1583,16 @@ struct mlx5_priv {struct mlx5_nl_vlan_vmwa_context *vmwa_context;/* VLAN WA context. */ struct mlx5_hlist *mreg_cp_tbl;/* Hash table of Rx metadata register copy table. */ +struct mlx5_mtr_config mtr_config;/* Meter configuration */ uint8_t mtr_sfx_reg;/* Meter prefix-suffix flow match REG_C. */ uint8_t mtr_color_reg;/* Meter color match REG_C. */ struct mlx5_legacy_flow_meters flow_meters;/* MTR list. */ struct mlx5_l3t_tbl *mtr_profile_tbl;/* Meter index lookup table. */ +struct mlx5_flow_meter_profile *mtr_profile_arr;/* Profile array. */ struct mlx5_l3t_tbl *policy_idx_tbl;/* Policy index lookup table. */ +struct mlx5_flow_meter_policy *mtr_policy_arr;/* Policy array. */ struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ +struct mlx5_mtr_bulk mtr_bulk;/* Meter index mapping for HWS */ uint8_t skip_default_rss_reta;/* Skip configuration of default reta. */ uint8_t fdb_def_rule;/* Whether fdb jump to table 1 is configured. */ struct mlx5_mp_id mp_id;/* ID of a multi-process process */
@@ -1557,13 +1606,13 @@ struct mlx5_priv {struct mlx5_flex_item flex_item[MLX5_PORT_FLEX_ITEM_NUM ];/* Flex items have been created on the port. */ uint32_t flex_item_map;/* Map of allocated flex item elements. */ +uint32_t nb_queue;/* HW steering queue number. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )/* Item template list. */ LIST_HEAD(flow_hw_itt, rte_flow_pattern_template) flow_hw_itt;/* Action template list. */ LIST_HEAD(flow_hw_at, rte_flow_actions_template) flow_hw_at;struct mlx5dr_context *dr_ctx;/**< HW steering DR context. */ -uint32_t nb_queue;/* HW steering queue number. */ /* HW steering queue polling mechanism job descriptor LIFO. */ struct mlx5_hw_q *hw_q;/* HW steering rte flow table list header. */
@@ -1579,6 +1628,7 @@ struct mlx5_priv {#define PORT_ID (priv) ((priv)->dev_data->port_id)#define ETH_DEV (priv) (&rte_eth_devices[PORT_ID(priv)]) +#define CTRL_QUEUE_ID (priv) ((priv)->nb_queue - 1)struct rte_hairpin_peer_info {uint32_t qp_id;
@@ -1890,6 +1940,11 @@ void mlx5_pmd_socket_uninit(void);/* mlx5_flow_meter.c */ +int mlx5_flow_meter_init (struct rte_eth_dev *dev, +uint32_t nb_meters, +uint32_t nb_meter_profiles, +uint32_t nb_meter_policies); +void mlx5_flow_meter_uninit (struct rte_eth_dev *dev);int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg);struct mlx5_flow_meter_info *mlx5_flow_meter_find (struct mlx5_priv *priv,uint32_t meter_id,uint32_t *mtr_idx);
@@ -1964,7 +2019,7 @@ int mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh);void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh,enum mlx5_access_aso_opc_mod aso_opc_mod);int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh, -struct mlx5_aso_mtr *mtr); +struct mlx5_aso_mtr *mtr,struct mlx5_mtr_bulk *bulk);int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh,struct mlx5_aso_mtr *mtr); int mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh,
drivers/net/mlx5/mlx5_flow.c +71 -0
83 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +50 -0
86 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_aso.c +19 -11
@@ -642,7 +642,8 @@ mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh)static uint16_t mlx5_aso_mtr_sq_enqueue_single (struct mlx5_dev_ctx_shared *sh,struct mlx5_aso_sq *sq, -struct mlx5_aso_mtr *aso_mtr) +struct mlx5_aso_mtr *aso_mtr, +struct mlx5_mtr_bulk *bulk) {volatile struct mlx5_aso_wqe *wqe =NULL ;struct mlx5_flow_meter_info *fm =NULL ;
@@ -653,6 +654,7 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_dev_ctx_shared *sh,uint32_t dseg_idx =0 ;struct mlx5_aso_mtr_pool *pool =NULL ;uint32_t param_le; +int id;rte_spinlock_lock (&sq->sqsl); res = size - (uint16_t )(sq->head - sq->tail);
@@ -666,14 +668,19 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_dev_ctx_shared *sh,/* Fill next WQE. */ fm = &aso_mtr->fm; sq->elts[sq->head & mask].mtr = aso_mtr; - pool = container_of(aso_mtr, struct mlx5_aso_mtr_pool, - mtrs[aso_mtr->offset]); - wqe->general_cseg.misc =rte_cpu_to_be_32 (pool->devx_obj->id + - (aso_mtr->offset >>1 )); - wqe->general_cseg.opcode =rte_cpu_to_be_32 (MLX5_OPCODE_ACCESS_ASO | - (ASO_OPC_MOD_POLICER << -WQE_CSEG_OPC_MOD_OFFSET ) | - sq->pi <<WQE_CSEG_WQE_INDEX_OFFSET ); +if (aso_mtr->type ==ASO_METER_INDIRECT ) { + pool = container_of(aso_mtr, struct mlx5_aso_mtr_pool, + mtrs[aso_mtr->offset]); + id = pool->devx_obj->id; + }else { + id = bulk->devx_obj->id; + } + wqe->general_cseg.misc =rte_cpu_to_be_32 (id + + (aso_mtr->offset >>1 )); + wqe->general_cseg.opcode = +rte_cpu_to_be_32 (MLX5_OPCODE_ACCESS_ASO | + (ASO_OPC_MOD_POLICER <<WQE_CSEG_OPC_MOD_OFFSET ) | + sq->pi <<WQE_CSEG_WQE_INDEX_OFFSET );/* There are 2 meters in one ASO cache line. */ dseg_idx = aso_mtr->offset &0x1 ; wqe->aso_cseg.data_mask =
@@ -811,14 +818,15 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)*/ int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh, -struct mlx5_aso_mtr *mtr) +struct mlx5_aso_mtr *mtr, +struct mlx5_mtr_bulk *bulk) {struct mlx5_aso_sq *sq = &sh->mtrmng->pools_mng.sq;uint32_t poll_wqe_times =MLX5_MTR_POLL_WQE_CQE_TIMES ; do { mlx5_aso_mtr_completion_handle(sq); - if (mlx5_aso_mtr_sq_enqueue_single(sh, sq, mtr)) + if (mlx5_aso_mtr_sq_enqueue_single(sh, sq, mtr, bulk)) return 0; /* Waiting for wqe resource. */ rte_delay_us_sleep(MLX5_ASO_WQE_CQE_RESPONSE_DELAY);
drivers/net/mlx5/mlx5_flow_dv.c +0 -25
@@ -216,31 +216,6 @@ flow_dv_attr_init(const struct rte_flow_item *item, union flow_dv_attr *attr, attr->valid =1 ; } -/* -* Convert rte_mtr_color to mlx5 color. -* -* @param[in] rcol -* rte_mtr_color. -* -* @return -* mlx5 color. -*/ -static inline int -rte_col_2_mlx5_col (enum rte_color rcol) -{ -switch (rcol) { -case RTE_COLOR_GREEN : -return MLX5_FLOW_COLOR_GREEN ; -case RTE_COLOR_YELLOW : -return MLX5_FLOW_COLOR_YELLOW ; -case RTE_COLOR_RED : -return MLX5_FLOW_COLOR_RED ; -default : -break ; - } -return MLX5_FLOW_COLOR_UNDEFINED ; -} -struct field_modify_info modify_eth[] = { {4 ,0 ,MLX5_MODI_OUT_DMAC_47_16 }, {2 ,4 ,MLX5_MODI_OUT_DMAC_15_0 },
drivers/net/mlx5/mlx5_flow_hw.c +256 -8
353 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +688 -14
807 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 8/17 net/mlx5: add HW steering counter action
In reply to Suanming MouFrom: Xiaoyu Min <[email protected]>
This commit adds HW steering counter action support.
Pool mechanism is the basic data structure for the HW steering counter.
The HW steering's counter pool is based on the rte_ring of zero-copy variation.
There are two global rte_rings:
1. free_list:
Store the counters indexes, which are ready for use.
2. wait_reset_list:
Store the counters indexes, which are just freed from the user and need to query the hardware counter to get the reset value before this counter can be reused again.
The counter pool also supports cache per HW steering's queues, which are also based on rte_ring of zero-copy variation.
The cache can be configured in size, preload, threshold, and fetch size, they are all exposed via device args.
The main operations of the counter pool are as follows:
- Get one counter from the pool:
1. The user call _get_* API.
2. If the cache is enabled, dequeue one counter index from the local cache:
2.A: if the dequeued one from the local cache is still in reset
status (counter's query_gen_when_free is equal to pool's query gen):
I. Flush all counters in local cache back to global
wait_reset_list.
II. Fetch _fetch_sz_ counters into the cache from the global
free list.
III. Fetch one counter from the cache.
3. If the cache is empty, fetch _fetch_sz_ counters from the global free list into the cache and fetch one counter from the cache.
- Free one counter into the pool:
1. The user calls _put_* API.
2. Put the counter into the local cache.
3. If the local cache is full:
3.A: Write back all counters above _threshold_ into the global
wait_reset_list.
3.B: Also, write back this counter into the global wait_reset_list.
When the local cache is disabled, _get_/_put_ cache directly from/into global list.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 50 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 27 ++ drivers/common/mlx5/mlx5_prm.h | 62 ++- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 14 + drivers/net/mlx5/mlx5.h | 27 ++ drivers/net/mlx5/mlx5_defs.h | 2 + drivers/net/mlx5/mlx5_flow.c | 27 +- drivers/net/mlx5/mlx5_flow.h | 5 + drivers/net/mlx5/mlx5_flow_aso.c | 261 ++++++++++++- drivers/net/mlx5/mlx5_flow_hw.c | 340 +++++++++++++++- drivers/net/mlx5/mlx5_hws_cnt.c | 528 +++++++++++++++++++++++++ drivers/net/mlx5/mlx5_hws_cnt.h | 558 +++++++++++++++++++++++++++ 14 files changed, 1871 insertions(+), 32 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.c create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.h
drivers/common/mlx5/mlx5_devx_cmds.c +50 -0
@@ -176,6 +176,41 @@ mlx5_devx_cmd_register_write(void *ctx, uint16_t reg_id, uint32_t arg,return 0 ; } +struct mlx5_devx_obj * +mlx5_devx_cmd_flow_counter_alloc_general (void *ctx, +struct mlx5_devx_counter_attr *attr) +{ +struct mlx5_devx_obj *dcs =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*dcs), +0 ,SOCKET_ID_ANY ); +uint32_t in[MLX5_ST_SZ_DW (alloc_flow_counter_in)] = {0 }; +uint32_t out[MLX5_ST_SZ_DW (alloc_flow_counter_out)] = {0 }; + +if (!dcs) { + rte_errno =ENOMEM ; +return NULL ; + } +MLX5_SET (alloc_flow_counter_in, in, opcode, +MLX5_CMD_OP_ALLOC_FLOW_COUNTER ); +if (attr->bulk_log_max_alloc) +MLX5_SET (alloc_flow_counter_in, in, flow_counter_bulk_log_size, + attr->flow_counter_bulk_log_size); +else +MLX5_SET (alloc_flow_counter_in, in, flow_counter_bulk, + attr->bulk_n_128); +if (attr->pd_valid) +MLX5_SET (alloc_flow_counter_in, in, pd, attr->pd); + dcs->obj = mlx5_glue->devx_obj_create (ctx, in, +sizeof (in), out,sizeof (out)); +if (!dcs->obj) { +DRV_LOG (ERR ,"Can't allocate counters - error %d" , errno); + rte_errno = errno; +mlx5_free (dcs); +return NULL ; + } + dcs->id =MLX5_GET (alloc_flow_counter_out, out, flow_counter_id); +return dcs; +} +/** * Allocate flow counters via devx interface. *
@@ -967,6 +1002,16 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, general_obj_types) & MLX5_GENERAL_OBJ_TYPES_CAP_CONN_TRACK_OFFLOAD); attr->rq_delay_drop =MLX5_GET (cmd_hca_cap, hcattr, rq_delay_drop); + attr->max_flow_counter_15_0 =MLX5_GET (cmd_hca_cap, hcattr, + max_flow_counter_15_0); + attr->max_flow_counter_31_16 =MLX5_GET (cmd_hca_cap, hcattr, + max_flow_counter_31_16); + attr->alloc_flow_counter_pd =MLX5_GET (cmd_hca_cap, hcattr, + alloc_flow_counter_pd); + attr->flow_counter_access_aso =MLX5_GET (cmd_hca_cap, hcattr, + flow_counter_access_aso); + attr->flow_access_aso_opc_mod =MLX5_GET (cmd_hca_cap, hcattr, + flow_access_aso_opc_mod);if (attr->crypto) { attr->aes_xts =MLX5_GET (cmd_hca_cap, hcattr, aes_xts); hcattr = mlx5_devx_get_hca_cap(ctx, in, out, &rc,
@@ -989,6 +1034,11 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, } attr->log_min_stride_wqe_sz =MLX5_GET (cmd_hca_cap_2, hcattr, log_min_stride_wqe_sz); + attr->flow_counter_bulk_log_max_alloc =MLX5_GET (cmd_hca_cap_2, + hcattr, flow_counter_bulk_log_max_alloc); + attr->flow_counter_bulk_log_granularity = +MLX5_GET (cmd_hca_cap_2, hcattr, + flow_counter_bulk_log_granularity); }if (attr->log_min_stride_wqe_sz ==0 ) attr->log_min_stride_wqe_sz =MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE ;
drivers/common/mlx5/mlx5_devx_cmds.h +27 -0
@@ -15,6 +15,16 @@#define MLX5_DEVX_MAX_KLM_ENTRIES ((UINT16_MAX - \ MLX5_ST_SZ_DW(create_mkey_in) * 4) / (MLX5_ST_SZ_DW(klm) * 4)) +struct mlx5_devx_counter_attr { +uint32_t pd_valid:1 ; +uint32_t pd:24 ; +uint32_t bulk_log_max_alloc:1 ; +union { +uint8_t flow_counter_bulk_log_size; +uint8_t bulk_n_128; + }; +}; +struct mlx5_devx_mkey_attr {uint64_t addr;uint64_t size;
@@ -263,6 +273,18 @@ struct mlx5_hca_attr { uint32_t set_reg_c:8; uint32_t nic_flow_table:1; uint32_t modify_outer_ip_ecn:1; +union { +uint32_t max_flow_counter; +struct { +uint16_t max_flow_counter_15_0; +uint16_t max_flow_counter_31_16; + }; + }; + uint32_t flow_counter_bulk_log_max_alloc:5; + uint32_t flow_counter_bulk_log_granularity:5; + uint32_t alloc_flow_counter_pd:1; + uint32_t flow_counter_access_aso:1; + uint32_t flow_access_aso_opc_mod:8; };/* LAG Context. */
@@ -593,6 +615,11 @@ struct mlx5_devx_crypto_login_attr {/* mlx5_devx_cmds.c */ +__rte_internal +struct mlx5_devx_obj * +mlx5_devx_cmd_flow_counter_alloc_general (void *ctx, +struct mlx5_devx_counter_attr *attr); +__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_flow_counter_alloc(void *ctx,uint32_t bulk_sz);
drivers/common/mlx5/mlx5_prm.h +57 -5
80 lines not on this page · raw message
drivers/common/mlx5/version.map +1 -0
@@ -40,6 +40,7 @@ INTERNAL { mlx5_devx_cmd_create_virtq; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc; + mlx5_devx_cmd_flow_counter_alloc_general; mlx5_devx_cmd_flow_counter_query; mlx5_devx_cmd_flow_dump; mlx5_devx_cmd_flow_single_dump;
drivers/net/mlx5/meson.build +1 -0
@@ -38,6 +38,7 @@ sources = files( 'mlx5_vlan.c', 'mlx5_utils.c', 'mlx5_devx.c', + 'mlx5_hws_cnt.c', ) if is_linux
drivers/net/mlx5/mlx5.c +14 -0
@@ -175,6 +175,12 @@/* Device parameter to create the fdb default rule in PMD */ #define MLX5_FDB_DEFAULT_RULE_EN "fdb_def_rule_en" +/* HW steering counter configuration. */ +#define MLX5_HWS_CNT_SERVICE_CORE "service_core" + +/* HW steering counter's query interval. */ +#define MLX5_HWS_CNT_CYCLE_TIME "svc_cycle_time" +/* Shared memory between primary and secondary processes. */ struct mlx5_shared_data *mlx5_shared_data;
@@ -1245,6 +1251,10 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque) config->allow_duplicate_pattern = !!tmp; }else if (strcmp (MLX5_FDB_DEFAULT_RULE_EN , key) ==0 ) { config->fdb_def_rule = !!tmp; + }else if (strcmp (MLX5_HWS_CNT_SERVICE_CORE , key) ==0 ) { + config->cnt_svc.service_core = tmp; + }else if (strcmp (MLX5_HWS_CNT_CYCLE_TIME , key) ==0 ) { + config->cnt_svc.cycle_time = tmp; }return 0 ; }
@@ -1281,6 +1291,8 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,MLX5_DECAP_EN ,MLX5_ALLOW_DUPLICATE_PATTERN ,MLX5_FDB_DEFAULT_RULE_EN , +MLX5_HWS_CNT_SERVICE_CORE , +MLX5_HWS_CNT_CYCLE_TIME , NULL, };int ret =0 ;
@@ -1293,6 +1305,8 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->decap_en =1 ; config->allow_duplicate_pattern =1 ; config->fdb_def_rule =1 ; + config->cnt_svc.cycle_time =MLX5_CNT_SVC_CYCLE_TIME_DEFAULT ; + config->cnt_svc.service_core =rte_get_main_lcore ();if (mkvlist !=NULL ) {/* Process parameters. */ ret = mlx5_kvargs_process(mkvlist, params,
drivers/net/mlx5/mlx5.h +27 -0
@@ -308,6 +308,10 @@ struct mlx5_sh_config { uint32_t hw_fcs_strip:1; /* FCS stripping is supported. */ uint32_t allow_duplicate_pattern:1; uint32_t lro_allowed:1; /* Whether LRO is allowed. */ +struct { +uint16_t service_core; +uint32_t cycle_time;/* query cycle time in milli-second. */ + } cnt_svc;/* configure for HW steering's counter's service. */ /* Allow/Prevent the duplicate rules pattern. */ uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ };
@@ -1224,6 +1228,22 @@ struct mlx5_flex_item {struct mlx5_flex_pattern_field map[MLX5_FLEX_ITEM_MAPPING_NUM ]; }; +#define HWS_CNT_ASO_SQ_NUM 4 + +struct mlx5_hws_aso_mng { +uint16_t sq_num; +struct mlx5_aso_sq sqs[HWS_CNT_ASO_SQ_NUM ]; +}; + +struct mlx5_hws_cnt_svc_mng { +uint32_t refcnt; +uint32_t service_core; +uint32_t query_interval; +pthread_t service_thread; +uint8_t svc_running; + struct mlx5_hws_aso_mng aso_mng __rte_cache_aligned; +}; +/* * Shared Infiniband device context for Master/Representors * which belong to same IB device with multiple IB ports.
@@ -1323,6 +1343,7 @@ struct mlx5_dev_ctx_shared {pthread_mutex_t lwm_config_lock; uint32_t host_shaper_rate:8; uint32_t lwm_triggered:1; +struct mlx5_hws_cnt_svc_mng *cnt_svc;struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1607,6 +1628,7 @@ struct mlx5_priv {/* Flex items have been created on the port. */ uint32_t flex_item_map;/* Map of allocated flex item elements. */ uint32_t nb_queue;/* HW steering queue number. */ +struct mlx5_hws_cnt_pool *hws_cpool;/* HW steering's counter pool. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )/* Item template list. */ LIST_HEAD(flow_hw_itt, rte_flow_pattern_template) flow_hw_itt;
@@ -2037,6 +2059,11 @@ mlx5_get_supported_sw_parsing_offloads(const struct mlx5_hca_attr *attr);uint32_t mlx5_get_supported_tunneling_offloads (const struct mlx5_hca_attr *attr); +int mlx5_aso_cnt_queue_init (struct mlx5_dev_ctx_shared *sh); +void mlx5_aso_cnt_queue_uninit (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_cnt_query (struct mlx5_dev_ctx_shared *sh, +struct mlx5_hws_cnt_pool *cpool); +/* mlx5_flow_flex.c */ struct rte_flow_item_flex_handle *
drivers/net/mlx5/mlx5_defs.h +2 -0
@@ -188,4 +188,6 @@#define static_assert _Static_assert#endif +#define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#endif /* RTE_PMD_MLX5_DEFS_H_ */
drivers/net/mlx5/mlx5_flow.c +15 -12
@@ -7832,24 +7832,33 @@ mlx5_flow_isolate(struct rte_eth_dev *dev,*/ static int flow_drv_query (struct rte_eth_dev *dev, -uint32_t flow_idx, +struct rte_flow *eflow,const struct rte_flow_action *actions,void *data,struct rte_flow_error *error) {struct mlx5_priv *priv = dev->data->dev_private;const struct mlx5_flow_driver_ops *fops; -struct rte_flow *flow =mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], - flow_idx); -enum mlx5_flow_drv_type ftype; +struct rte_flow *flow =NULL ; +enum mlx5_flow_drv_type ftype =MLX5_FLOW_TYPE_MIN ; +if (priv->sh->config.dv_flow_en ==2 ) { +#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H ) + flow = eflow; + ftype =MLX5_FLOW_TYPE_HW ; +#endif + }else { + flow = (struct rte_flow *)mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], + (uintptr_t )(void *)eflow); + }if (!flow) {return rte_flow_error_set (error,ENOENT ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL ,"invalid flow handle" ); } - ftype = flow->drv_type; +if (ftype ==MLX5_FLOW_TYPE_MIN ) + ftype = flow->drv_type;MLX5_ASSERT (ftype >MLX5_FLOW_TYPE_MIN && ftype <MLX5_FLOW_TYPE_MAX ); fops =flow_get_drv_ops (ftype);
@@ -7870,14 +7879,8 @@ mlx5_flow_query(struct rte_eth_dev *dev, struct rte_flow_error *error) {int ret; -struct mlx5_priv *priv = dev->data->dev_private; -if (priv->sh->config.dv_flow_en ==2 ) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"Flow non-Q query not supported" ); - ret =flow_drv_query (dev, (uintptr_t )(void *)flow, actions, data, + ret =flow_drv_query (dev, flow, actions, data, error);if (ret <0 )return ret;
drivers/net/mlx5/mlx5_flow.h +5 -0
@@ -1103,6 +1103,7 @@ struct rte_flow_hw { };struct rte_flow_template_table *table;/* The table flow allcated from. */ struct mlx5dr_rule rule;/* HWS layer data struct. */ +uint32_t cnt_id; } __rte_packed;/* rte flow action translate to DR action struct. */
@@ -1146,6 +1147,9 @@ struct mlx5_action_construct_data {uint32_t level;/* RSS level. */ uint32_t idx;/* Shared action index. */ } shared_rss; +struct { +uint32_t id; + } shared_counter; }; };
@@ -1224,6 +1228,7 @@ struct mlx5_hw_actions {uint16_t encap_decap_pos;/* Encap/Decap action position. */ uint32_t acts_num:4; /* Total action number. */ uint32_t mark:1; /* Indicate the mark action. */ +uint32_t cnt_id;/* Counter id. */ /* Translated DR action array from action template. */ struct mlx5dr_rule_action rule_acts[MLX5_HW_MAX_ACTS ]; };
drivers/net/mlx5/mlx5_flow_aso.c +254 -7
309 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +332 -8
460 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.c new file +528 -0
528 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h new file +558 -0
558 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 9/17 net/mlx5: support DR action template API
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch adapts mlx5 PMD to changes in mlx5dr API regarding action templates. It changes the following:
1. Actions template creation:
- Flow actions types are translated to mlx5dr action types in order to create mlx5dr_action_template object.
- An offset is assigned to each flow action. This offset is used to predetermine action's location in rule_acts array passed on rule creation.
2. Template table creation:
- Fixed actions are created and put in rule_acts cache using predetermined offsets
- mlx5dr matcher is parametrized by action templates bound to template table.
- mlx5dr matcher is configured to optimize rule creation based on passed rule indices.
3. Flow rule creation:
- mlx5dr rule is parametrized by action template on which these rule's actions are based.
- Rule index hint is provided to mlx5dr.
--- drivers/net/mlx5/linux/mlx5_os.c | 1 + drivers/net/mlx5/mlx5.c | 4 +- drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow.h | 30 +- drivers/net/mlx5/mlx5_flow_hw.c | 617 +++++++++++++++++++++++++------ drivers/net/mlx5/mlx5_trigger.c | 10 + 6 files changed, 541 insertions(+), 123 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +1 -0
@@ -1565,6 +1565,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, }/* Only HWS requires this information. */ flow_hw_init_tags_set (eth_dev); +flow_hw_init_flow_metadata_config (eth_dev);if (priv->sh->config.dv_esw_en &&flow_hw_create_vport_action (eth_dev)) { DRV_LOG(ERR, "port %u failed to create vport action",
drivers/net/mlx5/mlx5.c +3 -1
@@ -1969,8 +1969,10 @@ mlx5_dev_close(struct rte_eth_dev *dev)flow_hw_destroy_vport_action (dev);flow_hw_resource_release (dev);flow_hw_clear_port_info (dev); -if (priv->sh->config.dv_flow_en ==2 ) +if (priv->sh->config.dv_flow_en ==2 ) { +flow_hw_clear_flow_metadata_config ();flow_hw_clear_tags_set (dev); + }#endif if (priv->rxq_privs !=NULL ) {/* XXX race condition if mlx5_rx_burst() is still running. */
drivers/net/mlx5/mlx5.h +2 -0
@@ -1644,6 +1644,8 @@ struct mlx5_priv {struct mlx5dr_action *hw_drop[2 ];/* HW steering global tag action. */ struct mlx5dr_action *hw_tag[2 ]; +/* HW steering create ongoing rte flow table list header. */ + LIST_HEAD(flow_hw_tbl_ongo, rte_flow_template_table) flow_hw_tbl_ongo;struct mlx5_indexed_pool *acts_ipool;/* Action data indexed pool. */ #endif };
drivers/net/mlx5/mlx5_flow.h +28 -2
@@ -1175,6 +1175,11 @@ struct rte_flow_actions_template {struct rte_flow_actions_template_attr attr;struct rte_flow_action *actions;/* Cached flow actions. */ struct rte_flow_action *masks;/* Cached action masks.*/ +struct mlx5dr_action_template *tmpl;/* mlx5dr action template. */ +uint16_t dr_actions_num;/* Amount of DR rules actions. */ +uint16_t actions_num;/* Amount of flow actions */ +uint16_t *actions_off;/* DR action offset for given rte action offset. */ +uint16_t reformat_off;/* Offset of DR reformat action. */ uint16_t mhdr_off;/* Offset of DR modify header action. */ uint32_t refcnt;/* Reference counter. */ uint16_t rx_cpy_pos;/* Action position of Rx metadata to be copied. */
@@ -1226,7 +1231,6 @@ struct mlx5_hw_actions {/* Encap/Decap action. */ struct mlx5_hw_encap_decap_action *encap_decap;uint16_t encap_decap_pos;/* Encap/Decap action position. */ - uint32_t acts_num:4; /* Total action number. */ uint32_t mark:1; /* Indicate the mark action. */uint32_t cnt_id;/* Counter id. */ /* Translated DR action array from action template. */
@@ -1482,6 +1486,13 @@ flow_hw_get_wire_port(struct ibv_context *ibctx) }#endif +extern uint32_t mlx5_flow_hw_flow_metadata_config_refcnt; +extern uint8_t mlx5_flow_hw_flow_metadata_esw_en; +extern uint8_t mlx5_flow_hw_flow_metadata_xmeta_en; + +void flow_hw_init_flow_metadata_config (struct rte_eth_dev *dev); +void flow_hw_clear_flow_metadata_config (void ); +/* * Convert metadata or tag to the actual register. * META: Can only be used to match in the FDB in this stage, fixed C_1.
@@ -1493,7 +1504,20 @@ flow_hw_get_reg_id(enum rte_flow_item_type type, uint32_t id) {switch (type) {case RTE_FLOW_ITEM_TYPE_META : -return REG_C_1 ; +if (mlx5_flow_hw_flow_metadata_esw_en && + mlx5_flow_hw_flow_metadata_xmeta_en ==MLX5_XMETA_MODE_META32_HWS ) { +return REG_C_1 ; + } +/* +* On root table - PMD allows only egress META matching, thus +* REG_A matching is sufficient. +* +* On non-root tables - REG_A corresponds to general_purpose_lookup_field, +* which translates to REG_A in NIC TX and to REG_B in NIC RX. +* However, current FW does not implement REG_B case right now, so +* REG_B case should be rejected on pattern template validation. +*/ +return REG_A ;case RTE_FLOW_ITEM_TYPE_TAG :MLX5_ASSERT (id <MLX5_FLOW_HW_TAGS_MAX );return mlx5_flow_hw_avl_tags[id];
@@ -2402,4 +2426,6 @@ int mlx5_flow_pattern_validate(struct rte_eth_dev *dev,const struct rte_flow_pattern_template_attr *attr, const struct rte_flow_item items[], struct rte_flow_error *error); +int flow_hw_table_update (struct rte_eth_dev *dev, +struct rte_flow_error *error);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_hw.c +497 -120
1,068 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +10 -0
@@ -1170,6 +1170,16 @@ mlx5_dev_start(struct rte_eth_dev *dev) dev->data->port_id, rte_strerror(rte_errno)); goto error; } +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) { + ret =flow_hw_table_update (dev,NULL ); +if (ret) { +DRV_LOG (ERR ,"port %u failed to update HWS tables" , + dev->data->port_id); + goto error; + } + } +#endif ret =mlx5_traffic_enable (dev);if (ret) { DRV_LOG(ERR, "port %u failed to set defaults flows",
Signature · 1 line
2.25.1
PATCH v3 10/17 net/mlx5: add HW steering connection tracking support
In reply to Suanming MouThis commit adds the support of connection tracking to HW steering as SW steering did before.
Different with SW steering implementation, take advantage of HW steering bulk action allocation support, in HW steering only one single CT pool is needed.
An indexed pool is introduced to record allocated actions from bulk and CT action state etc. Once one CT action is allocated from bulk, one indexed object will also be allocated from the indexed pool, similar for deallocate. That makes mlx5_aso_ct_action can also be managed by that indexed pool, no need to be reserved from mlx5_aso_ct_pool. The single CT pool is also saved to mlx5_aso_ct_action struct directly.
The ASO operation functions are shared with SW steering implementation.
--- drivers/net/mlx5/linux/mlx5_os.c | 8 +- drivers/net/mlx5/mlx5.c | 3 +- drivers/net/mlx5/mlx5.h | 54 ++++- drivers/net/mlx5/mlx5_flow.c | 1 + drivers/net/mlx5/mlx5_flow.h | 7 + drivers/net/mlx5/mlx5_flow_aso.c | 212 +++++++++++++---- drivers/net/mlx5/mlx5_flow_dv.c | 28 ++- drivers/net/mlx5/mlx5_flow_hw.c | 381 ++++++++++++++++++++++++++++++- 8 files changed, 617 insertions(+), 77 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +5 -3
@@ -1349,9 +1349,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,DRV_LOG (DEBUG ,"Flow Hit ASO is supported." ); }#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ -#if defined(HAVE_MLX5_DR_CREATE_ACTION_ASO ) && \ - defined(HAVE_MLX5_DR_ACTION_ASO_CT ) -if (hca_attr->ct_offload && priv->mtr_color_reg ==REG_C_3 ) { +#if defined (HAVE_MLX5_DR_CREATE_ACTION_ASO ) && \ + defined (HAVE_MLX5_DR_ACTION_ASO_CT ) +/* HWS create CT ASO SQ based on HWS configure queue number. */ +if (sh->config.dv_flow_en !=2 && + hca_attr->ct_offload && priv->mtr_color_reg ==REG_C_3 ) { err =mlx5_flow_aso_ct_mng_init (sh);if (err) { err = -err;
drivers/net/mlx5/mlx5.c +2 -1
@@ -755,7 +755,8 @@ mlx5_flow_aso_ct_mng_init(struct mlx5_dev_ctx_shared *sh)if (sh->ct_mng)return 0 ; - sh->ct_mng =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*sh->ct_mng), + sh->ct_mng =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*sh->ct_mng) + +sizeof (struct mlx5_aso_sq ) *MLX5_ASO_CT_SQ_NUM ,RTE_CACHE_LINE_SIZE ,SOCKET_ID_ANY );if (!sh->ct_mng) {DRV_LOG (ERR ,"ASO CT management allocation failed." );
drivers/net/mlx5/mlx5.h +44 -10
120 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.c +1 -0
@@ -49,6 +49,7 @@ struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS];*/ uint32_t mlx5_flow_hw_avl_tags_init_cnt;enum modify_reg mlx5_flow_hw_avl_tags[MLX5_FLOW_HW_TAGS_MAX ] = {REG_NON }; +enum modify_reg mlx5_flow_hw_aso_tag;struct tunnel_default_miss_ctx {uint16_t *queue;
drivers/net/mlx5/mlx5_flow.h +7 -0
@@ -82,6 +82,10 @@ enum {#define MLX5_INDIRECT_ACT_CT_GET_IDX (index) \ ((index) & ((1 << MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) - 1)) +#define MLX5_ACTION_CTX_CT_GET_IDX MLX5_INDIRECT_ACT_CT_GET_IDX +#define MLX5_ACTION_CTX_CT_GET_OWNER MLX5_INDIRECT_ACT_CT_GET_OWNER +#define MLX5_ACTION_CTX_CT_GEN_IDX MLX5_INDIRECT_ACT_CT_GEN_IDX +/* Matches on selected register. */ struct mlx5_rte_flow_item_tag {enum modify_reg id;
@@ -1444,6 +1448,7 @@ extern struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS];#define MLX5_FLOW_HW_TAGS_MAX 8extern uint32_t mlx5_flow_hw_avl_tags_init_cnt;extern enum modify_reg mlx5_flow_hw_avl_tags[]; +extern enum modify_reg mlx5_flow_hw_aso_tag;/* * Get metadata match tag and mask for given rte_eth_dev port.
@@ -1518,6 +1523,8 @@ flow_hw_get_reg_id(enum rte_flow_item_type type, uint32_t id)* REG_B case should be rejected on pattern template validation. */ return REG_A ; +case RTE_FLOW_ITEM_TYPE_CONNTRACK : +return mlx5_flow_hw_aso_tag;case RTE_FLOW_ITEM_TYPE_TAG :MLX5_ASSERT (id <MLX5_FLOW_HW_TAGS_MAX );return mlx5_flow_hw_avl_tags[id];
drivers/net/mlx5/mlx5_flow_aso.c +162 -50
415 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +18 -10
@@ -12813,6 +12813,7 @@ flow_dv_ct_pool_create(struct rte_eth_dev *dev,struct mlx5_devx_obj *obj =NULL ;uint32_t i;uint32_t log_obj_size =rte_log2_u32 (MLX5_ASO_CT_ACTIONS_PER_POOL ); +size_t mem_size; obj = mlx5_devx_cmd_create_conn_track_offload_obj(priv->sh->cdev->ctx, priv->sh->cdev->pdn,
@@ -12822,7 +12823,10 @@ flow_dv_ct_pool_create(struct rte_eth_dev *dev,DRV_LOG (ERR ,"Failed to create conn_track_offload_obj using DevX." );return NULL ; } - pool =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*pool),0 ,SOCKET_ID_ANY ); + mem_size =sizeof (struct mlx5_aso_ct_action ) * +MLX5_ASO_CT_ACTIONS_PER_POOL + +sizeof (*pool); + pool =mlx5_malloc (MLX5_MEM_ZERO , mem_size,0 ,SOCKET_ID_ANY );if (!pool) { rte_errno =ENOMEM ;claim_zero (mlx5_devx_cmd_destroy (obj));
@@ -12962,10 +12966,13 @@ flow_dv_translate_create_conntrack(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Failed to allocate CT object"); ct =flow_aso_ct_get_by_dev_idx (dev, idx); -if (mlx5_aso_ct_update_by_wqe (sh, ct, pro)) -return rte_flow_error_set (error,EBUSY , -RTE_FLOW_ERROR_TYPE_ACTION ,NULL , -"Failed to update CT" ); +if (mlx5_aso_ct_update_by_wqe (sh,MLX5_HW_INV_QUEUE , ct, pro)) { +flow_dv_aso_ct_dev_release (dev, idx); +rte_flow_error_set (error,EBUSY , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Failed to update CT" ); +return 0 ; + } ct->is_original = !!pro->is_original_dir; ct->peer = pro->peer_port;return idx;
@@ -14160,7 +14167,7 @@ flow_dv_translate(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Failed to get CT object."); -if (mlx5_aso_ct_available (priv->sh, ct)) +if (mlx5_aso_ct_available (priv->sh,MLX5_HW_INV_QUEUE , ct)) return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -15768,14 +15775,15 @@ __flow_dv_action_ct_update(struct rte_eth_dev *dev, uint32_t idx, ret =mlx5_validate_action_ct (dev, new_prf, error);if (ret)return ret; - ret =mlx5_aso_ct_update_by_wqe (priv->sh, ct, new_prf); + ret =mlx5_aso_ct_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , + ct, new_prf);if (ret)return rte_flow_error_set (error,EIO ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL ,"Failed to send CT context update WQE" ); -/* Block until ready or a failure. */ - ret =mlx5_aso_ct_available (priv->sh, ct); +/* Block until ready or a failure, default is asynchronous. */ + ret =mlx5_aso_ct_available (priv->sh,MLX5_HW_INV_QUEUE , ct);if (ret) rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -16604,7 +16612,7 @@ flow_dv_action_query(struct rte_eth_dev *dev, ct->peer; ((struct rte_flow_action_conntrack *)data)->is_original_dir = ct->is_original; -if (mlx5_aso_ct_query_by_wqe (priv->sh, ct, data)) +if (mlx5_aso_ct_query_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , ct, data)) return rte_flow_error_set(error, EIO, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
drivers/net/mlx5/mlx5_flow_hw.c +378 -3
546 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 11/17 net/mlx5: add HW steering VLAN push, pop and VID modify flow actions
In reply to Suanming MouFrom: Gregory Etelson <[email protected]>
Add PMD implementation for HW steering VLAN push, pop and modify flow actions.
HWS VLAN push flow action is triggered by a sequence of mandatory OF_PUSH_VLAN, OF_SET_VLAN_VID and optional OF_SET_VLAN_PCP flow actions commands.
The commands must be arranged in the exact order:OF_PUSH_VLAN / OF_SET_VLAN_VID [ / OF_SET_VLAN_PCP ].
In masked HWS VLAN push flow action template *ALL* the above flow actions must be masked.
In non-masked HWS VLAN push flow action template *ALL* the above flow actions must not be masked.
Example:
flow actions_template <port id> create \actions_template_id <action id> \
template \
of_push_vlan / \
of_set_vlan_vid \
[ / of_set_vlan_pcp ] / end \
mask \
of_push_vlan ethertype 0 / \
of_set_vlan_vid vlan_vid 0 \
[ / of_set_vlan_pcp vlan_pcp 0 ] / end\
flow actions_template <port id> create \actions_template_id <action id> \
template \
of_push_vlan ethertype <E>/ \
of_set_vlan_vid vlan_vid <VID>\
[ / of_set_vlan_pcp <PCP>] / end \
mask \
of_push_vlan ethertype <type != 0> / \
of_set_vlan_vid vlan_vid <vid_mask != 0>\
[ / of_set_vlan_pcp vlan_pcp <pcp_mask != 0> ] / end\
HWS VLAN pop flow action is triggered by OF_POP_VLAN flow action command.
HWS VLAN pop action template is always non-masked.
Example:
flow actions_template <port id> create \actions_template_id <action id> \
template of_pop_vlan / end mask of_pop_vlan / end
HWS VLAN VID modify flow action is triggered by a standalone OF_SET_VLAN_VID flow action command.
HWS VLAN VID modify action template can be ether masked or non-masked.
Example:
flow actions_template <port id> create \actions_template_id <action id> \
template of_set_vlan_vid / end mask of_set_vlan_vid vlan_vid 0 / end
flow actions_template <port id> create \actions_template_id <action id> \
template of_set_vlan_vid vlan_vid 0x101 / end \
mask of_set_vlan_vid vlan_vid 0xffff / end
--- drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow.h | 4 + drivers/net/mlx5/mlx5_flow_dv.c | 2 +- drivers/net/mlx5/mlx5_flow_hw.c | 492 +++++++++++++++++++++++++++++--- 4 files changed, 463 insertions(+), 37 deletions(-)
drivers/net/mlx5/mlx5.h +2 -0
@@ -1665,6 +1665,8 @@ struct mlx5_priv {struct mlx5_hw_q *hw_q;/* HW steering rte flow table list header. */ LIST_HEAD(flow_hw_tbl, rte_flow_template_table) flow_hw_tbl; +struct mlx5dr_action *hw_push_vlan[MLX5DR_TABLE_TYPE_MAX ]; +struct mlx5dr_action *hw_pop_vlan[MLX5DR_TABLE_TYPE_MAX ];struct mlx5dr_action **hw_vport;/* HW steering global drop action. */ struct mlx5dr_action *hw_drop[2 ];
drivers/net/mlx5/mlx5_flow.h +4 -0
@@ -2435,4 +2435,8 @@ int mlx5_flow_pattern_validate(struct rte_eth_dev *dev, struct rte_flow_error *error);int flow_hw_table_update (struct rte_eth_dev *dev,struct rte_flow_error *error); +int mlx5_flow_item_field_width (struct rte_eth_dev *dev, +enum rte_flow_field_id field,int inherit, +const struct rte_flow_attr *attr, +struct rte_flow_error *error);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -1326,7 +1326,7 @@ flow_dv_convert_action_modify_ipv6_dscp MLX5_MODIFICATION_TYPE_SET, error); } -static int +int mlx5_flow_item_field_width(struct rte_eth_dev *dev, enum rte_flow_field_id field, int inherit, const struct rte_flow_attr *attr,
drivers/net/mlx5/mlx5_flow_hw.c +456 -36
647 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 12/17 net/mlx5: implement METER MARK indirect action for HWS
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
Add ability to create an indirect action handle for METER_MARK. It allows to share one Meter between several different actions.
--- drivers/net/mlx5/mlx5.c | 4 +- drivers/net/mlx5/mlx5.h | 33 ++- drivers/net/mlx5/mlx5_flow.c | 6 + drivers/net/mlx5/mlx5_flow.h | 19 +- drivers/net/mlx5/mlx5_flow_aso.c | 139 +++++++-- drivers/net/mlx5/mlx5_flow_dv.c | 145 +++++++++- drivers/net/mlx5/mlx5_flow_hw.c | 438 +++++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 79 +++++- 8 files changed, 764 insertions(+), 99 deletions(-)
drivers/net/mlx5/mlx5.c +2 -2
@@ -442,7 +442,7 @@ mlx5_flow_aso_age_mng_init(struct mlx5_dev_ctx_shared *sh) rte_errno =ENOMEM ;return -ENOMEM ; } - err =mlx5_aso_queue_init (sh,ASO_OPC_MOD_FLOW_HIT ); + err =mlx5_aso_queue_init (sh,ASO_OPC_MOD_FLOW_HIT ,1 );if (err) {mlx5_free (sh->aso_age_mng);return -1 ;
@@ -763,7 +763,7 @@ mlx5_flow_aso_ct_mng_init(struct mlx5_dev_ctx_shared *sh) rte_errno =ENOMEM ;return -rte_errno; } - err =mlx5_aso_queue_init (sh,ASO_OPC_MOD_CONNECTION_TRACKING ); + err =mlx5_aso_queue_init (sh,ASO_OPC_MOD_CONNECTION_TRACKING ,MLX5_ASO_CT_SQ_NUM );if (err) {mlx5_free (sh->ct_mng);/* rte_errno should be extracted from the failure. */
drivers/net/mlx5/mlx5.h +26 -7
@@ -971,12 +971,16 @@ enum mlx5_aso_mtr_type {/* Generic aso_flow_meter information. */ struct mlx5_aso_mtr { -LIST_ENTRY (mlx5_aso_mtr) next; +union { +LIST_ENTRY (mlx5_aso_mtr) next; +struct mlx5_aso_mtr_pool *pool; + };enum mlx5_aso_mtr_type type;struct mlx5_flow_meter_info fm;/**< Pointer to the next aso flow meter structure. */ uint8_t state;/**< ASO flow meter state. */ uint32_t offset; +enum rte_color init_color; };/* Generic aso_flow_meter pool structure. */
@@ -985,7 +989,11 @@ struct mlx5_aso_mtr_pool {/*Must be the first in pool*/ struct mlx5_devx_obj *devx_obj;/* The devx object of the minimum aso flow meter ID. */ +struct mlx5dr_action *action;/* HWS action. */ +struct mlx5_indexed_pool *idx_pool;/* HWS index pool. */ uint32_t index;/* Pool index in management structure. */ +uint32_t nb_sq;/* Number of ASO SQ. */ +struct mlx5_aso_sq *sq;/* ASO SQs. */ };LIST_HEAD (aso_meter_list, mlx5_aso_mtr);
@@ -1678,6 +1686,7 @@ struct mlx5_priv {struct mlx5_aso_ct_pools_mng *ct_mng;/* Management data for ASO connection tracking. */ struct mlx5_aso_ct_pool *hws_ctpool;/* HW steering's CT pool. */ +struct mlx5_aso_mtr_pool *hws_mpool;/* HW steering's Meter pool. */ #endif };
@@ -1998,7 +2007,8 @@ void mlx5_pmd_socket_uninit(void);int mlx5_flow_meter_init (struct rte_eth_dev *dev,uint32_t nb_meters,uint32_t nb_meter_profiles, -uint32_t nb_meter_policies); +uint32_t nb_meter_policies, +uint32_t nb_queues);void mlx5_flow_meter_uninit (struct rte_eth_dev *dev);int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg); struct mlx5_flow_meter_info *mlx5_flow_meter_find(struct mlx5_priv *priv,
@@ -2067,15 +2077,24 @@ eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);/* mlx5_flow_aso.c */ +int mlx5_aso_mtr_queue_init (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_mtr_pool *hws_pool, +struct mlx5_aso_mtr_pools_mng *pool_mng, +uint32_t nb_queues); +void mlx5_aso_mtr_queue_uninit (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_mtr_pool *hws_pool, +struct mlx5_aso_mtr_pools_mng *pool_mng);int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh, -enum mlx5_access_aso_opc_mod aso_opc_mod); +enum mlx5_access_aso_opc_mod aso_opc_mode, +uint32_t nb_queues);int mlx5_aso_flow_hit_queue_poll_start (struct mlx5_dev_ctx_shared *sh);int mlx5_aso_flow_hit_queue_poll_stop (struct mlx5_dev_ctx_shared *sh);void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh, -enum mlx5_access_aso_opc_mod aso_opc_mod); -int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh, -struct mlx5_aso_mtr *mtr,struct mlx5_mtr_bulk *bulk); -int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh, +enum mlx5_access_aso_opc_mod aso_opc_mod); +int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh,uint32_t queue, +struct mlx5_aso_mtr *mtr, +struct mlx5_mtr_bulk *bulk); +int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_mtr *mtr); int mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh, uint32_t queue, struct mlx5_aso_ct_action *ct,
drivers/net/mlx5/mlx5_flow.c +6 -0
@@ -4221,6 +4221,12 @@ flow_action_handles_translate(struct rte_eth_dev *dev,MLX5_RTE_FLOW_ACTION_TYPE_COUNT ; translated[handle->index].conf = (void *)(uintptr_t )idx;break ; +case MLX5_INDIRECT_ACTION_TYPE_METER_MARK : + translated[handle->index].type = + (enum rte_flow_action_type ) +MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK ; + translated[handle->index].conf = (void *)(uintptr_t )idx; +break ;case MLX5_INDIRECT_ACTION_TYPE_AGE :if (priv->sh->flow_hit_aso_en) { translated[handle->index].type =
drivers/net/mlx5/mlx5_flow.h +15 -4
@@ -46,6 +46,7 @@ enum mlx5_rte_flow_action_type {MLX5_RTE_FLOW_ACTION_TYPE_COUNT ,MLX5_RTE_FLOW_ACTION_TYPE_JUMP ,MLX5_RTE_FLOW_ACTION_TYPE_RSS , + MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK, };/* Private (internal) Field IDs for MODIFY_FIELD action. */
@@ -54,22 +55,23 @@ enum mlx5_rte_flow_field_id { MLX5_RTE_FLOW_FIELD_META_REG, }; -#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 30 +#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 29enum {MLX5_INDIRECT_ACTION_TYPE_RSS ,MLX5_INDIRECT_ACTION_TYPE_AGE ,MLX5_INDIRECT_ACTION_TYPE_COUNT ,MLX5_INDIRECT_ACTION_TYPE_CT , +MLX5_INDIRECT_ACTION_TYPE_METER_MARK , }; -/* Now, the maximal ports will be supported is 256, action number is 4M. */ -#define MLX5_INDIRECT_ACT_CT_MAX_PORT 0x100 +/* Now, the maximal ports will be supported is 16, action number is 32M. */ +#define MLX5_INDIRECT_ACT_CT_MAX_PORT 0x10#define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 22#define MLX5_INDIRECT_ACT_CT_OWNER_MASK (MLX5_INDIRECT_ACT_CT_MAX_PORT - 1) -/* 30-31: type, 22-29: owner port, 0-21: index. */ +/* 29-31: type, 25-28: owner port, 0-24: index */ #define MLX5_INDIRECT_ACT_CT_GEN_IDX (owner, index) \ ((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | \ (((owner) & MLX5_INDIRECT_ACT_CT_OWNER_MASK) << \
@@ -207,6 +209,9 @@ enum mlx5_feature_name {#define MLX5_FLOW_ITEM_PORT_REPRESENTOR (UINT64_C(1) << 41)#define MLX5_FLOW_ITEM_REPRESENTED_PORT (UINT64_C(1) << 42) +/* Meter color item */ +#define MLX5_FLOW_ITEM_METER_COLOR (UINT64_C(1) << 44) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
@@ -1108,6 +1113,7 @@ struct rte_flow_hw {struct rte_flow_template_table *table;/* The table flow allcated from. */ struct mlx5dr_rule rule;/* HWS layer data struct. */ uint32_t cnt_id; +uint32_t mtr_id; } __rte_packed;/* rte flow action translate to DR action struct. */
@@ -1154,6 +1160,9 @@ struct mlx5_action_construct_data {struct {uint32_t id; } shared_counter; +struct { +uint32_t id; + } shared_meter; }; };
@@ -1237,6 +1246,7 @@ struct mlx5_hw_actions {uint16_t encap_decap_pos;/* Encap/Decap action position. */ uint32_t mark:1; /* Indicate the mark action. */uint32_t cnt_id;/* Counter id. */ +uint32_t mtr_id;/* Meter id. */ /* Translated DR action array from action template. */ struct mlx5dr_rule_action rule_acts[MLX5_HW_MAX_ACTS ]; };
@@ -1524,6 +1534,7 @@ flow_hw_get_reg_id(enum rte_flow_item_type type, uint32_t id)*/ return REG_A ;case RTE_FLOW_ITEM_TYPE_CONNTRACK : +case RTE_FLOW_ITEM_TYPE_METER_COLOR :return mlx5_flow_hw_aso_tag;case RTE_FLOW_ITEM_TYPE_TAG :MLX5_ASSERT (id <MLX5_FLOW_HW_TAGS_MAX );
drivers/net/mlx5/mlx5_flow_aso.c +118 -21
241 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +143 -2
193 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +382 -56
715 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +72 -7
135 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 13/17 net/mlx5: add HWS AGE action support
In reply to Suanming MouFrom: Michael Baum <[email protected]>
Add support for AGE action for HW steering.
This patch includes:
1. Add new structures to manage the aging.
2. Initialize all them in configure function.
3. Implement per second aging check using CNT background thread.
4. Enable AGE action in flow create/destroy operations.
5. Implement queue-based function to report aged flow rules.
--- drivers/net/mlx5/mlx5.c | 67 +- drivers/net/mlx5/mlx5.h | 51 +- drivers/net/mlx5/mlx5_defs.h | 3 + drivers/net/mlx5/mlx5_flow.c | 89 ++- drivers/net/mlx5/mlx5_flow.h | 33 +- drivers/net/mlx5/mlx5_flow_dv.c | 30 +- drivers/net/mlx5/mlx5_flow_hw.c | 1104 ++++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow_verbs.c | 4 +- drivers/net/mlx5/mlx5_hws_cnt.c | 704 +++++++++++++++++- drivers/net/mlx5/mlx5_hws_cnt.h | 193 ++++- 10 files changed, 2013 insertions(+), 265 deletions(-)
drivers/net/mlx5/mlx5.c +47 -20
@@ -497,6 +497,12 @@ mlx5_flow_aging_init(struct mlx5_dev_ctx_shared *sh)uint32_t i;struct mlx5_age_info *age_info; +/* +* In HW steering, aging information structure is initialized later +* during configure function. +*/ +if (sh->config.dv_flow_en ==2 ) +return ;for (i =0 ; i < sh->max_port; i++) { age_info = &sh->port[i].age_info; age_info->flags =0 ;
@@ -540,8 +546,8 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused) hca_attr->flow_counter_bulk_alloc_bitmap);/* Initialize fallback mode only on the port initializes sh. */ if (sh->refcnt ==1 ) - sh->cmng.counter_fallback = fallback; -else if (fallback != sh->cmng.counter_fallback) + sh->sws_cmng.counter_fallback = fallback; +else if (fallback != sh->sws_cmng.counter_fallback)DRV_LOG (WARNING ,"Port %d in sh has different fallback mode " "with others:%d." ,PORT_ID (priv), fallback);#endif
@@ -556,17 +562,38 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused)static void mlx5_flow_counters_mng_init (struct mlx5_dev_ctx_shared *sh) { -int i; +int i, j; + +if (sh->config.dv_flow_en <2 ) { +memset (&sh->sws_cmng,0 ,sizeof (sh->sws_cmng)); +TAILQ_INIT (&sh->sws_cmng.flow_counters); + sh->sws_cmng.min_id =MLX5_CNT_BATCH_OFFSET ; + sh->sws_cmng.max_id =-1 ; + sh->sws_cmng.last_pool_idx =POOL_IDX_INVALID ; +rte_spinlock_init (&sh->sws_cmng.pool_update_sl); +for (i =0 ; i <MLX5_COUNTER_TYPE_MAX ; i++) { +TAILQ_INIT (&sh->sws_cmng.counters[i]); +rte_spinlock_init (&sh->sws_cmng.csl[i]); + } + }else { +struct mlx5_hca_attr *attr = &sh->cdev->config.hca_attr; +uint32_t fw_max_nb_cnts = attr->max_flow_counter; +uint8_t log_dcs =log2above (fw_max_nb_cnts) -1 ; +uint32_t max_nb_cnts =0 ; + +for (i =0 , j =0 ; j <MLX5_HWS_CNT_DCS_NUM ; ++i) { +int log_dcs_i = log_dcs - i; -memset (&sh->cmng,0 ,sizeof (sh->cmng)); -TAILQ_INIT (&sh->cmng.flow_counters); - sh->cmng.min_id =MLX5_CNT_BATCH_OFFSET ; - sh->cmng.max_id =-1 ; - sh->cmng.last_pool_idx =POOL_IDX_INVALID ; -rte_spinlock_init (&sh->cmng.pool_update_sl); -for (i =0 ; i <MLX5_COUNTER_TYPE_MAX ; i++) { -TAILQ_INIT (&sh->cmng.counters[i]); -rte_spinlock_init (&sh->cmng.csl[i]); +if (log_dcs_i <0 ) +break ; +if ((max_nb_cnts |RTE_BIT32 (log_dcs_i)) > + fw_max_nb_cnts) +continue ; + max_nb_cnts |=RTE_BIT32 (log_dcs_i); + j++; + } + sh->hws_max_log_bulk_sz = log_dcs; + sh->hws_max_nb_counters = max_nb_cnts; } }
@@ -607,13 +634,13 @@ mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh)rte_pause (); } -if (sh->cmng.pools) { +if (sh->sws_cmng.pools) {struct mlx5_flow_counter_pool *pool; -uint16_t n_valid = sh->cmng.n_valid; -bool fallback = sh->cmng.counter_fallback; +uint16_t n_valid = sh->sws_cmng.n_valid; +bool fallback = sh->sws_cmng.counter_fallback;for (i =0 ; i < n_valid; ++i) { - pool = sh->cmng.pools[i]; + pool = sh->sws_cmng.pools[i];if (!fallback && pool->min_dcs)claim_zero (mlx5_devx_cmd_destroy (pool->min_dcs));
@@ -632,14 +659,14 @@ mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh) }mlx5_free (pool); } -mlx5_free (sh->cmng.pools); +mlx5_free (sh->sws_cmng.pools); } - mng =LIST_FIRST (&sh->cmng.mem_mngs); + mng =LIST_FIRST (&sh->sws_cmng.mem_mngs);while (mng) {mlx5_flow_destroy_counter_stat_mem_mng (mng); - mng =LIST_FIRST (&sh->cmng.mem_mngs); + mng =LIST_FIRST (&sh->sws_cmng.mem_mngs); } -memset (&sh->cmng,0 ,sizeof (sh->cmng)); +memset (&sh->sws_cmng,0 ,sizeof (sh->sws_cmng)); }/**
drivers/net/mlx5/mlx5.h +47 -4
84 lines not on this page · raw message
drivers/net/mlx5/mlx5_defs.h +3 -0
@@ -43,6 +43,9 @@#define MLX5_PMD_SOFT_COUNTERS 1#endif +/* Maximum number of DCS created per port. */ +#define MLX5_HWS_CNT_DCS_NUM 4 +/* Alarm timeout. */ #define MLX5_ALARM_TIMEOUT_US 100000
drivers/net/mlx5/mlx5_flow.c +65 -24
175 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +30 -3
@@ -293,6 +293,8 @@ enum mlx5_feature_name {#define MLX5_FLOW_ACTION_MODIFY_FIELD (1ull << 39)#define MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY (1ull << 40)#define MLX5_FLOW_ACTION_CT (1ull << 41) +#define MLX5_FLOW_ACTION_INDIRECT_COUNT (1ull << 42) +#define MLX5_FLOW_ACTION_INDIRECT_AGE (1ull << 43)#define MLX5_FLOW_FATE_ACTIONS \ (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
@@ -1099,6 +1101,22 @@ struct rte_flow {uint32_t geneve_tlv_option;/**< Holds Geneve TLV option id. > */ } __rte_packed; +/* +* HWS COUNTER ID's layout +* 3 2 1 0 +* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +* | T | | D | | +* ~ Y | | C | IDX ~ +* | P | | S | | +* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +* +* Bit 31:29 = TYPE = MLX5_INDIRECT_ACTION_TYPE_COUNT = b'10 +* Bit 25:24 = DCS index +* Bit 23:00 = IDX in this counter belonged DCS bulk. +*/ +typedef uint32_t cnt_id_t ; +#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )/* HWS flow struct. */
@@ -1112,7 +1130,8 @@ struct rte_flow_hw { };struct rte_flow_template_table *table;/* The table flow allcated from. */ struct mlx5dr_rule rule;/* HWS layer data struct. */ -uint32_t cnt_id; +uint32_t age_idx; +cnt_id_t cnt_id;uint32_t mtr_id; } __rte_packed;
@@ -1158,7 +1177,7 @@ struct mlx5_action_construct_data {uint32_t idx;/* Shared action index. */ } shared_rss;struct { -uint32_t id; +cnt_id_t id; } shared_counter;struct {uint32_t id;
@@ -1189,6 +1208,7 @@ struct rte_flow_actions_template {struct rte_flow_action *actions;/* Cached flow actions. */ struct rte_flow_action *masks;/* Cached action masks.*/ struct mlx5dr_action_template *tmpl;/* mlx5dr action template. */ +uint64_t action_flags;/* Bit-map of all valid action in template. */ uint16_t dr_actions_num;/* Amount of DR rules actions. */ uint16_t actions_num;/* Amount of flow actions */ uint16_t *actions_off;/* DR action offset for given rte action offset. */
@@ -1245,7 +1265,7 @@ struct mlx5_hw_actions {struct mlx5_hw_encap_decap_action *encap_decap;uint16_t encap_decap_pos;/* Encap/Decap action position. */ uint32_t mark:1; /* Indicate the mark action. */ -uint32_t cnt_id;/* Counter id. */ +cnt_id_t cnt_id;/* Counter id. */ uint32_t mtr_id;/* Meter id. */ /* Translated DR action array from action template. */ struct mlx5dr_rule_action rule_acts[MLX5_HW_MAX_ACTS ];
@@ -1619,6 +1639,12 @@ typedef int (*mlx5_flow_get_aged_flows_t)void **context, uint32_t nb_contexts, struct rte_flow_error *error); +typedef int (*mlx5_flow_get_q_aged_flows_t ) + (struct rte_eth_dev *dev, +uint32_t queue_id, +void **context, +uint32_t nb_contexts, +struct rte_flow_error *error);typedef int (*mlx5_flow_action_validate_t ) (struct rte_eth_dev *dev, const struct rte_flow_indir_action_conf *conf,
@@ -1825,6 +1851,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_counter_free_t counter_free;mlx5_flow_counter_query_t counter_query;mlx5_flow_get_aged_flows_t get_aged_flows; +mlx5_flow_get_q_aged_flows_t get_q_aged_flows;mlx5_flow_action_validate_t action_validate;mlx5_flow_action_create_t action_create;mlx5_flow_action_destroy_t action_destroy;
drivers/net/mlx5/mlx5_flow_dv.c +15 -15
@@ -5524,7 +5524,7 @@ flow_dv_validate_action_age(uint64_t action_flags,const struct rte_flow_action_age *age = action->conf;if (!priv->sh->cdev->config.devx || - (priv->sh->cmng.counter_fallback && !priv->sh->aso_age_mng)) + (priv->sh->sws_cmng.counter_fallback && !priv->sh->aso_age_mng)) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -6085,7 +6085,7 @@ flow_dv_counter_get_by_idx(struct rte_eth_dev *dev, struct mlx5_flow_counter_pool **ppool) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;struct mlx5_flow_counter_pool *pool;/* Decrease to original index and clear shared bit. */
@@ -6179,7 +6179,7 @@ static int flow_dv_container_resize(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;void *old_pools = cmng->pools;uint32_t resize = cmng->n +MLX5_CNT_CONTAINER_RESIZE ;uint32_t mem_size =sizeof (struct mlx5_flow_counter_pool *) * resize;
@@ -6225,7 +6225,7 @@ _flow_dv_query_count(struct rte_eth_dev *dev, uint32_t counter, uint64_t *pkts, cnt =flow_dv_counter_get_by_idx (dev, counter, &pool);MLX5_ASSERT (pool); -if (priv->sh->cmng.counter_fallback) +if (priv->sh->sws_cmng.counter_fallback)return mlx5_devx_cmd_flow_counter_query (cnt->dcs_when_active,0 ,0 , pkts, bytes,0 ,NULL ,NULL ,0 );rte_spinlock_lock (&pool->sl);
@@ -6262,8 +6262,8 @@ flow_dv_pool_create(struct rte_eth_dev *dev, struct mlx5_devx_obj *dcs, {struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_counter_pool *pool; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; -bool fallback = priv->sh->cmng.counter_fallback; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng; +bool fallback = priv->sh->sws_cmng.counter_fallback;uint32_t size =sizeof (*pool); size +=MLX5_COUNTERS_PER_POOL *MLX5_CNT_SIZE ;
@@ -6324,14 +6324,14 @@ flow_dv_counter_pool_prepare(struct rte_eth_dev *dev, uint32_t age) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;struct mlx5_flow_counter_pool *pool;struct mlx5_counters tmp_tq;struct mlx5_devx_obj *dcs =NULL ;struct mlx5_flow_counter *cnt;enum mlx5_counter_type cnt_type = age ?MLX5_COUNTER_TYPE_AGE :MLX5_COUNTER_TYPE_ORIGIN ; -bool fallback = priv->sh->cmng.counter_fallback; +bool fallback = priv->sh->sws_cmng.counter_fallback;uint32_t i;if (fallback) {
@@ -6395,8 +6395,8 @@ flow_dv_counter_alloc(struct rte_eth_dev *dev, uint32_t age)struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_counter_pool *pool =NULL ;struct mlx5_flow_counter *cnt_free =NULL ; -bool fallback = priv->sh->cmng.counter_fallback; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +bool fallback = priv->sh->sws_cmng.counter_fallback; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;enum mlx5_counter_type cnt_type = age ?MLX5_COUNTER_TYPE_AGE :MLX5_COUNTER_TYPE_ORIGIN ;uint32_t cnt_idx;
@@ -6442,7 +6442,7 @@ flow_dv_counter_alloc(struct rte_eth_dev *dev, uint32_t age)if (_flow_dv_query_count (dev, cnt_idx, &cnt_free->hits, &cnt_free->bytes)) goto err; -if (!fallback && !priv->sh->cmng.query_thread_on) +if (!fallback && !priv->sh->sws_cmng.query_thread_on)/* Start the asynchronous batch query by the host thread. */ mlx5_set_query_alarm (priv->sh);/*
@@ -6570,7 +6570,7 @@ flow_dv_counter_free(struct rte_eth_dev *dev, uint32_t counter)* this case, lock will not be needed as query callback and release * function both operate with the different list. */ -if (!priv->sh->cmng.counter_fallback) { +if (!priv->sh->sws_cmng.counter_fallback) {rte_spinlock_lock (&pool->csl);TAILQ_INSERT_TAIL (&pool->counters[pool->query_gen], cnt, next);rte_spinlock_unlock (&pool->csl);
@@ -6578,10 +6578,10 @@ flow_dv_counter_free(struct rte_eth_dev *dev, uint32_t counter) cnt->dcs_when_free = cnt->dcs_when_active; cnt_type = pool->is_aged ?MLX5_COUNTER_TYPE_AGE :MLX5_COUNTER_TYPE_ORIGIN ; -rte_spinlock_lock (&priv->sh->cmng.csl[cnt_type]); -TAILQ_INSERT_TAIL (&priv->sh->cmng.counters[cnt_type], +rte_spinlock_lock (&priv->sh->sws_cmng.csl[cnt_type]); +TAILQ_INSERT_TAIL (&priv->sh->sws_cmng.counters[cnt_type], cnt, next); -rte_spinlock_unlock (&priv->sh->cmng.csl[cnt_type]); +rte_spinlock_unlock (&priv->sh->sws_cmng.csl[cnt_type]); } }
drivers/net/mlx5/mlx5_flow_hw.c +948 -156
1,611 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -2
@@ -122,7 +122,7 @@ flow_verbs_counter_get_by_idx(struct rte_eth_dev *dev, struct mlx5_flow_counter_pool **ppool) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;struct mlx5_flow_counter_pool *pool; idx = (idx -1 ) & (MLX5_CNT_SHARED_OFFSET -1 );
@@ -215,7 +215,7 @@ static uint32_t flow_verbs_counter_new(struct rte_eth_dev *dev, uint32_t id __rte_unused) { struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; +struct mlx5_flow_counter_mng *cmng = &priv->sh->sws_cmng;struct mlx5_flow_counter_pool *pool =NULL ;struct mlx5_flow_counter *cnt =NULL ;uint32_t n_valid = cmng->n_valid;
drivers/net/mlx5/mlx5_hws_cnt.c +687 -17
803 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h +169 -24
19 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH v3 14/17 net/mlx5: add async action push and pull support
In reply to Suanming MouThe queue based rte_flow_async_action_* functions work same as queue based async flow functions. The operations can be pushed asynchronously, so is the pull.
This commit adds the async action missing push and pull support.
--- drivers/net/mlx5/mlx5.h | 62 ++++- drivers/net/mlx5/mlx5_flow.c | 45 ++++ drivers/net/mlx5/mlx5_flow.h | 17 ++ drivers/net/mlx5/mlx5_flow_aso.c | 181 +++++++++++-- drivers/net/mlx5/mlx5_flow_dv.c | 7 +- drivers/net/mlx5/mlx5_flow_hw.c | 412 +++++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 6 +- 7 files changed, 626 insertions(+), 104 deletions(-)
drivers/net/mlx5/mlx5.h +50 -12
@@ -341,6 +341,8 @@ struct mlx5_lb_ctx {enum {MLX5_HW_Q_JOB_TYPE_CREATE ,/* Flow create job type. */ MLX5_HW_Q_JOB_TYPE_DESTROY ,/* Flow destroy job type. */ +MLX5_HW_Q_JOB_TYPE_UPDATE , +MLX5_HW_Q_JOB_TYPE_QUERY , };#define MLX5_HW_MAX_ITEMS (16)
@@ -348,12 +350,23 @@ enum {/* HW steering flow management job descriptor. */ struct mlx5_hw_q_job {uint32_t type;/* Job type. */ -struct rte_flow_hw *flow;/* Flow attached to the job. */ +union { +struct rte_flow_hw *flow;/* Flow attached to the job. */ +const void *action;/* Indirect action attached to the job. */ + };void *user_data;/* Job user data. */ uint8_t *encap_data;/* Encap data. */ struct mlx5_modification_cmd *mhdr_cmd;struct rte_flow_item *items; -struct rte_flow_item_ethdev port_spec; +union { +struct { +/* Pointer to ct query user memory. */ +struct rte_flow_action_conntrack *profile; +/* Pointer to ct ASO query out memory. */ +void *out_data; + } __rte_packed; +struct rte_flow_item_ethdev port_spec; + } __rte_packed; };/* HW steering job descriptor LIFO pool. */
@@ -361,6 +374,8 @@ struct mlx5_hw_q {uint32_t job_idx;/* Free job index. */ uint32_t size;/* LIFO size. */ struct mlx5_hw_q_job **job;/* LIFO header. */ +struct rte_ring *indir_cq;/* Indirect action SW completion queue. */ +struct rte_ring *indir_iq;/* Indirect action SW in progress queue. */ } __rte_cache_aligned;
@@ -569,6 +584,7 @@ struct mlx5_aso_sq_elem {struct mlx5_aso_ct_action *ct;char *query_data; }; +void *user_data; }; };
@@ -578,7 +594,9 @@ struct mlx5_aso_sq {struct mlx5_aso_cq cq;struct mlx5_devx_sq sq_obj;struct mlx5_pmd_mr mr; +volatile struct mlx5_aso_wqe *db;uint16_t pi; +uint16_t db_pi;uint32_t head;uint32_t tail;uint32_t sqn;
@@ -993,6 +1011,7 @@ struct mlx5_flow_meter_profile {enum mlx5_aso_mtr_state {ASO_METER_FREE ,/* In free list. */ ASO_METER_WAIT ,/* ACCESS_ASO WQE in progress. */ +ASO_METER_WAIT_ASYNC ,/* CQE will be handled by async pull. */ ASO_METER_READY ,/* CQE received. */ };
@@ -1195,6 +1214,7 @@ struct mlx5_bond_info {enum mlx5_aso_ct_state {ASO_CONNTRACK_FREE ,/* Inactive, in the free list. */ ASO_CONNTRACK_WAIT ,/* WQE sent in the SQ. */ +ASO_CONNTRACK_WAIT_ASYNC ,/* CQE will be handled by async pull. */ ASO_CONNTRACK_READY ,/* CQE received w/o error. */ ASO_CONNTRACK_QUERY ,/* WQE for query sent. */ ASO_CONNTRACK_MAX ,/* Guard. */
@@ -1203,13 +1223,21 @@ enum mlx5_aso_ct_state {/* Generic ASO connection tracking structure. */ struct mlx5_aso_ct_action {union { -LIST_ENTRY (mlx5_aso_ct_action) next; -/* Pointer to the next ASO CT. Used only in SWS. */ -struct mlx5_aso_ct_pool *pool; -/* Pointer to action pool. Used only in HWS. */ +/* SWS mode struct. */ +struct { +/* Pointer to the next ASO CT. Used only in SWS. */ +LIST_ENTRY (mlx5_aso_ct_action) next; + }; +/* HWS mode struct. */ +struct { +/* Pointer to action pool. Used only in HWS. */ +struct mlx5_aso_ct_pool *pool; + }; }; -void *dr_action_orig;/* General action object for original dir. */ -void *dr_action_rply;/* General action object for reply dir. */ +/* General action object for original dir. */ +void *dr_action_orig; +/* General action object for reply dir. */ +void *dr_action_rply;uint32_t refcnt;/* Action used count in device flows. */ uint16_t offset;/* Offset of ASO CT in DevX objects bulk. */ uint16_t peer;/* The only peer port index could also use this CT. */
@@ -2135,18 +2163,21 @@ int mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh);void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh,enum mlx5_access_aso_opc_mod aso_opc_mod);int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh,uint32_t queue, -struct mlx5_aso_mtr *mtr, -struct mlx5_mtr_bulk *bulk); +struct mlx5_aso_mtr *mtr,struct mlx5_mtr_bulk *bulk, +void *user_data,bool push);int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_mtr *mtr);int mlx5_aso_ct_update_by_wqe (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_ct_action *ct, -const struct rte_flow_action_conntrack *profile); +const struct rte_flow_action_conntrack *profile, +void *user_data, +bool push);int mlx5_aso_ct_wait_ready (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_ct_action *ct);int mlx5_aso_ct_query_by_wqe (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_ct_action *ct, -struct rte_flow_action_conntrack *profile); +struct rte_flow_action_conntrack *profile, +void *user_data,bool push);int mlx5_aso_ct_available (struct mlx5_dev_ctx_shared *sh,uint32_t queue,struct mlx5_aso_ct_action *ct);uint32_t
@@ -2154,6 +2185,13 @@ mlx5_get_supported_sw_parsing_offloads(const struct mlx5_hca_attr *attr);uint32_t mlx5_get_supported_tunneling_offloads (const struct mlx5_hca_attr *attr); +void mlx5_aso_ct_obj_analyze (struct rte_flow_action_conntrack *profile, +char *wdata); +void mlx5_aso_push_wqe (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_sq *sq); +int mlx5_aso_pull_completion (struct mlx5_aso_sq *sq, +struct rte_flow_op_result res[], +uint16_t n_res);int mlx5_aso_cnt_queue_init (struct mlx5_dev_ctx_shared *sh);void mlx5_aso_cnt_queue_uninit (struct mlx5_dev_ctx_shared *sh); int mlx5_aso_cnt_query(struct mlx5_dev_ctx_shared *sh,
drivers/net/mlx5/mlx5_flow.c +45 -0
63 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +17 -0
@@ -57,6 +57,13 @@ enum mlx5_rte_flow_field_id {#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 29 +#define MLX5_INDIRECT_ACTION_TYPE_GET (handle) \ + (((uint32_t)(uintptr_t)(handle)) >> MLX5_INDIRECT_ACTION_TYPE_OFFSET) + +#define MLX5_INDIRECT_ACTION_IDX_GET (handle) \ + (((uint32_t)(uintptr_t)(handle)) & \ + ((1u << MLX5_INDIRECT_ACTION_TYPE_OFFSET) - 1)) +enum {MLX5_INDIRECT_ACTION_TYPE_RSS ,MLX5_INDIRECT_ACTION_TYPE_AGE ,
@@ -1816,6 +1823,15 @@ typedef int (*mlx5_flow_async_action_handle_update_t)void *user_data, struct rte_flow_error *error); +typedef int (*mlx5_flow_async_action_handle_query_t ) + (struct rte_eth_dev *dev, +uint32_t queue, +const struct rte_flow_op_attr *attr, +const struct rte_flow_action_handle *handle, +void *data, +void *user_data, +struct rte_flow_error *error); +typedef int (*mlx5_flow_async_action_handle_destroy_t ) (struct rte_eth_dev *dev, uint32_t queue,
@@ -1878,6 +1894,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_push_t push;mlx5_flow_async_action_handle_create_t async_action_create;mlx5_flow_async_action_handle_update_t async_action_update; +mlx5_flow_async_action_handle_query_t async_action_query;mlx5_flow_async_action_handle_destroy_t async_action_destroy; };
drivers/net/mlx5/mlx5_flow_aso.c +152 -29
322 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +4 -3
@@ -13103,7 +13103,7 @@ flow_dv_translate_create_conntrack(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Failed to allocate CT object"); ct =flow_aso_ct_get_by_dev_idx (dev, idx); -if (mlx5_aso_ct_update_by_wqe (sh,MLX5_HW_INV_QUEUE , ct, pro)) { +if (mlx5_aso_ct_update_by_wqe (sh,MLX5_HW_INV_QUEUE , ct, pro,NULL , true)) {flow_dv_aso_ct_dev_release (dev, idx); rte_flow_error_set(error, EBUSY, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -15917,7 +15917,7 @@ __flow_dv_action_ct_update(struct rte_eth_dev *dev, uint32_t idx,if (ret)return ret; ret =mlx5_aso_ct_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , - ct, new_prf); + ct, new_prf,NULL , true);if (ret) return rte_flow_error_set(error, EIO, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -16753,7 +16753,8 @@ flow_dv_action_query(struct rte_eth_dev *dev, ct->peer; ((struct rte_flow_action_conntrack *)data)->is_original_dir = ct->is_original; -if (mlx5_aso_ct_query_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , ct, data)) +if (mlx5_aso_ct_query_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , ct, + data,NULL , true)) return rte_flow_error_set(error, EIO, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
drivers/net/mlx5/mlx5_flow_hw.c +355 -57
677 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +3 -3
@@ -1627,7 +1627,7 @@ mlx5_flow_meter_action_modify(struct mlx5_priv *priv, fm->is_enable = !!is_enable; aso_mtr = container_of(fm, struct mlx5_aso_mtr, fm); ret =mlx5_aso_meter_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , - aso_mtr, &priv->mtr_bulk); + aso_mtr, &priv->mtr_bulk,NULL , true);if (ret)return ret; ret =mlx5_aso_mtr_wait (priv->sh,MLX5_HW_INV_QUEUE , aso_mtr);
@@ -1877,7 +1877,7 @@ mlx5_flow_meter_create(struct rte_eth_dev *dev, uint32_t meter_id,if (priv->sh->meter_aso_en) { aso_mtr = container_of(fm, struct mlx5_aso_mtr, fm); ret =mlx5_aso_meter_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , - aso_mtr, &priv->mtr_bulk); + aso_mtr, &priv->mtr_bulk,NULL , true);if (ret) goto error;if (!priv->mtr_idx_tbl) {
@@ -1983,7 +1983,7 @@ mlx5_flow_meter_hws_create(struct rte_eth_dev *dev, uint32_t meter_id, fm->initialized =1 ;/* Update ASO flow meter by wqe. */ ret =mlx5_aso_meter_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , aso_mtr, - &priv->mtr_bulk); + &priv->mtr_bulk,NULL , true);if (ret) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_UNSPECIFIED,
Signature · 1 line
2.25.1
PATCH v3 15/17 net/mlx5: support flow integrity in HWS group 0
In reply to Suanming MouFrom: Gregory Etelson <[email protected]>
- Reformat flow integrity item translation for HWS code.
- Support flow integrity bits in HWS group 0.
- Update integrity item translation to match positive semantics only. Positive flow semantics was described in patch [ae37c0f60c].
--- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 163 ++++++++++++++++---------------- drivers/net/mlx5/mlx5_flow_hw.c | 8 ++ 3 files changed, 90 insertions(+), 82 deletions(-)
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -1462,6 +1462,7 @@ struct mlx5_dv_matcher_workspace {struct mlx5_flow_rss_desc *rss_desc;/* RSS descriptor. */ const struct rte_flow_item *tunnel_item;/* Flow tunnel item. */ const struct rte_flow_item *gre_item;/* Flow GRE item. */ +const struct rte_flow_item *integrity_items[2 ]; };struct mlx5_flow_split_info {
drivers/net/mlx5/mlx5_flow_dv.c +81 -82
251 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +8 -0
@@ -4656,6 +4656,14 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,case RTE_FLOW_ITEM_TYPE_ICMP6 :case RTE_FLOW_ITEM_TYPE_CONNTRACK :break ; +case RTE_FLOW_ITEM_TYPE_INTEGRITY : +/* +* Integrity flow item validation require access to +* both item mask and spec. +* Current HWS model allows item mask in pattern +* template and item spec in flow rule. +*/ +break ;case RTE_FLOW_ITEM_TYPE_END : items_end = true;break ;
Signature · 1 line
2.25.1
PATCH v3 16/17 net/mlx5: support device control for E-Switch default rule
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch introduces
This patch adds support for fdb_def_rule_en device argument to HW Steering, which controls:
- creation of default FDB jump flow rule,
- ability of the user to create transfer flow rules in root table.
A new PMD API to allow user application to enable traffic with port ID and SQ number is also added to direct packet to wire.
--- drivers/net/mlx5/linux/mlx5_os.c | 14 ++ drivers/net/mlx5/mlx5.h | 4 +- drivers/net/mlx5/mlx5_flow.c | 28 ++-- drivers/net/mlx5/mlx5_flow.h | 11 +- drivers/net/mlx5/mlx5_flow_dv.c | 78 +++++---- drivers/net/mlx5/mlx5_flow_hw.c | 279 +++++++++++++++---------------- drivers/net/mlx5/mlx5_trigger.c | 31 ++-- drivers/net/mlx5/mlx5_tx.h | 1 + drivers/net/mlx5/mlx5_txq.c | 47 ++++++ drivers/net/mlx5/rte_pmd_mlx5.h | 17 ++ drivers/net/mlx5/version.map | 1 + 11 files changed, 305 insertions(+), 206 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +14 -0
@@ -1554,6 +1554,20 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,rte_rwlock_init (&priv->ind_tbls_lock);if (priv->sh->config.dv_flow_en ==2 ) {#ifdef HAVE_IBV_FLOW_DV_SUPPORT +if (priv->sh->config.dv_esw_en) { +if (priv->sh->dv_regc0_mask ==UINT32_MAX ) { +DRV_LOG (ERR ,"E-Switch port metadata is required when using HWS " +"but it is disabled (configure it through devlink)" ); + err =ENOTSUP ; + goto error; + } +if (priv->sh->dv_regc0_mask ==0 ) { +DRV_LOG (ERR ,"E-Switch with HWS is not supported " +"(no available bits in reg_c[0])" ); + err =ENOTSUP ; + goto error; + } + }if (priv->vport_meta_mask)flow_hw_set_port_info (eth_dev); if (priv->sh->config.dv_esw_en &&
drivers/net/mlx5/mlx5.h +2 -2
@@ -2015,7 +2015,7 @@ int mlx5_flow_ops_get(struct rte_eth_dev *dev, const struct rte_flow_ops **ops);int mlx5_flow_start_default (struct rte_eth_dev *dev);void mlx5_flow_stop_default (struct rte_eth_dev *dev);int mlx5_flow_verify (struct rte_eth_dev *dev); -int mlx5_ctrl_flow_source_queue (struct rte_eth_dev *dev,uint32_t queue); +int mlx5_ctrl_flow_source_queue (struct rte_eth_dev *dev,uint32_t sq_num); int mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, struct rte_flow_item_eth *eth_spec, struct rte_flow_item_eth *eth_mask,
@@ -2027,7 +2027,7 @@ int mlx5_ctrl_flow(struct rte_eth_dev *dev,int mlx5_flow_lacp_miss (struct rte_eth_dev *dev);struct rte_flow *mlx5_flow_create_esw_table_zero_flow (struct rte_eth_dev *dev);uint32_t mlx5_flow_create_devx_sq_miss_flow (struct rte_eth_dev *dev, -uint32_t txq); +uint32_t sq_num);void mlx5_flow_async_pool_query_handle (struct mlx5_dev_ctx_shared *sh,uint64_t async_id,int status);void mlx5_set_query_alarm (struct mlx5_dev_ctx_shared *sh);
drivers/net/mlx5/mlx5_flow.c +14 -14
@@ -7155,14 +7155,14 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev)* * @param dev * Pointer to Ethernet device. -* @param txq -* Txq index. +* @param sq_num +* SQ number. * * @return * Flow ID on success, 0 otherwise and rte_errno is set. */ uint32_t -mlx5_flow_create_devx_sq_miss_flow (struct rte_eth_dev *dev,uint32_t txq) +mlx5_flow_create_devx_sq_miss_flow (struct rte_eth_dev *dev,uint32_t sq_num) {struct rte_flow_attr attr = { .group =0 ,
@@ -7174,8 +7174,8 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t txq)struct rte_flow_item_port_id port_spec = { .id =MLX5_PORT_ESW_MGR , }; -struct mlx5_rte_flow_item_tx_queue txq_spec = { - .queue = txq, +struct mlx5_rte_flow_item_sq sq_spec = { + .queue = sq_num, };struct rte_flow_item pattern[] = { {
@@ -7184,8 +7184,8 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t txq) }, { .type = (enum rte_flow_item_type) - MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE, - .spec = &txq_spec, + MLX5_RTE_FLOW_ITEM_TYPE_SQ, + .spec = &sq_spec, }, { .type = RTE_FLOW_ITEM_TYPE_END,
@@ -7556,30 +7556,30 @@ mlx5_flow_verify(struct rte_eth_dev *dev __rte_unused)* * @param dev * Pointer to Ethernet device. -* @param queue -* The queue index. +* @param sq_num +* The SQ hw number. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ int mlx5_ctrl_flow_source_queue (struct rte_eth_dev *dev, -uint32_t queue) +uint32_t sq_num) {const struct rte_flow_attr attr = { .egress =1 , .priority =0 , }; -struct mlx5_rte_flow_item_tx_queue queue_spec = { - .queue = queue, +struct mlx5_rte_flow_item_sq queue_spec = { + .queue = sq_num, }; -struct mlx5_rte_flow_item_tx_queue queue_mask = { +struct mlx5_rte_flow_item_sq queue_mask = { .queue =UINT32_MAX , };struct rte_flow_item items[] = { { .type = (enum rte_flow_item_type ) -MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE , +MLX5_RTE_FLOW_ITEM_TYPE_SQ , .spec = &queue_spec, .last =NULL , .mask = &queue_mask,
drivers/net/mlx5/mlx5_flow.h +5 -6
@@ -29,7 +29,7 @@enum mlx5_rte_flow_item_type {MLX5_RTE_FLOW_ITEM_TYPE_END =INT_MIN ,MLX5_RTE_FLOW_ITEM_TYPE_TAG , -MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE , +MLX5_RTE_FLOW_ITEM_TYPE_SQ ,MLX5_RTE_FLOW_ITEM_TYPE_VLAN ,MLX5_RTE_FLOW_ITEM_TYPE_TUNNEL , };
@@ -115,8 +115,8 @@ struct mlx5_flow_action_copy_mreg { };/* Matches on source queue. */ -struct mlx5_rte_flow_item_tx_queue { -uint32_t queue; +struct mlx5_rte_flow_item_sq { +uint32_t queue;/* DevX SQ number */ };/* Feature name to allocate metadata register. */
@@ -179,7 +179,7 @@ enum mlx5_feature_name {#define MLX5_FLOW_LAYER_GENEVE (1u << 26)/* Queue items. */ -#define MLX5_FLOW_ITEM_TX_QUEUE (1u << 27) +#define MLX5_FLOW_ITEM_SQ (1u << 27)/* Pattern tunnel Layer bits (continued). */ #define MLX5_FLOW_LAYER_GTP (1u << 28)
@@ -2475,9 +2475,8 @@ int mlx5_flow_pick_transfer_proxy(struct rte_eth_dev *dev,int mlx5_flow_hw_flush_ctrl_flows (struct rte_eth_dev *dev); -int mlx5_flow_hw_esw_create_mgr_sq_miss_flow (struct rte_eth_dev *dev);int mlx5_flow_hw_esw_create_sq_miss_flow (struct rte_eth_dev *dev, -uint32_t txq); +uint32_t sqn);int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev);int mlx5_flow_hw_create_tx_default_mreg_copy_flow (struct rte_eth_dev *dev); int mlx5_flow_actions_validate(struct rte_eth_dev *dev,
drivers/net/mlx5/mlx5_flow_dv.c +48 -30
148 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +138 -141
423 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +18 -13
@@ -426,7 +426,7 @@ mlx5_hairpin_queue_peer_update(struct rte_eth_dev *dev, uint16_t peer_queue,mlx5_txq_release (dev, peer_queue);return -rte_errno; } - peer_info->qp_id = txq_ctrl->obj->sq->id; + peer_info->qp_id =mlx5_txq_get_sqn (txq_ctrl); peer_info->vhca_id = priv->sh->cdev->config.hca_attr.vhca_id;/* 1-to-1 mapping, only the first one is used. */ peer_info->peer_q = txq_ctrl->hairpin_conf.peers[0 ].queue;
@@ -818,7 +818,7 @@ mlx5_hairpin_bind_single_port(struct rte_eth_dev *dev, uint16_t rx_port) }/* Pass TxQ's information to peer RxQ and try binding. */ cur.peer_q = rx_queue; - cur.qp_id = txq_ctrl->obj->sq->id; + cur.qp_id =mlx5_txq_get_sqn (txq_ctrl); cur.vhca_id = priv->sh->cdev->config.hca_attr.vhca_id; cur.tx_explicit = txq_ctrl->hairpin_conf.tx_explicit; cur.manual_bind = txq_ctrl->hairpin_conf.manual_bind;
@@ -1300,8 +1300,6 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev)int ret;if (priv->sh->config.dv_esw_en && priv->master) { -if (mlx5_flow_hw_esw_create_mgr_sq_miss_flow (dev)) - goto error;if (priv->sh->config.dv_xmeta_en ==MLX5_XMETA_MODE_META32_HWS )if (mlx5_flow_hw_create_tx_default_mreg_copy_flow (dev)) goto error;
@@ -1312,10 +1310,7 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev)if (!txq)continue ; -if (txq->is_hairpin) - queue = txq->obj->sq->id; -else - queue = txq->obj->sq_obj.sq->id; + queue =mlx5_txq_get_sqn (txq);if ((priv->representor || priv->master) && priv->sh->config.dv_esw_en) {if (mlx5_flow_hw_esw_create_sq_miss_flow (dev, queue)) {
@@ -1325,9 +1320,15 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev) }mlx5_txq_release (dev, i); } -if ((priv->master || priv->representor) && priv->sh->config.dv_esw_en) { -if (mlx5_flow_hw_esw_create_default_jump_flow (dev)) - goto error; +if (priv->sh->config.fdb_def_rule) { +if ((priv->master || priv->representor) && priv->sh->config.dv_esw_en) { +if (!mlx5_flow_hw_esw_create_default_jump_flow (dev)) + priv->fdb_def_rule =1 ; +else + goto error; + } + }else { +DRV_LOG (INFO ,"port %u FDB default rule is disabled" , dev->data->port_id); }return 0 ; error:
@@ -1393,14 +1394,18 @@ mlx5_traffic_enable(struct rte_eth_dev *dev) txq_ctrl->hairpin_conf.tx_explicit == 0 && txq_ctrl->hairpin_conf.peers[0].port == priv->dev_data->port_id) { - ret =mlx5_ctrl_flow_source_queue (dev, i); + ret =mlx5_ctrl_flow_source_queue (dev, +mlx5_txq_get_sqn (txq_ctrl));if (ret) {mlx5_txq_release (dev, i); goto error; } }if (priv->sh->config.dv_esw_en) { -if (mlx5_flow_create_devx_sq_miss_flow (dev, i) ==0 ) { +uint32_t q =mlx5_txq_get_sqn (txq_ctrl); + +if (mlx5_flow_create_devx_sq_miss_flow (dev, q) ==0 ) { +mlx5_txq_release (dev, i);DRV_LOG (ERR ,"Port %u Tx queue %u SQ create representor devx default miss rule failed." , dev->data->port_id, i);
drivers/net/mlx5/mlx5_tx.h +1 -0
@@ -213,6 +213,7 @@ struct mlx5_txq_ctrl *mlx5_txq_get(struct rte_eth_dev *dev, uint16_t idx);int mlx5_txq_release (struct rte_eth_dev *dev,uint16_t idx);int mlx5_txq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_txq_verify (struct rte_eth_dev *dev); +int mlx5_txq_get_sqn (struct mlx5_txq_ctrl *txq);void txq_alloc_elts (struct mlx5_txq_ctrl *txq_ctrl);void txq_free_elts (struct mlx5_txq_ctrl *txq_ctrl);uint64_t mlx5_get_tx_port_offloads (struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_txq.c +47 -0
59 lines not on this page · raw message
drivers/net/mlx5/rte_pmd_mlx5.h +17 -0
@@ -139,6 +139,23 @@ int rte_pmd_mlx5_external_rx_queue_id_unmap(uint16_t port_id,__rte_experimental int rte_pmd_mlx5_host_shaper_config(int port_id, uint8_t rate, uint32_t flags); +/** +* Enable traffic for external SQ. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] sq_num +* SQ HW number. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +* Possible values for rte_errno: +* - EINVAL - invalid sq_number or port type. +* - ENODEV - there is no Ethernet device for this port id. +*/ +__rte_experimental +int rte_pmd_mlx5_external_sq_enable(uint16_t port_id, uint32_t sq_num); + #ifdef __cplusplus }#endif
drivers/net/mlx5/version.map +1 -0
@@ -14,4 +14,5 @@ EXPERIMENTAL { rte_pmd_mlx5_external_rx_queue_id_unmap; # added in 22.07 rte_pmd_mlx5_host_shaper_config; + rte_pmd_mlx5_external_sq_enable; };
Signature · 1 line
2.25.1
PATCH v3 17/17 net/mlx5: support device control of representor matching
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
In some E-Switch use cases applications want to receive all traffic on a single port. Since currently flow API does not provide a way to match traffic forwarded to any port representor, this patch adds support for controlling representor matching on ingress flow rules.
Representor matching is controlled through new device argument repr_matching_en.
- If representor matching is enabled (default setting), then each ingress pattern template has an implicit REPRESENTED_PORT item added. Flow rules based on this pattern template will match the vport associated with port on which rule is created.
- If representor matching is disabled, then there will be no implicit item added. As a result ingress flow rules will match traffic coming to any port, not only the port on which flow rule is created.
Representor matching is enabled by default, to provide an expected default behavior.
This patch enables egress flow rules on representors when E-Switch is enabled in the following configurations:
- repr_matching_en=1 and dv_xmeta_en=4
- repr_matching_en=1 and dv_xmeta_en=0
- repr_matching_en=0 and dv_xmeta_en=0
When representor matching is enabled, the following logic is implemented:
1. Creating an egress template table in group 0 for each port. These tables will hold default flow rules defined as follows:
pattern SQ
actions MODIFY_FIELD (set available bits in REG_C_0 to
vport_meta_tag)
MODIFY_FIELD (copy REG_A to REG_C_1, only when
dv_xmeta_en == 4)
JUMP (group 1)
2. Egress pattern templates created by an application have an implicit MLX5_RTE_FLOW_ITEM_TYPE_TAG item prepended to pattern, which matches available bits of REG_C_0.
3. Egress flow rules created by an application have an implicit MLX5_RTE_FLOW_ITEM_TYPE_TAG item prepended to pattern, which matches vport_meta_tag placed in available bits of REG_C_0.
4. Egress template tables created by an application, which are in group n, are placed in group n + 1.
5. Items and actions related to META are operating on REG_A when dv_xmeta_en == 0 or REG_C_1 when dv_xmeta_en == 4.
When representor matching is disabled and extended metadata is disabled, no changes to current logic are required.
--- drivers/net/mlx5/linux/mlx5_os.c | 11 + drivers/net/mlx5/mlx5.c | 13 + drivers/net/mlx5/mlx5.h | 5 + drivers/net/mlx5/mlx5_flow.c | 8 +- drivers/net/mlx5/mlx5_flow.h | 7 + drivers/net/mlx5/mlx5_flow_hw.c | 738 ++++++++++++++++++++++++------- drivers/net/mlx5/mlx5_trigger.c | 167 ++++++- 7 files changed, 783 insertions(+), 166 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +11 -0
@@ -1555,6 +1555,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,if (priv->sh->config.dv_flow_en ==2 ) {#ifdef HAVE_IBV_FLOW_DV_SUPPORT if (priv->sh->config.dv_esw_en) { +uint32_t usable_bits; +uint32_t required_bits; +if (priv->sh->dv_regc0_mask ==UINT32_MAX ) {DRV_LOG (ERR ,"E-Switch port metadata is required when using HWS " "but it is disabled (configure it through devlink)" );
@@ -1567,6 +1570,14 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err =ENOTSUP ; goto error; } + usable_bits =__builtin_popcount (priv->sh->dv_regc0_mask); + required_bits =__builtin_popcount (priv->vport_meta_mask); +if (usable_bits < required_bits) { +DRV_LOG (ERR ,"Not enough bits available in reg_c[0] to provide " +"representor matching." ); + err =ENOTSUP ; + goto error; + } }if (priv->vport_meta_mask)flow_hw_set_port_info (eth_dev);
drivers/net/mlx5/mlx5.c +13 -0
@@ -181,6 +181,9 @@/* HW steering counter's query interval. */ #define MLX5_HWS_CNT_CYCLE_TIME "svc_cycle_time" +/* Device parameter to control representor matching in ingress/egress flows with HWS. */ +#define MLX5_REPR_MATCHING_EN "repr_matching_en" +/* Shared memory between primary and secondary processes. */ struct mlx5_shared_data *mlx5_shared_data;
@@ -1283,6 +1286,8 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque) config->cnt_svc.service_core = tmp; }else if (strcmp (MLX5_HWS_CNT_CYCLE_TIME , key) ==0 ) { config->cnt_svc.cycle_time = tmp; + }else if (strcmp (MLX5_REPR_MATCHING_EN , key) ==0 ) { + config->repr_matching = !!tmp; }return 0 ; }
@@ -1321,6 +1326,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,MLX5_FDB_DEFAULT_RULE_EN ,MLX5_HWS_CNT_SERVICE_CORE ,MLX5_HWS_CNT_CYCLE_TIME , +MLX5_REPR_MATCHING_EN , NULL, };int ret =0 ;
@@ -1335,6 +1341,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->fdb_def_rule =1 ; config->cnt_svc.cycle_time =MLX5_CNT_SVC_CYCLE_TIME_DEFAULT ; config->cnt_svc.service_core =rte_get_main_lcore (); + config->repr_matching =1 ;if (mkvlist !=NULL ) {/* Process parameters. */ ret = mlx5_kvargs_process(mkvlist, params,
@@ -1368,6 +1375,11 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->dv_xmeta_en); config->dv_xmeta_en =MLX5_XMETA_MODE_LEGACY ; } +if (config->dv_flow_en !=2 && !config->repr_matching) { +DRV_LOG (DEBUG ,"Disabling representor matching is valid only " +"when HW Steering is enabled." ); + config->repr_matching =1 ; + }if (config->tx_pp && !sh->dev_cap.txpp_en) {DRV_LOG (ERR ,"Packet pacing is not supported." ); rte_errno =ENODEV ;
@@ -1411,6 +1423,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,DRV_LOG (DEBUG ,"\"allow_duplicate_pattern\" is %u." , config->allow_duplicate_pattern);DRV_LOG (DEBUG ,"\"fdb_def_rule_en\" is %u." , config->fdb_def_rule); +DRV_LOG (DEBUG ,"\"repr_matching_en\" is %u." , config->repr_matching);return 0 ; }
drivers/net/mlx5/mlx5.h +5 -0
@@ -316,6 +316,7 @@ struct mlx5_sh_config { } cnt_svc;/* configure for HW steering's counter's service. */ /* Allow/Prevent the duplicate rules pattern. */ uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ + uint32_t repr_matching:1; /* Enable implicit vport matching in HWS FDB. */ };/* Structure for VF VLAN workaround. */
@@ -366,6 +367,7 @@ struct mlx5_hw_q_job {void *out_data; } __rte_packed;struct rte_flow_item_ethdev port_spec; +struct rte_flow_item_tag tag_spec; } __rte_packed; };
@@ -1673,6 +1675,9 @@ struct mlx5_priv {struct rte_flow_template_table *hw_esw_sq_miss_tbl;struct rte_flow_template_table *hw_esw_zero_tbl;struct rte_flow_template_table *hw_tx_meta_cpy_tbl; +struct rte_flow_pattern_template *hw_tx_repr_tagging_pt; +struct rte_flow_actions_template *hw_tx_repr_tagging_at; +struct rte_flow_template_table *hw_tx_repr_tagging_tbl;struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI ];/* RTE Flow rules. */ uint32_t ctrl_flows;/* Control flow rules. */
drivers/net/mlx5/mlx5_flow.c +6 -2
@@ -1123,7 +1123,11 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev, }break ;case MLX5_METADATA_TX : -return REG_A ; +if (config->dv_flow_en ==2 && config->dv_xmeta_en ==MLX5_XMETA_MODE_META32_HWS ) { +return REG_C_1 ; + }else { +return REG_A ; + }case MLX5_METADATA_FDB :switch (config->dv_xmeta_en) {case MLX5_XMETA_MODE_LEGACY :
@@ -11319,7 +11323,7 @@ mlx5_flow_pick_transfer_proxy(struct rte_eth_dev *dev,return 0 ; } } -return rte_flow_error_set (error,EINVAL , +return rte_flow_error_set (error,ENODEV ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL ,"unable to find a proxy port" ); }
drivers/net/mlx5/mlx5_flow.h +7 -0
@@ -1199,12 +1199,18 @@ struct rte_flow_pattern_template {struct rte_flow_pattern_template_attr attr;struct mlx5dr_match_template *mt;/* mlx5 match template. */ uint64_t item_flags;/* Item layer flags. */ +uint64_t orig_item_nb;/* Number of pattern items provided by the user (with END item). */ uint32_t refcnt;/* Reference counter. */ /* * If true, then rule pattern should be prepended with * represented_port pattern item. */ bool implicit_port; +/* +* If true, then rule pattern should be prepended with +* tag pattern item for representor matching. +*/ +bool implicit_tag; };/* Flow action template struct. */
@@ -2479,6 +2485,7 @@ int mlx5_flow_hw_esw_create_sq_miss_flow(struct rte_eth_dev *dev, uint32_t sqn);int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev);int mlx5_flow_hw_create_tx_default_mreg_copy_flow (struct rte_eth_dev *dev); +int mlx5_flow_hw_tx_repr_matching_flow (struct rte_eth_dev *dev,uint32_t sqn); int mlx5_flow_actions_validate(struct rte_eth_dev *dev, const struct rte_flow_actions_template_attr *attr, const struct rte_flow_action actions[],
drivers/net/mlx5/mlx5_flow_hw.c +582 -156
1,022 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +159 -8
213 lines not on this page · raw message
Signature · 1 line
2.25.1
v4 cover net/mlx5: HW steering PMD update
In reply to Suanming MouThe skeleton of mlx5 HW steering(HWS) has been updated into upstream for pretty a long time, but not updated anymore due to missing of the low-level steering layer code. Luckily, better late than never, the steering layer finnaly comes[1].
This series will add more features to the existing PMD code:
- FDB and metadata copy.
- Modify field.
- Meter color.
- Counter.
- Aging.
- Action template pre-parser optimization.
- Connection tracking.
Some features such as meter/aging/ct touches the public API, and public API changes have been sent to ML much earily in other threads in order not to be swallowed by this big series.
The dpends patches as below:
[1]https://inbox.dpdk.org/dev/[email protected]/
---
v4:
- Disable aging due to the flow age API change still in progress.
https://patches.dpdk.org/project/dpdk/cover/[email protected]/
- Add control flow for HWS.
v3:
- Fixed flow can't be aged out.
- Fix error not be filled properly while table creat failed.
- Remove transfer_mode in flow attributes before ethdev layer applied.
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
v2:
- Remove the rte_flow patches as they will be integrated in other thread.
- Fix compilation issues.
- Make the patches be better organized.
*** BLURB HERE ***
Alexander Kozyrev (2):
net/mlx5: add HW steering meter action net/mlx5: implement METER MARK indirect action for HWS
Bing Zhao (1):
net/mlx5: add extended metadata mode for hardware steering
Dariusz Sosnowski (5):
net/mlx5: add HW steering port action
net/mlx5: support DR action template API net/mlx5: support device control for E-Switch default rule net/mlx5: support device control of representor matching net/mlx5: create control flow rules with HWS
Gregory Etelson (2):
net/mlx5: add HW steering VLAN push, pop and VID modify flow actions net/mlx5: support flow integrity in HWS group 0
Michael Baum (1):
net/mlx5: add HWS AGE action support
Suanming Mou (6):
net/mlx5: fix invalid flow attributes net/mlx5: fix IPv6 and TCP RSS hash fields net/mlx5: add shared header reformat support net/mlx5: add modify field hws support net/mlx5: add HW steering connection tracking support net/mlx5: add async action push and pull support
Xiaoyu Min (1):
net/mlx5: add HW steering counter action
doc/guides/nics/mlx5.rst | 39 + drivers/common/mlx5/mlx5_devx_cmds.c | 50 + drivers/common/mlx5/mlx5_devx_cmds.h | 27 + drivers/common/mlx5/mlx5_prm.h | 22 +- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/linux/mlx5_os.c | 78 +- drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 126 +- drivers/net/mlx5/mlx5.h | 322 +- drivers/net/mlx5/mlx5_defs.h | 5 + drivers/net/mlx5/mlx5_flow.c | 409 +- drivers/net/mlx5/mlx5_flow.h | 335 +- drivers/net/mlx5/mlx5_flow_aso.c | 797 ++- drivers/net/mlx5/mlx5_flow_dv.c | 1128 ++-- drivers/net/mlx5/mlx5_flow_hw.c | 8789 +++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_meter.c | 776 ++- drivers/net/mlx5/mlx5_flow_verbs.c | 8 +- drivers/net/mlx5/mlx5_hws_cnt.c | 1247 ++++ drivers/net/mlx5/mlx5_hws_cnt.h | 703 ++ drivers/net/mlx5/mlx5_rxq.c | 3 +- drivers/net/mlx5/mlx5_trigger.c | 272 +- drivers/net/mlx5/mlx5_tx.h | 1 + drivers/net/mlx5/mlx5_txq.c | 47 + drivers/net/mlx5/mlx5_utils.h | 10 +- drivers/net/mlx5/rte_pmd_mlx5.h | 17 + drivers/net/mlx5/version.map | 1 + 26 files changed, 13576 insertions(+), 1638 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.c create mode 100644 drivers/net/mlx5/mlx5_hws_cnt.h
Signature · 1 line
2.25.1
PATCH v4 1/18 net/mlx5: fix invalid flow attributes
In the function flow_get_drv_type(), attr will be read in non-HWS mode. In case user call the HWS API in SWS mode, attr should be placed in HWS functions, or it will cause crash.
--- drivers/net/mlx5/mlx5_flow.c | 38 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-)
drivers/net/mlx5/mlx5_flow.c +26 -12
@@ -3742,6 +3742,8 @@ flow_get_drv_type(struct rte_eth_dev *dev, const struct rte_flow_attr *attr)*/ if (priv->sh->config.dv_flow_en ==2 )return MLX5_FLOW_TYPE_HW ; +if (!attr) +return MLX5_FLOW_TYPE_MIN ;/* If no OS specific type - continue with DV/VERBS selection */ if (attr->transfer && priv->sh->config.dv_esw_en) type =MLX5_FLOW_TYPE_DV ;
@@ -8254,8 +8256,9 @@ mlx5_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8289,8 +8292,9 @@ mlx5_flow_port_configure(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8321,8 +8325,9 @@ mlx5_flow_pattern_template_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8352,8 +8357,9 @@ mlx5_flow_pattern_template_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8387,8 +8393,9 @@ mlx5_flow_actions_template_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8418,8 +8425,9 @@ mlx5_flow_actions_template_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8459,8 +8467,9 @@ mlx5_flow_table_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8496,8 +8505,9 @@ mlx5_flow_table_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8544,8 +8554,9 @@ mlx5_flow_async_flow_create(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) { +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8587,8 +8598,9 @@ mlx5_flow_async_flow_destroy(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr fattr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &fattr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8623,8 +8635,9 @@ mlx5_flow_pull(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -8652,8 +8665,9 @@ mlx5_flow_push(struct rte_eth_dev *dev, struct rte_flow_error *error) {const struct mlx5_flow_driver_ops *fops; +struct rte_flow_attr attr = {0 }; -if (flow_get_drv_type (dev,NULL ) !=MLX5_FLOW_TYPE_HW ) +if (flow_get_drv_type (dev, &attr) !=MLX5_FLOW_TYPE_HW ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
Signature · 1 line
2.25.1
PATCH v4 2/18 net/mlx5: fix IPv6 and TCP RSS hash fields
In reply to Suanming MouIn the flow_dv_hashfields_set() function, while item_flags was 0, the code went directly to the first if and the else case would never have chance be checked. This caused the IPv6 and TCP hash fileds in the else case would never be set.
This commit adds the dedicate HW steering hash field set function to generate the RSS hash fields.
--- drivers/net/mlx5/mlx5_flow_dv.c | 12 +++---- drivers/net/mlx5/mlx5_flow_hw.c | 59 ++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 9 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +4 -8
@@ -11274,8 +11274,7 @@ flow_dv_hashfields_set(uint64_t item_flags, rss_inner =1 ;#endif if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L3_IPV4 )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV4 )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV4 ))) {if (rss_types &MLX5_IPV4_LAYER_TYPES ) {if (rss_types &RTE_ETH_RSS_L3_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_IPV4 ;
@@ -11285,8 +11284,7 @@ flow_dv_hashfields_set(uint64_t item_flags, fields |=MLX5_IPV4_IBV_RX_HASH ; } }else if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L3_IPV6 )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV6 )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L3_IPV6 ))) {if (rss_types &MLX5_IPV6_LAYER_TYPES ) {if (rss_types &RTE_ETH_RSS_L3_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_IPV6 ;
@@ -11309,8 +11307,7 @@ flow_dv_hashfields_set(uint64_t item_flags,return ; }if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L4_UDP )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_UDP )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_UDP ))) {if (rss_types &RTE_ETH_RSS_UDP ) {if (rss_types &RTE_ETH_RSS_L4_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_PORT_UDP ;
@@ -11320,8 +11317,7 @@ flow_dv_hashfields_set(uint64_t item_flags, fields |=MLX5_UDP_IBV_RX_HASH ; } }else if ((rss_inner && (items &MLX5_FLOW_LAYER_INNER_L4_TCP )) || - (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_TCP )) || - !items) { + (!rss_inner && (items &MLX5_FLOW_LAYER_OUTER_L4_TCP ))) {if (rss_types &RTE_ETH_RSS_TCP ) {if (rss_types &RTE_ETH_RSS_L4_SRC_ONLY ) fields |=IBV_RX_HASH_SRC_PORT_TCP ;
drivers/net/mlx5/mlx5_flow_hw.c +58 -1
71 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 3/18 net/mlx5: add shared header reformat support
In reply to Suanming MouAs the rte_flow_async API defines, the action mask with field value not be 0 means the action will be used as shared in all the flows in the table.
The header reformat action with action mask field not be 0 will be created as constant shared action. For encapsulation header reformat action, there are two kinds of encapsulation data, raw_encap_data and rte_flow_item encap_data. Both of these two kinds of data can be identified from the action mask conf as constant or not.
Examples:
1. VXLAN encap (encap_data: rte_flow_item)
action conf (eth/ipv4/udp/vxlan_hdr)
a. action mask conf (eth/ipv4/udp/vxlan_hdr)
- items are constant.
b. action mask conf (NULL)
- items will change.
2. RAW encap (encap_data: raw)
action conf (raw_data)
a. action mask conf (not NULL)
- encap_data constant.
b. action mask conf (NULL)
- encap_data will change.
--- drivers/net/mlx5/mlx5_flow.h | 6 +- drivers/net/mlx5/mlx5_flow_hw.c | 124 ++++++++++---------------------- 2 files changed, 39 insertions(+), 91 deletions(-)
drivers/net/mlx5/mlx5_flow.h +2 -4
@@ -1075,10 +1075,6 @@ struct mlx5_action_construct_data {uint16_t action_dst;/* mlx5dr_rule_action dst offset. */ union {struct { -/* encap src(item) offset. */ -uint16_t src; -/* encap dst data offset. */ -uint16_t dst;/* encap data len. */ uint16_t len; } encap;
@@ -1121,6 +1117,8 @@ struct mlx5_hw_jump_action {/* Encap decap action struct. */ struct mlx5_hw_encap_decap_action {struct mlx5dr_action *action;/* Action object. */ +/* Is header_reformat action shared across flows in table. */ +bool shared;size_t data_size;/* Action metadata size. */ uint8_t data[];/* Action data. */ };
drivers/net/mlx5/mlx5_flow_hw.c +37 -87
226 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 4/18 net/mlx5: add modify field hws support
In reply to Suanming MouThis patch introduces support for modify_field rte_flow actions in HWS mode. Support includes:
- Ingress and egress domains,
- SET and ADD operations,
- usage of arbitrary bit offsets and widths for packet and metadata fields.
Support is implemented in two phases:
1. On flow table creation the hardware commands are generated, based on rte_flow action templates, and stored alongside action template.
2. On flow rule creation/queueing the hardware commands are updated with values provided by the user. Any masks over immediate values, provided in action templates, are applied to these values before enqueueing rules for creation.
--- drivers/common/mlx5/mlx5_prm.h | 2 + drivers/net/mlx5/linux/mlx5_os.c | 18 +- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.h | 96 +++++ drivers/net/mlx5/mlx5_flow_dv.c | 551 ++++++++++++++------------- drivers/net/mlx5/mlx5_flow_hw.c | 614 ++++++++++++++++++++++++++++++- 6 files changed, 1007 insertions(+), 275 deletions(-)
drivers/common/mlx5/mlx5_prm.h +2 -0
@@ -751,6 +751,8 @@ enum mlx5_modification_field {MLX5_MODI_IN_TCP_ACK_NUM =0x5C ,MLX5_MODI_GTP_TEID =0x6E ,MLX5_MODI_OUT_IP_ECN =0x73 , +MLX5_MODI_TUNNEL_HDR_DW_1 =0x75 , + MLX5_MODI_GTPU_FIRST_EXT_DW_0 = 0x76, };/* Total number of metadata reg_c's. */
drivers/net/mlx5/linux/mlx5_os.c +9 -9
@@ -1540,6 +1540,15 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, mlx5_hrxq_clone_free_cb);if (!priv->hrxqs) goto error; +mlx5_set_metadata_mask (eth_dev); +if (sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + !priv->sh->dv_regc0_mask) { +DRV_LOG (ERR ,"metadata mode %u is not supported " +"(no metadata reg_c[0] is available)" , + sh->config.dv_xmeta_en); + err =ENOTSUP ; + goto error; + }rte_rwlock_init (&priv->ind_tbls_lock);if (priv->sh->config.dv_flow_en ==2 ) {#ifdef HAVE_IBV_FLOW_DV_SUPPORT
@@ -1566,15 +1575,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err = -err; goto error; } -mlx5_set_metadata_mask (eth_dev); -if (sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && - !priv->sh->dv_regc0_mask) { -DRV_LOG (ERR ,"metadata mode %u is not supported " -"(no metadata reg_c[0] is available)" , - sh->config.dv_xmeta_en); - err =ENOTSUP ; - goto error; - }/* Query availability of metadata reg_c's. */ if (!priv->sh->metadata_regc_check_flag) { err =mlx5_flow_discover_mreg_c (eth_dev);
drivers/net/mlx5/mlx5.h +1 -0
@@ -348,6 +348,7 @@ struct mlx5_hw_q_job {struct rte_flow_hw *flow;/* Flow attached to the job. */ void *user_data;/* Job user data. */ uint8_t *encap_data;/* Encap data. */ +struct mlx5_modification_cmd *mhdr_cmd; };/* HW steering job descriptor LIFO pool. */
drivers/net/mlx5/mlx5_flow.h +96 -0
132 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +286 -265
732 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +613 -1
709 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 5/18 net/mlx5: add HW steering port action
In reply to Suanming MouFrom: Dariusz Sosnowski <[email protected]>
This patch implements creating and caching of port actions for use with HW Steering FDB flows.
Actions are created on flow template API configuration and created only on the port designated as master. Attaching and detaching of ports in the same switching domain causes an update to the port actions cache by, respectively, creating and destroying actions.
A new devarg fdb_def_rule_en is being added and it's used to control the default dedicated E-Switch rule is created by PMD implicitly or not, and PMD sets this value to 1 by default.
If set to 0, the default E-Switch rule will not be created and user can create the specific E-Switch rule on root table if needed.
--- doc/guides/nics/mlx5.rst | 9 + drivers/net/mlx5/linux/mlx5_os.c | 16 +- drivers/net/mlx5/mlx5.c | 14 + drivers/net/mlx5/mlx5.h | 26 +- drivers/net/mlx5/mlx5_flow.c | 96 +- drivers/net/mlx5/mlx5_flow.h | 22 +- drivers/net/mlx5/mlx5_flow_dv.c | 93 +- drivers/net/mlx5/mlx5_flow_hw.c | 1356 +++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_flow_verbs.c | 4 +- drivers/net/mlx5/mlx5_trigger.c | 77 +- 10 files changed, 1595 insertions(+), 118 deletions(-)
doc/guides/nics/mlx5.rst +9 -0
@@ -1132,6 +1132,15 @@ for an additional list of options shared with other mlx5 drivers. By default, the PMD will set this value to 1. +- ``fdb_def_rule_en`` parameter [int] + + A non-zero value enables the PMD to create a dedicated rule on E-Switch root + table, this dedicated rule forwards all incoming packets into table 1, other + rules will be created in E-Switch table original table level plus one, to + improve the flow insertion rate due to skip root table managed by firmware. + If set to 0, all rules will be created on the original E-Switch table level. + + By default, the PMD will set this value to 1. Supported NICs --------------
drivers/net/mlx5/linux/mlx5_os.c +15 -1
@@ -1551,11 +1551,18 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, }rte_rwlock_init (&priv->ind_tbls_lock);if (priv->sh->config.dv_flow_en ==2 ) { -#ifdef HAVE_IBV_FLOW_DV_SUPPORT +#ifdef HAVE_MLX5_HWS_SUPPORT if (priv->vport_meta_mask)flow_hw_set_port_info (eth_dev);/* Only HWS requires this information. */ flow_hw_init_tags_set (eth_dev); +if (priv->sh->config.dv_esw_en && +flow_hw_create_vport_action (eth_dev)) { +DRV_LOG (ERR ,"port %u failed to create vport action" , + eth_dev->data->port_id); + err =EINVAL ; + goto error; + }return eth_dev;#else DRV_LOG (ERR ,"DV support is missing for HWS." );
@@ -1620,6 +1627,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,return eth_dev; error:if (priv) { +#ifdef HAVE_MLX5_HWS_SUPPORT +if (eth_dev && + priv->sh && + priv->sh->config.dv_flow_en ==2 && + priv->sh->config.dv_esw_en) +flow_hw_destroy_vport_action (eth_dev); +#endif if (priv->mreg_cp_tbl)mlx5_hlist_destroy (priv->mreg_cp_tbl);if (priv->sh)
drivers/net/mlx5/mlx5.c +14 -0
@@ -172,6 +172,9 @@/* Device parameter to configure the delay drop when creating Rxqs. */ #define MLX5_DELAY_DROP "delay_drop" +/* Device parameter to create the fdb default rule in PMD */ +#define MLX5_FDB_DEFAULT_RULE_EN "fdb_def_rule_en" +/* Shared memory between primary and secondary processes. */ struct mlx5_shared_data *mlx5_shared_data;
@@ -1239,6 +1242,8 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque) config->decap_en = !!tmp; }else if (strcmp (MLX5_ALLOW_DUPLICATE_PATTERN , key) ==0 ) { config->allow_duplicate_pattern = !!tmp; + }else if (strcmp (MLX5_FDB_DEFAULT_RULE_EN , key) ==0 ) { + config->fdb_def_rule = !!tmp; }return 0 ; }
@@ -1274,6 +1279,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,MLX5_RECLAIM_MEM ,MLX5_DECAP_EN ,MLX5_ALLOW_DUPLICATE_PATTERN , +MLX5_FDB_DEFAULT_RULE_EN , NULL, };int ret =0 ;
@@ -1285,6 +1291,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->dv_flow_en =1 ; config->decap_en =1 ; config->allow_duplicate_pattern =1 ; + config->fdb_def_rule =1 ;if (mkvlist !=NULL ) {/* Process parameters. */ ret = mlx5_kvargs_process(mkvlist, params,
@@ -1360,6 +1367,7 @@ mlx5_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh,DRV_LOG (DEBUG ,"\"decap_en\" is %u." , config->decap_en);DRV_LOG (DEBUG ,"\"allow_duplicate_pattern\" is %u." , config->allow_duplicate_pattern); +DRV_LOG (DEBUG ,"\"fdb_def_rule_en\" is %u." , config->fdb_def_rule);return 0 ; }
@@ -1943,6 +1951,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)mlx5_flex_parser_ecpri_release (dev);mlx5_flex_item_port_cleanup (dev);#ifdef HAVE_MLX5_HWS_SUPPORT +flow_hw_destroy_vport_action (dev);flow_hw_resource_release (dev);flow_hw_clear_port_info (dev);if (priv->sh->config.dv_flow_en ==2 )
@@ -2644,6 +2653,11 @@ mlx5_probe_again_args_validate(struct mlx5_common_device *cdev, sh->ibdev_name); goto error; } +if (sh->config.fdb_def_rule ^ config->fdb_def_rule) { +DRV_LOG (ERR ,"\"fdb_def_rule_en\" configuration mismatch for shared %s context." , + sh->ibdev_name); + goto error; + }if (sh->config.l3_vxlan_en ^ config->l3_vxlan_en) { DRV_LOG(ERR, "\"l3_vxlan_en\" " "configuration mismatch for shared %s context.",
drivers/net/mlx5/mlx5.h +22 -4
@@ -314,6 +314,7 @@ struct mlx5_sh_config { uint32_t allow_duplicate_pattern:1; uint32_t lro_allowed:1; /* Whether LRO is allowed. *//* Allow/Prevent the duplicate rules pattern. */ + uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ };
@@ -342,6 +343,8 @@ enum { MLX5_HW_Q_JOB_TYPE_DESTROY, /* Flow destroy job type. */ }; +#define MLX5_HW_MAX_ITEMS (16) +/* HW steering flow management job descriptor. */ struct mlx5_hw_q_job {uint32_t type;/* Job type. */
@@ -349,6 +352,8 @@ struct mlx5_hw_q_job {void *user_data;/* Job user data. */ uint8_t *encap_data;/* Encap data. */ struct mlx5_modification_cmd *mhdr_cmd; +struct rte_flow_item *items; +struct rte_flow_item_ethdev port_spec; };/* HW steering job descriptor LIFO pool. */
@@ -1207,6 +1212,8 @@ struct mlx5_dev_ctx_shared { uint32_t flow_priority_check_flag:1; /* Check Flag for flow priority. */ uint32_t metadata_regc_check_flag:1; /* Check Flag for metadata REGC. */ uint32_t hws_tags:1; /* Check if tags info for HWS initialized. */ + uint32_t shared_mark_enabled:1; +/* If mark action is enabled on Rxqs (shared E-Switch domain). */ uint32_t max_port;/* Maximal IB device port index. */ struct mlx5_bond_info bond;/* Bonding information. */ struct mlx5_common_device *cdev;/* Backend mlx5 device. */
@@ -1457,6 +1464,12 @@ struct mlx5_obj_ops {#define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields) +struct mlx5_hw_ctrl_flow { +LIST_ENTRY (mlx5_hw_ctrl_flow) next; +struct rte_eth_dev *owner_dev; +struct rte_flow *flow; +}; +struct mlx5_priv {struct rte_eth_dev_data *dev_data;/* Pointer to device data. */ struct mlx5_dev_ctx_shared *sh;/* Shared device context. */
@@ -1497,6 +1510,11 @@ struct mlx5_priv {unsigned int reta_idx_n;/* RETA index size. */ struct mlx5_drop drop_queue;/* Flow drop queues. */ void *root_drop_action;/* Pointer to root drop action. */ +rte_spinlock_t hw_ctrl_lock; + LIST_HEAD(hw_ctrl_flow, mlx5_hw_ctrl_flow) hw_ctrl_flows; +struct rte_flow_template_table *hw_esw_sq_miss_root_tbl; +struct rte_flow_template_table *hw_esw_sq_miss_tbl; +struct rte_flow_template_table *hw_esw_zero_tbl;struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI ];/* RTE Flow rules. */ uint32_t ctrl_flows;/* Control flow rules. */
@@ -1557,11 +1575,11 @@ struct mlx5_priv {struct mlx5_hw_q *hw_q;/* HW steering rte flow table list header. */ LIST_HEAD(flow_hw_tbl, rte_flow_template_table) flow_hw_tbl; +struct mlx5dr_action **hw_vport;/* HW steering global drop action. */ -struct mlx5dr_action *hw_drop[MLX5_HW_ACTION_FLAG_MAX ] - [MLX5DR_TABLE_TYPE_MAX ]; -/* HW steering global drop action. */ -struct mlx5dr_action *hw_tag[MLX5_HW_ACTION_FLAG_MAX ]; +struct mlx5dr_action *hw_drop[2 ]; +/* HW steering global tag action. */ +struct mlx5dr_action *hw_tag[2 ];struct mlx5_indexed_pool *acts_ipool;/* Action data indexed pool. */ #endif };
drivers/net/mlx5/mlx5_flow.c +80 -16
171 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +21 -1
@@ -1162,6 +1162,11 @@ struct rte_flow_pattern_template {struct mlx5dr_match_template *mt;/* mlx5 match template. */ uint64_t item_flags;/* Item layer flags. */ uint32_t refcnt;/* Reference counter. */ +/* +* If true, then rule pattern should be prepended with +* represented_port pattern item. +*/ +bool implicit_port; };/* Flow action template struct. */
@@ -1237,6 +1242,7 @@ struct mlx5_hw_action_template {/* mlx5 flow group struct. */ struct mlx5_flow_group {struct mlx5_list_entry entry; +struct rte_eth_dev *dev;/* Reference to corresponding device. */ struct mlx5dr_table *tbl;/* HWS table object. */ struct mlx5_hw_jump_action jump;/* Jump action. */ enum mlx5dr_table_type type;/* Table type. */
@@ -1495,6 +1501,9 @@ void flow_hw_clear_port_info(struct rte_eth_dev *dev);void flow_hw_init_tags_set (struct rte_eth_dev *dev);void flow_hw_clear_tags_set (struct rte_eth_dev *dev); +int flow_hw_create_vport_action (struct rte_eth_dev *dev); +void flow_hw_destroy_vport_action (struct rte_eth_dev *dev); + typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2093,7 +2102,7 @@ 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, + bool root, struct rte_flow_error *error); int mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item, uint64_t item_flags,
@@ -2350,4 +2359,15 @@ int flow_dv_translate_items_hws(const struct rte_flow_item *items, uint32_t key_type, uint64_t *item_flags, uint8_t *match_criteria, struct rte_flow_error *error); + +int mlx5_flow_pick_transfer_proxy (struct rte_eth_dev *dev, +uint16_t *proxy_port_id, +struct rte_flow_error *error); + +int mlx5_flow_hw_flush_ctrl_flows (struct rte_eth_dev *dev); + +int mlx5_flow_hw_esw_create_mgr_sq_miss_flow (struct rte_eth_dev *dev); +int mlx5_flow_hw_esw_create_sq_miss_flow (struct rte_eth_dev *dev, +uint32_t txq); +int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +53 -40
297 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +1309 -47
1,615 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +3 -1
@@ -1245,12 +1245,14 @@ flow_verbs_validate(struct rte_eth_dev *dev,uint16_t ether_type =0 ;bool is_empty_vlan = false;uint16_t udp_dport =0 ; +bool is_root;if (items ==NULL )return -1 ; ret =mlx5_flow_validate_attributes (dev, attr, error);if (ret <0 )return ret; + is_root = ret;for (; items->type !=RTE_FLOW_ITEM_TYPE_END ; items++) {int tunnel = !!(item_flags &MLX5_FLOW_LAYER_TUNNEL );int ret =0 ;
@@ -1380,7 +1382,7 @@ flow_verbs_validate(struct rte_eth_dev *dev,case RTE_FLOW_ITEM_TYPE_VXLAN : ret =mlx5_flow_validate_item_vxlan (dev, udp_dport, items, item_flags, - attr, error); + is_root, error);if (ret <0 )return ret; last_item =MLX5_FLOW_LAYER_VXLAN ;
drivers/net/mlx5/mlx5_trigger.c +69 -8
101 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 6/18 net/mlx5: add extended metadata mode for hardware steering
In reply to Suanming MouFrom: Bing Zhao <[email protected]>
The new mode 4 of devarg "dv_xmeta_en" is added for HWS only. In this mode, the Rx / Tx metadata with 32b width copy between FDB and NIC is supported. The mark is only supported in NIC and there is no copy supported.
--- doc/guides/nics/mlx5.rst | 4 + drivers/net/mlx5/linux/mlx5_os.c | 10 +- drivers/net/mlx5/mlx5.c | 7 +- drivers/net/mlx5/mlx5.h | 8 +- drivers/net/mlx5/mlx5_flow.c | 8 +- drivers/net/mlx5/mlx5_flow.h | 14 + drivers/net/mlx5/mlx5_flow_dv.c | 43 +- drivers/net/mlx5/mlx5_flow_hw.c | 864 ++++++++++++++++++++++++++++--- drivers/net/mlx5/mlx5_trigger.c | 3 + 9 files changed, 876 insertions(+), 85 deletions(-)
doc/guides/nics/mlx5.rst +4 -0
@@ -980,6 +980,10 @@ for an additional list of options shared with other mlx5 drivers. - 3, this engages tunnel offload mode. In E-Switch configuration, that mode implicitly activates ``dv_xmeta_en=1``. + - 4, this mode only supported in HWS (``dv_flow_en=2``). The Rx / Tx + metadata with 32b width copy between FDB and NIC is supported. The + mark is only supported in NIC and there is no copy supported. + +------+-----------+-----------+-------------+-------------+ | Mode | ``MARK`` | ``META`` | ``META`` Tx | FDB/Through | +======+===========+===========+=============+=============+
drivers/net/mlx5/linux/mlx5_os.c +9 -1
@@ -1554,6 +1554,15 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,#ifdef HAVE_MLX5_HWS_SUPPORT if (priv->vport_meta_mask)flow_hw_set_port_info (eth_dev); +if (priv->sh->config.dv_esw_en && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_META32_HWS ) { +DRV_LOG (ERR , +"metadata mode %u is not supported in HWS eswitch mode" , + priv->sh->config.dv_xmeta_en); + err =ENOTSUP ; + goto error; + }/* Only HWS requires this information. */ flow_hw_init_tags_set (eth_dev); if (priv->sh->config.dv_esw_en &&
@@ -1569,7 +1578,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, goto error;#endif } -/* Port representor shares the same max priority with pf port. */ if (!priv->sh->flow_priority_check_flag) {/* Supported Verbs flow priority number detection. */ err =mlx5_flow_discover_priorities (eth_dev);
drivers/net/mlx5/mlx5.c +6 -1
@@ -1218,7 +1218,8 @@ mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque)if (tmp !=MLX5_XMETA_MODE_LEGACY && tmp !=MLX5_XMETA_MODE_META16 && tmp !=MLX5_XMETA_MODE_META32 && - tmp !=MLX5_XMETA_MODE_MISS_INFO ) { + tmp !=MLX5_XMETA_MODE_MISS_INFO && + tmp !=MLX5_XMETA_MODE_META32_HWS ) {DRV_LOG (ERR ,"Invalid extensive metadata parameter." ); rte_errno =EINVAL ;return -rte_errno;
@@ -2849,6 +2850,10 @@ mlx5_set_metadata_mask(struct rte_eth_dev *dev) meta =UINT32_MAX ; mark = (reg_c0 >>rte_bsf32 (reg_c0)) &MLX5_FLOW_MARK_MASK ;break ; +case MLX5_XMETA_MODE_META32_HWS : + meta =UINT32_MAX ; + mark =MLX5_FLOW_MARK_MASK ; +break ;default : meta =0 ; mark =0 ;
drivers/net/mlx5/mlx5.h +4 -4
@@ -303,8 +303,8 @@ struct mlx5_sh_config { uint32_t reclaim_mode:2; /* Memory reclaim mode. */ uint32_t dv_esw_en:1; /* Enable E-Switch DV flow. *//* Enable DV flow. 1 means SW steering, 2 means HW steering. */ - unsigned int dv_flow_en:2; - uint32_t dv_xmeta_en:2; /* Enable extensive flow metadata. */ + uint32_t dv_flow_en:2; /* Enable DV flow. */ + uint32_t dv_xmeta_en:3; /* Enable extensive flow metadata. */ uint32_t dv_miss_info:1; /* Restore packet after partial hw miss. */ uint32_t l3_vxlan_en:1; /* Enable L3 VXLAN flow creation. */ uint32_t vf_nl_en:1; /* Enable Netlink requests in VF mode. */
@@ -317,7 +317,6 @@ struct mlx5_sh_config { uint32_t fdb_def_rule:1; /* Create FDB default jump rule */ }; -/* Structure for VF VLAN workaround. */ struct mlx5_vf_vlan {uint32_t tag:12 ;
@@ -1284,12 +1283,12 @@ struct mlx5_dev_ctx_shared {struct mlx5_lb_ctx self_lb;/* QP to enable self loopback for Devx. */ unsigned int flow_max_priority;enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM ]; +/* Availability of mreg_c's. */ void *devx_channel_lwm;struct rte_intr_handle *intr_handle_lwm;pthread_mutex_t lwm_config_lock; uint32_t host_shaper_rate:8; uint32_t lwm_triggered:1; -/* Availability of mreg_c's. */ struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1515,6 +1514,7 @@ struct mlx5_priv {struct rte_flow_template_table *hw_esw_sq_miss_root_tbl;struct rte_flow_template_table *hw_esw_sq_miss_tbl;struct rte_flow_template_table *hw_esw_zero_tbl; +struct rte_flow_template_table *hw_tx_meta_cpy_tbl;struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI ];/* RTE Flow rules. */ uint32_t ctrl_flows;/* Control flow rules. */
drivers/net/mlx5/mlx5_flow.c +7 -1
@@ -1109,6 +1109,8 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,return REG_C_0 ;case MLX5_XMETA_MODE_META32 :return REG_C_1 ; +case MLX5_XMETA_MODE_META32_HWS : +return REG_C_1 ; }break ;case MLX5_METADATA_TX :
@@ -1121,11 +1123,14 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,return REG_C_0 ;case MLX5_XMETA_MODE_META32 :return REG_C_1 ; +case MLX5_XMETA_MODE_META32_HWS : +return REG_C_1 ; }break ;case MLX5_FLOW_MARK :switch (config->dv_xmeta_en) {case MLX5_XMETA_MODE_LEGACY : +case MLX5_XMETA_MODE_META32_HWS :return REG_NON ;case MLX5_XMETA_MODE_META16 :return REG_C_1 ;
@@ -4444,7 +4449,8 @@ static bool flow_check_modify_action_type(struct rte_eth_dev *dev,return true;case RTE_FLOW_ACTION_TYPE_FLAG :case RTE_FLOW_ACTION_TYPE_MARK : -if (priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY ) +if (priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + priv->sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_META32_HWS )return true;else return false;
drivers/net/mlx5/mlx5_flow.h +14 -0
@@ -48,6 +48,12 @@ enum mlx5_rte_flow_action_type { MLX5_RTE_FLOW_ACTION_TYPE_RSS, }; +/* Private (internal) Field IDs for MODIFY_FIELD action. */ +enum mlx5_rte_flow_field_id { +MLX5_RTE_FLOW_FIELD_END =INT_MIN , +MLX5_RTE_FLOW_FIELD_META_REG , +}; +#define MLX5_INDIRECT_ACTION_TYPE_OFFSET 30enum {
@@ -1178,6 +1184,7 @@ struct rte_flow_actions_template {struct rte_flow_action *masks;/* Cached action masks.*/ uint16_t mhdr_off;/* Offset of DR modify header action. */ uint32_t refcnt;/* Reference counter. */ +uint16_t rx_cpy_pos;/* Action position of Rx metadata to be copied. */ };/* Jump action struct. */
@@ -1254,6 +1261,11 @@ struct mlx5_flow_group {#define MLX5_HW_TBL_MAX_ITEM_TEMPLATE 2#define MLX5_HW_TBL_MAX_ACTION_TEMPLATE 32 +struct mlx5_flow_template_table_cfg { +struct rte_flow_template_table_attr attr;/* Table attributes passed through flow API. */ +bool external;/* True if created by flow API, false if table is internal to PMD. */ +}; +struct rte_flow_template_table {LIST_ENTRY (rte_flow_template_table) next;struct mlx5_flow_group *grp;/* The group rte_flow_template_table uses. */
@@ -1263,6 +1275,7 @@ struct rte_flow_template_table {/* Action templates bind to the table. */ struct mlx5_hw_action_template ats[MLX5_HW_TBL_MAX_ACTION_TEMPLATE ];struct mlx5_indexed_pool *flow;/* The table's flow ipool. */ +struct mlx5_flow_template_table_cfg cfg;uint32_t type;/* Flow table type RX/TX/FDB. */ uint8_t nb_item_templates;/* Item template number. */ uint8_t nb_action_templates;/* Action template number. */
@@ -2370,4 +2383,5 @@ int mlx5_flow_hw_esw_create_mgr_sq_miss_flow(struct rte_eth_dev *dev);int mlx5_flow_hw_esw_create_sq_miss_flow (struct rte_eth_dev *dev,uint32_t txq);int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev); +int mlx5_flow_hw_create_tx_default_mreg_copy_flow (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +39 -4
73 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +790 -74
1,295 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +3 -0
@@ -1292,6 +1292,9 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev)if (priv->sh->config.dv_esw_en && priv->master) {if (mlx5_flow_hw_esw_create_mgr_sq_miss_flow (dev)) goto error; +if (priv->sh->config.dv_xmeta_en ==MLX5_XMETA_MODE_META32_HWS ) +if (mlx5_flow_hw_create_tx_default_mreg_copy_flow (dev)) + goto error; }for (i =0 ; i < priv->txqs_n; ++i) {struct mlx5_txq_ctrl *txq =mlx5_txq_get (dev, i);
Signature · 1 line
2.25.1
PATCH v4 7/18 net/mlx5: add HW steering meter action
In reply to Suanming MouFrom: Alexander Kozyrev <[email protected]>
This commit adds meter action for HWS steering.
HW steering meter is based on ASO. The number of meters will be used by flows should be specified in advanced in the flow configure API.
--- drivers/net/mlx5/mlx5.h | 61 ++- drivers/net/mlx5/mlx5_flow.c | 71 +++ drivers/net/mlx5/mlx5_flow.h | 24 + drivers/net/mlx5/mlx5_flow_aso.c | 30 +- drivers/net/mlx5/mlx5_flow_hw.c | 258 ++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 702 ++++++++++++++++++++++++++++- 6 files changed, 1110 insertions(+), 36 deletions(-)
drivers/net/mlx5/mlx5.h +58 -3
@@ -362,6 +362,9 @@ struct mlx5_hw_q {struct mlx5_hw_q_job **job;/* LIFO header. */ } __rte_cache_aligned; + + +#define MLX5_COUNTERS_PER_POOL 512#define MLX5_MAX_PENDING_QUERIES 4#define MLX5_CNT_CONTAINER_RESIZE 64
@@ -787,15 +790,29 @@ struct mlx5_flow_meter_policy {/* Is meter action in policy table. */ uint32_t hierarchy_drop_cnt:1;/* Is any meter in hierarchy contains drop_cnt. */ + uint32_t skip_r:1; +/* If red color policy is skipped. */ uint32_t skip_y:1;/* If yellow color policy is skipped. */ uint32_t skip_g:1;/* If green color policy is skipped. */ uint32_t mark:1;/* If policy contains mark action. */ + uint32_t initialized:1; +/* Initialized. */ +uint16_t group; +/* The group. */ rte_spinlock_t sl;uint32_t ref_cnt;/* Use count. */ +struct rte_flow_pattern_template *hws_item_templ; +/* Hardware steering item templates. */ +struct rte_flow_actions_template *hws_act_templ[MLX5_MTR_DOMAIN_MAX ]; +/* Hardware steering action templates. */ +struct rte_flow_template_table *hws_flow_table[MLX5_MTR_DOMAIN_MAX ]; +/* Hardware steering tables. */ +struct rte_flow *hws_flow_rule[MLX5_MTR_DOMAIN_MAX ][RTE_COLORS ]; +/* Hardware steering rules. */ struct mlx5_meter_policy_action_container act_cnt[MLX5_MTR_RTE_COLORS ];/* Policy actions container. */ void *dr_drop_action[MLX5_MTR_DOMAIN_MAX ];
@@ -870,6 +887,7 @@ struct mlx5_flow_meter_info {*/ uint32_t transfer:1; uint32_t def_policy:1; + uint32_t initialized:1;/* Meter points to default policy. */ uint32_t color_aware:1;/* Meter is color aware mode. */
@@ -885,6 +903,10 @@ struct mlx5_flow_meter_info {/**< Flow meter action. */ void *meter_action_y;/**< Flow meter action for yellow init_color. */ +uint32_t meter_offset; +/**< Flow meter offset. */ +uint16_t group; +/**< Flow meter group. */ };/* PPS(packets per second) map to BPS(Bytes per second).
@@ -919,6 +941,7 @@ struct mlx5_flow_meter_profile {uint32_t ref_cnt;/**< Use count. */ uint32_t g_support:1; /**< If G color will be generated. */ uint32_t y_support:1; /**< If Y color will be generated. */ + uint32_t initialized:1; /**< Initialized. */ };/* 2 meters in each ASO cache line */
@@ -939,13 +962,20 @@ enum mlx5_aso_mtr_state { ASO_METER_READY, /* CQE received. */ }; +/*aso flow meter type*/ +enum mlx5_aso_mtr_type { +ASO_METER_INDIRECT , +ASO_METER_DIRECT , +}; +/* Generic aso_flow_meter information. */ struct mlx5_aso_mtr {LIST_ENTRY (mlx5_aso_mtr) next; +enum mlx5_aso_mtr_type type;struct mlx5_flow_meter_info fm;/**< Pointer to the next aso flow meter structure. */ uint8_t state;/**< ASO flow meter state. */ -uint8_t offset; +uint32_t offset; };/* Generic aso_flow_meter pool structure. */
@@ -969,6 +999,14 @@ struct mlx5_aso_mtr_pools_mng {struct mlx5_aso_mtr_pool **pools;/* ASO flow meter pool array. */ }; +/* Bulk management structure for ASO flow meter. */ +struct mlx5_mtr_bulk { +uint32_t size;/* Number of ASO objects. */ +struct mlx5dr_action *action;/* HWS action */ +struct mlx5_devx_obj *devx_obj;/* DEVX object. */ +struct mlx5_aso_mtr *aso;/* Array of ASO objects. */ +}; +/* Meter management structure for global flow meter resource. */ struct mlx5_flow_mtr_mng {struct mlx5_aso_mtr_pools_mng pools_mng;
@@ -1022,6 +1060,7 @@ struct mlx5_flow_tbl_resource {#define MLX5_FLOW_TABLE_LEVEL_METER (MLX5_MAX_TABLES - 3)#define MLX5_FLOW_TABLE_LEVEL_POLICY (MLX5_MAX_TABLES - 4)#define MLX5_MAX_TABLES_EXTERNAL MLX5_FLOW_TABLE_LEVEL_POLICY +#define MLX5_FLOW_TABLE_HWS_POLICY (MLX5_MAX_TABLES - 10)#define MLX5_MAX_TABLES_FDB UINT16_MAX#define MLX5_FLOW_TABLE_FACTOR 10
@@ -1308,6 +1347,12 @@ TAILQ_HEAD(mlx5_mtr_profiles, mlx5_flow_meter_profile);/* MTR list. */ TAILQ_HEAD (mlx5_legacy_flow_meters, mlx5_legacy_flow_meter); +struct mlx5_mtr_config { +uint32_t nb_meters;/**< Number of configured meters */ +uint32_t nb_meter_profiles;/**< Number of configured meter profiles */ +uint32_t nb_meter_policies;/**< Number of configured meter policies */ +}; +/* RSS description. */ struct mlx5_flow_rss_desc {uint32_t level;
@@ -1545,12 +1590,16 @@ struct mlx5_priv {struct mlx5_nl_vlan_vmwa_context *vmwa_context;/* VLAN WA context. */ struct mlx5_hlist *mreg_cp_tbl;/* Hash table of Rx metadata register copy table. */ +struct mlx5_mtr_config mtr_config;/* Meter configuration */ uint8_t mtr_sfx_reg;/* Meter prefix-suffix flow match REG_C. */ uint8_t mtr_color_reg;/* Meter color match REG_C. */ struct mlx5_legacy_flow_meters flow_meters;/* MTR list. */ struct mlx5_l3t_tbl *mtr_profile_tbl;/* Meter index lookup table. */ +struct mlx5_flow_meter_profile *mtr_profile_arr;/* Profile array. */ struct mlx5_l3t_tbl *policy_idx_tbl;/* Policy index lookup table. */ +struct mlx5_flow_meter_policy *mtr_policy_arr;/* Policy array. */ struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ +struct mlx5_mtr_bulk mtr_bulk;/* Meter index mapping for HWS */ uint8_t skip_default_rss_reta;/* Skip configuration of default reta. */ uint8_t fdb_def_rule;/* Whether fdb jump to table 1 is configured. */ struct mlx5_mp_id mp_id;/* ID of a multi-process process */
@@ -1564,13 +1613,13 @@ struct mlx5_priv {struct mlx5_flex_item flex_item[MLX5_PORT_FLEX_ITEM_NUM ];/* Flex items have been created on the port. */ uint32_t flex_item_map;/* Map of allocated flex item elements. */ +uint32_t nb_queue;/* HW steering queue number. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )/* Item template list. */ LIST_HEAD(flow_hw_itt, rte_flow_pattern_template) flow_hw_itt;/* Action template list. */ LIST_HEAD(flow_hw_at, rte_flow_actions_template) flow_hw_at;struct mlx5dr_context *dr_ctx;/**< HW steering DR context. */ -uint32_t nb_queue;/* HW steering queue number. */ /* HW steering queue polling mechanism job descriptor LIFO. */ struct mlx5_hw_q *hw_q;/* HW steering rte flow table list header. */
@@ -1586,6 +1635,7 @@ struct mlx5_priv {#define PORT_ID (priv) ((priv)->dev_data->port_id)#define ETH_DEV (priv) (&rte_eth_devices[PORT_ID(priv)]) +#define CTRL_QUEUE_ID (priv) ((priv)->nb_queue - 1)struct rte_hairpin_peer_info {uint32_t qp_id;
@@ -1897,6 +1947,11 @@ void mlx5_pmd_socket_uninit(void);/* mlx5_flow_meter.c */ +int mlx5_flow_meter_init (struct rte_eth_dev *dev, +uint32_t nb_meters, +uint32_t nb_meter_profiles, +uint32_t nb_meter_policies); +void mlx5_flow_meter_uninit (struct rte_eth_dev *dev);int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg);struct mlx5_flow_meter_info *mlx5_flow_meter_find (struct mlx5_priv *priv,uint32_t meter_id,uint32_t *mtr_idx);
@@ -1971,7 +2026,7 @@ int mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh);void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh,enum mlx5_access_aso_opc_mod aso_opc_mod);int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh, -struct mlx5_aso_mtr *mtr); +struct mlx5_aso_mtr *mtr,struct mlx5_mtr_bulk *bulk);int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh,struct mlx5_aso_mtr *mtr); int mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh,
drivers/net/mlx5/mlx5_flow.c +71 -0
83 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +24 -0
@@ -1665,6 +1665,11 @@ typedef int (*mlx5_flow_port_configure_t)uint16_t nb_queue, const struct rte_flow_queue_attr *queue_attr[], struct rte_flow_error *err); +typedef int (*mlx5_flow_pattern_validate_t ) + (struct rte_eth_dev *dev, +const struct rte_flow_pattern_template_attr *attr, +const struct rte_flow_item items[], +struct rte_flow_error *error);typedef struct rte_flow_pattern_template *(*mlx5_flow_pattern_template_create_t ) (struct rte_eth_dev *dev, const struct rte_flow_pattern_template_attr *attr,
@@ -1674,6 +1679,12 @@ typedef int (*mlx5_flow_pattern_template_destroy_t) (struct rte_eth_dev *dev, struct rte_flow_pattern_template *template, struct rte_flow_error *error); +typedef int (*mlx5_flow_actions_validate_t ) + (struct rte_eth_dev *dev, +const struct rte_flow_actions_template_attr *attr, +const struct rte_flow_action actions[], +const struct rte_flow_action masks[], +struct rte_flow_error *error);typedef struct rte_flow_actions_template *(*mlx5_flow_actions_template_create_t ) (struct rte_eth_dev *dev, const struct rte_flow_actions_template_attr *attr,
@@ -1790,8 +1801,10 @@ struct mlx5_flow_driver_ops {mlx5_flow_item_update_t item_update;mlx5_flow_info_get_t info_get;mlx5_flow_port_configure_t configure; +mlx5_flow_pattern_validate_t pattern_validate;mlx5_flow_pattern_template_create_t pattern_template_create;mlx5_flow_pattern_template_destroy_t pattern_template_destroy; +mlx5_flow_actions_validate_t actions_validate;mlx5_flow_actions_template_create_t actions_template_create;mlx5_flow_actions_template_destroy_t actions_template_destroy;mlx5_flow_table_create_t template_table_create;
@@ -1873,6 +1886,8 @@ mlx5_aso_meter_by_idx(struct mlx5_priv *priv, uint32_t idx)/* Decrease to original index. */ idx--; +if (priv->mtr_bulk.aso) +return priv->mtr_bulk.aso + idx;MLX5_ASSERT (idx /MLX5_ASO_MTRS_PER_POOL < pools_mng->n);rte_rwlock_read_lock (&pools_mng->resize_mtrwl); pool = pools_mng->pools[idx /MLX5_ASO_MTRS_PER_POOL ];
@@ -2384,4 +2399,13 @@ int mlx5_flow_hw_esw_create_sq_miss_flow(struct rte_eth_dev *dev, uint32_t txq);int mlx5_flow_hw_esw_create_default_jump_flow (struct rte_eth_dev *dev);int mlx5_flow_hw_create_tx_default_mreg_copy_flow (struct rte_eth_dev *dev); +int mlx5_flow_actions_validate (struct rte_eth_dev *dev, +const struct rte_flow_actions_template_attr *attr, +const struct rte_flow_action actions[], +const struct rte_flow_action masks[], +struct rte_flow_error *error); +int mlx5_flow_pattern_validate (struct rte_eth_dev *dev, +const struct rte_flow_pattern_template_attr *attr, +const struct rte_flow_item items[], +struct rte_flow_error *error);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_aso.c +19 -11
@@ -642,7 +642,8 @@ mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh)static uint16_t mlx5_aso_mtr_sq_enqueue_single (struct mlx5_dev_ctx_shared *sh,struct mlx5_aso_sq *sq, -struct mlx5_aso_mtr *aso_mtr) +struct mlx5_aso_mtr *aso_mtr, +struct mlx5_mtr_bulk *bulk) {volatile struct mlx5_aso_wqe *wqe =NULL ;struct mlx5_flow_meter_info *fm =NULL ;
@@ -653,6 +654,7 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_dev_ctx_shared *sh,uint32_t dseg_idx =0 ;struct mlx5_aso_mtr_pool *pool =NULL ;uint32_t param_le; +int id;rte_spinlock_lock (&sq->sqsl); res = size - (uint16_t )(sq->head - sq->tail);
@@ -666,14 +668,19 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_dev_ctx_shared *sh,/* Fill next WQE. */ fm = &aso_mtr->fm; sq->elts[sq->head & mask].mtr = aso_mtr; - pool = container_of(aso_mtr, struct mlx5_aso_mtr_pool, - mtrs[aso_mtr->offset]); - wqe->general_cseg.misc =rte_cpu_to_be_32 (pool->devx_obj->id + - (aso_mtr->offset >>1 )); - wqe->general_cseg.opcode =rte_cpu_to_be_32 (MLX5_OPCODE_ACCESS_ASO | - (ASO_OPC_MOD_POLICER << -WQE_CSEG_OPC_MOD_OFFSET ) | - sq->pi <<WQE_CSEG_WQE_INDEX_OFFSET ); +if (aso_mtr->type ==ASO_METER_INDIRECT ) { + pool = container_of(aso_mtr, struct mlx5_aso_mtr_pool, + mtrs[aso_mtr->offset]); + id = pool->devx_obj->id; + }else { + id = bulk->devx_obj->id; + } + wqe->general_cseg.misc =rte_cpu_to_be_32 (id + + (aso_mtr->offset >>1 )); + wqe->general_cseg.opcode = +rte_cpu_to_be_32 (MLX5_OPCODE_ACCESS_ASO | + (ASO_OPC_MOD_POLICER <<WQE_CSEG_OPC_MOD_OFFSET ) | + sq->pi <<WQE_CSEG_WQE_INDEX_OFFSET );/* There are 2 meters in one ASO cache line. */ dseg_idx = aso_mtr->offset &0x1 ; wqe->aso_cseg.data_mask =
@@ -811,14 +818,15 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)*/ int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh, -struct mlx5_aso_mtr *mtr) +struct mlx5_aso_mtr *mtr, +struct mlx5_mtr_bulk *bulk) {struct mlx5_aso_sq *sq = &sh->mtrmng->pools_mng.sq;uint32_t poll_wqe_times =MLX5_MTR_POLL_WQE_CQE_TIMES ; do { mlx5_aso_mtr_completion_handle(sq); - if (mlx5_aso_mtr_sq_enqueue_single(sh, sq, mtr)) + if (mlx5_aso_mtr_sq_enqueue_single(sh, sq, mtr, bulk)) return 0; /* Waiting for wqe resource. */ rte_delay_us_sleep(MLX5_ASO_WQE_CQE_RESPONSE_DELAY);
drivers/net/mlx5/mlx5_flow_hw.c +250 -8
347 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +688 -14
807 lines not on this page · raw message
Signature · 1 line
2.25.1