All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: David Wei <dw@davidwei.uk>
Cc: netdev@vger.kernel.org, Michael Chan <michael.chan@broadcom.com>,
	Pavan Chebbi <pavan.chebbi@broadcom.com>,
	Andy Gospodarek <andrew.gospodarek@broadcom.com>,
	Adrian Alvarado <adrian.alvarado@broadcom.com>,
	Mina Almasry <almasrymina@google.com>,
	Shailend Chand <shailend@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>
Subject: Re: [RFC PATCH net-next v2 5/9] bnxt: refactor bnxt_{alloc,free}_one_tpa_info()
Date: Sat, 4 May 2024 13:30:35 +0100	[thread overview]
Message-ID: <20240504123035.GH3167983@kernel.org> (raw)
In-Reply-To: <20240502045410.3524155-6-dw@davidwei.uk>

On Wed, May 01, 2024 at 09:54:06PM -0700, David Wei wrote:
> Refactor the allocation of each rx ring's tpa_info in
> bnxt_alloc_tpa_info() out into a standalone function
> __bnxt_alloc_one_tpa_info().
> 
> In case of allocation failures during bnxt_alloc_tpa_info(), clean up
> in-place.
> 
> Change bnxt_free_tpa_info() to free a single rx ring passed in as a
> parameter. This makes bnxt_free_rx_rings() more symmetrical.
> 
> Signed-off-by: David Wei <dw@davidwei.uk>

Hi David,

Some minor nits flagged by

./scripts/checkpatch.pl --codespell --max-line-length=80 --strict

> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 95 +++++++++++++++--------
>  1 file changed, 62 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c

...

> +static int __bnxt_alloc_one_tpa_info(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
> +{

Please consider limiting Networking code to 80 columns wide where
it can be trivially achieved.

In this case, perhaps:

static int __bnxt_alloc_one_tpa_info(struct bnxt *bp,
				     struct bnxt_rx_ring_info *rxr)

> +	struct rx_agg_cmp *agg;
> +	int i, rc;
> +
> +	rxr->rx_tpa = kcalloc(bp->max_tpa, sizeof(struct bnxt_tpa_info),
> +				GFP_KERNEL);

The indentation here is not quite right.

	rxr->rx_tpa = kcalloc(bp->max_tpa, sizeof(struct bnxt_tpa_info),
			      GFP_KERNEL);

> +	if (!rxr->rx_tpa)
> +		return -ENOMEM;
> +
> +	if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS))
> +		return 0;
> +
> +	for (i = 0; i < bp->max_tpa; i++) {
> +		agg = kcalloc(MAX_SKB_FRAGS, sizeof(*agg), GFP_KERNEL);
> +		if (!agg) {
> +			rc = -ENOMEM;
> +			goto err_free;
>  		}
> -		kfree(rxr->rx_tpa);
> -		rxr->rx_tpa = NULL;
> +		rxr->rx_tpa[i].agg_arr = agg;
> +	}
> +	rxr->rx_tpa_idx_map = kzalloc(sizeof(*rxr->rx_tpa_idx_map),
> +					GFP_KERNEL);
> +	if (!rxr->rx_tpa_idx_map) {
> +		rc = -ENOMEM;
> +		goto err_free;
>  	}
> +
> +	return 0;
> +
> +err_free:
> +	while(i--) {

Space before '(' here please.

> +		kfree(rxr->rx_tpa[i].agg_arr);
> +		rxr->rx_tpa[i].agg_arr = NULL;
> +	}
> +	kfree(rxr->rx_tpa);
> +	rxr->rx_tpa = NULL;
> +
> +	return rc;
>  }

...

  reply	other threads:[~2024-05-04 12:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-02  4:54 [RFC PATCH net-next v2 0/9] bnxt: implement queue api David Wei
2024-05-02  4:54 ` [RFC PATCH net-next v2 1/9] queue_api: define " David Wei
2024-05-04 12:11   ` Simon Horman
2024-05-06  0:34     ` David Wei
2024-05-02  4:54 ` [RFC PATCH net-next v2 2/9] bnxt: implement " David Wei
2024-05-02 17:23   ` Mina Almasry
2024-05-06  0:36     ` David Wei
2024-05-02  4:54 ` [RFC PATCH net-next v2 3/9] netdev: add netdev_rx_queue_restart() David Wei
2024-05-02 17:27   ` Mina Almasry
2024-05-06  0:38     ` David Wei
2024-05-04 12:20   ` Simon Horman
2024-05-06  0:41     ` David Wei
2024-05-07 16:46       ` Simon Horman
2024-05-08 17:13         ` Mina Almasry
2024-05-02  4:54 ` [RFC PATCH net-next v2 4/9] bnxt: refactor bnxt_{alloc,free}_one_rx_ring() David Wei
2024-05-02  4:54 ` [RFC PATCH net-next v2 5/9] bnxt: refactor bnxt_{alloc,free}_one_tpa_info() David Wei
2024-05-04 12:30   ` Simon Horman [this message]
2024-05-06  0:43     ` David Wei
2024-05-02  4:54 ` [RFC PATCH net-next v2 6/9] bnxt: add __bnxt_init_rx_ring_struct() helper David Wei
2024-05-02  4:54 ` [RFC PATCH net-next v2 7/9] bnxt: add helpers for allocating rx ring mem David Wei
2024-05-04 12:34   ` Simon Horman
2024-05-06  0:42     ` David Wei
2024-05-02  4:54 ` [RFC PATCH net-next v2 8/9] bnxt: alloc rx ring mem first before reset David Wei
2024-05-02  4:54 ` [RFC PATCH net-next v2 9/9] bnxt: swap rx ring mem during queue_stop() David Wei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240504123035.GH3167983@kernel.org \
    --to=horms@kernel.org \
    --cc=adrian.alvarado@broadcom.com \
    --cc=almasrymina@google.com \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=dw@davidwei.uk \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=shailend@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.