netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Michael Chan <michael.chan@broadcom.com>
Cc: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>,
	davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, pavan.chebbi@broadcom.com,
	andrew.gospodarek@broadcom.com, horms@kernel.org,
	helgaas@kernel.org, przemyslaw.kitszel@intel.com,
	Hongguang Gao <hongguang.gao@broadcom.com>,
	Somnath Kotur <somnath.kotur@broadcom.com>
Subject: Re: [PATCH net-next v3 9/9] bnxt_en: Support dynamic MSIX
Date: Tue, 27 Aug 2024 14:16:12 -0700	[thread overview]
Message-ID: <20240827141612.2edc92eb@kernel.org> (raw)
In-Reply-To: <Zs2A8wvFUoZfjPzQ@mev-dev.igk.intel.com>

On Tue, 27 Aug 2024 09:32:03 +0200 Michal Swiatkowski wrote:
> > +static int bnxt_add_msix(struct bnxt *bp, int total)
> > +{
> > +	int i;
> > +
> > +	if (bp->total_irqs >= total)
> > +		return total;
> > +
> > +	for (i = bp->total_irqs; i < total; i++) {
> > +		struct msi_map map;
> > +
> > +		map = pci_msix_alloc_irq_at(bp->pdev, i, NULL);
> > +		if (map.index < 0)
> > +			break;
> > +		bp->irq_tbl[i].vector = map.virq;
> > +		bp->total_irqs++;
> > +	}
> > +	return bp->total_irqs;
> > +}
> > +
> > +static int bnxt_trim_msix(struct bnxt *bp, int total)
> > +{
> > +	int i;
> > +
> > +	if (bp->total_irqs <= total)
> > +		return total;
> > +
> > +	for (i = bp->total_irqs; i > total; i--) {
> > +		struct msi_map map;
> > +
> > +		map.index = i - 1;
> > +		map.virq = bp->irq_tbl[i - 1].vector;
> > +		pci_msix_free_irq(bp->pdev, map);
> > +		bp->total_irqs--;
> > +	}
> > +	return bp->total_irqs;
> > +}  
> 
> Patch looks fine, treat it only as suggestion:
> 
> You can save some lines of code by merging this two function.
> 
> static int bnxt_change_msix(struct bnxt *bp, int total)
> {
> 	int i;
> 
> 	/* add MSI-Xs if needed */
> 	for (i = bp->total_irqs; i < total; i++) {
> 		...
> 	}
> 
> 	/* remove MSI-Xs if needed */
> 	for (i = bp->total_irqs; i > total; i--) {
> 		...
> 	}
> 
> 	return bp->total_irqs;
> }

> > +	} else if (irq_change && !rc) {
> > +		int total;
> > +
> > +		if (irqs_required > bp->total_irqs)
> > +			total = bnxt_add_msix(bp, irqs_required);
> > +		else
> > +			total = bnxt_trim_msix(bp, irqs_required);
> > +
> > +		if (total != irqs_required)
> > +			rc = -ENOSPC;  
> 
> and here
> 
> if (bnxt_change_msix(bp, irqs_required) != irqs_required)
> 	rc = -ENOSPC;

👍️ that does look cleaner

      reply	other threads:[~2024-08-27 21:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23 19:56 [PATCH net-next v3 0/9] bnxt_en: Update for net-next Michael Chan
2024-08-23 19:56 ` [PATCH net-next v3 1/9] bnxt_en: add support for storing crash dump into host memory Michael Chan
2024-08-23 19:56 ` [PATCH net-next v3 2/9] bnxt_en: add support for retrieving crash dump using ethtool Michael Chan
2024-08-23 19:56 ` [PATCH net-next v3 3/9] bnxt_en: Support QOS and TPID settings for the SRIOV VLAN Michael Chan
2024-08-23 19:56 ` [PATCH net-next v3 4/9] bnxt_en: Deprecate support for legacy INTX mode Michael Chan
2024-08-23 19:56 ` [PATCH net-next v3 5/9] bnxt_en: Remove BNXT_FLAG_USING_MSIX flag Michael Chan
2024-08-23 19:56 ` [PATCH net-next v3 6/9] bnxt_en: Remove register mapping to support INTX Michael Chan
2024-08-23 19:56 ` [PATCH net-next v3 7/9] bnxt_en: Replace deprecated PCI MSIX APIs Michael Chan
2024-08-23 19:56 ` [PATCH net-next v3 8/9] bnxt_en: Allocate the max bp->irq_tbl size for dynamic msix allocation Michael Chan
2024-08-23 19:56 ` [PATCH net-next v3 9/9] bnxt_en: Support dynamic MSIX Michael Chan
2024-08-27  7:32   ` Michal Swiatkowski
2024-08-27 21:16     ` Jakub Kicinski [this message]

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=20240827141612.2edc92eb@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=helgaas@kernel.org \
    --cc=hongguang.gao@broadcom.com \
    --cc=horms@kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=somnath.kotur@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;
as well as URLs for NNTP newsgroup(s).