[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250901142747.6e6f8bfd@kernel.org>
Date: Mon, 1 Sep 2025 14:27:47 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Bhargava Marreddy <bhargava.marreddy@...adcom.com>
Cc: davem@...emloft.net, edumazet@...gle.com, pabeni@...hat.com,
andrew+netdev@...n.ch, horms@...nel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, michael.chan@...adcom.com,
pavan.chebbi@...adcom.com, vsrama-krishna.nemani@...adcom.com, Vikas Gupta
<vikas.gupta@...adcom.com>, Rajashekar Hudumula
<rajashekar.hudumula@...adcom.com>
Subject: Re: [v5, net-next 2/9] bng_en: Add initial support for CP and NQ
rings
On Thu, 28 Aug 2025 18:45:40 +0000 Bhargava Marreddy wrote:
> Allocate CP and NQ related data structures and add support to
> associate NQ and CQ rings. Also, add the association of NQ, NAPI,
> and interrupts.
> +static int bnge_alloc_nq_desc_arr(struct bnge_nq_ring_info *nqr, int n)
> +{
> + nqr->desc_ring = kcalloc(n, sizeof(*nqr->desc_ring), GFP_KERNEL);
> + if (!nqr->desc_ring)
> + return -ENOMEM;
> +
> + nqr->desc_mapping = kcalloc(n, sizeof(*nqr->desc_mapping), GFP_KERNEL);
> + if (!nqr->desc_mapping)
> + return -ENOMEM;
Please add appropriate local unwind in all functions. If the function
fails it should undo its partial updates. The assumptions about unwind
somewhere deep in the call stack made it hard to work with bnxt.
> +static int alloc_one_cp_ring(struct bnge_net *bn,
> + struct bnge_cp_ring_info *cpr)
> +{
> + struct bnge_ring_mem_info *rmem;
> + struct bnge_ring_struct *ring;
> + struct bnge_dev *bd = bn->bd;
> + int rc;
> +
> + rc = bnge_alloc_cp_desc_arr(cpr, bn->cp_nr_pages);
> + if (rc) {
> + bnge_free_cp_desc_arr(cpr);
> + return -ENOMEM;
> + }
> + ring = &cpr->ring_struct;
> + rmem = &ring->ring_mem;
> + rmem->nr_pages = bn->cp_nr_pages;
> + rmem->page_size = HW_CMPD_RING_SIZE;
> + rmem->pg_arr = (void **)cpr->desc_ring;
> + rmem->dma_arr = cpr->desc_mapping;
> + rmem->flags = BNGE_RMEM_RING_PTE_FLAG;
> + rc = bnge_alloc_ring(bd, rmem);
> + if (rc) {
> + bnge_free_ring(bd, rmem);
> + bnge_free_cp_desc_arr(cpr);
use a goto ladder for centralized error handling, per kernel coding
style
> + }
> +
> + return rc;
> +}
> +static int bnge_set_real_num_queues(struct bnge_net *bn)
> +{
> + struct net_device *dev = bn->netdev;
> + struct bnge_dev *bd = bn->bd;
> + int rc;
> +
> + rc = netif_set_real_num_tx_queues(dev, bd->tx_nr_rings);
> + if (rc)
> + return rc;
> +
> + return netif_set_real_num_rx_queues(dev, bd->rx_nr_rings);
> +}
netif_set_real_num_queues() exists
> +static int bnge_setup_interrupts(struct bnge_net *bn)
> +{
> + struct bnge_dev *bd = bn->bd;
> +
> + if (!bd->irq_tbl) {
> + if (bnge_alloc_irqs(bd))
> + return -ENODEV;
> + }
> +
> + bnge_setup_msix(bn);
> +
> + return bnge_set_real_num_queues(bn);
> +}
> +
> +static int bnge_request_irq(struct bnge_net *bn)
> +{
> + struct bnge_dev *bd = bn->bd;
> + int i, rc;
> +
> + rc = bnge_setup_interrupts(bn);
> + if (rc) {
> + netdev_err(bn->netdev, "bnge_setup_interrupts err: %d\n", rc);
> + return rc;
> + }
> + for (i = 0; i < bd->nq_nr_rings; i++) {
> + int map_idx = bnge_cp_num_to_irq_num(bn, i);
> + struct bnge_irq *irq = &bd->irq_tbl[map_idx];
> +
> + rc = request_irq(irq->vector, irq->handler, 0, irq->name,
> + bn->bnapi[i]);
> + if (rc)
> + break;
> +
> + netif_napi_set_irq_locked(&bn->bnapi[i]->napi, irq->vector);
Are you netdev-locked here? I don't see the driver either requesting ops
lock or implementing any API which enables netdev-lock.
--
pw-bot: cr
Powered by blists - more mailing lists