* [PATCH 0/9] drivers/raw: introduce cnxk rvu lf device driver
@ 2024-09-07 19:33 Akhil Goyal
2024-09-07 19:33 ` [PATCH 1/9] rawdev: add API to get device from index Akhil Goyal
` (8 more replies)
0 siblings, 9 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-09-07 19:33 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
CNXK product families can have a use case to allow PF and VF
applications to communicate using mailboxes and also get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
The RVU LF device implements following features in the rawdev API:
- Register mailbox callbacks for the other side to process mailboxes.
- Register interrupt handler callbacks.
- Process mailbox.
- Set range of message IDs allowed for communication.
Akhil Goyal (9):
rawdev: add API to get device from index
drivers/raw: introduce cnxk rvu lf device driver
raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc
raw/cnxk_rvu_lf: add PMD API to get BAR addresses
raw/cnxk_rvu_lf: register/unregister interrupt handler
raw/cnxk_rvu_lf: register/unregister msg handler
raw/cnxk_rvu_lf: set message ID range
raw/cnxk_rvu_lf: process mailbox message
raw/cnxk_rvu_lf: add selftest
MAINTAINERS | 6 +
doc/guides/rawdevs/cnxk_rvu_lf.rst | 100 ++++++
doc/guides/rawdevs/index.rst | 1 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 2 +
drivers/common/cnxk/roc_dev.c | 117 ++++++-
drivers/common/cnxk/roc_dev_priv.h | 7 +
drivers/common/cnxk/roc_idev.c | 46 +++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_mbox.h | 2 +
drivers/common/cnxk/roc_npa.c | 6 +
drivers/common/cnxk/roc_npa.h | 3 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 202 ++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 44 +++
drivers/common/cnxk/roc_rvu_lf_priv.h | 37 +++
drivers/common/cnxk/roc_sso.c | 6 +
drivers/common/cnxk/roc_sso.h | 3 +
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 15 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 380 +++++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 10 +
drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 214 +++++++++++++
drivers/raw/meson.build | 1 +
lib/rawdev/rte_rawdev_pmd.h | 24 ++
27 files changed, 1233 insertions(+), 6 deletions(-)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
create mode 100644 drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH 1/9] rawdev: add API to get device from index
2024-09-07 19:33 [PATCH 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
@ 2024-09-07 19:33 ` Akhil Goyal
2024-09-23 15:23 ` Jerin Jacob
2024-10-08 7:40 ` [PATCH v2] " Akhil Goyal
2024-09-07 19:33 ` [PATCH 2/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (7 subsequent siblings)
8 siblings, 2 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-09-07 19:33 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added an internal API for PMDs to get raw device pointer
from a device id.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
lib/rawdev/rte_rawdev_pmd.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h
index 22b406444d..8339122348 100644
--- a/lib/rawdev/rte_rawdev_pmd.h
+++ b/lib/rawdev/rte_rawdev_pmd.h
@@ -102,6 +102,30 @@ rte_rawdev_pmd_get_named_dev(const char *name)
return NULL;
}
+/**
+ * Get the rte_rawdev structure device pointer for given device ID.
+ *
+ * @param dev_id
+ * raw device index.
+ *
+ * @return
+ * - The rte_rawdev structure pointer for the given device ID.
+ */
+static inline struct rte_rawdev *
+rte_rawdev_pmd_get_dev(uint8_t dev_id)
+{
+ struct rte_rawdev *dev;
+
+ if (dev_id >= RTE_RAWDEV_MAX_DEVS)
+ return NULL;
+
+ dev = &rte_rawdevs[dev_id];
+ if (dev->attached == RTE_RAWDEV_ATTACHED)
+ return dev;
+
+ return NULL;
+}
+
/**
* Validate if the raw device index is a valid attached raw device.
*
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH 2/9] drivers/raw: introduce cnxk rvu lf device driver
2024-09-07 19:33 [PATCH 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-09-07 19:33 ` [PATCH 1/9] rawdev: add API to get device from index Akhil Goyal
@ 2024-09-07 19:33 ` Akhil Goyal
2024-09-23 15:28 ` Jerin Jacob
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
2024-09-07 19:33 ` [PATCH 3/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
` (6 subsequent siblings)
8 siblings, 2 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-09-07 19:33 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
CNXK product families can have a use case to allow PF and VF
applications to communicate using mailboxes and also get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
MAINTAINERS | 6 ++
doc/guides/rawdevs/cnxk_rvu_lf.rst | 40 ++++++++
doc/guides/rawdevs/index.rst | 1 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 2 +
drivers/common/cnxk/roc_dev_priv.h | 1 +
drivers/common/cnxk/roc_idev.c | 46 +++++++++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 63 ++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 24 +++++
drivers/common/cnxk/roc_rvu_lf_priv.h | 32 ++++++
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 5 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 123 +++++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 9 ++
drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 39 +++++++
drivers/raw/meson.build | 1 +
20 files changed, 405 insertions(+)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
create mode 100644 drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
diff --git a/MAINTAINERS b/MAINTAINERS
index c5a703b5c0..753dcd9743 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1499,6 +1499,12 @@ T: git://dpdk.org/next/dpdk-next-net-mrvl
F: doc/guides/rawdevs/cnxk_gpio.rst
F: drivers/raw/cnxk_gpio/
+Marvell CNXK RVU LF
+M: Akhil Goyal <gakhil@marvell.com>
+T: git://dpdk.org/next/dpdk-next-net-mrvl
+F: doc/guides/rawdevs/cnxk_rvu_lf.rst
+F: drivers/raw/cnxk_rvu_lf/
+
NTB
M: Jingjing Wu <jingjing.wu@intel.com>
F: drivers/raw/ntb/
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
new file mode 100644
index 0000000000..8a0bc22dd5
--- /dev/null
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -0,0 +1,40 @@
+.. SPDX-License-Identifier: BSD-3-Clause
+ Copyright(c) 2024 Marvell.
+
+Marvell CNXK RVU LF Driver
+==========================
+
+CNXK product families can have a use case to allow PF and VF
+applications to communicate using mailboxes and also get notified
+of any interrupt that may occur on the device.
+Hence, a new raw device driver is added for such RVU LF devices.
+These devices can map to a PF or a VF which can send mailboxes to
+each other.
+
+Features
+--------
+
+The RVU LF device implements following features in the rawdev API:
+
+- Register mailbox callbacks for the other side to process mailboxes.
+- Register interrupt handler callbacks.
+- Process mailbox.
+- Set range of message IDs allowed for communication.
+
+Limitations
+-----------
+
+In multiprocess mode user-space application must ensure
+no resources sharing takes place.
+Otherwise, user-space application should ensure synchronization.
+
+Device Setup
+------------
+
+The RVU LF devices will need to be bound to a user-space IO driver for use.
+The script ``dpdk-devbind.py`` included with DPDK can be used to
+view the state of the devices and to bind them to a suitable DPDK-supported
+kernel driver. When querying the status of the devices, they will appear under
+the category of "Misc (rawdev) devices", i.e. the command
+``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
+devices alone.
diff --git a/doc/guides/rawdevs/index.rst b/doc/guides/rawdevs/index.rst
index f34315f051..8e07cf4d6c 100644
--- a/doc/guides/rawdevs/index.rst
+++ b/doc/guides/rawdevs/index.rst
@@ -13,6 +13,7 @@ application through rawdev API.
cnxk_bphy
cnxk_gpio
+ cnxk_rvu_lf
dpaa2_cmdif
ifpga
ntb
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index e0e4600989..3d351aa730 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -71,6 +71,7 @@ sources = files(
'roc_tim_irq.c',
'roc_utils.c',
'roc_ree.c',
+ 'roc_rvu_lf.c',
)
# Security common code
diff --git a/drivers/common/cnxk/roc_api.h b/drivers/common/cnxk/roc_api.h
index 6a86863c57..93e7bf11bb 100644
--- a/drivers/common/cnxk/roc_api.h
+++ b/drivers/common/cnxk/roc_api.h
@@ -120,4 +120,7 @@
/* Eswitch */
#include "roc_eswitch.h"
+/* RVU LF */
+#include "roc_rvu_lf.h"
+
#endif /* _ROC_API_H_ */
diff --git a/drivers/common/cnxk/roc_constants.h b/drivers/common/cnxk/roc_constants.h
index 21b3998cee..44f28be2df 100644
--- a/drivers/common/cnxk/roc_constants.h
+++ b/drivers/common/cnxk/roc_constants.h
@@ -45,6 +45,8 @@
#define PCI_DEVID_CNXK_RVU_REE_VF 0xA0f5
#define PCI_DEVID_CNXK_RVU_ESWITCH_PF 0xA0E0
#define PCI_DEVID_CNXK_RVU_ESWITCH_VF 0xA0E1
+#define PCI_DEVID_CNXK_RVU_BPHY_PF 0xA0E4
+#define PCI_DEVID_CNXK_RVU_BPHY_VF 0xA0E5
#define PCI_DEVID_CN9K_CGX 0xA059
#define PCI_DEVID_CN10K_RPM 0xA060
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index 50e12cbf17..4af9513733 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -106,6 +106,7 @@ struct dev {
void *roc_cpt;
void *roc_tim;
void *roc_ml;
+ void *roc_rvu_lf;
bool disable_shared_lmt; /* false(default): shared lmt mode enabled */
const struct plt_memzone *lmt_mz;
struct mbox_sync sync;
diff --git a/drivers/common/cnxk/roc_idev.c b/drivers/common/cnxk/roc_idev.c
index 0778d51d1e..84812f73e0 100644
--- a/drivers/common/cnxk/roc_idev.c
+++ b/drivers/common/cnxk/roc_idev.c
@@ -38,6 +38,7 @@ idev_set_defaults(struct idev_cfg *idev)
idev->num_lmtlines = 0;
idev->bphy = NULL;
idev->cpt = NULL;
+ TAILQ_INIT(&idev->rvu_lf_list);
TAILQ_INIT(&idev->mcs_list);
idev->nix_inl_dev = NULL;
TAILQ_INIT(&idev->roc_nix_list);
@@ -188,6 +189,51 @@ roc_idev_cpt_get(void)
return NULL;
}
+struct roc_rvu_lf *
+roc_idev_rvu_lf_get(uint8_t rvu_lf_idx)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf, &idev->rvu_lf_list, next) {
+ if (rvu_lf->idx == rvu_lf_idx)
+ return rvu_lf;
+ }
+ }
+
+ return NULL;
+}
+
+void
+roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ return;
+ }
+ TAILQ_INSERT_TAIL(&idev->rvu_lf_list, rvu, next);
+ }
+}
+
+void
+roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ TAILQ_REMOVE(&idev->rvu_lf_list, rvu, next);
+ }
+ }
+}
+
struct roc_mcs *
roc_idev_mcs_get(uint8_t mcs_idx)
{
diff --git a/drivers/common/cnxk/roc_idev.h b/drivers/common/cnxk/roc_idev.h
index fc0f7db54e..6edb5f83b2 100644
--- a/drivers/common/cnxk/roc_idev.h
+++ b/drivers/common/cnxk/roc_idev.h
@@ -29,4 +29,8 @@ uint16_t *__roc_api roc_idev_nix_rx_chan_base_get(void);
void __roc_api roc_idev_nix_rx_chan_set(uint16_t port, uint16_t chan);
uint16_t __roc_api roc_idev_nix_inl_dev_pffunc_get(void);
+
+struct roc_rvu_lf *__roc_api roc_idev_rvu_lf_get(uint8_t rvu_lf_idx);
+void __roc_api roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu);
+void __roc_api roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu);
#endif /* _ROC_IDEV_H_ */
diff --git a/drivers/common/cnxk/roc_idev_priv.h b/drivers/common/cnxk/roc_idev_priv.h
index 6628b18152..98b6286bfe 100644
--- a/drivers/common/cnxk/roc_idev_priv.h
+++ b/drivers/common/cnxk/roc_idev_priv.h
@@ -36,6 +36,7 @@ struct idev_cfg {
struct roc_bphy *bphy;
struct roc_cpt *cpt;
struct roc_sso *sso;
+ struct roc_rvu_lf_head rvu_lf_list;
struct roc_mcs_head mcs_list;
struct nix_inl_dev *nix_inl_dev;
struct idev_nix_inl_cfg inl_cfg;
diff --git a/drivers/common/cnxk/roc_priv.h b/drivers/common/cnxk/roc_priv.h
index 254a2d3310..8732a05ac3 100644
--- a/drivers/common/cnxk/roc_priv.h
+++ b/drivers/common/cnxk/roc_priv.h
@@ -53,4 +53,6 @@
/* ML */
#include "roc_ml_priv.h"
+/* RVU LF */
+#include "roc_rvu_lf_priv.h"
#endif /* _ROC_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
new file mode 100644
index 0000000000..1ae39e746e
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include "roc_api.h"
+#include "roc_priv.h"
+
+int
+roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct plt_pci_device *pci_dev;
+ struct dev *dev;
+ struct rvu_lf *rvu;
+ int rc;
+
+ if (roc_rvu_lf == NULL || roc_rvu_lf->pci_dev == NULL)
+ return RVU_ERR_PARAM;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ pci_dev = roc_rvu_lf->pci_dev;
+ dev = &rvu->dev;
+
+ if (rvu->dev.drv_inited)
+ return 0;
+
+ if (dev->mbox_active)
+ goto skip_dev_init;
+
+ memset(rvu, 0, sizeof(*rvu));
+
+ /* Initialize device */
+ rc = dev_init(dev, pci_dev);
+ if (rc) {
+ plt_err("Failed to init roc device");
+ goto fail;
+ }
+
+skip_dev_init:
+ dev->roc_rvu_lf = roc_rvu_lf;
+ rvu->pci_dev = pci_dev;
+
+ roc_idev_rvu_lf_set(roc_rvu_lf);
+ rvu->dev.drv_inited = true;
+
+ return 0;
+fail:
+ return rc;
+}
+
+int
+roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (rvu == NULL)
+ return NIX_ERR_PARAM;
+
+ rvu->dev.drv_inited = false;
+
+ roc_idev_rvu_lf_free(roc_rvu_lf);
+
+ return dev_fini(&rvu->dev, rvu->pci_dev);
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
new file mode 100644
index 0000000000..7ce8065a8b
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_H_
+#define _ROC_RVU_LF_H_
+
+#include "roc_platform.h"
+
+struct roc_rvu_lf {
+ TAILQ_ENTRY(roc_rvu_lf) next;
+ struct plt_pci_device *pci_dev;
+ uint8_t idx;
+#define ROC_RVU_MEM_SZ (6 * 1024)
+ uint8_t reserved[ROC_RVU_MEM_SZ] __plt_cache_aligned;
+};
+
+TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
+
+/* Dev */
+int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+
+#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
new file mode 100644
index 0000000000..8feff82961
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_PRIV_H_
+#define _ROC_RVU_LF_PRIV_H_
+
+enum rvu_err_status {
+ RVU_ERR_PARAM = -1,
+ RVU_ERR_NO_MEM = -2,
+};
+
+struct rvu_lf {
+ struct plt_pci_device *pci_dev;
+ struct dev dev;
+ uint16_t msg_id_from;
+ uint16_t msg_id_to;
+};
+
+static inline struct rvu_lf *
+roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
+{
+ return (struct rvu_lf *)&roc_rvu_lf->reserved[0];
+}
+
+static inline struct roc_rvu_lf *
+rvu_priv_to_roc_rvu_lf(struct rvu_lf *rvu_lf)
+{
+ return (struct roc_rvu_lf *)((char *)rvu_lf - offsetof(struct roc_rvu_lf, reserved));
+}
+
+#endif /* _ROC_RVU_LF_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_utils.c b/drivers/common/cnxk/roc_utils.c
index 9af2ae9b69..bcc0d2de38 100644
--- a/drivers/common/cnxk/roc_utils.c
+++ b/drivers/common/cnxk/roc_utils.c
@@ -17,11 +17,13 @@ roc_error_msg_get(int errorcode)
case NPC_ERR_PARAM:
case SSO_ERR_PARAM:
case MCS_ERR_PARAM:
+ case RVU_ERR_PARAM:
case UTIL_ERR_PARAM:
err_msg = "Invalid parameter";
break;
case NIX_ERR_NO_MEM:
case NPC_ERR_NO_MEM:
+ case RVU_ERR_NO_MEM:
err_msg = "Out of memory";
break;
case NIX_ERR_INVALID_RANGE:
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index f98738d07e..a2baa12f1a 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -118,6 +118,9 @@ INTERNAL {
roc_idev_nix_rx_chan_set;
roc_idev_nix_rx_inject_get;
roc_idev_nix_rx_inject_set;
+ roc_idev_rvu_lf_free;
+ roc_idev_rvu_lf_get;
+ roc_idev_rvu_lf_set;
roc_ml_reg_read64;
roc_ml_reg_write64;
roc_ml_reg_read32;
@@ -541,5 +544,7 @@ INTERNAL {
roc_ree_rule_db_get;
roc_ree_rule_db_len_get;
roc_ree_rule_db_prog;
+ roc_rvu_lf_dev_fini;
+ roc_rvu_lf_dev_init;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
new file mode 100644
index 0000000000..50862ca097
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include <bus_pci_driver.h>
+#include <rte_common.h>
+#include <dev_driver.h>
+#include <rte_eal.h>
+#include <rte_lcore.h>
+#include <rte_pci.h>
+#include <rte_rawdev.h>
+#include <rte_rawdev_pmd.h>
+
+#include <roc_api.h>
+
+#include "rte_pmd_rvu_lf.h"
+
+static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
+ .dev_selftest = NULL,
+};
+
+static void
+rvu_lf_rawdev_get_name(char *name, struct rte_pci_device *pci_dev)
+{
+ snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "RVU LF:%02x:%02x.%x",
+ pci_dev->addr.bus, pci_dev->addr.devid,
+ pci_dev->addr.function);
+}
+
+static int
+rvu_lf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct rte_rawdev *rvu_lf_rawdev;
+ struct roc_rvu_lf *roc_rvu_lf;
+ int ret;
+
+ RTE_SET_USED(pci_drv);
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (!pci_dev->mem_resource[2].addr) {
+ CNXK_RVU_LF_LOG(ERR, "BARs have invalid values: BAR0 %p\n BAR2 %p",
+ pci_dev->mem_resource[2].addr, pci_dev->mem_resource[4].addr);
+ return -ENODEV;
+ }
+
+ ret = roc_plt_init();
+ if (ret)
+ return ret;
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rvu_lf_rawdev = rte_rawdev_pmd_allocate(name, sizeof(*roc_rvu_lf),
+ rte_socket_id());
+ if (rvu_lf_rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "Failed to allocate rawdev");
+ return -ENOMEM;
+ }
+
+ rvu_lf_rawdev->dev_ops = &rvu_lf_rawdev_ops;
+ rvu_lf_rawdev->device = &pci_dev->device;
+ rvu_lf_rawdev->driver_name = pci_dev->driver->driver.name;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rvu_lf_rawdev->dev_private;
+ roc_rvu_lf->pci_dev = pci_dev;
+
+ ret = roc_rvu_lf_dev_init(roc_rvu_lf);
+ if (ret) {
+ rte_rawdev_pmd_release(rvu_lf_rawdev);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int
+rvu_lf_remove(struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (pci_dev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid pci_dev");
+ return -EINVAL;
+ }
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rawdev = rte_rawdev_pmd_get_named_dev(name);
+ if (rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid device name (%s)", name);
+ return -EINVAL;
+ }
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+ roc_rvu_lf_dev_fini(roc_rvu_lf);
+
+ return rte_rawdev_pmd_release(rawdev);
+}
+
+static const struct rte_pci_id pci_rvu_lf_map[] = {
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_BPHY_PF),
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_BPHY_VF),
+ {
+ .vendor_id = 0,
+ },
+};
+
+static struct rte_pci_driver cnxk_rvu_lf_rawdev_pmd = {
+ .id_table = pci_rvu_lf_map,
+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
+ .probe = rvu_lf_probe,
+ .remove = rvu_lf_remove,
+};
+
+RTE_PMD_REGISTER_PCI(rvu_lf_rawdev_pci_driver, cnxk_rvu_lf_rawdev_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(rvu_lf_rawdev_pci_driver, pci_rvu_lf_map);
+RTE_PMD_REGISTER_KMOD_DEP(rvu_lf_rawdev_pci_driver, "vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_rvu_lf, rvu_lf, INFO);
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
new file mode 100644
index 0000000000..32081e147f
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2024 Marvell.
+#
+
+deps += ['bus_pci', 'common_cnxk', 'rawdev']
+sources = files(
+ 'cnxk_rvu_lf.c',
+)
+require_iova_in_mbuf = false
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
new file mode 100644
index 0000000000..2d3cd032b7
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _CNXK_RVU_LF_H_
+#define _CNXK_RVU_LF_H_
+
+#include <stdint.h>
+
+#include <rte_common.h>
+#include <rte_dev.h>
+#include <rte_malloc.h>
+#include <rte_memcpy.h>
+#include <rte_rawdev.h>
+
+/**
+ * @file rte_pmd_rvu_lf.h
+ *
+ * Marvell RVU LF raw PMD specific structures and interface
+ *
+ * This API allows applications to manage RVU LF device in user space along with
+ * installing interrupt handlers for low latency signal processing.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int cnxk_logtype_rvu_lf;
+
+#define CNXK_RVU_LF_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
+ "%s(): " fmt "\n", __func__, ## args)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CNXK_RVU_LF_H_ */
diff --git a/drivers/raw/meson.build b/drivers/raw/meson.build
index 05cad143fe..54221643d5 100644
--- a/drivers/raw/meson.build
+++ b/drivers/raw/meson.build
@@ -8,6 +8,7 @@ endif
drivers = [
'cnxk_bphy',
'cnxk_gpio',
+ 'cnxk_rvu_lf',
'dpaa2_cmdif',
'ifpga',
'ntb',
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH 3/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc
2024-09-07 19:33 [PATCH 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-09-07 19:33 ` [PATCH 1/9] rawdev: add API to get device from index Akhil Goyal
2024-09-07 19:33 ` [PATCH 2/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
@ 2024-09-07 19:33 ` Akhil Goyal
2024-09-07 19:33 ` [PATCH 4/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
` (5 subsequent siblings)
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-09-07 19:33 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added rte_pmd_rvu_lf_npa_pf_func_get and
rte_pmd_rvu_lf_sso_pf_func_get APIs to get NPA and
SSO pffunc for the application use.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 +++++++
drivers/common/cnxk/roc_npa.c | 6 ++++++
drivers/common/cnxk/roc_npa.h | 3 +++
drivers/common/cnxk/roc_sso.c | 6 ++++++
drivers/common/cnxk/roc_sso.h | 3 +++
drivers/common/cnxk/version.map | 2 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 12 ++++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 1 +
drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 18 ++++++++++++++++++
9 files changed, 58 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 8a0bc22dd5..13184ad4dc 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -38,3 +38,10 @@ kernel driver. When querying the status of the devices, they will appear under
the category of "Misc (rawdev) devices", i.e. the command
``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
devices alone.
+
+Get NPA and SSO PF FUNC
+-----------------------
+
+APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
+can be used to get the cnxk NPA PF func and SSO PF func which application
+can use for NPA/SSO specific configuration.
diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index 6c14c49901..6e6d50f1ce 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -17,6 +17,12 @@ roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb)
return 0;
}
+uint16_t
+roc_npa_pf_func_get(void)
+{
+ return idev_npa_pffunc_get();
+}
+
void
roc_npa_pool_op_range_set(uint64_t aura_handle, uint64_t start_iova,
uint64_t end_iova)
diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h
index 4ad5f044b5..1ca7348534 100644
--- a/drivers/common/cnxk/roc_npa.h
+++ b/drivers/common/cnxk/roc_npa.h
@@ -812,6 +812,9 @@ int __roc_api roc_npa_aura_bp_configure(uint64_t aura_id, uint16_t bpid, uint8_t
typedef int (*roc_npa_lf_init_cb_t)(struct plt_pci_device *pci_dev);
int __roc_api roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb);
+/* Utility functions */
+uint16_t __roc_api roc_npa_pf_func_get(void);
+
/* Debug */
int __roc_api roc_npa_ctx_dump(void);
int __roc_api roc_npa_dump(void);
diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c
index 293b0c81a1..57ed2a4fed 100644
--- a/drivers/common/cnxk/roc_sso.c
+++ b/drivers/common/cnxk/roc_sso.c
@@ -319,6 +319,12 @@ roc_sso_hwgrp_base_get(struct roc_sso *roc_sso, uint16_t hwgrp)
return dev->bar2 + (RVU_BLOCK_ADDR_SSO << 20 | hwgrp << 12);
}
+uint16_t
+roc_sso_pf_func_get(void)
+{
+ return idev_sso_pffunc_get();
+}
+
uint64_t
roc_sso_ns_to_gw(uint64_t base, uint64_t ns)
{
diff --git a/drivers/common/cnxk/roc_sso.h b/drivers/common/cnxk/roc_sso.h
index 4ac901762e..3e293a0a69 100644
--- a/drivers/common/cnxk/roc_sso.h
+++ b/drivers/common/cnxk/roc_sso.h
@@ -103,6 +103,9 @@ int __roc_api roc_sso_hwgrp_stash_config(struct roc_sso *roc_sso,
void __roc_api roc_sso_hws_gwc_invalidate(struct roc_sso *roc_sso, uint8_t *hws,
uint8_t nb_hws);
+/* Utility function */
+uint16_t __roc_api roc_sso_pf_func_get(void);
+
/* Debug */
void __roc_api roc_sso_dump(struct roc_sso *roc_sso, uint8_t nb_hws,
uint16_t hwgrp, FILE *f);
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index a2baa12f1a..1f593febc3 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -449,6 +449,7 @@ INTERNAL {
roc_npa_dev_unlock;
roc_npa_dump;
roc_npa_lf_init_cb_register;
+ roc_npa_pf_func_get;
roc_npa_pool_create;
roc_npa_pool_destroy;
roc_npa_pool_op_pc_reset;
@@ -516,6 +517,7 @@ INTERNAL {
roc_sso_hws_gwc_invalidate;
roc_sso_hws_unlink;
roc_sso_ns_to_gw;
+ roc_sso_pf_func_get;
roc_sso_rsrc_fini;
roc_sso_rsrc_init;
roc_tim_fini;
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 50862ca097..2fbde52966 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -15,6 +15,18 @@
#include "rte_pmd_rvu_lf.h"
+uint16_t
+rte_pmd_rvu_lf_npa_pf_func_get(void)
+{
+ return roc_npa_pf_func_get();
+}
+
+uint16_t
+rte_pmd_rvu_lf_sso_pf_func_get(void)
+{
+ return roc_sso_pf_func_get();
+}
+
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
.dev_selftest = NULL,
};
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
index 32081e147f..d4c934709a 100644
--- a/drivers/raw/cnxk_rvu_lf/meson.build
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -6,4 +6,5 @@ deps += ['bus_pci', 'common_cnxk', 'rawdev']
sources = files(
'cnxk_rvu_lf.c',
)
+headers = files('rte_pmd_rvu_lf.h')
require_iova_in_mbuf = false
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
index 2d3cd032b7..c11df14553 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
@@ -32,6 +32,24 @@ extern int cnxk_logtype_rvu_lf;
rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
"%s(): " fmt "\n", __func__, ## args)
+/**
+ * Obtain NPA PF func
+ *
+ * @return
+ * Returns NPA pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_experimental
+uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
+
+/**
+ * Obtain SSO PF func
+ *
+ * @return
+ * Returns SSO pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_experimental
+uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+
#ifdef __cplusplus
}
#endif
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH 4/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-09-07 19:33 [PATCH 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (2 preceding siblings ...)
2024-09-07 19:33 ` [PATCH 3/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
@ 2024-09-07 19:33 ` Akhil Goyal
2024-09-07 19:33 ` [PATCH 5/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
` (4 subsequent siblings)
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-09-07 19:33 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added rte_pmd_rvu_lf_bar_get() API to get BAR address
for application to configure hardware.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 +++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 23 +++++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 18 ++++++++++++++++++
3 files changed, 48 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 13184ad4dc..6dfbd466ad 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -45,3 +45,10 @@ Get NPA and SSO PF FUNC
APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
can be used to get the cnxk NPA PF func and SSO PF func which application
can use for NPA/SSO specific configuration.
+
+Get BAR addresses
+-----------------
+
+Application can retrieve PCI BAR addresses of the device using the API
+``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the
+registers of the hardware device.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 2fbde52966..fc9facd852 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -15,6 +15,29 @@
#include "rte_pmd_rvu_lf.h"
+int
+rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask)
+{
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+ if (bar_num > PCI_MAX_RESOURCE ||
+ (roc_rvu_lf->pci_dev->mem_resource[bar_num].addr == NULL)) {
+ *va = 0;
+ *mask = 0;
+ return -ENOTSUP;
+ }
+ *va = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].addr);
+ *mask = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].len - 1);
+
+ return 0;
+}
+
uint16_t
rte_pmd_rvu_lf_npa_pf_func_get(void)
{
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
index c11df14553..50b43b1785 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
@@ -50,6 +50,24 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
__rte_experimental
uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+/**
+ * Get BAR addresses for the RVU LF device.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param bar_num
+ * BAR number for which address is required
+ * @param[out] va
+ * Virtual address of the BAR. 0 if not mapped
+ * @param[out] mask
+ * BAR address mask, 0 if not mapped
+ *
+ * @return
+ * Returns 0 on success, negative error code otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask);
+
#ifdef __cplusplus
}
#endif
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH 5/9] raw/cnxk_rvu_lf: register/unregister interrupt handler
2024-09-07 19:33 [PATCH 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (3 preceding siblings ...)
2024-09-07 19:33 ` [PATCH 4/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
@ 2024-09-07 19:33 ` Akhil Goyal
2024-09-07 19:33 ` [PATCH 6/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
` (3 subsequent siblings)
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-09-07 19:33 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD API rte_pmd_rvu_lf_irq_register() and
rte_pmd_rvu_lf_irq_unregister() to register/unregister
interrupt handlers for rvu lf raw device.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 +++++
drivers/common/cnxk/roc_rvu_lf.c | 26 ++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 +++
drivers/common/cnxk/version.map | 2 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 30 ++++++++++++++++
drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 46 ++++++++++++++++++++++++
6 files changed, 117 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 6dfbd466ad..7bae6b523e 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -52,3 +52,11 @@ Get BAR addresses
Application can retrieve PCI BAR addresses of the device using the API
``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the
registers of the hardware device.
+
+Register or remove interrupt handler
+------------------------------------
+
+Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register()``
+or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
+The irq numbers for which the interrupts are registered is negotiated separately
+and is not in scope of the driver.
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1ae39e746e..63bc149f2a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -61,3 +61,29 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+
+int
+roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ return dev_irq_register(handle, (plt_intr_callback_fn)cb, data, irq);
+}
+
+int
+roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ dev_irq_unregister(handle, (plt_intr_callback_fn)cb, data, irq);
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7ce8065a8b..800bf4e674 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,4 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 1f593febc3..a948729688 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -548,5 +548,7 @@ INTERNAL {
roc_ree_rule_db_prog;
roc_rvu_lf_dev_fini;
roc_rvu_lf_dev_init;
+ roc_rvu_lf_irq_register;
+ roc_rvu_lf_irq_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index fc9facd852..b4b6c34eb3 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -15,6 +15,36 @@
#include "rte_pmd_rvu_lf.h"
+int
+rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_register(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
+int
+rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_unregister(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
int
rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask)
{
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
index 50b43b1785..e39133f879 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
@@ -32,6 +32,52 @@ extern int cnxk_logtype_rvu_lf;
rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
"%s(): " fmt "\n", __func__, ## args)
+/**
+ * Signature of callback function called when an interrupt is received on RVU LF device.
+ *
+ * @param cb_arg
+ * pointer to the information received on an interrupt
+ */
+typedef void (*rte_pmd_rvu_lf_intr_callback_fn)(void *cb_arg);
+
+/**
+ * Register interrupt callback
+ *
+ * Registers an interrupt callback to be executed when interrupt is raised.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number for which interrupt will be raised
+ * @param cb
+ * callback function to be executed
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
+/**
+ * Unregister interrupt callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number
+ * @param cb
+ * callback function registered
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
/**
* Obtain NPA PF func
*
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH 6/9] raw/cnxk_rvu_lf: register/unregister msg handler
2024-09-07 19:33 [PATCH 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (4 preceding siblings ...)
2024-09-07 19:33 ` [PATCH 5/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
@ 2024-09-07 19:33 ` Akhil Goyal
2024-09-07 19:33 ` [PATCH 7/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
` (2 subsequent siblings)
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-09-07 19:33 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD APIs rte_pmd_rvu_lf_msg_handler_register()
and rte_pmd_rvu_lf_msg_handler_unregister() to register/unregister
mailbox message handlers. These handlers are needed to fill
response at the other side for the request sent from one side.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
drivers/common/cnxk/roc_dev_priv.h | 6 +++
drivers/common/cnxk/roc_rvu_lf.c | 25 ++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 7 ++++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 28 ++++++++++++++
drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 49 ++++++++++++++++++++++++
6 files changed, 117 insertions(+)
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index 4af9513733..0235415bcf 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -39,11 +39,17 @@ typedef void (*link_status_get_t)(void *roc_nix,
/* Representee notification callback */
typedef int (*repte_notify_t)(void *roc_nix, void *notify_msg);
+/* RVU Message process callback */
+typedef int (*msg_process_cb_t)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
struct dev_ops {
link_info_t link_status_update;
ptp_info_t ptp_info_update;
link_status_get_t link_status_get;
q_err_cb_t q_err_cb;
+ msg_process_cb_t msg_process_cb;
repte_notify_t repte_notify;
};
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 63bc149f2a..2e1be81e52 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -87,3 +87,28 @@ roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
return 0;
}
+
+int
+roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf, roc_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ if (cb == NULL)
+ return -EINVAL;
+
+ dev->ops->msg_process_cb = (msg_process_cb_t)cb;
+
+ return 0;
+}
+
+int
+roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ dev->ops->msg_process_cb = NULL;
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 800bf4e674..90a0b5690a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -22,8 +22,15 @@ int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf,
+ roc_rvu_lf_msg_handler_cb_fn cb);
+int __roc_api roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index a948729688..c850b17dbb 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -550,5 +550,7 @@ INTERNAL {
roc_rvu_lf_dev_init;
roc_rvu_lf_irq_register;
roc_rvu_lf_irq_unregister;
+ roc_rvu_lf_msg_handler_register;
+ roc_rvu_lf_msg_handler_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index b4b6c34eb3..ced77bb36e 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -15,6 +15,34 @@
#include "rte_pmd_rvu_lf.h"
+int
+rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_register(roc_rvu_lf, (roc_rvu_lf_msg_handler_cb_fn)cb);
+}
+
+int
+rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_unregister(roc_rvu_lf);
+}
+
int
rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
index e39133f879..51701cc49c 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
@@ -32,6 +32,55 @@ extern int cnxk_logtype_rvu_lf;
rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
"%s(): " fmt "\n", __func__, ## args)
+/**
+ * Signature of callback function called when a message process handler is called
+ * on RVU LF device.
+ *
+ * @param vf
+ * VF number(0 to N) from which message is received (ignored in case of PF)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request
+ * @param req_len
+ * pointer to message request
+ * @param[out] rsp
+ * pointer to message response
+ * @param[out] rsp_len
+ * length of message response
+ *
+ * @return 0 when response is set, negative value otherwise
+ */
+typedef int (*rte_pmd_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
+/**
+ * Register message handler callback
+ *
+ * Registers message handler callback to be executed when the message is received from peer.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param cb
+ * callback function to be executed
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb);
+
+/**
+ * Unregister message handler callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
+
/**
* Signature of callback function called when an interrupt is received on RVU LF device.
*
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH 7/9] raw/cnxk_rvu_lf: set message ID range
2024-09-07 19:33 [PATCH 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (5 preceding siblings ...)
2024-09-07 19:33 ` [PATCH 6/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
@ 2024-09-07 19:33 ` Akhil Goyal
2024-09-07 19:33 ` [PATCH 8/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
2024-09-07 19:33 ` [PATCH 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-09-07 19:33 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD API rte_pmd_rvu_lf_msg_id_range_set()
to set RVU mailbox message id range.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 12 ++++++++++
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 30 ++++++++++++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 3 +++
drivers/common/cnxk/version.map | 2 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 14 +++++++++++
drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 15 ++++++++++++
7 files changed, 77 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7bae6b523e..7f193e232c 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -60,3 +60,15 @@ Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register(
or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
The irq numbers for which the interrupts are registered is negotiated separately
and is not in scope of the driver.
+
+RVU LF RAW MESSAGE PROCESSING
+-----------------------------
+
+Once a RVU LF raw device is probed, a range of message ids can be configured for
+which mailboxes will be sent using the API ``rte_pmd_rvu_lf_msg_id_range_set``.
+
+For processing of mailboxes received on PF/VF application, application
+can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()``
+and fill required responses as per the request and message id received.
+Application can also unregister already registered message callbacks using
+``rte_pmd_rvu_lf_msg_handler_unregister()``.
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index f1a3371ef9..3018a4f73e 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -54,6 +54,7 @@ struct mbox_msghdr {
#define MBOX_MSG_MASK 0xFFFF
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
+#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 2e1be81e52..1026ccc125 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,36 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+int
+roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (from <= MBOX_MSG_GENERIC_MAX_ID || from > to)
+ return -EINVAL;
+
+ rvu->msg_id_from = from;
+ rvu->msg_id_to = to;
+
+ return 0;
+}
+
+bool
+roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
+{
+ struct rvu_lf *rvu;
+
+ if (roc_rvu_lf == NULL)
+ return 0;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (msg_id > rvu->msg_id_from && msg_id < rvu->msg_id_to)
+ return 1;
+
+ return 0;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 90a0b5690a..7243e170b9 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t from, uint16_t to);
+bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
void *req, uint16_t req_len,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index c850b17dbb..adfe7ee789 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -552,5 +552,7 @@ INTERNAL {
roc_rvu_lf_irq_unregister;
roc_rvu_lf_msg_handler_register;
roc_rvu_lf_msg_handler_unregister;
+ roc_rvu_lf_msg_id_range_check;
+ roc_rvu_lf_msg_id_range_set;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index ced77bb36e..a21bca9ea6 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -15,6 +15,20 @@
#include "rte_pmd_rvu_lf.h"
+int
+rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
index 51701cc49c..9ee9c57d7d 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
@@ -32,6 +32,21 @@ extern int cnxk_logtype_rvu_lf;
rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
"%s(): " fmt "\n", __func__, ## args)
+/**
+ * Set RVU mailbox message id range.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param from
+ * starting message id for RVU mailbox (> 0x1FF)
+ * @param to
+ * last message id for RVU mailbox (< 0xFFFF)
+ *
+ * @return 0 on success, -EINVAL for invalid range
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+
/**
* Signature of callback function called when a message process handler is called
* on RVU LF device.
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH 8/9] raw/cnxk_rvu_lf: process mailbox message
2024-09-07 19:33 [PATCH 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (6 preceding siblings ...)
2024-09-07 19:33 ` [PATCH 7/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
@ 2024-09-07 19:33 ` Akhil Goyal
2024-09-07 19:33 ` [PATCH 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-09-07 19:33 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD API rte_pmd_rvu_lf_msg_process() to process
mailbox messages between rvu_lf devices.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 ++
drivers/common/cnxk/roc_dev.c | 117 +++++++++++++++++++++--
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 58 +++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 +
drivers/common/cnxk/roc_rvu_lf_priv.h | 5 +
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 15 +++
drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 29 ++++++
9 files changed, 234 insertions(+), 6 deletions(-)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7f193e232c..7b321abd38 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -72,3 +72,11 @@ can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()``
and fill required responses as per the request and message id received.
Application can also unregister already registered message callbacks using
``rte_pmd_rvu_lf_msg_handler_unregister()``.
+
+A PMD API ``rte_pmd_rvu_lf_msg_process()`` is created to send a request and
+receive corresponding response from the other side(PF/VF).
+It accepts an opaque pointer of a request and its size which can be defined by application
+and provides an opaque pointer for a response and its length.
+PF and VF application can define its own request and response based on the message id
+of the mailbox.
+For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``.
diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index daf7684d8e..806d34143b 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -215,6 +215,51 @@ af_pf_wait_msg(struct dev *dev, uint16_t vf, int num_msg)
return req_hdr->num_msgs;
}
+static int
+process_rvu_lf_msgs(struct dev *dev, uint16_t vf, struct mbox_msghdr *msg, size_t size)
+{
+ uint16_t max_bits = sizeof(dev->active_vfs[0]) * 8;
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Handle BPHY mailbox message in PF */
+ dev->active_vfs[vf / max_bits] |= BIT_ULL(vf % max_bits);
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -1;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", vf);
+ return -1;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_vfpf, vf,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", vf);
+ return -1;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ free(resp);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return 0;
+}
+
/* PF receives mbox DOWN messages from VF and forwards to AF */
static int
vf_pf_process_msgs(struct dev *dev, uint16_t vf)
@@ -261,6 +306,9 @@ vf_pf_process_msgs(struct dev *dev, uint16_t vf)
/* PF/VF function ID */
rsp->hdr.pcifunc = msg->pcifunc;
rsp->hdr.rc = 0;
+ } else if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ if (process_rvu_lf_msgs(dev, vf, msg, size) < 0)
+ continue;
} else {
struct mbox_msghdr *af_req;
/* Reserve AF/PF mbox message */
@@ -339,8 +387,13 @@ vf_pf_process_up_msgs(struct dev *dev, uint16_t vf)
dev_get_vf(msg->pcifunc));
break;
default:
- plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
- msg->id, mbox_id2name(msg->id), msg->pcifunc);
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id))
+ plt_base_dbg("PF: Msg 0x%x fn:0x%x (pf:%d,vf:%d)",
+ msg->id, msg->pcifunc, dev_get_pf(msg->pcifunc),
+ dev_get_vf(msg->pcifunc));
+ else
+ plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
+ msg->id, mbox_id2name(msg->id), msg->pcifunc);
}
offset = mbox->rx_start + msg->next_msgoff;
}
@@ -789,6 +842,49 @@ mbox_process_msgs_up(struct dev *dev, struct mbox_msghdr *req)
return -ENODEV;
}
+static int
+process_rvu_lf_msgs_up(struct dev *dev, struct mbox_msghdr *msg, size_t size)
+{
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Check if valid, if not reply with an invalid msg */
+ if (msg->sig != MBOX_REQ_SIG)
+ return -EIO;
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -ENOMEM;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", dev->vf);
+ return rc;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_up, 0,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", dev->vf);
+ return -ENOMEM;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return rc;
+}
+
/* Received up messages from AF (PF context) / PF (in context) */
static void
process_msgs_up(struct dev *dev, struct mbox *mbox)
@@ -797,6 +893,7 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
struct mbox_hdr *req_hdr;
struct mbox_msghdr *msg;
int i, err, offset;
+ size_t size;
req_hdr = (struct mbox_hdr *)((uintptr_t)mdev->mbase + mbox->rx_start);
if (req_hdr->num_msgs == 0)
@@ -809,10 +906,17 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
plt_base_dbg("Message 0x%x (%s) pf:%d/vf:%d", msg->id,
mbox_id2name(msg->id), dev_get_pf(msg->pcifunc),
dev_get_vf(msg->pcifunc));
- err = mbox_process_msgs_up(dev, msg);
- if (err)
- plt_err("Error %d handling 0x%x (%s)", err, msg->id,
- mbox_id2name(msg->id));
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ size = mbox->rx_start + msg->next_msgoff - offset;
+ err = process_rvu_lf_msgs_up(dev, msg, size);
+ if (err)
+ plt_err("Error %d handling 0x%x RVU_LF up msg", err, msg->id);
+ } else {
+ err = mbox_process_msgs_up(dev, msg);
+ if (err)
+ plt_err("Error %d handling 0x%x (%s)", err, msg->id,
+ mbox_id2name(msg->id));
+ }
offset = mbox->rx_start + msg->next_msgoff;
}
/* Send mbox responses */
@@ -1272,6 +1376,7 @@ dev_vf_hwcap_update(struct plt_pci_device *pci_dev, struct dev *dev)
case PCI_DEVID_CNXK_RVU_VF:
case PCI_DEVID_CNXK_RVU_SDP_VF:
case PCI_DEVID_CNXK_RVU_NIX_INL_VF:
+ case PCI_DEVID_CNXK_RVU_BPHY_VF:
case PCI_DEVID_CNXK_RVU_ESWITCH_VF:
dev->hwcap |= DEV_HWCAP_F_VF;
break;
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index 3018a4f73e..ea806ea6e8 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -55,6 +55,7 @@ struct mbox_msghdr {
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
+#define MBOX_MSG_REQ_SIZE_MAX (16 * 1024)
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1026ccc125..471dfa7a46 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,15 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+static uint16_t
+roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ return dev->pf_func;
+}
+
int
roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
{
@@ -92,6 +101,55 @@ roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
return 0;
}
+int
+roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf, uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len, void *rsp_data, uint16_t rsp_len)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct mbox *mbox;
+ struct rvu_lf_msg *req;
+ struct rvu_lf_msg *rsp;
+ int rc = -ENOSPC;
+ int devid = 0;
+
+ if (rvu->dev.vf == -1 && roc_rvu_lf_msg_id_range_check(roc_rvu_lf, msg_id)) {
+ /* This is PF context */
+ if (vf >= rvu->dev.maxvf)
+ return -EINVAL;
+ devid = vf;
+ mbox = mbox_get(&rvu->dev.mbox_vfpf_up);
+ } else {
+ /* This is VF context */
+ devid = 0; /* VF send all message to PF */
+ mbox = mbox_get(rvu->dev.mbox);
+ }
+ req = (struct rvu_lf_msg *)mbox_alloc_msg_rsp(mbox, devid,
+ req_len + sizeof(struct rvu_lf_msg),
+ rsp_len + sizeof(struct rvu_lf_msg));
+ if (!req)
+ goto fail;
+ mbox_memcpy(req->data, req_data, req_len);
+ req->hdr.sig = MBOX_REQ_SIG;
+ req->hdr.id = msg_id;
+ req->hdr.pcifunc = roc_rvu_lf_pf_func_get(roc_rvu_lf);
+
+ if (rvu->dev.vf == -1) {
+ mbox_msg_send_up(mbox, devid);
+ rc = mbox_get_rsp(mbox, devid, (void *)&rsp);
+ if (rc)
+ goto fail;
+ } else {
+ rc = mbox_process_msg(mbox, (void *)&rsp);
+ if (rc)
+ goto fail;
+ }
+ if (rsp_len && rsp_data != NULL)
+ mbox_memcpy(rsp_data, rsp->data, rsp_len);
+fail:
+ mbox_put(mbox);
+ return rc;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7243e170b9..6b4819666a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,11 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len,
+ void *rsp_data, uint16_t rsp_len);
+
int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
uint16_t from, uint16_t to);
bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
index 8feff82961..57bb713b21 100644
--- a/drivers/common/cnxk/roc_rvu_lf_priv.h
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -17,6 +17,11 @@ struct rvu_lf {
uint16_t msg_id_to;
};
+struct rvu_lf_msg {
+ struct mbox_msghdr hdr;
+ uint8_t data[];
+};
+
static inline struct rvu_lf *
roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
{
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index adfe7ee789..a3e2170739 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -554,5 +554,7 @@ INTERNAL {
roc_rvu_lf_msg_handler_unregister;
roc_rvu_lf_msg_id_range_check;
roc_rvu_lf_msg_id_range_set;
+ roc_rvu_lf_msg_process;
+
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index a21bca9ea6..66c8e241db 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -29,6 +29,21 @@ rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
}
+int
+rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_process(roc_rvu_lf, vf, msg_id, req, req_len, rsp, rsp_len);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
index 9ee9c57d7d..cb8bced718 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
@@ -47,6 +47,35 @@ extern int cnxk_logtype_rvu_lf;
__rte_experimental
int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+/**
+ * Process a RVU mailbox message.
+ *
+ * Message request and response to be sent/received,
+ * need to be allocated/deallocated by application
+ * before/after processing the message.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param vf
+ * VF number(0 to N) in case of PF->VF message. 0 is valid as VF0.
+ * (For VF->PF message, this field is ignored)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request data to be sent
+ * @param req_len
+ * length of request data
+ * @param rsp
+ * pointer to message response expected to be received, NULL if no response
+ * @param rsp_len
+ * length of message response expected, 0 if no response
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len);
+
/**
* Signature of callback function called when a message process handler is called
* on RVU LF device.
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH 9/9] raw/cnxk_rvu_lf: add selftest
2024-09-07 19:33 [PATCH 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (7 preceding siblings ...)
2024-09-07 19:33 ` [PATCH 8/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
@ 2024-09-07 19:33 ` Akhil Goyal
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-09-07 19:33 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added raw device selftest for cnxk_rvu_lf to verify
various PMD APIs.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 18 ++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 137 +++++++++++++++++++++++++-
2 files changed, 154 insertions(+), 1 deletion(-)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7b321abd38..59f6506ebb 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -80,3 +80,21 @@ and provides an opaque pointer for a response and its length.
PF and VF application can define its own request and response based on the message id
of the mailbox.
For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``.
+
+Self test
+---------
+
+On EAL initialization RVU_LF devices will be probed and populated into
+the raw devices. The rawdev ID of the device can be obtained using invocation
+of ``rte_rawdev_get_dev_id("NAME:x")`` from the test application, where:
+
+- NAME is the desired subsystem: use "RVU_LF".
+- x is the device's bus id specified in "bus:device.func" (BDF) format. BDF follows convention
+ used by lspci i.e bus, device and func are specified using respectively two, two and one hex
+ digit(s).
+
+Use this identifier for further rawdev function calls.
+
+Selftest rawdev API can be used to verify the mailbox communication between
+PF and VF devices based applications. There can be multiple VFs for a particular PF.
+Each VF can send mailboxes to PF and PF can broadcast message to all VFs.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 66c8e241db..0c3dbdee9a 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -10,11 +10,146 @@
#include <rte_pci.h>
#include <rte_rawdev.h>
#include <rte_rawdev_pmd.h>
+#include <rte_hexdump.h>
#include <roc_api.h>
#include "rte_pmd_rvu_lf.h"
+#define PF 0
+#define VF 0
+#define RSP_LEN 64
+#define REQ_LEN 64
+#define MSG_ID_FROM 0x3000
+#define MSG_ID_TO 0x4000
+
+static int
+msg_process_notify_cb(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void **rsp, uint16_t *rsp_len)
+{
+ uint8_t *resp;
+ int i;
+
+ printf("\nReceived message(0x%x) from VF0x%x\n", msg_id, vf);
+ rte_hexdump(stdout, "req_data received", req, req_len);
+
+ resp = malloc(RSP_LEN);
+ if (resp == NULL)
+ return -ENOMEM;
+ for (i = 0; i < RSP_LEN; i++)
+ resp[i] = 0xB0;
+ *rsp = resp;
+ *rsp_len = RSP_LEN;
+ rte_hexdump(stdout, "rsp_data_filled", *rsp, RSP_LEN);
+
+ return 0;
+}
+
+static int
+rvu_lf_rawdev_selftest(uint16_t dev_id)
+{
+ char *dev_name = rte_rawdevs[dev_id].name;
+ uint8_t req[REQ_LEN] = {0};
+ uint8_t rsp[RSP_LEN] = {0};
+ unsigned int i, j;
+ uint16_t pf_func;
+ char *token[2];
+ int func, ret;
+
+ token[0] = strtok_r(dev_name, ".", &dev_name);
+ token[1] = strtok_r(dev_name, ".", &dev_name);
+ func = atoi(token[1]);
+
+ ret = rte_rawdev_start(dev_id);
+ if (ret)
+ return ret;
+
+ pf_func = rte_pmd_rvu_lf_npa_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "NPA pf_func is invalid");
+
+ pf_func = rte_pmd_rvu_lf_sso_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "SSO pf_func is invalid");
+
+ ret = rte_pmd_rvu_lf_msg_id_range_set(dev_id, MSG_ID_FROM, MSG_ID_TO);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message ID range invalid");
+ goto out;
+ }
+
+ ret = rte_pmd_rvu_lf_msg_handler_register(dev_id, msg_process_notify_cb);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message handler register failed, ret: %d", ret);
+ goto out;
+ }
+
+ if (func == 0) {
+ j = 50;
+ printf("\n");
+ while (j--) {
+ /* PF will wait for RVU message callbacks to be called */
+ rte_delay_ms(1000);
+ printf("PF waiting for VF messages for %d sec.\r", j);
+ }
+ /* PF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xC0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO.
+ * Messages sent with this id will be serviced by VF..
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ VF /* Send to VF0 */,
+ MSG_ID_FROM + 0x2,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf PF->VF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU PF->VF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("PF waiting for VF to exit for %d sec.\r", j);
+ }
+
+ } else {
+ /* VF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xA0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO
+ * Messages sent with this id will be serviced by PF and will
+ * not be forwarded to AF.
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ PF /* Send to PF */,
+ MSG_ID_FROM + 0x1,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf VF->PF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU VF->PF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("VF waiting for PF to send msg for %d sec.\r", j);
+ }
+ }
+unregister:
+ rte_pmd_rvu_lf_msg_handler_unregister(dev_id);
+out:
+ rte_rawdev_stop(dev_id);
+
+ return ret;
+}
+
int
rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
{
@@ -138,7 +273,7 @@ rte_pmd_rvu_lf_sso_pf_func_get(void)
}
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
- .dev_selftest = NULL,
+ .dev_selftest = rvu_lf_rawdev_selftest,
};
static void
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH 1/9] rawdev: add API to get device from index
2024-09-07 19:33 ` [PATCH 1/9] rawdev: add API to get device from index Akhil Goyal
@ 2024-09-23 15:23 ` Jerin Jacob
2024-10-08 7:40 ` [PATCH v2] " Akhil Goyal
1 sibling, 0 replies; 96+ messages in thread
From: Jerin Jacob @ 2024-09-23 15:23 UTC (permalink / raw)
To: Akhil Goyal; +Cc: dev, thomas, david.marchand, hemant.agrawal, jerinj, hkalra
On Sun, Sep 8, 2024 at 1:03 AM Akhil Goyal <gakhil@marvell.com> wrote:
>
> Added an internal API for PMDs to get raw device pointer
> from a device id.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
> lib/rawdev/rte_rawdev_pmd.h | 24 ++++++++++++++++++++++++
# This patch needs to go through the main tree. So please send this
separate patch and rest of the patch as separate series.
# verion.map update is missing for new API as INTERNAL section.
> 1 file changed, 24 insertions(+)
>
> diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h
> index 22b406444d..8339122348 100644
> --- a/lib/rawdev/rte_rawdev_pmd.h
> +++ b/lib/rawdev/rte_rawdev_pmd.h
> @@ -102,6 +102,30 @@ rte_rawdev_pmd_get_named_dev(const char *name)
> return NULL;
> }
>
> +/**
> + * Get the rte_rawdev structure device pointer for given device ID.
> + *
> + * @param dev_id
> + * raw device index.
> + *
> + * @return
> + * - The rte_rawdev structure pointer for the given device ID.
> + */
> +static inline struct rte_rawdev *
> +rte_rawdev_pmd_get_dev(uint8_t dev_id)
> +{
> + struct rte_rawdev *dev;
> +
> + if (dev_id >= RTE_RAWDEV_MAX_DEVS)
> + return NULL;
> +
> + dev = &rte_rawdevs[dev_id];
> + if (dev->attached == RTE_RAWDEV_ATTACHED)
> + return dev;
> +
> + return NULL;
> +}
> +
> /**
> * Validate if the raw device index is a valid attached raw device.
> *
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH 2/9] drivers/raw: introduce cnxk rvu lf device driver
2024-09-07 19:33 ` [PATCH 2/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
@ 2024-09-23 15:28 ` Jerin Jacob
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
1 sibling, 0 replies; 96+ messages in thread
From: Jerin Jacob @ 2024-09-23 15:28 UTC (permalink / raw)
To: Akhil Goyal; +Cc: dev, thomas, david.marchand, hemant.agrawal, jerinj, hkalra
On Sun, Sep 8, 2024 at 1:28 AM Akhil Goyal <gakhil@marvell.com> wrote:
>
> CNXK product families can have a use case to allow PF and VF
> applications to communicate using mailboxes and also get notified
> of any interrupt that may occur on the device.
> Hence, a new raw device driver is added for such RVU LF devices.
> These devices can map to a PF or a VF which can send mailboxes to
> each other.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright(C) 2024 Marvell.
> +#
> +
> +deps += ['bus_pci', 'common_cnxk', 'rawdev']
> +sources = files(
> + 'cnxk_rvu_lf.c',
> +)
> +require_iova_in_mbuf = false
> diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
> new file mode 100644
> index 0000000000..2d3cd032b7
> --- /dev/null
> +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h
> @@ -0,0 +1,39 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2024 Marvell.
> + */
> +
> +#ifndef _CNXK_RVU_LF_H_
> +#define _CNXK_RVU_LF_H_
> +
> +#include <stdint.h>
> +
> +#include <rte_common.h>
> +#include <rte_dev.h>
> +#include <rte_malloc.h>
> +#include <rte_memcpy.h>
> +#include <rte_rawdev.h>
Missing update to doc/api/doxy-api-index.md
> +
> +/**
> + * @file rte_pmd_rvu_lf.h
> + *
> + * Marvell RVU LF raw PMD specific structures and interface
> + *
> + * This API allows applications to manage RVU LF device in user space along with
> + * installing interrupt handlers for low latency signal processing.
> + */
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +extern int cnxk_logtype_rvu_lf;
Public symbol. Please add Doxygen symbol
> +
> +#define CNXK_RVU_LF_LOG(level, fmt, args...) \
Public symbol. Please add Doxygen symbol
> + rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
> + "%s(): " fmt "\n", __func__, ## args)
> +
Do we need to make this public symbols?
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v2] rawdev: add API to get device from index
2024-09-07 19:33 ` [PATCH 1/9] rawdev: add API to get device from index Akhil Goyal
2024-09-23 15:23 ` Jerin Jacob
@ 2024-10-08 7:40 ` Akhil Goyal
2024-10-08 11:59 ` David Marchand
` (2 more replies)
1 sibling, 3 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 7:40 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, Akhil Goyal
Added an internal API for PMDs to get raw device pointer
from a device id.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
- resend patch for main branch separated from rvu_lf raw driver
https://patches.dpdk.org/project/dpdk/list/?series=32949
lib/rawdev/rte_rawdev_pmd.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h
index 22b406444d..8339122348 100644
--- a/lib/rawdev/rte_rawdev_pmd.h
+++ b/lib/rawdev/rte_rawdev_pmd.h
@@ -102,6 +102,30 @@ rte_rawdev_pmd_get_named_dev(const char *name)
return NULL;
}
+/**
+ * Get the rte_rawdev structure device pointer for given device ID.
+ *
+ * @param dev_id
+ * raw device index.
+ *
+ * @return
+ * - The rte_rawdev structure pointer for the given device ID.
+ */
+static inline struct rte_rawdev *
+rte_rawdev_pmd_get_dev(uint8_t dev_id)
+{
+ struct rte_rawdev *dev;
+
+ if (dev_id >= RTE_RAWDEV_MAX_DEVS)
+ return NULL;
+
+ dev = &rte_rawdevs[dev_id];
+ if (dev->attached == RTE_RAWDEV_ATTACHED)
+ return dev;
+
+ return NULL;
+}
+
/**
* Validate if the raw device index is a valid attached raw device.
*
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v2 0/9] drivers/raw: introduce cnxk rvu lf device driver
2024-09-07 19:33 ` [PATCH 2/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-09-23 15:28 ` Jerin Jacob
@ 2024-10-08 10:54 ` Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 1/9] " Akhil Goyal
` (10 more replies)
1 sibling, 11 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 10:54 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
CNXK product families can have a use case to allow PF and VF
applications to communicate using mailboxes and also get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
The RVU LF device implements following features in the rawdev API:
- Register mailbox callbacks for the other side to process mailboxes.
- Register interrupt handler callbacks.
- Process mailbox.
- Set range of message IDs allowed for communication.
Depends-on: https://patches.dpdk.org/project/dpdk/patch/20241008074000.3745855-1-gakhil@marvell.com/
Changes in v2:
- removed library patch from series
- removed PMD logs from external PMD header.
- updated doc/api/doxy-api-index.md
- Added release notes
Akhil Goyal (9):
drivers/raw: introduce cnxk rvu lf device driver
raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc
raw/cnxk_rvu_lf: add PMD API to get BAR addresses
raw/cnxk_rvu_lf: register/unregister interrupt handler
raw/cnxk_rvu_lf: register/unregister msg handler
raw/cnxk_rvu_lf: set message ID range
raw/cnxk_rvu_lf: process mailbox message
raw/cnxk_rvu_lf: add selftest
raw/cnxk_rvu_lf: add PMD API to get device pffunc
MAINTAINERS | 6 +
doc/api/doxy-api-index.md | 1 +
doc/guides/rawdevs/cnxk_rvu_lf.rst | 100 +++++
doc/guides/rawdevs/index.rst | 1 +
doc/guides/rel_notes/release_24_11.rst | 5 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 3 +
drivers/common/cnxk/roc_dev.c | 118 +++++-
drivers/common/cnxk/roc_dev_priv.h | 7 +
drivers/common/cnxk/roc_idev.c | 46 ++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_mbox.h | 2 +
drivers/common/cnxk/roc_npa.c | 6 +
drivers/common/cnxk/roc_npa.h | 3 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 202 +++++++++
drivers/common/cnxk/roc_rvu_lf.h | 46 ++
drivers/common/cnxk/roc_rvu_lf_priv.h | 37 ++
drivers/common/cnxk/roc_sso.c | 6 +
drivers/common/cnxk/roc_sso.h | 3 +
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 16 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 399 ++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 222 ++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 10 +
drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 33 ++
drivers/raw/meson.build | 1 +
29 files changed, 1280 insertions(+), 6 deletions(-)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
create mode 100644 drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v2 1/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
@ 2024-10-08 10:54 ` Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
` (9 subsequent siblings)
10 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 10:54 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
CNXK product families can have a use case to allow PF and VF
applications to communicate using mailboxes and also get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
MAINTAINERS | 6 ++
doc/api/doxy-api-index.md | 1 +
doc/guides/rawdevs/cnxk_rvu_lf.rst | 40 +++++++++
doc/guides/rawdevs/index.rst | 1 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 3 +
drivers/common/cnxk/roc_dev_priv.h | 1 +
drivers/common/cnxk/roc_idev.c | 46 ++++++++++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 63 +++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 24 +++++
drivers/common/cnxk/roc_rvu_lf_priv.h | 32 +++++++
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 5 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 123 ++++++++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 35 ++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 9 ++
drivers/raw/meson.build | 1 +
21 files changed, 403 insertions(+)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
diff --git a/MAINTAINERS b/MAINTAINERS
index 812463fe9f..97e934edb0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1498,6 +1498,12 @@ T: git://dpdk.org/next/dpdk-next-net-mrvl
F: doc/guides/rawdevs/cnxk_gpio.rst
F: drivers/raw/cnxk_gpio/
+Marvell CNXK RVU LF
+M: Akhil Goyal <gakhil@marvell.com>
+T: git://dpdk.org/next/dpdk-next-net-mrvl
+F: doc/guides/rawdevs/cnxk_rvu_lf.rst
+F: drivers/raw/cnxk_rvu_lf/
+
NTB
M: Jingjing Wu <jingjing.wu@intel.com>
F: drivers/raw/ntb/
diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index f9f0300126..b4dbe51727 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -52,6 +52,7 @@ The public API headers are grouped by topics:
[cnxk_crypto](@ref rte_pmd_cnxk_crypto.h),
[cnxk_eventdev](@ref rte_pmd_cnxk_eventdev.h),
[cnxk_mempool](@ref rte_pmd_cnxk_mempool.h),
+ [cnxk_rvu_lf](@ref rte_pmd_cnxk_rvu_lf.h),
[dpaa](@ref rte_pmd_dpaa.h),
[dpaa2](@ref rte_pmd_dpaa2.h),
[mlx5](@ref rte_pmd_mlx5.h),
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
new file mode 100644
index 0000000000..8a0bc22dd5
--- /dev/null
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -0,0 +1,40 @@
+.. SPDX-License-Identifier: BSD-3-Clause
+ Copyright(c) 2024 Marvell.
+
+Marvell CNXK RVU LF Driver
+==========================
+
+CNXK product families can have a use case to allow PF and VF
+applications to communicate using mailboxes and also get notified
+of any interrupt that may occur on the device.
+Hence, a new raw device driver is added for such RVU LF devices.
+These devices can map to a PF or a VF which can send mailboxes to
+each other.
+
+Features
+--------
+
+The RVU LF device implements following features in the rawdev API:
+
+- Register mailbox callbacks for the other side to process mailboxes.
+- Register interrupt handler callbacks.
+- Process mailbox.
+- Set range of message IDs allowed for communication.
+
+Limitations
+-----------
+
+In multiprocess mode user-space application must ensure
+no resources sharing takes place.
+Otherwise, user-space application should ensure synchronization.
+
+Device Setup
+------------
+
+The RVU LF devices will need to be bound to a user-space IO driver for use.
+The script ``dpdk-devbind.py`` included with DPDK can be used to
+view the state of the devices and to bind them to a suitable DPDK-supported
+kernel driver. When querying the status of the devices, they will appear under
+the category of "Misc (rawdev) devices", i.e. the command
+``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
+devices alone.
diff --git a/doc/guides/rawdevs/index.rst b/doc/guides/rawdevs/index.rst
index f34315f051..8e07cf4d6c 100644
--- a/doc/guides/rawdevs/index.rst
+++ b/doc/guides/rawdevs/index.rst
@@ -13,6 +13,7 @@ application through rawdev API.
cnxk_bphy
cnxk_gpio
+ cnxk_rvu_lf
dpaa2_cmdif
ifpga
ntb
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index dc2ddf1f20..f847aa5d34 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -71,6 +71,7 @@ sources = files(
'roc_tim_irq.c',
'roc_utils.c',
'roc_ree.c',
+ 'roc_rvu_lf.c',
)
# Security common code
diff --git a/drivers/common/cnxk/roc_api.h b/drivers/common/cnxk/roc_api.h
index 6a86863c57..93e7bf11bb 100644
--- a/drivers/common/cnxk/roc_api.h
+++ b/drivers/common/cnxk/roc_api.h
@@ -120,4 +120,7 @@
/* Eswitch */
#include "roc_eswitch.h"
+/* RVU LF */
+#include "roc_rvu_lf.h"
+
#endif /* _ROC_API_H_ */
diff --git a/drivers/common/cnxk/roc_constants.h b/drivers/common/cnxk/roc_constants.h
index 0e7495a37c..67cd74b28a 100644
--- a/drivers/common/cnxk/roc_constants.h
+++ b/drivers/common/cnxk/roc_constants.h
@@ -45,6 +45,8 @@
#define PCI_DEVID_CNXK_RVU_REE_VF 0xA0f5
#define PCI_DEVID_CNXK_RVU_ESWITCH_PF 0xA0E0
#define PCI_DEVID_CNXK_RVU_ESWITCH_VF 0xA0E1
+#define PCI_DEVID_CNXK_RVU_BPHY_PF 0xA0E4
+#define PCI_DEVID_CNXK_RVU_BPHY_VF 0xA0E5
#define PCI_DEVID_CN9K_CGX 0xA059
#define PCI_DEVID_CN10K_RPM 0xA060
@@ -63,6 +65,7 @@
#define PCI_SUBSYSTEM_DEVID_CNF10KB 0xBC00
#define PCI_SUBSYSTEM_DEVID_CN20KA 0xA020
+#define PCI_SUBSYSTEM_DEVID_CNF20KA 0xA000
#define PCI_SUBSYSTEM_DEVID_CN9KA 0x0000
#define PCI_SUBSYSTEM_DEVID_CN9KB 0xb400
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index 5ab4f72f8f..dd4949b32c 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -141,6 +141,7 @@ struct dev {
void *roc_cpt;
void *roc_tim;
void *roc_ml;
+ void *roc_rvu_lf;
bool disable_shared_lmt; /* false(default): shared lmt mode enabled */
const struct plt_memzone *lmt_mz;
struct mbox_sync sync;
diff --git a/drivers/common/cnxk/roc_idev.c b/drivers/common/cnxk/roc_idev.c
index 0778d51d1e..84812f73e0 100644
--- a/drivers/common/cnxk/roc_idev.c
+++ b/drivers/common/cnxk/roc_idev.c
@@ -38,6 +38,7 @@ idev_set_defaults(struct idev_cfg *idev)
idev->num_lmtlines = 0;
idev->bphy = NULL;
idev->cpt = NULL;
+ TAILQ_INIT(&idev->rvu_lf_list);
TAILQ_INIT(&idev->mcs_list);
idev->nix_inl_dev = NULL;
TAILQ_INIT(&idev->roc_nix_list);
@@ -188,6 +189,51 @@ roc_idev_cpt_get(void)
return NULL;
}
+struct roc_rvu_lf *
+roc_idev_rvu_lf_get(uint8_t rvu_lf_idx)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf, &idev->rvu_lf_list, next) {
+ if (rvu_lf->idx == rvu_lf_idx)
+ return rvu_lf;
+ }
+ }
+
+ return NULL;
+}
+
+void
+roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ return;
+ }
+ TAILQ_INSERT_TAIL(&idev->rvu_lf_list, rvu, next);
+ }
+}
+
+void
+roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ TAILQ_REMOVE(&idev->rvu_lf_list, rvu, next);
+ }
+ }
+}
+
struct roc_mcs *
roc_idev_mcs_get(uint8_t mcs_idx)
{
diff --git a/drivers/common/cnxk/roc_idev.h b/drivers/common/cnxk/roc_idev.h
index fc0f7db54e..6edb5f83b2 100644
--- a/drivers/common/cnxk/roc_idev.h
+++ b/drivers/common/cnxk/roc_idev.h
@@ -29,4 +29,8 @@ uint16_t *__roc_api roc_idev_nix_rx_chan_base_get(void);
void __roc_api roc_idev_nix_rx_chan_set(uint16_t port, uint16_t chan);
uint16_t __roc_api roc_idev_nix_inl_dev_pffunc_get(void);
+
+struct roc_rvu_lf *__roc_api roc_idev_rvu_lf_get(uint8_t rvu_lf_idx);
+void __roc_api roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu);
+void __roc_api roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu);
#endif /* _ROC_IDEV_H_ */
diff --git a/drivers/common/cnxk/roc_idev_priv.h b/drivers/common/cnxk/roc_idev_priv.h
index 6628b18152..98b6286bfe 100644
--- a/drivers/common/cnxk/roc_idev_priv.h
+++ b/drivers/common/cnxk/roc_idev_priv.h
@@ -36,6 +36,7 @@ struct idev_cfg {
struct roc_bphy *bphy;
struct roc_cpt *cpt;
struct roc_sso *sso;
+ struct roc_rvu_lf_head rvu_lf_list;
struct roc_mcs_head mcs_list;
struct nix_inl_dev *nix_inl_dev;
struct idev_nix_inl_cfg inl_cfg;
diff --git a/drivers/common/cnxk/roc_priv.h b/drivers/common/cnxk/roc_priv.h
index 254a2d3310..8732a05ac3 100644
--- a/drivers/common/cnxk/roc_priv.h
+++ b/drivers/common/cnxk/roc_priv.h
@@ -53,4 +53,6 @@
/* ML */
#include "roc_ml_priv.h"
+/* RVU LF */
+#include "roc_rvu_lf_priv.h"
#endif /* _ROC_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
new file mode 100644
index 0000000000..1ae39e746e
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include "roc_api.h"
+#include "roc_priv.h"
+
+int
+roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct plt_pci_device *pci_dev;
+ struct dev *dev;
+ struct rvu_lf *rvu;
+ int rc;
+
+ if (roc_rvu_lf == NULL || roc_rvu_lf->pci_dev == NULL)
+ return RVU_ERR_PARAM;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ pci_dev = roc_rvu_lf->pci_dev;
+ dev = &rvu->dev;
+
+ if (rvu->dev.drv_inited)
+ return 0;
+
+ if (dev->mbox_active)
+ goto skip_dev_init;
+
+ memset(rvu, 0, sizeof(*rvu));
+
+ /* Initialize device */
+ rc = dev_init(dev, pci_dev);
+ if (rc) {
+ plt_err("Failed to init roc device");
+ goto fail;
+ }
+
+skip_dev_init:
+ dev->roc_rvu_lf = roc_rvu_lf;
+ rvu->pci_dev = pci_dev;
+
+ roc_idev_rvu_lf_set(roc_rvu_lf);
+ rvu->dev.drv_inited = true;
+
+ return 0;
+fail:
+ return rc;
+}
+
+int
+roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (rvu == NULL)
+ return NIX_ERR_PARAM;
+
+ rvu->dev.drv_inited = false;
+
+ roc_idev_rvu_lf_free(roc_rvu_lf);
+
+ return dev_fini(&rvu->dev, rvu->pci_dev);
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
new file mode 100644
index 0000000000..7ce8065a8b
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_H_
+#define _ROC_RVU_LF_H_
+
+#include "roc_platform.h"
+
+struct roc_rvu_lf {
+ TAILQ_ENTRY(roc_rvu_lf) next;
+ struct plt_pci_device *pci_dev;
+ uint8_t idx;
+#define ROC_RVU_MEM_SZ (6 * 1024)
+ uint8_t reserved[ROC_RVU_MEM_SZ] __plt_cache_aligned;
+};
+
+TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
+
+/* Dev */
+int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+
+#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
new file mode 100644
index 0000000000..8feff82961
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_PRIV_H_
+#define _ROC_RVU_LF_PRIV_H_
+
+enum rvu_err_status {
+ RVU_ERR_PARAM = -1,
+ RVU_ERR_NO_MEM = -2,
+};
+
+struct rvu_lf {
+ struct plt_pci_device *pci_dev;
+ struct dev dev;
+ uint16_t msg_id_from;
+ uint16_t msg_id_to;
+};
+
+static inline struct rvu_lf *
+roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
+{
+ return (struct rvu_lf *)&roc_rvu_lf->reserved[0];
+}
+
+static inline struct roc_rvu_lf *
+rvu_priv_to_roc_rvu_lf(struct rvu_lf *rvu_lf)
+{
+ return (struct roc_rvu_lf *)((char *)rvu_lf - offsetof(struct roc_rvu_lf, reserved));
+}
+
+#endif /* _ROC_RVU_LF_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_utils.c b/drivers/common/cnxk/roc_utils.c
index 9af2ae9b69..bcc0d2de38 100644
--- a/drivers/common/cnxk/roc_utils.c
+++ b/drivers/common/cnxk/roc_utils.c
@@ -17,11 +17,13 @@ roc_error_msg_get(int errorcode)
case NPC_ERR_PARAM:
case SSO_ERR_PARAM:
case MCS_ERR_PARAM:
+ case RVU_ERR_PARAM:
case UTIL_ERR_PARAM:
err_msg = "Invalid parameter";
break;
case NIX_ERR_NO_MEM:
case NPC_ERR_NO_MEM:
+ case RVU_ERR_NO_MEM:
err_msg = "Out of memory";
break;
case NIX_ERR_INVALID_RANGE:
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 6f8a2e02da..9f7c804542 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -118,6 +118,9 @@ INTERNAL {
roc_idev_nix_rx_chan_set;
roc_idev_nix_rx_inject_get;
roc_idev_nix_rx_inject_set;
+ roc_idev_rvu_lf_free;
+ roc_idev_rvu_lf_get;
+ roc_idev_rvu_lf_set;
roc_ml_reg_read64;
roc_ml_reg_write64;
roc_ml_reg_read32;
@@ -543,5 +546,7 @@ INTERNAL {
roc_ree_rule_db_get;
roc_ree_rule_db_len_get;
roc_ree_rule_db_prog;
+ roc_rvu_lf_dev_fini;
+ roc_rvu_lf_dev_init;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
new file mode 100644
index 0000000000..36067909be
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include <bus_pci_driver.h>
+#include <rte_common.h>
+#include <dev_driver.h>
+#include <rte_eal.h>
+#include <rte_lcore.h>
+#include <rte_pci.h>
+#include <rte_rawdev.h>
+#include <rte_rawdev_pmd.h>
+
+#include <roc_api.h>
+
+#include "cnxk_rvu_lf.h"
+
+static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
+ .dev_selftest = NULL,
+};
+
+static void
+rvu_lf_rawdev_get_name(char *name, struct rte_pci_device *pci_dev)
+{
+ snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "RVU LF:%02x:%02x.%x",
+ pci_dev->addr.bus, pci_dev->addr.devid,
+ pci_dev->addr.function);
+}
+
+static int
+rvu_lf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct rte_rawdev *rvu_lf_rawdev;
+ struct roc_rvu_lf *roc_rvu_lf;
+ int ret;
+
+ RTE_SET_USED(pci_drv);
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (!pci_dev->mem_resource[2].addr) {
+ CNXK_RVU_LF_LOG(ERR, "BARs have invalid values: BAR0 %p\n BAR2 %p",
+ pci_dev->mem_resource[2].addr, pci_dev->mem_resource[4].addr);
+ return -ENODEV;
+ }
+
+ ret = roc_plt_init();
+ if (ret)
+ return ret;
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rvu_lf_rawdev = rte_rawdev_pmd_allocate(name, sizeof(*roc_rvu_lf),
+ rte_socket_id());
+ if (rvu_lf_rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "Failed to allocate rawdev");
+ return -ENOMEM;
+ }
+
+ rvu_lf_rawdev->dev_ops = &rvu_lf_rawdev_ops;
+ rvu_lf_rawdev->device = &pci_dev->device;
+ rvu_lf_rawdev->driver_name = pci_dev->driver->driver.name;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rvu_lf_rawdev->dev_private;
+ roc_rvu_lf->pci_dev = pci_dev;
+
+ ret = roc_rvu_lf_dev_init(roc_rvu_lf);
+ if (ret) {
+ rte_rawdev_pmd_release(rvu_lf_rawdev);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int
+rvu_lf_remove(struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (pci_dev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid pci_dev");
+ return -EINVAL;
+ }
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rawdev = rte_rawdev_pmd_get_named_dev(name);
+ if (rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid device name (%s)", name);
+ return -EINVAL;
+ }
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+ roc_rvu_lf_dev_fini(roc_rvu_lf);
+
+ return rte_rawdev_pmd_release(rawdev);
+}
+
+static const struct rte_pci_id pci_rvu_lf_map[] = {
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_PF),
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_VF),
+ {
+ .vendor_id = 0,
+ },
+};
+
+static struct rte_pci_driver cnxk_rvu_lf_rawdev_pmd = {
+ .id_table = pci_rvu_lf_map,
+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
+ .probe = rvu_lf_probe,
+ .remove = rvu_lf_remove,
+};
+
+RTE_PMD_REGISTER_PCI(rvu_lf_rawdev_pci_driver, cnxk_rvu_lf_rawdev_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(rvu_lf_rawdev_pci_driver, pci_rvu_lf_map);
+RTE_PMD_REGISTER_KMOD_DEP(rvu_lf_rawdev_pci_driver, "vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_rvu_lf, rvu_lf, INFO);
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
new file mode 100644
index 0000000000..a23a629500
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _CNXK_RVU_LF_H_
+#define _CNXK_RVU_LF_H_
+
+#include <stdint.h>
+
+#include <rte_common.h>
+
+/**
+ * @file cnxk_rvu_lf.h
+ *
+ * Marvell RVU LF raw PMD specific internal structures
+ *
+ * This API allows applications to manage RVU LF device in user space along with
+ * installing interrupt handlers for low latency signal processing.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int cnxk_logtype_rvu_lf;
+
+#define CNXK_RVU_LF_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
+ "%s(): " fmt "\n", __func__, ## args)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CNXK_RVU_LF_H_ */
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
new file mode 100644
index 0000000000..32081e147f
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2024 Marvell.
+#
+
+deps += ['bus_pci', 'common_cnxk', 'rawdev']
+sources = files(
+ 'cnxk_rvu_lf.c',
+)
+require_iova_in_mbuf = false
diff --git a/drivers/raw/meson.build b/drivers/raw/meson.build
index 05cad143fe..54221643d5 100644
--- a/drivers/raw/meson.build
+++ b/drivers/raw/meson.build
@@ -8,6 +8,7 @@ endif
drivers = [
'cnxk_bphy',
'cnxk_gpio',
+ 'cnxk_rvu_lf',
'dpaa2_cmdif',
'ifpga',
'ntb',
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v2 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 1/9] " Akhil Goyal
@ 2024-10-08 10:54 ` Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
` (8 subsequent siblings)
10 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 10:54 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added rte_pmd_rvu_lf_npa_pf_func_get and
rte_pmd_rvu_lf_sso_pf_func_get APIs to get NPA and
SSO pffunc for the application use.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 ++++
drivers/common/cnxk/roc_npa.c | 6 ++++
drivers/common/cnxk/roc_npa.h | 3 ++
drivers/common/cnxk/roc_sso.c | 6 ++++
drivers/common/cnxk/roc_sso.h | 3 ++
drivers/common/cnxk/version.map | 2 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 12 +++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 18 ++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 1 +
drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 33 +++++++++++++++++++
10 files changed, 91 insertions(+)
create mode 100644 drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 8a0bc22dd5..13184ad4dc 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -38,3 +38,10 @@ kernel driver. When querying the status of the devices, they will appear under
the category of "Misc (rawdev) devices", i.e. the command
``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
devices alone.
+
+Get NPA and SSO PF FUNC
+-----------------------
+
+APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
+can be used to get the cnxk NPA PF func and SSO PF func which application
+can use for NPA/SSO specific configuration.
diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index 934d7361a9..a33f9a8499 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -17,6 +17,12 @@ roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb)
return 0;
}
+uint16_t
+roc_npa_pf_func_get(void)
+{
+ return idev_npa_pffunc_get();
+}
+
void
roc_npa_pool_op_range_set(uint64_t aura_handle, uint64_t start_iova,
uint64_t end_iova)
diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h
index fbf75b2fca..f7cb4460e7 100644
--- a/drivers/common/cnxk/roc_npa.h
+++ b/drivers/common/cnxk/roc_npa.h
@@ -820,6 +820,9 @@ int __roc_api roc_npa_aura_bp_configure(uint64_t aura_id, uint16_t bpid, uint8_t
typedef int (*roc_npa_lf_init_cb_t)(struct plt_pci_device *pci_dev);
int __roc_api roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb);
+/* Utility functions */
+uint16_t __roc_api roc_npa_pf_func_get(void);
+
/* Debug */
int __roc_api roc_npa_ctx_dump(void);
int __roc_api roc_npa_dump(void);
diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c
index 2e3b134bfc..aed8819a1b 100644
--- a/drivers/common/cnxk/roc_sso.c
+++ b/drivers/common/cnxk/roc_sso.c
@@ -319,6 +319,12 @@ roc_sso_hwgrp_base_get(struct roc_sso *roc_sso, uint16_t hwgrp)
return dev->bar2 + (RVU_BLOCK_ADDR_SSO << 20 | hwgrp << 12);
}
+uint16_t
+roc_sso_pf_func_get(void)
+{
+ return idev_sso_pffunc_get();
+}
+
uint64_t
roc_sso_ns_to_gw(uint64_t base, uint64_t ns)
{
diff --git a/drivers/common/cnxk/roc_sso.h b/drivers/common/cnxk/roc_sso.h
index 4ac901762e..3e293a0a69 100644
--- a/drivers/common/cnxk/roc_sso.h
+++ b/drivers/common/cnxk/roc_sso.h
@@ -103,6 +103,9 @@ int __roc_api roc_sso_hwgrp_stash_config(struct roc_sso *roc_sso,
void __roc_api roc_sso_hws_gwc_invalidate(struct roc_sso *roc_sso, uint8_t *hws,
uint8_t nb_hws);
+/* Utility function */
+uint16_t __roc_api roc_sso_pf_func_get(void);
+
/* Debug */
void __roc_api roc_sso_dump(struct roc_sso *roc_sso, uint8_t nb_hws,
uint16_t hwgrp, FILE *f);
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 9f7c804542..dd56caef16 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -451,6 +451,7 @@ INTERNAL {
roc_npa_dev_unlock;
roc_npa_dump;
roc_npa_lf_init_cb_register;
+ roc_npa_pf_func_get;
roc_npa_pool_create;
roc_npa_pool_destroy;
roc_npa_pool_op_pc_reset;
@@ -518,6 +519,7 @@ INTERNAL {
roc_sso_hws_gwc_invalidate;
roc_sso_hws_unlink;
roc_sso_ns_to_gw;
+ roc_sso_pf_func_get;
roc_sso_rsrc_fini;
roc_sso_rsrc_init;
roc_tim_fini;
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 36067909be..7285059cdd 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -15,6 +15,18 @@
#include "cnxk_rvu_lf.h"
+uint16_t
+rte_pmd_rvu_lf_npa_pf_func_get(void)
+{
+ return roc_npa_pf_func_get();
+}
+
+uint16_t
+rte_pmd_rvu_lf_sso_pf_func_get(void)
+{
+ return roc_sso_pf_func_get();
+}
+
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
.dev_selftest = NULL,
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
index a23a629500..25da50caa2 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -28,6 +28,24 @@ extern int cnxk_logtype_rvu_lf;
rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
"%s(): " fmt "\n", __func__, ## args)
+/**
+ * Obtain NPA PF func
+ *
+ * @return
+ * Returns NPA pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_experimental
+uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
+
+/**
+ * Obtain SSO PF func
+ *
+ * @return
+ * Returns SSO pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_experimental
+uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
index 32081e147f..a1a010319b 100644
--- a/drivers/raw/cnxk_rvu_lf/meson.build
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -6,4 +6,5 @@ deps += ['bus_pci', 'common_cnxk', 'rawdev']
sources = files(
'cnxk_rvu_lf.c',
)
+headers = files('rte_pmd_cnxk_rvu_lf.h')
require_iova_in_mbuf = false
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
new file mode 100644
index 0000000000..e7e415f11f
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _CNXK_RVU_LF_H_
+#define _CNXK_RVU_LF_H_
+
+#include <stdint.h>
+
+#include <rte_common.h>
+#include <rte_dev.h>
+#include <rte_malloc.h>
+#include <rte_memcpy.h>
+#include <rte_rawdev.h>
+
+/**
+ * @file rte_pmd_cnxk_rvu_lf.h
+ *
+ * Marvell RVU LF raw PMD specific structures and interface
+ *
+ * This API allows applications to manage RVU LF device in user space along with
+ * installing interrupt handlers for low latency signal processing.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CNXK_RVU_LF_H_ */
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v2 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 1/9] " Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
@ 2024-10-08 10:54 ` Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 4/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
` (7 subsequent siblings)
10 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 10:54 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added rte_pmd_rvu_lf_bar_get() API to get BAR address
for application to configure hardware.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 +++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 23 +++++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 18 ++++++++++++++++++
3 files changed, 48 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 13184ad4dc..6dfbd466ad 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -45,3 +45,10 @@ Get NPA and SSO PF FUNC
APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
can be used to get the cnxk NPA PF func and SSO PF func which application
can use for NPA/SSO specific configuration.
+
+Get BAR addresses
+-----------------
+
+Application can retrieve PCI BAR addresses of the device using the API
+``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the
+registers of the hardware device.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 7285059cdd..bbcf33017d 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -15,6 +15,29 @@
#include "cnxk_rvu_lf.h"
+int
+rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask)
+{
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+ if (bar_num > PCI_MAX_RESOURCE ||
+ (roc_rvu_lf->pci_dev->mem_resource[bar_num].addr == NULL)) {
+ *va = 0;
+ *mask = 0;
+ return -ENOTSUP;
+ }
+ *va = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].addr);
+ *mask = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].len - 1);
+
+ return 0;
+}
+
uint16_t
rte_pmd_rvu_lf_npa_pf_func_get(void)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
index 25da50caa2..1f4dd135e1 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -46,6 +46,24 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
__rte_experimental
uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+/**
+ * Get BAR addresses for the RVU LF device.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param bar_num
+ * BAR number for which address is required
+ * @param[out] va
+ * Virtual address of the BAR. 0 if not mapped
+ * @param[out] mask
+ * BAR address mask, 0 if not mapped
+ *
+ * @return
+ * Returns 0 on success, negative error code otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask);
+
#ifdef __cplusplus
}
#endif
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v2 4/9] raw/cnxk_rvu_lf: register/unregister interrupt handler
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
` (2 preceding siblings ...)
2024-10-08 10:54 ` [PATCH v2 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
@ 2024-10-08 10:54 ` Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 5/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
` (6 subsequent siblings)
10 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 10:54 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD API rte_pmd_rvu_lf_irq_register() and
rte_pmd_rvu_lf_irq_unregister() to register/unregister
interrupt handlers for rvu lf raw device.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 +++++
drivers/common/cnxk/roc_rvu_lf.c | 26 +++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 +++
drivers/common/cnxk/version.map | 2 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 30 +++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 46 +++++++++++++++++++++++++++
6 files changed, 117 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 6dfbd466ad..7bae6b523e 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -52,3 +52,11 @@ Get BAR addresses
Application can retrieve PCI BAR addresses of the device using the API
``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the
registers of the hardware device.
+
+Register or remove interrupt handler
+------------------------------------
+
+Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register()``
+or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
+The irq numbers for which the interrupts are registered is negotiated separately
+and is not in scope of the driver.
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1ae39e746e..63bc149f2a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -61,3 +61,29 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+
+int
+roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ return dev_irq_register(handle, (plt_intr_callback_fn)cb, data, irq);
+}
+
+int
+roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ dev_irq_unregister(handle, (plt_intr_callback_fn)cb, data, irq);
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7ce8065a8b..800bf4e674 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,4 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index dd56caef16..2c845cd591 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -550,5 +550,7 @@ INTERNAL {
roc_ree_rule_db_prog;
roc_rvu_lf_dev_fini;
roc_rvu_lf_dev_init;
+ roc_rvu_lf_irq_register;
+ roc_rvu_lf_irq_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index bbcf33017d..7c1b96b824 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -15,6 +15,36 @@
#include "cnxk_rvu_lf.h"
+int
+rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_register(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
+int
+rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_unregister(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
int
rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
index 1f4dd135e1..87a8079921 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -28,6 +28,52 @@ extern int cnxk_logtype_rvu_lf;
rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
"%s(): " fmt "\n", __func__, ## args)
+/**
+ * Signature of callback function called when an interrupt is received on RVU LF device.
+ *
+ * @param cb_arg
+ * pointer to the information received on an interrupt
+ */
+typedef void (*rte_pmd_rvu_lf_intr_callback_fn)(void *cb_arg);
+
+/**
+ * Register interrupt callback
+ *
+ * Registers an interrupt callback to be executed when interrupt is raised.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number for which interrupt will be raised
+ * @param cb
+ * callback function to be executed
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
+/**
+ * Unregister interrupt callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number
+ * @param cb
+ * callback function registered
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
/**
* Obtain NPA PF func
*
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v2 5/9] raw/cnxk_rvu_lf: register/unregister msg handler
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
` (3 preceding siblings ...)
2024-10-08 10:54 ` [PATCH v2 4/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
@ 2024-10-08 10:54 ` Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 6/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
` (5 subsequent siblings)
10 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 10:54 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD APIs rte_pmd_rvu_lf_msg_handler_register()
and rte_pmd_rvu_lf_msg_handler_unregister() to register/unregister
mailbox message handlers. These handlers are needed to fill
response at the other side for the request sent from one side.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
drivers/common/cnxk/roc_dev_priv.h | 6 ++++
drivers/common/cnxk/roc_rvu_lf.c | 25 ++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 7 ++++
drivers/common/cnxk/version.map | 2 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 28 +++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 49 +++++++++++++++++++++++++++
6 files changed, 117 insertions(+)
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index dd4949b32c..c766183196 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -46,11 +46,17 @@ typedef void (*link_status_get_t)(void *roc_nix,
/* Representee notification callback */
typedef int (*repte_notify_t)(void *roc_nix, void *notify_msg);
+/* RVU Message process callback */
+typedef int (*msg_process_cb_t)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
struct dev_ops {
link_info_t link_status_update;
ptp_info_t ptp_info_update;
link_status_get_t link_status_get;
q_err_cb_t q_err_cb;
+ msg_process_cb_t msg_process_cb;
repte_notify_t repte_notify;
};
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 63bc149f2a..2e1be81e52 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -87,3 +87,28 @@ roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
return 0;
}
+
+int
+roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf, roc_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ if (cb == NULL)
+ return -EINVAL;
+
+ dev->ops->msg_process_cb = (msg_process_cb_t)cb;
+
+ return 0;
+}
+
+int
+roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ dev->ops->msg_process_cb = NULL;
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 800bf4e674..90a0b5690a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -22,8 +22,15 @@ int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf,
+ roc_rvu_lf_msg_handler_cb_fn cb);
+int __roc_api roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 2c845cd591..f3c48ae3cb 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -552,5 +552,7 @@ INTERNAL {
roc_rvu_lf_dev_init;
roc_rvu_lf_irq_register;
roc_rvu_lf_irq_unregister;
+ roc_rvu_lf_msg_handler_register;
+ roc_rvu_lf_msg_handler_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 7c1b96b824..0f02b648e0 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -15,6 +15,34 @@
#include "cnxk_rvu_lf.h"
+int
+rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_register(roc_rvu_lf, (roc_rvu_lf_msg_handler_cb_fn)cb);
+}
+
+int
+rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_unregister(roc_rvu_lf);
+}
+
int
rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
index 87a8079921..b6f125de33 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -28,6 +28,55 @@ extern int cnxk_logtype_rvu_lf;
rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
"%s(): " fmt "\n", __func__, ## args)
+/**
+ * Signature of callback function called when a message process handler is called
+ * on RVU LF device.
+ *
+ * @param vf
+ * VF number(0 to N) from which message is received (ignored in case of PF)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request
+ * @param req_len
+ * pointer to message request
+ * @param[out] rsp
+ * pointer to message response
+ * @param[out] rsp_len
+ * length of message response
+ *
+ * @return 0 when response is set, negative value otherwise
+ */
+typedef int (*rte_pmd_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
+/**
+ * Register message handler callback
+ *
+ * Registers message handler callback to be executed when the message is received from peer.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param cb
+ * callback function to be executed
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb);
+
+/**
+ * Unregister message handler callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
+
/**
* Signature of callback function called when an interrupt is received on RVU LF device.
*
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v2 6/9] raw/cnxk_rvu_lf: set message ID range
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
` (4 preceding siblings ...)
2024-10-08 10:54 ` [PATCH v2 5/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
@ 2024-10-08 10:54 ` Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 7/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
` (4 subsequent siblings)
10 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 10:54 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD API rte_pmd_rvu_lf_msg_id_range_set()
to set RVU mailbox message id range.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 12 +++++++++++
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 30 +++++++++++++++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 3 +++
drivers/common/cnxk/version.map | 2 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 14 +++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 15 ++++++++++++++
7 files changed, 77 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7bae6b523e..7f193e232c 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -60,3 +60,15 @@ Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register(
or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
The irq numbers for which the interrupts are registered is negotiated separately
and is not in scope of the driver.
+
+RVU LF RAW MESSAGE PROCESSING
+-----------------------------
+
+Once a RVU LF raw device is probed, a range of message ids can be configured for
+which mailboxes will be sent using the API ``rte_pmd_rvu_lf_msg_id_range_set``.
+
+For processing of mailboxes received on PF/VF application, application
+can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()``
+and fill required responses as per the request and message id received.
+Application can also unregister already registered message callbacks using
+``rte_pmd_rvu_lf_msg_handler_unregister()``.
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index dd65946e9e..f8791e9f84 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -54,6 +54,7 @@ struct mbox_msghdr {
#define MBOX_MSG_MASK 0xFFFF
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
+#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 2e1be81e52..1026ccc125 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,36 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+int
+roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (from <= MBOX_MSG_GENERIC_MAX_ID || from > to)
+ return -EINVAL;
+
+ rvu->msg_id_from = from;
+ rvu->msg_id_to = to;
+
+ return 0;
+}
+
+bool
+roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
+{
+ struct rvu_lf *rvu;
+
+ if (roc_rvu_lf == NULL)
+ return 0;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (msg_id > rvu->msg_id_from && msg_id < rvu->msg_id_to)
+ return 1;
+
+ return 0;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 90a0b5690a..7243e170b9 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t from, uint16_t to);
+bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
void *req, uint16_t req_len,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index f3c48ae3cb..ed390b8575 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -554,5 +554,7 @@ INTERNAL {
roc_rvu_lf_irq_unregister;
roc_rvu_lf_msg_handler_register;
roc_rvu_lf_msg_handler_unregister;
+ roc_rvu_lf_msg_id_range_check;
+ roc_rvu_lf_msg_id_range_set;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 0f02b648e0..0815e9e6b8 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -15,6 +15,20 @@
#include "cnxk_rvu_lf.h"
+int
+rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
index b6f125de33..04a519b49a 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -28,6 +28,21 @@ extern int cnxk_logtype_rvu_lf;
rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
"%s(): " fmt "\n", __func__, ## args)
+/**
+ * Set RVU mailbox message id range.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param from
+ * starting message id for RVU mailbox (> 0x1FF)
+ * @param to
+ * last message id for RVU mailbox (< 0xFFFF)
+ *
+ * @return 0 on success, -EINVAL for invalid range
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+
/**
* Signature of callback function called when a message process handler is called
* on RVU LF device.
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v2 7/9] raw/cnxk_rvu_lf: process mailbox message
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
` (5 preceding siblings ...)
2024-10-08 10:54 ` [PATCH v2 6/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
@ 2024-10-08 10:54 ` Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 8/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
` (3 subsequent siblings)
10 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 10:54 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD API rte_pmd_rvu_lf_msg_process() to process
mailbox messages between rvu_lf devices.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 ++
doc/guides/rel_notes/release_24_11.rst | 5 ++
drivers/common/cnxk/roc_dev.c | 118 +++++++++++++++++++++++--
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 58 ++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 ++
drivers/common/cnxk/roc_rvu_lf_priv.h | 5 ++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 15 ++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 29 ++++++
10 files changed, 240 insertions(+), 6 deletions(-)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7f193e232c..7b321abd38 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -72,3 +72,11 @@ can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()``
and fill required responses as per the request and message id received.
Application can also unregister already registered message callbacks using
``rte_pmd_rvu_lf_msg_handler_unregister()``.
+
+A PMD API ``rte_pmd_rvu_lf_msg_process()`` is created to send a request and
+receive corresponding response from the other side(PF/VF).
+It accepts an opaque pointer of a request and its size which can be defined by application
+and provides an opaque pointer for a response and its length.
+PF and VF application can define its own request and response based on the message id
+of the mailbox.
+For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``.
diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst
index b2bd442ee1..dadf058278 100644
--- a/doc/guides/rel_notes/release_24_11.rst
+++ b/doc/guides/rel_notes/release_24_11.rst
@@ -75,6 +75,11 @@ New Features
* Added ethdev driver support for CN20K SoC.
+* **Added Marvell cnxk RVU LF rawdev driver.**
+
+ Added a new raw device driver for Marvell cnxk based devices to allow
+ applications to communicate using mailboxes and notify for the interrupts.
+
Removed Items
-------------
diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index c905d35ea6..cb8d5d03fd 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -218,6 +218,51 @@ af_pf_wait_msg(struct dev *dev, uint16_t vf, int num_msg)
return req_hdr->num_msgs;
}
+static int
+process_rvu_lf_msgs(struct dev *dev, uint16_t vf, struct mbox_msghdr *msg, size_t size)
+{
+ uint16_t max_bits = sizeof(dev->active_vfs[0]) * 8;
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Handle BPHY mailbox message in PF */
+ dev->active_vfs[vf / max_bits] |= BIT_ULL(vf % max_bits);
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -1;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", vf);
+ return -1;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_vfpf, vf,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", vf);
+ return -1;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ free(resp);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return 0;
+}
+
/* PF receives mbox DOWN messages from VF and forwards to AF */
static int
vf_pf_process_msgs(struct dev *dev, uint16_t vf)
@@ -264,6 +309,9 @@ vf_pf_process_msgs(struct dev *dev, uint16_t vf)
/* PF/VF function ID */
rsp->hdr.pcifunc = msg->pcifunc;
rsp->hdr.rc = 0;
+ } else if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ if (process_rvu_lf_msgs(dev, vf, msg, size) < 0)
+ continue;
} else {
struct mbox_msghdr *af_req;
/* Reserve AF/PF mbox message */
@@ -342,8 +390,13 @@ vf_pf_process_up_msgs(struct dev *dev, uint16_t vf)
dev_get_vf(msg->pcifunc));
break;
default:
- plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
- msg->id, mbox_id2name(msg->id), msg->pcifunc);
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id))
+ plt_base_dbg("PF: Msg 0x%x fn:0x%x (pf:%d,vf:%d)",
+ msg->id, msg->pcifunc, dev_get_pf(msg->pcifunc),
+ dev_get_vf(msg->pcifunc));
+ else
+ plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
+ msg->id, mbox_id2name(msg->id), msg->pcifunc);
}
offset = mbox->rx_start + msg->next_msgoff;
}
@@ -792,6 +845,50 @@ mbox_process_msgs_up(struct dev *dev, struct mbox_msghdr *req)
return -ENODEV;
}
+static int
+process_rvu_lf_msgs_up(struct dev *dev, struct mbox_msghdr *msg, size_t size)
+{
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Check if valid, if not reply with an invalid msg */
+ if (msg->sig != MBOX_REQ_SIG)
+ return -EIO;
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -ENOMEM;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", dev->vf);
+ return rc;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_up, 0,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", dev->vf);
+ return -ENOMEM;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ free(resp);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return rc;
+}
+
/* Received up messages from AF (PF context) / PF (in context) */
static void
process_msgs_up(struct dev *dev, struct mbox *mbox)
@@ -800,6 +897,7 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
struct mbox_hdr *req_hdr;
struct mbox_msghdr *msg;
int i, err, offset;
+ size_t size;
req_hdr = (struct mbox_hdr *)((uintptr_t)mdev->mbase + mbox->rx_start);
if (req_hdr->num_msgs == 0)
@@ -812,10 +910,17 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
plt_base_dbg("Message 0x%x (%s) pf:%d/vf:%d", msg->id,
mbox_id2name(msg->id), dev_get_pf(msg->pcifunc),
dev_get_vf(msg->pcifunc));
- err = mbox_process_msgs_up(dev, msg);
- if (err)
- plt_err("Error %d handling 0x%x (%s)", err, msg->id,
- mbox_id2name(msg->id));
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ size = mbox->rx_start + msg->next_msgoff - offset;
+ err = process_rvu_lf_msgs_up(dev, msg, size);
+ if (err)
+ plt_err("Error %d handling 0x%x RVU_LF up msg", err, msg->id);
+ } else {
+ err = mbox_process_msgs_up(dev, msg);
+ if (err)
+ plt_err("Error %d handling 0x%x (%s)", err, msg->id,
+ mbox_id2name(msg->id));
+ }
offset = mbox->rx_start + msg->next_msgoff;
}
/* Send mbox responses */
@@ -1304,6 +1409,7 @@ dev_vf_hwcap_update(struct plt_pci_device *pci_dev, struct dev *dev)
case PCI_DEVID_CNXK_RVU_VF:
case PCI_DEVID_CNXK_RVU_SDP_VF:
case PCI_DEVID_CNXK_RVU_NIX_INL_VF:
+ case PCI_DEVID_CNXK_RVU_BPHY_VF:
case PCI_DEVID_CNXK_RVU_ESWITCH_VF:
dev->hwcap |= DEV_HWCAP_F_VF;
break;
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index f8791e9f84..4518680684 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -55,6 +55,7 @@ struct mbox_msghdr {
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
+#define MBOX_MSG_REQ_SIZE_MAX (16 * 1024)
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1026ccc125..471dfa7a46 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,15 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+static uint16_t
+roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ return dev->pf_func;
+}
+
int
roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
{
@@ -92,6 +101,55 @@ roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
return 0;
}
+int
+roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf, uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len, void *rsp_data, uint16_t rsp_len)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct mbox *mbox;
+ struct rvu_lf_msg *req;
+ struct rvu_lf_msg *rsp;
+ int rc = -ENOSPC;
+ int devid = 0;
+
+ if (rvu->dev.vf == -1 && roc_rvu_lf_msg_id_range_check(roc_rvu_lf, msg_id)) {
+ /* This is PF context */
+ if (vf >= rvu->dev.maxvf)
+ return -EINVAL;
+ devid = vf;
+ mbox = mbox_get(&rvu->dev.mbox_vfpf_up);
+ } else {
+ /* This is VF context */
+ devid = 0; /* VF send all message to PF */
+ mbox = mbox_get(rvu->dev.mbox);
+ }
+ req = (struct rvu_lf_msg *)mbox_alloc_msg_rsp(mbox, devid,
+ req_len + sizeof(struct rvu_lf_msg),
+ rsp_len + sizeof(struct rvu_lf_msg));
+ if (!req)
+ goto fail;
+ mbox_memcpy(req->data, req_data, req_len);
+ req->hdr.sig = MBOX_REQ_SIG;
+ req->hdr.id = msg_id;
+ req->hdr.pcifunc = roc_rvu_lf_pf_func_get(roc_rvu_lf);
+
+ if (rvu->dev.vf == -1) {
+ mbox_msg_send_up(mbox, devid);
+ rc = mbox_get_rsp(mbox, devid, (void *)&rsp);
+ if (rc)
+ goto fail;
+ } else {
+ rc = mbox_process_msg(mbox, (void *)&rsp);
+ if (rc)
+ goto fail;
+ }
+ if (rsp_len && rsp_data != NULL)
+ mbox_memcpy(rsp_data, rsp->data, rsp_len);
+fail:
+ mbox_put(mbox);
+ return rc;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7243e170b9..6b4819666a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,11 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len,
+ void *rsp_data, uint16_t rsp_len);
+
int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
uint16_t from, uint16_t to);
bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
index 8feff82961..57bb713b21 100644
--- a/drivers/common/cnxk/roc_rvu_lf_priv.h
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -17,6 +17,11 @@ struct rvu_lf {
uint16_t msg_id_to;
};
+struct rvu_lf_msg {
+ struct mbox_msghdr hdr;
+ uint8_t data[];
+};
+
static inline struct rvu_lf *
roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
{
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index ed390b8575..cd177a7920 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -556,5 +556,7 @@ INTERNAL {
roc_rvu_lf_msg_handler_unregister;
roc_rvu_lf_msg_id_range_check;
roc_rvu_lf_msg_id_range_set;
+ roc_rvu_lf_msg_process;
+
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 0815e9e6b8..7cffb85e76 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -29,6 +29,21 @@ rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
}
+int
+rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_process(roc_rvu_lf, vf, msg_id, req, req_len, rsp, rsp_len);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
index 04a519b49a..ef6b427544 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -43,6 +43,35 @@ extern int cnxk_logtype_rvu_lf;
__rte_experimental
int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+/**
+ * Process a RVU mailbox message.
+ *
+ * Message request and response to be sent/received,
+ * need to be allocated/deallocated by application
+ * before/after processing the message.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param vf
+ * VF number(0 to N) in case of PF->VF message. 0 is valid as VF0.
+ * (For VF->PF message, this field is ignored)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request data to be sent
+ * @param req_len
+ * length of request data
+ * @param rsp
+ * pointer to message response expected to be received, NULL if no response
+ * @param rsp_len
+ * length of message response expected, 0 if no response
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len);
+
/**
* Signature of callback function called when a message process handler is called
* on RVU LF device.
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v2 8/9] raw/cnxk_rvu_lf: add selftest
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
` (6 preceding siblings ...)
2024-10-08 10:54 ` [PATCH v2 7/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
@ 2024-10-08 10:54 ` Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 9/9] raw/cnxk_rvu_lf: add PMD API to get device pffunc Akhil Goyal
` (2 subsequent siblings)
10 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 10:54 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added raw device selftest for cnxk_rvu_lf to verify
various PMD APIs.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 18 ++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 137 +++++++++++++++++++++++++-
2 files changed, 154 insertions(+), 1 deletion(-)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7b321abd38..59f6506ebb 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -80,3 +80,21 @@ and provides an opaque pointer for a response and its length.
PF and VF application can define its own request and response based on the message id
of the mailbox.
For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``.
+
+Self test
+---------
+
+On EAL initialization RVU_LF devices will be probed and populated into
+the raw devices. The rawdev ID of the device can be obtained using invocation
+of ``rte_rawdev_get_dev_id("NAME:x")`` from the test application, where:
+
+- NAME is the desired subsystem: use "RVU_LF".
+- x is the device's bus id specified in "bus:device.func" (BDF) format. BDF follows convention
+ used by lspci i.e bus, device and func are specified using respectively two, two and one hex
+ digit(s).
+
+Use this identifier for further rawdev function calls.
+
+Selftest rawdev API can be used to verify the mailbox communication between
+PF and VF devices based applications. There can be multiple VFs for a particular PF.
+Each VF can send mailboxes to PF and PF can broadcast message to all VFs.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 7cffb85e76..82773a2988 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -10,11 +10,146 @@
#include <rte_pci.h>
#include <rte_rawdev.h>
#include <rte_rawdev_pmd.h>
+#include <rte_hexdump.h>
#include <roc_api.h>
#include "cnxk_rvu_lf.h"
+#define PF 0
+#define VF 0
+#define RSP_LEN 64
+#define REQ_LEN 64
+#define MSG_ID_FROM 0x3000
+#define MSG_ID_TO 0x4000
+
+static int
+msg_process_notify_cb(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void **rsp, uint16_t *rsp_len)
+{
+ uint8_t *resp;
+ int i;
+
+ printf("\nReceived message(0x%x) from VF0x%x\n", msg_id, vf);
+ rte_hexdump(stdout, "req_data received", req, req_len);
+
+ resp = malloc(RSP_LEN);
+ if (resp == NULL)
+ return -ENOMEM;
+ for (i = 0; i < RSP_LEN; i++)
+ resp[i] = 0xB0;
+ *rsp = resp;
+ *rsp_len = RSP_LEN;
+ rte_hexdump(stdout, "rsp_data_filled", *rsp, RSP_LEN);
+
+ return 0;
+}
+
+static int
+rvu_lf_rawdev_selftest(uint16_t dev_id)
+{
+ char *dev_name = rte_rawdevs[dev_id].name;
+ uint8_t req[REQ_LEN] = {0};
+ uint8_t rsp[RSP_LEN] = {0};
+ unsigned int i, j;
+ uint16_t pf_func;
+ char *token[2];
+ int func, ret;
+
+ token[0] = strtok_r(dev_name, ".", &dev_name);
+ token[1] = strtok_r(dev_name, ".", &dev_name);
+ func = atoi(token[1]);
+
+ ret = rte_rawdev_start(dev_id);
+ if (ret)
+ return ret;
+
+ pf_func = rte_pmd_rvu_lf_npa_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "NPA pf_func is invalid");
+
+ pf_func = rte_pmd_rvu_lf_sso_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "SSO pf_func is invalid");
+
+ ret = rte_pmd_rvu_lf_msg_id_range_set(dev_id, MSG_ID_FROM, MSG_ID_TO);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message ID range invalid");
+ goto out;
+ }
+
+ ret = rte_pmd_rvu_lf_msg_handler_register(dev_id, msg_process_notify_cb);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message handler register failed, ret: %d", ret);
+ goto out;
+ }
+
+ if (func == 0) {
+ j = 50;
+ printf("\n");
+ while (j--) {
+ /* PF will wait for RVU message callbacks to be called */
+ rte_delay_ms(1000);
+ printf("PF waiting for VF messages for %d sec.\r", j);
+ }
+ /* PF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xC0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO.
+ * Messages sent with this id will be serviced by VF..
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ VF /* Send to VF0 */,
+ MSG_ID_FROM + 0x2,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf PF->VF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU PF->VF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("PF waiting for VF to exit for %d sec.\r", j);
+ }
+
+ } else {
+ /* VF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xA0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO
+ * Messages sent with this id will be serviced by PF and will
+ * not be forwarded to AF.
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ PF /* Send to PF */,
+ MSG_ID_FROM + 0x1,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf VF->PF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU VF->PF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("VF waiting for PF to send msg for %d sec.\r", j);
+ }
+ }
+unregister:
+ rte_pmd_rvu_lf_msg_handler_unregister(dev_id);
+out:
+ rte_rawdev_stop(dev_id);
+
+ return ret;
+}
+
int
rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
{
@@ -138,7 +273,7 @@ rte_pmd_rvu_lf_sso_pf_func_get(void)
}
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
- .dev_selftest = NULL,
+ .dev_selftest = rvu_lf_rawdev_selftest,
};
static void
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v2 9/9] raw/cnxk_rvu_lf: add PMD API to get device pffunc
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
` (7 preceding siblings ...)
2024-10-08 10:54 ` [PATCH v2 8/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
@ 2024-10-08 10:54 ` Akhil Goyal
2024-10-08 11:52 ` [PATCH v2 0/9] drivers/raw: introduce cnxk rvu lf device driver David Marchand
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
10 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 10:54 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added ``rte_pmd_rvu_lf_pf_func_get`` API
to get RVU LF device pffunc for the application use.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
drivers/common/cnxk/roc_rvu_lf.c | 2 +-
drivers/common/cnxk/roc_rvu_lf.h | 2 ++
drivers/common/cnxk/version.map | 1 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 19 +++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 12 ++++++++++++
5 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 471dfa7a46..862a201135 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,7 +62,7 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
-static uint16_t
+uint16_t
roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf)
{
struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 6b4819666a..8c71876cbc 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,8 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+uint16_t __roc_api roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf);
+
int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf,
uint16_t vf, uint16_t msg_id,
void *req_data, uint16_t req_len,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index cd177a7920..980b770d9b 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -557,6 +557,7 @@ INTERNAL {
roc_rvu_lf_msg_id_range_check;
roc_rvu_lf_msg_id_range_set;
roc_rvu_lf_msg_process;
+ roc_rvu_lf_pf_func_get;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 82773a2988..0d510c3f59 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -72,6 +72,10 @@ rvu_lf_rawdev_selftest(uint16_t dev_id)
if (pf_func == 0)
CNXK_RVU_LF_LOG(WARNING, "SSO pf_func is invalid");
+ pf_func = rte_pmd_rvu_lf_pf_func_get(dev_id);
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "RVU LF pf_func is invalid");
+
ret = rte_pmd_rvu_lf_msg_id_range_set(dev_id, MSG_ID_FROM, MSG_ID_TO);
if (ret) {
CNXK_RVU_LF_LOG(ERR, "RVU message ID range invalid");
@@ -272,6 +276,21 @@ rte_pmd_rvu_lf_sso_pf_func_get(void)
return roc_sso_pf_func_get();
}
+uint16_t
+rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id)
+{
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ if (rawdev == NULL)
+ return 0;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_pf_func_get(roc_rvu_lf);
+}
+
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
.dev_selftest = rvu_lf_rawdev_selftest,
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
index ef6b427544..f8f8e6f0e4 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -185,6 +185,18 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
__rte_experimental
uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+/**
+ * Obtain RVU LF device PF func
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ *
+ * @return
+ * Returns RVU LF pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_experimental
+uint16_t rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id);
+
/**
* Get BAR addresses for the RVU LF device.
*
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v2 0/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
` (8 preceding siblings ...)
2024-10-08 10:54 ` [PATCH v2 9/9] raw/cnxk_rvu_lf: add PMD API to get device pffunc Akhil Goyal
@ 2024-10-08 11:52 ` David Marchand
2024-10-08 12:10 ` [EXTERNAL] " Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
10 siblings, 1 reply; 96+ messages in thread
From: David Marchand @ 2024-10-08 11:52 UTC (permalink / raw)
To: Akhil Goyal; +Cc: dev, thomas, hemant.agrawal, jerinj, hkalra
On Tue, Oct 8, 2024 at 12:54 PM Akhil Goyal <gakhil@marvell.com> wrote:
>
> CNXK product families can have a use case to allow PF and VF
> applications to communicate using mailboxes and also get notified
> of any interrupt that may occur on the device.
> Hence, a new raw device driver is added for such RVU LF devices.
> These devices can map to a PF or a VF which can send mailboxes to
> each other.
> The RVU LF device implements following features in the rawdev API:
>
> - Register mailbox callbacks for the other side to process mailboxes.
> - Register interrupt handler callbacks.
> - Process mailbox.
> - Set range of message IDs allowed for communication.
>
> Depends-on: https://patches.dpdk.org/project/dpdk/patch/20241008074000.3745855-1-gakhil@marvell.com/
>
> Changes in v2:
> - removed library patch from series
> - removed PMD logs from external PMD header.
> - updated doc/api/doxy-api-index.md
> - Added release notes
I see changes in wrong patches and the pmd API ending up in
cnxk_rvu_lf.h instead of rte_pmd_cnxk_rvu_lf.h (which I think was the
intention).
I am a bit skeptical about the pmd API that gives back a PCI bar
address to an application.
It looks more like the pmd specific API is unfinished and you are
leaving a door open for some guy who has the hw datasheet...
Thanks.
--
David Marchand
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v2] rawdev: add API to get device from index
2024-10-08 7:40 ` [PATCH v2] " Akhil Goyal
@ 2024-10-08 11:59 ` David Marchand
2024-10-08 12:00 ` [EXTERNAL] " Akhil Goyal
2024-10-09 6:11 ` Hemant Agrawal
2024-10-22 19:12 ` David Marchand
2 siblings, 1 reply; 96+ messages in thread
From: David Marchand @ 2024-10-08 11:59 UTC (permalink / raw)
To: Akhil Goyal; +Cc: dev, thomas, hemant.agrawal, jerinj
On Tue, Oct 8, 2024 at 9:40 AM Akhil Goyal <gakhil@marvell.com> wrote:
>
> Added an internal API for PMDs to get raw device pointer
> from a device id.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
> - resend patch for main branch separated from rvu_lf raw driver
> https://patches.dpdk.org/project/dpdk/list/?series=32949
>
> lib/rawdev/rte_rawdev_pmd.h | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h
> index 22b406444d..8339122348 100644
> --- a/lib/rawdev/rte_rawdev_pmd.h
> +++ b/lib/rawdev/rte_rawdev_pmd.h
> @@ -102,6 +102,30 @@ rte_rawdev_pmd_get_named_dev(const char *name)
> return NULL;
> }
>
> +/**
> + * Get the rte_rawdev structure device pointer for given device ID.
> + *
> + * @param dev_id
> + * raw device index.
> + *
> + * @return
> + * - The rte_rawdev structure pointer for the given device ID.
> + */
> +static inline struct rte_rawdev *
> +rte_rawdev_pmd_get_dev(uint8_t dev_id)
> +{
> + struct rte_rawdev *dev;
> +
> + if (dev_id >= RTE_RAWDEV_MAX_DEVS)
> + return NULL;
> +
> + dev = &rte_rawdevs[dev_id];
> + if (dev->attached == RTE_RAWDEV_ATTACHED)
> + return dev;
> +
> + return NULL;
> +}
> +
This seems simple enough and we have the same kind of helper in other
device class libraries.
But I would like to better understand the driver API that requires this.
--
David Marchand
^ permalink raw reply [flat|nested] 96+ messages in thread
* RE: [EXTERNAL] Re: [PATCH v2] rawdev: add API to get device from index
2024-10-08 11:59 ` David Marchand
@ 2024-10-08 12:00 ` Akhil Goyal
2024-10-09 21:13 ` Akhil Goyal
0 siblings, 1 reply; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 12:00 UTC (permalink / raw)
To: David Marchand; +Cc: dev, thomas, hemant.agrawal, Jerin Jacob
> > diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h
> > index 22b406444d..8339122348 100644
> > --- a/lib/rawdev/rte_rawdev_pmd.h
> > +++ b/lib/rawdev/rte_rawdev_pmd.h
> > @@ -102,6 +102,30 @@ rte_rawdev_pmd_get_named_dev(const char *name)
> > return NULL;
> > }
> >
> > +/**
> > + * Get the rte_rawdev structure device pointer for given device ID.
> > + *
> > + * @param dev_id
> > + * raw device index.
> > + *
> > + * @return
> > + * - The rte_rawdev structure pointer for the given device ID.
> > + */
> > +static inline struct rte_rawdev *
> > +rte_rawdev_pmd_get_dev(uint8_t dev_id)
> > +{
> > + struct rte_rawdev *dev;
> > +
> > + if (dev_id >= RTE_RAWDEV_MAX_DEVS)
> > + return NULL;
> > +
> > + dev = &rte_rawdevs[dev_id];
> > + if (dev->attached == RTE_RAWDEV_ATTACHED)
> > + return dev;
> > +
> > + return NULL;
> > +}
> > +
>
> This seems simple enough and we have the same kind of helper in other
> device class libraries.
> But I would like to better understand the driver API that requires this.
>
This is being used in the new cnxk rvu_lf driver.
https://patches.dpdk.org/project/dpdk/cover/20241008105415.1026962-1-gakhil@marvell.com/
^ permalink raw reply [flat|nested] 96+ messages in thread
* RE: [EXTERNAL] Re: [PATCH v2 0/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-08 11:52 ` [PATCH v2 0/9] drivers/raw: introduce cnxk rvu lf device driver David Marchand
@ 2024-10-08 12:10 ` Akhil Goyal
0 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 12:10 UTC (permalink / raw)
To: David Marchand; +Cc: dev, thomas, hemant.agrawal, Jerin Jacob, Harman Kalra
Hi David,
> > Changes in v2:
> > - removed library patch from series
> > - removed PMD logs from external PMD header.
> > - updated doc/api/doxy-api-index.md
> > - Added release notes
>
> I see changes in wrong patches and the pmd API ending up in
> cnxk_rvu_lf.h instead of rte_pmd_cnxk_rvu_lf.h (which I think was the
> intention).
>
Thanks for pointing this out.
The logs were moved from external header to internal one.
This got screwed up while rebasing. Will fix in v3
> I am a bit skeptical about the pmd API that gives back a PCI bar
> address to an application.
> It looks more like the pmd specific API is unfinished and you are
> leaving a door open for some guy who has the hw datasheet...
>
The intention of the driver is to allow mailbox communication between a PF and VF/AF application.
The contents of the mailboxes are not defined in the driver and
hence the intent of the raw driver is to be raw which allows application to define their mailboxes and
may need to fill the BAR addresses as well for certain actions based on mailbox types.
With this driver, the application is given full control of the device.
The driver APIs are generic which can be used by any of the cnxk device.
This can be used as a debugging tool also for any new cnxk device for which the formal driver is not ready.
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v3 0/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
` (9 preceding siblings ...)
2024-10-08 11:52 ` [PATCH v2 0/9] drivers/raw: introduce cnxk rvu lf device driver David Marchand
@ 2024-10-08 18:49 ` Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 1/9] " Akhil Goyal
` (9 more replies)
10 siblings, 10 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 18:49 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
CNXK product families can have a use case to allow PF and VF
applications to communicate using mailboxes and also get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
The RVU LF device implements following features in the rawdev API:
- Register mailbox callbacks for the other side to process mailboxes.
- Register interrupt handler callbacks.
- Process mailbox.
- Set range of message IDs allowed for communication.
Depends-on: https://patches.dpdk.org/project/dpdk/patch/20241008074000.3745855-1-gakhil@marvell.com/
Changes in v3:
- fix internal/external header files.
Changes in v2:
- removed library patch from series
- removed PMD logs from external PMD header.
- updated doc/api/doxy-api-index.md
- Added release notes
Akhil Goyal (9):
drivers/raw: introduce cnxk rvu lf device driver
raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc
raw/cnxk_rvu_lf: add PMD API to get BAR addresses
raw/cnxk_rvu_lf: register/unregister interrupt handler
raw/cnxk_rvu_lf: register/unregister msg handler
raw/cnxk_rvu_lf: set message ID range
raw/cnxk_rvu_lf: process mailbox message
raw/cnxk_rvu_lf: add selftest
raw/cnxk_rvu_lf: add PMD API to get device pffunc
MAINTAINERS | 6 +
doc/api/doxy-api-index.md | 1 +
doc/guides/rawdevs/cnxk_rvu_lf.rst | 100 +++++
doc/guides/rawdevs/index.rst | 1 +
doc/guides/rel_notes/release_24_11.rst | 5 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 3 +
drivers/common/cnxk/roc_dev.c | 118 +++++-
drivers/common/cnxk/roc_dev_priv.h | 7 +
drivers/common/cnxk/roc_idev.c | 46 ++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_mbox.h | 2 +
drivers/common/cnxk/roc_npa.c | 6 +
drivers/common/cnxk/roc_npa.h | 3 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 202 +++++++++
drivers/common/cnxk/roc_rvu_lf.h | 46 ++
drivers/common/cnxk/roc_rvu_lf_priv.h | 37 ++
drivers/common/cnxk/roc_sso.c | 6 +
drivers/common/cnxk/roc_sso.h | 3 +
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 16 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 400 ++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 35 ++
drivers/raw/cnxk_rvu_lf/meson.build | 10 +
drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 220 ++++++++++
drivers/raw/meson.build | 1 +
29 files changed, 1281 insertions(+), 6 deletions(-)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
create mode 100644 drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v3 1/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
@ 2024-10-08 18:49 ` Akhil Goyal
2024-10-08 20:44 ` Stephen Hemminger
` (2 more replies)
2024-10-08 18:49 ` [PATCH v3 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
` (8 subsequent siblings)
9 siblings, 3 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 18:49 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
CNXK product families can have a use case to allow PF and VF
applications to communicate using mailboxes and also get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
MAINTAINERS | 6 ++
doc/guides/rawdevs/cnxk_rvu_lf.rst | 40 +++++++++
doc/guides/rawdevs/index.rst | 1 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 3 +
drivers/common/cnxk/roc_dev_priv.h | 1 +
drivers/common/cnxk/roc_idev.c | 46 ++++++++++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 63 +++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 24 +++++
drivers/common/cnxk/roc_rvu_lf_priv.h | 32 +++++++
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 5 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 123 ++++++++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 35 ++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 9 ++
drivers/raw/meson.build | 1 +
20 files changed, 402 insertions(+)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
diff --git a/MAINTAINERS b/MAINTAINERS
index 812463fe9f..97e934edb0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1498,6 +1498,12 @@ T: git://dpdk.org/next/dpdk-next-net-mrvl
F: doc/guides/rawdevs/cnxk_gpio.rst
F: drivers/raw/cnxk_gpio/
+Marvell CNXK RVU LF
+M: Akhil Goyal <gakhil@marvell.com>
+T: git://dpdk.org/next/dpdk-next-net-mrvl
+F: doc/guides/rawdevs/cnxk_rvu_lf.rst
+F: drivers/raw/cnxk_rvu_lf/
+
NTB
M: Jingjing Wu <jingjing.wu@intel.com>
F: drivers/raw/ntb/
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
new file mode 100644
index 0000000000..8a0bc22dd5
--- /dev/null
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -0,0 +1,40 @@
+.. SPDX-License-Identifier: BSD-3-Clause
+ Copyright(c) 2024 Marvell.
+
+Marvell CNXK RVU LF Driver
+==========================
+
+CNXK product families can have a use case to allow PF and VF
+applications to communicate using mailboxes and also get notified
+of any interrupt that may occur on the device.
+Hence, a new raw device driver is added for such RVU LF devices.
+These devices can map to a PF or a VF which can send mailboxes to
+each other.
+
+Features
+--------
+
+The RVU LF device implements following features in the rawdev API:
+
+- Register mailbox callbacks for the other side to process mailboxes.
+- Register interrupt handler callbacks.
+- Process mailbox.
+- Set range of message IDs allowed for communication.
+
+Limitations
+-----------
+
+In multiprocess mode user-space application must ensure
+no resources sharing takes place.
+Otherwise, user-space application should ensure synchronization.
+
+Device Setup
+------------
+
+The RVU LF devices will need to be bound to a user-space IO driver for use.
+The script ``dpdk-devbind.py`` included with DPDK can be used to
+view the state of the devices and to bind them to a suitable DPDK-supported
+kernel driver. When querying the status of the devices, they will appear under
+the category of "Misc (rawdev) devices", i.e. the command
+``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
+devices alone.
diff --git a/doc/guides/rawdevs/index.rst b/doc/guides/rawdevs/index.rst
index f34315f051..8e07cf4d6c 100644
--- a/doc/guides/rawdevs/index.rst
+++ b/doc/guides/rawdevs/index.rst
@@ -13,6 +13,7 @@ application through rawdev API.
cnxk_bphy
cnxk_gpio
+ cnxk_rvu_lf
dpaa2_cmdif
ifpga
ntb
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index dc2ddf1f20..f847aa5d34 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -71,6 +71,7 @@ sources = files(
'roc_tim_irq.c',
'roc_utils.c',
'roc_ree.c',
+ 'roc_rvu_lf.c',
)
# Security common code
diff --git a/drivers/common/cnxk/roc_api.h b/drivers/common/cnxk/roc_api.h
index 6a86863c57..93e7bf11bb 100644
--- a/drivers/common/cnxk/roc_api.h
+++ b/drivers/common/cnxk/roc_api.h
@@ -120,4 +120,7 @@
/* Eswitch */
#include "roc_eswitch.h"
+/* RVU LF */
+#include "roc_rvu_lf.h"
+
#endif /* _ROC_API_H_ */
diff --git a/drivers/common/cnxk/roc_constants.h b/drivers/common/cnxk/roc_constants.h
index 0e7495a37c..67cd74b28a 100644
--- a/drivers/common/cnxk/roc_constants.h
+++ b/drivers/common/cnxk/roc_constants.h
@@ -45,6 +45,8 @@
#define PCI_DEVID_CNXK_RVU_REE_VF 0xA0f5
#define PCI_DEVID_CNXK_RVU_ESWITCH_PF 0xA0E0
#define PCI_DEVID_CNXK_RVU_ESWITCH_VF 0xA0E1
+#define PCI_DEVID_CNXK_RVU_BPHY_PF 0xA0E4
+#define PCI_DEVID_CNXK_RVU_BPHY_VF 0xA0E5
#define PCI_DEVID_CN9K_CGX 0xA059
#define PCI_DEVID_CN10K_RPM 0xA060
@@ -63,6 +65,7 @@
#define PCI_SUBSYSTEM_DEVID_CNF10KB 0xBC00
#define PCI_SUBSYSTEM_DEVID_CN20KA 0xA020
+#define PCI_SUBSYSTEM_DEVID_CNF20KA 0xA000
#define PCI_SUBSYSTEM_DEVID_CN9KA 0x0000
#define PCI_SUBSYSTEM_DEVID_CN9KB 0xb400
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index 5ab4f72f8f..dd4949b32c 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -141,6 +141,7 @@ struct dev {
void *roc_cpt;
void *roc_tim;
void *roc_ml;
+ void *roc_rvu_lf;
bool disable_shared_lmt; /* false(default): shared lmt mode enabled */
const struct plt_memzone *lmt_mz;
struct mbox_sync sync;
diff --git a/drivers/common/cnxk/roc_idev.c b/drivers/common/cnxk/roc_idev.c
index 0778d51d1e..84812f73e0 100644
--- a/drivers/common/cnxk/roc_idev.c
+++ b/drivers/common/cnxk/roc_idev.c
@@ -38,6 +38,7 @@ idev_set_defaults(struct idev_cfg *idev)
idev->num_lmtlines = 0;
idev->bphy = NULL;
idev->cpt = NULL;
+ TAILQ_INIT(&idev->rvu_lf_list);
TAILQ_INIT(&idev->mcs_list);
idev->nix_inl_dev = NULL;
TAILQ_INIT(&idev->roc_nix_list);
@@ -188,6 +189,51 @@ roc_idev_cpt_get(void)
return NULL;
}
+struct roc_rvu_lf *
+roc_idev_rvu_lf_get(uint8_t rvu_lf_idx)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf, &idev->rvu_lf_list, next) {
+ if (rvu_lf->idx == rvu_lf_idx)
+ return rvu_lf;
+ }
+ }
+
+ return NULL;
+}
+
+void
+roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ return;
+ }
+ TAILQ_INSERT_TAIL(&idev->rvu_lf_list, rvu, next);
+ }
+}
+
+void
+roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ TAILQ_REMOVE(&idev->rvu_lf_list, rvu, next);
+ }
+ }
+}
+
struct roc_mcs *
roc_idev_mcs_get(uint8_t mcs_idx)
{
diff --git a/drivers/common/cnxk/roc_idev.h b/drivers/common/cnxk/roc_idev.h
index fc0f7db54e..6edb5f83b2 100644
--- a/drivers/common/cnxk/roc_idev.h
+++ b/drivers/common/cnxk/roc_idev.h
@@ -29,4 +29,8 @@ uint16_t *__roc_api roc_idev_nix_rx_chan_base_get(void);
void __roc_api roc_idev_nix_rx_chan_set(uint16_t port, uint16_t chan);
uint16_t __roc_api roc_idev_nix_inl_dev_pffunc_get(void);
+
+struct roc_rvu_lf *__roc_api roc_idev_rvu_lf_get(uint8_t rvu_lf_idx);
+void __roc_api roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu);
+void __roc_api roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu);
#endif /* _ROC_IDEV_H_ */
diff --git a/drivers/common/cnxk/roc_idev_priv.h b/drivers/common/cnxk/roc_idev_priv.h
index 6628b18152..98b6286bfe 100644
--- a/drivers/common/cnxk/roc_idev_priv.h
+++ b/drivers/common/cnxk/roc_idev_priv.h
@@ -36,6 +36,7 @@ struct idev_cfg {
struct roc_bphy *bphy;
struct roc_cpt *cpt;
struct roc_sso *sso;
+ struct roc_rvu_lf_head rvu_lf_list;
struct roc_mcs_head mcs_list;
struct nix_inl_dev *nix_inl_dev;
struct idev_nix_inl_cfg inl_cfg;
diff --git a/drivers/common/cnxk/roc_priv.h b/drivers/common/cnxk/roc_priv.h
index 254a2d3310..8732a05ac3 100644
--- a/drivers/common/cnxk/roc_priv.h
+++ b/drivers/common/cnxk/roc_priv.h
@@ -53,4 +53,6 @@
/* ML */
#include "roc_ml_priv.h"
+/* RVU LF */
+#include "roc_rvu_lf_priv.h"
#endif /* _ROC_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
new file mode 100644
index 0000000000..1ae39e746e
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include "roc_api.h"
+#include "roc_priv.h"
+
+int
+roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct plt_pci_device *pci_dev;
+ struct dev *dev;
+ struct rvu_lf *rvu;
+ int rc;
+
+ if (roc_rvu_lf == NULL || roc_rvu_lf->pci_dev == NULL)
+ return RVU_ERR_PARAM;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ pci_dev = roc_rvu_lf->pci_dev;
+ dev = &rvu->dev;
+
+ if (rvu->dev.drv_inited)
+ return 0;
+
+ if (dev->mbox_active)
+ goto skip_dev_init;
+
+ memset(rvu, 0, sizeof(*rvu));
+
+ /* Initialize device */
+ rc = dev_init(dev, pci_dev);
+ if (rc) {
+ plt_err("Failed to init roc device");
+ goto fail;
+ }
+
+skip_dev_init:
+ dev->roc_rvu_lf = roc_rvu_lf;
+ rvu->pci_dev = pci_dev;
+
+ roc_idev_rvu_lf_set(roc_rvu_lf);
+ rvu->dev.drv_inited = true;
+
+ return 0;
+fail:
+ return rc;
+}
+
+int
+roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (rvu == NULL)
+ return NIX_ERR_PARAM;
+
+ rvu->dev.drv_inited = false;
+
+ roc_idev_rvu_lf_free(roc_rvu_lf);
+
+ return dev_fini(&rvu->dev, rvu->pci_dev);
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
new file mode 100644
index 0000000000..7ce8065a8b
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_H_
+#define _ROC_RVU_LF_H_
+
+#include "roc_platform.h"
+
+struct roc_rvu_lf {
+ TAILQ_ENTRY(roc_rvu_lf) next;
+ struct plt_pci_device *pci_dev;
+ uint8_t idx;
+#define ROC_RVU_MEM_SZ (6 * 1024)
+ uint8_t reserved[ROC_RVU_MEM_SZ] __plt_cache_aligned;
+};
+
+TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
+
+/* Dev */
+int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+
+#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
new file mode 100644
index 0000000000..8feff82961
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_PRIV_H_
+#define _ROC_RVU_LF_PRIV_H_
+
+enum rvu_err_status {
+ RVU_ERR_PARAM = -1,
+ RVU_ERR_NO_MEM = -2,
+};
+
+struct rvu_lf {
+ struct plt_pci_device *pci_dev;
+ struct dev dev;
+ uint16_t msg_id_from;
+ uint16_t msg_id_to;
+};
+
+static inline struct rvu_lf *
+roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
+{
+ return (struct rvu_lf *)&roc_rvu_lf->reserved[0];
+}
+
+static inline struct roc_rvu_lf *
+rvu_priv_to_roc_rvu_lf(struct rvu_lf *rvu_lf)
+{
+ return (struct roc_rvu_lf *)((char *)rvu_lf - offsetof(struct roc_rvu_lf, reserved));
+}
+
+#endif /* _ROC_RVU_LF_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_utils.c b/drivers/common/cnxk/roc_utils.c
index 9af2ae9b69..bcc0d2de38 100644
--- a/drivers/common/cnxk/roc_utils.c
+++ b/drivers/common/cnxk/roc_utils.c
@@ -17,11 +17,13 @@ roc_error_msg_get(int errorcode)
case NPC_ERR_PARAM:
case SSO_ERR_PARAM:
case MCS_ERR_PARAM:
+ case RVU_ERR_PARAM:
case UTIL_ERR_PARAM:
err_msg = "Invalid parameter";
break;
case NIX_ERR_NO_MEM:
case NPC_ERR_NO_MEM:
+ case RVU_ERR_NO_MEM:
err_msg = "Out of memory";
break;
case NIX_ERR_INVALID_RANGE:
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 6f8a2e02da..9f7c804542 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -118,6 +118,9 @@ INTERNAL {
roc_idev_nix_rx_chan_set;
roc_idev_nix_rx_inject_get;
roc_idev_nix_rx_inject_set;
+ roc_idev_rvu_lf_free;
+ roc_idev_rvu_lf_get;
+ roc_idev_rvu_lf_set;
roc_ml_reg_read64;
roc_ml_reg_write64;
roc_ml_reg_read32;
@@ -543,5 +546,7 @@ INTERNAL {
roc_ree_rule_db_get;
roc_ree_rule_db_len_get;
roc_ree_rule_db_prog;
+ roc_rvu_lf_dev_fini;
+ roc_rvu_lf_dev_init;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
new file mode 100644
index 0000000000..36067909be
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include <bus_pci_driver.h>
+#include <rte_common.h>
+#include <dev_driver.h>
+#include <rte_eal.h>
+#include <rte_lcore.h>
+#include <rte_pci.h>
+#include <rte_rawdev.h>
+#include <rte_rawdev_pmd.h>
+
+#include <roc_api.h>
+
+#include "cnxk_rvu_lf.h"
+
+static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
+ .dev_selftest = NULL,
+};
+
+static void
+rvu_lf_rawdev_get_name(char *name, struct rte_pci_device *pci_dev)
+{
+ snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "RVU LF:%02x:%02x.%x",
+ pci_dev->addr.bus, pci_dev->addr.devid,
+ pci_dev->addr.function);
+}
+
+static int
+rvu_lf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct rte_rawdev *rvu_lf_rawdev;
+ struct roc_rvu_lf *roc_rvu_lf;
+ int ret;
+
+ RTE_SET_USED(pci_drv);
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (!pci_dev->mem_resource[2].addr) {
+ CNXK_RVU_LF_LOG(ERR, "BARs have invalid values: BAR0 %p\n BAR2 %p",
+ pci_dev->mem_resource[2].addr, pci_dev->mem_resource[4].addr);
+ return -ENODEV;
+ }
+
+ ret = roc_plt_init();
+ if (ret)
+ return ret;
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rvu_lf_rawdev = rte_rawdev_pmd_allocate(name, sizeof(*roc_rvu_lf),
+ rte_socket_id());
+ if (rvu_lf_rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "Failed to allocate rawdev");
+ return -ENOMEM;
+ }
+
+ rvu_lf_rawdev->dev_ops = &rvu_lf_rawdev_ops;
+ rvu_lf_rawdev->device = &pci_dev->device;
+ rvu_lf_rawdev->driver_name = pci_dev->driver->driver.name;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rvu_lf_rawdev->dev_private;
+ roc_rvu_lf->pci_dev = pci_dev;
+
+ ret = roc_rvu_lf_dev_init(roc_rvu_lf);
+ if (ret) {
+ rte_rawdev_pmd_release(rvu_lf_rawdev);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int
+rvu_lf_remove(struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (pci_dev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid pci_dev");
+ return -EINVAL;
+ }
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rawdev = rte_rawdev_pmd_get_named_dev(name);
+ if (rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid device name (%s)", name);
+ return -EINVAL;
+ }
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+ roc_rvu_lf_dev_fini(roc_rvu_lf);
+
+ return rte_rawdev_pmd_release(rawdev);
+}
+
+static const struct rte_pci_id pci_rvu_lf_map[] = {
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_PF),
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_VF),
+ {
+ .vendor_id = 0,
+ },
+};
+
+static struct rte_pci_driver cnxk_rvu_lf_rawdev_pmd = {
+ .id_table = pci_rvu_lf_map,
+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
+ .probe = rvu_lf_probe,
+ .remove = rvu_lf_remove,
+};
+
+RTE_PMD_REGISTER_PCI(rvu_lf_rawdev_pci_driver, cnxk_rvu_lf_rawdev_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(rvu_lf_rawdev_pci_driver, pci_rvu_lf_map);
+RTE_PMD_REGISTER_KMOD_DEP(rvu_lf_rawdev_pci_driver, "vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_rvu_lf, rvu_lf, INFO);
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
new file mode 100644
index 0000000000..a23a629500
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _CNXK_RVU_LF_H_
+#define _CNXK_RVU_LF_H_
+
+#include <stdint.h>
+
+#include <rte_common.h>
+
+/**
+ * @file cnxk_rvu_lf.h
+ *
+ * Marvell RVU LF raw PMD specific internal structures
+ *
+ * This API allows applications to manage RVU LF device in user space along with
+ * installing interrupt handlers for low latency signal processing.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int cnxk_logtype_rvu_lf;
+
+#define CNXK_RVU_LF_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
+ "%s(): " fmt "\n", __func__, ## args)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CNXK_RVU_LF_H_ */
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
new file mode 100644
index 0000000000..32081e147f
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2024 Marvell.
+#
+
+deps += ['bus_pci', 'common_cnxk', 'rawdev']
+sources = files(
+ 'cnxk_rvu_lf.c',
+)
+require_iova_in_mbuf = false
diff --git a/drivers/raw/meson.build b/drivers/raw/meson.build
index 05cad143fe..54221643d5 100644
--- a/drivers/raw/meson.build
+++ b/drivers/raw/meson.build
@@ -8,6 +8,7 @@ endif
drivers = [
'cnxk_bphy',
'cnxk_gpio',
+ 'cnxk_rvu_lf',
'dpaa2_cmdif',
'ifpga',
'ntb',
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v3 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 1/9] " Akhil Goyal
@ 2024-10-08 18:49 ` Akhil Goyal
2024-10-23 14:13 ` David Marchand
2024-10-08 18:49 ` [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
` (7 subsequent siblings)
9 siblings, 1 reply; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 18:49 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added rte_pmd_rvu_lf_npa_pf_func_get and
rte_pmd_rvu_lf_sso_pf_func_get APIs to get NPA and
SSO pffunc for the application use.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/api/doxy-api-index.md | 1 +
doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 +++
drivers/common/cnxk/roc_npa.c | 6 +++
drivers/common/cnxk/roc_npa.h | 3 ++
drivers/common/cnxk/roc_sso.c | 6 +++
drivers/common/cnxk/roc_sso.h | 3 ++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 13 +++++
drivers/raw/cnxk_rvu_lf/meson.build | 1 +
drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 51 +++++++++++++++++++
10 files changed, 93 insertions(+)
create mode 100644 drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index f9f0300126..b4dbe51727 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -52,6 +52,7 @@ The public API headers are grouped by topics:
[cnxk_crypto](@ref rte_pmd_cnxk_crypto.h),
[cnxk_eventdev](@ref rte_pmd_cnxk_eventdev.h),
[cnxk_mempool](@ref rte_pmd_cnxk_mempool.h),
+ [cnxk_rvu_lf](@ref rte_pmd_cnxk_rvu_lf.h),
[dpaa](@ref rte_pmd_dpaa.h),
[dpaa2](@ref rte_pmd_dpaa2.h),
[mlx5](@ref rte_pmd_mlx5.h),
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 8a0bc22dd5..13184ad4dc 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -38,3 +38,10 @@ kernel driver. When querying the status of the devices, they will appear under
the category of "Misc (rawdev) devices", i.e. the command
``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
devices alone.
+
+Get NPA and SSO PF FUNC
+-----------------------
+
+APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
+can be used to get the cnxk NPA PF func and SSO PF func which application
+can use for NPA/SSO specific configuration.
diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index 934d7361a9..a33f9a8499 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -17,6 +17,12 @@ roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb)
return 0;
}
+uint16_t
+roc_npa_pf_func_get(void)
+{
+ return idev_npa_pffunc_get();
+}
+
void
roc_npa_pool_op_range_set(uint64_t aura_handle, uint64_t start_iova,
uint64_t end_iova)
diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h
index fbf75b2fca..f7cb4460e7 100644
--- a/drivers/common/cnxk/roc_npa.h
+++ b/drivers/common/cnxk/roc_npa.h
@@ -820,6 +820,9 @@ int __roc_api roc_npa_aura_bp_configure(uint64_t aura_id, uint16_t bpid, uint8_t
typedef int (*roc_npa_lf_init_cb_t)(struct plt_pci_device *pci_dev);
int __roc_api roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb);
+/* Utility functions */
+uint16_t __roc_api roc_npa_pf_func_get(void);
+
/* Debug */
int __roc_api roc_npa_ctx_dump(void);
int __roc_api roc_npa_dump(void);
diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c
index 2e3b134bfc..aed8819a1b 100644
--- a/drivers/common/cnxk/roc_sso.c
+++ b/drivers/common/cnxk/roc_sso.c
@@ -319,6 +319,12 @@ roc_sso_hwgrp_base_get(struct roc_sso *roc_sso, uint16_t hwgrp)
return dev->bar2 + (RVU_BLOCK_ADDR_SSO << 20 | hwgrp << 12);
}
+uint16_t
+roc_sso_pf_func_get(void)
+{
+ return idev_sso_pffunc_get();
+}
+
uint64_t
roc_sso_ns_to_gw(uint64_t base, uint64_t ns)
{
diff --git a/drivers/common/cnxk/roc_sso.h b/drivers/common/cnxk/roc_sso.h
index 4ac901762e..3e293a0a69 100644
--- a/drivers/common/cnxk/roc_sso.h
+++ b/drivers/common/cnxk/roc_sso.h
@@ -103,6 +103,9 @@ int __roc_api roc_sso_hwgrp_stash_config(struct roc_sso *roc_sso,
void __roc_api roc_sso_hws_gwc_invalidate(struct roc_sso *roc_sso, uint8_t *hws,
uint8_t nb_hws);
+/* Utility function */
+uint16_t __roc_api roc_sso_pf_func_get(void);
+
/* Debug */
void __roc_api roc_sso_dump(struct roc_sso *roc_sso, uint8_t nb_hws,
uint16_t hwgrp, FILE *f);
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 9f7c804542..dd56caef16 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -451,6 +451,7 @@ INTERNAL {
roc_npa_dev_unlock;
roc_npa_dump;
roc_npa_lf_init_cb_register;
+ roc_npa_pf_func_get;
roc_npa_pool_create;
roc_npa_pool_destroy;
roc_npa_pool_op_pc_reset;
@@ -518,6 +519,7 @@ INTERNAL {
roc_sso_hws_gwc_invalidate;
roc_sso_hws_unlink;
roc_sso_ns_to_gw;
+ roc_sso_pf_func_get;
roc_sso_rsrc_fini;
roc_sso_rsrc_init;
roc_tim_fini;
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 36067909be..43d3a6fa87 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -14,6 +14,19 @@
#include <roc_api.h>
#include "cnxk_rvu_lf.h"
+#include "rte_pmd_cnxk_rvu_lf.h"
+
+uint16_t
+rte_pmd_rvu_lf_npa_pf_func_get(void)
+{
+ return roc_npa_pf_func_get();
+}
+
+uint16_t
+rte_pmd_rvu_lf_sso_pf_func_get(void)
+{
+ return roc_sso_pf_func_get();
+}
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
.dev_selftest = NULL,
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
index 32081e147f..a1a010319b 100644
--- a/drivers/raw/cnxk_rvu_lf/meson.build
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -6,4 +6,5 @@ deps += ['bus_pci', 'common_cnxk', 'rawdev']
sources = files(
'cnxk_rvu_lf.c',
)
+headers = files('rte_pmd_cnxk_rvu_lf.h')
require_iova_in_mbuf = false
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
new file mode 100644
index 0000000000..ea03e7ac8c
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _RTE_PMD_CNXK_RVU_LF_H_
+#define _RTE_PMD_CNXK_RVU_LF_H_
+
+#include <stdint.h>
+
+#include <rte_common.h>
+#include <rte_dev.h>
+#include <rte_malloc.h>
+#include <rte_memcpy.h>
+#include <rte_rawdev.h>
+
+/**
+ * @file rte_pmd_cnxk_rvu_lf.h
+ *
+ * Marvell RVU LF raw PMD specific structures and interface
+ *
+ * This API allows applications to manage RVU LF device in user space along with
+ * installing interrupt handlers for low latency signal processing.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Obtain NPA PF func
+ *
+ * @return
+ * Returns NPA pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_experimental
+uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
+
+/**
+ * Obtain SSO PF func
+ *
+ * @return
+ * Returns SSO pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_experimental
+uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_PMD_CNXK_RVU_LF_H_ */
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 1/9] " Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
@ 2024-10-08 18:49 ` Akhil Goyal
2024-10-21 21:30 ` Thomas Monjalon
2024-10-08 18:49 ` [PATCH v3 4/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
` (6 subsequent siblings)
9 siblings, 1 reply; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 18:49 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added rte_pmd_rvu_lf_bar_get() API to get BAR address
for application to configure hardware.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 ++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 23 +++++++++++++++++++
drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 18 +++++++++++++++
3 files changed, 48 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 13184ad4dc..6dfbd466ad 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -45,3 +45,10 @@ Get NPA and SSO PF FUNC
APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
can be used to get the cnxk NPA PF func and SSO PF func which application
can use for NPA/SSO specific configuration.
+
+Get BAR addresses
+-----------------
+
+Application can retrieve PCI BAR addresses of the device using the API
+``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the
+registers of the hardware device.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 43d3a6fa87..e4ae3c937a 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,29 @@
#include "cnxk_rvu_lf.h"
#include "rte_pmd_cnxk_rvu_lf.h"
+int
+rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask)
+{
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+ if (bar_num > PCI_MAX_RESOURCE ||
+ (roc_rvu_lf->pci_dev->mem_resource[bar_num].addr == NULL)) {
+ *va = 0;
+ *mask = 0;
+ return -ENOTSUP;
+ }
+ *va = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].addr);
+ *mask = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].len - 1);
+
+ return 0;
+}
+
uint16_t
rte_pmd_rvu_lf_npa_pf_func_get(void)
{
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
index ea03e7ac8c..3d44cfc835 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
@@ -44,6 +44,24 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
__rte_experimental
uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+/**
+ * Get BAR addresses for the RVU LF device.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param bar_num
+ * BAR number for which address is required
+ * @param[out] va
+ * Virtual address of the BAR. 0 if not mapped
+ * @param[out] mask
+ * BAR address mask, 0 if not mapped
+ *
+ * @return
+ * Returns 0 on success, negative error code otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask);
+
#ifdef __cplusplus
}
#endif
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v3 4/9] raw/cnxk_rvu_lf: register/unregister interrupt handler
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
` (2 preceding siblings ...)
2024-10-08 18:49 ` [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
@ 2024-10-08 18:49 ` Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 5/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
` (5 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 18:49 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD API rte_pmd_rvu_lf_irq_register() and
rte_pmd_rvu_lf_irq_unregister() to register/unregister
interrupt handlers for rvu lf raw device.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 ++++
drivers/common/cnxk/roc_rvu_lf.c | 26 +++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 ++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 30 ++++++++++++
drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 46 +++++++++++++++++++
6 files changed, 117 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 6dfbd466ad..7bae6b523e 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -52,3 +52,11 @@ Get BAR addresses
Application can retrieve PCI BAR addresses of the device using the API
``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the
registers of the hardware device.
+
+Register or remove interrupt handler
+------------------------------------
+
+Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register()``
+or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
+The irq numbers for which the interrupts are registered is negotiated separately
+and is not in scope of the driver.
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1ae39e746e..63bc149f2a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -61,3 +61,29 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+
+int
+roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ return dev_irq_register(handle, (plt_intr_callback_fn)cb, data, irq);
+}
+
+int
+roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ dev_irq_unregister(handle, (plt_intr_callback_fn)cb, data, irq);
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7ce8065a8b..800bf4e674 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,4 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index dd56caef16..2c845cd591 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -550,5 +550,7 @@ INTERNAL {
roc_ree_rule_db_prog;
roc_rvu_lf_dev_fini;
roc_rvu_lf_dev_init;
+ roc_rvu_lf_irq_register;
+ roc_rvu_lf_irq_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index e4ae3c937a..6791800935 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,36 @@
#include "cnxk_rvu_lf.h"
#include "rte_pmd_cnxk_rvu_lf.h"
+int
+rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_register(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
+int
+rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_unregister(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
int
rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask)
{
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
index 3d44cfc835..54e4817604 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
@@ -62,6 +62,52 @@ uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
__rte_experimental
int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask);
+/**
+ * Signature of callback function called when an interrupt is received on RVU LF device.
+ *
+ * @param cb_arg
+ * pointer to the information received on an interrupt
+ */
+typedef void (*rte_pmd_rvu_lf_intr_callback_fn)(void *cb_arg);
+
+/**
+ * Register interrupt callback
+ *
+ * Registers an interrupt callback to be executed when interrupt is raised.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number for which interrupt will be raised
+ * @param cb
+ * callback function to be executed
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
+/**
+ * Unregister interrupt callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number
+ * @param cb
+ * callback function registered
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
#ifdef __cplusplus
}
#endif
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v3 5/9] raw/cnxk_rvu_lf: register/unregister msg handler
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
` (3 preceding siblings ...)
2024-10-08 18:49 ` [PATCH v3 4/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
@ 2024-10-08 18:49 ` Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 6/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
` (4 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 18:49 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD APIs rte_pmd_rvu_lf_msg_handler_register()
and rte_pmd_rvu_lf_msg_handler_unregister() to register/unregister
mailbox message handlers. These handlers are needed to fill
response at the other side for the request sent from one side.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
drivers/common/cnxk/roc_dev_priv.h | 6 +++
drivers/common/cnxk/roc_rvu_lf.c | 25 ++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 7 +++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 28 +++++++++++
drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 49 +++++++++++++++++++
6 files changed, 117 insertions(+)
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index dd4949b32c..c766183196 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -46,11 +46,17 @@ typedef void (*link_status_get_t)(void *roc_nix,
/* Representee notification callback */
typedef int (*repte_notify_t)(void *roc_nix, void *notify_msg);
+/* RVU Message process callback */
+typedef int (*msg_process_cb_t)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
struct dev_ops {
link_info_t link_status_update;
ptp_info_t ptp_info_update;
link_status_get_t link_status_get;
q_err_cb_t q_err_cb;
+ msg_process_cb_t msg_process_cb;
repte_notify_t repte_notify;
};
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 63bc149f2a..2e1be81e52 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -87,3 +87,28 @@ roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
return 0;
}
+
+int
+roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf, roc_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ if (cb == NULL)
+ return -EINVAL;
+
+ dev->ops->msg_process_cb = (msg_process_cb_t)cb;
+
+ return 0;
+}
+
+int
+roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ dev->ops->msg_process_cb = NULL;
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 800bf4e674..90a0b5690a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -22,8 +22,15 @@ int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf,
+ roc_rvu_lf_msg_handler_cb_fn cb);
+int __roc_api roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 2c845cd591..f3c48ae3cb 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -552,5 +552,7 @@ INTERNAL {
roc_rvu_lf_dev_init;
roc_rvu_lf_irq_register;
roc_rvu_lf_irq_unregister;
+ roc_rvu_lf_msg_handler_register;
+ roc_rvu_lf_msg_handler_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 6791800935..13d33867a8 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,34 @@
#include "cnxk_rvu_lf.h"
#include "rte_pmd_cnxk_rvu_lf.h"
+int
+rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_register(roc_rvu_lf, (roc_rvu_lf_msg_handler_cb_fn)cb);
+}
+
+int
+rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_unregister(roc_rvu_lf);
+}
+
int
rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
index 54e4817604..a570507731 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
@@ -108,6 +108,55 @@ __rte_experimental
int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+/**
+ * Signature of callback function called when a message process handler is called
+ * on RVU LF device.
+ *
+ * @param vf
+ * VF number(0 to N) from which message is received (ignored in case of PF)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request
+ * @param req_len
+ * pointer to message request
+ * @param[out] rsp
+ * pointer to message response
+ * @param[out] rsp_len
+ * length of message response
+ *
+ * @return 0 when response is set, negative value otherwise
+ */
+typedef int (*rte_pmd_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
+/**
+ * Register message handler callback
+ *
+ * Registers message handler callback to be executed when the message is received from peer.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param cb
+ * callback function to be executed
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb);
+
+/**
+ * Unregister message handler callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
+
#ifdef __cplusplus
}
#endif
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v3 6/9] raw/cnxk_rvu_lf: set message ID range
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
` (4 preceding siblings ...)
2024-10-08 18:49 ` [PATCH v3 5/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
@ 2024-10-08 18:49 ` Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 7/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
` (3 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 18:49 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD API rte_pmd_rvu_lf_msg_id_range_set()
to set RVU mailbox message id range.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 12 ++++++++
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 30 +++++++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 3 ++
drivers/common/cnxk/version.map | 2 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 14 +++++++++
drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 15 ++++++++++
7 files changed, 77 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7bae6b523e..7f193e232c 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -60,3 +60,15 @@ Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register(
or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
The irq numbers for which the interrupts are registered is negotiated separately
and is not in scope of the driver.
+
+RVU LF RAW MESSAGE PROCESSING
+-----------------------------
+
+Once a RVU LF raw device is probed, a range of message ids can be configured for
+which mailboxes will be sent using the API ``rte_pmd_rvu_lf_msg_id_range_set``.
+
+For processing of mailboxes received on PF/VF application, application
+can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()``
+and fill required responses as per the request and message id received.
+Application can also unregister already registered message callbacks using
+``rte_pmd_rvu_lf_msg_handler_unregister()``.
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index dd65946e9e..f8791e9f84 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -54,6 +54,7 @@ struct mbox_msghdr {
#define MBOX_MSG_MASK 0xFFFF
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
+#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 2e1be81e52..1026ccc125 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,36 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+int
+roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (from <= MBOX_MSG_GENERIC_MAX_ID || from > to)
+ return -EINVAL;
+
+ rvu->msg_id_from = from;
+ rvu->msg_id_to = to;
+
+ return 0;
+}
+
+bool
+roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
+{
+ struct rvu_lf *rvu;
+
+ if (roc_rvu_lf == NULL)
+ return 0;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (msg_id > rvu->msg_id_from && msg_id < rvu->msg_id_to)
+ return 1;
+
+ return 0;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 90a0b5690a..7243e170b9 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t from, uint16_t to);
+bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
void *req, uint16_t req_len,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index f3c48ae3cb..ed390b8575 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -554,5 +554,7 @@ INTERNAL {
roc_rvu_lf_irq_unregister;
roc_rvu_lf_msg_handler_register;
roc_rvu_lf_msg_handler_unregister;
+ roc_rvu_lf_msg_id_range_check;
+ roc_rvu_lf_msg_id_range_set;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 13d33867a8..fcf51da8f6 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,20 @@
#include "cnxk_rvu_lf.h"
#include "rte_pmd_cnxk_rvu_lf.h"
+int
+rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
index a570507731..a612d1cebd 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
@@ -157,6 +157,21 @@ int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handl
__rte_experimental
int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
+/**
+ * Set RVU mailbox message id range.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param from
+ * starting message id for RVU mailbox (> 0x1FF)
+ * @param to
+ * last message id for RVU mailbox (< 0xFFFF)
+ *
+ * @return 0 on success, -EINVAL for invalid range
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+
#ifdef __cplusplus
}
#endif
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v3 7/9] raw/cnxk_rvu_lf: process mailbox message
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
` (5 preceding siblings ...)
2024-10-08 18:49 ` [PATCH v3 6/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
@ 2024-10-08 18:49 ` Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 8/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
` (2 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 18:49 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added PMD API rte_pmd_rvu_lf_msg_process() to process
mailbox messages between rvu_lf devices.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 ++
doc/guides/rel_notes/release_24_11.rst | 5 +
drivers/common/cnxk/roc_dev.c | 118 +++++++++++++++++-
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 58 +++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 +
drivers/common/cnxk/roc_rvu_lf_priv.h | 5 +
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 15 +++
drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 29 +++++
10 files changed, 240 insertions(+), 6 deletions(-)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7f193e232c..7b321abd38 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -72,3 +72,11 @@ can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()``
and fill required responses as per the request and message id received.
Application can also unregister already registered message callbacks using
``rte_pmd_rvu_lf_msg_handler_unregister()``.
+
+A PMD API ``rte_pmd_rvu_lf_msg_process()`` is created to send a request and
+receive corresponding response from the other side(PF/VF).
+It accepts an opaque pointer of a request and its size which can be defined by application
+and provides an opaque pointer for a response and its length.
+PF and VF application can define its own request and response based on the message id
+of the mailbox.
+For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``.
diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst
index b2bd442ee1..dadf058278 100644
--- a/doc/guides/rel_notes/release_24_11.rst
+++ b/doc/guides/rel_notes/release_24_11.rst
@@ -75,6 +75,11 @@ New Features
* Added ethdev driver support for CN20K SoC.
+* **Added Marvell cnxk RVU LF rawdev driver.**
+
+ Added a new raw device driver for Marvell cnxk based devices to allow
+ applications to communicate using mailboxes and notify for the interrupts.
+
Removed Items
-------------
diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index c905d35ea6..cb8d5d03fd 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -218,6 +218,51 @@ af_pf_wait_msg(struct dev *dev, uint16_t vf, int num_msg)
return req_hdr->num_msgs;
}
+static int
+process_rvu_lf_msgs(struct dev *dev, uint16_t vf, struct mbox_msghdr *msg, size_t size)
+{
+ uint16_t max_bits = sizeof(dev->active_vfs[0]) * 8;
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Handle BPHY mailbox message in PF */
+ dev->active_vfs[vf / max_bits] |= BIT_ULL(vf % max_bits);
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -1;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", vf);
+ return -1;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_vfpf, vf,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", vf);
+ return -1;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ free(resp);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return 0;
+}
+
/* PF receives mbox DOWN messages from VF and forwards to AF */
static int
vf_pf_process_msgs(struct dev *dev, uint16_t vf)
@@ -264,6 +309,9 @@ vf_pf_process_msgs(struct dev *dev, uint16_t vf)
/* PF/VF function ID */
rsp->hdr.pcifunc = msg->pcifunc;
rsp->hdr.rc = 0;
+ } else if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ if (process_rvu_lf_msgs(dev, vf, msg, size) < 0)
+ continue;
} else {
struct mbox_msghdr *af_req;
/* Reserve AF/PF mbox message */
@@ -342,8 +390,13 @@ vf_pf_process_up_msgs(struct dev *dev, uint16_t vf)
dev_get_vf(msg->pcifunc));
break;
default:
- plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
- msg->id, mbox_id2name(msg->id), msg->pcifunc);
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id))
+ plt_base_dbg("PF: Msg 0x%x fn:0x%x (pf:%d,vf:%d)",
+ msg->id, msg->pcifunc, dev_get_pf(msg->pcifunc),
+ dev_get_vf(msg->pcifunc));
+ else
+ plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
+ msg->id, mbox_id2name(msg->id), msg->pcifunc);
}
offset = mbox->rx_start + msg->next_msgoff;
}
@@ -792,6 +845,50 @@ mbox_process_msgs_up(struct dev *dev, struct mbox_msghdr *req)
return -ENODEV;
}
+static int
+process_rvu_lf_msgs_up(struct dev *dev, struct mbox_msghdr *msg, size_t size)
+{
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Check if valid, if not reply with an invalid msg */
+ if (msg->sig != MBOX_REQ_SIG)
+ return -EIO;
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -ENOMEM;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", dev->vf);
+ return rc;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_up, 0,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", dev->vf);
+ return -ENOMEM;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ free(resp);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return rc;
+}
+
/* Received up messages from AF (PF context) / PF (in context) */
static void
process_msgs_up(struct dev *dev, struct mbox *mbox)
@@ -800,6 +897,7 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
struct mbox_hdr *req_hdr;
struct mbox_msghdr *msg;
int i, err, offset;
+ size_t size;
req_hdr = (struct mbox_hdr *)((uintptr_t)mdev->mbase + mbox->rx_start);
if (req_hdr->num_msgs == 0)
@@ -812,10 +910,17 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
plt_base_dbg("Message 0x%x (%s) pf:%d/vf:%d", msg->id,
mbox_id2name(msg->id), dev_get_pf(msg->pcifunc),
dev_get_vf(msg->pcifunc));
- err = mbox_process_msgs_up(dev, msg);
- if (err)
- plt_err("Error %d handling 0x%x (%s)", err, msg->id,
- mbox_id2name(msg->id));
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ size = mbox->rx_start + msg->next_msgoff - offset;
+ err = process_rvu_lf_msgs_up(dev, msg, size);
+ if (err)
+ plt_err("Error %d handling 0x%x RVU_LF up msg", err, msg->id);
+ } else {
+ err = mbox_process_msgs_up(dev, msg);
+ if (err)
+ plt_err("Error %d handling 0x%x (%s)", err, msg->id,
+ mbox_id2name(msg->id));
+ }
offset = mbox->rx_start + msg->next_msgoff;
}
/* Send mbox responses */
@@ -1304,6 +1409,7 @@ dev_vf_hwcap_update(struct plt_pci_device *pci_dev, struct dev *dev)
case PCI_DEVID_CNXK_RVU_VF:
case PCI_DEVID_CNXK_RVU_SDP_VF:
case PCI_DEVID_CNXK_RVU_NIX_INL_VF:
+ case PCI_DEVID_CNXK_RVU_BPHY_VF:
case PCI_DEVID_CNXK_RVU_ESWITCH_VF:
dev->hwcap |= DEV_HWCAP_F_VF;
break;
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index f8791e9f84..4518680684 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -55,6 +55,7 @@ struct mbox_msghdr {
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
+#define MBOX_MSG_REQ_SIZE_MAX (16 * 1024)
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1026ccc125..471dfa7a46 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,15 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+static uint16_t
+roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ return dev->pf_func;
+}
+
int
roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
{
@@ -92,6 +101,55 @@ roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
return 0;
}
+int
+roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf, uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len, void *rsp_data, uint16_t rsp_len)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct mbox *mbox;
+ struct rvu_lf_msg *req;
+ struct rvu_lf_msg *rsp;
+ int rc = -ENOSPC;
+ int devid = 0;
+
+ if (rvu->dev.vf == -1 && roc_rvu_lf_msg_id_range_check(roc_rvu_lf, msg_id)) {
+ /* This is PF context */
+ if (vf >= rvu->dev.maxvf)
+ return -EINVAL;
+ devid = vf;
+ mbox = mbox_get(&rvu->dev.mbox_vfpf_up);
+ } else {
+ /* This is VF context */
+ devid = 0; /* VF send all message to PF */
+ mbox = mbox_get(rvu->dev.mbox);
+ }
+ req = (struct rvu_lf_msg *)mbox_alloc_msg_rsp(mbox, devid,
+ req_len + sizeof(struct rvu_lf_msg),
+ rsp_len + sizeof(struct rvu_lf_msg));
+ if (!req)
+ goto fail;
+ mbox_memcpy(req->data, req_data, req_len);
+ req->hdr.sig = MBOX_REQ_SIG;
+ req->hdr.id = msg_id;
+ req->hdr.pcifunc = roc_rvu_lf_pf_func_get(roc_rvu_lf);
+
+ if (rvu->dev.vf == -1) {
+ mbox_msg_send_up(mbox, devid);
+ rc = mbox_get_rsp(mbox, devid, (void *)&rsp);
+ if (rc)
+ goto fail;
+ } else {
+ rc = mbox_process_msg(mbox, (void *)&rsp);
+ if (rc)
+ goto fail;
+ }
+ if (rsp_len && rsp_data != NULL)
+ mbox_memcpy(rsp_data, rsp->data, rsp_len);
+fail:
+ mbox_put(mbox);
+ return rc;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7243e170b9..6b4819666a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,11 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len,
+ void *rsp_data, uint16_t rsp_len);
+
int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
uint16_t from, uint16_t to);
bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
index 8feff82961..57bb713b21 100644
--- a/drivers/common/cnxk/roc_rvu_lf_priv.h
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -17,6 +17,11 @@ struct rvu_lf {
uint16_t msg_id_to;
};
+struct rvu_lf_msg {
+ struct mbox_msghdr hdr;
+ uint8_t data[];
+};
+
static inline struct rvu_lf *
roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
{
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index ed390b8575..cd177a7920 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -556,5 +556,7 @@ INTERNAL {
roc_rvu_lf_msg_handler_unregister;
roc_rvu_lf_msg_id_range_check;
roc_rvu_lf_msg_id_range_set;
+ roc_rvu_lf_msg_process;
+
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index fcf51da8f6..a54eda5de5 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -30,6 +30,21 @@ rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
}
+int
+rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_process(roc_rvu_lf, vf, msg_id, req, req_len, rsp, rsp_len);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
index a612d1cebd..b79bd8ba8e 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
@@ -172,6 +172,35 @@ int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
__rte_experimental
int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+/**
+ * Process a RVU mailbox message.
+ *
+ * Message request and response to be sent/received,
+ * need to be allocated/deallocated by application
+ * before/after processing the message.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param vf
+ * VF number(0 to N) in case of PF->VF message. 0 is valid as VF0.
+ * (For VF->PF message, this field is ignored)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request data to be sent
+ * @param req_len
+ * length of request data
+ * @param rsp
+ * pointer to message response expected to be received, NULL if no response
+ * @param rsp_len
+ * length of message response expected, 0 if no response
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_experimental
+int rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len);
+
#ifdef __cplusplus
}
#endif
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v3 8/9] raw/cnxk_rvu_lf: add selftest
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
` (6 preceding siblings ...)
2024-10-08 18:49 ` [PATCH v3 7/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
@ 2024-10-08 18:49 ` Akhil Goyal
2024-10-23 14:16 ` David Marchand
2024-10-08 18:49 ` [PATCH v3 9/9] raw/cnxk_rvu_lf: add PMD API to get device pffunc Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
9 siblings, 1 reply; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 18:49 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added raw device selftest for cnxk_rvu_lf to verify
various PMD APIs.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 18 ++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 137 +++++++++++++++++++++++++-
2 files changed, 154 insertions(+), 1 deletion(-)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7b321abd38..59f6506ebb 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -80,3 +80,21 @@ and provides an opaque pointer for a response and its length.
PF and VF application can define its own request and response based on the message id
of the mailbox.
For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``.
+
+Self test
+---------
+
+On EAL initialization RVU_LF devices will be probed and populated into
+the raw devices. The rawdev ID of the device can be obtained using invocation
+of ``rte_rawdev_get_dev_id("NAME:x")`` from the test application, where:
+
+- NAME is the desired subsystem: use "RVU_LF".
+- x is the device's bus id specified in "bus:device.func" (BDF) format. BDF follows convention
+ used by lspci i.e bus, device and func are specified using respectively two, two and one hex
+ digit(s).
+
+Use this identifier for further rawdev function calls.
+
+Selftest rawdev API can be used to verify the mailbox communication between
+PF and VF devices based applications. There can be multiple VFs for a particular PF.
+Each VF can send mailboxes to PF and PF can broadcast message to all VFs.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index a54eda5de5..209af006f3 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -10,12 +10,147 @@
#include <rte_pci.h>
#include <rte_rawdev.h>
#include <rte_rawdev_pmd.h>
+#include <rte_hexdump.h>
#include <roc_api.h>
#include "cnxk_rvu_lf.h"
#include "rte_pmd_cnxk_rvu_lf.h"
+#define PF 0
+#define VF 0
+#define RSP_LEN 64
+#define REQ_LEN 64
+#define MSG_ID_FROM 0x3000
+#define MSG_ID_TO 0x4000
+
+static int
+msg_process_notify_cb(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void **rsp, uint16_t *rsp_len)
+{
+ uint8_t *resp;
+ int i;
+
+ printf("\nReceived message(0x%x) from VF0x%x\n", msg_id, vf);
+ rte_hexdump(stdout, "req_data received", req, req_len);
+
+ resp = malloc(RSP_LEN);
+ if (resp == NULL)
+ return -ENOMEM;
+ for (i = 0; i < RSP_LEN; i++)
+ resp[i] = 0xB0;
+ *rsp = resp;
+ *rsp_len = RSP_LEN;
+ rte_hexdump(stdout, "rsp_data_filled", *rsp, RSP_LEN);
+
+ return 0;
+}
+
+static int
+rvu_lf_rawdev_selftest(uint16_t dev_id)
+{
+ char *dev_name = rte_rawdevs[dev_id].name;
+ uint8_t req[REQ_LEN] = {0};
+ uint8_t rsp[RSP_LEN] = {0};
+ unsigned int i, j;
+ uint16_t pf_func;
+ char *token[2];
+ int func, ret;
+
+ token[0] = strtok_r(dev_name, ".", &dev_name);
+ token[1] = strtok_r(dev_name, ".", &dev_name);
+ func = atoi(token[1]);
+
+ ret = rte_rawdev_start(dev_id);
+ if (ret)
+ return ret;
+
+ pf_func = rte_pmd_rvu_lf_npa_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "NPA pf_func is invalid");
+
+ pf_func = rte_pmd_rvu_lf_sso_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "SSO pf_func is invalid");
+
+ ret = rte_pmd_rvu_lf_msg_id_range_set(dev_id, MSG_ID_FROM, MSG_ID_TO);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message ID range invalid");
+ goto out;
+ }
+
+ ret = rte_pmd_rvu_lf_msg_handler_register(dev_id, msg_process_notify_cb);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message handler register failed, ret: %d", ret);
+ goto out;
+ }
+
+ if (func == 0) {
+ j = 50;
+ printf("\n");
+ while (j--) {
+ /* PF will wait for RVU message callbacks to be called */
+ rte_delay_ms(1000);
+ printf("PF waiting for VF messages for %d sec.\r", j);
+ }
+ /* PF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xC0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO.
+ * Messages sent with this id will be serviced by VF..
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ VF /* Send to VF0 */,
+ MSG_ID_FROM + 0x2,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf PF->VF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU PF->VF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("PF waiting for VF to exit for %d sec.\r", j);
+ }
+
+ } else {
+ /* VF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xA0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO
+ * Messages sent with this id will be serviced by PF and will
+ * not be forwarded to AF.
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ PF /* Send to PF */,
+ MSG_ID_FROM + 0x1,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf VF->PF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU VF->PF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("VF waiting for PF to send msg for %d sec.\r", j);
+ }
+ }
+unregister:
+ rte_pmd_rvu_lf_msg_handler_unregister(dev_id);
+out:
+ rte_rawdev_stop(dev_id);
+
+ return ret;
+}
+
int
rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
{
@@ -139,7 +274,7 @@ rte_pmd_rvu_lf_sso_pf_func_get(void)
}
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
- .dev_selftest = NULL,
+ .dev_selftest = rvu_lf_rawdev_selftest,
};
static void
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v3 9/9] raw/cnxk_rvu_lf: add PMD API to get device pffunc
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
` (7 preceding siblings ...)
2024-10-08 18:49 ` [PATCH v3 8/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
@ 2024-10-08 18:49 ` Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-08 18:49 UTC (permalink / raw)
To: dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, Akhil Goyal
Added ``rte_pmd_rvu_lf_pf_func_get`` API
to get RVU LF device pffunc for the application use.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
drivers/common/cnxk/roc_rvu_lf.c | 2 +-
drivers/common/cnxk/roc_rvu_lf.h | 2 ++
drivers/common/cnxk/version.map | 1 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 19 +++++++++++++++++++
drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 12 ++++++++++++
5 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 471dfa7a46..862a201135 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,7 +62,7 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
-static uint16_t
+uint16_t
roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf)
{
struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 6b4819666a..8c71876cbc 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,8 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+uint16_t __roc_api roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf);
+
int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf,
uint16_t vf, uint16_t msg_id,
void *req_data, uint16_t req_len,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index cd177a7920..980b770d9b 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -557,6 +557,7 @@ INTERNAL {
roc_rvu_lf_msg_id_range_check;
roc_rvu_lf_msg_id_range_set;
roc_rvu_lf_msg_process;
+ roc_rvu_lf_pf_func_get;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 209af006f3..5262b45569 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -73,6 +73,10 @@ rvu_lf_rawdev_selftest(uint16_t dev_id)
if (pf_func == 0)
CNXK_RVU_LF_LOG(WARNING, "SSO pf_func is invalid");
+ pf_func = rte_pmd_rvu_lf_pf_func_get(dev_id);
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "RVU LF pf_func is invalid");
+
ret = rte_pmd_rvu_lf_msg_id_range_set(dev_id, MSG_ID_FROM, MSG_ID_TO);
if (ret) {
CNXK_RVU_LF_LOG(ERR, "RVU message ID range invalid");
@@ -273,6 +277,21 @@ rte_pmd_rvu_lf_sso_pf_func_get(void)
return roc_sso_pf_func_get();
}
+uint16_t
+rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id)
+{
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ if (rawdev == NULL)
+ return 0;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_pf_func_get(roc_rvu_lf);
+}
+
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
.dev_selftest = rvu_lf_rawdev_selftest,
};
diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
index b79bd8ba8e..5d167c55a0 100644
--- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
@@ -44,6 +44,18 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
__rte_experimental
uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+/**
+ * Obtain RVU LF device PF func
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ *
+ * @return
+ * Returns RVU LF pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_experimental
+uint16_t rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id);
+
/**
* Get BAR addresses for the RVU LF device.
*
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v3 1/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-08 18:49 ` [PATCH v3 1/9] " Akhil Goyal
@ 2024-10-08 20:44 ` Stephen Hemminger
2024-10-09 18:09 ` Stephen Hemminger
2024-10-23 14:01 ` David Marchand
2 siblings, 0 replies; 96+ messages in thread
From: Stephen Hemminger @ 2024-10-08 20:44 UTC (permalink / raw)
To: Akhil Goyal; +Cc: dev, thomas, david.marchand, hemant.agrawal, jerinj, hkalra
On Wed, 9 Oct 2024 00:19:07 +0530
Akhil Goyal <gakhil@marvell.com> wrote:
> +Marvell CNXK RVU LF Driver
> +==========================
> +
> +CNXK product families can have a use case to allow PF and VF
> +applications to communicate using mailboxes and also get notified
> +of any interrupt that may occur on the device.
> +Hence, a new raw device driver is added for such RVU LF devices.
> +These devices can map to a PF or a VF which can send mailboxes to
> +each other.
This wording is very indirect and awkward.
Please write documentation in imperative not passive voice.
If you need help, there are many online grammar tools to fix this kind of stuff.
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v2] rawdev: add API to get device from index
2024-10-08 7:40 ` [PATCH v2] " Akhil Goyal
2024-10-08 11:59 ` David Marchand
@ 2024-10-09 6:11 ` Hemant Agrawal
2024-10-22 19:12 ` David Marchand
2 siblings, 0 replies; 96+ messages in thread
From: Hemant Agrawal @ 2024-10-09 6:11 UTC (permalink / raw)
To: Akhil Goyal, dev; +Cc: thomas, david.marchand, hemant.agrawal, jerinj
Reviewed-by: Hemant Agrawal <hemant.agrawal@nxp.com>
On 08-10-2024 13:10, Akhil Goyal wrote:
> Added an internal API for PMDs to get raw device pointer
> from a device id.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
> - resend patch for main branch separated from rvu_lf raw driver
> https://patches.dpdk.org/project/dpdk/list/?series=32949
>
> lib/rawdev/rte_rawdev_pmd.h | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h
> index 22b406444d..8339122348 100644
> --- a/lib/rawdev/rte_rawdev_pmd.h
> +++ b/lib/rawdev/rte_rawdev_pmd.h
> @@ -102,6 +102,30 @@ rte_rawdev_pmd_get_named_dev(const char *name)
> return NULL;
> }
>
> +/**
> + * Get the rte_rawdev structure device pointer for given device ID.
> + *
> + * @param dev_id
> + * raw device index.
> + *
> + * @return
> + * - The rte_rawdev structure pointer for the given device ID.
> + */
> +static inline struct rte_rawdev *
> +rte_rawdev_pmd_get_dev(uint8_t dev_id)
> +{
> + struct rte_rawdev *dev;
> +
> + if (dev_id >= RTE_RAWDEV_MAX_DEVS)
> + return NULL;
> +
> + dev = &rte_rawdevs[dev_id];
> + if (dev->attached == RTE_RAWDEV_ATTACHED)
> + return dev;
> +
> + return NULL;
> +}
> +
> /**
> * Validate if the raw device index is a valid attached raw device.
> *
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v3 1/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-08 18:49 ` [PATCH v3 1/9] " Akhil Goyal
2024-10-08 20:44 ` Stephen Hemminger
@ 2024-10-09 18:09 ` Stephen Hemminger
2024-10-09 18:14 ` [EXTERNAL] " Akhil Goyal
2024-10-23 14:01 ` David Marchand
2 siblings, 1 reply; 96+ messages in thread
From: Stephen Hemminger @ 2024-10-09 18:09 UTC (permalink / raw)
To: Akhil Goyal; +Cc: dev, thomas, david.marchand, hemant.agrawal, jerinj, hkalra
On Wed, 9 Oct 2024 00:19:07 +0530
Akhil Goyal <gakhil@marvell.com> wrote:
> CNXK product families can have a use case to allow PF and VF
> applications to communicate using mailboxes and also get notified
> of any interrupt that may occur on the device.
> Hence, a new raw device driver is added for such RVU LF devices.
> These devices can map to a PF or a VF which can send mailboxes to
> each other.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
> MAINTAINERS | 6 ++
> doc/guides/rawdevs/cnxk_rvu_lf.rst | 40 +++++++++
> doc/guides/rawdevs/index.rst | 1 +
> drivers/common/cnxk/meson.build | 1 +
> drivers/common/cnxk/roc_api.h | 3 +
> drivers/common/cnxk/roc_constants.h | 3 +
This patch set does not apply to main branch, are you targeting another tree
or is there a dependency on a previous patch series.
$ cat drivers/common/cnxk/roc_constants.h.rej
--- drivers/common/cnxk/roc_constants.h
+++ drivers/common/cnxk/roc_constants.h
@@ -65,6 +67,7 @@
#define PCI_SUBSYSTEM_DEVID_CNF10KB 0xBC00
#define PCI_SUBSYSTEM_DEVID_CN20KA 0xA020
+#define PCI_SUBSYSTEM_DEVID_CNF20KA 0xA000
#define PCI_SUBSYSTEM_DEVID_CN9KA 0x0000
#define PCI_SUBSYSTEM_DEVID_CN9KB 0xb400
^ permalink raw reply [flat|nested] 96+ messages in thread
* RE: [EXTERNAL] Re: [PATCH v3 1/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-09 18:09 ` Stephen Hemminger
@ 2024-10-09 18:14 ` Akhil Goyal
0 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-09 18:14 UTC (permalink / raw)
To: Stephen Hemminger
Cc: dev, thomas, david.marchand, hemant.agrawal, Jerin Jacob, Harman Kalra
> On Wed, 9 Oct 2024 00:19:07 +0530
> Akhil Goyal <gakhil@marvell.com> wrote:
>
> > CNXK product families can have a use case to allow PF and VF
> > applications to communicate using mailboxes and also get notified
> > of any interrupt that may occur on the device.
> > Hence, a new raw device driver is added for such RVU LF devices.
> > These devices can map to a PF or a VF which can send mailboxes to
> > each other.
> >
> > Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> > ---
> > MAINTAINERS | 6 ++
> > doc/guides/rawdevs/cnxk_rvu_lf.rst | 40 +++++++++
> > doc/guides/rawdevs/index.rst | 1 +
> > drivers/common/cnxk/meson.build | 1 +
> > drivers/common/cnxk/roc_api.h | 3 +
> > drivers/common/cnxk/roc_constants.h | 3 +
>
> This patch set does not apply to main branch, are you targeting another tree
> or is there a dependency on a previous patch series.
This is targeted for next-net-mrvl and as mentioned in cover-letter it depends on
https://patches.dpdk.org/project/dpdk/patch/20241008074000.3745855-1-gakhil@marvell.com/
>
> $ cat drivers/common/cnxk/roc_constants.h.rej
> --- drivers/common/cnxk/roc_constants.h
> +++ drivers/common/cnxk/roc_constants.h
> @@ -65,6 +67,7 @@
> #define PCI_SUBSYSTEM_DEVID_CNF10KB 0xBC00
>
> #define PCI_SUBSYSTEM_DEVID_CN20KA 0xA020
> +#define PCI_SUBSYSTEM_DEVID_CNF20KA 0xA000
>
> #define PCI_SUBSYSTEM_DEVID_CN9KA 0x0000
> #define PCI_SUBSYSTEM_DEVID_CN9KB 0xb400
^ permalink raw reply [flat|nested] 96+ messages in thread
* RE: [EXTERNAL] Re: [PATCH v2] rawdev: add API to get device from index
2024-10-08 12:00 ` [EXTERNAL] " Akhil Goyal
@ 2024-10-09 21:13 ` Akhil Goyal
2024-10-21 10:48 ` Akhil Goyal
0 siblings, 1 reply; 96+ messages in thread
From: Akhil Goyal @ 2024-10-09 21:13 UTC (permalink / raw)
To: David Marchand, thomas; +Cc: dev, hemant.agrawal, Jerin Jacob, Akhil Goyal
> > > diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h
> > > index 22b406444d..8339122348 100644
> > > --- a/lib/rawdev/rte_rawdev_pmd.h
> > > +++ b/lib/rawdev/rte_rawdev_pmd.h
> > > @@ -102,6 +102,30 @@ rte_rawdev_pmd_get_named_dev(const char
> *name)
> > > return NULL;
> > > }
> > >
> > > +/**
> > > + * Get the rte_rawdev structure device pointer for given device ID.
> > > + *
> > > + * @param dev_id
> > > + * raw device index.
> > > + *
> > > + * @return
> > > + * - The rte_rawdev structure pointer for the given device ID.
> > > + */
> > > +static inline struct rte_rawdev *
> > > +rte_rawdev_pmd_get_dev(uint8_t dev_id)
> > > +{
> > > + struct rte_rawdev *dev;
> > > +
> > > + if (dev_id >= RTE_RAWDEV_MAX_DEVS)
> > > + return NULL;
> > > +
> > > + dev = &rte_rawdevs[dev_id];
> > > + if (dev->attached == RTE_RAWDEV_ATTACHED)
> > > + return dev;
> > > +
> > > + return NULL;
> > > +}
> > > +
> >
> > This seems simple enough and we have the same kind of helper in other
> > device class libraries.
> > But I would like to better understand the driver API that requires this.
> >
> This is being used in the new cnxk rvu_lf driver.
> https://patches.dpdk.org/project/dpdk/cover/20241008105415.1026962-1-gakhil@marvell.com/
Hi David/Thomas,
Can this patch be merged in RC1, so that PMD patches can be rebased in next-net-mrvl for RC2?
-Akhil
^ permalink raw reply [flat|nested] 96+ messages in thread
* RE: [EXTERNAL] Re: [PATCH v2] rawdev: add API to get device from index
2024-10-09 21:13 ` Akhil Goyal
@ 2024-10-21 10:48 ` Akhil Goyal
0 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-21 10:48 UTC (permalink / raw)
To: David Marchand, thomas; +Cc: dev, hemant.agrawal, Jerin Jacob
> Subject: RE: [EXTERNAL] Re: [PATCH v2] rawdev: add API to get device from index
>
> > > > diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h
> > > > index 22b406444d..8339122348 100644
> > > > --- a/lib/rawdev/rte_rawdev_pmd.h
> > > > +++ b/lib/rawdev/rte_rawdev_pmd.h
> > > > @@ -102,6 +102,30 @@ rte_rawdev_pmd_get_named_dev(const char
> > *name)
> > > > return NULL;
> > > > }
> > > >
> > > > +/**
> > > > + * Get the rte_rawdev structure device pointer for given device ID.
> > > > + *
> > > > + * @param dev_id
> > > > + * raw device index.
> > > > + *
> > > > + * @return
> > > > + * - The rte_rawdev structure pointer for the given device ID.
> > > > + */
> > > > +static inline struct rte_rawdev *
> > > > +rte_rawdev_pmd_get_dev(uint8_t dev_id)
> > > > +{
> > > > + struct rte_rawdev *dev;
> > > > +
> > > > + if (dev_id >= RTE_RAWDEV_MAX_DEVS)
> > > > + return NULL;
> > > > +
> > > > + dev = &rte_rawdevs[dev_id];
> > > > + if (dev->attached == RTE_RAWDEV_ATTACHED)
> > > > + return dev;
> > > > +
> > > > + return NULL;
> > > > +}
> > > > +
> > >
> > > This seems simple enough and we have the same kind of helper in other
> > > device class libraries.
> > > But I would like to better understand the driver API that requires this.
> > >
> > This is being used in the new cnxk rvu_lf driver.
> > https://patches.dpdk.org/project/dpdk/cover/20241008105415.1026962-1-
> gakhil@marvell.com/
>
> Hi David/Thomas,
> Can this patch be merged in RC1, so that PMD patches can be rebased in next-
> net-mrvl for RC2?
>
Can we merge this patch early into RC2, so that PMD patch can be rebased?
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-08 18:49 ` [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
@ 2024-10-21 21:30 ` Thomas Monjalon
2024-10-22 2:46 ` Jerin Jacob
0 siblings, 1 reply; 96+ messages in thread
From: Thomas Monjalon @ 2024-10-21 21:30 UTC (permalink / raw)
To: Akhil Goyal
Cc: dev, david.marchand, hemant.agrawal, jerinj, hkalra,
Stephen Hemminger, Bruce Richardson, Hemant Agrawal,
Sachin Saxena, Ferruh Yigit
08/10/2024 20:49, Akhil Goyal:
> Added rte_pmd_rvu_lf_bar_get() API to get BAR address
> for application to configure hardware.
In my opinion, we should not return PCI BAR addresses to an application.
We should make an effort to have all theses details managed in the driver.
Giving this level of access to an app is a door we should probably not open.
> +/**
> + * Get BAR addresses for the RVU LF device.
> + *
> + * @param dev_id
> + * device id of RVU LF device
> + * @param bar_num
> + * BAR number for which address is required
> + * @param[out] va
> + * Virtual address of the BAR. 0 if not mapped
> + * @param[out] mask
> + * BAR address mask, 0 if not mapped
> + *
> + * @return
> + * Returns 0 on success, negative error code otherwise
> + */
> +__rte_experimental
> +int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask);
The cover letter does not talk about this.
The announced features are:
"
- Register mailbox callbacks for the other side to process mailboxes.
- Register interrupt handler callbacks.
- Process mailbox.
- Set range of message IDs allowed for communication.
"
Having mailbox, callbacks and message IDs is perfectly fine.
It should not be needed to get PCI BARs for this purpose.
Maybe a level of abstraction is needed here.
Also I feel mailbox messaging is something we could make generic in rte_device.
As you may understand, I'm not a big fan of how the feature is implemented in this series.
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-21 21:30 ` Thomas Monjalon
@ 2024-10-22 2:46 ` Jerin Jacob
2024-10-22 6:05 ` [EXTERNAL] " Akhil Goyal
0 siblings, 1 reply; 96+ messages in thread
From: Jerin Jacob @ 2024-10-22 2:46 UTC (permalink / raw)
To: Thomas Monjalon
Cc: Akhil Goyal, dev, david.marchand, jerinj, hkalra,
Stephen Hemminger, Bruce Richardson, Hemant Agrawal,
Sachin Saxena, Ferruh Yigit
On Tue, Oct 22, 2024 at 3:00 AM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 08/10/2024 20:49, Akhil Goyal:
> > Added rte_pmd_rvu_lf_bar_get() API to get BAR address
> > for application to configure hardware.
>
> In my opinion, we should not return PCI BAR addresses to an application.
> We should make an effort to have all theses details managed in the driver.
> Giving this level of access to an app is a door we should probably not open.
I agree with this in the traditional application laying context.
Typical layering is "driver" -> "device class like ethdev" ->application.
In this case, This raw driver is a proprietary 5G PCIe device where
the DPDK does not have a subsystem for that. So application is layered
to have "Hardware abstraction library" and "Application"
i.e "cnxk lf raw driver" -> "Hardware abstraction library using the
BAR address" -> "Real Application". The real application is taking
only to the Hardware abstraction library.
The rational to NOT pull "Hardware abstraction library using the BAR
address" to DPDK are
-Yet another 200K of driver C++ code which does not make sense to keep
in dpdk.org
-It can not implemenent any of the current subsystems
In this context, let me know what you think?
^ permalink raw reply [flat|nested] 96+ messages in thread
* RE: [EXTERNAL] Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-22 2:46 ` Jerin Jacob
@ 2024-10-22 6:05 ` Akhil Goyal
2024-10-22 9:27 ` Thomas Monjalon
2024-10-22 10:08 ` David Marchand
0 siblings, 2 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-22 6:05 UTC (permalink / raw)
To: Jerin Jacob, Thomas Monjalon
Cc: dev, david.marchand, Jerin Jacob, Harman Kalra,
Stephen Hemminger, Bruce Richardson, Hemant Agrawal,
Sachin Saxena, Ferruh Yigit
> On Tue, Oct 22, 2024 at 3:00 AM Thomas Monjalon <thomas@monjalon.net>
> wrote:
> >
> > 08/10/2024 20:49, Akhil Goyal:
> > > Added rte_pmd_rvu_lf_bar_get() API to get BAR address
> > > for application to configure hardware.
> >
> > In my opinion, we should not return PCI BAR addresses to an application.
> > We should make an effort to have all theses details managed in the driver.
> > Giving this level of access to an app is a door we should probably not open.
>
> I agree with this in the traditional application laying context.
> Typical layering is "driver" -> "device class like ethdev" ->application.
>
> In this case, This raw driver is a proprietary 5G PCIe device where
> the DPDK does not have a subsystem for that. So application is layered
> to have "Hardware abstraction library" and "Application"
> i.e "cnxk lf raw driver" -> "Hardware abstraction library using the
> BAR address" -> "Real Application". The real application is taking
> only to the Hardware abstraction library.
>
> The rational to NOT pull "Hardware abstraction library using the BAR
> address" to DPDK are
> -Yet another 200K of driver C++ code which does not make sense to keep
> in dpdk.org
> -It can not implemenent any of the current subsystems
>
> In this context, let me know what you think?
Just to add one more point.
Even if we don’t use this API, we can still get the BAR addresses as David mentioned in another mail chain
rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar addr
This we can get for each raw PCI device, not just cnxk_rvu_lf. Right?
This API is just avoiding the hassle of application to use 4 calls/indirections to get the BAR address.
So having an API to improve usability should not be an issue.
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [EXTERNAL] Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-22 6:05 ` [EXTERNAL] " Akhil Goyal
@ 2024-10-22 9:27 ` Thomas Monjalon
2024-10-22 10:08 ` David Marchand
1 sibling, 0 replies; 96+ messages in thread
From: Thomas Monjalon @ 2024-10-22 9:27 UTC (permalink / raw)
To: Jerin Jacob, Akhil Goyal
Cc: dev, david.marchand, Jerin Jacob, Harman Kalra,
Stephen Hemminger, Bruce Richardson, Hemant Agrawal,
Sachin Saxena, Ferruh Yigit, techboard
22/10/2024 08:05, Akhil Goyal:
> > On Tue, Oct 22, 2024 at 3:00 AM Thomas Monjalon <thomas@monjalon.net>
> > wrote:
> > >
> > > 08/10/2024 20:49, Akhil Goyal:
> > > > Added rte_pmd_rvu_lf_bar_get() API to get BAR address
> > > > for application to configure hardware.
> > >
> > > In my opinion, we should not return PCI BAR addresses to an application.
> > > We should make an effort to have all theses details managed in the driver.
> > > Giving this level of access to an app is a door we should probably not open.
> >
> > I agree with this in the traditional application laying context.
> > Typical layering is "driver" -> "device class like ethdev" ->application.
> >
> > In this case, This raw driver is a proprietary 5G PCIe device where
> > the DPDK does not have a subsystem for that. So application is layered
> > to have "Hardware abstraction library" and "Application"
> > i.e "cnxk lf raw driver" -> "Hardware abstraction library using the
> > BAR address" -> "Real Application". The real application is taking
> > only to the Hardware abstraction library.
> >
> > The rational to NOT pull "Hardware abstraction library using the BAR
> > address" to DPDK are
> > -Yet another 200K of driver C++ code which does not make sense to keep
> > in dpdk.org
> > -It can not implemenent any of the current subsystems
> >
> > In this context, let me know what you think?
>
> Just to add one more point.
> Even if we don’t use this API, we can still get the BAR addresses as David mentioned in another mail chain
> rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar addr
>
> This we can get for each raw PCI device, not just cnxk_rvu_lf. Right?
>
> This API is just avoiding the hassle of application to use 4 calls/indirections to get the BAR address.
> So having an API to improve usability should not be an issue.
I'm not confortable taking this decision alone.
I wonder what others think?
Adding the techboard as Cc.
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [EXTERNAL] Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-22 6:05 ` [EXTERNAL] " Akhil Goyal
2024-10-22 9:27 ` Thomas Monjalon
@ 2024-10-22 10:08 ` David Marchand
2024-10-22 12:06 ` Akhil Goyal
2024-10-22 15:30 ` Stephen Hemminger
1 sibling, 2 replies; 96+ messages in thread
From: David Marchand @ 2024-10-22 10:08 UTC (permalink / raw)
To: Akhil Goyal
Cc: Jerin Jacob, Thomas Monjalon, dev, Jerin Jacob, Harman Kalra,
Stephen Hemminger, Bruce Richardson, Hemant Agrawal,
Sachin Saxena, Ferruh Yigit
On Tue, Oct 22, 2024 at 8:06 AM Akhil Goyal <gakhil@marvell.com> wrote:
> > The rational to NOT pull "Hardware abstraction library using the BAR
> > address" to DPDK are
> > -Yet another 200K of driver C++ code which does not make sense to keep
> > in dpdk.org
> > -It can not implemenent any of the current subsystems
> >
> > In this context, let me know what you think?
This hardware abstraction library will have to call some driver
specific API (like the added raw/cnxk_rvu API).
Can this library directly use the PCI driver API, and call the cnxk
common driver?
If so, there is no need to add another driver API (that breaks
layers), and the rawdev driver is only about adding the mailbox
features.
>
> Just to add one more point.
> Even if we don’t use this API, we can still get the BAR addresses as David mentioned in another mail chain
> rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar addr
>
> This we can get for each raw PCI device, not just cnxk_rvu_lf. Right?
Any PCI driver can do this (via bus_pci_driver.h header, exported with
the enable_driver_sdk meson option).
That's not exposed to application.
Your abstraction library may cache this info if you think it will have
an impact on fast path.
--
David Marchand
^ permalink raw reply [flat|nested] 96+ messages in thread
* RE: [EXTERNAL] Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-22 10:08 ` David Marchand
@ 2024-10-22 12:06 ` Akhil Goyal
2024-10-23 16:00 ` Thomas Monjalon
2024-10-22 15:30 ` Stephen Hemminger
1 sibling, 1 reply; 96+ messages in thread
From: Akhil Goyal @ 2024-10-22 12:06 UTC (permalink / raw)
To: David Marchand
Cc: Jerin Jacob, Thomas Monjalon, dev, Jerin Jacob, Harman Kalra,
Stephen Hemminger, Bruce Richardson, Hemant Agrawal,
Sachin Saxena, Ferruh Yigit
> On Tue, Oct 22, 2024 at 8:06 AM Akhil Goyal <gakhil@marvell.com> wrote:
> > > The rational to NOT pull "Hardware abstraction library using the BAR
> > > address" to DPDK are
> > > -Yet another 200K of driver C++ code which does not make sense to keep
> > > in dpdk.org
> > > -It can not implemenent any of the current subsystems
> > >
> > > In this context, let me know what you think?
>
> This hardware abstraction library will have to call some driver
> specific API (like the added raw/cnxk_rvu API).
> Can this library directly use the PCI driver API, and call the cnxk
> common driver?
> If so, there is no need to add another driver API (that breaks
> layers), and the rawdev driver is only about adding the mailbox
> features.
cnxk common has a lot of internal APIs which
we do not want to expose directly to application.
It seems the only contentious API is to get the BAR addresses.
All other APIs seems to be fine. Right?
If so, we can remove that API and get the bar addresses as you suggested below.
rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar addr
via bus_pci_driver.h header, exported via enable_driver_sdk option
If it is ok, I can send the next version with this change and documentation update.
But we need to merge the library patch to get the device from dev_id.
https://patches.dpdk.org/project/dpdk/patch/20241008074000.3745855-1-gakhil@marvell.com/
> >
> > Just to add one more point.
> > Even if we don’t use this API, we can still get the BAR addresses as David
> mentioned in another mail chain
> > rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar addr
> >
> > This we can get for each raw PCI device, not just cnxk_rvu_lf. Right?
>
> Any PCI driver can do this (via bus_pci_driver.h header, exported with
> the enable_driver_sdk meson option).
> That's not exposed to application.
>
> Your abstraction library may cache this info if you think it will have
> an impact on fast path.
Yes, that can be done if we are not allowing the PMD API.
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [EXTERNAL] Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-22 10:08 ` David Marchand
2024-10-22 12:06 ` Akhil Goyal
@ 2024-10-22 15:30 ` Stephen Hemminger
2024-10-22 17:06 ` Jerin Jacob
1 sibling, 1 reply; 96+ messages in thread
From: Stephen Hemminger @ 2024-10-22 15:30 UTC (permalink / raw)
To: David Marchand
Cc: Akhil Goyal, Jerin Jacob, Thomas Monjalon, dev, Jerin Jacob,
Harman Kalra, Bruce Richardson, Hemant Agrawal, Sachin Saxena,
Ferruh Yigit
On Tue, 22 Oct 2024 12:08:22 +0200
David Marchand <david.marchand@redhat.com> wrote:
> On Tue, Oct 22, 2024 at 8:06 AM Akhil Goyal <gakhil@marvell.com> wrote:
> > > The rational to NOT pull "Hardware abstraction library using the BAR
> > > address" to DPDK are
> > > -Yet another 200K of driver C++ code which does not make sense to keep
> > > in dpdk.org
> > > -It can not implemenent any of the current subsystems
> > >
> > > In this context, let me know what you think?
>
> This hardware abstraction library will have to call some driver
> specific API (like the added raw/cnxk_rvu API).
> Can this library directly use the PCI driver API, and call the cnxk
> common driver?
> If so, there is no need to add another driver API (that breaks
> layers), and the rawdev driver is only about adding the mailbox
> features.
>
This seems related to the discussion of binary drivers in the TB.
There was discussion that any/all use of binary drivers means that the any
crashes in DPDK could be cause by that binary. Like the Linux kernel,
we need a "tainted" policy. Where any bug reports on tainted use of DPDK
are just rejected and forwarded to the binary driver vendor.
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [EXTERNAL] Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-22 15:30 ` Stephen Hemminger
@ 2024-10-22 17:06 ` Jerin Jacob
0 siblings, 0 replies; 96+ messages in thread
From: Jerin Jacob @ 2024-10-22 17:06 UTC (permalink / raw)
To: Stephen Hemminger
Cc: David Marchand, Akhil Goyal, Thomas Monjalon, dev, Jerin Jacob,
Harman Kalra, Bruce Richardson, Hemant Agrawal, Sachin Saxena,
Ferruh Yigit
On Tue, Oct 22, 2024 at 9:00 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Tue, 22 Oct 2024 12:08:22 +0200
> David Marchand <david.marchand@redhat.com> wrote:
>
> > On Tue, Oct 22, 2024 at 8:06 AM Akhil Goyal <gakhil@marvell.com> wrote:
> > > > The rational to NOT pull "Hardware abstraction library using the BAR
> > > > address" to DPDK are
> > > > -Yet another 200K of driver C++ code which does not make sense to keep
> > > > in dpdk.org
> > > > -It can not implemenent any of the current subsystems
> > > >
> > > > In this context, let me know what you think?
> >
> > This hardware abstraction library will have to call some driver
> > specific API (like the added raw/cnxk_rvu API).
> > Can this library directly use the PCI driver API, and call the cnxk
> > common driver?
> > If so, there is no need to add another driver API (that breaks
> > layers), and the rawdev driver is only about adding the mailbox
> > features.
> >
>
>
> This seems related to the discussion of binary drivers in the TB.
> There was discussion that any/all use of binary drivers means that the any
> crashes in DPDK could be cause by that binary. Like the Linux kernel,
> we need a "tainted" policy. Where any bug reports on tainted use of DPDK
> are just rejected and forwarded to the binary driver vendor.
It is not a binary driver situation, it is more out of tree driver
situation i.e DPDK does not depend on any binary drivers. It is the
same as exposing rte_pci_device via enable_driver_sdk meson option.
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v2] rawdev: add API to get device from index
2024-10-08 7:40 ` [PATCH v2] " Akhil Goyal
2024-10-08 11:59 ` David Marchand
2024-10-09 6:11 ` Hemant Agrawal
@ 2024-10-22 19:12 ` David Marchand
2 siblings, 0 replies; 96+ messages in thread
From: David Marchand @ 2024-10-22 19:12 UTC (permalink / raw)
To: Akhil Goyal
Cc: dev, thomas, hemant.agrawal, jerinj, Rosen Xu, Jakub Palider,
Tomasz Duszynski
On Tue, Oct 8, 2024 at 9:40 AM Akhil Goyal <gakhil@marvell.com> wrote:
>
> Added an internal API for PMDs to get raw device pointer
> from a device id.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> Reviewed-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Applied, thanks.
Can someone send a followup patch cleaning raw/cnxk_bphy and raw/ifpga
that implement a similar helper?
Cc: maintainers of those drivers.
--
David Marchand
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v3 1/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-08 18:49 ` [PATCH v3 1/9] " Akhil Goyal
2024-10-08 20:44 ` Stephen Hemminger
2024-10-09 18:09 ` Stephen Hemminger
@ 2024-10-23 14:01 ` David Marchand
2 siblings, 0 replies; 96+ messages in thread
From: David Marchand @ 2024-10-23 14:01 UTC (permalink / raw)
To: Akhil Goyal; +Cc: dev, thomas, hemant.agrawal, jerinj, hkalra
On Tue, Oct 8, 2024 at 8:49 PM Akhil Goyal <gakhil@marvell.com> wrote:
>
> CNXK product families can have a use case to allow PF and VF
> applications to communicate using mailboxes and also get notified
> of any interrupt that may occur on the device.
> Hence, a new raw device driver is added for such RVU LF devices.
> These devices can map to a PF or a VF which can send mailboxes to
> each other.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Some small comments below.
> diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
> new file mode 100644
> index 0000000000..36067909be
> --- /dev/null
> +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
> @@ -0,0 +1,123 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2024 Marvell.
> + */
> +
> +#include <bus_pci_driver.h>
> +#include <rte_common.h>
> +#include <dev_driver.h>
> +#include <rte_eal.h>
> +#include <rte_lcore.h>
> +#include <rte_pci.h>
> +#include <rte_rawdev.h>
> +#include <rte_rawdev_pmd.h>
> +
> +#include <roc_api.h>
> +
> +#include "cnxk_rvu_lf.h"
> +
> +static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
> + .dev_selftest = NULL,
> +};
> +
> +static void
> +rvu_lf_rawdev_get_name(char *name, struct rte_pci_device *pci_dev)
> +{
> + snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "RVU LF:%02x:%02x.%x",
> + pci_dev->addr.bus, pci_dev->addr.devid,
> + pci_dev->addr.function);
> +}
> +
> +static int
> +rvu_lf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
> +{
> + char name[RTE_RAWDEV_NAME_MAX_LEN];
> + struct rte_rawdev *rvu_lf_rawdev;
> + struct roc_rvu_lf *roc_rvu_lf;
> + int ret;
> +
> + RTE_SET_USED(pci_drv);
> +
> + if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> + return 0;
> +
> + if (!pci_dev->mem_resource[2].addr) {
> + CNXK_RVU_LF_LOG(ERR, "BARs have invalid values: BAR0 %p\n BAR2 %p",
No \n in the middle of a log please.
> + pci_dev->mem_resource[2].addr, pci_dev->mem_resource[4].addr);
> + return -ENODEV;
> + }
> +
> + ret = roc_plt_init();
> + if (ret)
> + return ret;
> +
> + rvu_lf_rawdev_get_name(name, pci_dev);
> + rvu_lf_rawdev = rte_rawdev_pmd_allocate(name, sizeof(*roc_rvu_lf),
> + rte_socket_id());
> + if (rvu_lf_rawdev == NULL) {
> + CNXK_RVU_LF_LOG(ERR, "Failed to allocate rawdev");
> + return -ENOMEM;
> + }
> +
> + rvu_lf_rawdev->dev_ops = &rvu_lf_rawdev_ops;
> + rvu_lf_rawdev->device = &pci_dev->device;
> + rvu_lf_rawdev->driver_name = pci_dev->driver->driver.name;
> +
> + roc_rvu_lf = (struct roc_rvu_lf *)rvu_lf_rawdev->dev_private;
> + roc_rvu_lf->pci_dev = pci_dev;
> +
> + ret = roc_rvu_lf_dev_init(roc_rvu_lf);
> + if (ret) {
> + rte_rawdev_pmd_release(rvu_lf_rawdev);
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static int
> +rvu_lf_remove(struct rte_pci_device *pci_dev)
> +{
> + char name[RTE_RAWDEV_NAME_MAX_LEN];
> + struct roc_rvu_lf *roc_rvu_lf;
> + struct rte_rawdev *rawdev;
> +
> + if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> + return 0;
> +
> + if (pci_dev == NULL) {
> + CNXK_RVU_LF_LOG(ERR, "invalid pci_dev");
> + return -EINVAL;
> + }
> +
> + rvu_lf_rawdev_get_name(name, pci_dev);
> + rawdev = rte_rawdev_pmd_get_named_dev(name);
> + if (rawdev == NULL) {
> + CNXK_RVU_LF_LOG(ERR, "invalid device name (%s)", name);
> + return -EINVAL;
> + }
> +
> + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
> + roc_rvu_lf_dev_fini(roc_rvu_lf);
> +
> + return rte_rawdev_pmd_release(rawdev);
> +}
> +
> +static const struct rte_pci_id pci_rvu_lf_map[] = {
> + CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_PF),
> + CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_VF),
> + {
> + .vendor_id = 0,
> + },
> +};
> +
> +static struct rte_pci_driver cnxk_rvu_lf_rawdev_pmd = {
> + .id_table = pci_rvu_lf_map,
> + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
> + .probe = rvu_lf_probe,
> + .remove = rvu_lf_remove,
> +};
> +
> +RTE_PMD_REGISTER_PCI(rvu_lf_rawdev_pci_driver, cnxk_rvu_lf_rawdev_pmd);
> +RTE_PMD_REGISTER_PCI_TABLE(rvu_lf_rawdev_pci_driver, pci_rvu_lf_map);
> +RTE_PMD_REGISTER_KMOD_DEP(rvu_lf_rawdev_pci_driver, "vfio-pci");
> +RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_rvu_lf, rvu_lf, INFO);
> diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
> new file mode 100644
> index 0000000000..a23a629500
> --- /dev/null
> +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
> @@ -0,0 +1,35 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2024 Marvell.
> + */
> +
> +#ifndef _CNXK_RVU_LF_H_
> +#define _CNXK_RVU_LF_H_
> +
> +#include <stdint.h>
> +
> +#include <rte_common.h>
> +
> +/**
> + * @file cnxk_rvu_lf.h
> + *
> + * Marvell RVU LF raw PMD specific internal structures
> + *
> + * This API allows applications to manage RVU LF device in user space along with
> + * installing interrupt handlers for low latency signal processing.
> + */
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
You don't need this for non exported/internal headers.
> +
> +extern int cnxk_logtype_rvu_lf;
> +
> +#define CNXK_RVU_LF_LOG(level, fmt, args...) \
> + rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \
> + "%s(): " fmt "\n", __func__, ## args)
Please convert to RTE_LOG_LINE_PREFIX.
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* _CNXK_RVU_LF_H_ */
--
David Marchand
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v3 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc
2024-10-08 18:49 ` [PATCH v3 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
@ 2024-10-23 14:13 ` David Marchand
0 siblings, 0 replies; 96+ messages in thread
From: David Marchand @ 2024-10-23 14:13 UTC (permalink / raw)
To: Akhil Goyal; +Cc: dev, thomas, hemant.agrawal, jerinj, hkalra
On Tue, Oct 8, 2024 at 8:49 PM Akhil Goyal <gakhil@marvell.com> wrote:
>
> Added rte_pmd_rvu_lf_npa_pf_func_get and
> rte_pmd_rvu_lf_sso_pf_func_get APIs to get NPA and
> SSO pffunc for the application use.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
You are missing some update of drivers/raw/cnxk_rvu_lf/version.map.
Without it, symbols from this library won't be exported in .so.
> ---
> doc/api/doxy-api-index.md | 1 +
> doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 +++
> drivers/common/cnxk/roc_npa.c | 6 +++
> drivers/common/cnxk/roc_npa.h | 3 ++
> drivers/common/cnxk/roc_sso.c | 6 +++
> drivers/common/cnxk/roc_sso.h | 3 ++
> drivers/common/cnxk/version.map | 2 +
> drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 13 +++++
> drivers/raw/cnxk_rvu_lf/meson.build | 1 +
> drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 51 +++++++++++++++++++
> 10 files changed, 93 insertions(+)
> create mode 100644 drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h
--
David Marchand
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v3 8/9] raw/cnxk_rvu_lf: add selftest
2024-10-08 18:49 ` [PATCH v3 8/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
@ 2024-10-23 14:16 ` David Marchand
0 siblings, 0 replies; 96+ messages in thread
From: David Marchand @ 2024-10-23 14:16 UTC (permalink / raw)
To: Akhil Goyal; +Cc: dev, thomas, hemant.agrawal, jerinj, hkalra
On Tue, Oct 8, 2024 at 8:49 PM Akhil Goyal <gakhil@marvell.com> wrote:
>
> Added raw device selftest for cnxk_rvu_lf to verify
> various PMD APIs.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
> doc/guides/rawdevs/cnxk_rvu_lf.rst | 18 ++++
> drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 137 +++++++++++++++++++++++++-
> 2 files changed, 154 insertions(+), 1 deletion(-)
Can you move selftest code in a dedicated file to make it clearer what
is actual driver code and selftest?
Like drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c for example.
--
David Marchand
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [EXTERNAL] Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-22 12:06 ` Akhil Goyal
@ 2024-10-23 16:00 ` Thomas Monjalon
2024-10-23 19:14 ` Akhil Goyal
0 siblings, 1 reply; 96+ messages in thread
From: Thomas Monjalon @ 2024-10-23 16:00 UTC (permalink / raw)
To: Akhil Goyal
Cc: David Marchand, dev, Jerin Jacob, Jerin Jacob, Harman Kalra,
Stephen Hemminger, Bruce Richardson, Hemant Agrawal,
Sachin Saxena, Ferruh Yigit
22/10/2024 14:06, Akhil Goyal:
> > On Tue, Oct 22, 2024 at 8:06 AM Akhil Goyal <gakhil@marvell.com> wrote:
> > > > The rational to NOT pull "Hardware abstraction library using the BAR
> > > > address" to DPDK are
> > > > -Yet another 200K of driver C++ code which does not make sense to keep
> > > > in dpdk.org
> > > > -It can not implemenent any of the current subsystems
> > > >
> > > > In this context, let me know what you think?
> >
> > This hardware abstraction library will have to call some driver
> > specific API (like the added raw/cnxk_rvu API).
> > Can this library directly use the PCI driver API, and call the cnxk
> > common driver?
> > If so, there is no need to add another driver API (that breaks
> > layers), and the rawdev driver is only about adding the mailbox
> > features.
>
> cnxk common has a lot of internal APIs which
> we do not want to expose directly to application.
Actually the target is an out-of-tree driver, not an application.
> It seems the only contentious API is to get the BAR addresses.
> All other APIs seems to be fine. Right?
Interrupt management is also something we would like to see reserved to drivers.
> If so, we can remove that API and get the bar addresses as you suggested below.
> rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar addr
> via bus_pci_driver.h header, exported via enable_driver_sdk option
Yes please, it is better to avoid confusion between driver and application.
Any driver type layer should be exposed only when the Meson option
enable_driver_sdk is enabled.
You probably should export the interrupt functions in a separate file
through driver_sdk_headers, so it is clear it is not an application level.
Does it apply to the mailbox functions as well?
> If it is ok, I can send the next version with this change and documentation update.
Yes, thanks.
^ permalink raw reply [flat|nested] 96+ messages in thread
* RE: [EXTERNAL] Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-23 16:00 ` Thomas Monjalon
@ 2024-10-23 19:14 ` Akhil Goyal
2024-10-23 19:29 ` Thomas Monjalon
0 siblings, 1 reply; 96+ messages in thread
From: Akhil Goyal @ 2024-10-23 19:14 UTC (permalink / raw)
To: Thomas Monjalon
Cc: David Marchand, dev, Jerin Jacob, Jerin Jacob, Harman Kalra,
Stephen Hemminger, Bruce Richardson, Hemant Agrawal,
Sachin Saxena, Ferruh Yigit
> 22/10/2024 14:06, Akhil Goyal:
> > > On Tue, Oct 22, 2024 at 8:06 AM Akhil Goyal <gakhil@marvell.com> wrote:
> > > > > The rational to NOT pull "Hardware abstraction library using the BAR
> > > > > address" to DPDK are
> > > > > -Yet another 200K of driver C++ code which does not make sense to keep
> > > > > in dpdk.org
> > > > > -It can not implemenent any of the current subsystems
> > > > >
> > > > > In this context, let me know what you think?
> > >
> > > This hardware abstraction library will have to call some driver
> > > specific API (like the added raw/cnxk_rvu API).
> > > Can this library directly use the PCI driver API, and call the cnxk
> > > common driver?
> > > If so, there is no need to add another driver API (that breaks
> > > layers), and the rawdev driver is only about adding the mailbox
> > > features.
> >
> > cnxk common has a lot of internal APIs which
> > we do not want to expose directly to application.
>
> Actually the target is an out-of-tree driver, not an application.
>
> > It seems the only contentious API is to get the BAR addresses.
> > All other APIs seems to be fine. Right?
>
> Interrupt management is also something we would like to see reserved to drivers.
>
> > If so, we can remove that API and get the bar addresses as you suggested
> below.
> > rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar addr
> > via bus_pci_driver.h header, exported via enable_driver_sdk option
>
> Yes please, it is better to avoid confusion between driver and application.
> Any driver type layer should be exposed only when the Meson option
> enable_driver_sdk is enabled.
>
> You probably should export the interrupt functions in a separate file
> through driver_sdk_headers, so it is clear it is not an application level.
> Does it apply to the mailbox functions as well?
>
Ok, if we are having a separate file as driver_sdk_header,
We can also keep the BAR address API in that. Right?
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [EXTERNAL] Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-23 19:14 ` Akhil Goyal
@ 2024-10-23 19:29 ` Thomas Monjalon
2024-10-24 13:03 ` Akhil Goyal
0 siblings, 1 reply; 96+ messages in thread
From: Thomas Monjalon @ 2024-10-23 19:29 UTC (permalink / raw)
To: Akhil Goyal
Cc: David Marchand, dev, Jerin Jacob, Jerin Jacob, Harman Kalra,
Stephen Hemminger, Bruce Richardson, Hemant Agrawal,
Sachin Saxena, Ferruh Yigit
23/10/2024 21:14, Akhil Goyal:
> > 22/10/2024 14:06, Akhil Goyal:
> > > > On Tue, Oct 22, 2024 at 8:06 AM Akhil Goyal <gakhil@marvell.com> wrote:
> > > > > > The rational to NOT pull "Hardware abstraction library using the BAR
> > > > > > address" to DPDK are
> > > > > > -Yet another 200K of driver C++ code which does not make sense to keep
> > > > > > in dpdk.org
> > > > > > -It can not implemenent any of the current subsystems
> > > > > >
> > > > > > In this context, let me know what you think?
> > > >
> > > > This hardware abstraction library will have to call some driver
> > > > specific API (like the added raw/cnxk_rvu API).
> > > > Can this library directly use the PCI driver API, and call the cnxk
> > > > common driver?
> > > > If so, there is no need to add another driver API (that breaks
> > > > layers), and the rawdev driver is only about adding the mailbox
> > > > features.
> > >
> > > cnxk common has a lot of internal APIs which
> > > we do not want to expose directly to application.
> >
> > Actually the target is an out-of-tree driver, not an application.
> >
> > > It seems the only contentious API is to get the BAR addresses.
> > > All other APIs seems to be fine. Right?
> >
> > Interrupt management is also something we would like to see reserved to drivers.
> >
> > > If so, we can remove that API and get the bar addresses as you suggested
> > below.
> > > rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar addr
> > > via bus_pci_driver.h header, exported via enable_driver_sdk option
> >
> > Yes please, it is better to avoid confusion between driver and application.
> > Any driver type layer should be exposed only when the Meson option
> > enable_driver_sdk is enabled.
> >
> > You probably should export the interrupt functions in a separate file
> > through driver_sdk_headers, so it is clear it is not an application level.
> > Does it apply to the mailbox functions as well?
> >
> Ok, if we are having a separate file as driver_sdk_header,
> We can also keep the BAR address API in that. Right?
I think yes but it is redundant with the path
rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar addr
Is it performance sensitive? In this case you could save/cache it.
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
` (8 preceding siblings ...)
2024-10-08 18:49 ` [PATCH v3 9/9] raw/cnxk_rvu_lf: add PMD API to get device pffunc Akhil Goyal
@ 2024-10-24 13:01 ` Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 1/9] " Akhil Goyal
` (9 more replies)
9 siblings, 10 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
bruce.richards, stephen, sachin.saxena, ferruh.yigit,
Akhil Goyal
CNXK product families can have a use case to allow PF and VF
applications to communicate using mailboxes and also get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
The RVU LF device implements following features in the rawdev API:
- Register mailbox callbacks for the other side to process mailboxes.
- Register interrupt handler callbacks.
- Process mailbox.
- Set range of message IDs allowed for communication.
Changes in v4:
- moved all PMD APIs to internal APIs to be exposed via
enable_driver_sdk meson option.
- added missing version.map entries as internal APIs.
- separate out selftest in a separate file
- fixed logs
Changes in v3:
- fix internal/external header files.
Changes in v2:
- removed library patch from series
- removed PMD logs from external PMD header.
- updated doc/api/doxy-api-index.md
- Added release notes
Akhil Goyal (9):
drivers/raw: introduce cnxk rvu lf device driver
raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc
raw/cnxk_rvu_lf: register/unregister interrupt handler
raw/cnxk_rvu_lf: register/unregister msg handler
raw/cnxk_rvu_lf: set message ID range
raw/cnxk_rvu_lf: process mailbox message
raw/cnxk_rvu_lf: add API to get device pffunc
raw/cnxk_rvu_lf: add API to get BAR addresses
raw/cnxk_rvu_lf: add selftest
MAINTAINERS | 6 +
doc/guides/rawdevs/cnxk_rvu_lf.rst | 100 +++++++
doc/guides/rawdevs/index.rst | 1 +
doc/guides/rel_notes/release_24_11.rst | 5 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 3 +
drivers/common/cnxk/roc_dev.c | 118 +++++++-
drivers/common/cnxk/roc_dev_priv.h | 7 +
drivers/common/cnxk/roc_idev.c | 46 ++++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_mbox.h | 2 +
drivers/common/cnxk/roc_npa.c | 6 +
drivers/common/cnxk/roc_npa.h | 3 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 202 ++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 46 ++++
drivers/common/cnxk/roc_rvu_lf_priv.h | 37 +++
drivers/common/cnxk/roc_sso.c | 6 +
drivers/common/cnxk/roc_sso.h | 3 +
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 16 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 260 ++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 26 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 216 +++++++++++++++
.../raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c | 147 ++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 11 +
drivers/raw/cnxk_rvu_lf/version.map | 16 ++
drivers/raw/meson.build | 1 +
30 files changed, 1291 insertions(+), 6 deletions(-)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
create mode 100644 drivers/raw/cnxk_rvu_lf/version.map
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v4 1/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
@ 2024-10-24 13:01 ` Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc Akhil Goyal
` (8 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
bruce.richards, stephen, sachin.saxena, ferruh.yigit,
Akhil Goyal
CNXK product families can have a use case to allow PF and VF
applications to communicate using mailboxes and also get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
MAINTAINERS | 6 ++
doc/guides/rawdevs/cnxk_rvu_lf.rst | 40 +++++++++
doc/guides/rawdevs/index.rst | 1 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 3 +
drivers/common/cnxk/roc_dev_priv.h | 1 +
drivers/common/cnxk/roc_idev.c | 46 ++++++++++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 63 +++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 24 +++++
drivers/common/cnxk/roc_rvu_lf_priv.h | 32 +++++++
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 5 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 123 ++++++++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 24 +++++
drivers/raw/cnxk_rvu_lf/meson.build | 9 ++
drivers/raw/meson.build | 1 +
20 files changed, 391 insertions(+)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
diff --git a/MAINTAINERS b/MAINTAINERS
index cd78bc7db1..fe1464d06a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1503,6 +1503,12 @@ T: git://dpdk.org/next/dpdk-next-net-mrvl
F: doc/guides/rawdevs/cnxk_gpio.rst
F: drivers/raw/cnxk_gpio/
+Marvell CNXK RVU LF
+M: Akhil Goyal <gakhil@marvell.com>
+T: git://dpdk.org/next/dpdk-next-net-mrvl
+F: doc/guides/rawdevs/cnxk_rvu_lf.rst
+F: drivers/raw/cnxk_rvu_lf/
+
NTB
M: Jingjing Wu <jingjing.wu@intel.com>
F: drivers/raw/ntb/
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
new file mode 100644
index 0000000000..8a0bc22dd5
--- /dev/null
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -0,0 +1,40 @@
+.. SPDX-License-Identifier: BSD-3-Clause
+ Copyright(c) 2024 Marvell.
+
+Marvell CNXK RVU LF Driver
+==========================
+
+CNXK product families can have a use case to allow PF and VF
+applications to communicate using mailboxes and also get notified
+of any interrupt that may occur on the device.
+Hence, a new raw device driver is added for such RVU LF devices.
+These devices can map to a PF or a VF which can send mailboxes to
+each other.
+
+Features
+--------
+
+The RVU LF device implements following features in the rawdev API:
+
+- Register mailbox callbacks for the other side to process mailboxes.
+- Register interrupt handler callbacks.
+- Process mailbox.
+- Set range of message IDs allowed for communication.
+
+Limitations
+-----------
+
+In multiprocess mode user-space application must ensure
+no resources sharing takes place.
+Otherwise, user-space application should ensure synchronization.
+
+Device Setup
+------------
+
+The RVU LF devices will need to be bound to a user-space IO driver for use.
+The script ``dpdk-devbind.py`` included with DPDK can be used to
+view the state of the devices and to bind them to a suitable DPDK-supported
+kernel driver. When querying the status of the devices, they will appear under
+the category of "Misc (rawdev) devices", i.e. the command
+``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
+devices alone.
diff --git a/doc/guides/rawdevs/index.rst b/doc/guides/rawdevs/index.rst
index f34315f051..8e07cf4d6c 100644
--- a/doc/guides/rawdevs/index.rst
+++ b/doc/guides/rawdevs/index.rst
@@ -13,6 +13,7 @@ application through rawdev API.
cnxk_bphy
cnxk_gpio
+ cnxk_rvu_lf
dpaa2_cmdif
ifpga
ntb
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index abb0f6f01f..cb0ffd5d40 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -71,6 +71,7 @@ sources = files(
'roc_tim_irq.c',
'roc_utils.c',
'roc_ree.c',
+ 'roc_rvu_lf.c',
)
# Security common code
diff --git a/drivers/common/cnxk/roc_api.h b/drivers/common/cnxk/roc_api.h
index 6a86863c57..93e7bf11bb 100644
--- a/drivers/common/cnxk/roc_api.h
+++ b/drivers/common/cnxk/roc_api.h
@@ -120,4 +120,7 @@
/* Eswitch */
#include "roc_eswitch.h"
+/* RVU LF */
+#include "roc_rvu_lf.h"
+
#endif /* _ROC_API_H_ */
diff --git a/drivers/common/cnxk/roc_constants.h b/drivers/common/cnxk/roc_constants.h
index 0e7495a37c..67cd74b28a 100644
--- a/drivers/common/cnxk/roc_constants.h
+++ b/drivers/common/cnxk/roc_constants.h
@@ -45,6 +45,8 @@
#define PCI_DEVID_CNXK_RVU_REE_VF 0xA0f5
#define PCI_DEVID_CNXK_RVU_ESWITCH_PF 0xA0E0
#define PCI_DEVID_CNXK_RVU_ESWITCH_VF 0xA0E1
+#define PCI_DEVID_CNXK_RVU_BPHY_PF 0xA0E4
+#define PCI_DEVID_CNXK_RVU_BPHY_VF 0xA0E5
#define PCI_DEVID_CN9K_CGX 0xA059
#define PCI_DEVID_CN10K_RPM 0xA060
@@ -63,6 +65,7 @@
#define PCI_SUBSYSTEM_DEVID_CNF10KB 0xBC00
#define PCI_SUBSYSTEM_DEVID_CN20KA 0xA020
+#define PCI_SUBSYSTEM_DEVID_CNF20KA 0xA000
#define PCI_SUBSYSTEM_DEVID_CN9KA 0x0000
#define PCI_SUBSYSTEM_DEVID_CN9KB 0xb400
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index 5ab4f72f8f..dd4949b32c 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -141,6 +141,7 @@ struct dev {
void *roc_cpt;
void *roc_tim;
void *roc_ml;
+ void *roc_rvu_lf;
bool disable_shared_lmt; /* false(default): shared lmt mode enabled */
const struct plt_memzone *lmt_mz;
struct mbox_sync sync;
diff --git a/drivers/common/cnxk/roc_idev.c b/drivers/common/cnxk/roc_idev.c
index 0778d51d1e..84812f73e0 100644
--- a/drivers/common/cnxk/roc_idev.c
+++ b/drivers/common/cnxk/roc_idev.c
@@ -38,6 +38,7 @@ idev_set_defaults(struct idev_cfg *idev)
idev->num_lmtlines = 0;
idev->bphy = NULL;
idev->cpt = NULL;
+ TAILQ_INIT(&idev->rvu_lf_list);
TAILQ_INIT(&idev->mcs_list);
idev->nix_inl_dev = NULL;
TAILQ_INIT(&idev->roc_nix_list);
@@ -188,6 +189,51 @@ roc_idev_cpt_get(void)
return NULL;
}
+struct roc_rvu_lf *
+roc_idev_rvu_lf_get(uint8_t rvu_lf_idx)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf, &idev->rvu_lf_list, next) {
+ if (rvu_lf->idx == rvu_lf_idx)
+ return rvu_lf;
+ }
+ }
+
+ return NULL;
+}
+
+void
+roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ return;
+ }
+ TAILQ_INSERT_TAIL(&idev->rvu_lf_list, rvu, next);
+ }
+}
+
+void
+roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ TAILQ_REMOVE(&idev->rvu_lf_list, rvu, next);
+ }
+ }
+}
+
struct roc_mcs *
roc_idev_mcs_get(uint8_t mcs_idx)
{
diff --git a/drivers/common/cnxk/roc_idev.h b/drivers/common/cnxk/roc_idev.h
index fc0f7db54e..6edb5f83b2 100644
--- a/drivers/common/cnxk/roc_idev.h
+++ b/drivers/common/cnxk/roc_idev.h
@@ -29,4 +29,8 @@ uint16_t *__roc_api roc_idev_nix_rx_chan_base_get(void);
void __roc_api roc_idev_nix_rx_chan_set(uint16_t port, uint16_t chan);
uint16_t __roc_api roc_idev_nix_inl_dev_pffunc_get(void);
+
+struct roc_rvu_lf *__roc_api roc_idev_rvu_lf_get(uint8_t rvu_lf_idx);
+void __roc_api roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu);
+void __roc_api roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu);
#endif /* _ROC_IDEV_H_ */
diff --git a/drivers/common/cnxk/roc_idev_priv.h b/drivers/common/cnxk/roc_idev_priv.h
index 6628b18152..98b6286bfe 100644
--- a/drivers/common/cnxk/roc_idev_priv.h
+++ b/drivers/common/cnxk/roc_idev_priv.h
@@ -36,6 +36,7 @@ struct idev_cfg {
struct roc_bphy *bphy;
struct roc_cpt *cpt;
struct roc_sso *sso;
+ struct roc_rvu_lf_head rvu_lf_list;
struct roc_mcs_head mcs_list;
struct nix_inl_dev *nix_inl_dev;
struct idev_nix_inl_cfg inl_cfg;
diff --git a/drivers/common/cnxk/roc_priv.h b/drivers/common/cnxk/roc_priv.h
index 254a2d3310..8732a05ac3 100644
--- a/drivers/common/cnxk/roc_priv.h
+++ b/drivers/common/cnxk/roc_priv.h
@@ -53,4 +53,6 @@
/* ML */
#include "roc_ml_priv.h"
+/* RVU LF */
+#include "roc_rvu_lf_priv.h"
#endif /* _ROC_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
new file mode 100644
index 0000000000..1ae39e746e
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include "roc_api.h"
+#include "roc_priv.h"
+
+int
+roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct plt_pci_device *pci_dev;
+ struct dev *dev;
+ struct rvu_lf *rvu;
+ int rc;
+
+ if (roc_rvu_lf == NULL || roc_rvu_lf->pci_dev == NULL)
+ return RVU_ERR_PARAM;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ pci_dev = roc_rvu_lf->pci_dev;
+ dev = &rvu->dev;
+
+ if (rvu->dev.drv_inited)
+ return 0;
+
+ if (dev->mbox_active)
+ goto skip_dev_init;
+
+ memset(rvu, 0, sizeof(*rvu));
+
+ /* Initialize device */
+ rc = dev_init(dev, pci_dev);
+ if (rc) {
+ plt_err("Failed to init roc device");
+ goto fail;
+ }
+
+skip_dev_init:
+ dev->roc_rvu_lf = roc_rvu_lf;
+ rvu->pci_dev = pci_dev;
+
+ roc_idev_rvu_lf_set(roc_rvu_lf);
+ rvu->dev.drv_inited = true;
+
+ return 0;
+fail:
+ return rc;
+}
+
+int
+roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (rvu == NULL)
+ return NIX_ERR_PARAM;
+
+ rvu->dev.drv_inited = false;
+
+ roc_idev_rvu_lf_free(roc_rvu_lf);
+
+ return dev_fini(&rvu->dev, rvu->pci_dev);
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
new file mode 100644
index 0000000000..7ce8065a8b
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_H_
+#define _ROC_RVU_LF_H_
+
+#include "roc_platform.h"
+
+struct roc_rvu_lf {
+ TAILQ_ENTRY(roc_rvu_lf) next;
+ struct plt_pci_device *pci_dev;
+ uint8_t idx;
+#define ROC_RVU_MEM_SZ (6 * 1024)
+ uint8_t reserved[ROC_RVU_MEM_SZ] __plt_cache_aligned;
+};
+
+TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
+
+/* Dev */
+int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+
+#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
new file mode 100644
index 0000000000..8feff82961
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_PRIV_H_
+#define _ROC_RVU_LF_PRIV_H_
+
+enum rvu_err_status {
+ RVU_ERR_PARAM = -1,
+ RVU_ERR_NO_MEM = -2,
+};
+
+struct rvu_lf {
+ struct plt_pci_device *pci_dev;
+ struct dev dev;
+ uint16_t msg_id_from;
+ uint16_t msg_id_to;
+};
+
+static inline struct rvu_lf *
+roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
+{
+ return (struct rvu_lf *)&roc_rvu_lf->reserved[0];
+}
+
+static inline struct roc_rvu_lf *
+rvu_priv_to_roc_rvu_lf(struct rvu_lf *rvu_lf)
+{
+ return (struct roc_rvu_lf *)((char *)rvu_lf - offsetof(struct roc_rvu_lf, reserved));
+}
+
+#endif /* _ROC_RVU_LF_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_utils.c b/drivers/common/cnxk/roc_utils.c
index 9af2ae9b69..bcc0d2de38 100644
--- a/drivers/common/cnxk/roc_utils.c
+++ b/drivers/common/cnxk/roc_utils.c
@@ -17,11 +17,13 @@ roc_error_msg_get(int errorcode)
case NPC_ERR_PARAM:
case SSO_ERR_PARAM:
case MCS_ERR_PARAM:
+ case RVU_ERR_PARAM:
case UTIL_ERR_PARAM:
err_msg = "Invalid parameter";
break;
case NIX_ERR_NO_MEM:
case NPC_ERR_NO_MEM:
+ case RVU_ERR_NO_MEM:
err_msg = "Out of memory";
break;
case NIX_ERR_INVALID_RANGE:
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 877333b80c..777e260731 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -119,6 +119,9 @@ INTERNAL {
roc_idev_nix_rx_chan_set;
roc_idev_nix_rx_inject_get;
roc_idev_nix_rx_inject_set;
+ roc_idev_rvu_lf_free;
+ roc_idev_rvu_lf_get;
+ roc_idev_rvu_lf_set;
roc_ml_reg_read64;
roc_ml_reg_write64;
roc_ml_reg_read32;
@@ -544,5 +547,7 @@ INTERNAL {
roc_ree_rule_db_get;
roc_ree_rule_db_len_get;
roc_ree_rule_db_prog;
+ roc_rvu_lf_dev_fini;
+ roc_rvu_lf_dev_init;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
new file mode 100644
index 0000000000..1ed12d6979
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include <bus_pci_driver.h>
+#include <rte_common.h>
+#include <dev_driver.h>
+#include <rte_eal.h>
+#include <rte_lcore.h>
+#include <rte_pci.h>
+#include <rte_rawdev.h>
+#include <rte_rawdev_pmd.h>
+
+#include <roc_api.h>
+
+#include "cnxk_rvu_lf.h"
+
+static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
+ .dev_selftest = NULL,
+};
+
+static void
+rvu_lf_rawdev_get_name(char *name, struct rte_pci_device *pci_dev)
+{
+ snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "RVU LF:%02x:%02x.%x",
+ pci_dev->addr.bus, pci_dev->addr.devid,
+ pci_dev->addr.function);
+}
+
+static int
+rvu_lf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct rte_rawdev *rvu_lf_rawdev;
+ struct roc_rvu_lf *roc_rvu_lf;
+ int ret;
+
+ RTE_SET_USED(pci_drv);
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (!pci_dev->mem_resource[2].addr) {
+ CNXK_RVU_LF_LOG(ERR, "BARs have invalid values: BAR0 %p, BAR2 %p",
+ pci_dev->mem_resource[2].addr, pci_dev->mem_resource[4].addr);
+ return -ENODEV;
+ }
+
+ ret = roc_plt_init();
+ if (ret)
+ return ret;
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rvu_lf_rawdev = rte_rawdev_pmd_allocate(name, sizeof(*roc_rvu_lf),
+ rte_socket_id());
+ if (rvu_lf_rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "Failed to allocate rawdev");
+ return -ENOMEM;
+ }
+
+ rvu_lf_rawdev->dev_ops = &rvu_lf_rawdev_ops;
+ rvu_lf_rawdev->device = &pci_dev->device;
+ rvu_lf_rawdev->driver_name = pci_dev->driver->driver.name;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rvu_lf_rawdev->dev_private;
+ roc_rvu_lf->pci_dev = pci_dev;
+
+ ret = roc_rvu_lf_dev_init(roc_rvu_lf);
+ if (ret) {
+ rte_rawdev_pmd_release(rvu_lf_rawdev);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int
+rvu_lf_remove(struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (pci_dev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid pci_dev");
+ return -EINVAL;
+ }
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rawdev = rte_rawdev_pmd_get_named_dev(name);
+ if (rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid device name (%s)", name);
+ return -EINVAL;
+ }
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+ roc_rvu_lf_dev_fini(roc_rvu_lf);
+
+ return rte_rawdev_pmd_release(rawdev);
+}
+
+static const struct rte_pci_id pci_rvu_lf_map[] = {
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_PF),
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_VF),
+ {
+ .vendor_id = 0,
+ },
+};
+
+static struct rte_pci_driver cnxk_rvu_lf_rawdev_pmd = {
+ .id_table = pci_rvu_lf_map,
+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
+ .probe = rvu_lf_probe,
+ .remove = rvu_lf_remove,
+};
+
+RTE_PMD_REGISTER_PCI(rvu_lf_rawdev_pci_driver, cnxk_rvu_lf_rawdev_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(rvu_lf_rawdev_pci_driver, pci_rvu_lf_map);
+RTE_PMD_REGISTER_KMOD_DEP(rvu_lf_rawdev_pci_driver, "vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_rvu_lf, rvu_lf, INFO);
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
new file mode 100644
index 0000000000..65cc1bb64d
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _CNXK_RVU_LF_H_
+#define _CNXK_RVU_LF_H_
+
+#include <stdint.h>
+
+#include <rte_common.h>
+
+/**
+ * @file cnxk_rvu_lf.h
+ *
+ * Marvell RVU LF raw PMD specific internal structures
+ *
+ */
+
+extern int cnxk_logtype_rvu_lf;
+#define RTE_LOGTYPE_CNXK_RVU_LF cnxk_logtype_rvu_lf
+#define CNXK_RVU_LF_LOG(level, ...) \
+ RTE_LOG_LINE_PREFIX(level, CNXK_RVU_LF, "%s(): ", __func__, __VA_ARGS__)
+
+#endif /* _CNXK_RVU_LF_H_ */
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
new file mode 100644
index 0000000000..32081e147f
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2024 Marvell.
+#
+
+deps += ['bus_pci', 'common_cnxk', 'rawdev']
+sources = files(
+ 'cnxk_rvu_lf.c',
+)
+require_iova_in_mbuf = false
diff --git a/drivers/raw/meson.build b/drivers/raw/meson.build
index 05cad143fe..54221643d5 100644
--- a/drivers/raw/meson.build
+++ b/drivers/raw/meson.build
@@ -8,6 +8,7 @@ endif
drivers = [
'cnxk_bphy',
'cnxk_gpio',
+ 'cnxk_rvu_lf',
'dpaa2_cmdif',
'ifpga',
'ntb',
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v4 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 1/9] " Akhil Goyal
@ 2024-10-24 13:01 ` Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 3/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
` (7 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
bruce.richards, stephen, sachin.saxena, ferruh.yigit,
Akhil Goyal
Added rte_pmd_rvu_lf_npa_pf_func_get and
rte_pmd_rvu_lf_sso_pf_func_get APIs to get NPA and
SSO pffunc for the application/external driver use.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 +++
drivers/common/cnxk/roc_npa.c | 6 +++
drivers/common/cnxk/roc_npa.h | 3 ++
drivers/common/cnxk/roc_sso.c | 6 +++
drivers/common/cnxk/roc_sso.h | 3 ++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 13 ++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 47 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 1 +
drivers/raw/cnxk_rvu_lf/version.map | 8 ++++
10 files changed, 96 insertions(+)
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
create mode 100644 drivers/raw/cnxk_rvu_lf/version.map
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 8a0bc22dd5..13184ad4dc 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -38,3 +38,10 @@ kernel driver. When querying the status of the devices, they will appear under
the category of "Misc (rawdev) devices", i.e. the command
``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
devices alone.
+
+Get NPA and SSO PF FUNC
+-----------------------
+
+APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
+can be used to get the cnxk NPA PF func and SSO PF func which application
+can use for NPA/SSO specific configuration.
diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index 934d7361a9..a33f9a8499 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -17,6 +17,12 @@ roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb)
return 0;
}
+uint16_t
+roc_npa_pf_func_get(void)
+{
+ return idev_npa_pffunc_get();
+}
+
void
roc_npa_pool_op_range_set(uint64_t aura_handle, uint64_t start_iova,
uint64_t end_iova)
diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h
index fbf75b2fca..f7cb4460e7 100644
--- a/drivers/common/cnxk/roc_npa.h
+++ b/drivers/common/cnxk/roc_npa.h
@@ -820,6 +820,9 @@ int __roc_api roc_npa_aura_bp_configure(uint64_t aura_id, uint16_t bpid, uint8_t
typedef int (*roc_npa_lf_init_cb_t)(struct plt_pci_device *pci_dev);
int __roc_api roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb);
+/* Utility functions */
+uint16_t __roc_api roc_npa_pf_func_get(void);
+
/* Debug */
int __roc_api roc_npa_ctx_dump(void);
int __roc_api roc_npa_dump(void);
diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c
index 2e3b134bfc..aed8819a1b 100644
--- a/drivers/common/cnxk/roc_sso.c
+++ b/drivers/common/cnxk/roc_sso.c
@@ -319,6 +319,12 @@ roc_sso_hwgrp_base_get(struct roc_sso *roc_sso, uint16_t hwgrp)
return dev->bar2 + (RVU_BLOCK_ADDR_SSO << 20 | hwgrp << 12);
}
+uint16_t
+roc_sso_pf_func_get(void)
+{
+ return idev_sso_pffunc_get();
+}
+
uint64_t
roc_sso_ns_to_gw(uint64_t base, uint64_t ns)
{
diff --git a/drivers/common/cnxk/roc_sso.h b/drivers/common/cnxk/roc_sso.h
index 4ac901762e..3e293a0a69 100644
--- a/drivers/common/cnxk/roc_sso.h
+++ b/drivers/common/cnxk/roc_sso.h
@@ -103,6 +103,9 @@ int __roc_api roc_sso_hwgrp_stash_config(struct roc_sso *roc_sso,
void __roc_api roc_sso_hws_gwc_invalidate(struct roc_sso *roc_sso, uint8_t *hws,
uint8_t nb_hws);
+/* Utility function */
+uint16_t __roc_api roc_sso_pf_func_get(void);
+
/* Debug */
void __roc_api roc_sso_dump(struct roc_sso *roc_sso, uint8_t nb_hws,
uint16_t hwgrp, FILE *f);
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 777e260731..d4c3e6c425 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -452,6 +452,7 @@ INTERNAL {
roc_npa_dev_unlock;
roc_npa_dump;
roc_npa_lf_init_cb_register;
+ roc_npa_pf_func_get;
roc_npa_pool_create;
roc_npa_pool_destroy;
roc_npa_pool_op_pc_reset;
@@ -519,6 +520,7 @@ INTERNAL {
roc_sso_hws_gwc_invalidate;
roc_sso_hws_unlink;
roc_sso_ns_to_gw;
+ roc_sso_pf_func_get;
roc_sso_rsrc_fini;
roc_sso_rsrc_init;
roc_tim_fini;
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 1ed12d6979..c8490ccbab 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -14,6 +14,19 @@
#include <roc_api.h>
#include "cnxk_rvu_lf.h"
+#include "cnxk_rvu_lf_driver.h"
+
+uint16_t
+rte_pmd_rvu_lf_npa_pf_func_get(void)
+{
+ return roc_npa_pf_func_get();
+}
+
+uint16_t
+rte_pmd_rvu_lf_sso_pf_func_get(void)
+{
+ return roc_sso_pf_func_get();
+}
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
.dev_selftest = NULL,
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
new file mode 100644
index 0000000000..3837a6066d
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _CNXK_RVU_LF_DRIVER_H_
+#define _CNXK_RVU_LF_DRIVER_H_
+
+#include <stdint.h>
+
+#include <rte_common.h>
+
+/**
+ * @file cnxk_rvu_lf_driver.h
+ *
+ * Marvell RVU LF raw PMD specific structures and interface
+ *
+ * This API allows external driver/application to manage RVU LF device
+ * in user space along with installing interrupt handlers for low latency signal processing.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Obtain NPA PF func
+ *
+ * @return
+ * Returns NPA pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_internal
+uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
+
+/**
+ * Obtain SSO PF func
+ *
+ * @return
+ * Returns SSO pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_internal
+uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CNXK_RVU_LF_DRIVER_H_ */
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
index 32081e147f..7ea1c3916c 100644
--- a/drivers/raw/cnxk_rvu_lf/meson.build
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -6,4 +6,5 @@ deps += ['bus_pci', 'common_cnxk', 'rawdev']
sources = files(
'cnxk_rvu_lf.c',
)
+driver_sdk_headers += files('cnxk_rvu_lf_driver.h')
require_iova_in_mbuf = false
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
new file mode 100644
index 0000000000..3b81544aac
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -0,0 +1,8 @@
+INTERNAL {
+ global:
+
+ rte_pmd_rvu_lf_npa_pf_func_get;
+ rte_pmd_rvu_lf_sso_pf_func_get;
+
+ local: *;
+};
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v4 3/9] raw/cnxk_rvu_lf: register/unregister interrupt handler
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 1/9] " Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc Akhil Goyal
@ 2024-10-24 13:01 ` Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 4/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
` (6 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
bruce.richards, stephen, sachin.saxena, ferruh.yigit,
Akhil Goyal
Added API rte_pmd_rvu_lf_irq_register() and
rte_pmd_rvu_lf_irq_unregister() to register/unregister
interrupt handlers for rvu lf raw device.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 ++++
drivers/common/cnxk/roc_rvu_lf.c | 26 +++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 +++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 30 +++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 46 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 2 +
7 files changed, 119 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 13184ad4dc..52e4f12e3c 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -45,3 +45,11 @@ Get NPA and SSO PF FUNC
APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
can be used to get the cnxk NPA PF func and SSO PF func which application
can use for NPA/SSO specific configuration.
+
+Register or remove interrupt handler
+------------------------------------
+
+Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register()``
+or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
+The irq numbers for which the interrupts are registered is negotiated separately
+and is not in scope of the driver.
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1ae39e746e..63bc149f2a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -61,3 +61,29 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+
+int
+roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ return dev_irq_register(handle, (plt_intr_callback_fn)cb, data, irq);
+}
+
+int
+roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ dev_irq_unregister(handle, (plt_intr_callback_fn)cb, data, irq);
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7ce8065a8b..800bf4e674 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,4 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index d4c3e6c425..4e687c1cb8 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -551,5 +551,7 @@ INTERNAL {
roc_ree_rule_db_prog;
roc_rvu_lf_dev_fini;
roc_rvu_lf_dev_init;
+ roc_rvu_lf_irq_register;
+ roc_rvu_lf_irq_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index c8490ccbab..c108931f97 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,36 @@
#include "cnxk_rvu_lf.h"
#include "cnxk_rvu_lf_driver.h"
+int
+rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_register(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
+int
+rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_unregister(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
uint16_t
rte_pmd_rvu_lf_npa_pf_func_get(void)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 3837a6066d..61bbcb7c04 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -40,6 +40,52 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
__rte_internal
uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+/**
+ * Signature of callback function called when an interrupt is received on RVU LF device.
+ *
+ * @param cb_arg
+ * pointer to the information received on an interrupt
+ */
+typedef void (*rte_pmd_rvu_lf_intr_callback_fn)(void *cb_arg);
+
+/**
+ * Register interrupt callback
+ *
+ * Registers an interrupt callback to be executed when interrupt is raised.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number for which interrupt will be raised
+ * @param cb
+ * callback function to be executed
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
+/**
+ * Unregister interrupt callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number
+ * @param cb
+ * callback function registered
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index 3b81544aac..a2e8a2c9b3 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -1,6 +1,8 @@
INTERNAL {
global:
+ rte_pmd_rvu_lf_irq_register;
+ rte_pmd_rvu_lf_irq_unregister;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v4 4/9] raw/cnxk_rvu_lf: register/unregister msg handler
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (2 preceding siblings ...)
2024-10-24 13:01 ` [PATCH v4 3/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
@ 2024-10-24 13:01 ` Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 5/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
` (5 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
bruce.richards, stephen, sachin.saxena, ferruh.yigit,
Akhil Goyal
Added APIs rte_pmd_rvu_lf_msg_handler_register()
and rte_pmd_rvu_lf_msg_handler_unregister() to register/unregister
mailbox message handlers. These handlers are needed to fill
response at the other side for the request sent from one side.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
drivers/common/cnxk/roc_dev_priv.h | 6 +++
drivers/common/cnxk/roc_rvu_lf.c | 25 ++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 7 +++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 28 +++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 49 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 2 +
7 files changed, 119 insertions(+)
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index dd4949b32c..c766183196 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -46,11 +46,17 @@ typedef void (*link_status_get_t)(void *roc_nix,
/* Representee notification callback */
typedef int (*repte_notify_t)(void *roc_nix, void *notify_msg);
+/* RVU Message process callback */
+typedef int (*msg_process_cb_t)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
struct dev_ops {
link_info_t link_status_update;
ptp_info_t ptp_info_update;
link_status_get_t link_status_get;
q_err_cb_t q_err_cb;
+ msg_process_cb_t msg_process_cb;
repte_notify_t repte_notify;
};
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 63bc149f2a..2e1be81e52 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -87,3 +87,28 @@ roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
return 0;
}
+
+int
+roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf, roc_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ if (cb == NULL)
+ return -EINVAL;
+
+ dev->ops->msg_process_cb = (msg_process_cb_t)cb;
+
+ return 0;
+}
+
+int
+roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ dev->ops->msg_process_cb = NULL;
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 800bf4e674..90a0b5690a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -22,8 +22,15 @@ int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf,
+ roc_rvu_lf_msg_handler_cb_fn cb);
+int __roc_api roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 4e687c1cb8..964c53f819 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -553,5 +553,7 @@ INTERNAL {
roc_rvu_lf_dev_init;
roc_rvu_lf_irq_register;
roc_rvu_lf_irq_unregister;
+ roc_rvu_lf_msg_handler_register;
+ roc_rvu_lf_msg_handler_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index c108931f97..29ab738392 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,34 @@
#include "cnxk_rvu_lf.h"
#include "cnxk_rvu_lf_driver.h"
+int
+rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_register(roc_rvu_lf, (roc_rvu_lf_msg_handler_cb_fn)cb);
+}
+
+int
+rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_unregister(roc_rvu_lf);
+}
+
int
rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 61bbcb7c04..ee5501cc57 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -86,6 +86,55 @@ __rte_internal
int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+/**
+ * Signature of callback function called when a message process handler is called
+ * on RVU LF device.
+ *
+ * @param vf
+ * VF number(0 to N) from which message is received (ignored in case of PF)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request
+ * @param req_len
+ * pointer to message request
+ * @param[out] rsp
+ * pointer to message response
+ * @param[out] rsp_len
+ * length of message response
+ *
+ * @return 0 when response is set, negative value otherwise
+ */
+typedef int (*rte_pmd_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
+/**
+ * Register message handler callback
+ *
+ * Registers message handler callback to be executed when the message is received from peer.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param cb
+ * callback function to be executed
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb);
+
+/**
+ * Unregister message handler callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index a2e8a2c9b3..fcbb2545ea 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -3,6 +3,8 @@ INTERNAL {
rte_pmd_rvu_lf_irq_register;
rte_pmd_rvu_lf_irq_unregister;
+ rte_pmd_rvu_lf_msg_handler_register;
+ rte_pmd_rvu_lf_msg_handler_unregister;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v4 5/9] raw/cnxk_rvu_lf: set message ID range
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (3 preceding siblings ...)
2024-10-24 13:01 ` [PATCH v4 4/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
@ 2024-10-24 13:01 ` Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 6/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
` (4 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
bruce.richards, stephen, sachin.saxena, ferruh.yigit,
Akhil Goyal
Added API rte_pmd_rvu_lf_msg_id_range_set()
to set RVU mailbox message id range.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 12 ++++++++
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 30 ++++++++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 3 ++
drivers/common/cnxk/version.map | 2 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 14 +++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 15 ++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
8 files changed, 78 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 52e4f12e3c..7622b19217 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -53,3 +53,15 @@ Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register(
or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
The irq numbers for which the interrupts are registered is negotiated separately
and is not in scope of the driver.
+
+RVU LF RAW MESSAGE PROCESSING
+-----------------------------
+
+Once a RVU LF raw device is probed, a range of message ids can be configured for
+which mailboxes will be sent using the API ``rte_pmd_rvu_lf_msg_id_range_set``.
+
+For processing of mailboxes received on PF/VF application, application
+can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()``
+and fill required responses as per the request and message id received.
+Application can also unregister already registered message callbacks using
+``rte_pmd_rvu_lf_msg_handler_unregister()``.
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index dd65946e9e..f8791e9f84 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -54,6 +54,7 @@ struct mbox_msghdr {
#define MBOX_MSG_MASK 0xFFFF
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
+#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 2e1be81e52..1026ccc125 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,36 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+int
+roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (from <= MBOX_MSG_GENERIC_MAX_ID || from > to)
+ return -EINVAL;
+
+ rvu->msg_id_from = from;
+ rvu->msg_id_to = to;
+
+ return 0;
+}
+
+bool
+roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
+{
+ struct rvu_lf *rvu;
+
+ if (roc_rvu_lf == NULL)
+ return 0;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (msg_id > rvu->msg_id_from && msg_id < rvu->msg_id_to)
+ return 1;
+
+ return 0;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 90a0b5690a..7243e170b9 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t from, uint16_t to);
+bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
void *req, uint16_t req_len,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 964c53f819..e38da19956 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -555,5 +555,7 @@ INTERNAL {
roc_rvu_lf_irq_unregister;
roc_rvu_lf_msg_handler_register;
roc_rvu_lf_msg_handler_unregister;
+ roc_rvu_lf_msg_id_range_check;
+ roc_rvu_lf_msg_id_range_set;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 29ab738392..82439cf9f8 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,20 @@
#include "cnxk_rvu_lf.h"
#include "cnxk_rvu_lf_driver.h"
+int
+rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index ee5501cc57..07b0279aa0 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -135,6 +135,21 @@ int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handl
__rte_internal
int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
+/**
+ * Set RVU mailbox message id range.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param from
+ * starting message id for RVU mailbox (> 0x1FF)
+ * @param to
+ * last message id for RVU mailbox (< 0xFFFF)
+ *
+ * @return 0 on success, -EINVAL for invalid range
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index fcbb2545ea..d8fb8eba26 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -5,6 +5,7 @@ INTERNAL {
rte_pmd_rvu_lf_irq_unregister;
rte_pmd_rvu_lf_msg_handler_register;
rte_pmd_rvu_lf_msg_handler_unregister;
+ rte_pmd_rvu_lf_msg_id_range_set;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v4 6/9] raw/cnxk_rvu_lf: process mailbox message
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (4 preceding siblings ...)
2024-10-24 13:01 ` [PATCH v4 5/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
@ 2024-10-24 13:01 ` Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 7/9] raw/cnxk_rvu_lf: add API to get device pffunc Akhil Goyal
` (3 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
bruce.richards, stephen, sachin.saxena, ferruh.yigit,
Akhil Goyal
Added API rte_pmd_rvu_lf_msg_process() to process
mailbox messages between rvu_lf devices.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 ++
doc/guides/rel_notes/release_24_11.rst | 5 +
drivers/common/cnxk/roc_dev.c | 118 ++++++++++++++++++-
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 58 +++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 +
drivers/common/cnxk/roc_rvu_lf_priv.h | 5 +
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 15 +++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 29 +++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
11 files changed, 241 insertions(+), 6 deletions(-)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7622b19217..51e1c58b69 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -65,3 +65,11 @@ can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()``
and fill required responses as per the request and message id received.
Application can also unregister already registered message callbacks using
``rte_pmd_rvu_lf_msg_handler_unregister()``.
+
+A PMD API ``rte_pmd_rvu_lf_msg_process()`` is created to send a request and
+receive corresponding response from the other side(PF/VF).
+It accepts an opaque pointer of a request and its size which can be defined by application
+and provides an opaque pointer for a response and its length.
+PF and VF application can define its own request and response based on the message id
+of the mailbox.
+For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``.
diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst
index fa4822d928..3f50545a2e 100644
--- a/doc/guides/rel_notes/release_24_11.rst
+++ b/doc/guides/rel_notes/release_24_11.rst
@@ -247,6 +247,11 @@ New Features
Added ability for node to advertise and update multiple xstat counters,
that can be retrieved using ``rte_graph_cluster_stats_get``.
+* **Added Marvell cnxk RVU LF rawdev driver.**
+
+ Added a new raw device driver for Marvell cnxk based devices to allow
+ applications to communicate using mailboxes and notify for the interrupts.
+
Removed Items
-------------
diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index c905d35ea6..cb8d5d03fd 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -218,6 +218,51 @@ af_pf_wait_msg(struct dev *dev, uint16_t vf, int num_msg)
return req_hdr->num_msgs;
}
+static int
+process_rvu_lf_msgs(struct dev *dev, uint16_t vf, struct mbox_msghdr *msg, size_t size)
+{
+ uint16_t max_bits = sizeof(dev->active_vfs[0]) * 8;
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Handle BPHY mailbox message in PF */
+ dev->active_vfs[vf / max_bits] |= BIT_ULL(vf % max_bits);
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -1;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", vf);
+ return -1;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_vfpf, vf,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", vf);
+ return -1;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ free(resp);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return 0;
+}
+
/* PF receives mbox DOWN messages from VF and forwards to AF */
static int
vf_pf_process_msgs(struct dev *dev, uint16_t vf)
@@ -264,6 +309,9 @@ vf_pf_process_msgs(struct dev *dev, uint16_t vf)
/* PF/VF function ID */
rsp->hdr.pcifunc = msg->pcifunc;
rsp->hdr.rc = 0;
+ } else if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ if (process_rvu_lf_msgs(dev, vf, msg, size) < 0)
+ continue;
} else {
struct mbox_msghdr *af_req;
/* Reserve AF/PF mbox message */
@@ -342,8 +390,13 @@ vf_pf_process_up_msgs(struct dev *dev, uint16_t vf)
dev_get_vf(msg->pcifunc));
break;
default:
- plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
- msg->id, mbox_id2name(msg->id), msg->pcifunc);
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id))
+ plt_base_dbg("PF: Msg 0x%x fn:0x%x (pf:%d,vf:%d)",
+ msg->id, msg->pcifunc, dev_get_pf(msg->pcifunc),
+ dev_get_vf(msg->pcifunc));
+ else
+ plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
+ msg->id, mbox_id2name(msg->id), msg->pcifunc);
}
offset = mbox->rx_start + msg->next_msgoff;
}
@@ -792,6 +845,50 @@ mbox_process_msgs_up(struct dev *dev, struct mbox_msghdr *req)
return -ENODEV;
}
+static int
+process_rvu_lf_msgs_up(struct dev *dev, struct mbox_msghdr *msg, size_t size)
+{
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Check if valid, if not reply with an invalid msg */
+ if (msg->sig != MBOX_REQ_SIG)
+ return -EIO;
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -ENOMEM;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", dev->vf);
+ return rc;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_up, 0,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", dev->vf);
+ return -ENOMEM;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ free(resp);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return rc;
+}
+
/* Received up messages from AF (PF context) / PF (in context) */
static void
process_msgs_up(struct dev *dev, struct mbox *mbox)
@@ -800,6 +897,7 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
struct mbox_hdr *req_hdr;
struct mbox_msghdr *msg;
int i, err, offset;
+ size_t size;
req_hdr = (struct mbox_hdr *)((uintptr_t)mdev->mbase + mbox->rx_start);
if (req_hdr->num_msgs == 0)
@@ -812,10 +910,17 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
plt_base_dbg("Message 0x%x (%s) pf:%d/vf:%d", msg->id,
mbox_id2name(msg->id), dev_get_pf(msg->pcifunc),
dev_get_vf(msg->pcifunc));
- err = mbox_process_msgs_up(dev, msg);
- if (err)
- plt_err("Error %d handling 0x%x (%s)", err, msg->id,
- mbox_id2name(msg->id));
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ size = mbox->rx_start + msg->next_msgoff - offset;
+ err = process_rvu_lf_msgs_up(dev, msg, size);
+ if (err)
+ plt_err("Error %d handling 0x%x RVU_LF up msg", err, msg->id);
+ } else {
+ err = mbox_process_msgs_up(dev, msg);
+ if (err)
+ plt_err("Error %d handling 0x%x (%s)", err, msg->id,
+ mbox_id2name(msg->id));
+ }
offset = mbox->rx_start + msg->next_msgoff;
}
/* Send mbox responses */
@@ -1304,6 +1409,7 @@ dev_vf_hwcap_update(struct plt_pci_device *pci_dev, struct dev *dev)
case PCI_DEVID_CNXK_RVU_VF:
case PCI_DEVID_CNXK_RVU_SDP_VF:
case PCI_DEVID_CNXK_RVU_NIX_INL_VF:
+ case PCI_DEVID_CNXK_RVU_BPHY_VF:
case PCI_DEVID_CNXK_RVU_ESWITCH_VF:
dev->hwcap |= DEV_HWCAP_F_VF;
break;
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index f8791e9f84..4518680684 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -55,6 +55,7 @@ struct mbox_msghdr {
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
+#define MBOX_MSG_REQ_SIZE_MAX (16 * 1024)
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1026ccc125..471dfa7a46 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,15 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+static uint16_t
+roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ return dev->pf_func;
+}
+
int
roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
{
@@ -92,6 +101,55 @@ roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
return 0;
}
+int
+roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf, uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len, void *rsp_data, uint16_t rsp_len)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct mbox *mbox;
+ struct rvu_lf_msg *req;
+ struct rvu_lf_msg *rsp;
+ int rc = -ENOSPC;
+ int devid = 0;
+
+ if (rvu->dev.vf == -1 && roc_rvu_lf_msg_id_range_check(roc_rvu_lf, msg_id)) {
+ /* This is PF context */
+ if (vf >= rvu->dev.maxvf)
+ return -EINVAL;
+ devid = vf;
+ mbox = mbox_get(&rvu->dev.mbox_vfpf_up);
+ } else {
+ /* This is VF context */
+ devid = 0; /* VF send all message to PF */
+ mbox = mbox_get(rvu->dev.mbox);
+ }
+ req = (struct rvu_lf_msg *)mbox_alloc_msg_rsp(mbox, devid,
+ req_len + sizeof(struct rvu_lf_msg),
+ rsp_len + sizeof(struct rvu_lf_msg));
+ if (!req)
+ goto fail;
+ mbox_memcpy(req->data, req_data, req_len);
+ req->hdr.sig = MBOX_REQ_SIG;
+ req->hdr.id = msg_id;
+ req->hdr.pcifunc = roc_rvu_lf_pf_func_get(roc_rvu_lf);
+
+ if (rvu->dev.vf == -1) {
+ mbox_msg_send_up(mbox, devid);
+ rc = mbox_get_rsp(mbox, devid, (void *)&rsp);
+ if (rc)
+ goto fail;
+ } else {
+ rc = mbox_process_msg(mbox, (void *)&rsp);
+ if (rc)
+ goto fail;
+ }
+ if (rsp_len && rsp_data != NULL)
+ mbox_memcpy(rsp_data, rsp->data, rsp_len);
+fail:
+ mbox_put(mbox);
+ return rc;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7243e170b9..6b4819666a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,11 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len,
+ void *rsp_data, uint16_t rsp_len);
+
int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
uint16_t from, uint16_t to);
bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
index 8feff82961..57bb713b21 100644
--- a/drivers/common/cnxk/roc_rvu_lf_priv.h
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -17,6 +17,11 @@ struct rvu_lf {
uint16_t msg_id_to;
};
+struct rvu_lf_msg {
+ struct mbox_msghdr hdr;
+ uint8_t data[];
+};
+
static inline struct rvu_lf *
roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
{
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index e38da19956..1b33421d3d 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -557,5 +557,7 @@ INTERNAL {
roc_rvu_lf_msg_handler_unregister;
roc_rvu_lf_msg_id_range_check;
roc_rvu_lf_msg_id_range_set;
+ roc_rvu_lf_msg_process;
+
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 82439cf9f8..17917532cd 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -30,6 +30,21 @@ rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
}
+int
+rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_process(roc_rvu_lf, vf, msg_id, req, req_len, rsp, rsp_len);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 07b0279aa0..981d297aba 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -150,6 +150,35 @@ int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
__rte_internal
int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+/**
+ * Process a RVU mailbox message.
+ *
+ * Message request and response to be sent/received,
+ * need to be allocated/deallocated by application
+ * before/after processing the message.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param vf
+ * VF number(0 to N) in case of PF->VF message. 0 is valid as VF0.
+ * (For VF->PF message, this field is ignored)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request data to be sent
+ * @param req_len
+ * length of request data
+ * @param rsp
+ * pointer to message response expected to be received, NULL if no response
+ * @param rsp_len
+ * length of message response expected, 0 if no response
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index d8fb8eba26..7896a8f777 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -6,6 +6,7 @@ INTERNAL {
rte_pmd_rvu_lf_msg_handler_register;
rte_pmd_rvu_lf_msg_handler_unregister;
rte_pmd_rvu_lf_msg_id_range_set;
+ rte_pmd_rvu_lf_msg_process;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v4 7/9] raw/cnxk_rvu_lf: add API to get device pffunc
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (5 preceding siblings ...)
2024-10-24 13:01 ` [PATCH v4 6/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
@ 2024-10-24 13:01 ` Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 8/9] raw/cnxk_rvu_lf: add API to get BAR addresses Akhil Goyal
` (2 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
bruce.richards, stephen, sachin.saxena, ferruh.yigit,
Akhil Goyal
Added ``rte_pmd_rvu_lf_pf_func_get`` API
to get RVU LF device pffunc for the application use.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
drivers/common/cnxk/roc_rvu_lf.c | 2 +-
drivers/common/cnxk/roc_rvu_lf.h | 2 ++
drivers/common/cnxk/version.map | 1 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 15 +++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 12 ++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
6 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 471dfa7a46..862a201135 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,7 +62,7 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
-static uint16_t
+uint16_t
roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf)
{
struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 6b4819666a..8c71876cbc 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,8 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+uint16_t __roc_api roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf);
+
int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf,
uint16_t vf, uint16_t msg_id,
void *req_data, uint16_t req_len,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 1b33421d3d..f8028ee4e6 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -558,6 +558,7 @@ INTERNAL {
roc_rvu_lf_msg_id_range_check;
roc_rvu_lf_msg_id_range_set;
roc_rvu_lf_msg_process;
+ roc_rvu_lf_pf_func_get;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 17917532cd..156b9460c1 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -115,6 +115,21 @@ rte_pmd_rvu_lf_sso_pf_func_get(void)
return roc_sso_pf_func_get();
}
+uint16_t
+rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id)
+{
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ if (rawdev == NULL)
+ return 0;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_pf_func_get(roc_rvu_lf);
+}
+
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
.dev_selftest = NULL,
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 981d297aba..22978f89af 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -40,6 +40,18 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
__rte_internal
uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+/**
+ * Obtain RVU LF device PF func
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ *
+ * @return
+ * Returns RVU LF pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_internal
+uint16_t rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id);
+
/**
* Signature of callback function called when an interrupt is received on RVU LF device.
*
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index 7896a8f777..aa974f629e 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -8,6 +8,7 @@ INTERNAL {
rte_pmd_rvu_lf_msg_id_range_set;
rte_pmd_rvu_lf_msg_process;
rte_pmd_rvu_lf_npa_pf_func_get;
+ rte_pmd_rvu_lf_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
local: *;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v4 8/9] raw/cnxk_rvu_lf: add API to get BAR addresses
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (6 preceding siblings ...)
2024-10-24 13:01 ` [PATCH v4 7/9] raw/cnxk_rvu_lf: add API to get device pffunc Akhil Goyal
@ 2024-10-24 13:01 ` Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
bruce.richards, stephen, sachin.saxena, ferruh.yigit,
Akhil Goyal
Added rte_pmd_rvu_lf_bar_get() API to get BAR address
for application to configure hardware.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 ++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 24 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 18 +++++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
4 files changed, 50 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 51e1c58b69..a972654f82 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -73,3 +73,10 @@ and provides an opaque pointer for a response and its length.
PF and VF application can define its own request and response based on the message id
of the mailbox.
For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``.
+
+Get BAR addresses
+-----------------
+
+Application can retrieve PCI BAR addresses of the device using the API
+``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the
+registers of the hardware device.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 156b9460c1..3a3971ecd3 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -103,6 +103,30 @@ rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
return roc_rvu_lf_irq_unregister(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
}
+int
+rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask)
+{
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ if (bar_num > PCI_MAX_RESOURCE ||
+ (roc_rvu_lf->pci_dev->mem_resource[bar_num].addr == NULL)) {
+ *va = 0;
+ *mask = 0;
+ return -ENOTSUP;
+ }
+ *va = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].addr);
+ *mask = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].len - 1);
+
+ return 0;
+}
+
uint16_t
rte_pmd_rvu_lf_npa_pf_func_get(void)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 22978f89af..922c852592 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -191,6 +191,24 @@ __rte_internal
int rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
void *req, uint16_t req_len, void *rsp, uint16_t rsp_len);
+/**
+ * Get BAR addresses for the RVU LF device.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param bar_num
+ * BAR number for which address is required
+ * @param[out] va
+ * Virtual address of the BAR. 0 if not mapped
+ * @param[out] mask
+ * BAR address mask, 0 if not mapped
+ *
+ * @return
+ * Returns 0 on success, negative error code otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index aa974f629e..012f05d1e4 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -1,6 +1,7 @@
INTERNAL {
global:
+ rte_pmd_rvu_lf_bar_get;
rte_pmd_rvu_lf_irq_register;
rte_pmd_rvu_lf_irq_unregister;
rte_pmd_rvu_lf_msg_handler_register;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v4 9/9] raw/cnxk_rvu_lf: add selftest
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (7 preceding siblings ...)
2024-10-24 13:01 ` [PATCH v4 8/9] raw/cnxk_rvu_lf: add API to get BAR addresses Akhil Goyal
@ 2024-10-24 13:01 ` Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
bruce.richards, stephen, sachin.saxena, ferruh.yigit,
Akhil Goyal
Added raw device selftest for cnxk_rvu_lf to verify
various PMD APIs.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 18 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 4 +-
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 2 +
.../raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c | 164 ++++++++++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 1 +
5 files changed, 186 insertions(+), 3 deletions(-)
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index a972654f82..41fd2d1b42 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -80,3 +80,21 @@ Get BAR addresses
Application can retrieve PCI BAR addresses of the device using the API
``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the
registers of the hardware device.
+
+Self test
+---------
+
+On EAL initialization RVU_LF devices will be probed and populated into
+the raw devices. The rawdev ID of the device can be obtained using invocation
+of ``rte_rawdev_get_dev_id("NAME:x")`` from the test application, where:
+
+- NAME is the desired subsystem: use "RVU_LF".
+- x is the device's bus id specified in "bus:device.func" (BDF) format. BDF follows convention
+ used by lspci i.e bus, device and func are specified using respectively two, two and one hex
+ digit(s).
+
+Use this identifier for further rawdev function calls.
+
+Selftest rawdev API can be used to verify the mailbox communication between
+PF and VF devices based applications. There can be multiple VFs for a particular PF.
+Each VF can send mailboxes to PF and PF can broadcast message to all VFs.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 3a3971ecd3..516fc896b9 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -5,8 +5,6 @@
#include <bus_pci_driver.h>
#include <rte_common.h>
#include <dev_driver.h>
-#include <rte_eal.h>
-#include <rte_lcore.h>
#include <rte_pci.h>
#include <rte_rawdev.h>
#include <rte_rawdev_pmd.h>
@@ -155,7 +153,7 @@ rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id)
}
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
- .dev_selftest = NULL,
+ .dev_selftest = rvu_lf_rawdev_selftest,
};
static void
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
index 65cc1bb64d..e64643dcee 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -21,4 +21,6 @@ extern int cnxk_logtype_rvu_lf;
#define CNXK_RVU_LF_LOG(level, ...) \
RTE_LOG_LINE_PREFIX(level, CNXK_RVU_LF, "%s(): ", __func__, __VA_ARGS__)
+int rvu_lf_rawdev_selftest(uint16_t dev_id);
+
#endif /* _CNXK_RVU_LF_H_ */
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
new file mode 100644
index 0000000000..79439b2b72
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include <stdlib.h>
+
+#include <rte_common.h>
+#include <rte_hexdump.h>
+#include <rte_eal.h>
+#include <rte_lcore.h>
+
+#include <rte_rawdev.h>
+#include <rte_cycles.h>
+
+#include "cnxk_rvu_lf.h"
+#include "cnxk_rvu_lf_driver.h"
+
+#define PF 0
+#define VF 0
+#define RSP_LEN 64
+#define REQ_LEN 64
+#define MSG_ID_FROM 0x3000
+#define MSG_ID_TO 0x4000
+#define MAX_BAR 6
+
+static int
+msg_process_notify_cb(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void **rsp, uint16_t *rsp_len)
+{
+ uint8_t *resp;
+ int i;
+
+ printf("\nReceived message(0x%x) from VF0x%x\n", msg_id, vf);
+ rte_hexdump(stdout, "req_data received", req, req_len);
+
+ resp = malloc(RSP_LEN);
+ if (resp == NULL)
+ return -ENOMEM;
+ for (i = 0; i < RSP_LEN; i++)
+ resp[i] = 0xB0;
+ *rsp = resp;
+ *rsp_len = RSP_LEN;
+ rte_hexdump(stdout, "rsp_data_filled", *rsp, RSP_LEN);
+
+ return 0;
+}
+
+int
+rvu_lf_rawdev_selftest(uint16_t dev_id)
+{
+ char *dev_name = rte_rawdevs[dev_id].name;
+ uint8_t req[REQ_LEN] = {0};
+ uint8_t rsp[RSP_LEN] = {0};
+ size_t bar_mask = 0;
+ size_t bar_va = 0;
+ unsigned int i, j;
+ uint16_t pf_func;
+ char *token[2];
+ int func, ret;
+
+ token[0] = strtok_r(dev_name, ".", &dev_name);
+ token[1] = strtok_r(dev_name, ".", &dev_name);
+ func = atoi(token[1]);
+
+ ret = rte_rawdev_start(dev_id);
+ if (ret)
+ return ret;
+
+ pf_func = rte_pmd_rvu_lf_npa_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "NPA pf_func is invalid");
+
+ pf_func = rte_pmd_rvu_lf_sso_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "SSO pf_func is invalid");
+
+ pf_func = rte_pmd_rvu_lf_pf_func_get(dev_id);
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "RVU-LF pf_func is invalid");
+
+ for (i = 0; i < MAX_BAR; i++) {
+ if(!rte_pmd_rvu_lf_bar_get(dev_id, i, &bar_va, &bar_mask))
+ printf("\n BAR[%d]: addr: 0x%lx, mask: 0x%lx", i, bar_va, bar_mask);
+ }
+
+ ret = rte_pmd_rvu_lf_msg_id_range_set(dev_id, MSG_ID_FROM, MSG_ID_TO);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message ID range invalid");
+ goto out;
+ }
+
+ ret = rte_pmd_rvu_lf_msg_handler_register(dev_id, msg_process_notify_cb);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message handler register failed, ret: %d", ret);
+ goto out;
+ }
+
+ if (func == 0) {
+ j = 50;
+ printf("\n");
+ while (j--) {
+ /* PF will wait for RVU message callbacks to be called */
+ rte_delay_ms(1000);
+ printf("PF waiting for VF messages for %d sec.\r", j);
+ }
+ /* PF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xC0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO.
+ * Messages sent with this id will be serviced by VF..
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ VF /* Send to VF0 */,
+ MSG_ID_FROM + 0x2,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf PF->VF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU PF->VF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("PF waiting for VF to exit for %d sec.\r", j);
+ }
+
+ } else {
+ /* VF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xA0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO
+ * Messages sent with this id will be serviced by PF and will
+ * not be forwarded to AF.
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ PF /* Send to PF */,
+ MSG_ID_FROM + 0x1,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf VF->PF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU VF->PF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("VF waiting for PF to send msg for %d sec.\r", j);
+ }
+ }
+unregister:
+ rte_pmd_rvu_lf_msg_handler_unregister(dev_id);
+out:
+ rte_rawdev_stop(dev_id);
+
+ return ret;
+}
+
+
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
index 7ea1c3916c..c960989bb7 100644
--- a/drivers/raw/cnxk_rvu_lf/meson.build
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -5,6 +5,7 @@
deps += ['bus_pci', 'common_cnxk', 'rawdev']
sources = files(
'cnxk_rvu_lf.c',
+ 'cnxk_rvu_lf_selftest.c',
)
driver_sdk_headers += files('cnxk_rvu_lf_driver.h')
require_iova_in_mbuf = false
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* RE: [EXTERNAL] Re: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses
2024-10-23 19:29 ` Thomas Monjalon
@ 2024-10-24 13:03 ` Akhil Goyal
0 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:03 UTC (permalink / raw)
To: Thomas Monjalon
Cc: David Marchand, dev, Jerin Jacob, Jerin Jacob, Harman Kalra,
Stephen Hemminger, Bruce Richardson, Hemant Agrawal,
Sachin Saxena, Ferruh Yigit
> 23/10/2024 21:14, Akhil Goyal:
> > > 22/10/2024 14:06, Akhil Goyal:
> > > > > On Tue, Oct 22, 2024 at 8:06 AM Akhil Goyal <gakhil@marvell.com>
> wrote:
> > > > > > > The rational to NOT pull "Hardware abstraction library using the BAR
> > > > > > > address" to DPDK are
> > > > > > > -Yet another 200K of driver C++ code which does not make sense to
> keep
> > > > > > > in dpdk.org
> > > > > > > -It can not implemenent any of the current subsystems
> > > > > > >
> > > > > > > In this context, let me know what you think?
> > > > >
> > > > > This hardware abstraction library will have to call some driver
> > > > > specific API (like the added raw/cnxk_rvu API).
> > > > > Can this library directly use the PCI driver API, and call the cnxk
> > > > > common driver?
> > > > > If so, there is no need to add another driver API (that breaks
> > > > > layers), and the rawdev driver is only about adding the mailbox
> > > > > features.
> > > >
> > > > cnxk common has a lot of internal APIs which
> > > > we do not want to expose directly to application.
> > >
> > > Actually the target is an out-of-tree driver, not an application.
> > >
> > > > It seems the only contentious API is to get the BAR addresses.
> > > > All other APIs seems to be fine. Right?
> > >
> > > Interrupt management is also something we would like to see reserved to
> drivers.
> > >
> > > > If so, we can remove that API and get the bar addresses as you suggested
> > > below.
> > > > rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar
> addr
> > > > via bus_pci_driver.h header, exported via enable_driver_sdk option
> > >
> > > Yes please, it is better to avoid confusion between driver and application.
> > > Any driver type layer should be exposed only when the Meson option
> > > enable_driver_sdk is enabled.
> > >
> > > You probably should export the interrupt functions in a separate file
> > > through driver_sdk_headers, so it is clear it is not an application level.
> > > Does it apply to the mailbox functions as well?
> > >
> > Ok, if we are having a separate file as driver_sdk_header,
> > We can also keep the BAR address API in that. Right?
>
> I think yes but it is redundant with the path
> rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar addr
> Is it performance sensitive? In this case you could save/cache it.
It is about the ease of getting the BAR address.
rte_rawdev_info_get() -> get rte_device -> RTE_DEV_TO_PCI -> get bar addr
need 4 indirections/API to be used.
With this API, it is a single call.
Hence kept this API in v4.
If you have strong objection, I can remove it.
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (8 preceding siblings ...)
2024-10-24 13:01 ` [PATCH v4 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
@ 2024-10-24 13:17 ` Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 1/9] " Akhil Goyal
` (9 more replies)
9 siblings, 10 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:17 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
CNXK product families can have a use case to allow PF and VF
applications to communicate using mailboxes and also get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
The RVU LF device implements following features in the rawdev API:
- Register mailbox callbacks for the other side to process mailboxes.
- Register interrupt handler callbacks.
- Process mailbox.
- Set range of message IDs allowed for communication.
Changes in v5:
- fixed checkpatch
Changes in v4:
- moved all PMD APIs to internal APIs to be exposed via
enable_driver_sdk meson option.
- added missing version.map entries as internal APIs.
- separate out selftest in a separate file
- fixed logs
Changes in v3:
- fix internal/external header files.
Changes in v2:
- removed library patch from series
- removed PMD logs from external PMD header.
- updated doc/api/doxy-api-index.md
- Added release notes
Akhil Goyal (9):
drivers/raw: introduce cnxk rvu lf device driver
raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc
raw/cnxk_rvu_lf: register/unregister interrupt handler
raw/cnxk_rvu_lf: register/unregister msg handler
raw/cnxk_rvu_lf: set message ID range
raw/cnxk_rvu_lf: process mailbox message
raw/cnxk_rvu_lf: add API to get device pffunc
raw/cnxk_rvu_lf: add API to get BAR addresses
raw/cnxk_rvu_lf: add selftest
MAINTAINERS | 6 +
doc/guides/rawdevs/cnxk_rvu_lf.rst | 100 +++++++
doc/guides/rawdevs/index.rst | 1 +
doc/guides/rel_notes/release_24_11.rst | 5 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 3 +
drivers/common/cnxk/roc_dev.c | 118 +++++++-
drivers/common/cnxk/roc_dev_priv.h | 7 +
drivers/common/cnxk/roc_idev.c | 46 ++++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_mbox.h | 2 +
drivers/common/cnxk/roc_npa.c | 6 +
drivers/common/cnxk/roc_npa.h | 3 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 202 ++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 46 ++++
drivers/common/cnxk/roc_rvu_lf_priv.h | 37 +++
drivers/common/cnxk/roc_sso.c | 6 +
drivers/common/cnxk/roc_sso.h | 3 +
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 16 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 260 ++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 26 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 216 +++++++++++++++
.../raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c | 166 +++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 11 +
drivers/raw/cnxk_rvu_lf/version.map | 16 ++
drivers/raw/meson.build | 1 +
30 files changed, 1310 insertions(+), 6 deletions(-)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
create mode 100644 drivers/raw/cnxk_rvu_lf/version.map
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v5 1/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
@ 2024-10-24 13:17 ` Akhil Goyal
2024-10-24 15:59 ` Jerin Jacob
2024-10-24 13:17 ` [PATCH v5 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc Akhil Goyal
` (8 subsequent siblings)
9 siblings, 1 reply; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:17 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
CNXK product families can have a use case to allow PF and VF
applications to communicate using mailboxes and also get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
MAINTAINERS | 6 ++
doc/guides/rawdevs/cnxk_rvu_lf.rst | 40 +++++++++
doc/guides/rawdevs/index.rst | 1 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 3 +
drivers/common/cnxk/roc_dev_priv.h | 1 +
drivers/common/cnxk/roc_idev.c | 46 ++++++++++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 63 +++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 24 +++++
drivers/common/cnxk/roc_rvu_lf_priv.h | 32 +++++++
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 5 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 123 ++++++++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 24 +++++
drivers/raw/cnxk_rvu_lf/meson.build | 9 ++
drivers/raw/meson.build | 1 +
20 files changed, 391 insertions(+)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
diff --git a/MAINTAINERS b/MAINTAINERS
index cd78bc7db1..fe1464d06a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1503,6 +1503,12 @@ T: git://dpdk.org/next/dpdk-next-net-mrvl
F: doc/guides/rawdevs/cnxk_gpio.rst
F: drivers/raw/cnxk_gpio/
+Marvell CNXK RVU LF
+M: Akhil Goyal <gakhil@marvell.com>
+T: git://dpdk.org/next/dpdk-next-net-mrvl
+F: doc/guides/rawdevs/cnxk_rvu_lf.rst
+F: drivers/raw/cnxk_rvu_lf/
+
NTB
M: Jingjing Wu <jingjing.wu@intel.com>
F: drivers/raw/ntb/
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
new file mode 100644
index 0000000000..8a0bc22dd5
--- /dev/null
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -0,0 +1,40 @@
+.. SPDX-License-Identifier: BSD-3-Clause
+ Copyright(c) 2024 Marvell.
+
+Marvell CNXK RVU LF Driver
+==========================
+
+CNXK product families can have a use case to allow PF and VF
+applications to communicate using mailboxes and also get notified
+of any interrupt that may occur on the device.
+Hence, a new raw device driver is added for such RVU LF devices.
+These devices can map to a PF or a VF which can send mailboxes to
+each other.
+
+Features
+--------
+
+The RVU LF device implements following features in the rawdev API:
+
+- Register mailbox callbacks for the other side to process mailboxes.
+- Register interrupt handler callbacks.
+- Process mailbox.
+- Set range of message IDs allowed for communication.
+
+Limitations
+-----------
+
+In multiprocess mode user-space application must ensure
+no resources sharing takes place.
+Otherwise, user-space application should ensure synchronization.
+
+Device Setup
+------------
+
+The RVU LF devices will need to be bound to a user-space IO driver for use.
+The script ``dpdk-devbind.py`` included with DPDK can be used to
+view the state of the devices and to bind them to a suitable DPDK-supported
+kernel driver. When querying the status of the devices, they will appear under
+the category of "Misc (rawdev) devices", i.e. the command
+``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
+devices alone.
diff --git a/doc/guides/rawdevs/index.rst b/doc/guides/rawdevs/index.rst
index f34315f051..8e07cf4d6c 100644
--- a/doc/guides/rawdevs/index.rst
+++ b/doc/guides/rawdevs/index.rst
@@ -13,6 +13,7 @@ application through rawdev API.
cnxk_bphy
cnxk_gpio
+ cnxk_rvu_lf
dpaa2_cmdif
ifpga
ntb
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index abb0f6f01f..cb0ffd5d40 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -71,6 +71,7 @@ sources = files(
'roc_tim_irq.c',
'roc_utils.c',
'roc_ree.c',
+ 'roc_rvu_lf.c',
)
# Security common code
diff --git a/drivers/common/cnxk/roc_api.h b/drivers/common/cnxk/roc_api.h
index 6a86863c57..93e7bf11bb 100644
--- a/drivers/common/cnxk/roc_api.h
+++ b/drivers/common/cnxk/roc_api.h
@@ -120,4 +120,7 @@
/* Eswitch */
#include "roc_eswitch.h"
+/* RVU LF */
+#include "roc_rvu_lf.h"
+
#endif /* _ROC_API_H_ */
diff --git a/drivers/common/cnxk/roc_constants.h b/drivers/common/cnxk/roc_constants.h
index 0e7495a37c..67cd74b28a 100644
--- a/drivers/common/cnxk/roc_constants.h
+++ b/drivers/common/cnxk/roc_constants.h
@@ -45,6 +45,8 @@
#define PCI_DEVID_CNXK_RVU_REE_VF 0xA0f5
#define PCI_DEVID_CNXK_RVU_ESWITCH_PF 0xA0E0
#define PCI_DEVID_CNXK_RVU_ESWITCH_VF 0xA0E1
+#define PCI_DEVID_CNXK_RVU_BPHY_PF 0xA0E4
+#define PCI_DEVID_CNXK_RVU_BPHY_VF 0xA0E5
#define PCI_DEVID_CN9K_CGX 0xA059
#define PCI_DEVID_CN10K_RPM 0xA060
@@ -63,6 +65,7 @@
#define PCI_SUBSYSTEM_DEVID_CNF10KB 0xBC00
#define PCI_SUBSYSTEM_DEVID_CN20KA 0xA020
+#define PCI_SUBSYSTEM_DEVID_CNF20KA 0xA000
#define PCI_SUBSYSTEM_DEVID_CN9KA 0x0000
#define PCI_SUBSYSTEM_DEVID_CN9KB 0xb400
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index 5ab4f72f8f..dd4949b32c 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -141,6 +141,7 @@ struct dev {
void *roc_cpt;
void *roc_tim;
void *roc_ml;
+ void *roc_rvu_lf;
bool disable_shared_lmt; /* false(default): shared lmt mode enabled */
const struct plt_memzone *lmt_mz;
struct mbox_sync sync;
diff --git a/drivers/common/cnxk/roc_idev.c b/drivers/common/cnxk/roc_idev.c
index 0778d51d1e..84812f73e0 100644
--- a/drivers/common/cnxk/roc_idev.c
+++ b/drivers/common/cnxk/roc_idev.c
@@ -38,6 +38,7 @@ idev_set_defaults(struct idev_cfg *idev)
idev->num_lmtlines = 0;
idev->bphy = NULL;
idev->cpt = NULL;
+ TAILQ_INIT(&idev->rvu_lf_list);
TAILQ_INIT(&idev->mcs_list);
idev->nix_inl_dev = NULL;
TAILQ_INIT(&idev->roc_nix_list);
@@ -188,6 +189,51 @@ roc_idev_cpt_get(void)
return NULL;
}
+struct roc_rvu_lf *
+roc_idev_rvu_lf_get(uint8_t rvu_lf_idx)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf, &idev->rvu_lf_list, next) {
+ if (rvu_lf->idx == rvu_lf_idx)
+ return rvu_lf;
+ }
+ }
+
+ return NULL;
+}
+
+void
+roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ return;
+ }
+ TAILQ_INSERT_TAIL(&idev->rvu_lf_list, rvu, next);
+ }
+}
+
+void
+roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ TAILQ_REMOVE(&idev->rvu_lf_list, rvu, next);
+ }
+ }
+}
+
struct roc_mcs *
roc_idev_mcs_get(uint8_t mcs_idx)
{
diff --git a/drivers/common/cnxk/roc_idev.h b/drivers/common/cnxk/roc_idev.h
index fc0f7db54e..6edb5f83b2 100644
--- a/drivers/common/cnxk/roc_idev.h
+++ b/drivers/common/cnxk/roc_idev.h
@@ -29,4 +29,8 @@ uint16_t *__roc_api roc_idev_nix_rx_chan_base_get(void);
void __roc_api roc_idev_nix_rx_chan_set(uint16_t port, uint16_t chan);
uint16_t __roc_api roc_idev_nix_inl_dev_pffunc_get(void);
+
+struct roc_rvu_lf *__roc_api roc_idev_rvu_lf_get(uint8_t rvu_lf_idx);
+void __roc_api roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu);
+void __roc_api roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu);
#endif /* _ROC_IDEV_H_ */
diff --git a/drivers/common/cnxk/roc_idev_priv.h b/drivers/common/cnxk/roc_idev_priv.h
index 6628b18152..98b6286bfe 100644
--- a/drivers/common/cnxk/roc_idev_priv.h
+++ b/drivers/common/cnxk/roc_idev_priv.h
@@ -36,6 +36,7 @@ struct idev_cfg {
struct roc_bphy *bphy;
struct roc_cpt *cpt;
struct roc_sso *sso;
+ struct roc_rvu_lf_head rvu_lf_list;
struct roc_mcs_head mcs_list;
struct nix_inl_dev *nix_inl_dev;
struct idev_nix_inl_cfg inl_cfg;
diff --git a/drivers/common/cnxk/roc_priv.h b/drivers/common/cnxk/roc_priv.h
index 254a2d3310..8732a05ac3 100644
--- a/drivers/common/cnxk/roc_priv.h
+++ b/drivers/common/cnxk/roc_priv.h
@@ -53,4 +53,6 @@
/* ML */
#include "roc_ml_priv.h"
+/* RVU LF */
+#include "roc_rvu_lf_priv.h"
#endif /* _ROC_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
new file mode 100644
index 0000000000..1ae39e746e
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include "roc_api.h"
+#include "roc_priv.h"
+
+int
+roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct plt_pci_device *pci_dev;
+ struct dev *dev;
+ struct rvu_lf *rvu;
+ int rc;
+
+ if (roc_rvu_lf == NULL || roc_rvu_lf->pci_dev == NULL)
+ return RVU_ERR_PARAM;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ pci_dev = roc_rvu_lf->pci_dev;
+ dev = &rvu->dev;
+
+ if (rvu->dev.drv_inited)
+ return 0;
+
+ if (dev->mbox_active)
+ goto skip_dev_init;
+
+ memset(rvu, 0, sizeof(*rvu));
+
+ /* Initialize device */
+ rc = dev_init(dev, pci_dev);
+ if (rc) {
+ plt_err("Failed to init roc device");
+ goto fail;
+ }
+
+skip_dev_init:
+ dev->roc_rvu_lf = roc_rvu_lf;
+ rvu->pci_dev = pci_dev;
+
+ roc_idev_rvu_lf_set(roc_rvu_lf);
+ rvu->dev.drv_inited = true;
+
+ return 0;
+fail:
+ return rc;
+}
+
+int
+roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (rvu == NULL)
+ return NIX_ERR_PARAM;
+
+ rvu->dev.drv_inited = false;
+
+ roc_idev_rvu_lf_free(roc_rvu_lf);
+
+ return dev_fini(&rvu->dev, rvu->pci_dev);
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
new file mode 100644
index 0000000000..7ce8065a8b
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_H_
+#define _ROC_RVU_LF_H_
+
+#include "roc_platform.h"
+
+struct roc_rvu_lf {
+ TAILQ_ENTRY(roc_rvu_lf) next;
+ struct plt_pci_device *pci_dev;
+ uint8_t idx;
+#define ROC_RVU_MEM_SZ (6 * 1024)
+ uint8_t reserved[ROC_RVU_MEM_SZ] __plt_cache_aligned;
+};
+
+TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
+
+/* Dev */
+int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+
+#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
new file mode 100644
index 0000000000..8feff82961
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_PRIV_H_
+#define _ROC_RVU_LF_PRIV_H_
+
+enum rvu_err_status {
+ RVU_ERR_PARAM = -1,
+ RVU_ERR_NO_MEM = -2,
+};
+
+struct rvu_lf {
+ struct plt_pci_device *pci_dev;
+ struct dev dev;
+ uint16_t msg_id_from;
+ uint16_t msg_id_to;
+};
+
+static inline struct rvu_lf *
+roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
+{
+ return (struct rvu_lf *)&roc_rvu_lf->reserved[0];
+}
+
+static inline struct roc_rvu_lf *
+rvu_priv_to_roc_rvu_lf(struct rvu_lf *rvu_lf)
+{
+ return (struct roc_rvu_lf *)((char *)rvu_lf - offsetof(struct roc_rvu_lf, reserved));
+}
+
+#endif /* _ROC_RVU_LF_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_utils.c b/drivers/common/cnxk/roc_utils.c
index 9af2ae9b69..bcc0d2de38 100644
--- a/drivers/common/cnxk/roc_utils.c
+++ b/drivers/common/cnxk/roc_utils.c
@@ -17,11 +17,13 @@ roc_error_msg_get(int errorcode)
case NPC_ERR_PARAM:
case SSO_ERR_PARAM:
case MCS_ERR_PARAM:
+ case RVU_ERR_PARAM:
case UTIL_ERR_PARAM:
err_msg = "Invalid parameter";
break;
case NIX_ERR_NO_MEM:
case NPC_ERR_NO_MEM:
+ case RVU_ERR_NO_MEM:
err_msg = "Out of memory";
break;
case NIX_ERR_INVALID_RANGE:
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 877333b80c..777e260731 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -119,6 +119,9 @@ INTERNAL {
roc_idev_nix_rx_chan_set;
roc_idev_nix_rx_inject_get;
roc_idev_nix_rx_inject_set;
+ roc_idev_rvu_lf_free;
+ roc_idev_rvu_lf_get;
+ roc_idev_rvu_lf_set;
roc_ml_reg_read64;
roc_ml_reg_write64;
roc_ml_reg_read32;
@@ -544,5 +547,7 @@ INTERNAL {
roc_ree_rule_db_get;
roc_ree_rule_db_len_get;
roc_ree_rule_db_prog;
+ roc_rvu_lf_dev_fini;
+ roc_rvu_lf_dev_init;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
new file mode 100644
index 0000000000..1ed12d6979
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include <bus_pci_driver.h>
+#include <rte_common.h>
+#include <dev_driver.h>
+#include <rte_eal.h>
+#include <rte_lcore.h>
+#include <rte_pci.h>
+#include <rte_rawdev.h>
+#include <rte_rawdev_pmd.h>
+
+#include <roc_api.h>
+
+#include "cnxk_rvu_lf.h"
+
+static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
+ .dev_selftest = NULL,
+};
+
+static void
+rvu_lf_rawdev_get_name(char *name, struct rte_pci_device *pci_dev)
+{
+ snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "RVU LF:%02x:%02x.%x",
+ pci_dev->addr.bus, pci_dev->addr.devid,
+ pci_dev->addr.function);
+}
+
+static int
+rvu_lf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct rte_rawdev *rvu_lf_rawdev;
+ struct roc_rvu_lf *roc_rvu_lf;
+ int ret;
+
+ RTE_SET_USED(pci_drv);
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (!pci_dev->mem_resource[2].addr) {
+ CNXK_RVU_LF_LOG(ERR, "BARs have invalid values: BAR0 %p, BAR2 %p",
+ pci_dev->mem_resource[2].addr, pci_dev->mem_resource[4].addr);
+ return -ENODEV;
+ }
+
+ ret = roc_plt_init();
+ if (ret)
+ return ret;
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rvu_lf_rawdev = rte_rawdev_pmd_allocate(name, sizeof(*roc_rvu_lf),
+ rte_socket_id());
+ if (rvu_lf_rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "Failed to allocate rawdev");
+ return -ENOMEM;
+ }
+
+ rvu_lf_rawdev->dev_ops = &rvu_lf_rawdev_ops;
+ rvu_lf_rawdev->device = &pci_dev->device;
+ rvu_lf_rawdev->driver_name = pci_dev->driver->driver.name;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rvu_lf_rawdev->dev_private;
+ roc_rvu_lf->pci_dev = pci_dev;
+
+ ret = roc_rvu_lf_dev_init(roc_rvu_lf);
+ if (ret) {
+ rte_rawdev_pmd_release(rvu_lf_rawdev);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int
+rvu_lf_remove(struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (pci_dev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid pci_dev");
+ return -EINVAL;
+ }
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rawdev = rte_rawdev_pmd_get_named_dev(name);
+ if (rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid device name (%s)", name);
+ return -EINVAL;
+ }
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+ roc_rvu_lf_dev_fini(roc_rvu_lf);
+
+ return rte_rawdev_pmd_release(rawdev);
+}
+
+static const struct rte_pci_id pci_rvu_lf_map[] = {
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_PF),
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_VF),
+ {
+ .vendor_id = 0,
+ },
+};
+
+static struct rte_pci_driver cnxk_rvu_lf_rawdev_pmd = {
+ .id_table = pci_rvu_lf_map,
+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
+ .probe = rvu_lf_probe,
+ .remove = rvu_lf_remove,
+};
+
+RTE_PMD_REGISTER_PCI(rvu_lf_rawdev_pci_driver, cnxk_rvu_lf_rawdev_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(rvu_lf_rawdev_pci_driver, pci_rvu_lf_map);
+RTE_PMD_REGISTER_KMOD_DEP(rvu_lf_rawdev_pci_driver, "vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_rvu_lf, rvu_lf, INFO);
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
new file mode 100644
index 0000000000..65cc1bb64d
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _CNXK_RVU_LF_H_
+#define _CNXK_RVU_LF_H_
+
+#include <stdint.h>
+
+#include <rte_common.h>
+
+/**
+ * @file cnxk_rvu_lf.h
+ *
+ * Marvell RVU LF raw PMD specific internal structures
+ *
+ */
+
+extern int cnxk_logtype_rvu_lf;
+#define RTE_LOGTYPE_CNXK_RVU_LF cnxk_logtype_rvu_lf
+#define CNXK_RVU_LF_LOG(level, ...) \
+ RTE_LOG_LINE_PREFIX(level, CNXK_RVU_LF, "%s(): ", __func__, __VA_ARGS__)
+
+#endif /* _CNXK_RVU_LF_H_ */
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
new file mode 100644
index 0000000000..32081e147f
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2024 Marvell.
+#
+
+deps += ['bus_pci', 'common_cnxk', 'rawdev']
+sources = files(
+ 'cnxk_rvu_lf.c',
+)
+require_iova_in_mbuf = false
diff --git a/drivers/raw/meson.build b/drivers/raw/meson.build
index 05cad143fe..54221643d5 100644
--- a/drivers/raw/meson.build
+++ b/drivers/raw/meson.build
@@ -8,6 +8,7 @@ endif
drivers = [
'cnxk_bphy',
'cnxk_gpio',
+ 'cnxk_rvu_lf',
'dpaa2_cmdif',
'ifpga',
'ntb',
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v5 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 1/9] " Akhil Goyal
@ 2024-10-24 13:17 ` Akhil Goyal
2024-10-25 6:52 ` Jerin Jacob
2024-10-25 15:38 ` Stephen Hemminger
2024-10-24 13:17 ` [PATCH v5 3/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
` (7 subsequent siblings)
9 siblings, 2 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:17 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added rte_pmd_rvu_lf_npa_pf_func_get and
rte_pmd_rvu_lf_sso_pf_func_get APIs to get NPA and
SSO pffunc for the application/external driver use.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 +++
drivers/common/cnxk/roc_npa.c | 6 +++
drivers/common/cnxk/roc_npa.h | 3 ++
drivers/common/cnxk/roc_sso.c | 6 +++
drivers/common/cnxk/roc_sso.h | 3 ++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 13 ++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 47 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 1 +
drivers/raw/cnxk_rvu_lf/version.map | 8 ++++
10 files changed, 96 insertions(+)
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
create mode 100644 drivers/raw/cnxk_rvu_lf/version.map
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 8a0bc22dd5..13184ad4dc 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -38,3 +38,10 @@ kernel driver. When querying the status of the devices, they will appear under
the category of "Misc (rawdev) devices", i.e. the command
``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
devices alone.
+
+Get NPA and SSO PF FUNC
+-----------------------
+
+APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
+can be used to get the cnxk NPA PF func and SSO PF func which application
+can use for NPA/SSO specific configuration.
diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index 934d7361a9..a33f9a8499 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -17,6 +17,12 @@ roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb)
return 0;
}
+uint16_t
+roc_npa_pf_func_get(void)
+{
+ return idev_npa_pffunc_get();
+}
+
void
roc_npa_pool_op_range_set(uint64_t aura_handle, uint64_t start_iova,
uint64_t end_iova)
diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h
index fbf75b2fca..f7cb4460e7 100644
--- a/drivers/common/cnxk/roc_npa.h
+++ b/drivers/common/cnxk/roc_npa.h
@@ -820,6 +820,9 @@ int __roc_api roc_npa_aura_bp_configure(uint64_t aura_id, uint16_t bpid, uint8_t
typedef int (*roc_npa_lf_init_cb_t)(struct plt_pci_device *pci_dev);
int __roc_api roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb);
+/* Utility functions */
+uint16_t __roc_api roc_npa_pf_func_get(void);
+
/* Debug */
int __roc_api roc_npa_ctx_dump(void);
int __roc_api roc_npa_dump(void);
diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c
index 2e3b134bfc..aed8819a1b 100644
--- a/drivers/common/cnxk/roc_sso.c
+++ b/drivers/common/cnxk/roc_sso.c
@@ -319,6 +319,12 @@ roc_sso_hwgrp_base_get(struct roc_sso *roc_sso, uint16_t hwgrp)
return dev->bar2 + (RVU_BLOCK_ADDR_SSO << 20 | hwgrp << 12);
}
+uint16_t
+roc_sso_pf_func_get(void)
+{
+ return idev_sso_pffunc_get();
+}
+
uint64_t
roc_sso_ns_to_gw(uint64_t base, uint64_t ns)
{
diff --git a/drivers/common/cnxk/roc_sso.h b/drivers/common/cnxk/roc_sso.h
index 4ac901762e..3e293a0a69 100644
--- a/drivers/common/cnxk/roc_sso.h
+++ b/drivers/common/cnxk/roc_sso.h
@@ -103,6 +103,9 @@ int __roc_api roc_sso_hwgrp_stash_config(struct roc_sso *roc_sso,
void __roc_api roc_sso_hws_gwc_invalidate(struct roc_sso *roc_sso, uint8_t *hws,
uint8_t nb_hws);
+/* Utility function */
+uint16_t __roc_api roc_sso_pf_func_get(void);
+
/* Debug */
void __roc_api roc_sso_dump(struct roc_sso *roc_sso, uint8_t nb_hws,
uint16_t hwgrp, FILE *f);
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 777e260731..d4c3e6c425 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -452,6 +452,7 @@ INTERNAL {
roc_npa_dev_unlock;
roc_npa_dump;
roc_npa_lf_init_cb_register;
+ roc_npa_pf_func_get;
roc_npa_pool_create;
roc_npa_pool_destroy;
roc_npa_pool_op_pc_reset;
@@ -519,6 +520,7 @@ INTERNAL {
roc_sso_hws_gwc_invalidate;
roc_sso_hws_unlink;
roc_sso_ns_to_gw;
+ roc_sso_pf_func_get;
roc_sso_rsrc_fini;
roc_sso_rsrc_init;
roc_tim_fini;
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 1ed12d6979..c8490ccbab 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -14,6 +14,19 @@
#include <roc_api.h>
#include "cnxk_rvu_lf.h"
+#include "cnxk_rvu_lf_driver.h"
+
+uint16_t
+rte_pmd_rvu_lf_npa_pf_func_get(void)
+{
+ return roc_npa_pf_func_get();
+}
+
+uint16_t
+rte_pmd_rvu_lf_sso_pf_func_get(void)
+{
+ return roc_sso_pf_func_get();
+}
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
.dev_selftest = NULL,
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
new file mode 100644
index 0000000000..3837a6066d
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _CNXK_RVU_LF_DRIVER_H_
+#define _CNXK_RVU_LF_DRIVER_H_
+
+#include <stdint.h>
+
+#include <rte_common.h>
+
+/**
+ * @file cnxk_rvu_lf_driver.h
+ *
+ * Marvell RVU LF raw PMD specific structures and interface
+ *
+ * This API allows external driver/application to manage RVU LF device
+ * in user space along with installing interrupt handlers for low latency signal processing.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Obtain NPA PF func
+ *
+ * @return
+ * Returns NPA pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_internal
+uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
+
+/**
+ * Obtain SSO PF func
+ *
+ * @return
+ * Returns SSO pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_internal
+uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CNXK_RVU_LF_DRIVER_H_ */
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
index 32081e147f..7ea1c3916c 100644
--- a/drivers/raw/cnxk_rvu_lf/meson.build
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -6,4 +6,5 @@ deps += ['bus_pci', 'common_cnxk', 'rawdev']
sources = files(
'cnxk_rvu_lf.c',
)
+driver_sdk_headers += files('cnxk_rvu_lf_driver.h')
require_iova_in_mbuf = false
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
new file mode 100644
index 0000000000..3b81544aac
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -0,0 +1,8 @@
+INTERNAL {
+ global:
+
+ rte_pmd_rvu_lf_npa_pf_func_get;
+ rte_pmd_rvu_lf_sso_pf_func_get;
+
+ local: *;
+};
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v5 3/9] raw/cnxk_rvu_lf: register/unregister interrupt handler
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 1/9] " Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc Akhil Goyal
@ 2024-10-24 13:17 ` Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 4/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
` (6 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:17 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added API rte_pmd_rvu_lf_irq_register() and
rte_pmd_rvu_lf_irq_unregister() to register/unregister
interrupt handlers for rvu lf raw device.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 ++++
drivers/common/cnxk/roc_rvu_lf.c | 26 +++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 +++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 30 +++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 46 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 2 +
7 files changed, 119 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 13184ad4dc..52e4f12e3c 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -45,3 +45,11 @@ Get NPA and SSO PF FUNC
APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
can be used to get the cnxk NPA PF func and SSO PF func which application
can use for NPA/SSO specific configuration.
+
+Register or remove interrupt handler
+------------------------------------
+
+Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register()``
+or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
+The irq numbers for which the interrupts are registered is negotiated separately
+and is not in scope of the driver.
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1ae39e746e..63bc149f2a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -61,3 +61,29 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+
+int
+roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ return dev_irq_register(handle, (plt_intr_callback_fn)cb, data, irq);
+}
+
+int
+roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ dev_irq_unregister(handle, (plt_intr_callback_fn)cb, data, irq);
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7ce8065a8b..800bf4e674 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,4 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index d4c3e6c425..4e687c1cb8 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -551,5 +551,7 @@ INTERNAL {
roc_ree_rule_db_prog;
roc_rvu_lf_dev_fini;
roc_rvu_lf_dev_init;
+ roc_rvu_lf_irq_register;
+ roc_rvu_lf_irq_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index c8490ccbab..c108931f97 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,36 @@
#include "cnxk_rvu_lf.h"
#include "cnxk_rvu_lf_driver.h"
+int
+rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_register(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
+int
+rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_unregister(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
uint16_t
rte_pmd_rvu_lf_npa_pf_func_get(void)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 3837a6066d..61bbcb7c04 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -40,6 +40,52 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
__rte_internal
uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+/**
+ * Signature of callback function called when an interrupt is received on RVU LF device.
+ *
+ * @param cb_arg
+ * pointer to the information received on an interrupt
+ */
+typedef void (*rte_pmd_rvu_lf_intr_callback_fn)(void *cb_arg);
+
+/**
+ * Register interrupt callback
+ *
+ * Registers an interrupt callback to be executed when interrupt is raised.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number for which interrupt will be raised
+ * @param cb
+ * callback function to be executed
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
+/**
+ * Unregister interrupt callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number
+ * @param cb
+ * callback function registered
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index 3b81544aac..a2e8a2c9b3 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -1,6 +1,8 @@
INTERNAL {
global:
+ rte_pmd_rvu_lf_irq_register;
+ rte_pmd_rvu_lf_irq_unregister;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v5 4/9] raw/cnxk_rvu_lf: register/unregister msg handler
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (2 preceding siblings ...)
2024-10-24 13:17 ` [PATCH v5 3/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
@ 2024-10-24 13:17 ` Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 5/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
` (5 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:17 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added APIs rte_pmd_rvu_lf_msg_handler_register()
and rte_pmd_rvu_lf_msg_handler_unregister() to register/unregister
mailbox message handlers. These handlers are needed to fill
response at the other side for the request sent from one side.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
drivers/common/cnxk/roc_dev_priv.h | 6 +++
drivers/common/cnxk/roc_rvu_lf.c | 25 ++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 7 +++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 28 +++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 49 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 2 +
7 files changed, 119 insertions(+)
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index dd4949b32c..c766183196 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -46,11 +46,17 @@ typedef void (*link_status_get_t)(void *roc_nix,
/* Representee notification callback */
typedef int (*repte_notify_t)(void *roc_nix, void *notify_msg);
+/* RVU Message process callback */
+typedef int (*msg_process_cb_t)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
struct dev_ops {
link_info_t link_status_update;
ptp_info_t ptp_info_update;
link_status_get_t link_status_get;
q_err_cb_t q_err_cb;
+ msg_process_cb_t msg_process_cb;
repte_notify_t repte_notify;
};
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 63bc149f2a..2e1be81e52 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -87,3 +87,28 @@ roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
return 0;
}
+
+int
+roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf, roc_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ if (cb == NULL)
+ return -EINVAL;
+
+ dev->ops->msg_process_cb = (msg_process_cb_t)cb;
+
+ return 0;
+}
+
+int
+roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ dev->ops->msg_process_cb = NULL;
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 800bf4e674..90a0b5690a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -22,8 +22,15 @@ int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf,
+ roc_rvu_lf_msg_handler_cb_fn cb);
+int __roc_api roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 4e687c1cb8..964c53f819 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -553,5 +553,7 @@ INTERNAL {
roc_rvu_lf_dev_init;
roc_rvu_lf_irq_register;
roc_rvu_lf_irq_unregister;
+ roc_rvu_lf_msg_handler_register;
+ roc_rvu_lf_msg_handler_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index c108931f97..29ab738392 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,34 @@
#include "cnxk_rvu_lf.h"
#include "cnxk_rvu_lf_driver.h"
+int
+rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_register(roc_rvu_lf, (roc_rvu_lf_msg_handler_cb_fn)cb);
+}
+
+int
+rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_unregister(roc_rvu_lf);
+}
+
int
rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 61bbcb7c04..ee5501cc57 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -86,6 +86,55 @@ __rte_internal
int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+/**
+ * Signature of callback function called when a message process handler is called
+ * on RVU LF device.
+ *
+ * @param vf
+ * VF number(0 to N) from which message is received (ignored in case of PF)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request
+ * @param req_len
+ * pointer to message request
+ * @param[out] rsp
+ * pointer to message response
+ * @param[out] rsp_len
+ * length of message response
+ *
+ * @return 0 when response is set, negative value otherwise
+ */
+typedef int (*rte_pmd_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
+/**
+ * Register message handler callback
+ *
+ * Registers message handler callback to be executed when the message is received from peer.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param cb
+ * callback function to be executed
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb);
+
+/**
+ * Unregister message handler callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index a2e8a2c9b3..fcbb2545ea 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -3,6 +3,8 @@ INTERNAL {
rte_pmd_rvu_lf_irq_register;
rte_pmd_rvu_lf_irq_unregister;
+ rte_pmd_rvu_lf_msg_handler_register;
+ rte_pmd_rvu_lf_msg_handler_unregister;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v5 5/9] raw/cnxk_rvu_lf: set message ID range
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (3 preceding siblings ...)
2024-10-24 13:17 ` [PATCH v5 4/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
@ 2024-10-24 13:17 ` Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 6/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
` (4 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:17 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added API rte_pmd_rvu_lf_msg_id_range_set()
to set RVU mailbox message id range.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 12 ++++++++
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 30 ++++++++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 3 ++
drivers/common/cnxk/version.map | 2 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 14 +++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 15 ++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
8 files changed, 78 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 52e4f12e3c..7622b19217 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -53,3 +53,15 @@ Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register(
or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
The irq numbers for which the interrupts are registered is negotiated separately
and is not in scope of the driver.
+
+RVU LF RAW MESSAGE PROCESSING
+-----------------------------
+
+Once a RVU LF raw device is probed, a range of message ids can be configured for
+which mailboxes will be sent using the API ``rte_pmd_rvu_lf_msg_id_range_set``.
+
+For processing of mailboxes received on PF/VF application, application
+can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()``
+and fill required responses as per the request and message id received.
+Application can also unregister already registered message callbacks using
+``rte_pmd_rvu_lf_msg_handler_unregister()``.
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index dd65946e9e..f8791e9f84 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -54,6 +54,7 @@ struct mbox_msghdr {
#define MBOX_MSG_MASK 0xFFFF
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
+#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 2e1be81e52..1026ccc125 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,36 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+int
+roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (from <= MBOX_MSG_GENERIC_MAX_ID || from > to)
+ return -EINVAL;
+
+ rvu->msg_id_from = from;
+ rvu->msg_id_to = to;
+
+ return 0;
+}
+
+bool
+roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
+{
+ struct rvu_lf *rvu;
+
+ if (roc_rvu_lf == NULL)
+ return 0;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (msg_id > rvu->msg_id_from && msg_id < rvu->msg_id_to)
+ return 1;
+
+ return 0;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 90a0b5690a..7243e170b9 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t from, uint16_t to);
+bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
void *req, uint16_t req_len,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 964c53f819..e38da19956 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -555,5 +555,7 @@ INTERNAL {
roc_rvu_lf_irq_unregister;
roc_rvu_lf_msg_handler_register;
roc_rvu_lf_msg_handler_unregister;
+ roc_rvu_lf_msg_id_range_check;
+ roc_rvu_lf_msg_id_range_set;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 29ab738392..82439cf9f8 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,20 @@
#include "cnxk_rvu_lf.h"
#include "cnxk_rvu_lf_driver.h"
+int
+rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index ee5501cc57..07b0279aa0 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -135,6 +135,21 @@ int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handl
__rte_internal
int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
+/**
+ * Set RVU mailbox message id range.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param from
+ * starting message id for RVU mailbox (> 0x1FF)
+ * @param to
+ * last message id for RVU mailbox (< 0xFFFF)
+ *
+ * @return 0 on success, -EINVAL for invalid range
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index fcbb2545ea..d8fb8eba26 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -5,6 +5,7 @@ INTERNAL {
rte_pmd_rvu_lf_irq_unregister;
rte_pmd_rvu_lf_msg_handler_register;
rte_pmd_rvu_lf_msg_handler_unregister;
+ rte_pmd_rvu_lf_msg_id_range_set;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v5 6/9] raw/cnxk_rvu_lf: process mailbox message
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (4 preceding siblings ...)
2024-10-24 13:17 ` [PATCH v5 5/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
@ 2024-10-24 13:17 ` Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 7/9] raw/cnxk_rvu_lf: add API to get device pffunc Akhil Goyal
` (3 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:17 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added API rte_pmd_rvu_lf_msg_process() to process
mailbox messages between rvu_lf devices.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 ++
doc/guides/rel_notes/release_24_11.rst | 5 +
drivers/common/cnxk/roc_dev.c | 118 ++++++++++++++++++-
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 58 +++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 +
drivers/common/cnxk/roc_rvu_lf_priv.h | 5 +
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 15 +++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 29 +++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
11 files changed, 241 insertions(+), 6 deletions(-)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7622b19217..51e1c58b69 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -65,3 +65,11 @@ can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()``
and fill required responses as per the request and message id received.
Application can also unregister already registered message callbacks using
``rte_pmd_rvu_lf_msg_handler_unregister()``.
+
+A PMD API ``rte_pmd_rvu_lf_msg_process()`` is created to send a request and
+receive corresponding response from the other side(PF/VF).
+It accepts an opaque pointer of a request and its size which can be defined by application
+and provides an opaque pointer for a response and its length.
+PF and VF application can define its own request and response based on the message id
+of the mailbox.
+For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``.
diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst
index fa4822d928..3f50545a2e 100644
--- a/doc/guides/rel_notes/release_24_11.rst
+++ b/doc/guides/rel_notes/release_24_11.rst
@@ -247,6 +247,11 @@ New Features
Added ability for node to advertise and update multiple xstat counters,
that can be retrieved using ``rte_graph_cluster_stats_get``.
+* **Added Marvell cnxk RVU LF rawdev driver.**
+
+ Added a new raw device driver for Marvell cnxk based devices to allow
+ applications to communicate using mailboxes and notify for the interrupts.
+
Removed Items
-------------
diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index c905d35ea6..cb8d5d03fd 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -218,6 +218,51 @@ af_pf_wait_msg(struct dev *dev, uint16_t vf, int num_msg)
return req_hdr->num_msgs;
}
+static int
+process_rvu_lf_msgs(struct dev *dev, uint16_t vf, struct mbox_msghdr *msg, size_t size)
+{
+ uint16_t max_bits = sizeof(dev->active_vfs[0]) * 8;
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Handle BPHY mailbox message in PF */
+ dev->active_vfs[vf / max_bits] |= BIT_ULL(vf % max_bits);
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -1;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", vf);
+ return -1;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_vfpf, vf,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", vf);
+ return -1;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ free(resp);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return 0;
+}
+
/* PF receives mbox DOWN messages from VF and forwards to AF */
static int
vf_pf_process_msgs(struct dev *dev, uint16_t vf)
@@ -264,6 +309,9 @@ vf_pf_process_msgs(struct dev *dev, uint16_t vf)
/* PF/VF function ID */
rsp->hdr.pcifunc = msg->pcifunc;
rsp->hdr.rc = 0;
+ } else if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ if (process_rvu_lf_msgs(dev, vf, msg, size) < 0)
+ continue;
} else {
struct mbox_msghdr *af_req;
/* Reserve AF/PF mbox message */
@@ -342,8 +390,13 @@ vf_pf_process_up_msgs(struct dev *dev, uint16_t vf)
dev_get_vf(msg->pcifunc));
break;
default:
- plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
- msg->id, mbox_id2name(msg->id), msg->pcifunc);
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id))
+ plt_base_dbg("PF: Msg 0x%x fn:0x%x (pf:%d,vf:%d)",
+ msg->id, msg->pcifunc, dev_get_pf(msg->pcifunc),
+ dev_get_vf(msg->pcifunc));
+ else
+ plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
+ msg->id, mbox_id2name(msg->id), msg->pcifunc);
}
offset = mbox->rx_start + msg->next_msgoff;
}
@@ -792,6 +845,50 @@ mbox_process_msgs_up(struct dev *dev, struct mbox_msghdr *req)
return -ENODEV;
}
+static int
+process_rvu_lf_msgs_up(struct dev *dev, struct mbox_msghdr *msg, size_t size)
+{
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Check if valid, if not reply with an invalid msg */
+ if (msg->sig != MBOX_REQ_SIG)
+ return -EIO;
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -ENOMEM;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", dev->vf);
+ return rc;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_up, 0,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", dev->vf);
+ return -ENOMEM;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ free(resp);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return rc;
+}
+
/* Received up messages from AF (PF context) / PF (in context) */
static void
process_msgs_up(struct dev *dev, struct mbox *mbox)
@@ -800,6 +897,7 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
struct mbox_hdr *req_hdr;
struct mbox_msghdr *msg;
int i, err, offset;
+ size_t size;
req_hdr = (struct mbox_hdr *)((uintptr_t)mdev->mbase + mbox->rx_start);
if (req_hdr->num_msgs == 0)
@@ -812,10 +910,17 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
plt_base_dbg("Message 0x%x (%s) pf:%d/vf:%d", msg->id,
mbox_id2name(msg->id), dev_get_pf(msg->pcifunc),
dev_get_vf(msg->pcifunc));
- err = mbox_process_msgs_up(dev, msg);
- if (err)
- plt_err("Error %d handling 0x%x (%s)", err, msg->id,
- mbox_id2name(msg->id));
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ size = mbox->rx_start + msg->next_msgoff - offset;
+ err = process_rvu_lf_msgs_up(dev, msg, size);
+ if (err)
+ plt_err("Error %d handling 0x%x RVU_LF up msg", err, msg->id);
+ } else {
+ err = mbox_process_msgs_up(dev, msg);
+ if (err)
+ plt_err("Error %d handling 0x%x (%s)", err, msg->id,
+ mbox_id2name(msg->id));
+ }
offset = mbox->rx_start + msg->next_msgoff;
}
/* Send mbox responses */
@@ -1304,6 +1409,7 @@ dev_vf_hwcap_update(struct plt_pci_device *pci_dev, struct dev *dev)
case PCI_DEVID_CNXK_RVU_VF:
case PCI_DEVID_CNXK_RVU_SDP_VF:
case PCI_DEVID_CNXK_RVU_NIX_INL_VF:
+ case PCI_DEVID_CNXK_RVU_BPHY_VF:
case PCI_DEVID_CNXK_RVU_ESWITCH_VF:
dev->hwcap |= DEV_HWCAP_F_VF;
break;
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index f8791e9f84..4518680684 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -55,6 +55,7 @@ struct mbox_msghdr {
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
+#define MBOX_MSG_REQ_SIZE_MAX (16 * 1024)
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1026ccc125..471dfa7a46 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,15 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+static uint16_t
+roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ return dev->pf_func;
+}
+
int
roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
{
@@ -92,6 +101,55 @@ roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
return 0;
}
+int
+roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf, uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len, void *rsp_data, uint16_t rsp_len)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct mbox *mbox;
+ struct rvu_lf_msg *req;
+ struct rvu_lf_msg *rsp;
+ int rc = -ENOSPC;
+ int devid = 0;
+
+ if (rvu->dev.vf == -1 && roc_rvu_lf_msg_id_range_check(roc_rvu_lf, msg_id)) {
+ /* This is PF context */
+ if (vf >= rvu->dev.maxvf)
+ return -EINVAL;
+ devid = vf;
+ mbox = mbox_get(&rvu->dev.mbox_vfpf_up);
+ } else {
+ /* This is VF context */
+ devid = 0; /* VF send all message to PF */
+ mbox = mbox_get(rvu->dev.mbox);
+ }
+ req = (struct rvu_lf_msg *)mbox_alloc_msg_rsp(mbox, devid,
+ req_len + sizeof(struct rvu_lf_msg),
+ rsp_len + sizeof(struct rvu_lf_msg));
+ if (!req)
+ goto fail;
+ mbox_memcpy(req->data, req_data, req_len);
+ req->hdr.sig = MBOX_REQ_SIG;
+ req->hdr.id = msg_id;
+ req->hdr.pcifunc = roc_rvu_lf_pf_func_get(roc_rvu_lf);
+
+ if (rvu->dev.vf == -1) {
+ mbox_msg_send_up(mbox, devid);
+ rc = mbox_get_rsp(mbox, devid, (void *)&rsp);
+ if (rc)
+ goto fail;
+ } else {
+ rc = mbox_process_msg(mbox, (void *)&rsp);
+ if (rc)
+ goto fail;
+ }
+ if (rsp_len && rsp_data != NULL)
+ mbox_memcpy(rsp_data, rsp->data, rsp_len);
+fail:
+ mbox_put(mbox);
+ return rc;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7243e170b9..6b4819666a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,11 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len,
+ void *rsp_data, uint16_t rsp_len);
+
int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
uint16_t from, uint16_t to);
bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
index 8feff82961..57bb713b21 100644
--- a/drivers/common/cnxk/roc_rvu_lf_priv.h
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -17,6 +17,11 @@ struct rvu_lf {
uint16_t msg_id_to;
};
+struct rvu_lf_msg {
+ struct mbox_msghdr hdr;
+ uint8_t data[];
+};
+
static inline struct rvu_lf *
roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
{
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index e38da19956..1b33421d3d 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -557,5 +557,7 @@ INTERNAL {
roc_rvu_lf_msg_handler_unregister;
roc_rvu_lf_msg_id_range_check;
roc_rvu_lf_msg_id_range_set;
+ roc_rvu_lf_msg_process;
+
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 82439cf9f8..17917532cd 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -30,6 +30,21 @@ rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
}
+int
+rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_process(roc_rvu_lf, vf, msg_id, req, req_len, rsp, rsp_len);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 07b0279aa0..981d297aba 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -150,6 +150,35 @@ int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
__rte_internal
int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+/**
+ * Process a RVU mailbox message.
+ *
+ * Message request and response to be sent/received,
+ * need to be allocated/deallocated by application
+ * before/after processing the message.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param vf
+ * VF number(0 to N) in case of PF->VF message. 0 is valid as VF0.
+ * (For VF->PF message, this field is ignored)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request data to be sent
+ * @param req_len
+ * length of request data
+ * @param rsp
+ * pointer to message response expected to be received, NULL if no response
+ * @param rsp_len
+ * length of message response expected, 0 if no response
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index d8fb8eba26..7896a8f777 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -6,6 +6,7 @@ INTERNAL {
rte_pmd_rvu_lf_msg_handler_register;
rte_pmd_rvu_lf_msg_handler_unregister;
rte_pmd_rvu_lf_msg_id_range_set;
+ rte_pmd_rvu_lf_msg_process;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v5 7/9] raw/cnxk_rvu_lf: add API to get device pffunc
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (5 preceding siblings ...)
2024-10-24 13:17 ` [PATCH v5 6/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
@ 2024-10-24 13:17 ` Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 8/9] raw/cnxk_rvu_lf: add API to get BAR addresses Akhil Goyal
` (2 subsequent siblings)
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:17 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added ``rte_pmd_rvu_lf_pf_func_get`` API
to get RVU LF device pffunc for the application use.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
drivers/common/cnxk/roc_rvu_lf.c | 2 +-
drivers/common/cnxk/roc_rvu_lf.h | 2 ++
drivers/common/cnxk/version.map | 1 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 15 +++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 12 ++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
6 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 471dfa7a46..862a201135 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,7 +62,7 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
-static uint16_t
+uint16_t
roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf)
{
struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 6b4819666a..8c71876cbc 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,8 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+uint16_t __roc_api roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf);
+
int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf,
uint16_t vf, uint16_t msg_id,
void *req_data, uint16_t req_len,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 1b33421d3d..f8028ee4e6 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -558,6 +558,7 @@ INTERNAL {
roc_rvu_lf_msg_id_range_check;
roc_rvu_lf_msg_id_range_set;
roc_rvu_lf_msg_process;
+ roc_rvu_lf_pf_func_get;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 17917532cd..156b9460c1 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -115,6 +115,21 @@ rte_pmd_rvu_lf_sso_pf_func_get(void)
return roc_sso_pf_func_get();
}
+uint16_t
+rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id)
+{
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ if (rawdev == NULL)
+ return 0;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_pf_func_get(roc_rvu_lf);
+}
+
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
.dev_selftest = NULL,
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 981d297aba..22978f89af 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -40,6 +40,18 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
__rte_internal
uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+/**
+ * Obtain RVU LF device PF func
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ *
+ * @return
+ * Returns RVU LF pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_internal
+uint16_t rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id);
+
/**
* Signature of callback function called when an interrupt is received on RVU LF device.
*
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index 7896a8f777..aa974f629e 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -8,6 +8,7 @@ INTERNAL {
rte_pmd_rvu_lf_msg_id_range_set;
rte_pmd_rvu_lf_msg_process;
rte_pmd_rvu_lf_npa_pf_func_get;
+ rte_pmd_rvu_lf_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
local: *;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v5 8/9] raw/cnxk_rvu_lf: add API to get BAR addresses
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (6 preceding siblings ...)
2024-10-24 13:17 ` [PATCH v5 7/9] raw/cnxk_rvu_lf: add API to get device pffunc Akhil Goyal
@ 2024-10-24 13:17 ` Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
9 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:17 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added rte_pmd_rvu_lf_bar_get() API to get BAR address
for application to configure hardware.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 ++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 24 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 18 +++++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
4 files changed, 50 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 51e1c58b69..a972654f82 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -73,3 +73,10 @@ and provides an opaque pointer for a response and its length.
PF and VF application can define its own request and response based on the message id
of the mailbox.
For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``.
+
+Get BAR addresses
+-----------------
+
+Application can retrieve PCI BAR addresses of the device using the API
+``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the
+registers of the hardware device.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 156b9460c1..3a3971ecd3 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -103,6 +103,30 @@ rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
return roc_rvu_lf_irq_unregister(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
}
+int
+rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask)
+{
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ if (bar_num > PCI_MAX_RESOURCE ||
+ (roc_rvu_lf->pci_dev->mem_resource[bar_num].addr == NULL)) {
+ *va = 0;
+ *mask = 0;
+ return -ENOTSUP;
+ }
+ *va = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].addr);
+ *mask = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].len - 1);
+
+ return 0;
+}
+
uint16_t
rte_pmd_rvu_lf_npa_pf_func_get(void)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 22978f89af..922c852592 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -191,6 +191,24 @@ __rte_internal
int rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
void *req, uint16_t req_len, void *rsp, uint16_t rsp_len);
+/**
+ * Get BAR addresses for the RVU LF device.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param bar_num
+ * BAR number for which address is required
+ * @param[out] va
+ * Virtual address of the BAR. 0 if not mapped
+ * @param[out] mask
+ * BAR address mask, 0 if not mapped
+ *
+ * @return
+ * Returns 0 on success, negative error code otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index aa974f629e..012f05d1e4 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -1,6 +1,7 @@
INTERNAL {
global:
+ rte_pmd_rvu_lf_bar_get;
rte_pmd_rvu_lf_irq_register;
rte_pmd_rvu_lf_irq_unregister;
rte_pmd_rvu_lf_msg_handler_register;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v5 9/9] raw/cnxk_rvu_lf: add selftest
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (7 preceding siblings ...)
2024-10-24 13:17 ` [PATCH v5 8/9] raw/cnxk_rvu_lf: add API to get BAR addresses Akhil Goyal
@ 2024-10-24 13:17 ` Akhil Goyal
2024-10-24 16:26 ` Stephen Hemminger
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
9 siblings, 1 reply; 96+ messages in thread
From: Akhil Goyal @ 2024-10-24 13:17 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added raw device selftest for cnxk_rvu_lf to verify
various PMD APIs.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 18 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 4 +-
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 2 +
.../raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c | 166 ++++++++++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 1 +
5 files changed, 188 insertions(+), 3 deletions(-)
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index a972654f82..41fd2d1b42 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -80,3 +80,21 @@ Get BAR addresses
Application can retrieve PCI BAR addresses of the device using the API
``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the
registers of the hardware device.
+
+Self test
+---------
+
+On EAL initialization RVU_LF devices will be probed and populated into
+the raw devices. The rawdev ID of the device can be obtained using invocation
+of ``rte_rawdev_get_dev_id("NAME:x")`` from the test application, where:
+
+- NAME is the desired subsystem: use "RVU_LF".
+- x is the device's bus id specified in "bus:device.func" (BDF) format. BDF follows convention
+ used by lspci i.e bus, device and func are specified using respectively two, two and one hex
+ digit(s).
+
+Use this identifier for further rawdev function calls.
+
+Selftest rawdev API can be used to verify the mailbox communication between
+PF and VF devices based applications. There can be multiple VFs for a particular PF.
+Each VF can send mailboxes to PF and PF can broadcast message to all VFs.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 3a3971ecd3..516fc896b9 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -5,8 +5,6 @@
#include <bus_pci_driver.h>
#include <rte_common.h>
#include <dev_driver.h>
-#include <rte_eal.h>
-#include <rte_lcore.h>
#include <rte_pci.h>
#include <rte_rawdev.h>
#include <rte_rawdev_pmd.h>
@@ -155,7 +153,7 @@ rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id)
}
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
- .dev_selftest = NULL,
+ .dev_selftest = rvu_lf_rawdev_selftest,
};
static void
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
index 65cc1bb64d..e64643dcee 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -21,4 +21,6 @@ extern int cnxk_logtype_rvu_lf;
#define CNXK_RVU_LF_LOG(level, ...) \
RTE_LOG_LINE_PREFIX(level, CNXK_RVU_LF, "%s(): ", __func__, __VA_ARGS__)
+int rvu_lf_rawdev_selftest(uint16_t dev_id);
+
#endif /* _CNXK_RVU_LF_H_ */
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
new file mode 100644
index 0000000000..e33973f24b
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
@@ -0,0 +1,166 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include <stdlib.h>
+#include <inttypes.h>
+
+#include <rte_common.h>
+#include <rte_hexdump.h>
+#include <rte_eal.h>
+#include <rte_lcore.h>
+
+#include <rte_rawdev.h>
+#include <rte_cycles.h>
+
+#include "cnxk_rvu_lf.h"
+#include "cnxk_rvu_lf_driver.h"
+
+#define PF 0
+#define VF 0
+#define RSP_LEN 64
+#define REQ_LEN 64
+#define MSG_ID_FROM 0x3000
+#define MSG_ID_TO 0x4000
+#define MAX_BAR 6
+
+static int
+msg_process_notify_cb(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void **rsp, uint16_t *rsp_len)
+{
+ uint8_t *resp;
+ int i;
+
+ printf("\nReceived message(0x%x) from VF0x%x\n", msg_id, vf);
+ rte_hexdump(stdout, "req_data received", req, req_len);
+
+ resp = malloc(RSP_LEN);
+ if (resp == NULL)
+ return -ENOMEM;
+ for (i = 0; i < RSP_LEN; i++)
+ resp[i] = 0xB0;
+ *rsp = resp;
+ *rsp_len = RSP_LEN;
+ rte_hexdump(stdout, "rsp_data_filled", *rsp, RSP_LEN);
+
+ return 0;
+}
+
+int
+rvu_lf_rawdev_selftest(uint16_t dev_id)
+{
+ char *dev_name = rte_rawdevs[dev_id].name;
+ uint8_t req[REQ_LEN] = {0};
+ uint8_t rsp[RSP_LEN] = {0};
+ size_t bar_mask = 0;
+ size_t bar_va = 0;
+ unsigned int i, j;
+ uint16_t pf_func;
+ char *token[2];
+ int func, ret;
+
+ token[0] = strtok_r(dev_name, ".", &dev_name);
+ token[1] = strtok_r(dev_name, ".", &dev_name);
+ func = atoi(token[1]);
+
+ ret = rte_rawdev_start(dev_id);
+ if (ret)
+ return ret;
+
+ pf_func = rte_pmd_rvu_lf_npa_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "NPA pf_func is invalid");
+
+ pf_func = rte_pmd_rvu_lf_sso_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "SSO pf_func is invalid");
+
+ pf_func = rte_pmd_rvu_lf_pf_func_get(dev_id);
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "RVU-LF pf_func is invalid");
+
+ for (i = 0; i < MAX_BAR; i++) {
+ if (!rte_pmd_rvu_lf_bar_get(dev_id, i, &bar_va, &bar_mask))
+ printf("\n BAR[%d]: addr: 0x%" PRIx64 ", mask: 0x%" PRIx64 "\n",
+ i, bar_va, bar_mask);
+ }
+
+ ret = rte_pmd_rvu_lf_msg_id_range_set(dev_id, MSG_ID_FROM, MSG_ID_TO);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message ID range invalid");
+ goto out;
+ }
+
+ ret = rte_pmd_rvu_lf_msg_handler_register(dev_id, msg_process_notify_cb);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message handler register failed, ret: %d", ret);
+ goto out;
+ }
+
+ if (func == 0) {
+ j = 50;
+ printf("\n");
+ while (j--) {
+ /* PF will wait for RVU message callbacks to be called */
+ rte_delay_ms(1000);
+ printf("PF waiting for VF messages for %d sec.\r", j);
+ }
+ /* PF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xC0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO.
+ * Messages sent with this id will be serviced by VF..
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ VF /* Send to VF0 */,
+ MSG_ID_FROM + 0x2,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf PF->VF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU PF->VF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("PF waiting for VF to exit for %d sec.\r", j);
+ }
+
+ } else {
+ /* VF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xA0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO
+ * Messages sent with this id will be serviced by PF and will
+ * not be forwarded to AF.
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ PF /* Send to PF */,
+ MSG_ID_FROM + 0x1,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf VF->PF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU VF->PF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("VF waiting for PF to send msg for %d sec.\r", j);
+ }
+ }
+unregister:
+ rte_pmd_rvu_lf_msg_handler_unregister(dev_id);
+out:
+ rte_rawdev_stop(dev_id);
+
+ return ret;
+}
+
+
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
index 7ea1c3916c..c960989bb7 100644
--- a/drivers/raw/cnxk_rvu_lf/meson.build
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -5,6 +5,7 @@
deps += ['bus_pci', 'common_cnxk', 'rawdev']
sources = files(
'cnxk_rvu_lf.c',
+ 'cnxk_rvu_lf_selftest.c',
)
driver_sdk_headers += files('cnxk_rvu_lf_driver.h')
require_iova_in_mbuf = false
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* RE: [PATCH v5 1/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-24 13:17 ` [PATCH v5 1/9] " Akhil Goyal
@ 2024-10-24 15:59 ` Jerin Jacob
0 siblings, 0 replies; 96+ messages in thread
From: Jerin Jacob @ 2024-10-24 15:59 UTC (permalink / raw)
To: Akhil Goyal, dev
Cc: thomas, david.marchand, hemant.agrawal, Harman Kalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, October 24, 2024 6:48 PM
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; david.marchand@redhat.com;
> hemant.agrawal@nxp.com; Jerin Jacob <jerinj@marvell.com>; Harman Kalra
> <hkalra@marvell.com>; stephen@networkplumber.org;
> sachin.saxena@oss.nxp.com; ferruh.yigit@amd.com; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [PATCH v5 1/9] drivers/raw: introduce cnxk rvu lf device driver
>
> CNXK product families can have a use case to allow PF and VF applications to
> communicate using mailboxes and also get notified of any interrupt that may
> occur on the device.
> Hence, a new raw device driver is added for such RVU LF devices.
> These devices can map to a PF or a VF which can send mailboxes to each other.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
_> +
> NTB
> M: Jingjing Wu <jingjing.wu@intel.com>
> F: drivers/raw/ntb/
> diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst
> b/doc/guides/rawdevs/cnxk_rvu_lf.rst
> new file mode 100644
> index 0000000000..8a0bc22dd5
> --- /dev/null
> +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
> @@ -0,0 +1,40 @@
> +.. SPDX-License-Identifier: BSD-3-Clause
> + Copyright(c) 2024 Marvell.
> +
> +Marvell CNXK RVU LF Driver
> +==========================
> +
> +CNXK product families can have a use case to allow PF and VF
PF and VF -> RVU PF and RVU VF
> +applications to communicate using mailboxes and also get notified of
Applications-> driver
> +any interrupt that may occur on the device.
> +Hence, a new raw device driver is added for such RVU LF devices.
> +These devices can map to a PF or a VF which can send mailboxes to each
> +other.
> +
> +Features
> +--------
> +
> +The RVU LF device implements following features in the rawdev API:
> +
> +- Register mailbox callbacks for the other side to process mailboxes.
> +- Register interrupt handler callbacks.
> +- Process mailbox.
> +- Set range of message IDs allowed for communication.
Please update each lines in the respective patch.
Also, please wire this file to doc/guides/platform/cnxk.rst like other cnxk drivers
> +
> +Limitations
> +-----------
> +
> +In multiprocess mode user-space application must ensure no resources
> +sharing takes place.
> +Otherwise, user-space application should ensure synchronization.
> +
> +Device Setup
> +------------
> +
> +The RVU LF devices will need to be bound to a user-space IO driver for use.
> +The script ``dpdk-devbind.py`` included with DPDK can be used to view
> +the state of the devices and to bind them to a suitable DPDK-supported
> +kernel driver. When querying the status of the devices, they will
> +appear under the category of "Misc (rawdev) devices", i.e. the command
> +``dpdk-devbind.py --status-dev misc`` can be used to see the state of
> +those devices alone.
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v5 9/9] raw/cnxk_rvu_lf: add selftest
2024-10-24 13:17 ` [PATCH v5 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
@ 2024-10-24 16:26 ` Stephen Hemminger
0 siblings, 0 replies; 96+ messages in thread
From: Stephen Hemminger @ 2024-10-24 16:26 UTC (permalink / raw)
To: Akhil Goyal
Cc: dev, thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
sachin.saxena, ferruh.yigit
On Thu, 24 Oct 2024 18:47:59 +0530
Akhil Goyal <gakhil@marvell.com> wrote:
> Added raw device selftest for cnxk_rvu_lf to verify
> various PMD APIs.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Missing include of rte_common.h??
-------------------------------BEGIN LOGS----------------------------
####################################################################################
#### [Begin job log] "ubuntu-22.04-gcc-debug+doc+examples+tests" at step Build and test
####################################################################################
/home/runner/work/dpdk/dpdk/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h:162:15: error: expected ‘;’ before ‘int’
162 | __rte_internal
| ^
| ;
163 | int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
| ~~~
/home/runner/work/dpdk/dpdk/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h:190:15: error: expected ‘;’ before ‘int’
190 | __rte_internal
| ^
| ;
191 | int rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
| ~~~
/home/runner/work/dpdk/dpdk/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h:209:15: error: expected ‘;’ before ‘int’
209 | __rte_internal
| ^
| ;
210 | int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask);
| ~~~
[3663/6471] Generating 'buildtools/chkincs/chkincs-exp.p/rte_uuid.c'.
[3664/6471] Compiling C object buildtools/chkincs/chkincs.p/meson-generated_bus_uacce_driver.c.o
[3665/6471] Compiling C object buildtools/chkincs/chkincs.p/meson-generated_rte_node_ip6_api.c.o
[3666/6471] Compiling C object buildtools/chkincs/chkincs.p/meson-generated_bus_ifpga_driver.c.o
[3667/6471] Compiling C object buildtools/chkincs/chkincs.p/meson-generated_cnxk_dma_event_dp.c.o
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v5 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc
2024-10-24 13:17 ` [PATCH v5 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc Akhil Goyal
@ 2024-10-25 6:52 ` Jerin Jacob
2024-10-25 15:38 ` Stephen Hemminger
1 sibling, 0 replies; 96+ messages in thread
From: Jerin Jacob @ 2024-10-25 6:52 UTC (permalink / raw)
To: Akhil Goyal
Cc: dev, thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
stephen, sachin.saxena, ferruh.yigit
On Thu, Oct 24, 2024 at 7:00 PM Akhil Goyal <gakhil@marvell.com> wrote:
>
For all patches, please change subject to raw/cnxk_rvu_lf: support ...
> +
> +#include <rte_common.h>
> +
> +/**
> + * @file cnxk_rvu_lf_driver.h
> + *
> + * Marvell RVU LF raw PMD specific structures and interface
> + *
> + * This API allows external driver/application to manage RVU LF device
> + * in user space along with installing interrupt handlers for low latency signal processing.
I think, we can change as “This API allows out of tree driver to
manage RVU LF device”
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v5 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc
2024-10-24 13:17 ` [PATCH v5 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc Akhil Goyal
2024-10-25 6:52 ` Jerin Jacob
@ 2024-10-25 15:38 ` Stephen Hemminger
2024-10-25 19:48 ` [EXTERNAL] " Akhil Goyal
1 sibling, 1 reply; 96+ messages in thread
From: Stephen Hemminger @ 2024-10-25 15:38 UTC (permalink / raw)
To: Akhil Goyal
Cc: dev, thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
sachin.saxena, ferruh.yigit
On Thu, 24 Oct 2024 18:47:52 +0530
Akhil Goyal <gakhil@marvell.com> wrote:
> +/**
> + * @file cnxk_rvu_lf_driver.h
> + *
> + * Marvell RVU LF raw PMD specific structures and interface
> + *
> + * This API allows external driver/application to manage RVU LF device
> + * in user space along with installing interrupt handlers for low latency signal processing.
> + */
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +/**
> + * Obtain NPA PF func
> + *
> + * @return
> + * Returns NPA pf_func on success, 0 in case of invalid pf_func.
> + */
> +__rte_internal
> +uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
> +
> +/**
> + * Obtain SSO PF func
> + *
> + * @return
> + * Returns SSO pf_func on success, 0 in case of invalid pf_func.
> + */
> +__rte_internal
> +uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
> +
> +#ifdef __cplusplus
> +}
> +#endif
If these functions are used by applications, they should be in experimental
section not internal. Applications shouldn't be calling internal routines.
^ permalink raw reply [flat|nested] 96+ messages in thread
* RE: [EXTERNAL] Re: [PATCH v5 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc
2024-10-25 15:38 ` Stephen Hemminger
@ 2024-10-25 19:48 ` Akhil Goyal
0 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-25 19:48 UTC (permalink / raw)
To: Stephen Hemminger
Cc: dev, thomas, david.marchand, hemant.agrawal, Jerin Jacob,
Harman Kalra, sachin.saxena, ferruh.yigit
Hi Stephen,
> On Thu, 24 Oct 2024 18:47:52 +0530
> Akhil Goyal <gakhil@marvell.com> wrote:
>
> > +/**
> > + * @file cnxk_rvu_lf_driver.h
> > + *
> > + * Marvell RVU LF raw PMD specific structures and interface
> > + *
> > + * This API allows external driver/application to manage RVU LF device
> > + * in user space along with installing interrupt handlers for low latency signal
> processing.
> > + */
> > +
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +/**
> > + * Obtain NPA PF func
> > + *
> > + * @return
> > + * Returns NPA pf_func on success, 0 in case of invalid pf_func.
> > + */
> > +__rte_internal
> > +uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
> > +
> > +/**
> > + * Obtain SSO PF func
> > + *
> > + * @return
> > + * Returns SSO pf_func on success, 0 in case of invalid pf_func.
> > + */
> > +__rte_internal
> > +uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
> > +
> > +#ifdef __cplusplus
> > +}
> > +#endif
>
> If these functions are used by applications, they should be in experimental
> section not internal. Applications shouldn't be calling internal routines.
These are meant to be used by external out of tree drivers using the enable_driver_sdk meson option.
Hence should be internal.
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (8 preceding siblings ...)
2024-10-24 13:17 ` [PATCH v5 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
@ 2024-10-28 11:01 ` Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 1/9] drivers/raw: introduce cnxk RVU LF " Akhil Goyal
` (8 more replies)
9 siblings, 9 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-28 11:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
CNXK product families can have a use case to allow PF and VF
applications to communicate using mailboxes and also get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
The RVU LF device implements following features in the rawdev API:
- Register mailbox callbacks for the other side to process mailboxes.
- Register interrupt handler callbacks.
- Process mailbox.
- Set range of message IDs allowed for communication.
Changes in v6:
- Addressed comments from Jerin on documentation
Changes in v5:
- fixed checkpatch
Changes in v4:
- moved all PMD APIs to internal APIs to be exposed via
enable_driver_sdk meson option.
- added missing version.map entries as internal APIs.
- separate out selftest in a separate file
- fixed logs
Changes in v3:
- fix internal/external header files.
Changes in v2:
- removed library patch from series
- removed PMD logs from external PMD header.
- updated doc/api/doxy-api-index.md
- Added release notes
Akhil Goyal (9):
drivers/raw: introduce cnxk rvu lf device driver
raw/cnxk_rvu_lf: support NPA/SSO pffunc get
raw/cnxk_rvu_lf: support interrupt callback registration
raw/cnxk_rvu_lf: support msg handler registration
raw/cnxk_rvu_lf: support to set message ID range
raw/cnxk_rvu_lf: support mailbox processing
raw/cnxk_rvu_lf: support device pffunc get
raw/cnxk_rvu_lf: support getting BAR addresses
raw/cnxk_rvu_lf: add selftest
MAINTAINERS | 6 +
doc/guides/platform/cnxk.rst | 5 +
doc/guides/rawdevs/cnxk_rvu_lf.rst | 109 ++++++++
doc/guides/rawdevs/index.rst | 1 +
doc/guides/rel_notes/release_24_11.rst | 5 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 3 +
drivers/common/cnxk/roc_dev.c | 118 +++++++-
drivers/common/cnxk/roc_dev_priv.h | 7 +
drivers/common/cnxk/roc_idev.c | 46 +++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_mbox.h | 2 +
drivers/common/cnxk/roc_npa.c | 6 +
drivers/common/cnxk/roc_npa.h | 3 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 202 ++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 46 +++
drivers/common/cnxk/roc_rvu_lf_priv.h | 37 +++
drivers/common/cnxk/roc_sso.c | 6 +
drivers/common/cnxk/roc_sso.h | 3 +
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 16 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 262 ++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 26 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 218 +++++++++++++++
.../raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c | 166 +++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 11 +
drivers/raw/cnxk_rvu_lf/version.map | 16 ++
drivers/raw/meson.build | 1 +
31 files changed, 1328 insertions(+), 6 deletions(-)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
create mode 100644 drivers/raw/cnxk_rvu_lf/version.map
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v6 1/9] drivers/raw: introduce cnxk RVU LF device driver
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
@ 2024-10-28 11:01 ` Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 2/9] raw/cnxk_rvu_lf: support NPA/SSO pffunc get Akhil Goyal
` (7 subsequent siblings)
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-28 11:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
CNXK product families can have a use case to allow RVU PF and
RVU VF drivers to communicate using mailboxes and get notified
of any interrupt that may occur on the device.
Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a PF or a VF which can send mailboxes to
each other.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
MAINTAINERS | 6 ++
doc/guides/platform/cnxk.rst | 5 ++
doc/guides/rawdevs/cnxk_rvu_lf.rst | 30 +++++++
doc/guides/rawdevs/index.rst | 1 +
drivers/common/cnxk/meson.build | 1 +
drivers/common/cnxk/roc_api.h | 3 +
drivers/common/cnxk/roc_constants.h | 3 +
drivers/common/cnxk/roc_dev_priv.h | 1 +
drivers/common/cnxk/roc_idev.c | 46 ++++++++++
drivers/common/cnxk/roc_idev.h | 4 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_priv.h | 2 +
drivers/common/cnxk/roc_rvu_lf.c | 63 +++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 24 +++++
drivers/common/cnxk/roc_rvu_lf_priv.h | 32 +++++++
drivers/common/cnxk/roc_utils.c | 2 +
drivers/common/cnxk/version.map | 5 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 123 ++++++++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 24 +++++
drivers/raw/cnxk_rvu_lf/meson.build | 9 ++
drivers/raw/meson.build | 1 +
21 files changed, 386 insertions(+)
create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst
create mode 100644 drivers/common/cnxk/roc_rvu_lf.c
create mode 100644 drivers/common/cnxk/roc_rvu_lf.h
create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build
diff --git a/MAINTAINERS b/MAINTAINERS
index cd78bc7db1..fe1464d06a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1503,6 +1503,12 @@ T: git://dpdk.org/next/dpdk-next-net-mrvl
F: doc/guides/rawdevs/cnxk_gpio.rst
F: drivers/raw/cnxk_gpio/
+Marvell CNXK RVU LF
+M: Akhil Goyal <gakhil@marvell.com>
+T: git://dpdk.org/next/dpdk-next-net-mrvl
+F: doc/guides/rawdevs/cnxk_rvu_lf.rst
+F: drivers/raw/cnxk_rvu_lf/
+
NTB
M: Jingjing Wu <jingjing.wu@intel.com>
F: drivers/raw/ntb/
diff --git a/doc/guides/platform/cnxk.rst b/doc/guides/platform/cnxk.rst
index 0e61bc91d9..642ba9b1c9 100644
--- a/doc/guides/platform/cnxk.rst
+++ b/doc/guides/platform/cnxk.rst
@@ -78,6 +78,8 @@ DPDK subsystem.
+---+-----+--------------------------------------------------------------+
| 13| ML | rte_mldev |
+---+-----+--------------------------------------------------------------+
+ | 14| RVU | rte_rawdev |
+ +---+-----+--------------------------------------------------------------+
PF0 is called the administrative / admin function (AF) and has exclusive
privileges to provision RVU functional block's LFs to each of the PF/VF.
@@ -175,6 +177,9 @@ This section lists dataplane H/W block(s) available in cnxk SoC.
#. **ML Device Driver**
See :doc:`../mldevs/cnxk` for Machine Learning device driver information.
+#. **RVU LF Driver**
+ See :doc:`../rawdevs/cnxk_rvu_lf` for RVU LF driver information.
+
Procedure to Setup Platform
---------------------------
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
new file mode 100644
index 0000000000..8543596aad
--- /dev/null
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -0,0 +1,30 @@
+.. SPDX-License-Identifier: BSD-3-Clause
+ Copyright(c) 2024 Marvell.
+
+Marvell CNXK RVU LF Driver
+==========================
+
+CNXK product families can have a use case to allow RVU PF and RVU VF
+driver to communicate using mailboxes and also get notified
+of any interrupt that may occur on the device.
+Hence, a new raw device driver is added for such RVU LF devices.
+These devices can map to a RVU PF or a RVU VF which
+can send mailboxes to each other.
+
+Limitations
+-----------
+
+In multiprocess mode user-space application must ensure
+no resources sharing takes place.
+Otherwise, user-space application should ensure synchronization.
+
+Device Setup
+------------
+
+The RVU LF devices will need to be bound to a user-space IO driver for use.
+The script ``dpdk-devbind.py`` included with DPDK can be used to
+view the state of the devices and to bind them to a suitable DPDK-supported
+kernel driver. When querying the status of the devices, they will appear under
+the category of "Misc (rawdev) devices", i.e. the command
+``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
+devices alone.
diff --git a/doc/guides/rawdevs/index.rst b/doc/guides/rawdevs/index.rst
index f34315f051..8e07cf4d6c 100644
--- a/doc/guides/rawdevs/index.rst
+++ b/doc/guides/rawdevs/index.rst
@@ -13,6 +13,7 @@ application through rawdev API.
cnxk_bphy
cnxk_gpio
+ cnxk_rvu_lf
dpaa2_cmdif
ifpga
ntb
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index abb0f6f01f..cb0ffd5d40 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -71,6 +71,7 @@ sources = files(
'roc_tim_irq.c',
'roc_utils.c',
'roc_ree.c',
+ 'roc_rvu_lf.c',
)
# Security common code
diff --git a/drivers/common/cnxk/roc_api.h b/drivers/common/cnxk/roc_api.h
index 6a86863c57..93e7bf11bb 100644
--- a/drivers/common/cnxk/roc_api.h
+++ b/drivers/common/cnxk/roc_api.h
@@ -120,4 +120,7 @@
/* Eswitch */
#include "roc_eswitch.h"
+/* RVU LF */
+#include "roc_rvu_lf.h"
+
#endif /* _ROC_API_H_ */
diff --git a/drivers/common/cnxk/roc_constants.h b/drivers/common/cnxk/roc_constants.h
index 0e7495a37c..67cd74b28a 100644
--- a/drivers/common/cnxk/roc_constants.h
+++ b/drivers/common/cnxk/roc_constants.h
@@ -45,6 +45,8 @@
#define PCI_DEVID_CNXK_RVU_REE_VF 0xA0f5
#define PCI_DEVID_CNXK_RVU_ESWITCH_PF 0xA0E0
#define PCI_DEVID_CNXK_RVU_ESWITCH_VF 0xA0E1
+#define PCI_DEVID_CNXK_RVU_BPHY_PF 0xA0E4
+#define PCI_DEVID_CNXK_RVU_BPHY_VF 0xA0E5
#define PCI_DEVID_CN9K_CGX 0xA059
#define PCI_DEVID_CN10K_RPM 0xA060
@@ -63,6 +65,7 @@
#define PCI_SUBSYSTEM_DEVID_CNF10KB 0xBC00
#define PCI_SUBSYSTEM_DEVID_CN20KA 0xA020
+#define PCI_SUBSYSTEM_DEVID_CNF20KA 0xA000
#define PCI_SUBSYSTEM_DEVID_CN9KA 0x0000
#define PCI_SUBSYSTEM_DEVID_CN9KB 0xb400
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index 5ab4f72f8f..dd4949b32c 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -141,6 +141,7 @@ struct dev {
void *roc_cpt;
void *roc_tim;
void *roc_ml;
+ void *roc_rvu_lf;
bool disable_shared_lmt; /* false(default): shared lmt mode enabled */
const struct plt_memzone *lmt_mz;
struct mbox_sync sync;
diff --git a/drivers/common/cnxk/roc_idev.c b/drivers/common/cnxk/roc_idev.c
index 0778d51d1e..84812f73e0 100644
--- a/drivers/common/cnxk/roc_idev.c
+++ b/drivers/common/cnxk/roc_idev.c
@@ -38,6 +38,7 @@ idev_set_defaults(struct idev_cfg *idev)
idev->num_lmtlines = 0;
idev->bphy = NULL;
idev->cpt = NULL;
+ TAILQ_INIT(&idev->rvu_lf_list);
TAILQ_INIT(&idev->mcs_list);
idev->nix_inl_dev = NULL;
TAILQ_INIT(&idev->roc_nix_list);
@@ -188,6 +189,51 @@ roc_idev_cpt_get(void)
return NULL;
}
+struct roc_rvu_lf *
+roc_idev_rvu_lf_get(uint8_t rvu_lf_idx)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf, &idev->rvu_lf_list, next) {
+ if (rvu_lf->idx == rvu_lf_idx)
+ return rvu_lf;
+ }
+ }
+
+ return NULL;
+}
+
+void
+roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ return;
+ }
+ TAILQ_INSERT_TAIL(&idev->rvu_lf_list, rvu, next);
+ }
+}
+
+void
+roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+ struct roc_rvu_lf *rvu_lf_iter = NULL;
+
+ if (idev != NULL) {
+ TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) {
+ if (rvu_lf_iter->idx == rvu->idx)
+ TAILQ_REMOVE(&idev->rvu_lf_list, rvu, next);
+ }
+ }
+}
+
struct roc_mcs *
roc_idev_mcs_get(uint8_t mcs_idx)
{
diff --git a/drivers/common/cnxk/roc_idev.h b/drivers/common/cnxk/roc_idev.h
index fc0f7db54e..6edb5f83b2 100644
--- a/drivers/common/cnxk/roc_idev.h
+++ b/drivers/common/cnxk/roc_idev.h
@@ -29,4 +29,8 @@ uint16_t *__roc_api roc_idev_nix_rx_chan_base_get(void);
void __roc_api roc_idev_nix_rx_chan_set(uint16_t port, uint16_t chan);
uint16_t __roc_api roc_idev_nix_inl_dev_pffunc_get(void);
+
+struct roc_rvu_lf *__roc_api roc_idev_rvu_lf_get(uint8_t rvu_lf_idx);
+void __roc_api roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu);
+void __roc_api roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu);
#endif /* _ROC_IDEV_H_ */
diff --git a/drivers/common/cnxk/roc_idev_priv.h b/drivers/common/cnxk/roc_idev_priv.h
index 6628b18152..98b6286bfe 100644
--- a/drivers/common/cnxk/roc_idev_priv.h
+++ b/drivers/common/cnxk/roc_idev_priv.h
@@ -36,6 +36,7 @@ struct idev_cfg {
struct roc_bphy *bphy;
struct roc_cpt *cpt;
struct roc_sso *sso;
+ struct roc_rvu_lf_head rvu_lf_list;
struct roc_mcs_head mcs_list;
struct nix_inl_dev *nix_inl_dev;
struct idev_nix_inl_cfg inl_cfg;
diff --git a/drivers/common/cnxk/roc_priv.h b/drivers/common/cnxk/roc_priv.h
index 254a2d3310..8732a05ac3 100644
--- a/drivers/common/cnxk/roc_priv.h
+++ b/drivers/common/cnxk/roc_priv.h
@@ -53,4 +53,6 @@
/* ML */
#include "roc_ml_priv.h"
+/* RVU LF */
+#include "roc_rvu_lf_priv.h"
#endif /* _ROC_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
new file mode 100644
index 0000000000..1ae39e746e
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include "roc_api.h"
+#include "roc_priv.h"
+
+int
+roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct plt_pci_device *pci_dev;
+ struct dev *dev;
+ struct rvu_lf *rvu;
+ int rc;
+
+ if (roc_rvu_lf == NULL || roc_rvu_lf->pci_dev == NULL)
+ return RVU_ERR_PARAM;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ pci_dev = roc_rvu_lf->pci_dev;
+ dev = &rvu->dev;
+
+ if (rvu->dev.drv_inited)
+ return 0;
+
+ if (dev->mbox_active)
+ goto skip_dev_init;
+
+ memset(rvu, 0, sizeof(*rvu));
+
+ /* Initialize device */
+ rc = dev_init(dev, pci_dev);
+ if (rc) {
+ plt_err("Failed to init roc device");
+ goto fail;
+ }
+
+skip_dev_init:
+ dev->roc_rvu_lf = roc_rvu_lf;
+ rvu->pci_dev = pci_dev;
+
+ roc_idev_rvu_lf_set(roc_rvu_lf);
+ rvu->dev.drv_inited = true;
+
+ return 0;
+fail:
+ return rc;
+}
+
+int
+roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (rvu == NULL)
+ return NIX_ERR_PARAM;
+
+ rvu->dev.drv_inited = false;
+
+ roc_idev_rvu_lf_free(roc_rvu_lf);
+
+ return dev_fini(&rvu->dev, rvu->pci_dev);
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
new file mode 100644
index 0000000000..7ce8065a8b
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_H_
+#define _ROC_RVU_LF_H_
+
+#include "roc_platform.h"
+
+struct roc_rvu_lf {
+ TAILQ_ENTRY(roc_rvu_lf) next;
+ struct plt_pci_device *pci_dev;
+ uint8_t idx;
+#define ROC_RVU_MEM_SZ (6 * 1024)
+ uint8_t reserved[ROC_RVU_MEM_SZ] __plt_cache_aligned;
+};
+
+TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
+
+/* Dev */
+int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+
+#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
new file mode 100644
index 0000000000..8feff82961
--- /dev/null
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ROC_RVU_LF_PRIV_H_
+#define _ROC_RVU_LF_PRIV_H_
+
+enum rvu_err_status {
+ RVU_ERR_PARAM = -1,
+ RVU_ERR_NO_MEM = -2,
+};
+
+struct rvu_lf {
+ struct plt_pci_device *pci_dev;
+ struct dev dev;
+ uint16_t msg_id_from;
+ uint16_t msg_id_to;
+};
+
+static inline struct rvu_lf *
+roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
+{
+ return (struct rvu_lf *)&roc_rvu_lf->reserved[0];
+}
+
+static inline struct roc_rvu_lf *
+rvu_priv_to_roc_rvu_lf(struct rvu_lf *rvu_lf)
+{
+ return (struct roc_rvu_lf *)((char *)rvu_lf - offsetof(struct roc_rvu_lf, reserved));
+}
+
+#endif /* _ROC_RVU_LF_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_utils.c b/drivers/common/cnxk/roc_utils.c
index 9af2ae9b69..bcc0d2de38 100644
--- a/drivers/common/cnxk/roc_utils.c
+++ b/drivers/common/cnxk/roc_utils.c
@@ -17,11 +17,13 @@ roc_error_msg_get(int errorcode)
case NPC_ERR_PARAM:
case SSO_ERR_PARAM:
case MCS_ERR_PARAM:
+ case RVU_ERR_PARAM:
case UTIL_ERR_PARAM:
err_msg = "Invalid parameter";
break;
case NIX_ERR_NO_MEM:
case NPC_ERR_NO_MEM:
+ case RVU_ERR_NO_MEM:
err_msg = "Out of memory";
break;
case NIX_ERR_INVALID_RANGE:
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 935be3584c..b1373bc429 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -120,6 +120,9 @@ INTERNAL {
roc_idev_nix_rx_chan_set;
roc_idev_nix_rx_inject_get;
roc_idev_nix_rx_inject_set;
+ roc_idev_rvu_lf_free;
+ roc_idev_rvu_lf_get;
+ roc_idev_rvu_lf_set;
roc_ml_reg_read64;
roc_ml_reg_write64;
roc_ml_reg_read32;
@@ -545,5 +548,7 @@ INTERNAL {
roc_ree_rule_db_get;
roc_ree_rule_db_len_get;
roc_ree_rule_db_prog;
+ roc_rvu_lf_dev_fini;
+ roc_rvu_lf_dev_init;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
new file mode 100644
index 0000000000..1ed12d6979
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include <bus_pci_driver.h>
+#include <rte_common.h>
+#include <dev_driver.h>
+#include <rte_eal.h>
+#include <rte_lcore.h>
+#include <rte_pci.h>
+#include <rte_rawdev.h>
+#include <rte_rawdev_pmd.h>
+
+#include <roc_api.h>
+
+#include "cnxk_rvu_lf.h"
+
+static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
+ .dev_selftest = NULL,
+};
+
+static void
+rvu_lf_rawdev_get_name(char *name, struct rte_pci_device *pci_dev)
+{
+ snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "RVU LF:%02x:%02x.%x",
+ pci_dev->addr.bus, pci_dev->addr.devid,
+ pci_dev->addr.function);
+}
+
+static int
+rvu_lf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct rte_rawdev *rvu_lf_rawdev;
+ struct roc_rvu_lf *roc_rvu_lf;
+ int ret;
+
+ RTE_SET_USED(pci_drv);
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (!pci_dev->mem_resource[2].addr) {
+ CNXK_RVU_LF_LOG(ERR, "BARs have invalid values: BAR0 %p, BAR2 %p",
+ pci_dev->mem_resource[2].addr, pci_dev->mem_resource[4].addr);
+ return -ENODEV;
+ }
+
+ ret = roc_plt_init();
+ if (ret)
+ return ret;
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rvu_lf_rawdev = rte_rawdev_pmd_allocate(name, sizeof(*roc_rvu_lf),
+ rte_socket_id());
+ if (rvu_lf_rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "Failed to allocate rawdev");
+ return -ENOMEM;
+ }
+
+ rvu_lf_rawdev->dev_ops = &rvu_lf_rawdev_ops;
+ rvu_lf_rawdev->device = &pci_dev->device;
+ rvu_lf_rawdev->driver_name = pci_dev->driver->driver.name;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rvu_lf_rawdev->dev_private;
+ roc_rvu_lf->pci_dev = pci_dev;
+
+ ret = roc_rvu_lf_dev_init(roc_rvu_lf);
+ if (ret) {
+ rte_rawdev_pmd_release(rvu_lf_rawdev);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int
+rvu_lf_remove(struct rte_pci_device *pci_dev)
+{
+ char name[RTE_RAWDEV_NAME_MAX_LEN];
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (pci_dev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid pci_dev");
+ return -EINVAL;
+ }
+
+ rvu_lf_rawdev_get_name(name, pci_dev);
+ rawdev = rte_rawdev_pmd_get_named_dev(name);
+ if (rawdev == NULL) {
+ CNXK_RVU_LF_LOG(ERR, "invalid device name (%s)", name);
+ return -EINVAL;
+ }
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+ roc_rvu_lf_dev_fini(roc_rvu_lf);
+
+ return rte_rawdev_pmd_release(rawdev);
+}
+
+static const struct rte_pci_id pci_rvu_lf_map[] = {
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_PF),
+ CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_VF),
+ {
+ .vendor_id = 0,
+ },
+};
+
+static struct rte_pci_driver cnxk_rvu_lf_rawdev_pmd = {
+ .id_table = pci_rvu_lf_map,
+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
+ .probe = rvu_lf_probe,
+ .remove = rvu_lf_remove,
+};
+
+RTE_PMD_REGISTER_PCI(rvu_lf_rawdev_pci_driver, cnxk_rvu_lf_rawdev_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(rvu_lf_rawdev_pci_driver, pci_rvu_lf_map);
+RTE_PMD_REGISTER_KMOD_DEP(rvu_lf_rawdev_pci_driver, "vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_rvu_lf, rvu_lf, INFO);
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
new file mode 100644
index 0000000000..65cc1bb64d
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _CNXK_RVU_LF_H_
+#define _CNXK_RVU_LF_H_
+
+#include <stdint.h>
+
+#include <rte_common.h>
+
+/**
+ * @file cnxk_rvu_lf.h
+ *
+ * Marvell RVU LF raw PMD specific internal structures
+ *
+ */
+
+extern int cnxk_logtype_rvu_lf;
+#define RTE_LOGTYPE_CNXK_RVU_LF cnxk_logtype_rvu_lf
+#define CNXK_RVU_LF_LOG(level, ...) \
+ RTE_LOG_LINE_PREFIX(level, CNXK_RVU_LF, "%s(): ", __func__, __VA_ARGS__)
+
+#endif /* _CNXK_RVU_LF_H_ */
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
new file mode 100644
index 0000000000..32081e147f
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2024 Marvell.
+#
+
+deps += ['bus_pci', 'common_cnxk', 'rawdev']
+sources = files(
+ 'cnxk_rvu_lf.c',
+)
+require_iova_in_mbuf = false
diff --git a/drivers/raw/meson.build b/drivers/raw/meson.build
index 05cad143fe..54221643d5 100644
--- a/drivers/raw/meson.build
+++ b/drivers/raw/meson.build
@@ -8,6 +8,7 @@ endif
drivers = [
'cnxk_bphy',
'cnxk_gpio',
+ 'cnxk_rvu_lf',
'dpaa2_cmdif',
'ifpga',
'ntb',
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v6 2/9] raw/cnxk_rvu_lf: support NPA/SSO pffunc get
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 1/9] drivers/raw: introduce cnxk RVU LF " Akhil Goyal
@ 2024-10-28 11:01 ` Akhil Goyal
2024-10-29 16:10 ` Jerin Jacob
2024-10-28 11:01 ` [PATCH v6 3/9] raw/cnxk_rvu_lf: support interrupt callback registration Akhil Goyal
` (6 subsequent siblings)
8 siblings, 1 reply; 96+ messages in thread
From: Akhil Goyal @ 2024-10-28 11:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added rte_pmd_rvu_lf_npa_pf_func_get and
rte_pmd_rvu_lf_sso_pf_func_get APIs to get NPA and
SSO pffunc for the application/external driver use.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 14 ++++++
drivers/common/cnxk/roc_npa.c | 6 +++
drivers/common/cnxk/roc_npa.h | 3 ++
drivers/common/cnxk/roc_sso.c | 6 +++
drivers/common/cnxk/roc_sso.h | 3 ++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 13 ++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 49 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 1 +
drivers/raw/cnxk_rvu_lf/version.map | 8 ++++
10 files changed, 105 insertions(+)
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
create mode 100644 drivers/raw/cnxk_rvu_lf/version.map
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 8543596aad..7429bb9739 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -11,6 +11,13 @@ Hence, a new raw device driver is added for such RVU LF devices.
These devices can map to a RVU PF or a RVU VF which
can send mailboxes to each other.
+Features
+--------
+
+The RVU LF device implements following features in the rawdev API:
+
+- Get PF FUNC of associated NPA and SSO devices.
+
Limitations
-----------
@@ -28,3 +35,10 @@ kernel driver. When querying the status of the devices, they will appear under
the category of "Misc (rawdev) devices", i.e. the command
``dpdk-devbind.py --status-dev misc`` can be used to see the state of those
devices alone.
+
+Get NPA and SSO PF FUNC
+-----------------------
+
+APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
+can be used to get the cnxk NPA PF func and SSO PF func which application
+can use for NPA/SSO specific configuration.
diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index 934d7361a9..a33f9a8499 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -17,6 +17,12 @@ roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb)
return 0;
}
+uint16_t
+roc_npa_pf_func_get(void)
+{
+ return idev_npa_pffunc_get();
+}
+
void
roc_npa_pool_op_range_set(uint64_t aura_handle, uint64_t start_iova,
uint64_t end_iova)
diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h
index fbf75b2fca..f7cb4460e7 100644
--- a/drivers/common/cnxk/roc_npa.h
+++ b/drivers/common/cnxk/roc_npa.h
@@ -820,6 +820,9 @@ int __roc_api roc_npa_aura_bp_configure(uint64_t aura_id, uint16_t bpid, uint8_t
typedef int (*roc_npa_lf_init_cb_t)(struct plt_pci_device *pci_dev);
int __roc_api roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb);
+/* Utility functions */
+uint16_t __roc_api roc_npa_pf_func_get(void);
+
/* Debug */
int __roc_api roc_npa_ctx_dump(void);
int __roc_api roc_npa_dump(void);
diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c
index 2e3b134bfc..aed8819a1b 100644
--- a/drivers/common/cnxk/roc_sso.c
+++ b/drivers/common/cnxk/roc_sso.c
@@ -319,6 +319,12 @@ roc_sso_hwgrp_base_get(struct roc_sso *roc_sso, uint16_t hwgrp)
return dev->bar2 + (RVU_BLOCK_ADDR_SSO << 20 | hwgrp << 12);
}
+uint16_t
+roc_sso_pf_func_get(void)
+{
+ return idev_sso_pffunc_get();
+}
+
uint64_t
roc_sso_ns_to_gw(uint64_t base, uint64_t ns)
{
diff --git a/drivers/common/cnxk/roc_sso.h b/drivers/common/cnxk/roc_sso.h
index 4ac901762e..3e293a0a69 100644
--- a/drivers/common/cnxk/roc_sso.h
+++ b/drivers/common/cnxk/roc_sso.h
@@ -103,6 +103,9 @@ int __roc_api roc_sso_hwgrp_stash_config(struct roc_sso *roc_sso,
void __roc_api roc_sso_hws_gwc_invalidate(struct roc_sso *roc_sso, uint8_t *hws,
uint8_t nb_hws);
+/* Utility function */
+uint16_t __roc_api roc_sso_pf_func_get(void);
+
/* Debug */
void __roc_api roc_sso_dump(struct roc_sso *roc_sso, uint8_t nb_hws,
uint16_t hwgrp, FILE *f);
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index b1373bc429..419df30470 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -453,6 +453,7 @@ INTERNAL {
roc_npa_dev_unlock;
roc_npa_dump;
roc_npa_lf_init_cb_register;
+ roc_npa_pf_func_get;
roc_npa_pool_create;
roc_npa_pool_destroy;
roc_npa_pool_op_pc_reset;
@@ -520,6 +521,7 @@ INTERNAL {
roc_sso_hws_gwc_invalidate;
roc_sso_hws_unlink;
roc_sso_ns_to_gw;
+ roc_sso_pf_func_get;
roc_sso_rsrc_fini;
roc_sso_rsrc_init;
roc_tim_fini;
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 1ed12d6979..c8490ccbab 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -14,6 +14,19 @@
#include <roc_api.h>
#include "cnxk_rvu_lf.h"
+#include "cnxk_rvu_lf_driver.h"
+
+uint16_t
+rte_pmd_rvu_lf_npa_pf_func_get(void)
+{
+ return roc_npa_pf_func_get();
+}
+
+uint16_t
+rte_pmd_rvu_lf_sso_pf_func_get(void)
+{
+ return roc_sso_pf_func_get();
+}
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
.dev_selftest = NULL,
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
new file mode 100644
index 0000000000..460e0129a7
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _CNXK_RVU_LF_DRIVER_H_
+#define _CNXK_RVU_LF_DRIVER_H_
+
+/**
+ * @file cnxk_rvu_lf_driver.h
+ *
+ * Marvell RVU LF raw PMD specific structures and interface
+ *
+ * This API allows out of tree driver to manage RVU LF device
+ * in user space along with installing interrupt handlers for
+ * low latency signal processing.
+ */
+
+#include <stdint.h>
+
+#include <rte_compat.h>
+#include <rte_common.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Obtain NPA PF func
+ *
+ * @return
+ * Returns NPA pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_internal
+uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
+
+/**
+ * Obtain SSO PF func
+ *
+ * @return
+ * Returns SSO pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_internal
+uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CNXK_RVU_LF_DRIVER_H_ */
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
index 32081e147f..7ea1c3916c 100644
--- a/drivers/raw/cnxk_rvu_lf/meson.build
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -6,4 +6,5 @@ deps += ['bus_pci', 'common_cnxk', 'rawdev']
sources = files(
'cnxk_rvu_lf.c',
)
+driver_sdk_headers += files('cnxk_rvu_lf_driver.h')
require_iova_in_mbuf = false
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
new file mode 100644
index 0000000000..3b81544aac
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -0,0 +1,8 @@
+INTERNAL {
+ global:
+
+ rte_pmd_rvu_lf_npa_pf_func_get;
+ rte_pmd_rvu_lf_sso_pf_func_get;
+
+ local: *;
+};
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v6 3/9] raw/cnxk_rvu_lf: support interrupt callback registration
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 1/9] drivers/raw: introduce cnxk RVU LF " Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 2/9] raw/cnxk_rvu_lf: support NPA/SSO pffunc get Akhil Goyal
@ 2024-10-28 11:01 ` Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 4/9] raw/cnxk_rvu_lf: support msg handler registration Akhil Goyal
` (5 subsequent siblings)
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-28 11:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added API rte_pmd_rvu_lf_irq_register() and
rte_pmd_rvu_lf_irq_unregister() to register/unregister
interrupt handlers for rvu lf raw device.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 9 ++++
drivers/common/cnxk/roc_rvu_lf.c | 26 +++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 +++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 30 +++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 46 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 2 +
7 files changed, 120 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7429bb9739..4a0ce5654b 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -17,6 +17,7 @@ Features
The RVU LF device implements following features in the rawdev API:
- Get PF FUNC of associated NPA and SSO devices.
+- Register/unregister interrupt handlers.
Limitations
-----------
@@ -42,3 +43,11 @@ Get NPA and SSO PF FUNC
APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()``
can be used to get the cnxk NPA PF func and SSO PF func which application
can use for NPA/SSO specific configuration.
+
+Register or remove interrupt handler
+------------------------------------
+
+Out of tree drivers can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register()``
+or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
+The irq numbers for which the interrupts are registered is negotiated separately
+and is not in scope of the driver.
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1ae39e746e..63bc149f2a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -61,3 +61,29 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+
+int
+roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ return dev_irq_register(handle, (plt_intr_callback_fn)cb, data, irq);
+}
+
+int
+roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *data)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct plt_intr_handle *handle;
+
+ handle = rvu->pci_dev->intr_handle;
+
+ dev_irq_unregister(handle, (plt_intr_callback_fn)cb, data, irq);
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7ce8065a8b..800bf4e674 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,4 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
+ roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 419df30470..174a953f6f 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -552,5 +552,7 @@ INTERNAL {
roc_ree_rule_db_prog;
roc_rvu_lf_dev_fini;
roc_rvu_lf_dev_init;
+ roc_rvu_lf_irq_register;
+ roc_rvu_lf_irq_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index c8490ccbab..c108931f97 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,36 @@
#include "cnxk_rvu_lf.h"
#include "cnxk_rvu_lf_driver.h"
+int
+rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_register(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
+int
+rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_irq_unregister(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
+}
+
uint16_t
rte_pmd_rvu_lf_npa_pf_func_get(void)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 460e0129a7..b315b2c61e 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -42,6 +42,52 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
__rte_internal
uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+/**
+ * Signature of callback function called when an interrupt is received on RVU LF device.
+ *
+ * @param cb_arg
+ * pointer to the information received on an interrupt
+ */
+typedef void (*rte_pmd_rvu_lf_intr_callback_fn)(void *cb_arg);
+
+/**
+ * Register interrupt callback
+ *
+ * Registers an interrupt callback to be executed when interrupt is raised.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number for which interrupt will be raised
+ * @param cb
+ * callback function to be executed
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
+/**
+ * Unregister interrupt callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param irq
+ * interrupt number
+ * @param cb
+ * callback function registered
+ * @param cb_arg
+ * argument to be passed to callback function
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
+ rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index 3b81544aac..a2e8a2c9b3 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -1,6 +1,8 @@
INTERNAL {
global:
+ rte_pmd_rvu_lf_irq_register;
+ rte_pmd_rvu_lf_irq_unregister;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v6 4/9] raw/cnxk_rvu_lf: support msg handler registration
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (2 preceding siblings ...)
2024-10-28 11:01 ` [PATCH v6 3/9] raw/cnxk_rvu_lf: support interrupt callback registration Akhil Goyal
@ 2024-10-28 11:01 ` Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 5/9] raw/cnxk_rvu_lf: support to set message ID range Akhil Goyal
` (4 subsequent siblings)
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-28 11:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added APIs rte_pmd_rvu_lf_msg_handler_register()
and rte_pmd_rvu_lf_msg_handler_unregister() to register/unregister
mailbox message handlers. These handlers are needed to fill
response at the other side for the request sent from one side.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 10 ++++
drivers/common/cnxk/roc_dev_priv.h | 6 +++
drivers/common/cnxk/roc_rvu_lf.c | 25 ++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 7 +++
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 28 +++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 49 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 2 +
8 files changed, 129 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 4a0ce5654b..3c1856fc6e 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -18,6 +18,7 @@ The RVU LF device implements following features in the rawdev API:
- Get PF FUNC of associated NPA and SSO devices.
- Register/unregister interrupt handlers.
+- Register/unregister mailbox callbacks for the other side to process mailboxes.
Limitations
-----------
@@ -51,3 +52,12 @@ Out of tree drivers can register interrupt handlers using ``rte_pmd_rvu_lf_irq_r
or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``.
The irq numbers for which the interrupts are registered is negotiated separately
and is not in scope of the driver.
+
+RVU LF RAW MESSAGE PROCESSING
+-----------------------------
+
+For processing of mailboxes received on RVU PF/VF application, out of tree
+drivers can register/unregister callbacks using ``rte_pmd_rvu_lf_msg_handler_register()``
+and ``rte_pmd_rvu_lf_msg_handler_unregister()``.
+Required responses as per the request and message id received can be filled
+in the callbacks.
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index dd4949b32c..c766183196 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -46,11 +46,17 @@ typedef void (*link_status_get_t)(void *roc_nix,
/* Representee notification callback */
typedef int (*repte_notify_t)(void *roc_nix, void *notify_msg);
+/* RVU Message process callback */
+typedef int (*msg_process_cb_t)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
struct dev_ops {
link_info_t link_status_update;
ptp_info_t ptp_info_update;
link_status_get_t link_status_get;
q_err_cb_t q_err_cb;
+ msg_process_cb_t msg_process_cb;
repte_notify_t repte_notify;
};
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 63bc149f2a..2e1be81e52 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -87,3 +87,28 @@ roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
return 0;
}
+
+int
+roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf, roc_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ if (cb == NULL)
+ return -EINVAL;
+
+ dev->ops->msg_process_cb = (msg_process_cb_t)cb;
+
+ return 0;
+}
+
+int
+roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ dev->ops->msg_process_cb = NULL;
+
+ return 0;
+}
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 800bf4e674..90a0b5690a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -22,8 +22,15 @@ int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
+typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *cb_arg);
+int __roc_api roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf,
+ roc_rvu_lf_msg_handler_cb_fn cb);
+int __roc_api roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf);
#endif /* _ROC_RVU_LF_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 174a953f6f..bc37f9ecd2 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -554,5 +554,7 @@ INTERNAL {
roc_rvu_lf_dev_init;
roc_rvu_lf_irq_register;
roc_rvu_lf_irq_unregister;
+ roc_rvu_lf_msg_handler_register;
+ roc_rvu_lf_msg_handler_unregister;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index c108931f97..29ab738392 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,34 @@
#include "cnxk_rvu_lf.h"
#include "cnxk_rvu_lf_driver.h"
+int
+rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_register(roc_rvu_lf, (roc_rvu_lf_msg_handler_cb_fn)cb);
+}
+
+int
+rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_handler_unregister(roc_rvu_lf);
+}
+
int
rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq,
rte_pmd_rvu_lf_intr_callback_fn cb, void *data)
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index b315b2c61e..15320e55ba 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -88,6 +88,55 @@ __rte_internal
int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg);
+/**
+ * Signature of callback function called when a message process handler is called
+ * on RVU LF device.
+ *
+ * @param vf
+ * VF number(0 to N) from which message is received (ignored in case of PF)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request
+ * @param req_len
+ * pointer to message request
+ * @param[out] rsp
+ * pointer to message response
+ * @param[out] rsp_len
+ * length of message response
+ *
+ * @return 0 when response is set, negative value otherwise
+ */
+typedef int (*rte_pmd_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len,
+ void **rsp, uint16_t *rsp_len);
+
+/**
+ * Register message handler callback
+ *
+ * Registers message handler callback to be executed when the message is received from peer.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param cb
+ * callback function to be executed
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb);
+
+/**
+ * Unregister message handler callback
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index a2e8a2c9b3..fcbb2545ea 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -3,6 +3,8 @@ INTERNAL {
rte_pmd_rvu_lf_irq_register;
rte_pmd_rvu_lf_irq_unregister;
+ rte_pmd_rvu_lf_msg_handler_register;
+ rte_pmd_rvu_lf_msg_handler_unregister;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v6 5/9] raw/cnxk_rvu_lf: support to set message ID range
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (3 preceding siblings ...)
2024-10-28 11:01 ` [PATCH v6 4/9] raw/cnxk_rvu_lf: support msg handler registration Akhil Goyal
@ 2024-10-28 11:01 ` Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 6/9] raw/cnxk_rvu_lf: support mailbox processing Akhil Goyal
` (3 subsequent siblings)
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-28 11:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added API rte_pmd_rvu_lf_msg_id_range_set()
to set RVU mailbox message id range from out of tree
driver to communicate.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 4 +++
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 30 ++++++++++++++++++++
drivers/common/cnxk/roc_rvu_lf.h | 3 ++
drivers/common/cnxk/version.map | 2 ++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 14 +++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 15 ++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
8 files changed, 70 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 3c1856fc6e..7f456ab61d 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -19,6 +19,7 @@ The RVU LF device implements following features in the rawdev API:
- Get PF FUNC of associated NPA and SSO devices.
- Register/unregister interrupt handlers.
- Register/unregister mailbox callbacks for the other side to process mailboxes.
+- Set mailbox message ID range to be used by the driver.
Limitations
-----------
@@ -61,3 +62,6 @@ drivers can register/unregister callbacks using ``rte_pmd_rvu_lf_msg_handler_reg
and ``rte_pmd_rvu_lf_msg_handler_unregister()``.
Required responses as per the request and message id received can be filled
in the callbacks.
+
+Once a RVU LF raw device is probed, a range of message ids can be configured for
+which mailboxes will be sent using the API ``rte_pmd_rvu_lf_msg_id_range_set()``.
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index 0864c0e8c0..7d8145a4b3 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -54,6 +54,7 @@ struct mbox_msghdr {
#define MBOX_MSG_MASK 0xFFFF
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
+#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 2e1be81e52..1026ccc125 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,36 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+int
+roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (from <= MBOX_MSG_GENERIC_MAX_ID || from > to)
+ return -EINVAL;
+
+ rvu->msg_id_from = from;
+ rvu->msg_id_to = to;
+
+ return 0;
+}
+
+bool
+roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
+{
+ struct rvu_lf *rvu;
+
+ if (roc_rvu_lf == NULL)
+ return 0;
+
+ rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+
+ if (msg_id > rvu->msg_id_from && msg_id < rvu->msg_id_to)
+ return 1;
+
+ return 0;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 90a0b5690a..7243e170b9 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t from, uint16_t to);
+bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg);
typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id,
void *req, uint16_t req_len,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index bc37f9ecd2..c2c67bc721 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -556,5 +556,7 @@ INTERNAL {
roc_rvu_lf_irq_unregister;
roc_rvu_lf_msg_handler_register;
roc_rvu_lf_msg_handler_unregister;
+ roc_rvu_lf_msg_id_range_check;
+ roc_rvu_lf_msg_id_range_set;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 29ab738392..82439cf9f8 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -16,6 +16,20 @@
#include "cnxk_rvu_lf.h"
#include "cnxk_rvu_lf_driver.h"
+int
+rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 15320e55ba..567778dcc5 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -137,6 +137,21 @@ int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handl
__rte_internal
int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
+/**
+ * Set RVU mailbox message id range.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param from
+ * starting message id for RVU mailbox (> 0x1FF)
+ * @param to
+ * last message id for RVU mailbox (< 0xFFFF)
+ *
+ * @return 0 on success, -EINVAL for invalid range
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index fcbb2545ea..d8fb8eba26 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -5,6 +5,7 @@ INTERNAL {
rte_pmd_rvu_lf_irq_unregister;
rte_pmd_rvu_lf_msg_handler_register;
rte_pmd_rvu_lf_msg_handler_unregister;
+ rte_pmd_rvu_lf_msg_id_range_set;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v6 6/9] raw/cnxk_rvu_lf: support mailbox processing
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (4 preceding siblings ...)
2024-10-28 11:01 ` [PATCH v6 5/9] raw/cnxk_rvu_lf: support to set message ID range Akhil Goyal
@ 2024-10-28 11:01 ` Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 7/9] raw/cnxk_rvu_lf: support device pffunc get Akhil Goyal
` (2 subsequent siblings)
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-28 11:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added API rte_pmd_rvu_lf_msg_process() to process
mailbox messages between rvu_lf devices.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 ++
doc/guides/rel_notes/release_24_11.rst | 5 +
drivers/common/cnxk/roc_dev.c | 118 ++++++++++++++++++-
drivers/common/cnxk/roc_mbox.h | 1 +
drivers/common/cnxk/roc_rvu_lf.c | 58 +++++++++
drivers/common/cnxk/roc_rvu_lf.h | 5 +
drivers/common/cnxk/roc_rvu_lf_priv.h | 5 +
drivers/common/cnxk/version.map | 2 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 15 +++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 29 +++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
11 files changed, 241 insertions(+), 6 deletions(-)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 7f456ab61d..e425950d16 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -20,6 +20,7 @@ The RVU LF device implements following features in the rawdev API:
- Register/unregister interrupt handlers.
- Register/unregister mailbox callbacks for the other side to process mailboxes.
- Set mailbox message ID range to be used by the driver.
+- Process mailbox messages.
Limitations
-----------
@@ -65,3 +66,10 @@ in the callbacks.
Once a RVU LF raw device is probed, a range of message ids can be configured for
which mailboxes will be sent using the API ``rte_pmd_rvu_lf_msg_id_range_set()``.
+
+The out of tree driver can call ``rte_pmd_rvu_lf_msg_process()`` to send a request and
+receive corresponding response from the other side(PF/VF).
+It accepts an opaque pointer of a request and its size which can be defined by user
+and provides an opaque pointer for a response and its length.
+PF and VF out of tree driver can define its own request and response based on the message id
+of the mailbox.
diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst
index 66f14af5b8..bf386a0f4a 100644
--- a/doc/guides/rel_notes/release_24_11.rst
+++ b/doc/guides/rel_notes/release_24_11.rst
@@ -251,6 +251,11 @@ New Features
Added ability for node to advertise and update multiple xstat counters,
that can be retrieved using ``rte_graph_cluster_stats_get``.
+* **Added Marvell cnxk RVU LF rawdev driver.**
+
+ Added a new raw device driver for Marvell cnxk based devices to allow
+ applications to communicate using mailboxes and notify for the interrupts.
+
Removed Items
-------------
diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index 45f007325e..32409f2ef3 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -218,6 +218,51 @@ af_pf_wait_msg(struct dev *dev, uint16_t vf, int num_msg)
return req_hdr->num_msgs;
}
+static int
+process_rvu_lf_msgs(struct dev *dev, uint16_t vf, struct mbox_msghdr *msg, size_t size)
+{
+ uint16_t max_bits = sizeof(dev->active_vfs[0]) * 8;
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Handle BPHY mailbox message in PF */
+ dev->active_vfs[vf / max_bits] |= BIT_ULL(vf % max_bits);
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -1;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", vf);
+ return -1;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_vfpf, vf,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", vf);
+ return -1;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ free(resp);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return 0;
+}
+
/* PF receives mbox DOWN messages from VF and forwards to AF */
static int
vf_pf_process_msgs(struct dev *dev, uint16_t vf)
@@ -264,6 +309,9 @@ vf_pf_process_msgs(struct dev *dev, uint16_t vf)
/* PF/VF function ID */
rsp->hdr.pcifunc = msg->pcifunc;
rsp->hdr.rc = 0;
+ } else if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ if (process_rvu_lf_msgs(dev, vf, msg, size) < 0)
+ continue;
} else {
struct mbox_msghdr *af_req;
/* Reserve AF/PF mbox message */
@@ -342,8 +390,13 @@ vf_pf_process_up_msgs(struct dev *dev, uint16_t vf)
dev_get_vf(msg->pcifunc));
break;
default:
- plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
- msg->id, mbox_id2name(msg->id), msg->pcifunc);
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id))
+ plt_base_dbg("PF: Msg 0x%x fn:0x%x (pf:%d,vf:%d)",
+ msg->id, msg->pcifunc, dev_get_pf(msg->pcifunc),
+ dev_get_vf(msg->pcifunc));
+ else
+ plt_err("Not handled UP msg 0x%x (%s) func:0x%x",
+ msg->id, mbox_id2name(msg->id), msg->pcifunc);
}
offset = mbox->rx_start + msg->next_msgoff;
}
@@ -782,6 +835,50 @@ mbox_process_msgs_up(struct dev *dev, struct mbox_msghdr *req)
return -ENODEV;
}
+static int
+process_rvu_lf_msgs_up(struct dev *dev, struct mbox_msghdr *msg, size_t size)
+{
+ uint8_t req[MBOX_MSG_REQ_SIZE_MAX];
+ struct msg_rsp *rsp;
+ uint16_t rsp_len;
+ void *resp;
+ int rc = 0;
+
+ /* Check if valid, if not reply with an invalid msg */
+ if (msg->sig != MBOX_REQ_SIG)
+ return -EIO;
+
+ if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) {
+ plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX);
+ return -ENOMEM;
+ }
+ mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr),
+ size - sizeof(struct mbox_msghdr));
+ rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req,
+ size - sizeof(struct mbox_msghdr), &resp, &rsp_len);
+ if (rc < 0) {
+ plt_err("Failed to process VF%d message", dev->vf);
+ return rc;
+ }
+
+ rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_up, 0,
+ rsp_len + sizeof(struct mbox_msghdr));
+ if (!rsp) {
+ plt_err("Failed to alloc VF%d response message", dev->vf);
+ return -ENOMEM;
+ }
+
+ mbox_rsp_init(msg->id, rsp);
+
+ mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len);
+ free(resp);
+ /* PF/VF function ID */
+ rsp->hdr.pcifunc = msg->pcifunc;
+ rsp->hdr.rc = 0;
+
+ return rc;
+}
+
/* Received up messages from AF (PF context) / PF (in context) */
static void
process_msgs_up(struct dev *dev, struct mbox *mbox)
@@ -790,6 +887,7 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
struct mbox_hdr *req_hdr;
struct mbox_msghdr *msg;
int i, err, offset;
+ size_t size;
req_hdr = (struct mbox_hdr *)((uintptr_t)mdev->mbase + mbox->rx_start);
if (req_hdr->num_msgs == 0)
@@ -802,10 +900,17 @@ process_msgs_up(struct dev *dev, struct mbox *mbox)
plt_base_dbg("Message 0x%x (%s) pf:%d/vf:%d", msg->id,
mbox_id2name(msg->id), dev_get_pf(msg->pcifunc),
dev_get_vf(msg->pcifunc));
- err = mbox_process_msgs_up(dev, msg);
- if (err)
- plt_err("Error %d handling 0x%x (%s)", err, msg->id,
- mbox_id2name(msg->id));
+ if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) {
+ size = mbox->rx_start + msg->next_msgoff - offset;
+ err = process_rvu_lf_msgs_up(dev, msg, size);
+ if (err)
+ plt_err("Error %d handling 0x%x RVU_LF up msg", err, msg->id);
+ } else {
+ err = mbox_process_msgs_up(dev, msg);
+ if (err)
+ plt_err("Error %d handling 0x%x (%s)", err, msg->id,
+ mbox_id2name(msg->id));
+ }
offset = mbox->rx_start + msg->next_msgoff;
}
/* Send mbox responses */
@@ -1294,6 +1399,7 @@ dev_vf_hwcap_update(struct plt_pci_device *pci_dev, struct dev *dev)
case PCI_DEVID_CNXK_RVU_VF:
case PCI_DEVID_CNXK_RVU_SDP_VF:
case PCI_DEVID_CNXK_RVU_NIX_INL_VF:
+ case PCI_DEVID_CNXK_RVU_BPHY_VF:
case PCI_DEVID_CNXK_RVU_ESWITCH_VF:
dev->hwcap |= DEV_HWCAP_F_VF;
break;
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index 7d8145a4b3..e7a916d61c 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -55,6 +55,7 @@ struct mbox_msghdr {
#define MBOX_MSG_INVALID 0xFFFE
#define MBOX_MSG_MAX 0xFFFF
#define MBOX_MSG_GENERIC_MAX_ID 0x1FF
+#define MBOX_MSG_REQ_SIZE_MAX (16 * 1024)
#define MBOX_MESSAGES \
/* Generic mbox IDs (range 0x000 - 0x1FF) */ \
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 1026ccc125..471dfa7a46 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,6 +62,15 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
+static uint16_t
+roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct dev *dev = &rvu->dev;
+
+ return dev->pf_func;
+}
+
int
roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to)
{
@@ -92,6 +101,55 @@ roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id)
return 0;
}
+int
+roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf, uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len, void *rsp_data, uint16_t rsp_len)
+{
+ struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
+ struct mbox *mbox;
+ struct rvu_lf_msg *req;
+ struct rvu_lf_msg *rsp;
+ int rc = -ENOSPC;
+ int devid = 0;
+
+ if (rvu->dev.vf == -1 && roc_rvu_lf_msg_id_range_check(roc_rvu_lf, msg_id)) {
+ /* This is PF context */
+ if (vf >= rvu->dev.maxvf)
+ return -EINVAL;
+ devid = vf;
+ mbox = mbox_get(&rvu->dev.mbox_vfpf_up);
+ } else {
+ /* This is VF context */
+ devid = 0; /* VF send all message to PF */
+ mbox = mbox_get(rvu->dev.mbox);
+ }
+ req = (struct rvu_lf_msg *)mbox_alloc_msg_rsp(mbox, devid,
+ req_len + sizeof(struct rvu_lf_msg),
+ rsp_len + sizeof(struct rvu_lf_msg));
+ if (!req)
+ goto fail;
+ mbox_memcpy(req->data, req_data, req_len);
+ req->hdr.sig = MBOX_REQ_SIG;
+ req->hdr.id = msg_id;
+ req->hdr.pcifunc = roc_rvu_lf_pf_func_get(roc_rvu_lf);
+
+ if (rvu->dev.vf == -1) {
+ mbox_msg_send_up(mbox, devid);
+ rc = mbox_get_rsp(mbox, devid, (void *)&rsp);
+ if (rc)
+ goto fail;
+ } else {
+ rc = mbox_process_msg(mbox, (void *)&rsp);
+ if (rc)
+ goto fail;
+ }
+ if (rsp_len && rsp_data != NULL)
+ mbox_memcpy(rsp_data, rsp->data, rsp_len);
+fail:
+ mbox_put(mbox);
+ return rc;
+}
+
int
roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq,
roc_rvu_lf_intr_cb_fn cb, void *data)
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 7243e170b9..6b4819666a 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,11 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf,
+ uint16_t vf, uint16_t msg_id,
+ void *req_data, uint16_t req_len,
+ void *rsp_data, uint16_t rsp_len);
+
int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf,
uint16_t from, uint16_t to);
bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id);
diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h
index 8feff82961..57bb713b21 100644
--- a/drivers/common/cnxk/roc_rvu_lf_priv.h
+++ b/drivers/common/cnxk/roc_rvu_lf_priv.h
@@ -17,6 +17,11 @@ struct rvu_lf {
uint16_t msg_id_to;
};
+struct rvu_lf_msg {
+ struct mbox_msghdr hdr;
+ uint8_t data[];
+};
+
static inline struct rvu_lf *
roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf)
{
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index c2c67bc721..a8cb0755ab 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -558,5 +558,7 @@ INTERNAL {
roc_rvu_lf_msg_handler_unregister;
roc_rvu_lf_msg_id_range_check;
roc_rvu_lf_msg_id_range_set;
+ roc_rvu_lf_msg_process;
+
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 82439cf9f8..17917532cd 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -30,6 +30,21 @@ rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to)
return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to);
}
+int
+rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len)
+{
+ struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ struct roc_rvu_lf *roc_rvu_lf;
+
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_msg_process(roc_rvu_lf, vf, msg_id, req, req_len, rsp, rsp_len);
+}
+
int
rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 567778dcc5..1d0308d6f1 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -152,6 +152,35 @@ int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id);
__rte_internal
int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to);
+/**
+ * Process a RVU mailbox message.
+ *
+ * Message request and response to be sent/received,
+ * need to be allocated/deallocated by application
+ * before/after processing the message.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param vf
+ * VF number(0 to N) in case of PF->VF message. 0 is valid as VF0.
+ * (For VF->PF message, this field is ignored)
+ * @param msg_id
+ * message id
+ * @param req
+ * pointer to message request data to be sent
+ * @param req_len
+ * length of request data
+ * @param rsp
+ * pointer to message response expected to be received, NULL if no response
+ * @param rsp_len
+ * length of message response expected, 0 if no response
+ *
+ * @return 0 on success, negative value otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void *rsp, uint16_t rsp_len);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index d8fb8eba26..7896a8f777 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -6,6 +6,7 @@ INTERNAL {
rte_pmd_rvu_lf_msg_handler_register;
rte_pmd_rvu_lf_msg_handler_unregister;
rte_pmd_rvu_lf_msg_id_range_set;
+ rte_pmd_rvu_lf_msg_process;
rte_pmd_rvu_lf_npa_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v6 7/9] raw/cnxk_rvu_lf: support device pffunc get
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (5 preceding siblings ...)
2024-10-28 11:01 ` [PATCH v6 6/9] raw/cnxk_rvu_lf: support mailbox processing Akhil Goyal
@ 2024-10-28 11:01 ` Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 8/9] raw/cnxk_rvu_lf: support getting BAR addresses Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-28 11:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added ``rte_pmd_rvu_lf_pf_func_get`` API
to get RVU LF device pffunc for the application use.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 6 ++++++
drivers/common/cnxk/roc_rvu_lf.c | 2 +-
drivers/common/cnxk/roc_rvu_lf.h | 2 ++
drivers/common/cnxk/version.map | 1 +
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 15 +++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 12 ++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
7 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index e425950d16..0854c88ac9 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -17,6 +17,7 @@ Features
The RVU LF device implements following features in the rawdev API:
- Get PF FUNC of associated NPA and SSO devices.
+- Get PF FUNC for RVU LF device.
- Register/unregister interrupt handlers.
- Register/unregister mailbox callbacks for the other side to process mailboxes.
- Set mailbox message ID range to be used by the driver.
@@ -47,6 +48,11 @@ APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()
can be used to get the cnxk NPA PF func and SSO PF func which application
can use for NPA/SSO specific configuration.
+Get RVU LF PF FUNC
+------------------
+
+APIs ``rte_pmd_rvu_lf_pf_func_get()`` is added to get the RVU LF device PF FUNC.
+
Register or remove interrupt handler
------------------------------------
diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c
index 471dfa7a46..862a201135 100644
--- a/drivers/common/cnxk/roc_rvu_lf.c
+++ b/drivers/common/cnxk/roc_rvu_lf.c
@@ -62,7 +62,7 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf)
return dev_fini(&rvu->dev, rvu->pci_dev);
}
-static uint16_t
+uint16_t
roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf)
{
struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf);
diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h
index 6b4819666a..8c71876cbc 100644
--- a/drivers/common/cnxk/roc_rvu_lf.h
+++ b/drivers/common/cnxk/roc_rvu_lf.h
@@ -21,6 +21,8 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf);
int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf);
+uint16_t __roc_api roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf);
+
int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf,
uint16_t vf, uint16_t msg_id,
void *req_data, uint16_t req_len,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index a8cb0755ab..42e9375706 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -559,6 +559,7 @@ INTERNAL {
roc_rvu_lf_msg_id_range_check;
roc_rvu_lf_msg_id_range_set;
roc_rvu_lf_msg_process;
+ roc_rvu_lf_pf_func_get;
local: *;
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 17917532cd..156b9460c1 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -115,6 +115,21 @@ rte_pmd_rvu_lf_sso_pf_func_get(void)
return roc_sso_pf_func_get();
}
+uint16_t
+rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id)
+{
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ if (rawdev == NULL)
+ return 0;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ return roc_rvu_lf_pf_func_get(roc_rvu_lf);
+}
+
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
.dev_selftest = NULL,
};
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 1d0308d6f1..9c4ede2602 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -42,6 +42,18 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void);
__rte_internal
uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void);
+/**
+ * Obtain RVU LF device PF func
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ *
+ * @return
+ * Returns RVU LF pf_func on success, 0 in case of invalid pf_func.
+ */
+__rte_internal
+uint16_t rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id);
+
/**
* Signature of callback function called when an interrupt is received on RVU LF device.
*
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index 7896a8f777..aa974f629e 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -8,6 +8,7 @@ INTERNAL {
rte_pmd_rvu_lf_msg_id_range_set;
rte_pmd_rvu_lf_msg_process;
rte_pmd_rvu_lf_npa_pf_func_get;
+ rte_pmd_rvu_lf_pf_func_get;
rte_pmd_rvu_lf_sso_pf_func_get;
local: *;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v6 8/9] raw/cnxk_rvu_lf: support getting BAR addresses
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (6 preceding siblings ...)
2024-10-28 11:01 ` [PATCH v6 7/9] raw/cnxk_rvu_lf: support device pffunc get Akhil Goyal
@ 2024-10-28 11:01 ` Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-28 11:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added rte_pmd_rvu_lf_bar_get() API to get BAR address
for out of tree drivers to configure hardware.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 +++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 24 ++++++++++++++++++++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h | 18 +++++++++++++++
drivers/raw/cnxk_rvu_lf/version.map | 1 +
4 files changed, 51 insertions(+)
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 0854c88ac9..708c9410fd 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -22,6 +22,7 @@ The RVU LF device implements following features in the rawdev API:
- Register/unregister mailbox callbacks for the other side to process mailboxes.
- Set mailbox message ID range to be used by the driver.
- Process mailbox messages.
+- Get BAR Addresses for the out of tree drivers to configure registers.
Limitations
-----------
@@ -79,3 +80,10 @@ It accepts an opaque pointer of a request and its size which can be defined by u
and provides an opaque pointer for a response and its length.
PF and VF out of tree driver can define its own request and response based on the message id
of the mailbox.
+
+Get BAR addresses
+-----------------
+
+Out of tree drivers can retrieve PCI BAR addresses of the device using the API
+``rte_pmd_rvu_lf_bar_get()``. This helps PF/VF drivers to configure the
+registers of the hardware device.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 156b9460c1..3a3971ecd3 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -103,6 +103,30 @@ rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq,
return roc_rvu_lf_irq_unregister(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data);
}
+int
+rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask)
+{
+ struct roc_rvu_lf *roc_rvu_lf;
+ struct rte_rawdev *rawdev;
+
+ rawdev = rte_rawdev_pmd_get_dev(dev_id);
+ if (rawdev == NULL)
+ return -EINVAL;
+
+ roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private;
+
+ if (bar_num > PCI_MAX_RESOURCE ||
+ (roc_rvu_lf->pci_dev->mem_resource[bar_num].addr == NULL)) {
+ *va = 0;
+ *mask = 0;
+ return -ENOTSUP;
+ }
+ *va = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].addr);
+ *mask = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].len - 1);
+
+ return 0;
+}
+
uint16_t
rte_pmd_rvu_lf_npa_pf_func_get(void)
{
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index 9c4ede2602..e405831ce1 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -193,6 +193,24 @@ __rte_internal
int rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id,
void *req, uint16_t req_len, void *rsp, uint16_t rsp_len);
+/**
+ * Get BAR addresses for the RVU LF device.
+ *
+ * @param dev_id
+ * device id of RVU LF device
+ * @param bar_num
+ * BAR number for which address is required
+ * @param[out] va
+ * Virtual address of the BAR. 0 if not mapped
+ * @param[out] mask
+ * BAR address mask, 0 if not mapped
+ *
+ * @return
+ * Returns 0 on success, negative error code otherwise
+ */
+__rte_internal
+int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map
index aa974f629e..012f05d1e4 100644
--- a/drivers/raw/cnxk_rvu_lf/version.map
+++ b/drivers/raw/cnxk_rvu_lf/version.map
@@ -1,6 +1,7 @@
INTERNAL {
global:
+ rte_pmd_rvu_lf_bar_get;
rte_pmd_rvu_lf_irq_register;
rte_pmd_rvu_lf_irq_unregister;
rte_pmd_rvu_lf_msg_handler_register;
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* [PATCH v6 9/9] raw/cnxk_rvu_lf: add selftest
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
` (7 preceding siblings ...)
2024-10-28 11:01 ` [PATCH v6 8/9] raw/cnxk_rvu_lf: support getting BAR addresses Akhil Goyal
@ 2024-10-28 11:01 ` Akhil Goyal
8 siblings, 0 replies; 96+ messages in thread
From: Akhil Goyal @ 2024-10-28 11:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.marchand, hemant.agrawal, jerinj, hkalra, stephen,
sachin.saxena, ferruh.yigit, Akhil Goyal
Added raw device selftest for cnxk_rvu_lf to verify
various PMD APIs.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
doc/guides/rawdevs/cnxk_rvu_lf.rst | 20 +++
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 2 +-
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 2 +
.../raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c | 166 ++++++++++++++++++
drivers/raw/cnxk_rvu_lf/meson.build | 1 +
5 files changed, 190 insertions(+), 1 deletion(-)
create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 708c9410fd..1ac7d6b84b 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -81,9 +81,29 @@ and provides an opaque pointer for a response and its length.
PF and VF out of tree driver can define its own request and response based on the message id
of the mailbox.
+For sample usage of the APIs, refer ``rvu_lf_rawdev_selftest()``.
+
Get BAR addresses
-----------------
Out of tree drivers can retrieve PCI BAR addresses of the device using the API
``rte_pmd_rvu_lf_bar_get()``. This helps PF/VF drivers to configure the
registers of the hardware device.
+
+Self test
+---------
+
+On EAL initialization RVU_LF devices will be probed and populated into
+the raw devices. The rawdev ID of the device can be obtained using invocation
+of ``rte_rawdev_get_dev_id("NAME:x")`` from the test application, where:
+
+- NAME is the desired subsystem: use "RVU_LF".
+- x is the device's bus id specified in "bus:device.func" (BDF) format. BDF follows convention
+ used by lspci i.e bus, device and func are specified using respectively two, two and one hex
+ digit(s).
+
+Use this identifier for further rawdev function calls.
+
+Selftest rawdev API can be used to verify the mailbox communication between
+PF and VF devices based applications. There can be multiple VFs for a particular PF.
+Each VF can send mailboxes to PF and PF can broadcast message to all VFs.
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
index 3a3971ecd3..54c58a8552 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c
@@ -155,7 +155,7 @@ rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id)
}
static const struct rte_rawdev_ops rvu_lf_rawdev_ops = {
- .dev_selftest = NULL,
+ .dev_selftest = rvu_lf_rawdev_selftest,
};
static void
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
index 65cc1bb64d..e64643dcee 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h
@@ -21,4 +21,6 @@ extern int cnxk_logtype_rvu_lf;
#define CNXK_RVU_LF_LOG(level, ...) \
RTE_LOG_LINE_PREFIX(level, CNXK_RVU_LF, "%s(): ", __func__, __VA_ARGS__)
+int rvu_lf_rawdev_selftest(uint16_t dev_id);
+
#endif /* _CNXK_RVU_LF_H_ */
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
new file mode 100644
index 0000000000..e33973f24b
--- /dev/null
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c
@@ -0,0 +1,166 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include <stdlib.h>
+#include <inttypes.h>
+
+#include <rte_common.h>
+#include <rte_hexdump.h>
+#include <rte_eal.h>
+#include <rte_lcore.h>
+
+#include <rte_rawdev.h>
+#include <rte_cycles.h>
+
+#include "cnxk_rvu_lf.h"
+#include "cnxk_rvu_lf_driver.h"
+
+#define PF 0
+#define VF 0
+#define RSP_LEN 64
+#define REQ_LEN 64
+#define MSG_ID_FROM 0x3000
+#define MSG_ID_TO 0x4000
+#define MAX_BAR 6
+
+static int
+msg_process_notify_cb(uint16_t vf, uint16_t msg_id,
+ void *req, uint16_t req_len, void **rsp, uint16_t *rsp_len)
+{
+ uint8_t *resp;
+ int i;
+
+ printf("\nReceived message(0x%x) from VF0x%x\n", msg_id, vf);
+ rte_hexdump(stdout, "req_data received", req, req_len);
+
+ resp = malloc(RSP_LEN);
+ if (resp == NULL)
+ return -ENOMEM;
+ for (i = 0; i < RSP_LEN; i++)
+ resp[i] = 0xB0;
+ *rsp = resp;
+ *rsp_len = RSP_LEN;
+ rte_hexdump(stdout, "rsp_data_filled", *rsp, RSP_LEN);
+
+ return 0;
+}
+
+int
+rvu_lf_rawdev_selftest(uint16_t dev_id)
+{
+ char *dev_name = rte_rawdevs[dev_id].name;
+ uint8_t req[REQ_LEN] = {0};
+ uint8_t rsp[RSP_LEN] = {0};
+ size_t bar_mask = 0;
+ size_t bar_va = 0;
+ unsigned int i, j;
+ uint16_t pf_func;
+ char *token[2];
+ int func, ret;
+
+ token[0] = strtok_r(dev_name, ".", &dev_name);
+ token[1] = strtok_r(dev_name, ".", &dev_name);
+ func = atoi(token[1]);
+
+ ret = rte_rawdev_start(dev_id);
+ if (ret)
+ return ret;
+
+ pf_func = rte_pmd_rvu_lf_npa_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "NPA pf_func is invalid");
+
+ pf_func = rte_pmd_rvu_lf_sso_pf_func_get();
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "SSO pf_func is invalid");
+
+ pf_func = rte_pmd_rvu_lf_pf_func_get(dev_id);
+ if (pf_func == 0)
+ CNXK_RVU_LF_LOG(WARNING, "RVU-LF pf_func is invalid");
+
+ for (i = 0; i < MAX_BAR; i++) {
+ if (!rte_pmd_rvu_lf_bar_get(dev_id, i, &bar_va, &bar_mask))
+ printf("\n BAR[%d]: addr: 0x%" PRIx64 ", mask: 0x%" PRIx64 "\n",
+ i, bar_va, bar_mask);
+ }
+
+ ret = rte_pmd_rvu_lf_msg_id_range_set(dev_id, MSG_ID_FROM, MSG_ID_TO);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message ID range invalid");
+ goto out;
+ }
+
+ ret = rte_pmd_rvu_lf_msg_handler_register(dev_id, msg_process_notify_cb);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "RVU message handler register failed, ret: %d", ret);
+ goto out;
+ }
+
+ if (func == 0) {
+ j = 50;
+ printf("\n");
+ while (j--) {
+ /* PF will wait for RVU message callbacks to be called */
+ rte_delay_ms(1000);
+ printf("PF waiting for VF messages for %d sec.\r", j);
+ }
+ /* PF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xC0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO.
+ * Messages sent with this id will be serviced by VF..
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ VF /* Send to VF0 */,
+ MSG_ID_FROM + 0x2,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf PF->VF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU PF->VF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("PF waiting for VF to exit for %d sec.\r", j);
+ }
+
+ } else {
+ /* VF will send the messages and receive responses. */
+ for (i = 0; i < REQ_LEN; i++)
+ req[i] = 0xA0;
+ /*
+ * Range is set as between MSG_ID_FROM and MSG_ID_TO
+ * Messages sent with this id will be serviced by PF and will
+ * not be forwarded to AF.
+ */
+ ret = rte_pmd_rvu_lf_msg_process(dev_id,
+ PF /* Send to PF */,
+ MSG_ID_FROM + 0x1,
+ req, REQ_LEN, rsp, RSP_LEN);
+ if (ret) {
+ CNXK_RVU_LF_LOG(ERR, "rvu lf VF->PF message send failed");
+ goto unregister;
+ }
+ CNXK_RVU_LF_LOG(INFO, "RVU VF->PF message processed");
+ rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN);
+ j = 50;
+ printf("\n");
+ while (j--) {
+ rte_delay_ms(1000);
+ printf("VF waiting for PF to send msg for %d sec.\r", j);
+ }
+ }
+unregister:
+ rte_pmd_rvu_lf_msg_handler_unregister(dev_id);
+out:
+ rte_rawdev_stop(dev_id);
+
+ return ret;
+}
+
+
diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build
index 7ea1c3916c..c960989bb7 100644
--- a/drivers/raw/cnxk_rvu_lf/meson.build
+++ b/drivers/raw/cnxk_rvu_lf/meson.build
@@ -5,6 +5,7 @@
deps += ['bus_pci', 'common_cnxk', 'rawdev']
sources = files(
'cnxk_rvu_lf.c',
+ 'cnxk_rvu_lf_selftest.c',
)
driver_sdk_headers += files('cnxk_rvu_lf_driver.h')
require_iova_in_mbuf = false
--
2.25.1
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v6 2/9] raw/cnxk_rvu_lf: support NPA/SSO pffunc get
2024-10-28 11:01 ` [PATCH v6 2/9] raw/cnxk_rvu_lf: support NPA/SSO pffunc get Akhil Goyal
@ 2024-10-29 16:10 ` Jerin Jacob
2024-11-04 11:27 ` Jerin Jacob
0 siblings, 1 reply; 96+ messages in thread
From: Jerin Jacob @ 2024-10-29 16:10 UTC (permalink / raw)
To: Akhil Goyal
Cc: dev, thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
stephen, sachin.saxena, ferruh.yigit
On Mon, Oct 28, 2024 at 4:40 PM Akhil Goyal <gakhil@marvell.com> wrote:
>
> Added rte_pmd_rvu_lf_npa_pf_func_get and
> rte_pmd_rvu_lf_sso_pf_func_get APIs to get NPA and
> SSO pffunc for the application/external driver use.
>
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> +driver_sdk_headers += files('cnxk_rvu_lf_driver.h')
+ @techboard@dpdk.org
Now that, _all_ the functions of this driver are exposed ONLY to out
of tree drives, I don't think, there are any more concerns. Please let
me know if someone thinks the other way around.
I will merge this version with the following diff[1]
[1]
[for-main]dell[dpdk-next-net-mrvl] $ git diff
diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst
b/doc/guides/rawdevs/cnxk_rvu_lf.rst
index 1ac7d6b84b..8f9c37a1cc 100644
--- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
+++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
@@ -27,7 +27,7 @@ The RVU LF device implements following features in
the rawdev API:
Limitations
-----------
-In multiprocess mode user-space application must ensure
+In multi-process mode user-space application must ensure
no resources sharing takes place.
Otherwise, user-space application should ensure synchronization.
diff --git a/doc/guides/rel_notes/release_24_11.rst
b/doc/guides/rel_notes/release_24_11.rst
index bf386a0f4a..2ebf4bbb39 100644
--- a/doc/guides/rel_notes/release_24_11.rst
+++ b/doc/guides/rel_notes/release_24_11.rst
@@ -254,7 +254,8 @@ New Features
* **Added Marvell cnxk RVU LF rawdev driver.**
Added a new raw device driver for Marvell cnxk based devices to allow
- applications to communicate using mailboxes and notify for the interrupts.
+ out of tree driver to manage RVU LF device. It enables operations such as
+ sending/receiving mailbox, register and notify the interrupts etc.
Removed Items
diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
index e405831ce1..28410a74cd 100644
--- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
+++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
@@ -11,8 +11,8 @@
* Marvell RVU LF raw PMD specific structures and interface
*
* This API allows out of tree driver to manage RVU LF device
- * in user space along with installing interrupt handlers for
- * low latency signal processing.
+ * It enables operations such as sending/receiving mailbox,
+ * register and notify the interrupts etc
*/
^ permalink raw reply [flat|nested] 96+ messages in thread
* Re: [PATCH v6 2/9] raw/cnxk_rvu_lf: support NPA/SSO pffunc get
2024-10-29 16:10 ` Jerin Jacob
@ 2024-11-04 11:27 ` Jerin Jacob
0 siblings, 0 replies; 96+ messages in thread
From: Jerin Jacob @ 2024-11-04 11:27 UTC (permalink / raw)
To: Akhil Goyal
Cc: dev, thomas, david.marchand, hemant.agrawal, jerinj, hkalra,
stephen, sachin.saxena, ferruh.yigit
On Tue, Oct 29, 2024 at 9:40 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
>
> On Mon, Oct 28, 2024 at 4:40 PM Akhil Goyal <gakhil@marvell.com> wrote:
> >
> > Added rte_pmd_rvu_lf_npa_pf_func_get and
> > rte_pmd_rvu_lf_sso_pf_func_get APIs to get NPA and
> > SSO pffunc for the application/external driver use.
> >
> > Signed-off-by: Akhil Goyal <gakhil@marvell.com>
>
> > +driver_sdk_headers += files('cnxk_rvu_lf_driver.h')
>
> + @techboard@dpdk.org
>
> Now that, _all_ the functions of this driver are exposed ONLY to out
> of tree drives, I don't think, there are any more concerns. Please let
> me know if someone thinks the other way around.
> I will merge this version with the following diff[1]
Series applied to dpdk-next-net-mrvl/for-main with following diff. Thanks
>
>
>
>
>
> [1]
> [for-main]dell[dpdk-next-net-mrvl] $ git diff
> diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst
> b/doc/guides/rawdevs/cnxk_rvu_lf.rst
> index 1ac7d6b84b..8f9c37a1cc 100644
> --- a/doc/guides/rawdevs/cnxk_rvu_lf.rst
> +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst
> @@ -27,7 +27,7 @@ The RVU LF device implements following features in
> the rawdev API:
> Limitations
> -----------
>
> -In multiprocess mode user-space application must ensure
> +In multi-process mode user-space application must ensure
> no resources sharing takes place.
> Otherwise, user-space application should ensure synchronization.
>
> diff --git a/doc/guides/rel_notes/release_24_11.rst
> b/doc/guides/rel_notes/release_24_11.rst
> index bf386a0f4a..2ebf4bbb39 100644
> --- a/doc/guides/rel_notes/release_24_11.rst
> +++ b/doc/guides/rel_notes/release_24_11.rst
> @@ -254,7 +254,8 @@ New Features
> * **Added Marvell cnxk RVU LF rawdev driver.**
>
> Added a new raw device driver for Marvell cnxk based devices to allow
> - applications to communicate using mailboxes and notify for the interrupts.
> + out of tree driver to manage RVU LF device. It enables operations such as
> + sending/receiving mailbox, register and notify the interrupts etc.
>
>
> Removed Items
> diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
> b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
> index e405831ce1..28410a74cd 100644
> --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
> +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h
> @@ -11,8 +11,8 @@
> * Marvell RVU LF raw PMD specific structures and interface
> *
> * This API allows out of tree driver to manage RVU LF device
> - * in user space along with installing interrupt handlers for
> - * low latency signal processing.
> + * It enables operations such as sending/receiving mailbox,
> + * register and notify the interrupts etc
> */
^ permalink raw reply [flat|nested] 96+ messages in thread
end of thread, other threads:[~2024-11-04 11:28 UTC | newest]
Thread overview: 96+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-07 19:33 [PATCH 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-09-07 19:33 ` [PATCH 1/9] rawdev: add API to get device from index Akhil Goyal
2024-09-23 15:23 ` Jerin Jacob
2024-10-08 7:40 ` [PATCH v2] " Akhil Goyal
2024-10-08 11:59 ` David Marchand
2024-10-08 12:00 ` [EXTERNAL] " Akhil Goyal
2024-10-09 21:13 ` Akhil Goyal
2024-10-21 10:48 ` Akhil Goyal
2024-10-09 6:11 ` Hemant Agrawal
2024-10-22 19:12 ` David Marchand
2024-09-07 19:33 ` [PATCH 2/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-09-23 15:28 ` Jerin Jacob
2024-10-08 10:54 ` [PATCH v2 0/9] " Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 1/9] " Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 4/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 5/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 6/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 7/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 8/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
2024-10-08 10:54 ` [PATCH v2 9/9] raw/cnxk_rvu_lf: add PMD API to get device pffunc Akhil Goyal
2024-10-08 11:52 ` [PATCH v2 0/9] drivers/raw: introduce cnxk rvu lf device driver David Marchand
2024-10-08 12:10 ` [EXTERNAL] " Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 " Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 1/9] " Akhil Goyal
2024-10-08 20:44 ` Stephen Hemminger
2024-10-09 18:09 ` Stephen Hemminger
2024-10-09 18:14 ` [EXTERNAL] " Akhil Goyal
2024-10-23 14:01 ` David Marchand
2024-10-08 18:49 ` [PATCH v3 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
2024-10-23 14:13 ` David Marchand
2024-10-08 18:49 ` [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
2024-10-21 21:30 ` Thomas Monjalon
2024-10-22 2:46 ` Jerin Jacob
2024-10-22 6:05 ` [EXTERNAL] " Akhil Goyal
2024-10-22 9:27 ` Thomas Monjalon
2024-10-22 10:08 ` David Marchand
2024-10-22 12:06 ` Akhil Goyal
2024-10-23 16:00 ` Thomas Monjalon
2024-10-23 19:14 ` Akhil Goyal
2024-10-23 19:29 ` Thomas Monjalon
2024-10-24 13:03 ` Akhil Goyal
2024-10-22 15:30 ` Stephen Hemminger
2024-10-22 17:06 ` Jerin Jacob
2024-10-08 18:49 ` [PATCH v3 4/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 5/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 6/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 7/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
2024-10-08 18:49 ` [PATCH v3 8/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
2024-10-23 14:16 ` David Marchand
2024-10-08 18:49 ` [PATCH v3 9/9] raw/cnxk_rvu_lf: add PMD API to get device pffunc Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 1/9] " Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 3/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 4/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 5/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 6/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 7/9] raw/cnxk_rvu_lf: add API to get device pffunc Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 8/9] raw/cnxk_rvu_lf: add API to get BAR addresses Akhil Goyal
2024-10-24 13:01 ` [PATCH v4 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 1/9] " Akhil Goyal
2024-10-24 15:59 ` Jerin Jacob
2024-10-24 13:17 ` [PATCH v5 2/9] raw/cnxk_rvu_lf: add API to get NPA/SSO pffunc Akhil Goyal
2024-10-25 6:52 ` Jerin Jacob
2024-10-25 15:38 ` Stephen Hemminger
2024-10-25 19:48 ` [EXTERNAL] " Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 3/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 4/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 5/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 6/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 7/9] raw/cnxk_rvu_lf: add API to get device pffunc Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 8/9] raw/cnxk_rvu_lf: add API to get BAR addresses Akhil Goyal
2024-10-24 13:17 ` [PATCH v5 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
2024-10-24 16:26 ` Stephen Hemminger
2024-10-28 11:01 ` [PATCH v6 0/9] drivers/raw: introduce cnxk rvu lf device driver Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 1/9] drivers/raw: introduce cnxk RVU LF " Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 2/9] raw/cnxk_rvu_lf: support NPA/SSO pffunc get Akhil Goyal
2024-10-29 16:10 ` Jerin Jacob
2024-11-04 11:27 ` Jerin Jacob
2024-10-28 11:01 ` [PATCH v6 3/9] raw/cnxk_rvu_lf: support interrupt callback registration Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 4/9] raw/cnxk_rvu_lf: support msg handler registration Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 5/9] raw/cnxk_rvu_lf: support to set message ID range Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 6/9] raw/cnxk_rvu_lf: support mailbox processing Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 7/9] raw/cnxk_rvu_lf: support device pffunc get Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 8/9] raw/cnxk_rvu_lf: support getting BAR addresses Akhil Goyal
2024-10-28 11:01 ` [PATCH v6 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
2024-09-07 19:33 ` [PATCH 3/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Akhil Goyal
2024-09-07 19:33 ` [PATCH 4/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Akhil Goyal
2024-09-07 19:33 ` [PATCH 5/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Akhil Goyal
2024-09-07 19:33 ` [PATCH 6/9] raw/cnxk_rvu_lf: register/unregister msg handler Akhil Goyal
2024-09-07 19:33 ` [PATCH 7/9] raw/cnxk_rvu_lf: set message ID range Akhil Goyal
2024-09-07 19:33 ` [PATCH 8/9] raw/cnxk_rvu_lf: process mailbox message Akhil Goyal
2024-09-07 19:33 ` [PATCH 9/9] raw/cnxk_rvu_lf: add selftest Akhil Goyal
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).