All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Jiawen Wu <jiawenwu@trustnetic.com>
Cc: netdev@vger.kernel.org, mengyuanlou@net-swift.com
Subject: Re: [PATCH net-next 01/10] net: libwx: Add irq flow functions
Date: Mon, 23 Jan 2023 16:13:18 +0100	[thread overview]
Message-ID: <Y86kDphvyHj21IxK@lunn.ch> (raw)
In-Reply-To: <20230118065504.3075474-2-jiawenwu@trustnetic.com>

> +/**
> + * wx_acquire_msix_vectors - acquire MSI-X vectors
> + * @wx: board private structure
> + *
> + * Attempts to acquire a suitable range of MSI-X vector interrupts. Will
> + * return a negative error code if unable to acquire MSI-X vectors for any
> + * reason.
> + */
> +static int wx_acquire_msix_vectors(struct wx *wx)
> +{
> +	struct irq_affinity affd = {0, };
> +	int nvecs, i;
> +
> +	nvecs = min_t(int, num_online_cpus(), wx->mac.max_msix_vectors);
> +
> +	wx->msix_entries = kcalloc(nvecs,
> +				   sizeof(struct msix_entry),
> +				   GFP_KERNEL);
> +	if (!wx->msix_entries)
> +		return -ENOMEM;

> + * wx_set_interrupt_capability - set MSI-X or MSI if supported
> + * @wx: board private structure to initialize
> + *
> + * Attempt to configure the interrupts using the best available
> + * capabilities of the hardware and the kernel.
> + **/
> +static void wx_set_interrupt_capability(struct wx *wx)
> +{
> +	int nvecs;
> +
> +	/* We will try to get MSI-X interrupts first */
> +	if (!wx_acquire_msix_vectors(wx))
> +		return;

This could return -ENOMEM. You should return that up the call stack.

I would suggest you make this check more specific. Success, or real
errors, return here, with 0 or -errcode. If it indicates MSI-X are not
available then do the fallback.

> +
> +	wx->num_rx_queues = 1;
> +	wx->num_tx_queues = 1;
> +	wx->num_q_vectors = 1;
> +
> +	/* minmum one for queue, one for misc*/
> +	nvecs = 1;
> +	nvecs = pci_alloc_irq_vectors(wx->pdev, nvecs,
> +				      nvecs, PCI_IRQ_MSI);
> +	if (nvecs < 0)
> +		wx_err(wx, "Failed to allocate MSI interrupts. Error: %d\n", nvecs);

If you don't have MSI-X or MSI interrupt, is the device usable? I
would expect some fatal error handling here.

> +/**
> + * wx_cache_ring_rss - Descriptor ring to register mapping for RSS
> + * @wx: board private structure to initialize
> + *
> + * Cache the descriptor ring offsets for RSS, ATR, FCoE, and SR-IOV.
> + *
> + **/
> +static bool wx_cache_ring_rss(struct wx *wx)
> +{
> +	u16 i;
> +
> +	for (i = 0; i < wx->num_rx_queues; i++)
> +		wx->rx_ring[i]->reg_idx = i;
> +
> +	for (i = 0; i < wx->num_tx_queues; i++)
> +		wx->tx_ring[i]->reg_idx = i;
> +
> +	return true;

What is the point of returning true. This cannot fail, so make it
void.

	Andrew

  parent reply	other threads:[~2023-01-23 15:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18  6:54 [PATCH net-next 00/10] Wangxun interrupt and RxTx support Jiawen Wu
2023-01-18  6:54 ` [PATCH net-next 01/10] net: libwx: Add irq flow functions Jiawen Wu
2023-01-18  9:27   ` kernel test robot
2023-01-19 18:14   ` kernel test robot
2023-01-23 15:13   ` Andrew Lunn [this message]
2023-01-18  6:54 ` [PATCH net-next 02/10] net: ngbe: Add irqs request flow Jiawen Wu
2023-01-18  6:54 ` [PATCH net-next 03/10] net: txgbe: Add interrupt support Jiawen Wu
2023-01-18  6:54 ` [PATCH net-next 04/10] net: libwx: Configure Rx and Tx unit on hardware Jiawen Wu
2023-01-18  6:54 ` [PATCH net-next 05/10] net: libwx: Allocate Rx and Tx resources Jiawen Wu
2023-01-22  3:05   ` kernel test robot
2023-01-23 15:27   ` Andrew Lunn
2023-01-18  6:55 ` [PATCH net-next 06/10] net: txgbe: Setup Rx and Tx ring Jiawen Wu
2023-01-18  6:55 ` [PATCH net-next 07/10] net: libwx: Support to receive packets in NAPI Jiawen Wu
2023-01-18  6:55 ` [PATCH net-next 08/10] net: libwx: Add transmit path to process packets Jiawen Wu
2023-01-18  6:55 ` [PATCH net-next 09/10] net: txgbe: Support Rx and Tx process path Jiawen Wu
2023-01-18  6:55 ` [PATCH net-next 10/10] net: ngbe: " Jiawen Wu
  -- strict thread matches above, loose matches on Subject: below --
2023-01-20 12:57 [PATCH net-next 01/10] net: libwx: Add irq flow functions 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=Y86kDphvyHj21IxK@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=jiawenwu@trustnetic.com \
    --cc=mengyuanlou@net-swift.com \
    --cc=netdev@vger.kernel.org \
    /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.