netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Mohsin Bashir <mohsin.bashr@gmail.com>
Cc: netdev@vger.kernel.org, aleksander.lobakin@intel.com,
	alexanderduyck@fb.com, andrew+netdev@lunn.ch, ast@kernel.org,
	bpf@vger.kernel.org, corbet@lwn.net, daniel@iogearbox.net,
	davem@davemloft.net, edumazet@google.com, hawk@kernel.org,
	horms@kernel.org, john.fastabend@gmail.com, kernel-team@meta.com,
	kuba@kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, pabeni@redhat.com, sdf@fomichev.me,
	vadim.fedorenko@linux.dev
Subject: Re: [PATCH net-next V4 5/9] eth: fbnic: Add XDP pass, drop, abort support
Date: Thu, 21 Aug 2025 15:52:11 +0300	[thread overview]
Message-ID: <aKcWe3bm3wQqlfdx@stanley.mountain> (raw)
In-Reply-To: <20250813221319.3367670-6-mohsin.bashr@gmail.com>

On Wed, Aug 13, 2025 at 03:13:15PM -0700, Mohsin Bashir wrote:
> @@ -1251,6 +1293,7 @@ static void fbnic_free_napi_vector(struct fbnic_net *fbn,
>  	}
>  
>  	for (j = 0; j < nv->rxt_count; j++, i++) {
> +		xdp_rxq_info_unreg(&nv->qt[i].xdp_rxq);
>  		fbnic_remove_rx_ring(fbn, &nv->qt[i].sub0);
>  		fbnic_remove_rx_ring(fbn, &nv->qt[i].sub1);
>  		fbnic_remove_rx_ring(fbn, &nv->qt[i].cmpl);
> @@ -1423,6 +1466,11 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn,
>  		fbnic_ring_init(&qt->cmpl, db, rxq_idx, FBNIC_RING_F_STATS);
>  		fbn->rx[rxq_idx] = &qt->cmpl;
>  
> +		err = xdp_rxq_info_reg(&qt->xdp_rxq, fbn->netdev, rxq_idx,
> +				       nv->napi.napi_id);
> +		if (err)
> +			goto free_ring_cur_qt;
> +
>  		/* Update Rx queue index */
>  		rxt_count--;
>  		rxq_idx += v_count;
> @@ -1433,6 +1481,25 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn,
>  
>  	return 0;
>  
> +	while (rxt_count < nv->rxt_count) {
               ^^^^^^^^^^^^^^^^^^^^^^^^^
This should be <= otherwise it won't free enough.  Then qt will point to
the wrong thing and the next loop will crash.

The loops in this function are mind bendingly complicated.  It might be
easiter to write them as:

	for (i = 0; i < nv->txt_count; i++) {
		qt = &nv->qt[i];
		...
	}

	for (i = 0; i < nv->rxt_count; i++) {
		qt = &nv->qt[txt_count + i];
		...
	}

Generally, I would just unwind the partial loop before the goto instead
of doing a jump to the middle of the goto.  It's more lines of code, but
I'm stupid, so I prefer code which is easy even if it's longer.

regards,
dan carpenter

> +		qt--;
> +
> +		xdp_rxq_info_unreg(&qt->xdp_rxq);
> +free_ring_cur_qt:
> +		fbnic_remove_rx_ring(fbn, &qt->sub0);
> +		fbnic_remove_rx_ring(fbn, &qt->sub1);
> +		fbnic_remove_rx_ring(fbn, &qt->cmpl);
> +		rxt_count++;
> +	}
> +	while (txt_count < nv->txt_count) {
> +		qt--;
> +
> +		fbnic_remove_tx_ring(fbn, &qt->sub0);
> +		fbnic_remove_tx_ring(fbn, &qt->cmpl);
> +
> +		txt_count++;
> +	}
> +	fbnic_napi_free_irq(fbd, nv);
>  pp_destroy:
>  	page_pool_destroy(nv->page_pool);
>  napi_del:


  reply	other threads:[~2025-08-21 12:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13 22:13 [PATCH net-next V4 0/9] eth: fbnic: Add XDP support for fbnic Mohsin Bashir
2025-08-13 22:13 ` [PATCH net-next V4 1/9] eth: fbnic: Add support for HDS configuration Mohsin Bashir
2025-08-13 22:13 ` [PATCH net-next V4 2/9] eth: fbnic: Update Headroom Mohsin Bashir
2025-08-13 22:13 ` [PATCH net-next V4 3/9] eth: fbnic: Use shinfo to track frags state on Rx Mohsin Bashir
2025-08-13 22:13 ` [PATCH net-next V4 4/9] eth: fbnic: Prefetch packet headers " Mohsin Bashir
2025-08-13 22:13 ` [PATCH net-next V4 5/9] eth: fbnic: Add XDP pass, drop, abort support Mohsin Bashir
2025-08-21 12:52   ` Dan Carpenter [this message]
2025-08-13 22:13 ` [PATCH net-next V4 6/9] eth: fbnic: Add support for XDP queues Mohsin Bashir
2025-08-13 22:13 ` [PATCH net-next V4 7/9] eth: fbnic: Add support for XDP_TX action Mohsin Bashir
2025-08-13 22:13 ` [PATCH net-next V4 8/9] eth: fbnic: Collect packet statistics for XDP Mohsin Bashir
2025-08-13 22:13 ` [PATCH net-next V4 9/9] eth: fbnic: Report XDP stats via ethtool Mohsin Bashir
2025-08-19  9:20 ` [PATCH net-next V4 0/9] eth: fbnic: Add XDP support for fbnic patchwork-bot+netdevbpf

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=aKcWe3bm3wQqlfdx@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=alexanderduyck@fb.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mohsin.bashr@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=vadim.fedorenko@linux.dev \
    /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 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).