net/ice: fix wild pointer
PATCH 1/1 net/ice: fix wild pointer
To avoid wild pointer, pointers should be set to NULL after free them.
--- drivers/net/ice/ice_fdir_filter.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ice/ice_fdir_filter.c +7 -1
@@ -403,6 +403,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/*
@@ -525,10 +528,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }/* Remove a profile for some filter type */
Signature · 1 line
2.17.1
Quoted 43 lines · Wang ShougangX
To avoid wild pointer, pointers should be set to NULL after free them.
Fixes 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")Fixes 84dc7a95a2d3 ("net/ice: enable flow director engine")Signed-off-by Wang ShougangX <[email protected]>---
drivers/net/ice/ice_fdir_filter.c| 8 +++++++-1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/ice/ice_fdir_filter.c +7
-1@@ -403,6 +403,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/* @@ -525,10 +528,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }/* Remove a profile for some filter type */ Signature · 1 line
2.17.1
Applied to dpdk-next-net-intel. Thanks.
Quoted 40 lines · Ye Xiaolong
Quoted 39 lines · Wang ShougangX
To avoid wild pointer, pointers should be set to NULL after free them.
Fixes 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")Fixes 84dc7a95a2d3 ("net/ice: enable flow director engine")Signed-off-by Wang ShougangX <[email protected]>---
drivers/net/ice/ice_fdir_filter.c| 8 +++++++-1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/ice/ice_fdir_filter.c +7
-1@@ -403,6 +403,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/* @@ -525,10 +528,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }
Quoted 8 lines
Quoted 4 lines
drivers/net/ice/ice_fdir_filter.c +0
-0/* Remove a profile for some filter type */ Signature · 1 line
2.17.1Reviewed-by Xiaolong Ye <[email protected]>Applied to dpdk-next-net-intel. Thanks.
Please ignore this mail, I'm still waiting for your new patchset.
Thanks,
Xiaolong
Quoted 57 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Thursday, November 7, 2019 11:30 AM
To: Wang, ShougangX <[email protected]>
Cc: [email protected]; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Cao, Yahui <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH] net/ice: fix wild pointerQuoted 47 lines · Ye Xiaolong
Quoted 41 lines · Wang ShougangX
To avoid wild pointer, pointers should be set to NULL after free them.
Fixes 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")Fixes 84dc7a95a2d3 ("net/ice: enable flow director engine")Signed-off-by Wang ShougangX <[email protected]>---
drivers/net/ice/ice_fdir_filter.c| 8 +++++++-1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/ice/ice_fdir_filter.c +7
-2@@ -403,6 +403,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/* @@ -525,10 +528,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }/* Remove a profile for some filter type */ --Quoted 2 lines
2.17.1
Reviewed-by Xiaolong Ye <[email protected]>
Quoted 4 lines
Quoted 1 line
Applied to dpdk-next-net-intel. Thanks.
Please ignore this mail, I'm still waiting for your new patchset.
OK, I will make a patchset.
Quoted 2 lines
Thanks,
Xiaolong
Thanks.
Shougang
v2 cover net/ice: fix memory release in FDIR
In reply to Wang ShougangXThese patches include FDIR memory resource fixes related to ICE driver. Patch 1: fix memzone reserve and release in FDIR
Patch 2: fix removal of FDIR profile
Patch 3: fix FDIR counter resource release
Patch 4: fix wild pointer
---
v2 changes:
Merged patches related to CVL memory resources management into patchset.
Wang ShougangX (4):
net/ice: fix memzone reserve and release in FDIR net/ice: fix removal of FDIR profile net/ice: fix FDIR counter resource release net/ice: fix wild pointer
drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 46 +++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/4 net/ice: fix memzone reserve and release in FDIR
To avoid memzone reserve failure and memory leak, following resources management should be added.
- Check if the FDIR Memzone already exists before reserving.
- Free FDIR memzone when teardown and other failure scenarios.
--- drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.h +1 -0
@@ -325,6 +325,7 @@ struct ice_fdir_info {struct ice_rx_queue *rxq;void *prg_pkt;/* memory for fdir program packet */ uint64_t dma_addr;/* physic address of packet memory*/ +const struct rte_memzone *mz;struct ice_fdir_filter_conf conf;struct ice_fdir_filter_conf **hash_map;
drivers/net/ice/ice_fdir_filter.c +18 -1
@@ -140,6 +140,12 @@ static struct ice_flow_parser ice_fdir_parser_comms;static const struct rte_memzone *ice_memzone_reserve (const char *name,uint32_t len,int socket_id) { +const struct rte_memzone *mz; + + mz =rte_memzone_lookup (name); +if (mz) +return mz; +return rte_memzone_reserve_aligned (name, len, socket_id,RTE_MEMZONE_IOVA_CONTIG ,ICE_RING_BASE_ALIGN );
@@ -493,19 +499,23 @@ ice_fdir_setup(struct ice_pf *pf) } pf->fdir.prg_pkt = mz->addr; pf->fdir.dma_addr = mz->iova; + pf->fdir.mz = mz; err =ice_fdir_prof_alloc (hw);if (err) {PMD_DRV_LOG (ERR ,"Cannot allocate memory for " "flow director profile." ); err = -ENOMEM ; - goto fail_mem; + goto fail_prof; }PMD_DRV_LOG (INFO ,"FDIR setup successfully, with programming queue %u." , vsi->base_queue);return ICE_SUCCESS ; +fail_prof: +rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; fail_mem:ice_rx_queue_release (pf->fdir.rxq); pf->fdir.rxq =NULL ;
@@ -619,6 +629,13 @@ ice_fdir_teardown(struct ice_pf *pf)ice_fdir_prof_free (hw);ice_release_vsi (vsi); pf->fdir.fdir_vsi =NULL ; + +if (pf->fdir.mz) { + err =rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; +if (err) +PMD_DRV_LOG (ERR ,"Failed to free memezone." ); + } } static int
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2 1/4] net/ice: fix memzone reserve and release in FDIR
Quoted 3 lines · Wang ShougangX
To avoid memzone reserve failure and memory leak, following resources management should be added.
- Check if the FDIR Memzone already exists before reserving.
In what scenario it will reserve FDIR memzone twice?
Quoted 4 lines
- Free FDIR memzone when teardown and other failure scenarios.
Fixes 84dc7a95a2d3 ("net/ice: enable flow director engine")
No need to cc stable since commit 84dc7a95a2d3 is in this release.
Quoted 62 lines
Signed-off-by Wang ShougangX <[email protected]>---
drivers/net/ice/ice_ethdev.h| 1 +drivers/net/ice/ice_fdir_filter.c| 19 ++++++++++++++++++-2 files changed, 19 insertions(+), 1 deletion(-)drivers/net/ice/ice_ethdev.h +1
-0@@ -325,6 +325,7 @@ struct ice_fdir_info {struct ice_rx_queue *rxq;void *prg_pkt;/* memory for fdir program packet */ uint64_t dma_addr;/* physic address of packet memory*/ +const struct rte_memzone *mz;struct ice_fdir_filter_conf conf;struct ice_fdir_filter_conf **hash_map;drivers/net/ice/ice_fdir_filter.c +0
-0@@ -140,6 +140,12 @@ static struct ice_flow_parser ice_fdir_parser_comms;static const struct
rte_memzone*ice_memzone_reserve(const char *name, uint32_t len, int socket_id){drivers/net/ice/ice_fdir_filter.c +6
-0+const struct rte_memzone *mz; + + mz =rte_memzone_lookup (name); +if (mz) +return mz; +return rte_memzone_reserve_aligned(name, len, socket_id, RTE_MEMZONE_IOVA_CONTIG, ICE_RING_BASE_ALIGN);drivers/net/ice/ice_fdir_filter.c +5
-1@@ -493,19 +499,23 @@ ice_fdir_setup(struct ice_pf *pf) } pf->fdir.prg_pkt = mz->addr; pf->fdir.dma_addr = mz->iova; + pf->fdir.mz = mz; err =ice_fdir_prof_alloc (hw);if (err) {PMD_DRV_LOG (ERR ,"Cannot allocate memory for " "flow director profile." ); err = -ENOMEM ; - goto fail_mem; + goto fail_prof; }PMD_DRV_LOG (INFO ,"FDIR setup successfully, with programming queue %u." , vsi->base_queue);return ICE_SUCCESS ; +fail_prof: +rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ;
fail_mem:ice_rx_queue_release(pf->fdir.rxq); pf->fdir.rxq = NULL;
drivers/net/ice/ice_fdir_filter.c ice_fdir_teardown(struct ice_pf *pf) · line 637
Quoted 9 lines
drivers/net/ice/ice_fdir_filter.c +6
-0@@ -619,6 +629,13 @@ ice_fdir_teardown(struct ice_pf *pf)ice_fdir_prof_free (hw);ice_release_vsi (vsi); pf->fdir.fdir_vsi =NULL ; + +if (pf->fdir.mz) { + err =rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; +if (err) +PMD_DRV_LOG (ERR ,"Failed to free memezone." );
Be more specific about the error, like "Failed to free memzone for flow director."
Thanks,
Xiaolong
Quoted 7 lines
drivers/net/ice/ice_fdir_filter.c +1
-0+ } }static int
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2 1/4] net/ice: fix memzone reserve and release in FDIR
Hi, Xiaolong
Quoted 9 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Monday, November 11, 2019 4:10 PM
To: Wang, ShougangX <[email protected]>
Cc: [email protected]; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 1/4] net/ice: fix memzone reserve and release in FDIR
Quoted 6 lines
Quoted 3 lines · Wang ShougangX
To avoid memzone reserve failure and memory leak, following resources management should be added.
- Check if the FDIR Memzone already exists before reserving.In what scenario it will reserve FDIR memzone twice?
Currently, there is no scenario.
It is a failsafe method, just like i40e_memzone_reserve().
Quoted 7 lines
Quoted 5 lines
- Free FDIR memzone when teardown and other failure scenarios.
Fixes 84dc7a95a2d3 ("net/ice: enable flow director engine")No need to cc stable since commit
84dc7a95a2d3is in this release.
Got it.
Quoted 67 lines
Quoted 42 lines
Signed-off-by Wang ShougangX <[email protected]>---
drivers/net/ice/ice_ethdev.h| 1 +drivers/net/ice/ice_fdir_filter.c| 19 ++++++++++++++++++-2 files changed, 19 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/net/ice/ice_ethdev.hindexde67e5934..0a39ca6ff100644drivers/net/ice/ice_ethdev.h +1
-0@@ -325,6 +325,7 @@ struct ice_fdir_info {struct ice_rx_queue *rxq;void *prg_pkt;/* memory for fdir program packet */ uint64_t dma_addr;/* physic address of packet memory*/ +const struct rte_memzone *mz;struct ice_fdir_filter_conf conf; struct ice_fdir_filter_conf **hash_map; diff --git
a/drivers/net/ice/ice_fdir_filter.cb/drivers/net/ice/ice_fdir_filter.cindex736ccd54e..31705c164100644drivers/net/ice/ice_fdir_filter.c +0
-0@@ -140,6 +140,12 @@ static struct ice_flow_parser
ice_fdir_parser_comms; static const structrte_memzone*ice_memzone_reserve(const char *name, uint32_t len, int socket_id){drivers/net/ice/ice_fdir_filter.c +6
-0+const struct rte_memzone *mz; + + mz =rte_memzone_lookup (name); +if (mz) +return mz; +return rte_memzone_reserve_aligned(name, len, socket_id, RTE_MEMZONE_IOVA_CONTIG, ICE_RING_BASE_ALIGN);drivers/net/ice/ice_fdir_filter.c +1
-0@@ -493,19 +499,23 @@ ice_fdir_setup(struct ice_pf *pf) } pf->fdir.prg_pkt = mz->addr; pf->fdir.dma_addr = mz->iova; + pf->fdir.mz = mz;drivers/net/ice/ice_fdir_filter.c ice_fdir_setup(struct ice_pf *pf) · line 512
Quoted 10 lines
drivers/net/ice/ice_fdir_filter.c +1
-1err =ice_fdir_prof_alloc (hw);if (err) {PMD_DRV_LOG (ERR ,"Cannot allocate memory for " "flow director profile." ); err = -ENOMEM ; - goto fail_mem; + goto fail_prof; } PMD_DRV_LOG(INFO, "FDIR setup successfully, with programmingqueue %u.",
Quoted 14 lines
drivers/net/ice/ice_fdir_filter.c +3
-0vsi->base_queue);return ICE_SUCCESS ; +fail_prof: +rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ;
fail_mem:ice_rx_queue_release(pf->fdir.rxq); pf->fdir.rxq = NULL;drivers/net/ice/ice_fdir_filter.c +1
-0@@ -619,6 +629,13 @@ ice_fdir_teardown(struct ice_pf *pf)ice_fdir_prof_free (hw);ice_release_vsi (vsi); pf->fdir.fdir_vsi =NULL ; +
Quoted 8 lines
drivers/net/ice/ice_fdir_filter.c ice_fdir_teardown(struct ice_pf *pf) · line 637
Quoted 5 lines
drivers/net/ice/ice_fdir_filter.c +5
-0+if (pf->fdir.mz) { + err =rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; +if (err) +PMD_DRV_LOG (ERR ,"Failed to free memezone." );Be more specific about the error, like "Failed to free memzone for flow director."
Got it.
Quoted 6 lines
Thanks,
Xiaolong
Quoted 7 lines
Quoted 7 lines
drivers/net/ice/ice_fdir_filter.c +1
-0+ } }static int
--
2.17.1
Thanks.
Shougang
PATCH v2 2/4 net/ice: fix removal of FDIR profile
In reply to Wang ShougangXThe removal of FDIR profile should start from ICE_FLTR_PTYPE_NONF_IPV4_UDP.
--- drivers/net/ice/ice_fdir_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ice/ice_fdir_filter.c +1 -1
@@ -583,7 +583,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) {enum ice_fltr_ptype ptype; -for (ptype =ICE_FLTR_PTYPE_NONF_NONE ; +for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {ice_fdir_prof_rm (pf, ptype, false);
Signature · 1 line
2.17.1
PATCH v2 3/4 net/ice: fix FDIR counter resource release
In reply to Wang ShougangXAll the counter resources should be cleaned up when teardown.
--- drivers/net/ice/ice_fdir_filter.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ice/ice_fdir_filter.c +3 -0
@@ -265,6 +265,9 @@ ice_fdir_counter_release(struct ice_pf *pf)for (i =0 ; i < container->index_free; i++)rte_free (container->pools[i]); +TAILQ_INIT (&container->pool_list); + container->index_free =0 ; +return 0 ; }
Signature · 1 line
2.17.1
PATCH v2 4/4 net/ice: fix wild pointer
In reply to Wang ShougangXTo avoid wild pointer, pointers should be set to NULL after free them.
--- drivers/net/ice/ice_fdir_filter.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/net/ice/ice_fdir_filter.c +19 -3
@@ -165,6 +165,10 @@ ice_fdir_prof_alloc(struct ice_hw *hw)if (!hw->fdir_prof)return -ENOMEM ; } + +/* To avoid wild pointer, unused field pointer should be NULL */ + hw->fdir_prof[ICE_FLTR_PTYPE_NONF_NONE ] =NULL ; +for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {
@@ -180,9 +184,13 @@ ice_fdir_prof_alloc(struct ice_hw *hw) fail_mem:for (fltr_ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; fltr_ptype < ptype; - fltr_ptype++) + fltr_ptype++) {rte_free (hw->fdir_prof[fltr_ptype]); + hw->fdir_prof[fltr_ptype] =NULL ; + } +rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ;return -ENOMEM ; }
@@ -262,8 +270,10 @@ ice_fdir_counter_release(struct ice_pf *pf) &fdir_info->counter;uint8_t i; -for (i =0 ; i < container->index_free; i++) +for (i =0 ; i < container->index_free; i++) {rte_free (container->pools[i]); + container->pools[i] =NULL ; + }TAILQ_INIT (&container->pool_list); container->index_free =0 ;
@@ -412,6 +422,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/*
@@ -538,10 +551,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }/* Remove a profile for some filter type */
Signature · 1 line
2.17.1
v3 cover net/ice: fix memory release in FDIR
In reply to Wang ShougangXThese patches include FDIR memory resource fixes related to ICE driver. Patch 1: fix memzone reserve and release in FDIR
Patch 2: fix removal of FDIR profile
Patch 3: fix FDIR counter resource release
Patch 4: fix wild pointer
---
v3 changes:
Changed error log.
v2 changes:
Merged patches related to CVL memory resources management into patchset.
Wang ShougangX (4):
net/ice: fix memzone reserve and release in FDIR net/ice: fix removal of FDIR profile net/ice: fix FDIR counter resource release net/ice: fix wild pointer
drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 46 +++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
v3 cover net/ice: fix memory release in FDIR
In reply to Wang ShougangXThese patches include FDIR memory resource fixes related to ICE driver. Patch 1: fix memzone reserve and release in FDIR
Patch 2: fix removal of FDIR profile
Patch 3: fix FDIR counter resource release
Patch 4: fix wild pointer
---
v3 changes:
Changed error log.
v2 changes:
Merged patches related to CVL memory resources management into patchset.
Wang ShougangX (4):
net/ice: fix memzone reserve and release in FDIR net/ice: fix removal of FDIR profile net/ice: fix FDIR counter resource release net/ice: fix wild pointer
drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 46 +++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/4 net/ice: fix memzone reserve and release in FDIR
To avoid memzone reserve failure and memory leak, following resources management should be added.
- Check if the FDIR Memzone already exists before reserving.
- Free FDIR memzone when teardown and other failure scenarios.
--- drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.h +1 -0
@@ -334,6 +334,7 @@ struct ice_fdir_info {struct ice_rx_queue *rxq;void *prg_pkt;/* memory for fdir program packet */ uint64_t dma_addr;/* physic address of packet memory*/ +const struct rte_memzone *mz;struct ice_fdir_filter_conf conf;struct ice_fdir_filter_conf **hash_map;
drivers/net/ice/ice_fdir_filter.c +18 -1
@@ -127,6 +127,12 @@ static struct ice_flow_parser ice_fdir_parser_comms;static const struct rte_memzone *ice_memzone_reserve (const char *name,uint32_t len,int socket_id) { +const struct rte_memzone *mz; + + mz =rte_memzone_lookup (name); +if (mz) +return mz; +return rte_memzone_reserve_aligned (name, len, socket_id,RTE_MEMZONE_IOVA_CONTIG ,ICE_RING_BASE_ALIGN );
@@ -481,19 +487,23 @@ ice_fdir_setup(struct ice_pf *pf) } pf->fdir.prg_pkt = mz->addr; pf->fdir.dma_addr = mz->iova; + pf->fdir.mz = mz; err =ice_fdir_prof_alloc (hw);if (err) {PMD_DRV_LOG (ERR ,"Cannot allocate memory for " "flow director profile." ); err = -ENOMEM ; - goto fail_mem; + goto fail_prof; }PMD_DRV_LOG (INFO ,"FDIR setup successfully, with programming queue %u." , vsi->base_queue);return ICE_SUCCESS ; +fail_prof: +rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; fail_mem:ice_rx_queue_release (pf->fdir.rxq); pf->fdir.rxq =NULL ;
@@ -607,6 +617,13 @@ ice_fdir_teardown(struct ice_pf *pf)ice_fdir_prof_free (hw);ice_release_vsi (vsi); pf->fdir.fdir_vsi =NULL ; + +if (pf->fdir.mz) { + err =rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; +if (err) +PMD_DRV_LOG (ERR ,"Failed to free FDIR memezone." ); + } } static int
Signature · 1 line
2.17.1
PATCH v3 2/4 net/ice: fix removal of FDIR profile
In reply to Wang ShougangXThe removal of FDIR profile should start from ICE_FLTR_PTYPE_NONF_IPV4_UDP.
--- drivers/net/ice/ice_fdir_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ice/ice_fdir_filter.c +1 -1
@@ -571,7 +571,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) {enum ice_fltr_ptype ptype; -for (ptype =ICE_FLTR_PTYPE_NONF_NONE ; +for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {ice_fdir_prof_rm (pf, ptype, false);
Signature · 1 line
2.17.1
PATCH v3 3/4 net/ice: fix FDIR counter resource release
In reply to Wang ShougangXAll the counter resources should be cleaned up when teardown.
--- drivers/net/ice/ice_fdir_filter.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ice/ice_fdir_filter.c +3 -0
@@ -252,6 +252,9 @@ ice_fdir_counter_release(struct ice_pf *pf)for (i =0 ; i < container->index_free; i++)rte_free (container->pools[i]); +TAILQ_INIT (&container->pool_list); + container->index_free =0 ; +return 0 ; }
Signature · 1 line
2.17.1
PATCH v3 4/4 net/ice: fix wild pointer
In reply to Wang ShougangXTo avoid wild pointer, pointers should be set to NULL after free them.
--- drivers/net/ice/ice_fdir_filter.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/net/ice/ice_fdir_filter.c +19 -3
@@ -152,6 +152,10 @@ ice_fdir_prof_alloc(struct ice_hw *hw)if (!hw->fdir_prof)return -ENOMEM ; } + +/* To avoid wild pointer, unused field pointer should be NULL */ + hw->fdir_prof[ICE_FLTR_PTYPE_NONF_NONE ] =NULL ; +for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {
@@ -167,9 +171,13 @@ ice_fdir_prof_alloc(struct ice_hw *hw) fail_mem:for (fltr_ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; fltr_ptype < ptype; - fltr_ptype++) + fltr_ptype++) {rte_free (hw->fdir_prof[fltr_ptype]); + hw->fdir_prof[fltr_ptype] =NULL ; + } +rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ;return -ENOMEM ; }
@@ -249,8 +257,10 @@ ice_fdir_counter_release(struct ice_pf *pf) &fdir_info->counter;uint8_t i; -for (i =0 ; i < container->index_free; i++) +for (i =0 ; i < container->index_free; i++) {rte_free (container->pools[i]); + container->pools[i] =NULL ; + }TAILQ_INIT (&container->pool_list); container->index_free =0 ;
@@ -400,6 +410,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/*
@@ -526,10 +539,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }/* Remove a profile for some filter type */
Signature · 1 line
2.17.1
v3 cover net/ice: fix memory release in FDIR
In reply to Wang ShougangXThese patches include FDIR memory resource fixes related to ICE driver. Patch 1: fix memzone reserve and release in FDIR
Patch 2: fix removal of FDIR profile
Patch 3: fix FDIR counter resource release
Patch 4: fix wild pointer
---
v3 changes:
Changed error log.
v2 changes:
Merged patches related to CVL memory resources management into patchset.
Wang ShougangX (4):
net/ice: fix memzone reserve and release in FDIR net/ice: fix removal of FDIR profile net/ice: fix FDIR counter resource release net/ice: fix wild pointer
drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 46 +++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/4 net/ice: fix memzone reserve and release in FDIR
To avoid memzone reserve failure and memory leak, following resources management should be added.
- Check if the FDIR Memzone already exists before reserving.
- Free FDIR memzone when teardown and other failure scenarios.
--- drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.h +1 -0
@@ -334,6 +334,7 @@ struct ice_fdir_info {struct ice_rx_queue *rxq;void *prg_pkt;/* memory for fdir program packet */ uint64_t dma_addr;/* physic address of packet memory*/ +const struct rte_memzone *mz;struct ice_fdir_filter_conf conf;struct ice_fdir_filter_conf **hash_map;
drivers/net/ice/ice_fdir_filter.c +18 -1
@@ -127,6 +127,12 @@ static struct ice_flow_parser ice_fdir_parser_comms;static const struct rte_memzone *ice_memzone_reserve (const char *name,uint32_t len,int socket_id) { +const struct rte_memzone *mz; + + mz =rte_memzone_lookup (name); +if (mz) +return mz; +return rte_memzone_reserve_aligned (name, len, socket_id,RTE_MEMZONE_IOVA_CONTIG ,ICE_RING_BASE_ALIGN );
@@ -481,19 +487,23 @@ ice_fdir_setup(struct ice_pf *pf) } pf->fdir.prg_pkt = mz->addr; pf->fdir.dma_addr = mz->iova; + pf->fdir.mz = mz; err =ice_fdir_prof_alloc (hw);if (err) {PMD_DRV_LOG (ERR ,"Cannot allocate memory for " "flow director profile." ); err = -ENOMEM ; - goto fail_mem; + goto fail_prof; }PMD_DRV_LOG (INFO ,"FDIR setup successfully, with programming queue %u." , vsi->base_queue);return ICE_SUCCESS ; +fail_prof: +rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; fail_mem:ice_rx_queue_release (pf->fdir.rxq); pf->fdir.rxq =NULL ;
@@ -607,6 +617,13 @@ ice_fdir_teardown(struct ice_pf *pf)ice_fdir_prof_free (hw);ice_release_vsi (vsi); pf->fdir.fdir_vsi =NULL ; + +if (pf->fdir.mz) { + err =rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; +if (err) +PMD_DRV_LOG (ERR ,"Failed to free FDIR memezone." ); + } } static int
Signature · 1 line
2.17.1
PATCH v3 2/4 net/ice: fix removal of FDIR profile
In reply to Wang ShougangXThe removal of FDIR profile should start from ICE_FLTR_PTYPE_NONF_IPV4_UDP.
--- drivers/net/ice/ice_fdir_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ice/ice_fdir_filter.c +1 -1
@@ -571,7 +571,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) {enum ice_fltr_ptype ptype; -for (ptype =ICE_FLTR_PTYPE_NONF_NONE ; +for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {ice_fdir_prof_rm (pf, ptype, false);
Signature · 1 line
2.17.1
PATCH v3 3/4 net/ice: fix FDIR counter resource release
In reply to Wang ShougangXAll the counter resources should be cleaned up when teardown.
--- drivers/net/ice/ice_fdir_filter.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ice/ice_fdir_filter.c +3 -0
@@ -252,6 +252,9 @@ ice_fdir_counter_release(struct ice_pf *pf)for (i =0 ; i < container->index_free; i++)rte_free (container->pools[i]); +TAILQ_INIT (&container->pool_list); + container->index_free =0 ; +return 0 ; }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 3/4] net/ice: fix FDIR counter resource release
Quoted 9 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Wang ShougangX
Sent: Tuesday, November 12, 2019 8:27 AM
To: [email protected]
Cc: Wang, ShougangX <[email protected]>
Subject: [dpdk-dev] [PATCH v3 3/4] net/ice: fix FDIR counter resource release
Quoted 5 lines
All the counter resources should be cleaned up when teardown.
Fixes 0f880c3df192 ("net/ice: add flow director counter resource init/release")Signed-off-by Wang ShougangX <[email protected]>
PATCH v3 4/4 net/ice: fix wild pointer
In reply to Wang ShougangXTo avoid wild pointer, pointers should be set to NULL after free them.
--- drivers/net/ice/ice_fdir_filter.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/net/ice/ice_fdir_filter.c +19 -3
@@ -152,6 +152,10 @@ ice_fdir_prof_alloc(struct ice_hw *hw)if (!hw->fdir_prof)return -ENOMEM ; } + +/* To avoid wild pointer, unused field pointer should be NULL */ + hw->fdir_prof[ICE_FLTR_PTYPE_NONF_NONE ] =NULL ; +for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {
@@ -167,9 +171,13 @@ ice_fdir_prof_alloc(struct ice_hw *hw) fail_mem:for (fltr_ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; fltr_ptype < ptype; - fltr_ptype++) + fltr_ptype++) {rte_free (hw->fdir_prof[fltr_ptype]); + hw->fdir_prof[fltr_ptype] =NULL ; + } +rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ;return -ENOMEM ; }
@@ -249,8 +257,10 @@ ice_fdir_counter_release(struct ice_pf *pf) &fdir_info->counter;uint8_t i; -for (i =0 ; i < container->index_free; i++) +for (i =0 ; i < container->index_free; i++) {rte_free (container->pools[i]); + container->pools[i] =NULL ; + }TAILQ_INIT (&container->pool_list); container->index_free =0 ;
@@ -400,6 +410,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/*
@@ -526,10 +539,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }/* Remove a profile for some filter type */
Signature · 1 line
2.17.1
Quoted 25 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Wang ShougangX
Sent: Tuesday, November 12, 2019 8:27 AM
To: [email protected]
Cc: Wang, ShougangX <[email protected]>
Subject: [dpdk-dev] [PATCH v3 4/4] net/ice: fix wild pointerTo avoid wild pointer, pointers should be set to NULL after free them.
Fixes 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")Fixes 84dc7a95a2d3 ("net/ice: enable flow director engine")Fixes 0f880c3df192 ("net/ice: add flow director counter resource init/release")Signed-off-by Wang ShougangX <[email protected]>--- drivers/net/ice/ice_fdir_filter.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)drivers/net/ice/ice_fdir_filter.c +0
-0
drivers/net/ice/ice_fdir_filter.c ice_fdir_prof_alloc(struct ice_hw *hw) · line 157
Quoted 6 lines
drivers/net/ice/ice_fdir_filter.c +3
-0@@ -152,6 +152,10 @@ ice_fdir_prof_alloc(struct ice_hw *hw)if (!hw->fdir_prof)return -ENOMEM ; } + +/* To avoid wild pointer, unused field pointer should be NULL */ + hw->fdir_prof[ICE_FLTR_PTYPE_NONF_NONE ] =NULL ;
This is not necessary, since ice_malloc already guarantee all the allocated memory is init to 0
Quoted 58 lines
drivers/net/ice/ice_fdir_filter.c +16
-4+for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {@@ -167,9 +171,13 @@ ice_fdir_prof_alloc(struct ice_hw *hw) fail_mem:for (fltr_ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; fltr_ptype < ptype; - fltr_ptype++) + fltr_ptype++) {rte_free (hw->fdir_prof[fltr_ptype]); + hw->fdir_prof[fltr_ptype] =NULL ; + } +rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ;return -ENOMEM ; }@@ -249,8 +257,10 @@ ice_fdir_counter_release(struct ice_pf *pf) &fdir_info->counter;uint8_t i; -for (i =0 ; i < container->index_free; i++) +for (i =0 ; i < container->index_free; i++) {rte_free (container->pools[i]); + container->pools[i] =NULL ; + }TAILQ_INIT (&container->pool_list); container->index_free =0 ;@@ -400,6 +410,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/* @@ -526,10 +539,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }/* Remove a profile for some filter type */ --2.17.1
v3 cover net/ice: fix memory release in FDIR
In reply to Wang ShougangXThese patches include FDIR memory resource fixes related to ICE driver. Patch 1: fix memzone reserve and release in FDIR
Patch 2: fix removal of FDIR profile
Patch 3: fix FDIR counter resource release
Patch 4: fix wild pointer
---
v3 changes:
Changed error log.
v2 changes:
Merged patches related to CVL memory resources management into patchset.
Wang ShougangX (4):
net/ice: fix memzone reserve and release in FDIR net/ice: fix removal of FDIR profile net/ice: fix FDIR counter resource release net/ice: fix wild pointer
drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 46 +++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/4 net/ice: fix memzone reserve and release in FDIR
To avoid memzone reserve failure and memory leak, following resources management should be added.
- Check if the FDIR Memzone already exists before reserving.
- Free FDIR memzone when teardown and other failure scenarios.
--- drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.h +1 -0
@@ -334,6 +334,7 @@ struct ice_fdir_info {struct ice_rx_queue *rxq;void *prg_pkt;/* memory for fdir program packet */ uint64_t dma_addr;/* physic address of packet memory*/ +const struct rte_memzone *mz;struct ice_fdir_filter_conf conf;struct ice_fdir_filter_conf **hash_map;
drivers/net/ice/ice_fdir_filter.c +18 -1
@@ -127,6 +127,12 @@ static struct ice_flow_parser ice_fdir_parser_comms;static const struct rte_memzone *ice_memzone_reserve (const char *name,uint32_t len,int socket_id) { +const struct rte_memzone *mz; + + mz =rte_memzone_lookup (name); +if (mz) +return mz; +return rte_memzone_reserve_aligned (name, len, socket_id,RTE_MEMZONE_IOVA_CONTIG ,ICE_RING_BASE_ALIGN );
@@ -481,19 +487,23 @@ ice_fdir_setup(struct ice_pf *pf) } pf->fdir.prg_pkt = mz->addr; pf->fdir.dma_addr = mz->iova; + pf->fdir.mz = mz; err =ice_fdir_prof_alloc (hw);if (err) {PMD_DRV_LOG (ERR ,"Cannot allocate memory for " "flow director profile." ); err = -ENOMEM ; - goto fail_mem; + goto fail_prof; }PMD_DRV_LOG (INFO ,"FDIR setup successfully, with programming queue %u." , vsi->base_queue);return ICE_SUCCESS ; +fail_prof: +rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; fail_mem:ice_rx_queue_release (pf->fdir.rxq); pf->fdir.rxq =NULL ;
@@ -607,6 +617,13 @@ ice_fdir_teardown(struct ice_pf *pf)ice_fdir_prof_free (hw);ice_release_vsi (vsi); pf->fdir.fdir_vsi =NULL ; + +if (pf->fdir.mz) { + err =rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; +if (err) +PMD_DRV_LOG (ERR ,"Failed to free FDIR memezone." ); + } } static int
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 1/4] net/ice: fix memzone reserve and release in FDIR
Quoted 11 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Wang ShougangX
Sent: Tuesday, November 12, 2019 8:51 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Wang, ShougangX <[email protected]>
Subject: [dpdk-dev] [PATCH v3 1/4] net/ice: fix memzone reserve and release in FDIR
Quoted 8 lines
To avoid memzone reserve failure and memory leak, following resources management should be added.
- Check if the FDIR Memzone already exists before reserving.
- Free FDIR memzone when teardown and other failure scenarios.Fixes 84dc7a95a2d3 ("net/ice: enable flow director engine")Signed-off-by Wang ShougangX <[email protected]>
PATCH v3 2/4 net/ice: fix removal of FDIR profile
In reply to Wang ShougangXThe removal of FDIR profile should start from ICE_FLTR_PTYPE_NONF_IPV4_UDP.
--- drivers/net/ice/ice_fdir_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ice/ice_fdir_filter.c +1 -1
@@ -571,7 +571,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) {enum ice_fltr_ptype ptype; -for (ptype =ICE_FLTR_PTYPE_NONF_NONE ; +for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {ice_fdir_prof_rm (pf, ptype, false);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 2/4] net/ice: fix removal of FDIR profile
Quoted 25 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Wang ShougangX
Sent: Tuesday, November 12, 2019 8:51 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Wang, ShougangX <[email protected]>
Subject: [dpdk-dev] [PATCH v3 2/4] net/ice: fix removal of FDIR profileThe removal of FDIR profile should start from
ICE_FLTR_PTYPE_NONF_IPV4_UDP.Fixes 109e8e06249e ("net/ice: configure HW flow director rule")Signed-off-by Wang ShougangX <[email protected]>--- drivers/net/ice/ice_fdir_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ice/ice_fdir_filter.c +0
-0
drivers/net/ice/ice_fdir_filter.c ice_fdir_prof_rm_all(struct ice_pf *pf) { · line 573
Quoted 4 lines
drivers/net/ice/ice_fdir_filter.c +1
-1@@ -571,7 +571,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) {enum ice_fltr_ptype ptype; - for (ptype = ICE_FLTR_PTYPE_NONF_NONE; + for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
Is "ptype = ICE_FLTR_PTYPE_NONF_NONE + 1" better?, so we don't need to worry profile be re-ordered or new one be inserted in future.
Quoted 5 lines
drivers/net/ice/ice_fdir_filter.c +0
-1ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {ice_fdir_prof_rm (pf, ptype, false); --2.17.1
Re: [dpdk-dev] [PATCH v3 2/4] net/ice: fix removal of FDIR profile
Hi, Qi
Quoted 37 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Tuesday, November 12, 2019 3:51 PM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Wang, ShougangX <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v3 2/4] net/ice: fix removal of FDIR profileQuoted 27 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Wang ShougangX
Sent: Tuesday, November 12, 2019 8:51 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Wang, ShougangX <[email protected]>
Subject: [dpdk-dev] [PATCH v3 2/4] net/ice: fix removal of FDIR profileThe removal of FDIR profile should start from
ICE_FLTR_PTYPE_NONF_IPV4_UDP.Fixes 109e8e06249e ("net/ice: configure HW flow director rule")Signed-off-by Wang ShougangX <[email protected]>--- drivers/net/ice/ice_fdir_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ice/ice_fdir_filter.c +0
-0@@ -571,7 +571,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) {enum ice_fltr_ptype ptype;
Quoted 5 lines
drivers/net/ice/ice_fdir_filter.c ice_fdir_prof_rm_all(struct ice_pf *pf) · line 574
Quoted 2 lines
drivers/net/ice/ice_fdir_filter.c +1
-1- for (ptype = ICE_FLTR_PTYPE_NONF_NONE; + for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;Is "ptype =
ICE_FLTR_PTYPE_NONF_NONE+ 1" better?, so we don't need to worry profile be re-ordered or new one be inserted in future.
yes, it is better. I will change it in next version. Thank you very much.
Quoted 7 lines
Quoted 7 lines
drivers/net/ice/ice_fdir_filter.c +0
-1ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {ice_fdir_prof_rm (pf, ptype, false); --2.17.1
Thanks.
Shougang
PATCH v3 3/4 net/ice: fix FDIR counter resource release
In reply to Wang ShougangXAll the counter resources should be cleaned up when teardown.
--- drivers/net/ice/ice_fdir_filter.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ice/ice_fdir_filter.c +3 -0
@@ -252,6 +252,9 @@ ice_fdir_counter_release(struct ice_pf *pf)for (i =0 ; i < container->index_free; i++)rte_free (container->pools[i]); +TAILQ_INIT (&container->pool_list); + container->index_free =0 ; +return 0 ; }
Signature · 1 line
2.17.1
PATCH v3 4/4 net/ice: fix wild pointer
In reply to Wang ShougangXTo avoid wild pointer, pointers should be set to NULL after free them.
--- drivers/net/ice/ice_fdir_filter.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/net/ice/ice_fdir_filter.c +19 -3
@@ -152,6 +152,10 @@ ice_fdir_prof_alloc(struct ice_hw *hw)if (!hw->fdir_prof)return -ENOMEM ; } + +/* To avoid wild pointer, unused field pointer should be NULL */ + hw->fdir_prof[ICE_FLTR_PTYPE_NONF_NONE ] =NULL ; +for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {
@@ -167,9 +171,13 @@ ice_fdir_prof_alloc(struct ice_hw *hw) fail_mem:for (fltr_ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; fltr_ptype < ptype; - fltr_ptype++) + fltr_ptype++) {rte_free (hw->fdir_prof[fltr_ptype]); + hw->fdir_prof[fltr_ptype] =NULL ; + } +rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ;return -ENOMEM ; }
@@ -249,8 +257,10 @@ ice_fdir_counter_release(struct ice_pf *pf) &fdir_info->counter;uint8_t i; -for (i =0 ; i < container->index_free; i++) +for (i =0 ; i < container->index_free; i++) {rte_free (container->pools[i]); + container->pools[i] =NULL ; + }TAILQ_INIT (&container->pool_list); container->index_free =0 ;
@@ -400,6 +410,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/*
@@ -526,10 +539,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }/* Remove a profile for some filter type */
Signature · 1 line
2.17.1
v4 cover net/ice: fix memory release in FDIR
In reply to Wang ShougangXThese patches include FDIR memory resource fixes related to ICE driver. Patch 1: fix memzone reserve and release in FDIR
Patch 2: fix removal of FDIR profile
Patch 3: fix FDIR counter resource release
Patch 4: fix wild pointer
---
v4 changes:
Removed unnecessary pointer initialization operations. Changed for loop start index in ice_fdir_prof_alloc().
v3 changes:
Changed error log.
v2 changes:
Merged patches related to CVL memory resources management into patchset.
Wang ShougangX (4):
net/ice: fix memzone reserve and release in FDIR net/ice: fix removal of FDIR profile net/ice: fix FDIR counter resource release net/ice: fix wild pointer
drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 43 +++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
PATCH v4 1/4 net/ice: fix memzone reserve and release in FDIR
To avoid memzone reserve failure and memory leak, following resources management should be added.
- Check if the FDIR Memzone already exists before reserving.
- Free FDIR memzone when teardown and other failure scenarios.
--- drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.h +1 -0
@@ -334,6 +334,7 @@ struct ice_fdir_info {struct ice_rx_queue *rxq;void *prg_pkt;/* memory for fdir program packet */ uint64_t dma_addr;/* physic address of packet memory*/ +const struct rte_memzone *mz;struct ice_fdir_filter_conf conf;struct ice_fdir_filter_conf **hash_map;
drivers/net/ice/ice_fdir_filter.c +18 -1
@@ -127,6 +127,12 @@ static struct ice_flow_parser ice_fdir_parser_comms;static const struct rte_memzone *ice_memzone_reserve (const char *name,uint32_t len,int socket_id) { +const struct rte_memzone *mz; + + mz =rte_memzone_lookup (name); +if (mz) +return mz; +return rte_memzone_reserve_aligned (name, len, socket_id,RTE_MEMZONE_IOVA_CONTIG ,ICE_RING_BASE_ALIGN );
@@ -481,19 +487,23 @@ ice_fdir_setup(struct ice_pf *pf) } pf->fdir.prg_pkt = mz->addr; pf->fdir.dma_addr = mz->iova; + pf->fdir.mz = mz; err =ice_fdir_prof_alloc (hw);if (err) {PMD_DRV_LOG (ERR ,"Cannot allocate memory for " "flow director profile." ); err = -ENOMEM ; - goto fail_mem; + goto fail_prof; }PMD_DRV_LOG (INFO ,"FDIR setup successfully, with programming queue %u." , vsi->base_queue);return ICE_SUCCESS ; +fail_prof: +rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; fail_mem:ice_rx_queue_release (pf->fdir.rxq); pf->fdir.rxq =NULL ;
@@ -607,6 +617,13 @@ ice_fdir_teardown(struct ice_pf *pf)ice_fdir_prof_free (hw);ice_release_vsi (vsi); pf->fdir.fdir_vsi =NULL ; + +if (pf->fdir.mz) { + err =rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; +if (err) +PMD_DRV_LOG (ERR ,"Failed to free FDIR memezone." ); + } } static int
Signature · 1 line
2.17.1
PATCH v4 2/4 net/ice: fix removal of FDIR profile
In reply to Wang ShougangXThe removal of FDIR profile should start from the next of ICE_FLTR_PTYPE_NONF_NONE.
--- drivers/net/ice/ice_fdir_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ice/ice_fdir_filter.c +1 -1
@@ -571,7 +571,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) {enum ice_fltr_ptype ptype; -for (ptype =ICE_FLTR_PTYPE_NONF_NONE ; +for (ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {ice_fdir_prof_rm (pf, ptype, false);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v4 2/4] net/ice: fix removal of FDIR profile
Hi,
Quoted 23 lines
-----Original Message-----
From: Wang, ShougangX
Sent: Tuesday, November 12, 2019 11:50 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Wang, ShougangX <[email protected]>
Subject: [PATCH v4 2/4] net/ice: fix removal of FDIR profileThe removal of FDIR profile should start from the next of
ICE_FLTR_PTYPE_NONF_NONE.Fixes 109e8e06249e ("net/ice: configure HW flow director rule")Signed-off-by Wang ShougangX <[email protected]>--- drivers/net/ice/ice_fdir_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ice/ice_fdir_filter.c +0
-0
drivers/net/ice/ice_fdir_filter.c ice_fdir_prof_rm_all(struct ice_pf *pf) { · line 573
Quoted 4 lines
drivers/net/ice/ice_fdir_filter.c +1
-1@@ -571,7 +571,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) {enum ice_fltr_ptype ptype; - for (ptype = ICE_FLTR_PTYPE_NONF_NONE; + for (ptype = ICE_FLTR_PTYPE_NONF_NONE + 1;
I think we should also use ICE_FLTR_PTYPE_NONF_NONE + 1 instead of ICE_FLTR_PTYPE_TCP_IPV4 in prof_add, To make sure it is symmetric. And it should be contained in this patch.
Quoted 5 lines
drivers/net/ice/ice_fdir_filter.c +0
-1ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {ice_fdir_prof_rm (pf, ptype, false); --2.17.1
Re: [dpdk-dev] [PATCH v4 2/4] net/ice: fix removal of FDIR profile
Hi, Qiming
Quoted 35 lines
-----Original Message-----
From: Yang, Qiming
Sent: Tuesday, November 12, 2019 6:37 PM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Zhang, Qi Z <[email protected]>
Subject: RE: [PATCH v4 2/4] net/ice: fix removal of FDIR profileHi,
Quoted 26 lines
-----Original Message-----
From: Wang, ShougangX
Sent: Tuesday, November 12, 2019 11:50 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Wang, ShougangX <[email protected]>
Subject: [PATCH v4 2/4] net/ice: fix removal of FDIR profileThe removal of FDIR profile should start from the next of
ICE_FLTR_PTYPE_NONF_NONE.Fixes 109e8e06249e ("net/ice: configure HW flow director rule")Signed-off-by Wang ShougangX <[email protected]>--- drivers/net/ice/ice_fdir_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ice/ice_fdir_filter.c +0
-0@@ -571,7 +571,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) {enum ice_fltr_ptype ptype;
Quoted 6 lines
drivers/net/ice/ice_fdir_filter.c ice_fdir_prof_rm_all(struct ice_pf *pf) · line 574
Quoted 2 lines
drivers/net/ice/ice_fdir_filter.c +1
-1- for (ptype = ICE_FLTR_PTYPE_NONF_NONE; + for (ptype = ICE_FLTR_PTYPE_NONF_NONE + 1;I think we should also use
ICE_FLTR_PTYPE_NONF_NONE+ 1 instead ofICE_FLTR_PTYPE_TCP_IPV4inprof_add, To make sure it is symmetric. And it should be contained in this patch.
OK, I will replace them.
Quoted 6 lines
Quoted 6 lines
drivers/net/ice/ice_fdir_filter.c +0
-1ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {ice_fdir_prof_rm (pf, ptype, false); --2.17.1
PATCH v4 3/4 net/ice: fix FDIR counter resource release
In reply to Wang ShougangXAll the counter resources should be cleaned up when teardown.
--- drivers/net/ice/ice_fdir_filter.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ice/ice_fdir_filter.c +3 -0
@@ -252,6 +252,9 @@ ice_fdir_counter_release(struct ice_pf *pf)for (i =0 ; i < container->index_free; i++)rte_free (container->pools[i]); +TAILQ_INIT (&container->pool_list); + container->index_free =0 ; +return 0 ; }
Signature · 1 line
2.17.1
PATCH v4 4/4 net/ice: fix wild pointer
In reply to Wang ShougangXTo avoid wild pointer, pointers should be set to NULL after free them.
--- drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/net/ice/ice_fdir_filter.c +16 -3
@@ -152,6 +152,7 @@ ice_fdir_prof_alloc(struct ice_hw *hw)if (!hw->fdir_prof)return -ENOMEM ; } +for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {
@@ -167,9 +168,13 @@ ice_fdir_prof_alloc(struct ice_hw *hw) fail_mem:for (fltr_ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; fltr_ptype < ptype; - fltr_ptype++) + fltr_ptype++) {rte_free (hw->fdir_prof[fltr_ptype]); + hw->fdir_prof[fltr_ptype] =NULL ; + } +rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ;return -ENOMEM ; }
@@ -249,8 +254,10 @@ ice_fdir_counter_release(struct ice_pf *pf) &fdir_info->counter;uint8_t i; -for (i =0 ; i < container->index_free; i++) +for (i =0 ; i < container->index_free; i++) {rte_free (container->pools[i]); + container->pools[i] =NULL ; + }TAILQ_INIT (&container->pool_list); container->index_free =0 ;
@@ -400,6 +407,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/*
@@ -526,10 +536,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }/* Remove a profile for some filter type */
Signature · 1 line
2.17.1
v5 cover net/ice: fix memory release in FDIR
In reply to Wang ShougangXThese patches include FDIR memory resource fixes related to ICE driver. Patch 1: fix memzone reserve and release in FDIR
Patch 2: fix removal of FDIR profile
Patch 3: fix FDIR counter resource release
Patch 4: fix wild pointer
---
v5 changes:
Changed loop start index in ice_fdir_prof_alloc().
Changed loop start index in ice_fdir_prof_free().
v4 changes:
Removed unnecessary pointer initialization operations. Changed loop start index in ice_fdir_prof_rm_all().
v3 changes:
Changed error log.
v2 changes:
Merged patches related to CVL memory resources management into patchset.
Wang ShougangX (4):
net/ice: fix memzone reserve and release in FDIR net/ice: fix removal of FDIR profile net/ice: fix FDIR counter resource release net/ice: fix wild pointer
drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 49 ++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 8 deletions(-)
Signature · 1 line
2.17.1
PATCH v5 1/4 net/ice: fix memzone reserve and release in FDIR
To avoid memzone reserve failure and memory leak, following resources management should be added.
- Check if the FDIR Memzone already exists before reserving.
- Free FDIR memzone when teardown and other failure scenarios.
--- drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.h +1 -0
@@ -334,6 +334,7 @@ struct ice_fdir_info {struct ice_rx_queue *rxq;void *prg_pkt;/* memory for fdir program packet */ uint64_t dma_addr;/* physic address of packet memory*/ +const struct rte_memzone *mz;struct ice_fdir_filter_conf conf;struct ice_fdir_filter_conf **hash_map;
drivers/net/ice/ice_fdir_filter.c +18 -1
@@ -127,6 +127,12 @@ static struct ice_flow_parser ice_fdir_parser_comms;static const struct rte_memzone *ice_memzone_reserve (const char *name,uint32_t len,int socket_id) { +const struct rte_memzone *mz; + + mz =rte_memzone_lookup (name); +if (mz) +return mz; +return rte_memzone_reserve_aligned (name, len, socket_id,RTE_MEMZONE_IOVA_CONTIG ,ICE_RING_BASE_ALIGN );
@@ -481,19 +487,23 @@ ice_fdir_setup(struct ice_pf *pf) } pf->fdir.prg_pkt = mz->addr; pf->fdir.dma_addr = mz->iova; + pf->fdir.mz = mz; err =ice_fdir_prof_alloc (hw);if (err) {PMD_DRV_LOG (ERR ,"Cannot allocate memory for " "flow director profile." ); err = -ENOMEM ; - goto fail_mem; + goto fail_prof; }PMD_DRV_LOG (INFO ,"FDIR setup successfully, with programming queue %u." , vsi->base_queue);return ICE_SUCCESS ; +fail_prof: +rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; fail_mem:ice_rx_queue_release (pf->fdir.rxq); pf->fdir.rxq =NULL ;
@@ -607,6 +617,13 @@ ice_fdir_teardown(struct ice_pf *pf)ice_fdir_prof_free (hw);ice_release_vsi (vsi); pf->fdir.fdir_vsi =NULL ; + +if (pf->fdir.mz) { + err =rte_memzone_free (pf->fdir.mz); + pf->fdir.mz =NULL ; +if (err) +PMD_DRV_LOG (ERR ,"Failed to free FDIR memezone." ); + } } static int
Signature · 1 line
2.17.1
PATCH v5 2/4 net/ice: fix removal of FDIR profile
In reply to Wang ShougangXThe removal of FDIR profile should start from the next of ICE_FLTR_PTYPE_NONF_NONE.
--- drivers/net/ice/ice_fdir_filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ice/ice_fdir_filter.c +4 -4
@@ -152,7 +152,7 @@ ice_fdir_prof_alloc(struct ice_hw *hw)if (!hw->fdir_prof)return -ENOMEM ; } -for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; +for (ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {if (!hw->fdir_prof[ptype]) {
@@ -165,7 +165,7 @@ ice_fdir_prof_alloc(struct ice_hw *hw)return 0 ; fail_mem: -for (fltr_ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; +for (fltr_ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; fltr_ptype < ptype; fltr_ptype++)rte_free (hw->fdir_prof[fltr_ptype]);
@@ -521,7 +521,7 @@ ice_fdir_prof_free(struct ice_hw *hw) {enum ice_fltr_ptype ptype; -for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; +for (ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++)rte_free (hw->fdir_prof[ptype]);
@@ -571,7 +571,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) {enum ice_fltr_ptype ptype; -for (ptype =ICE_FLTR_PTYPE_NONF_NONE ; +for (ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {ice_fdir_prof_rm (pf, ptype, false);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v5 2/4] net/ice: fix removal of FDIR profile
Hi,
Quoted 57 lines
-----Original Message-----
From: Wang, ShougangX
Sent: Wednesday, November 13, 2019 9:38 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Wang, ShougangX <[email protected]>
Subject: [PATCH v5 2/4] net/ice: fix removal of FDIR profileThe removal of FDIR profile should start from the next of
ICE_FLTR_PTYPE_NONF_NONE.Fixes 109e8e06249e ("net/ice: configure HW flow director rule")Signed-off-by Wang ShougangX <[email protected]>--- drivers/net/ice/ice_fdir_filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/ice/ice_fdir_filter.c +4
-5@@ -152,7 +152,7 @@ ice_fdir_prof_alloc(struct ice_hw *hw)if (!hw->fdir_prof)return -ENOMEM ; } -for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; +for (ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {if (!hw->fdir_prof[ptype]) {@@ -165,7 +165,7 @@ ice_fdir_prof_alloc(struct ice_hw *hw)return 0 ; fail_mem: -for (fltr_ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; +for (fltr_ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; fltr_ptype < ptype; fltr_ptype++)rte_free (hw->fdir_prof[fltr_ptype]);@@ -521,7 +521,7 @@ ice_fdir_prof_free(struct ice_hw *hw) {enum ice_fltr_ptype ptype; -for (ptype =ICE_FLTR_PTYPE_NONF_IPV4_UDP ; +for (ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++)rte_free (hw->fdir_prof[ptype]);@@ -571,7 +571,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) {enum ice_fltr_ptype ptype; -for (ptype =ICE_FLTR_PTYPE_NONF_NONE ; +for (ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; ptype <ICE_FLTR_PTYPE_MAX ; ptype++) {ice_fdir_prof_rm (pf, ptype, false); --
Quoted 1 line
2.17.1
PATCH v5 3/4 net/ice: fix FDIR counter resource release
In reply to Wang ShougangXAll the counter resources should be cleaned up when teardown.
--- drivers/net/ice/ice_fdir_filter.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ice/ice_fdir_filter.c +3 -0
@@ -252,6 +252,9 @@ ice_fdir_counter_release(struct ice_pf *pf)for (i =0 ; i < container->index_free; i++)rte_free (container->pools[i]); +TAILQ_INIT (&container->pool_list); + container->index_free =0 ; +return 0 ; }
Signature · 1 line
2.17.1
PATCH v5 4/4 net/ice: fix wild pointer
In reply to Wang ShougangXTo avoid wild pointer, pointers should be set to NULL after free them.
--- drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/net/ice/ice_fdir_filter.c +16 -3
@@ -167,9 +167,14 @@ ice_fdir_prof_alloc(struct ice_hw *hw) fail_mem:for (fltr_ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; fltr_ptype < ptype; - fltr_ptype++) + fltr_ptype++) {rte_free (hw->fdir_prof[fltr_ptype]); + hw->fdir_prof[fltr_ptype] =NULL ; + } +rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; +return -ENOMEM ; }
@@ -249,8 +254,10 @@ ice_fdir_counter_release(struct ice_pf *pf) &fdir_info->counter;uint8_t i; -for (i =0 ; i < container->index_free; i++) +for (i =0 ; i < container->index_free; i++) {rte_free (container->pools[i]); + container->pools[i] =NULL ; + }TAILQ_INIT (&container->pool_list); container->index_free =0 ;
@@ -400,6 +407,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/*
@@ -526,10 +536,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }/* Remove a profile for some filter type */
Signature · 1 line
2.17.1
Hi,
Quoted 78 lines
-----Original Message-----
From: Wang, ShougangX
Sent: Wednesday, November 13, 2019 9:38 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Wang, ShougangX <[email protected]>
Subject: [PATCH v5 4/4] net/ice: fix wild pointerTo avoid wild pointer, pointers should be set to NULL after free them.
Fixes 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")Fixes 84dc7a95a2d3 ("net/ice: enable flow director engine")Fixes 0f880c3df192 ("net/ice: add flow director counter resourceinit/release")
Signed-off-by Wang ShougangX <[email protected]>--- drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)drivers/net/ice/ice_fdir_filter.c +16
-4@@ -167,9 +167,14 @@ ice_fdir_prof_alloc(struct ice_hw *hw) fail_mem:for (fltr_ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; fltr_ptype < ptype; - fltr_ptype++) + fltr_ptype++) {rte_free (hw->fdir_prof[fltr_ptype]); + hw->fdir_prof[fltr_ptype] =NULL ; + } +rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; +return -ENOMEM ; }@@ -249,8 +254,10 @@ ice_fdir_counter_release(struct ice_pf *pf) &fdir_info->counter;uint8_t i; -for (i =0 ; i < container->index_free; i++) +for (i =0 ; i < container->index_free; i++) {rte_free (container->pools[i]); + container->pools[i] =NULL ; + }TAILQ_INIT (&container->pool_list); container->index_free =0 ;@@ -400,6 +407,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)rte_free (fdir_info->hash_map);if (fdir_info->hash_table)rte_hash_free (fdir_info->hash_table); + + fdir_info->hash_map =NULL ; + fdir_info->hash_table =NULL ; }/* @@ -526,10 +536,13 @@ ice_fdir_prof_free(struct ice_hw *hw)for (ptype =ICE_FLTR_PTYPE_NONF_NONE +1 ; ptype <ICE_FLTR_PTYPE_MAX ; - ptype++) + ptype++) {rte_free (hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] =NULL ; + }rte_free (hw->fdir_prof); + hw->fdir_prof =NULL ; }/* Remove a profile for some filter type */ --
Quoted 1 line
2.17.1
Re: [dpdk-dev] [PATCH v5 0/4] net/ice: fix memory release in FDIR
In reply to Wang ShougangXQuoted 24 lines · Wang ShougangX
These patches include FDIR memory resource fixes related to ICE driver. Patch 1: fix memzone reserve and release in FDIR
Patch 2: fix removal of FDIR profile
Patch 3: fix FDIR counter resource release
Patch 4: fix wild pointer---
v5 changes:
Changed loop start index inice_fdir_prof_alloc().
Changed loop start index inice_fdir_prof_free().
v4 changes:
Removed unnecessary pointer initialization operations. Changed loop start index inice_fdir_prof_rm_all().
v3 changes:
Changed error log.
v2 changes:
Merged patches related to CVL memory resources management into patchset.Wang ShougangX (4):
net/ice: fix memzone reserve and release in FDIR
net/ice: fix removal of FDIR profile
net/ice: fix FDIR counter resource release
net/ice: fix wild pointer
Quoted 7 lines
drivers/net/ice/ice_ethdev.h| 1 +drivers/net/ice/ice_fdir_filter.c| 49 ++++++++++++++++++++++++++-----2 files changed, 42 insertions(+), 8 deletions(-)Signature · 1 line
2.17.1
Series applied to dpdk-next-net-intel, Thanks.