DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] enic: fix name of hash table used for enic classifiers
@ 2016-06-14 23:52 Nelson Escobar
  2016-06-23 11:24 ` Bruce Richardson
  0 siblings, 1 reply; 4+ messages in thread
From: Nelson Escobar @ 2016-06-14 23:52 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, johndale, Nelson Escobar

The enic_clsf_init() function is called once per enic instance, but it
used a static name to create the hash table.  Consequently when using
more than one enic instance, there was a name collision which caused
errors:

EAL: memzone_reserve_aligned_thread_unsafe():
  memzone<RG_HT_enicpmd_clsf_hash> already exists
RING: Cannot reserve memory
HASH: memory allocation failed
PMD: rte_enic_pmd: Init of hash table for clsf failed.
  Flow director feature will not work

This patch changes the name to be unique per enic instance.

Fixes: fefed3d1e62c ("enic: new driver")

Signed-off-by: Nelson Escobar <neescoba@cisco.com>
Reviewed-by: John Daley <johndale@cisco.com>
---
 drivers/net/enic/enic_clsf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/enic/enic_clsf.c b/drivers/net/enic/enic_clsf.c
index edb56e1..2ec77f5 100644
--- a/drivers/net/enic/enic_clsf.c
+++ b/drivers/net/enic/enic_clsf.c
@@ -239,15 +239,16 @@ void enic_clsf_destroy(struct enic *enic)
 
 int enic_clsf_init(struct enic *enic)
 {
+	char clsf_name[RTE_HASH_NAMESIZE];
 	struct rte_hash_parameters hash_params = {
-		.name = "enicpmd_clsf_hash",
+		.name = clsf_name,
 		.entries = ENICPMD_CLSF_HASH_ENTRIES,
 		.key_len = sizeof(struct rte_eth_fdir_filter),
 		.hash_func = DEFAULT_HASH_FUNC,
 		.hash_func_init_val = 0,
 		.socket_id = SOCKET_ID_ANY,
 	};
-
+	sprintf(clsf_name, "enic_clsf_%s", enic->bdf_name);
 	enic->fdir.hash = rte_hash_create(&hash_params);
 	memset(&enic->fdir.stats, 0, sizeof(enic->fdir.stats));
 	enic->fdir.stats.free = ENICPMD_FDIR_MAX;
-- 
2.7.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] enic: fix name of hash table used for enic classifiers
  2016-06-14 23:52 [dpdk-dev] [PATCH] enic: fix name of hash table used for enic classifiers Nelson Escobar
@ 2016-06-23 11:24 ` Bruce Richardson
  2016-06-23 23:10   ` [dpdk-dev] [PATCH v2] " Nelson Escobar
  0 siblings, 1 reply; 4+ messages in thread
From: Bruce Richardson @ 2016-06-23 11:24 UTC (permalink / raw)
  To: Nelson Escobar; +Cc: dev, johndale

On Tue, Jun 14, 2016 at 04:52:28PM -0700, Nelson Escobar wrote:
> The enic_clsf_init() function is called once per enic instance, but it
> used a static name to create the hash table.  Consequently when using
> more than one enic instance, there was a name collision which caused
> errors:
> 
> EAL: memzone_reserve_aligned_thread_unsafe():
>   memzone<RG_HT_enicpmd_clsf_hash> already exists
> RING: Cannot reserve memory
> HASH: memory allocation failed
> PMD: rte_enic_pmd: Init of hash table for clsf failed.
>   Flow director feature will not work
> 
> This patch changes the name to be unique per enic instance.
> 
> Fixes: fefed3d1e62c ("enic: new driver")
> 
> Signed-off-by: Nelson Escobar <neescoba@cisco.com>
> Reviewed-by: John Daley <johndale@cisco.com>
> ---
>  drivers/net/enic/enic_clsf.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/enic/enic_clsf.c b/drivers/net/enic/enic_clsf.c
> index edb56e1..2ec77f5 100644
> --- a/drivers/net/enic/enic_clsf.c
> +++ b/drivers/net/enic/enic_clsf.c
> @@ -239,15 +239,16 @@ void enic_clsf_destroy(struct enic *enic)
>  
>  int enic_clsf_init(struct enic *enic)
>  {
> +	char clsf_name[RTE_HASH_NAMESIZE];
>  	struct rte_hash_parameters hash_params = {
> -		.name = "enicpmd_clsf_hash",
> +		.name = clsf_name,
>  		.entries = ENICPMD_CLSF_HASH_ENTRIES,
>  		.key_len = sizeof(struct rte_eth_fdir_filter),
>  		.hash_func = DEFAULT_HASH_FUNC,
>  		.hash_func_init_val = 0,
>  		.socket_id = SOCKET_ID_ANY,
>  	};
> -
> +	sprintf(clsf_name, "enic_clsf_%s", enic->bdf_name);

To avoid buffer overflow it's safer to use snprintf rather than sprintf.

	snprintf(clsf_name, sizeof(clsf_name), .... );

/Bruce

>  	enic->fdir.hash = rte_hash_create(&hash_params);
>  	memset(&enic->fdir.stats, 0, sizeof(enic->fdir.stats));
>  	enic->fdir.stats.free = ENICPMD_FDIR_MAX;
> -- 
> 2.7.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v2] enic: fix name of hash table used for enic classifiers
  2016-06-23 11:24 ` Bruce Richardson
@ 2016-06-23 23:10   ` Nelson Escobar
  2016-06-28 10:12     ` Bruce Richardson
  0 siblings, 1 reply; 4+ messages in thread
From: Nelson Escobar @ 2016-06-23 23:10 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Nelson Escobar

The enic_clsf_init() function is called once per enic instance, but it
used a static name to create the hash table.  Consequently when using
more than one enic instance, there was a name collision which caused
errors:

EAL: memzone_reserve_aligned_thread_unsafe():
  memzone<RG_HT_enicpmd_clsf_hash> already exists
RING: Cannot reserve memory
HASH: memory allocation failed
PMD: rte_enic_pmd: Init of hash table for clsf failed.
  Flow director feature will not work

This patch changes the name to be unique per enic instance.

Fixes: fefed3d1e62c ("enic: new driver")

Signed-off-by: Nelson Escobar <neescoba@cisco.com>
Reviewed-by: John Daley <johndale@cisco.com>
---
v2: 
  - use snprintf instead of sprintf

 drivers/net/enic/enic_clsf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/enic/enic_clsf.c b/drivers/net/enic/enic_clsf.c
index edb56e1..2050818 100644
--- a/drivers/net/enic/enic_clsf.c
+++ b/drivers/net/enic/enic_clsf.c
@@ -239,15 +239,16 @@ void enic_clsf_destroy(struct enic *enic)
 
 int enic_clsf_init(struct enic *enic)
 {
+	char clsf_name[RTE_HASH_NAMESIZE];
 	struct rte_hash_parameters hash_params = {
-		.name = "enicpmd_clsf_hash",
+		.name = clsf_name,
 		.entries = ENICPMD_CLSF_HASH_ENTRIES,
 		.key_len = sizeof(struct rte_eth_fdir_filter),
 		.hash_func = DEFAULT_HASH_FUNC,
 		.hash_func_init_val = 0,
 		.socket_id = SOCKET_ID_ANY,
 	};
-
+	snprintf(clsf_name, RTE_HASH_NAMESIZE, "enic_clsf_%s", enic->bdf_name);
 	enic->fdir.hash = rte_hash_create(&hash_params);
 	memset(&enic->fdir.stats, 0, sizeof(enic->fdir.stats));
 	enic->fdir.stats.free = ENICPMD_FDIR_MAX;
-- 
2.7.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] enic: fix name of hash table used for enic classifiers
  2016-06-23 23:10   ` [dpdk-dev] [PATCH v2] " Nelson Escobar
@ 2016-06-28 10:12     ` Bruce Richardson
  0 siblings, 0 replies; 4+ messages in thread
From: Bruce Richardson @ 2016-06-28 10:12 UTC (permalink / raw)
  To: Nelson Escobar; +Cc: dev

On Thu, Jun 23, 2016 at 04:10:02PM -0700, Nelson Escobar wrote:
> The enic_clsf_init() function is called once per enic instance, but it
> used a static name to create the hash table.  Consequently when using
> more than one enic instance, there was a name collision which caused
> errors:
> 
> EAL: memzone_reserve_aligned_thread_unsafe():
>   memzone<RG_HT_enicpmd_clsf_hash> already exists
> RING: Cannot reserve memory
> HASH: memory allocation failed
> PMD: rte_enic_pmd: Init of hash table for clsf failed.
>   Flow director feature will not work
> 
> This patch changes the name to be unique per enic instance.
> 
> Fixes: fefed3d1e62c ("enic: new driver")
> 
> Signed-off-by: Nelson Escobar <neescoba@cisco.com>
> Reviewed-by: John Daley <johndale@cisco.com>
> ---

Applied to dpdk-next-net/rel_16_07

/Bruce

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-28 10:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-14 23:52 [dpdk-dev] [PATCH] enic: fix name of hash table used for enic classifiers Nelson Escobar
2016-06-23 11:24 ` Bruce Richardson
2016-06-23 23:10   ` [dpdk-dev] [PATCH v2] " Nelson Escobar
2016-06-28 10:12     ` Bruce Richardson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).