mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Vikas Gupta <vikas.gupta@broadcom.com>,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
	vsrama-krishna.nemani@broadcom.com,
	Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>,
	Rajashekar Hudumula <rajashekar.hudumula@broadcom.com>
Subject: Re: [net-next, 08/10] bng_en: Add irq allocation support
Date: Thu, 19 Jun 2025 14:52:32 +0100	[thread overview]
Message-ID: <b66ab3f7-1445-48e2-b98b-7c148a2d3458@linux.dev> (raw)
In-Reply-To: <20250618144743.843815-9-vikas.gupta@broadcom.com>

On 18/06/2025 15:47, Vikas Gupta wrote:
> Add irq allocation functions. This will help
> to allocate IRQs to both netdev and RoCE aux devices.
> 
> Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
> Reviewed-by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
> Reviewed-by: Rajashekar Hudumula <rajashekar.hudumula@broadcom.com>
> ---
>   drivers/net/ethernet/broadcom/bnge/bnge.h     |  3 +
>   .../net/ethernet/broadcom/bnge/bnge_resc.c    | 69 +++++++++++++++++++
>   .../net/ethernet/broadcom/bnge/bnge_resc.h    | 13 ++++
>   3 files changed, 85 insertions(+)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge.h b/drivers/net/ethernet/broadcom/bnge/bnge.h
> index b58d8fc6f258..3c161b1a9b62 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge.h
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge.h
> @@ -172,6 +172,9 @@ struct bnge_dev {
>   #define BNGE_SUPPORTS_TPA(bd)	((bd)->max_tpa_v2)
>   
>   	u8                      num_tc;
> +
> +	struct bnge_irq		*irq_tbl;
> +	u16			irqs_acquired;
>   };
>   
>   static inline bool bnge_is_roce_en(struct bnge_dev *bd)
> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
> index 68e094474822..84f91e05a2b0 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
> @@ -326,3 +326,72 @@ int bnge_reserve_rings(struct bnge_dev *bd)
>   
>   	return rc;
>   }
> +
> +int bnge_alloc_irqs(struct bnge_dev *bd)
> +{
> +	u16 aux_msix, tx_cp, num_entries;
> +	u16 irqs_demand, max, min = 1;
> +	int i, rc = 0;

This assignment is not needed. Error paths re-assign proper error code
while normal flow re-assigns rc to the return value of
bnge_adjust_rings()

> +
> +	irqs_demand = bnge_nqs_demand(bd);
> +	max = bnge_get_max_func_irqs(bd);
> +	if (irqs_demand > max)
> +		irqs_demand = max;
> +
> +	if (!(bd->flags & BNGE_EN_SHARED_CHNL))
> +		min = 2;
> +
> +	irqs_demand = pci_alloc_irq_vectors(bd->pdev, min, irqs_demand,
> +					    PCI_IRQ_MSIX);
> +	aux_msix = bnge_aux_get_msix(bd);
> +	if (irqs_demand < 0 || irqs_demand < aux_msix) {
> +		rc = -ENODEV;
> +		goto err_free_irqs;
> +	}
> +
> +	num_entries = irqs_demand;
> +	if (pci_msix_can_alloc_dyn(bd->pdev))
> +		num_entries = max;
> +	bd->irq_tbl = kcalloc(num_entries, sizeof(*bd->irq_tbl), GFP_KERNEL);
> +	if (!bd->irq_tbl) {
> +		rc = -ENOMEM;
> +		goto err_free_irqs;
> +	}
> +
> +	for (i = 0; i < irqs_demand; i++)
> +		bd->irq_tbl[i].vector = pci_irq_vector(bd->pdev, i);
> +
> +	bd->irqs_acquired = irqs_demand;
> +	/* Reduce rings based upon num of vectors allocated.
> +	 * We dont need to consider NQs as they have been calculated
> +	 * and must be more than irqs_demand.
> +	 */
> +	rc = bnge_adjust_rings(bd, &bd->rx_nr_rings,
> +			       &bd->tx_nr_rings,
> +			       irqs_demand - aux_msix, min == 1);
> +	if (rc)
> +		goto err_free_irqs;
> +
> +	tx_cp = bnge_num_tx_to_cp(bd, bd->tx_nr_rings);
> +	bd->nq_nr_rings = (min == 1) ?
> +		max_t(u16, tx_cp, bd->rx_nr_rings) :
> +		tx_cp + bd->rx_nr_rings;
> +
> +	/* Readjust tx_nr_rings_per_tc */
> +	if (!bd->num_tc)
> +		bd->tx_nr_rings_per_tc = bd->tx_nr_rings;
> +
> +	return 0;
> +
> +err_free_irqs:
> +	dev_err(bd->dev, "Failed to allocate IRQs err = %d\n", rc);
> +	bnge_free_irqs(bd);
> +	return rc;
> +}

[...]

  reply	other threads:[~2025-06-19 13:52 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18 14:47 [net-next, 00/10] Introducing Broadcom BNGE Ethernet Driver Vikas Gupta
2025-06-18 14:47 ` [net-next, 01/10] bng_en: Add PCI interface Vikas Gupta
2025-06-19 12:25   ` Vadim Fedorenko
2025-06-18 14:47 ` [net-next, 02/10] bng_en: Add devlink interface Vikas Gupta
2025-06-19 12:34   ` Vadim Fedorenko
2025-06-18 14:47 ` [net-next, 03/10] bng_en: Add firmware communication mechanism Vikas Gupta
2025-06-19  9:46   ` kernel test robot
2025-06-19 12:43   ` Vadim Fedorenko
2025-06-24 10:23     ` Vikas Gupta
2025-06-18 14:47 ` [net-next, 04/10] bng_en: Add initial interaction with firmware Vikas Gupta
2025-06-19 12:53   ` Vadim Fedorenko
2025-06-24 10:26     ` Vikas Gupta
2025-06-24 12:11       ` Vadim Fedorenko
2025-06-25  9:29         ` Vikas Gupta
2025-06-25 10:24           ` Vadim Fedorenko
2025-06-18 14:47 ` [net-next, 05/10] bng_en: Add ring memory allocation support Vikas Gupta
2025-06-18 14:47 ` [net-next, 06/10] bng_en: Add backing store support Vikas Gupta
2025-06-19 13:02   ` Vadim Fedorenko
2025-06-24 10:29     ` Vikas Gupta
2025-06-24 12:12       ` Vadim Fedorenko
2025-06-18 14:47 ` [net-next, 07/10] bng_en: Add resource management support Vikas Gupta
2025-06-19 13:39   ` Vadim Fedorenko
2025-06-24 10:31     ` Vikas Gupta
2025-06-18 14:47 ` [net-next, 08/10] bng_en: Add irq allocation support Vikas Gupta
2025-06-19 13:52   ` Vadim Fedorenko [this message]
2025-06-19 21:25   ` kernel test robot
2025-06-22  5:21   ` kernel test robot
2025-06-23  6:11   ` kernel test robot
2025-06-25  9:17   ` kernel test robot
2025-06-18 14:47 ` [net-next, 09/10] bng_en: Initialize default configuration Vikas Gupta
2025-06-18 20:16   ` kernel test robot
2025-06-19 13:57   ` Vadim Fedorenko
2025-06-20  9:08   ` kernel test robot
2025-06-22 12:39   ` kernel test robot
2025-06-26  8:47   ` kernel test robot
2025-06-18 14:47 ` [net-next, 10/10] bng_en: Add a network device Vikas Gupta
2025-06-24  0:42   ` kernel test robot

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=b66ab3f7-1445-48e2-b98b-7c148a2d3458@linux.dev \
    --to=vadim.fedorenko@linux.dev \
    --cc=andrew+netdev@lunn.ch \
    --cc=bhargava.marreddy@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=rajashekar.hudumula@broadcom.com \
    --cc=vikas.gupta@broadcom.com \
    --cc=vsrama-krishna.nemani@broadcom.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®