netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Louis Peens <louis.peens@corigine.com>
Cc: David Miller <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	eperezma@redhat.com, Kyle Xu <zhenbing.xu@corigine.com>,
	netdev@vger.kernel.org, virtualization@lists.linux.dev,
	oss-drivers@corigine.com
Subject: Re: [RFC net-next 3/3] drivers/vdpa: add NFP devices vDPA driver
Date: Wed, 7 Aug 2024 14:48:31 +0100	[thread overview]
Message-ID: <20240807134831.GB2991391@kernel.org> (raw)
In-Reply-To: <20240802095931.24376-4-louis.peens@corigine.com>

On Fri, Aug 02, 2024 at 11:59:31AM +0200, Louis Peens wrote:
> From: Kyle Xu <zhenbing.xu@corigine.com>
> 
> Add a new kernel module ‘nfp_vdpa’ for the NFP vDPA networking driver.
> 
> The vDPA driver initializes the necessary resources on the VF and the
> data path will be offloaded. It also implements the ‘vdpa_config_ops’
> and the corresponding callback interfaces according to the requirement
> of kernel vDPA framework.
> 
> Signed-off-by: Kyle Xu <zhenbing.xu@corigine.com>
> Signed-off-by: Louis Peens <louis.peens@corigine.com>

...

> diff --git a/drivers/vdpa/netronome/nfp_vdpa_main.c b/drivers/vdpa/netronome/nfp_vdpa_main.c

...

> +static int nfp_vdpa_map_resources(struct nfp_vdpa_net *ndev,
> +				  struct pci_dev *pdev,
> +				  const struct nfp_dev_info *dev_info)
> +{
> +	unsigned int bar_off, bar_sz, tx_bar_sz, rx_bar_sz;
> +	unsigned int max_tx_rings, max_rx_rings, txq, rxq;
> +	u64 tx_bar_off, rx_bar_off;
> +	resource_size_t map_addr;
> +	void __iomem  *tx_bar;
> +	void __iomem  *rx_bar;

Hi Kyle and Louis,

A minor nit from my side: rx_bar is set but otherwise unused in this function.

> +	int err;
> +
> +	/* Map CTRL BAR */
> +	ndev->ctrl_bar = ioremap(pci_resource_start(pdev, NFP_NET_CTRL_BAR),
> +				 NFP_NET_CFG_BAR_SZ);
> +	if (!ndev->ctrl_bar)
> +		return -EIO;
> +
> +	/* Find out how many rings are supported */
> +	max_tx_rings = readl(ndev->ctrl_bar + NFP_NET_CFG_MAX_TXRINGS);
> +	max_rx_rings = readl(ndev->ctrl_bar + NFP_NET_CFG_MAX_RXRINGS);
> +	/* Currently, only one ring is supported */
> +	if (max_tx_rings != NFP_VDPA_QUEUE_RING_MAX || max_rx_rings != NFP_VDPA_QUEUE_RING_MAX) {
> +		err = -EINVAL;
> +		goto ctrl_bar_unmap;
> +	}
> +
> +	/* Map Q0_BAR as a single overlapping BAR mapping */
> +	tx_bar_sz = NFP_QCP_QUEUE_ADDR_SZ * max_tx_rings * NFP_VDPA_QUEUE_SPACE_STRIDE;
> +	rx_bar_sz = NFP_QCP_QUEUE_ADDR_SZ * max_rx_rings * NFP_VDPA_QUEUE_SPACE_STRIDE;
> +
> +	txq = readl(ndev->ctrl_bar + NFP_NET_CFG_START_TXQ);
> +	tx_bar_off = nfp_qcp_queue_offset(dev_info, txq);
> +	rxq = readl(ndev->ctrl_bar + NFP_NET_CFG_START_RXQ);
> +	rx_bar_off = nfp_qcp_queue_offset(dev_info, rxq);
> +
> +	bar_off = min(tx_bar_off, rx_bar_off);
> +	bar_sz = max(tx_bar_off + tx_bar_sz, rx_bar_off + rx_bar_sz);
> +	bar_sz -= bar_off;
> +
> +	map_addr = pci_resource_start(pdev, NFP_NET_Q0_BAR) + bar_off;
> +	ndev->q_bar = ioremap(map_addr, bar_sz);
> +	if (!ndev->q_bar) {
> +		err = -EIO;
> +		goto ctrl_bar_unmap;
> +	}
> +
> +	tx_bar = ndev->q_bar + (tx_bar_off - bar_off);
> +	rx_bar = ndev->q_bar + (rx_bar_off - bar_off);
> +
> +	/* TX queues */
> +	ndev->vring[txq].kick_addr = ndev->ctrl_bar + NFP_VDPA_NOTIFY_AREA_BASE
> +				     + txq * NFP_VDPA_QUEUE_NOTIFY_OFFSET;
> +	/* RX queues */
> +	ndev->vring[rxq].kick_addr = ndev->ctrl_bar + NFP_VDPA_NOTIFY_AREA_BASE
> +				     + rxq * NFP_VDPA_QUEUE_NOTIFY_OFFSET;
> +	/* Stash the re-configuration queue away. First odd queue in TX Bar */
> +	ndev->qcp_cfg = tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
> +
> +	return 0;
> +
> +ctrl_bar_unmap:
> +	iounmap(ndev->ctrl_bar);
> +	return err;
> +}

...

  parent reply	other threads:[~2024-08-07 13:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-02  9:59 [RFC net-next 0/3] add vDPA driver for nfp devices Louis Peens
2024-08-02  9:59 ` [RFC net-next 1/3] nfp: add new devlink "enable_vnet" generic device param Louis Peens
2024-08-02  9:59 ` [RFC net-next 2/3] nfp: initialize NFP VF device according to enable_vnet configuration Louis Peens
2024-08-02  9:59 ` [RFC net-next 3/3] drivers/vdpa: add NFP devices vDPA driver Louis Peens
2024-08-06  4:35   ` Jason Wang
2024-08-06  6:20     ` Louis Peens
2024-08-29 12:09     ` 回复: " Kyle Xu
2024-08-07 13:48   ` Simon Horman [this message]
2024-08-07 14:55   ` Eugenio Perez Martin

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=20240807134831.GB2991391@kernel.org \
    --to=horms@kernel.org \
    --cc=davem@davemloft.net \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kuba@kernel.org \
    --cc=louis.peens@corigine.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@corigine.com \
    --cc=virtualization@lists.linux.dev \
    --cc=zhenbing.xu@corigine.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).