net/mlx5: optimize flow structure
v2 cover net/mlx5: optimize flow structure
In reply to a message not in the archiveThis patch set is third part of the flow memory consumption optimization. It mainly optimizes the rte flow and mlx5 flow handle structure.
For mlx5 flow handle structure:
1. As one flow has only one fate action, the fate actions are reorganized as union.
2. The action flags are optimized to be the limited bits the flow needs.
3. The bits members are reorganized to align with bytes.
For rte flow structure:
1. Meter handle is converted to uint32_t type as unique meter id.
2. Fdir handle is converted to one bit to save the pointer to another list.
3. Metadata handle is converted to uint32_t type as indexed.
4. Remove the duplicated RSS member in rte flow.
5. The bit members are reorganized to align with bytes.
Some extra optimizations:
1. Allocate meter resource from indexed memory pool.
2. Allocate rte flow from indexed memory pool.
3. Split RSS type, level, key to common memory as they are not required for the flow destroy.
This patch set should be applied after the patch series as below:
https://patches.dpdk.org/cover/68591/
v2:
- Add unified routine for fate actions release.
- Rmove RSS totally from rte flow.
- Allocate rte flow totally from indexed memory pool.
Suanming Mou (9):
net/mlx5: reorganize fate actions as union net/mlx5: optimize action flags in flow handle net/mlx5: reorganize the mlx5 flow handle struct net/mlx5: optimize flow meter handle type net/mlx5: allocate meter from indexed pool net/mlx5: convert mark copy resource to indexed net/mlx5: optimize mlx5 flow RSS struct net/mlx5: allocate rte flow from indexed pool net/mlx5: reorganize rte flow structure
Wentao Cui (1):
net/mlx5: optimize flow director filter memory
drivers/net/mlx5/mlx5.c | 38 +++- drivers/net/mlx5/mlx5.h | 19 +- drivers/net/mlx5/mlx5_flow.c | 406 +++++++++++++++++++++++-------------- drivers/net/mlx5/mlx5_flow.h | 89 +++++--- drivers/net/mlx5/mlx5_flow_dv.c | 214 +++++++++++-------- drivers/net/mlx5/mlx5_flow_meter.c | 11 +- drivers/net/mlx5/mlx5_flow_verbs.c | 98 +++++---- 7 files changed, 554 insertions(+), 321 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/10 net/mlx5: reorganize fate actions as union
Currently, one flow only has one fate action, the fate actions members in the flow struct can be reorganized as union to save the memory for flow struct.
This commit reorganizes the fate actions as union, the act_flags helps to identify the fate action type when flow destroys.
--- drivers/net/mlx5/mlx5_flow.h | 11 +++++---- drivers/net/mlx5/mlx5_flow_dv.c | 48 +++++++++++++++++++++++++------------- drivers/net/mlx5/mlx5_flow_verbs.c | 22 ++++++++++++----- 3 files changed, 54 insertions(+), 27 deletions(-)
drivers/net/mlx5/mlx5_flow.h +6 -5
@@ -488,10 +488,6 @@ struct mlx5_flow_handle_dv {/**< Index to encap/decap resource in cache. */ struct mlx5_flow_dv_modify_hdr_resource *modify_hdr;/**< Pointer to modify header resource in cache. */ -uint32_t jump; -/**< Index to the jump action resource. */ -uint32_t port_id_action; -/**< Index to port ID action resource. */ struct mlx5_vf_vlan vf_vlan;/**< Structure for VF VLAN workaround. */ uint32_t push_vlan_res;
@@ -509,12 +505,17 @@ struct mlx5_flow_handle {uint64_t act_flags;/**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */ void *ib_flow;/**< Verbs flow pointer. */ -uint32_t hrxq;/**< Hash Rx queue object index. */ struct mlx5_vf_vlan vf_vlan;/**< Structure for VF VLAN workaround. */ union {uint32_t qrss_id;/**< Uniqie Q/RSS suffix subflow tag. */ uint32_t mtr_flow_id;/**< Unique meter match flow id. */ }; +union { +uint32_t hrxq;/**< Hash Rx queue object index. */ +uint32_t jump;/**< Index to the jump action resource. */ +uint32_t port_id_action; +/**< Index to port ID action resource. */ + };#ifdef HAVE_IBV_FLOW_DV_SUPPORT struct mlx5_flow_handle_dv dvh;#endif
drivers/net/mlx5/mlx5_flow_dv.c +32 -16
121 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +16 -6
@@ -1754,12 +1754,17 @@claim_zero (mlx5_glue->destroy_flow (handle->ib_flow)); handle->ib_flow =NULL ; } +/* hrxq is union, don't touch it only the flag is set. */ if (handle->hrxq) { -if (handle->act_flags &MLX5_FLOW_ACTION_DROP ) +if (handle->act_flags &MLX5_FLOW_ACTION_DROP ) {mlx5_hrxq_drop_release (dev); -else + handle->hrxq =0 ; + }else if (handle->act_flags & + (MLX5_FLOW_ACTION_QUEUE | +MLX5_FLOW_ACTION_RSS )) {mlx5_hrxq_release (dev, handle->hrxq); - handle->hrxq =0 ; + handle->hrxq =0 ; + } }if (handle->vf_vlan.tag && handle->vf_vlan.created)mlx5_vlan_vmwa_release (dev, &handle->vf_vlan);
@@ -1891,12 +1896,17 @@ err = rte_errno;/* Save rte_errno before cleanup. */ SILIST_FOREACH (priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW ], flow->dev_handles, dev_handles, handle, next) { +/* hrxq is union, don't touch it only the flag is set. */ if (handle->hrxq) { -if (handle->act_flags &MLX5_FLOW_ACTION_DROP ) +if (handle->act_flags &MLX5_FLOW_ACTION_DROP ) {mlx5_hrxq_drop_release (dev); -else + handle->hrxq =0 ; + }else if (handle->act_flags & + (MLX5_FLOW_ACTION_QUEUE | +MLX5_FLOW_ACTION_RSS )) {mlx5_hrxq_release (dev, handle->hrxq); - handle->hrxq =0 ; + handle->hrxq =0 ; + } }if (handle->vf_vlan.tag && handle->vf_vlan.created)mlx5_vlan_vmwa_release (dev, &handle->vf_vlan);
Signature · 1 line
1.8.3.1
PATCH v2 2/10 net/mlx5: optimize action flags in flow handle
In reply to Suanming MouAs only limited bits is used in act_flags for flow destroy, it's a bit expensive to save the whole 64 bits. Move the act_flags out of flow handle and save the needed bits for flow destroy to save some bytes for the flow handle data struct.
The fate action type and mark bits are reserved as they will be used in flow destroy.
--- drivers/net/mlx5/mlx5_flow.c | 8 ++--- drivers/net/mlx5/mlx5_flow.h | 18 ++++++++-- drivers/net/mlx5/mlx5_flow_dv.c | 68 ++++++++++++++++++++++++-------------- drivers/net/mlx5/mlx5_flow_verbs.c | 23 +++++++------ 4 files changed, 75 insertions(+), 42 deletions(-)
drivers/net/mlx5/mlx5_flow.c +3 -5
@@ -722,8 +722,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, struct mlx5_flow_handle *dev_handle) {struct mlx5_priv *priv = dev->data->dev_private; -const int mark = !!(dev_handle->act_flags & - (MLX5_FLOW_ACTION_FLAG |MLX5_FLOW_ACTION_MARK )); +const int mark = dev_handle->mark;const int tunnel = !!(dev_handle->layers &MLX5_FLOW_LAYER_TUNNEL );unsigned int i;
@@ -800,8 +799,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, struct mlx5_flow_handle *dev_handle) {struct mlx5_priv *priv = dev->data->dev_private; -const int mark = !!(dev_handle->act_flags & - (MLX5_FLOW_ACTION_FLAG |MLX5_FLOW_ACTION_MARK )); +const int mark = dev_handle->mark;const int tunnel = !!(dev_handle->layers &MLX5_FLOW_LAYER_TUNNEL );unsigned int i;
@@ -2718,7 +2716,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,* help to do the optimization work for source code. * If no decap actions, use the layers directly. */ -if (!(dev_flow->handle->act_flags &MLX5_FLOW_ACTION_DECAP )) +if (!(dev_flow->act_flags &MLX5_FLOW_ACTION_DECAP ))return dev_flow->handle->layers;/* Convert L3 layers with decap action. */ if (dev_flow->handle->layers &MLX5_FLOW_LAYER_INNER_L3_IPV4 )
drivers/net/mlx5/mlx5_flow.h +16 -2
@@ -339,6 +339,16 @@ enum mlx5_flow_drv_type { MLX5_FLOW_TYPE_MAX, }; +/* Fate action type. */ +enum mlx5_flow_fate_type { +MLX5_FLOW_FATE_NONE ,/* Egress flow. */ +MLX5_FLOW_FATE_QUEUE , +MLX5_FLOW_FATE_JUMP , +MLX5_FLOW_FATE_PORT_ID , +MLX5_FLOW_FATE_DROP , +MLX5_FLOW_FATE_MAX , +}; +/* Matcher PRM representation */ struct mlx5_flow_dv_match_params {size_t size;
@@ -502,19 +512,21 @@ struct mlx5_flow_handle {/**< Index to next device flow handle. */ uint64_t layers;/**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ -uint64_t act_flags; -/**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */ void *ib_flow;/**< Verbs flow pointer. */ struct mlx5_vf_vlan vf_vlan;/**< Structure for VF VLAN workaround. */ union {uint32_t qrss_id;/**< Uniqie Q/RSS suffix subflow tag. */ uint32_t mtr_flow_id;/**< Unique meter match flow id. */ }; + uint32_t mark:1; /**< Metadate rxq mark flag. */ + uint32_t fate_action:3; /**< Fate action type. */union {uint32_t hrxq;/**< Hash Rx queue object index. */ uint32_t jump;/**< Index to the jump action resource. */ uint32_t port_id_action;/**< Index to port ID action resource. */ +uint32_t fate_idx; +/**< Generic value indicates the fate action. */ };#ifdef HAVE_IBV_FLOW_DV_SUPPORT struct mlx5_flow_handle_dv dvh;
@@ -624,6 +636,8 @@ struct mlx5_flow_verbs_workspace {struct mlx5_flow {struct rte_flow *flow;/**< Pointer to the main flow. */ uint64_t hash_fields;/**< Verbs hash Rx queue hash fields. */ +uint64_t act_flags; +/**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */ bool external;/**< true if the flow is created external to PMD. */ uint8_t ingress;/**< 1 if the flow is ingress. */ union {
drivers/net/mlx5/mlx5_flow_dv.c +43 -25
157 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +13 -10
@@ -1589,22 +1589,27 @@case RTE_FLOW_ACTION_TYPE_FLAG :flow_verbs_translate_action_flag (dev_flow, actions); action_flags |=MLX5_FLOW_ACTION_FLAG ; + dev_flow->handle->mark =1 ;break ;case RTE_FLOW_ACTION_TYPE_MARK :flow_verbs_translate_action_mark (dev_flow, actions); action_flags |=MLX5_FLOW_ACTION_MARK ; + dev_flow->handle->mark =1 ;break ;case RTE_FLOW_ACTION_TYPE_DROP :flow_verbs_translate_action_drop (dev_flow, actions); action_flags |=MLX5_FLOW_ACTION_DROP ; + dev_flow->handle->fate_action =MLX5_FLOW_FATE_DROP ;break ;case RTE_FLOW_ACTION_TYPE_QUEUE :flow_verbs_translate_action_queue (dev_flow, actions); action_flags |=MLX5_FLOW_ACTION_QUEUE ; + dev_flow->handle->fate_action =MLX5_FLOW_FATE_QUEUE ;break ;case RTE_FLOW_ACTION_TYPE_RSS :flow_verbs_translate_action_rss (dev_flow, actions); action_flags |=MLX5_FLOW_ACTION_RSS ; + dev_flow->handle->fate_action =MLX5_FLOW_FATE_QUEUE ;break ;case RTE_FLOW_ACTION_TYPE_COUNT : ret = flow_verbs_translate_action_count(dev_flow,
@@ -1621,7 +1626,7 @@ "action not supported"); } } - dev_flow->handle->act_flags = action_flags; + dev_flow->act_flags = action_flags;for (; items->type !=RTE_FLOW_ITEM_TYPE_END ; items++) {int tunnel = !!(item_flags &MLX5_FLOW_LAYER_TUNNEL );
@@ -1756,12 +1761,11 @@ }/* hrxq is union, don't touch it only the flag is set. */ if (handle->hrxq) { -if (handle->act_flags &MLX5_FLOW_ACTION_DROP ) { +if (handle->fate_action ==MLX5_FLOW_FATE_DROP ) {mlx5_hrxq_drop_release (dev); handle->hrxq =0 ; - }else if (handle->act_flags & - (MLX5_FLOW_ACTION_QUEUE | -MLX5_FLOW_ACTION_RSS )) { + }else if (handle->fate_action == +MLX5_FLOW_FATE_QUEUE ) {mlx5_hrxq_release (dev, handle->hrxq); handle->hrxq =0 ; }
@@ -1833,7 +1837,7 @@for (idx = priv->flow_idx -1 ; idx >= priv->flow_nested_idx; idx--) { dev_flow = &((struct mlx5_flow *)priv->inter_flows)[idx]; handle = dev_flow->handle; -if (handle->act_flags &MLX5_FLOW_ACTION_DROP ) { +if (handle->fate_action ==MLX5_FLOW_FATE_DROP ) { hrxq =mlx5_hrxq_drop_new (dev);if (!hrxq) { rte_flow_error_set
@@ -1898,12 +1902,11 @@ dev_handles, handle, next) {/* hrxq is union, don't touch it only the flag is set. */ if (handle->hrxq) { -if (handle->act_flags &MLX5_FLOW_ACTION_DROP ) { +if (handle->fate_action ==MLX5_FLOW_FATE_DROP ) {mlx5_hrxq_drop_release (dev); handle->hrxq =0 ; - }else if (handle->act_flags & - (MLX5_FLOW_ACTION_QUEUE | -MLX5_FLOW_ACTION_RSS )) { + }else if (handle->fate_action == +MLX5_FLOW_FATE_QUEUE ) {mlx5_hrxq_release (dev, handle->hrxq); handle->hrxq =0 ; }
Signature · 1 line
1.8.3.1
PATCH v2 3/10 net/mlx5: reorganize the mlx5 flow handle struct
In reply to Suanming MouCurrently, the mlx5_flow_handle struct is not fully aligned and has some bits wasted. The members can be optimized and reorganized to save memory.
1. As metadata and meter is sharing the same flow match id, now the flow id is limited to 24 bits due to the 8 MSBs are used as for the meter color. Align the flow id to other bit members to 32 bits to save the mlx5 flow handle memory.
2. The vlan_vf in struct mlx5_flow_handle_dv was already moved to struct mlx5_flow_handle. Remove the legacy vlan_vf in struct mlx5_flow_handle_dv.
3. Reorganize the vlan_vf in mlx5_flow_handle with member SILIST_ENTRY next to make it align with 8 bytes.
4. Reorganize the header modify in mlx5_flow_handle_dv to ILIST_ENTRY next to make it align to with bytes.
5. Introduce __rte_pack attribute to make the struct tightly organized.
It will totally save 20 bytes memory for mlx5_flow_handle struct.
For the resource objects which are converted to indexed, align the names with the prefix of rix_.
--- drivers/net/mlx5/mlx5_flow.c | 8 ++--- drivers/net/mlx5/mlx5_flow.h | 29 +++++++---------- drivers/net/mlx5/mlx5_flow_dv.c | 66 ++++++++++++++++++++------------------ drivers/net/mlx5/mlx5_flow_verbs.c | 18 +++++------ 4 files changed, 59 insertions(+), 62 deletions(-)
drivers/net/mlx5/mlx5_flow.c +4 -4
@@ -2323,8 +2323,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,SILIST_FOREACH (priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW ], flow->dev_handles, handle_idx, dev_handle, next) -if (dev_handle->qrss_id) -flow_qrss_free_id (dev, dev_handle->qrss_id); +if (dev_handle->split_flow_id) +flow_qrss_free_id (dev, dev_handle->split_flow_id); } static int
@@ -3988,7 +3988,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,* reallocation becomes possible (for example, for * other flows in other threads). */ - dev_flow->handle->qrss_id = qrss_id; + dev_flow->handle->split_flow_id = qrss_id; ret =mlx5_flow_get_reg_id (dev,MLX5_COPY_MARK ,0 , error);if (ret <0 )
@@ -4101,7 +4101,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, ret = -rte_errno; goto exit; } - dev_flow->handle->mtr_flow_id = mtr_tag_id; + dev_flow->handle->split_flow_id = mtr_tag_id;/* Setting the sfx group atrr. */ sfx_attr.group = sfx_attr.transfer ? (MLX5_FLOW_TABLE_LEVEL_SUFFIX - 1) :
drivers/net/mlx5/mlx5_flow.h +12 -17
@@ -494,44 +494,39 @@ struct mlx5_flow_rss {struct mlx5_flow_handle_dv {/* Flow DV api: */ struct mlx5_flow_dv_matcher *matcher;/**< Cache to matcher. */ -uint32_t encap_decap; -/**< Index to encap/decap resource in cache. */ struct mlx5_flow_dv_modify_hdr_resource *modify_hdr;/**< Pointer to modify header resource in cache. */ -struct mlx5_vf_vlan vf_vlan; -/**< Structure for VF VLAN workaround. */ -uint32_t push_vlan_res; +uint32_t rix_encap_decap; +/**< Index to encap/decap resource in cache. */ +uint32_t rix_push_vlan;/**< Index to push VLAN action resource in cache. */ -uint32_t tag_resource; +uint32_t rix_tag;/**< Index to the tag action. */ -}; +} __rte_packed;/** Device flow handle structure: used both for creating & destroying. */ struct mlx5_flow_handle {SILIST_ENTRY (uint32_t )next; +struct mlx5_vf_vlan vf_vlan;/**< Structure for VF VLAN workaround. */ /**< Index to next device flow handle. */ uint64_t layers;/**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ void *ib_flow;/**< Verbs flow pointer. */ -struct mlx5_vf_vlan vf_vlan;/**< Structure for VF VLAN workaround. */ -union { -uint32_t qrss_id;/**< Uniqie Q/RSS suffix subflow tag. */ -uint32_t mtr_flow_id;/**< Unique meter match flow id. */ - }; +uint32_t split_flow_id:28 ;/**< Sub flow unique match flow id. */ uint32_t mark:1 ;/**< Metadate rxq mark flag. */ uint32_t fate_action:3 ;/**< Fate action type. */ union { -uint32_t hrxq;/**< Hash Rx queue object index. */ -uint32_t jump;/**< Index to the jump action resource. */ -uint32_t port_id_action; +uint32_t rix_hrxq;/**< Hash Rx queue object index. */ +uint32_t rix_jump;/**< Index to the jump action resource. */ +uint32_t rix_port_id_action;/**< Index to port ID action resource. */ -uint32_t fate_idx; +uint32_t rix_fate;/**< Generic value indicates the fate action. */ };#ifdef HAVE_IBV_FLOW_DV_SUPPORT struct mlx5_flow_handle_dv dvh;#endif -}; +} __rte_packed;/* * Size for Verbs device flow handle structure only. Do not use the DV only
drivers/net/mlx5/mlx5_flow_dv.c +34 -32
229 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +9 -9
@@ -1760,14 +1760,14 @@ handle->ib_flow =NULL ; }/* hrxq is union, don't touch it only the flag is set. */ -if (handle->hrxq) { +if (handle->rix_hrxq) {if (handle->fate_action ==MLX5_FLOW_FATE_DROP ) {mlx5_hrxq_drop_release (dev); - handle->hrxq =0 ; + handle->rix_hrxq =0 ; }else if (handle->fate_action ==MLX5_FLOW_FATE_QUEUE ) { -mlx5_hrxq_release (dev, handle->hrxq); - handle->hrxq =0 ; +mlx5_hrxq_release (dev, handle->rix_hrxq); + handle->rix_hrxq =0 ; } }if (handle->vf_vlan.tag && handle->vf_vlan.created)
@@ -1872,7 +1872,7 @@ "cannot get hash queue"); goto error; } - handle->hrxq = hrxq_idx; + handle->rix_hrxq = hrxq_idx; }MLX5_ASSERT (hrxq); handle->ib_flow = mlx5_glue->create_flow(hrxq->qp,
@@ -1901,14 +1901,14 @@SILIST_FOREACH (priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW ], flow->dev_handles, dev_handles, handle, next) {/* hrxq is union, don't touch it only the flag is set. */ -if (handle->hrxq) { +if (handle->rix_hrxq) {if (handle->fate_action ==MLX5_FLOW_FATE_DROP ) {mlx5_hrxq_drop_release (dev); - handle->hrxq =0 ; + handle->rix_hrxq =0 ; }else if (handle->fate_action ==MLX5_FLOW_FATE_QUEUE ) { -mlx5_hrxq_release (dev, handle->hrxq); - handle->hrxq =0 ; +mlx5_hrxq_release (dev, handle->rix_hrxq); + handle->rix_hrxq =0 ; } }if (handle->vf_vlan.tag && handle->vf_vlan.created)
Signature · 1 line
1.8.3.1
PATCH v2 4/10 net/mlx5: optimize flow meter handle type
In reply to Suanming MouWhile flow attaches the meter handle, the meter id can be the unique tag for the flow to get the meter handle. It's no need for flow to save the pointer of the meter handle.
Save the meter id instead of pointer helps reduce the size for rte flow structure.
As the supported maximum meter rule is 4K, uint16_t type is selected for the meter id.
--- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_flow_dv.c | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5_flow.h +1 -1
@@ -757,7 +757,7 @@ struct rte_flow {uint32_t counter;/**< Holds flow counter. */ struct mlx5_flow_mreg_copy_resource *mreg_copy;/**< pointer to metadata register copy table resource. */ -struct mlx5_flow_meter *meter;/**< Holds flow meter. */ +uint16_t meter;/**< Holds flow meter id. */ uint32_t dev_handles;/**< Device flow handles that are part of the flow. */ struct mlx5_fdir *fdir;/**< Pointer to associated FDIR if any. */
drivers/net/mlx5/mlx5_flow_dv.c +22 -7
@@ -7430,6 +7430,7 @@ struct field_modify_info modify_tcp[] = {struct mlx5_flow_dv_port_id_action_resource port_id_resource;int action_type = actions->type;const struct rte_flow_action *found_action =NULL ; +struct mlx5_flow_meter *fm =NULL ;switch (action_type) {case RTE_FLOW_ACTION_TYPE_VOID :
@@ -7806,20 +7807,30 @@ struct field_modify_info modify_tcp[] = {case RTE_FLOW_ACTION_TYPE_METER : mtr = actions->conf;if (!flow->meter) { - flow->meter =mlx5_flow_meter_attach (priv, - mtr->mtr_id, attr, - error); -if (!flow->meter) + fm =mlx5_flow_meter_attach (priv, mtr->mtr_id, + attr, error); +if (!fm)return rte_flow_error_set (error, rte_errno,RTE_FLOW_ERROR_TYPE_ACTION ,NULL ,"meter not found " "or invalid parameters" ); + flow->meter = fm->meter_id; }/* Set the meter action. */ +if (!fm) { + fm =mlx5_flow_meter_find (priv, flow->meter); +if (!fm) +return rte_flow_error_set (error, + rte_errno, +RTE_FLOW_ERROR_TYPE_ACTION , +NULL , +"meter not found " +"or invalid parameters" ); + } dev_flow->dv.actions[actions_n++] = - flow->meter->mfts->meter_action; + fm->mfts->meter_action; action_flags |=MLX5_FLOW_ACTION_METER ;break ;case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP :
@@ -8524,8 +8535,12 @@ struct field_modify_info modify_tcp[] = { flow->counter =0 ; }if (flow->meter) { -mlx5_flow_meter_detach (flow->meter); - flow->meter =NULL ; +struct mlx5_flow_meter *fm; + + fm =mlx5_flow_meter_find (priv, flow->meter); +if (fm) +mlx5_flow_meter_detach (fm); + flow->meter =0 ; }while (flow->dev_handles) {uint32_t tmp_idx = flow->dev_handles;
Signature · 1 line
1.8.3.1
PATCH v2 5/10 net/mlx5: allocate meter from indexed pool
In reply to Suanming MouThis patch allocate the meter object memory from indexed memory pool which will help to save the MALLOC_ELEM_OVERHEAD memory taken by rte_malloc().
--- drivers/net/mlx5/mlx5.c | 11 +++++++++++ drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_meter.c | 11 ++++++----- 4 files changed, 19 insertions(+), 5 deletions(-)
drivers/net/mlx5/mlx5.c +11 -0
@@ -257,6 +257,17 @@ struct mlx5_dev_spawn_data { },#endif { + .size = sizeof(struct mlx5_flow_meter), + .trunk_size = 64, + .grow_trunk = 3, + .grow_shift = 2, + .need_lock = 0, + .release_mem_en = 1, + .malloc = rte_malloc_socket, + .free = rte_free, + .type = "mlx5_meter_ipool", + }, + { .size = (sizeof(struct mlx5_hrxq) + MLX5_RSS_HASH_KEY_LEN), .trunk_size = 64, .grow_trunk = 3,
drivers/net/mlx5/mlx5.h +1 -0
@@ -52,6 +52,7 @@ enum mlx5_ipool_index {MLX5_IPOOL_PORT_ID ,/* Pool for port id resource. */ MLX5_IPOOL_JUMP ,/* Pool for jump resource. */ #endif +MLX5_IPOOL_MTR ,/* Pool for meter resource. */ MLX5_IPOOL_HRXQ ,/* Pool for hrxq resource. */ MLX5_IPOOL_MLX5_FLOW ,/* Pool for mlx5 flow handle. */ MLX5_IPOOL_MAX,
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -703,6 +703,7 @@ struct mlx5_meter_domains_infos {struct mlx5_flow_meter {TAILQ_ENTRY (mlx5_flow_meter) next;/**< Pointer to the next flow meter structure. */ +uint32_t idx;/* Index to meter object. */ uint32_t meter_id;/**< Meter id. */ struct rte_mtr_params params;
drivers/net/mlx5/mlx5_flow_meter.c +6 -5
@@ -631,6 +631,7 @@ };int ret;unsigned int i; +uint32_t idx =0 ;if (!priv->mtr_en) return -rte_mtr_error_set(error, ENOTSUP,
@@ -647,12 +648,12 @@RTE_MTR_ERROR_TYPE_METER_PROFILE_ID , NULL, "Meter profile id not valid.");/* Allocate the flow meter memory. */ - fm =rte_calloc (__func__,1 , -sizeof (struct mlx5_flow_meter ),RTE_CACHE_LINE_SIZE ); + fm =mlx5_ipool_zmalloc (priv->sh->ipool[MLX5_IPOOL_MTR ], &idx);if (fm ==NULL )return -rte_mtr_error_set (error,ENOMEM ,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL ,"Memory alloc failed for meter." ); + fm->idx = idx;/* Fill the flow meter parameters. */ fm->meter_id = meter_id; fm->profile = fmp;
@@ -683,7 +684,7 @@for (i =0 ; i <RTE_DIM (fm->policer_stats.cnt); i++)if (fm->policer_stats.cnt[i])mlx5_counter_free (dev, fm->policer_stats.cnt[i]); -rte_free (fm); +mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MTR ], idx);return -rte_mtr_error_set (error, -ret,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL ,"Failed to create devx meter." );
@@ -746,7 +747,7 @@/* Free meter flow table */ mlx5_flow_destroy_policer_rules (dev, fm, &attr);mlx5_flow_destroy_mtr_tbls (dev, fm->mfts); -rte_free (fm); +mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MTR ], fm->idx);return 0 ; }
@@ -1274,7 +1275,7 @@ struct mlx5_flow_meter */* Free meter flow table. */ mlx5_flow_destroy_policer_rules (dev, fm, &attr);mlx5_flow_destroy_mtr_tbls (dev, fm->mfts); -rte_free (fm); +mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MTR ], fm->idx); } TAILQ_FOREACH_SAFE(fmp, fmps, next, tmp) {/* Check unused. */
Signature · 1 line
1.8.3.1
PATCH v2 6/10 net/mlx5: convert mark copy resource to indexed
In reply to Suanming MouAllocate mark copy resource from indexed pool helps rte flow saves the 4 bytes index instead of 8 bytes pointer. For mark copy resource itself, it helps save MALLOC_ELEM_OVERHEAD bytes from rte_malloc().
--- drivers/net/mlx5/mlx5.c | 11 +++++++++++ drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.c | 40 ++++++++++++++++++++++++++++------------ drivers/net/mlx5/mlx5_flow.h | 5 +++-- 4 files changed, 43 insertions(+), 14 deletions(-)
drivers/net/mlx5/mlx5.c +11 -0
@@ -268,6 +268,17 @@ struct mlx5_dev_spawn_data { .type = "mlx5_meter_ipool", }, { + .size = sizeof(struct mlx5_flow_meter), + .trunk_size = 64, + .grow_trunk = 3, + .grow_shift = 2, + .need_lock = 0, + .release_mem_en = 1, + .malloc = rte_malloc_socket, + .free = rte_free, + .type = "mlx5_mcp_ipool", + }, + { .size = (sizeof(struct mlx5_hrxq) + MLX5_RSS_HASH_KEY_LEN), .trunk_size = 64, .grow_trunk = 3,
drivers/net/mlx5/mlx5.h +1 -0
@@ -53,6 +53,7 @@ enum mlx5_ipool_index {MLX5_IPOOL_JUMP ,/* Pool for jump resource. */ #endifMLX5_IPOOL_MTR ,/* Pool for meter resource. */ +MLX5_IPOOL_MCP ,/* Pool for metadata resource. */ MLX5_IPOOL_HRXQ ,/* Pool for hrxq resource. */ MLX5_IPOOL_MLX5_FLOW ,/* Pool for mlx5 flow handle. */ MLX5_IPOOL_MAX,
drivers/net/mlx5/mlx5_flow.c +28 -12
@@ -2962,6 +2962,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, [3] = { .type = RTE_FLOW_ACTION_TYPE_END, }, };struct mlx5_flow_mreg_copy_resource *mcp_res; +uint32_t idx =0 ;int ret;/* Fill the register fileds in the flow. */
@@ -3030,11 +3031,12 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, }; }/* Build a new entry. */ - mcp_res =rte_zmalloc (__func__,sizeof (*mcp_res),0 ); + mcp_res =mlx5_ipool_zmalloc (priv->sh->ipool[MLX5_IPOOL_MCP ], &idx);if (!mcp_res) { rte_errno =ENOMEM ;return NULL ; } + mcp_res->idx = idx;/* * The copy Flows are not included in any list. There * ones are referenced from other Flows and can not
@@ -3056,7 +3058,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, error:if (mcp_res->flow)flow_list_destroy (dev,NULL , mcp_res->flow); -rte_free (mcp_res); +mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], mcp_res->idx);return NULL ; }
@@ -3072,9 +3074,13 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, flow_mreg_del_copy_action(struct rte_eth_dev *dev, struct rte_flow *flow) { - struct mlx5_flow_mreg_copy_resource *mcp_res = flow->mreg_copy; + struct mlx5_flow_mreg_copy_resource *mcp_res;struct mlx5_priv *priv = dev->data->dev_private; +if (!flow->rix_mreg_copy) +return ; + mcp_res =mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_MCP ], + flow->rix_mreg_copy);if (!mcp_res || !priv->mreg_cp_tbl)return ;if (flow->copy_applied) {
@@ -3093,8 +3099,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,MLX5_ASSERT (mcp_res->flow);flow_list_destroy (dev,NULL , mcp_res->flow);mlx5_hlist_remove (priv->mreg_cp_tbl, &mcp_res->hlist_ent); -rte_free (mcp_res); - flow->mreg_copy =NULL ; +mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], mcp_res->idx); + flow->rix_mreg_copy =0 ; }/**
@@ -3112,10 +3118,15 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, flow_mreg_start_copy_action(struct rte_eth_dev *dev, struct rte_flow *flow) { - struct mlx5_flow_mreg_copy_resource *mcp_res = flow->mreg_copy; + struct mlx5_flow_mreg_copy_resource *mcp_res; +struct mlx5_priv *priv = dev->data->dev_private;int ret; -if (!mcp_res || flow->copy_applied) +if (!flow->rix_mreg_copy || flow->copy_applied) +return 0 ; + mcp_res =mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_MCP ], + flow->rix_mreg_copy); +if (!mcp_res)return 0 ;if (!mcp_res->appcnt) { ret =flow_drv_apply (dev, mcp_res->flow,NULL );
@@ -3139,9 +3150,14 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, flow_mreg_stop_copy_action(struct rte_eth_dev *dev, struct rte_flow *flow) { - struct mlx5_flow_mreg_copy_resource *mcp_res = flow->mreg_copy; + struct mlx5_flow_mreg_copy_resource *mcp_res; +struct mlx5_priv *priv = dev->data->dev_private; -if (!mcp_res || !flow->copy_applied) +if (!flow->rix_mreg_copy || !flow->copy_applied) +return ; + mcp_res =mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_MCP ], + flow->rix_mreg_copy); +if (!mcp_res)return ;MLX5_ASSERT (mcp_res->appcnt); --mcp_res->appcnt;
@@ -3172,7 +3188,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,MLX5_ASSERT (mcp_res->flow);flow_list_destroy (dev,NULL , mcp_res->flow);mlx5_hlist_remove (priv->mreg_cp_tbl, &mcp_res->hlist_ent); -rte_free (mcp_res); +mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], mcp_res->idx); }/**
@@ -3264,7 +3280,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, (dev,MLX5_FLOW_MARK_DEFAULT , error);if (!mcp_res)return -rte_errno; - flow->mreg_copy = mcp_res; + flow->rix_mreg_copy = mcp_res->idx;if (dev->data->dev_started) { mcp_res->appcnt++; flow->copy_applied =1 ;
@@ -3277,7 +3293,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,flow_mreg_add_copy_action (dev, mark->id, error);if (!mcp_res)return -rte_errno; - flow->mreg_copy = mcp_res; + flow->rix_mreg_copy = mcp_res->idx;if (dev->data->dev_started) { mcp_res->appcnt++; flow->copy_applied =1 ;
drivers/net/mlx5/mlx5_flow.h +3 -2
@@ -460,6 +460,7 @@ struct mlx5_flow_mreg_copy_resource {/* List entry for device flows. */ uint32_t refcnt;/* Reference counter. */ uint32_t appcnt;/* Apply/Remove counter. */ +uint32_t idx;struct rte_flow *flow;/* Built flow for copy. */ };
@@ -756,8 +757,8 @@ struct rte_flow {enum mlx5_flow_drv_type drv_type;/**< Driver type. */ struct mlx5_flow_rss rss;/**< RSS context. */ uint32_t counter;/**< Holds flow counter. */ -struct mlx5_flow_mreg_copy_resource *mreg_copy; -/**< pointer to metadata register copy table resource. */ +uint32_t rix_mreg_copy; +/**< Index to metadata register copy table resource. */ uint16_t meter;/**< Holds flow meter id. */ uint32_t dev_handles;/**< Device flow handles that are part of the flow. */
Signature · 1 line
1.8.3.1
PATCH v2 7/10 net/mlx5: optimize flow director filter memory
In reply to Suanming MouFrom: Wentao Cui <[email protected]>
This commit is for mlx5 fdir flow memory optimization.
Currently for the fdir member in rte_flow structure. It saves the fdir memory pointer directly. As fdir is fading away, use one bit help to indicate the function in the flow and add the content to an extra list save the memory for the other widely usage cases.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.c | 62 ++++++++++++++++++++++++++++++++++++-------- drivers/net/mlx5/mlx5_flow.h | 9 ++++++- 3 files changed, 60 insertions(+), 12 deletions(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -556,6 +556,7 @@ struct mlx5_priv {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 */ + LIST_HEAD(fdir, mlx5_fdir_flow) fdir_flows; /* fdir flows. */ };#define PORT_ID (priv) ((priv)->dev_data->port_id)
drivers/net/mlx5/mlx5_flow.c +51 -11
124 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +8 -1
@@ -751,6 +751,13 @@ struct mlx5_flow_meter_profile {uint32_t ref_cnt;/**< Use count. */ }; +/* Fdir flow struture */ +struct mlx5_fdir_flow { +LIST_ENTRY (mlx5_fdir_flow) next;/* Pointer to the next element. */ +struct mlx5_fdir *fdir;/* Pointer to fdir. */ +struct rte_flow *flow;/* Pointer to flow. */ +}; +/* Flow structure. */ struct rte_flow {TAILQ_ENTRY (rte_flow) next;/**< Pointer to the next flow structure. */
@@ -762,7 +769,7 @@ struct rte_flow {uint16_t meter;/**< Holds flow meter id. */ uint32_t dev_handles;/**< Device flow handles that are part of the flow. */ -struct mlx5_fdir *fdir;/**< Pointer to associated FDIR if any. */ + uint32_t fdir:1; /**< Identifier of associated FDIR if any. */uint32_t hairpin_flow_id;/**< The flow id used for hairpin. */ uint32_t copy_applied:1; /**< The MARK copy Flow os applied. */ };
Signature · 1 line
1.8.3.1
PATCH v2 8/10 net/mlx5: optimize mlx5 flow RSS struct
In reply to Suanming MouWhen destroy the flow with RSS, flow can invoke the queues information from hrxq index table object, since the queue number and list are both saved to the index table object. No need to save the duplicated data in rte flow.
Save the RSS description information to the intermediate private data when create the flow with RSS action helps to save the memory for rte flow.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.c | 72 ++++++++++++++++++++++---------------- drivers/net/mlx5/mlx5_flow.h | 11 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 59 ++++++++++++++++--------------- drivers/net/mlx5/mlx5_flow_verbs.c | 59 +++++++++++++++---------------- 5 files changed, 108 insertions(+), 94 deletions(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -515,6 +515,7 @@ struct mlx5_priv {struct mlx5_flows flows;/* RTE Flow rules. */ struct mlx5_flows ctrl_flows;/* Control flow rules. */ void *inter_flows;/* Intermediate resources for flow creation. */ +void *rss_desc;/* Intermediate rss description resources. */ int flow_idx;/* Intermediate device flow index. */ int flow_nested_idx;/* Intermediate device flow index, nested. */ LIST_HEAD(rxq, mlx5_rxq_ctrl) rxqsctrl; /* DPDK Rx queues. */
drivers/net/mlx5/mlx5_flow.c +42 -30
168 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +6 -5
@@ -483,14 +483,16 @@ struct ibv_spec_header {uint16_t size; }; -struct mlx5_flow_rss { +/* RSS description. */ +struct mlx5_flow_rss_desc {uint32_t level;uint32_t queue_num;/**< Number of entries in @p queue. */ uint64_t types;/**< Specific RSS hash types (see ETH_RSS_*). */ -uint16_t (*queue)[];/**< Destination queues to redirect traffic to. */ uint8_t key[MLX5_RSS_HASH_KEY_LEN ];/**< RSS hash key. */ +uint16_t queue[];/**< Destination queues to redirect traffic to. */ }; +/** Device flow handle structure for DV mode only. */ struct mlx5_flow_handle_dv {/* Flow DV api: */
@@ -762,7 +764,6 @@ struct mlx5_fdir_flow {struct rte_flow {TAILQ_ENTRY (rte_flow) next;/**< Pointer to the next flow structure. */ enum mlx5_flow_drv_type drv_type;/**< Driver type. */ -struct mlx5_flow_rss rss;/**< RSS context. */ uint32_t counter;/**< Holds flow counter. */ uint32_t rix_mreg_copy;/**< Index to metadata register copy table resource. */
@@ -855,8 +856,8 @@ uint32_t mlx5_flow_id_release(struct mlx5_flow_id_pool *pool,int mlx5_flow_group_to_table (const struct rte_flow_attr *attributes,bool external,uint32_t group,bool fdb_def_rule,uint32_t *table,struct rte_flow_error *error); -uint64_t mlx5_flow_hashfields_adjust (struct mlx5_flow *dev_flow,int tunnel, -uint64_t layer_types, +uint64_t mlx5_flow_hashfields_adjust (struct mlx5_flow_rss_desc *rss_desc, +int tunnel,uint64_t layer_types,uint64_t hash_fields);uint32_t mlx5_flow_adjust_priority (struct rte_eth_dev *dev,int32_t priority,uint32_t subpriority);
drivers/net/mlx5/mlx5_flow_dv.c +31 -28
154 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +28 -31
142 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 9/10 net/mlx5: allocate rte flow from indexed pool
In reply to Suanming MouThis commit allocates rte flow from indexed memory pool.
Allocate rte flow memory from indexed memory pool helps save more than MALLOC_ELEM_OVERHEAD bytes memory from rte_malloc().
--- drivers/net/mlx5/mlx5.c | 13 ++- drivers/net/mlx5/mlx5.h | 15 ++- drivers/net/mlx5/mlx5_flow.c | 234 ++++++++++++++++++++++++++----------------- drivers/net/mlx5/mlx5_flow.h | 6 +- 4 files changed, 160 insertions(+), 108 deletions(-)
drivers/net/mlx5/mlx5.c +11 -2
@@ -300,6 +300,15 @@ struct mlx5_dev_spawn_data { .free = rte_free, .type = "mlx5_flow_handle_ipool", }, + { + .size = sizeof(struct rte_flow), + .trunk_size = 4096, + .need_lock = 1, + .release_mem_en = 1, + .malloc = rte_malloc_socket, + .free = rte_free, + .type = "rte_flow_ipool", + }, };
@@ -2885,8 +2894,8 @@ struct mlx5_flow_id_pool *mlx5_ifindex (eth_dev), eth_dev->data->mac_addrs, MLX5_MAX_MAC_ADDRESSES); -TAILQ_INIT (&priv->flows); -TAILQ_INIT (&priv->ctrl_flows); + priv->flows =0 ; + priv->ctrl_flows =0 ;TAILQ_INIT (&priv->flow_meters);TAILQ_INIT (&priv->flow_meter_profiles);/* Hint libmlx5 to use PMD allocator for data plane resources */
drivers/net/mlx5/mlx5.h +6 -9
@@ -56,6 +56,7 @@ enum mlx5_ipool_index {MLX5_IPOOL_MCP ,/* Pool for metadata resource. */ MLX5_IPOOL_HRXQ ,/* Pool for hrxq resource. */ MLX5_IPOOL_MLX5_FLOW ,/* Pool for mlx5 flow handle. */ +MLX5_IPOOL_RTE_FLOW ,/* Pool for rte_flow. */ MLX5_IPOOL_MAX, };
@@ -109,9 +110,6 @@ struct mlx5_stats_ctrl {uint64_t imissed; }; -/* Flow list . */ -TAILQ_HEAD (mlx5_flows, rte_flow); -/* Default PMD specific parameter value. */ #define MLX5_ARG_UNSET (-1)
@@ -512,8 +510,8 @@ struct mlx5_priv {unsigned int (*reta_idx)[];/* RETA index table. */ unsigned int reta_idx_n;/* RETA index size. */ struct mlx5_drop drop_queue;/* Flow drop queues. */ -struct mlx5_flows flows;/* RTE Flow rules. */ -struct mlx5_flows ctrl_flows;/* Control flow rules. */ +uint32_t flows;/* RTE Flow rules. */ +uint32_t ctrl_flows;/* Control flow rules. */ void *inter_flows;/* Intermediate resources for flow creation. */ void *rss_desc;/* Intermediate rss description resources. */ int flow_idx;/* Intermediate device flow index. */
@@ -715,8 +713,7 @@ struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, struct rte_flow_error *error);int mlx5_flow_destroy (struct rte_eth_dev *dev,struct rte_flow *flow,struct rte_flow_error *error); -void mlx5_flow_list_flush (struct rte_eth_dev *dev,struct mlx5_flows *list, -bool active); +void mlx5_flow_list_flush (struct rte_eth_dev *dev,uint32_t *list,bool active);int mlx5_flow_flush (struct rte_eth_dev *dev,struct rte_flow_error *error); int mlx5_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow, const struct rte_flow_action *action, void *data,
@@ -727,8 +724,8 @@ int mlx5_dev_filter_ctrl(struct rte_eth_dev *dev,enum rte_filter_type filter_type, enum rte_filter_op filter_op, void *arg); -int mlx5_flow_start (struct rte_eth_dev *dev,struct mlx5_flows *list); -void mlx5_flow_stop (struct rte_eth_dev *dev,struct mlx5_flows *list); +int mlx5_flow_start (struct rte_eth_dev *dev,uint32_t *list); +void mlx5_flow_stop (struct rte_eth_dev *dev,uint32_t *list);int mlx5_flow_start_default (struct rte_eth_dev *dev);void mlx5_flow_stop_default (struct rte_eth_dev *dev);void mlx5_flow_alloc_intermediate (struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_flow.c +140 -94
554 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +3 -3
@@ -461,7 +461,7 @@ struct mlx5_flow_mreg_copy_resource {uint32_t refcnt;/* Reference counter. */ uint32_t appcnt;/* Apply/Remove counter. */ uint32_t idx; -struct rte_flow *flow;/* Built flow for copy. */ +uint32_t rix_flow;/* Built flow for copy. */ };/* Table data structure of the hash organization. */
@@ -757,12 +757,12 @@ struct mlx5_flow_meter_profile {struct mlx5_fdir_flow {LIST_ENTRY (mlx5_fdir_flow) next;/* Pointer to the next element. */ struct mlx5_fdir *fdir;/* Pointer to fdir. */ -struct rte_flow *flow;/* Pointer to flow. */ +uint32_t rix_flow;/* Index to flow. */ };/* Flow structure. */ struct rte_flow { -TAILQ_ENTRY (rte_flow) next;/**< Pointer to the next flow structure. */ +ILIST_ENTRY (uint32_t )next;/**< Index to the next flow structure. */ enum mlx5_flow_drv_type drv_type;/**< Driver type. */ uint32_t counter;/**< Holds flow counter. */ uint32_t rix_mreg_copy;
Signature · 1 line
1.8.3.1
PATCH v2 10/10 net/mlx5: reorganize rte flow structure
In reply to Suanming MouCurrently, the rte flow structure is not fully aligned and has some bits wasted. The members can be optimized and reorganized to save memory.
1. The drv_type uses only limited bits, change the type to 2 bits what it needs.
2. Align the hairpin_flow_id, drv_type, fdir, copy_applied to 32 bits. As hairpin never uses the full 32 bits.
3. __rte_packed helps tight up the structure memory layout.
The optimization totally helps save 14 bytes for the structure.
--- drivers/net/mlx5/mlx5.c | 3 ++- drivers/net/mlx5/mlx5_flow.h | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5.c +2 -1
@@ -764,7 +764,8 @@ struct mlx5_flow_id_pool * goto error; } } - sh->flow_id_pool =mlx5_flow_id_pool_alloc (UINT32_MAX ); + sh->flow_id_pool =mlx5_flow_id_pool_alloc + ((1 <<HAIRPIN_FLOW_ID_BITS ) -1 );if (!sh->flow_id_pool) {DRV_LOG (ERR ,"can't create flow id pool" ); err =ENOMEM ;
drivers/net/mlx5/mlx5_flow.h +10 -7
@@ -760,20 +760,23 @@ struct mlx5_fdir_flow {uint32_t rix_flow;/* Index to flow. */ }; +#define HAIRPIN_FLOW_ID_BITS 28 +/* Flow structure. */ struct rte_flow {ILIST_ENTRY (uint32_t )next;/**< Index to the next flow structure. */ -enum mlx5_flow_drv_type drv_type;/**< Driver type. */ -uint32_t counter;/**< Holds flow counter. */ -uint32_t rix_mreg_copy; -/**< Index to metadata register copy table resource. */ -uint16_t meter;/**< Holds flow meter id. */ uint32_t dev_handles;/**< Device flow handles that are part of the flow. */ +uint32_t drv_type:2 ;/**< Driver type. */ uint32_t fdir:1 ;/**< Identifier of associated FDIR if any. */ -uint32_t hairpin_flow_id;/**< The flow id used for hairpin. */ +uint32_t hairpin_flow_id:HAIRPIN_FLOW_ID_BITS ; +/**< The flow id used for hairpin. */ uint32_t copy_applied:1 ;/**< The MARK copy Flow os applied. */ -}; +uint32_t rix_mreg_copy; +/**< Index to metadata register copy table resource. */ +uint32_t counter;/**< Holds flow counter. */ +uint16_t meter;/**< Holds flow meter id. */ +} __rte_packed; typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
Signature · 1 line
1.8.3.1
Hi,
Quoted 67 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Thursday, April 16, 2020 11:34 AM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: Ori Kam <[email protected]>; Wentao Cui <[email protected]>; Raslan Darawsheh <[email protected]>; [email protected]
Subject: [PATCH v2 00/10] net/mlx5: optimize flow structureThis patch set is third part of the flow memory consumption optimization. It mainly optimizes the rte flow and mlx5 flow handle structure.
For mlx5 flow handle structure:
1. As one flow has only one fate action, the fate actions are reorganized as union.
2. The action flags are optimized to be the limited bits the flow needs.
3. The bits members are reorganized to align with bytes.For rte flow structure:
1. Meter handle is converted touint32_ttype as unique meter id.
2. Fdir handle is converted to one bit to save the pointer to another list.
3. Metadata handle is converted touint32_ttype as indexed.
4. Remove the duplicated RSS member in rte flow.
5. The bit members are reorganized to align with bytes.Some extra optimizations:
1. Allocate meter resource from indexed memory pool.
2. Allocate rte flow from indexed memory pool.
3. Split RSS type, level, key to common memory as they are not required for the flow destroy.This patch set should be applied after the patch series as below:
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatch
es.dpdk.org%2Fcover%2F68591%2F&data=02%7C01%7Crasland%40mell anox.com%7C48b4af5f669f4b82e2ea08d7e1e10031%7Ca652971c7d2e4d9ba6 a4d149256f461b%7C0%7C0%7C637226228837328616&sdata=tsWnTFMrX tokGwo1usxzLbZ5HGV5OGxkCp9pMZ8Rocs%3D&reserved=0v2:
- Add unified routine for fate actions release.
- Rmove RSS totally from rte flow.
- Allocate rte flow totally from indexed memory pool.Suanming Mou (9):
net/mlx5: reorganize fate actions as union net/mlx5: optimize action flags in flow handle net/mlx5: reorganize the mlx5 flow handle struct net/mlx5: optimize flow meter handle type net/mlx5: allocate meter from indexed pool net/mlx5: convert mark copy resource to indexed net/mlx5: optimize mlx5 flow RSS struct net/mlx5: allocate rte flow from indexed pool net/mlx5: reorganize rte flow structureWentao Cui (1):
net/mlx5: optimize flow director filter memorydrivers/net/mlx5/mlx5.c | 38 +++- drivers/net/mlx5/mlx5.h | 19 +- drivers/net/mlx5/mlx5_flow.c | 406 +++++++++++++++++++++++-------- ------ drivers/net/mlx5/mlx5_flow.h | 89 +++++--- drivers/net/mlx5/mlx5_flow_dv.c | 214 +++++++++++-------- drivers/net/mlx5/mlx5_flow_meter.c | 11 +- drivers/net/mlx5/mlx5_flow_verbs.c | 98 +++++---- 7 files changed, 554 insertions(+), 321 deletions(-)
Quoted 2 lines
--
1.8.3.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh