DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/mlx4: use anonymous DV allocator argument
@ 2020-06-24 13:29 Michael Baum
  2020-06-28 15:07 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Baum @ 2020-06-24 13:29 UTC (permalink / raw)
  To: dev; +Cc: matan, viacheslavo

The mlx4_pci_probe function defines an struct mlx4dv_ctx_allocators type
variable several hundred rows after it starts, with the only use it
being passed as a parameter to the mlx4_glue->dv_set_context_attr
function.
However, according to DPDK Coding Style Guidelines, variables should be
declared at the start of a block of code rather than in the middle.
Therefore, to improve the Coding Style, the variable is passed directly
to the function without declaring it before.

Signed-off-by: Michael Baum <michaelba@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx4/mlx4.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 5d72027..ff270b4 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -1054,14 +1054,13 @@ struct mlx4_conf {
 		eth_dev->dev_ops = &mlx4_dev_ops;
 #ifdef HAVE_IBV_MLX4_BUF_ALLOCATORS
 		/* Hint libmlx4 to use PMD allocator for data plane resources */
-		struct mlx4dv_ctx_allocators alctr = {
-			.alloc = &mlx4_alloc_verbs_buf,
-			.free = &mlx4_free_verbs_buf,
-			.data = priv,
-		};
 		err = mlx4_glue->dv_set_context_attr
 			(ctx, MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS,
-			 (void *)((uintptr_t)&alctr));
+			 (void *)((uintptr_t)&(struct mlx4dv_ctx_allocators){
+				 .alloc = &mlx4_alloc_verbs_buf,
+				 .free = &mlx4_free_verbs_buf,
+				 .data = priv,
+			}));
 		if (err)
 			WARN("Verbs external allocator is not supported");
 		else
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH] net/mlx4: use anonymous DV allocator argument
  2020-06-24 13:29 [dpdk-dev] [PATCH] net/mlx4: use anonymous DV allocator argument Michael Baum
@ 2020-06-28 15:07 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2020-06-28 15:07 UTC (permalink / raw)
  To: Michael Baum, dev; +Cc: Matan Azrad, Slava Ovsiienko

Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Michael Baum
> Sent: Wednesday, June 24, 2020 4:30 PM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>
> Subject: [dpdk-dev] [PATCH] net/mlx4: use anonymous DV allocator
> argument
> 
> The mlx4_pci_probe function defines an struct mlx4dv_ctx_allocators type
> variable several hundred rows after it starts, with the only use it
> being passed as a parameter to the mlx4_glue->dv_set_context_attr
> function.
> However, according to DPDK Coding Style Guidelines, variables should be
> declared at the start of a block of code rather than in the middle.
> Therefore, to improve the Coding Style, the variable is passed directly
> to the function without declaring it before.
> 
> Signed-off-by: Michael Baum <michaelba@mellanox.com>
> Acked-by: Matan Azrad <matan@mellanox.com>
> ---
>  drivers/net/mlx4/mlx4.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
> index 5d72027..ff270b4 100644
> --- a/drivers/net/mlx4/mlx4.c
> +++ b/drivers/net/mlx4/mlx4.c
> @@ -1054,14 +1054,13 @@ struct mlx4_conf {
>  		eth_dev->dev_ops = &mlx4_dev_ops;
>  #ifdef HAVE_IBV_MLX4_BUF_ALLOCATORS
>  		/* Hint libmlx4 to use PMD allocator for data plane resources
> */
> -		struct mlx4dv_ctx_allocators alctr = {
> -			.alloc = &mlx4_alloc_verbs_buf,
> -			.free = &mlx4_free_verbs_buf,
> -			.data = priv,
> -		};
>  		err = mlx4_glue->dv_set_context_attr
>  			(ctx, MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS,
> -			 (void *)((uintptr_t)&alctr));
> +			 (void *)((uintptr_t)&(struct mlx4dv_ctx_allocators){
> +				 .alloc = &mlx4_alloc_verbs_buf,
> +				 .free = &mlx4_free_verbs_buf,
> +				 .data = priv,
> +			}));
>  		if (err)
>  			WARN("Verbs external allocator is not supported");
>  		else
> --
> 1.8.3.1

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh


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

end of thread, other threads:[~2020-06-28 15:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-24 13:29 [dpdk-dev] [PATCH] net/mlx4: use anonymous DV allocator argument Michael Baum
2020-06-28 15:07 ` Raslan Darawsheh

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git