DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tomasz Duszynski <tduszynski@marvell.com>
To: <dev@dpdk.org>, Jakub Palider <jpalider@marvell.com>,
	Tomasz Duszynski <tduszynski@marvell.com>,
	Anatoly Burakov <anatoly.burakov@intel.com>
Cc: <jerinj@marvell.com>, <thomas@monjalon.net>
Subject: [PATCH] raw/cnxk_bphy: support multi-process mode
Date: Tue, 3 Oct 2023 22:41:09 +0200	[thread overview]
Message-ID: <20231003204110.3344703-1-tduszynski@marvell.com> (raw)

Add support for sharing BPHY PMD across multiple running processes.
In scenarios where resources need to be shared across processes
user-space need to ensure serialization.

Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
Reviewed-by: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
Tested-by: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
---
 doc/guides/rawdevs/cnxk_bphy.rst  |  8 ++++++++
 drivers/raw/cnxk_bphy/cnxk_bphy.c | 16 ++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/doc/guides/rawdevs/cnxk_bphy.rst b/doc/guides/rawdevs/cnxk_bphy.rst
index 2490912534..b544b543a3 100644
--- a/doc/guides/rawdevs/cnxk_bphy.rst
+++ b/doc/guides/rawdevs/cnxk_bphy.rst
@@ -19,6 +19,14 @@ The BPHY CGX/RPM implements following features in the rawdev API:
 - Access to BPHY CGX/RPM via a set of predefined messages
 - Access to BPHY memory
 - Custom interrupt handlers
+- Multiprocess aware
+
+Limitations
+-----------
+
+In multiprocess mode user-space application must ensure no resources
+sharing takes place. Otherwise, user-space application should ensure
+synchronization.
 
 Device Setup
 ------------
diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy.c b/drivers/raw/cnxk_bphy/cnxk_bphy.c
index d42cca649c..15dbc4c1a6 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy.c
@@ -359,10 +359,12 @@ bphy_rawdev_probe(struct rte_pci_driver *pci_drv,
 	bphy_dev->mem.res2 = pci_dev->mem_resource[2];
 	bphy_dev->bphy.pci_dev = pci_dev;
 
-	ret = roc_bphy_dev_init(&bphy_dev->bphy);
-	if (ret) {
-		rte_rawdev_pmd_release(bphy_rawdev);
-		return ret;
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		ret = roc_bphy_dev_init(&bphy_dev->bphy);
+		if (ret) {
+			rte_rawdev_pmd_release(bphy_rawdev);
+			return ret;
+		}
 	}
 
 	return 0;
@@ -390,8 +392,10 @@ bphy_rawdev_remove(struct rte_pci_device *pci_dev)
 		return -EINVAL;
 	}
 
-	bphy_dev = (struct bphy_device *)rawdev->dev_private;
-	roc_bphy_dev_fini(&bphy_dev->bphy);
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		bphy_dev = (struct bphy_device *)rawdev->dev_private;
+		roc_bphy_dev_fini(&bphy_dev->bphy);
+	}
 
 	return rte_rawdev_pmd_release(rawdev);
 }
-- 
2.34.1


             reply	other threads:[~2023-10-03 20:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03 20:41 Tomasz Duszynski [this message]
2023-10-04 17:47 ` Jerin Jacob

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=20231003204110.3344703-1-tduszynski@marvell.com \
    --to=tduszynski@marvell.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=jpalider@marvell.com \
    --cc=thomas@monjalon.net \
    /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).