All of lore.kernel.org
 help / color / mirror / Atom feed
From: Veerasenareddy Burru <vburru@marvell.com>
To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<lironh@marvell.com>, <aayarekar@marvell.com>,
	<sedara@marvell.com>, <sburla@marvell.com>
Cc: <linux-doc@vger.kernel.org>,
	Veerasenareddy Burru <vburru@marvell.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH net-next 7/9] octeon_ep: add SRIOV VF creation
Date: Sun, 6 Nov 2022 23:25:21 -0800	[thread overview]
Message-ID: <20221107072524.9485-8-vburru@marvell.com> (raw)
In-Reply-To: <20221107072524.9485-1-vburru@marvell.com>

Add support to create SRIOV VFs.

Signed-off-by: Veerasenareddy Burru <vburru@marvell.com>
Signed-off-by: Sathesh Edara <sedara@marvell.com>
---
 .../ethernet/marvell/octeon_ep/octep_main.c   | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
index ad5553854467..fa0f3d597eb1 100644
--- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
+++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
@@ -1236,11 +1236,61 @@ static void octep_remove(struct pci_dev *pdev)
 	pci_disable_device(pdev);
 }
 
+static int octep_sriov_disable(struct octep_device *oct)
+{
+	struct pci_dev *pdev = oct->pdev;
+
+	if (pci_vfs_assigned(oct->pdev)) {
+		dev_warn(&pdev->dev, "Can't disable SRIOV while VFs are assigned\n");
+		return -EPERM;
+	}
+
+	pci_disable_sriov(pdev);
+	CFG_GET_ACTIVE_VFS(oct->conf) = 0;
+
+	return 0;
+}
+
+static int octep_sriov_enable(struct octep_device *oct, int num_vfs)
+{
+	struct pci_dev *pdev = oct->pdev;
+	int err;
+
+	err = pci_enable_sriov(pdev, num_vfs);
+	if (err) {
+		dev_warn(&pdev->dev, "Failed to enable SRIOV err=%d\n", err);
+		return err;
+	}
+	CFG_GET_ACTIVE_VFS(oct->conf) = num_vfs;
+
+	return num_vfs;
+}
+
+static int octep_sriov_configure(struct pci_dev *pdev, int num_vfs)
+{
+	struct octep_device *oct = pci_get_drvdata(pdev);
+	int max_nvfs;
+
+	if (num_vfs == 0)
+		return octep_sriov_disable(oct);
+
+	max_nvfs = CFG_GET_MAX_VFS(oct->conf);
+
+	if (num_vfs > max_nvfs) {
+		dev_err(&pdev->dev, "Invalid VF count Max supported VFs = %d\n",
+			max_nvfs);
+		return -EINVAL;
+	}
+
+	return octep_sriov_enable(oct, num_vfs);
+}
+
 static struct pci_driver octep_driver = {
 	.name = OCTEP_DRV_NAME,
 	.id_table = octep_pci_id_tbl,
 	.probe = octep_probe,
 	.remove = octep_remove,
+	.sriov_configure = octep_sriov_configure,
 };
 
 /**
-- 
2.36.0


  parent reply	other threads:[~2022-11-07  7:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07  7:25 [PATCH net-next 0/9] octeon_ep: Update PF mailbox for VF Veerasenareddy Burru
2022-11-07  7:25 ` [PATCH net-next 1/9] octeon_ep: wait for firmware ready Veerasenareddy Burru
2022-11-07  8:18   ` Leon Romanovsky
2022-11-14 20:47     ` [EXT] " Veerasenareddy Burru
2022-11-15  9:04       ` Leon Romanovsky
2022-11-07  7:25 ` [PATCH net-next 2/9] octeon_ep: poll for control messages Veerasenareddy Burru
2022-11-07  7:25 ` [PATCH net-next 3/9] octeon_ep: control mailbox for multiple PFs Veerasenareddy Burru
2022-11-07  7:25 ` [PATCH net-next 4/9] octeon_ep: enhance control mailbox for VF support Veerasenareddy Burru
2022-11-07  7:25 ` [PATCH net-next 5/9] octeon_ep: support asynchronous notifications Veerasenareddy Burru
2022-11-07  7:25 ` [PATCH net-next 6/9] octeon_ep: control mbox support for VF stats and link info Veerasenareddy Burru
2022-11-07  7:25 ` Veerasenareddy Burru [this message]
2022-11-07  8:13   ` [PATCH net-next 7/9] octeon_ep: add SRIOV VF creation Leon Romanovsky
2022-11-07  7:25 ` [PATCH net-next 8/9] octeon_ep: add PF-VF mailbox communication Veerasenareddy Burru
2022-11-07  7:25 ` [PATCH net-next 9/9] octeon_ep: add heartbeat monitor Veerasenareddy Burru

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=20221107072524.9485-8-vburru@marvell.com \
    --to=vburru@marvell.com \
    --cc=aayarekar@marvell.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lironh@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sburla@marvell.com \
    --cc=sedara@marvell.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 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.