Subject: Re: [PATCH net-next v2 10/10] bnxt_en: Add TPH support in BNXT driver

From: Simon Horman <[email-masked]>
Date: Fri, 17 Jan 2025 15:41:49 +0000

On Thu, Jan 16, 2025 at 11:23:43AM -0800, Michael Chan wrote:
> From: Manoj Panicker <[email-masked]>
> 
> Add TPH support to the Broadcom BNXT device driver. This allows the
> driver to utilize TPH functions for retrieving and configuring Steering
> Tags when changing interrupt affinity. With compatible NIC firmware,
> network traffic will be tagged correctly with Steering Tags, resulting
> in significant memory bandwidth savings and other advantages as
> demonstrated by real network benchmarks on TPH-capable platforms.
> 
> Co-developed-by: Somnath Kotur <[email-masked]>
> Signed-off-by: Somnath Kotur <[email-masked]>
> Co-developed-by: Wei Huang <[email-masked]>
> Signed-off-by: Wei Huang <[email-masked]>
> Signed-off-by: Manoj Panicker <[email-masked]>
> Reviewed-by: Ajit Khaparde <[email-masked]>
> Reviewed-by: Andy Gospodarek <[email-masked]>
> Signed-off-by: Michael Chan <[email-masked]>
> ---
> Cc: Bjorn Helgaas <[email-masked]>
> 
> Previous driver series fixing rtnl_lock and empty release function:
> 
> https://lore.kernel.org/netdev/[email-masked]/
> 
> v5 of the PCI series using netdev_rx_queue_restart():
> 
> https://lore.kernel.org/netdev/[email-masked]/
> 
> v1 of the PCI series using open/close:
> 
> https://lore.kernel.org/netdev/[email-masked]/
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 105 ++++++++++++++++++++++
>  drivers/net/ethernet/broadcom/bnxt/bnxt.h |   7 ++
>  2 files changed, 112 insertions(+)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 0a10a4cffcc8..8c24642b8812 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -55,6 +55,8 @@
>  #include <net/page_pool/helpers.h>
>  #include <linux/align.h>
>  #include <net/netdev_queues.h>
> +#include <net/netdev_rx_queue.h>
> +#include <linux/pci-tph.h>
>  
>  #include "bnxt_hsi.h"
>  #include "bnxt.h"

Hi Manoj, Michael, all,

Modpost complains that:

WARNING: modpost: module bnxt_en uses symbol netdev_rx_queue_restart from namespace NETDEV_INTERNAL, but does not import it.

And looking into this I see:

* netdev: define NETDEV_INTERNAL
  https://git.kernel.org/netdev/net-next/c/0b7bdc7fab57

Which adds the following text to Documentation/networking/netdevices.rst

  NETDEV_INTERNAL symbol namespace
  ================================

  Symbols exported as NETDEV_INTERNAL can only be used in networking
  core and drivers which exclusively flow via the main networking list and trees.
  Note that the inverse is not true, most symbols outside of NETDEV_INTERNAL
  are not expected to be used by random code outside netdev either.
  Symbols may lack the designation because they predate the namespaces,
  or simply due to an oversight.

Which I think is satisfied here. So I think this problem can be
addressed by adding the following about here (completely untested!).

MODULE_IMPORT_NS("NETDEV_INTERNAL");

> @@ -11330,6 +11332,83 @@ static int bnxt_tx_queue_start(struct bnxt *bp, int idx)
>  	return 0;
>  }
>  
> +static void bnxt_irq_affinity_notify(struct irq_affinity_notify *notify,
> +				     const cpumask_t *mask)
> +{
> +	struct bnxt_irq *irq;
> +	u16 tag;
> +	int err;
> +
> +	irq = container_of(notify, struct bnxt_irq, affinity_notify);
> +
> +	if (!irq->bp->tph_mode)
> +		return;
> +
> +	cpumask_copy(irq->cpu_mask, mask);
> +
> +	if (irq->ring_nr >= irq->bp->rx_nr_rings)
> +		return;
> +
> +	if (pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM,
> +				cpumask_first(irq->cpu_mask), &tag))
> +		return;
> +
> +	if (pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, tag))
> +		return;
> +
> +	rtnl_lock();
> +	if (netif_running(irq->bp->dev)) {
> +		err = netdev_rx_queue_restart(irq->bp->dev, irq->ring_nr);
> +		if (err)
> +			netdev_err(irq->bp->dev,
> +				   "RX queue restart failed: err=%d\n", err);
> +	}
> +	rtnl_unlock();
> +}

...