Skip to contentSkip to conversation

dma/cnxk: add CN20K (O20) DPI DMA and inter-process domain support

PATCH Superseded Vamsi Krishna 2 participants 11 messages Aug 29 – Oct 16 dmaengine

lore
Share & tools
lore
#0 lore raw

cover dma/cnxk: add CN20K (O20) DPI DMA and inter-process domain support

From: Vamsi Attunuru <[email protected]>

This series adds DMA support for Marvell CN20K (O20) DPI hardware to the existing cnxk dmadev driver, building on the common ROC DPI layer used by CN9K/CN10K.

CN20K DPI is LF and ring-based: commands are posted to per-LF hardware queues rather than the legacy VF chunk-buffer model. The series introduces the ROC infrastructure for LF attach/detach, ring configuration, channel table management, and access-pair group mailbox operations, then wires the dmadev PMD to expose copy, copy-SG, fill, and enqueue/dequeue on O20.

Patch 1 lays the common foundation. Patch 2 integrates O20 into the dmadev fast and slow paths. Patch 3 adds inter-process domain DMA on top of the O20 path using the dmadev access-pair group API.

Vamsi Attunuru (3):
common/cnxk: add O20 DPI DMA support dma/cnxk: add O20 DPI DMA support dma/cnxk: enable inter process domain DMA support

 drivers/common/cnxk/hw/dpi.h                  |  72 +-
 drivers/common/cnxk/hw/rvu.h                  |   2 +
 drivers/common/cnxk/roc_constants.h           |   2 +
 drivers/common/cnxk/roc_dev.c                 |   1 +
 drivers/common/cnxk/roc_dpi.c                 | 683 +++++++++++++++++-
 drivers/common/cnxk/roc_dpi.h                 |  85 +++
 drivers/common/cnxk/roc_dpi_priv.h            |  34 +
 drivers/common/cnxk/roc_mbox.h                | 174 ++++-
 drivers/common/cnxk/roc_platform.h            |   8 +
 .../common/cnxk/roc_platform_base_symbols.c   |  18 +
 drivers/dma/cnxk/cnxk_dmadev.c                | 673 ++++++++++++++++-
 drivers/dma/cnxk/cnxk_dmadev.h                |  73 +-
 drivers/dma/cnxk/cnxk_dmadev_fp.c             | 214 ++++++
 13 files changed, 2003 insertions(+), 36 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/3 common/cnxk: add O20 DPI DMA support

From: Vamsi Attunuru <[email protected]>

Adds ROC support for O20 DPI DMA hardware.

---
 drivers/common/cnxk/hw/dpi.h                  |  72 +-
 drivers/common/cnxk/hw/rvu.h                  |   2 +
 drivers/common/cnxk/roc_constants.h           |   2 +
 drivers/common/cnxk/roc_dev.c                 |   1 +
 drivers/common/cnxk/roc_dpi.c                 | 683 +++++++++++++++++-
 drivers/common/cnxk/roc_dpi.h                 |  85 +++
 drivers/common/cnxk/roc_dpi_priv.h            |  34 +
 drivers/common/cnxk/roc_mbox.h                | 174 ++++-
 drivers/common/cnxk/roc_platform.h            |   8 +
 .../common/cnxk/roc_platform_base_symbols.c   |  18 +
 10 files changed, 1065 insertions(+), 14 deletions(-)
drivers/common/cnxk/hw/dpi.h +70 -2
index a34713dde6..8d5a5bd0e1 100644
@@ -23,6 +23,27 @@
 #define DPI_VF_INT_ENA_W1C (0x110)
 #define DPI_VF_INT_ENA_W1S (0x118)
 
+/* DPI CN20K LF register offsets from VF_BAR2 */
+#define DPI_LF_CTL		    (0ull)
+#define DPI_LF_RINGX_CFG(x)	    ((0x20ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_BASE(x)	    ((0x30ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_RIDX(x)	    ((0x40ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_WIDX(x)	    ((0x50ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_RST(x)	    ((0x70ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_ISTAT(x)	    ((0x80ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_CMPL(x)	    ((0x90ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_INT	    (0x100ull)
+#define DPI_LF_RINGX_INT_W1S	    (0x108ull)
+#define DPI_LF_RINGX_INT_ENA_W1C    (0x110ull)
+#define DPI_LF_RINGX_INT_ENA_W1S    (0x118ull)
+#define DPI_LF_RINGX_ERR_STAT(x)    ((0x120ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_ERR	    (0x200ull)
+#define DPI_LF_RINGX_ERR_W1S	    (0x208ull)
+#define DPI_LF_RINGX_ERR_ENA_W1C    (0x210ull)
+#define DPI_LF_RINGX_ERR_ENA_W1S    (0x218ull)
+#define DPI_LF_RINGX_DMA_CNT(x)	    ((0x220ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_DMA_BCNT(x)    ((0x230ull | (uint64_t)(x) << 3))
+
 /**
  * Enumeration dpi_hdr_xtype_e
  *
@@ -54,6 +75,26 @@
 #define DPI_MIN_CMD_SIZE 8
 #define DPI_MAX_CMD_SIZE 64
 
+#define DPI_CMD_SIZE_64B  64
+#define DPI_CMD_SIZE_128B 128
+
+#define DPI_CMD_VLD_BIT BIT_ULL(63)
+
+#define DPI_LF_QCFG_QEN	  BIT_ULL(63)
+#define DPI_LF_QCFG_ISIZE BIT(11)
+#define DPI_LF_QUEUE_RST  BIT(0)
+
+#define DPI_LF_QIDX_WRAP_MASK 0x8000
+#define DPI_LF_QSIZE_MASK     0xFF
+#define DPI_LF_QIDX_MASK      0xFFF
+#define DPI_LF_QSIZE_SHIFT    56
+
+#define DPI_Q_RIDX(x) ((x)&0xFFF)
+#define DPI_Q_WIDX(x) ((x)&0xFFF)
+
+#define DPI_Q_RIDX_WRAP(x) (((x) >> 15) & 0x1)
+#define DPI_Q_WIDX_WRAP(x) (((x) >> 15) & 0x1)
+
 /**
  * Structure dpi_instr_hdr_s for CN9K
  *
@@ -61,7 +102,7 @@
  */
 union dpi_instr_hdr_s {
 	uint64_t u[4];
-	struct dpi_cn9k_instr_hdr_s_s {
+	struct dpi_cn9k_instr_hdr_s {
 		uint64_t tag : 32;
 		uint64_t tt : 2;
 		uint64_t grp : 10;
@@ -95,7 +136,7 @@ union dpi_instr_hdr_s {
 		/* Word 3 - End */
 	} cn9k;
 
-	struct dpi_cn10k_instr_hdr_s_s {
+	struct dpi_cn10k_instr_hdr_s {
 		uint64_t nfst : 4;
 		uint64_t reserved_4_5 : 2;
 		uint64_t nlst : 4;
@@ -128,6 +169,33 @@ union dpi_instr_hdr_s {
 		uint64_t reserved_192_255 : 64;
 		/* Word 3 - End */
 	} cn10k;
+
+	struct dpi_cn20k_instr_hdr_s {
+		uint64_t nfst : 3;
+		uint64_t reserved_3 : 1;
+		uint64_t nlst : 3;
+		uint64_t reserved_7 : 1;
+		uint64_t msix_int : 1;
+		uint64_t ct : 3;
+		uint64_t chan : 14;
+		uint64_t reserved_26_29 : 4;
+		uint64_t aura : 20;
+		uint64_t xt : 2;
+		uint64_t ivec : 9;
+		uint64_t fe : 1;
+		uint64_t reserved_62 : 1;
+		uint64_t vld : 1;
+		/* Word 0 - End */
+		uint64_t ptr : 64;
+		/* Word 1 - End */
+		uint64_t tag : 32;
+		uint64_t tt : 2;
+		uint64_t grp : 10;
+		uint64_t reserved_107_127 : 20;
+		/* Word 2 - End */
+		uint64_t reserved_128_191 : 64;
+		/* Word 3 - End */
+	} cn20k;
 };
 
 #endif /*__DEV_DPI_HW_H__*/
drivers/common/cnxk/hw/rvu.h +2 -0
index 6f02d1e3d2..01f19b0a16 100644
@@ -169,6 +169,8 @@
 #define RVU_BLOCK_ADDR_R_START (0x14ull)
 #define RVU_BLOCK_ADDR_REE0    (0x14ull)
 #define RVU_BLOCK_ADDR_REE1    (0x15ull)
+#define RVU_BLOCK_ADDR_DPI0    (0x18ULL)
+#define RVU_BLOCK_ADDR_DPI1    (0x19ULL)
 #define RVU_BLOCK_ADDR_MBOX    (0x1bULL)
 
 #define RVU_VF_INT_VEC_MBOX (0x0ull)
drivers/common/cnxk/roc_constants.h +2 -0
index 795869c9df..3218e641f0 100644
@@ -47,6 +47,8 @@
 #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_CN20K_DPI_PF        0xA0E8
+#define PCI_DEVID_CN20K_DPI_VF        0xA0E9
 
 #define PCI_DEVID_CN9K_CGX  0xA059
 #define PCI_DEVID_CN10K_RPM 0xA060
drivers/common/cnxk/roc_dev.c +1 -0
index 61aa4b3075..e2b717a214 100644
@@ -1401,6 +1401,7 @@ dev_vf_hwcap_update(struct plt_pci_device *pci_dev, struct dev *dev)
 	case PCI_DEVID_CNXK_RVU_NIX_INL_VF:
 	case PCI_DEVID_CNXK_RVU_BPHY_VF:
 	case PCI_DEVID_CNXK_RVU_ESWITCH_VF:
+	case PCI_DEVID_CN20K_DPI_VF:
 		dev->hwcap |= DEV_HWCAP_F_VF;
 		break;
 	}
drivers/common/cnxk/roc_dpi.c +674 -9

729 lines not on this page · raw message

drivers/common/cnxk/roc_dpi.h +85 -0

106 lines not on this page · raw message

drivers/common/cnxk/roc_dpi_priv.h +34 -0
index 05b6751ca6..3051abc979 100644
@@ -18,6 +18,7 @@
 #define DPI_QUEUE_OPEN_V2 0x5
 
 #define DPI_QUEUE_IDLE_TMO_MS 1E3
+#define DPI_LF_RESET_TMO_US   10000
 
 typedef union dpi_mbox_msg_t {
 	uint64_t u[2];
@@ -43,4 +44,37 @@ typedef union dpi_mbox_msg_t {
 	} s;
 } dpi_mbox_msg_t;
 
+struct dpi {
+	struct plt_pci_device *pci_dev;
+	struct dev dev;
+	uint16_t lf_msix_off[ROC_DPI_MAX_LFS];
+	uint8_t lf_blkaddr[ROC_DPI_MAX_LFS];
+};
+
+static inline struct dpi *
+roc_dpi_to_dpi_priv(struct roc_dpi *roc_dpi)
+{
+	return (struct dpi *)&roc_dpi->reserved[0];
+}
+
+static inline struct roc_dpi *
+dpi_priv_to_roc_dpi(struct dpi *dpi)
+{
+	return (struct roc_dpi *)((char *)dpi - offsetof(struct roc_dpi, reserved));
+}
+
+int dpi_lf_reset(struct roc_dpi_lf *lf);
+void dpi_lf_ena_dis(struct roc_dpi_lf *lf, uint8_t enb);
+int dpi_lfs_attach(struct dev *dev, uint8_t blkaddr, bool modify, uint16_t nb_lf);
+int dpi_lfs_detach(struct dev *dev);
+int dpi_lf_attach(struct dev *dev, uint8_t blkaddr, bool modify, uint16_t nb_lf);
+int dpi_lf_detach(struct dev *dev);
+int dpi_lf_init(struct roc_dpi_lf *lf, struct dev *dev, uint8_t slot);
+int dpi_chan_tbl_alloc(struct dev *dev, uint8_t blk_addr, uint16_t tbl_sz);
+int dpi_chan_tbl_free(struct dev *dev, uint8_t blk_addr, uint16_t tbl_num);
+int dpi_chan_tbl_ena_dis(struct dev *dev, uint32_t dpi_blkaddr, uint16_t lfid, uint16_t chan_tbl,
+			 bool enable);
+int dpi_chan_tbl_update(struct dev *dev, uint8_t blk_addr, uint16_t chan_tbl, uint64_t *tbl,
+			uint16_t off, uint16_t nb_entries);
+
 #endif
drivers/common/cnxk/roc_mbox.h +171 -3

196 lines not on this page · raw message

drivers/common/cnxk/roc_platform.h +8 -0
index ac4f76473f..082397ed4e 100644
@@ -347,6 +347,14 @@ extern int cnxk_logtype_esw;
 	RTE_LOG_DP_LINE_PREFIX(DEBUG, CNXK, "%s():%u ", __func__ RTE_LOG_COMMA __LINE__, \
 		__VA_ARGS__)
 
+/* append dbdf to name */
+#define plt_pci_dev_name(devname, name, dev)                                                       \
+	({                                                                                         \
+		snprintf((devname), sizeof(devname), "%s" PCI_PRI_FMT, (name), (dev)->addr.domain, \
+			 (dev)->addr.bus, (dev)->addr.devid, (dev)->addr.function);                \
+		devname;                                                                           \
+	})
+
 #ifdef __cplusplus
 #define CNXK_PCI_ID(subsystem_dev, dev)                                        \
 {                                                                      \
drivers/common/cnxk/roc_platform_base_symbols.c +18 -0
index 063cb21aae..232129d903 100644
@@ -70,6 +70,24 @@ RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_configure)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_configure_v2)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_dev_init)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_dev_fini)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_ring_init)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_ring_fini)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_pffunc_cfg)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_ring_chan_cfg)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_chan_tbl_select)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_chan_tbl_ena_dis)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_chan_tbl_update)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_access_pair_group_create)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_access_pair_group_destroy)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_access_pair_group_join)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_access_pair_group_leave)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_access_pair_group_handler_get)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_reset)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_rsrc_init)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_rsrc_fini)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_chan_tbl_alloc)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_chan_tbl_free)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_chan_tbl_update)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_eswitch_npc_mcam_tx_rule)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_eswitch_npc_mcam_delete_rule)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_eswitch_npc_mcam_rx_rule)
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/3 dma/cnxk: add O20 DPI DMA support

In reply to Vamsi Krishna

From: Vamsi Attunuru <[email protected]>

Adds DMA driver support for O20 hardware.

---
 drivers/dma/cnxk/cnxk_dmadev.c    | 527 +++++++++++++++++++++++++++++-
 drivers/dma/cnxk/cnxk_dmadev.h    |  72 +++-
 drivers/dma/cnxk/cnxk_dmadev_fp.c | 214 ++++++++++++
 3 files changed, 791 insertions(+), 22 deletions(-)
drivers/dma/cnxk/cnxk_dmadev.c +509 -18
index 6ae7fdca3b..3970abe1c3 100644
@@ -2,6 +2,9 @@
  * Copyright (C) 2021 Marvell International Ltd.
  */
 
+#include <errno.h>
+#include <stdlib.h>
+
 #include <rte_event_dma_adapter.h>
 
 #include <cnxk_dmadev.h>
@@ -9,6 +12,68 @@
 static int cnxk_stats_reset(struct rte_dma_dev *dev, uint16_t vchan);
 static void cnxk_set_fp_ops(struct rte_dma_dev *dev, uint8_t enable_enq_deq);
 
+static int
+parse_val_u16(const char *key, const char *value, void *extra_args)
+{
+	unsigned long val;
+	char *end;
+
+	RTE_SET_USED(key);
+
+	if (value == NULL || extra_args == NULL)
+		return -EINVAL;
+
+	errno = 0;
+	val = strtoul(value, &end, 0);
+	if (errno != 0 || end == value || *end != '\0' || val > UINT16_MAX)
+		return -EINVAL;
+
+	*(uint16_t *)extra_args = (uint16_t)val;
+
+	return 0;
+}
+
+static int
+cn20k_dmadev_parse_devargs(struct rte_devargs *devargs, struct cnxk_dpi_vf_s *dpivf)
+{
+	uint16_t num_vchans = CN20K_DPI_DEF_VCHANS;
+	uint16_t num_lfs = num_vchans >> 1; /* Each LF has 2 rings */
+	struct rte_kvargs *kvlist = NULL;
+
+	if (devargs == NULL) {
+		dpivf->max_vchans = num_vchans;
+		dpivf->max_lfs = num_lfs;
+		return 0;
+	}
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		goto exit;
+
+	if (rte_kvargs_process(kvlist, CN20K_DPI_NUM_VCHANS, &parse_val_u16, &num_vchans) < 0)
+		goto exit;
+	if (rte_kvargs_process(kvlist, CN20K_DPI_NUM_LFS, &parse_val_u16, &num_lfs) < 0)
+		goto exit;
+
+	if (!num_vchans || !num_lfs || num_vchans > CN20K_DPI_MAX_VCHANS ||
+	    num_lfs > CN20K_DPI_MAX_LFS)
+		goto exit;
+
+	if (!rte_is_power_of_2(num_vchans) || !rte_is_power_of_2(num_lfs)) {
+		plt_err("num_vchans or num_lfs is not a power of 2");
+		goto exit;
+	}
+
+	dpivf->max_vchans = num_vchans;
+	dpivf->max_lfs = num_lfs;
+
+	rte_kvargs_free(kvlist);
+	return 0;
+exit:
+	rte_kvargs_free(kvlist);
+	return -EINVAL;
+}
+
 static int
 cnxk_dmadev_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *dev_info, uint32_t size)
 {
@@ -25,9 +90,21 @@ cnxk_dmadev_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *dev_inf
 		dev_info->dev_capa |= RTE_DMA_CAPA_PRI_POLICY_SP;
 		dev_info->nb_priorities = CN10K_DPI_MAX_PRI;
 	}
-	dev_info->max_desc = CNXK_DPI_MAX_DESC;
-	dev_info->min_desc = CNXK_DPI_MIN_DESC;
-	dev_info->max_sges = CNXK_DPI_MAX_POINTER;
+
+	if (roc_model_is_cn20k()) {
+		const uint16_t vpr = dpivf->vchans_per_ring ? dpivf->vchans_per_ring : 1;
+
+		dev_info->max_desc = CN20K_DPI_MAX_DESC / vpr;
+		dev_info->min_desc = CN20K_DPI_MIN_DESC;
+		dev_info->max_sges = CN20K_DPI_MAX_POINTER;
+		dev_info->max_vchans = dpivf->max_vchans;
+		dev_info->dev_capa |= RTE_DMA_CAPA_OPS_FILL;
+	} else {
+		dev_info->max_desc = CNXK_DPI_MAX_DESC;
+		dev_info->min_desc = CNXK_DPI_MIN_DESC;
+		dev_info->max_sges = CNXK_DPI_MAX_POINTER;
+		dev_info->max_vchans = CNXK_DPI_MAX_VCHANS_PER_QUEUE;
+	}
 
 	return 0;
 }
@@ -52,8 +129,10 @@ cnxk_dmadev_vchan_free(struct cnxk_dpi_vf_s *dpivf, uint16_t vchan)
 
 	for (; i < num_vchans; i++) {
 		dpi_conf = &dpivf->conf[i];
-		rte_free(dpi_conf->c_desc.compl_ptr);
-		dpi_conf->c_desc.compl_ptr = NULL;
+		if (dpi_conf->c_desc.compl_ptr) {
+			rte_free(dpi_conf->c_desc.compl_ptr);
+			dpi_conf->c_desc.compl_ptr = NULL;
+		}
 	}
 
 	return 0;
@@ -99,10 +178,42 @@ cnxk_dmadev_chunk_pool_create(struct rte_dma_dev *dev, uint32_t nb_chunks, uint3
 	return rc;
 }
 
+static int
+cnxk_dmadev_vchan_rsrc_free(struct cnxk_dpi_vf_s *dpivf)
+{
+	struct roc_dpi *rdpi = &dpivf->rdpi;
+	int rc;
+
+	if (dpivf->ring_conf) {
+		rte_free(dpivf->ring_conf);
+		dpivf->ring_conf = NULL;
+	}
+
+	if (rdpi->lfs == NULL)
+		return 0;
+
+	rc = roc_dpi_lf_chan_tbl_free(&(rdpi->lfs[0]));
+	if (rc < 0) {
+		plt_err("Failed to free dpi lf channel table");
+		goto error;
+	}
+
+	rc = roc_dpi_rsrc_fini(rdpi);
+	if (rc < 0)
+		plt_err("Failed to free dpi lfs");
+
+	dpivf->is_ring_conf_done = false;
+error:
+	return rc;
+}
+
 static int
 cnxk_dmadev_configure(struct rte_dma_dev *dev, const struct rte_dma_conf *conf, uint32_t conf_sz)
 {
 	struct cnxk_dpi_vf_s *dpivf = NULL;
+	struct roc_dpi_lf *lf;
+	uint16_t num_rings;
+	int rc = 0;
 
 	RTE_SET_USED(conf_sz);
 	dpivf = dev->fp_obj->dev_private;
@@ -111,13 +222,78 @@ cnxk_dmadev_configure(struct rte_dma_dev *dev, const struct rte_dma_conf *conf,
 	 * Free up vchan memory if any, before configuring num_vchans.
 	 */
 	cnxk_dmadev_vchan_free(dpivf, RTE_DMA_ALL_VCHAN);
+
 	dpivf->num_vchans = conf->nb_vchans;
+	if (roc_model_is_cn20k()) {
+		if (!rte_is_power_of_2(dpivf->num_vchans))
+			dpivf->num_vchans = rte_align32pow2(dpivf->num_vchans);
+
+		if (dpivf->num_vchans > dpivf->max_vchans) {
+			plt_info("Limiting vchans from %u to max_vchans %u",
+				 dpivf->num_vchans, dpivf->max_vchans);
+			dpivf->num_vchans = dpivf->max_vchans;
+		}
+	}
 	if (roc_feature_dpi_has_priority())
 		dpivf->rdpi.priority = conf->priority;
 
 	cnxk_set_fp_ops(dev, conf->flags & RTE_DMA_CFG_FLAG_ENQ_DEQ);
 
-	return 0;
+	if (roc_model_is_cn20k()) {
+		rc = cnxk_dmadev_vchan_rsrc_free(dpivf);
+		if (rc < 0)
+			goto error;
+
+		dpivf->rdpi.nr_lfs = dpivf->max_lfs;
+		num_rings = dpivf->rdpi.nr_lfs << 1;
+
+		if (dpivf->num_vchans > num_rings) {
+			dpivf->vchans_per_ring = dpivf->num_vchans / num_rings;
+		} else {
+			/* Each vchan has got it's own hardware ring */
+			dpivf->vchans_per_ring = 1;
+			dpivf->rdpi.nr_lfs = dpivf->num_vchans >> 1;
+			if (!dpivf->rdpi.nr_lfs)
+				dpivf->rdpi.nr_lfs = 1;
+		}
+
+		if ((CN20K_DPI_MAX_DESC / dpivf->vchans_per_ring) < CN20K_DPI_MIN_DESC) {
+			rc = -EINVAL;
+			plt_err("Very few LFs are requested than required");
+			goto error;
+		}
+
+		num_rings = dpivf->rdpi.nr_lfs << 1;
+		dpivf->ring_conf = rte_zmalloc("dpi_ring_conf", sizeof(struct cn20k_ring_conf) *
+					       num_rings, 0);
+		if (dpivf->ring_conf == NULL) {
+			plt_err("Failed to allocate memory for ring conf");
+			rc = -ENOMEM;
+			goto error;
+		}
+
+		rc = roc_dpi_rsrc_init(&dpivf->rdpi);
+		if (rc < 0) {
+			plt_err("rsrc alloc failed");
+			goto error;
+		}
+
+		lf = &(dpivf->rdpi.lfs[0]);
+		rc = roc_dpi_lf_chan_tbl_alloc(lf, dpivf->num_vchans);
+		if (rc < 0) {
+			plt_err("Failed to allocate chan tbl");
+			goto error;
+		}
+
+		dpivf->chan_tbl = lf->chan_tbl;
+		dpivf->is_ring_conf_done = false;
+	}
+
+error:
+	if (roc_model_is_cn20k() && rc < 0)
+		cnxk_dmadev_vchan_rsrc_free(dpivf);
+
+	return rc;
 }
 
 static int
@@ -232,6 +408,87 @@ cn10k_dmadev_setup_hdr(union cnxk_dpi_instr_cmd *header, const struct rte_dma_vc
 	return 0;
 }
 
+static int
+cn20k_dmadev_setup(struct cnxk_dpi_vf_s *dpivf, uint16_t vchan,
+		    const struct rte_dma_vchan_conf *conf)
+{
+	struct cnxk_dpi_conf *dpi_conf = &dpivf->conf[vchan];
+	struct cn20k_ring_conf *rconf = dpivf->ring_conf;
+	uint16_t ridx, max_desc, num_rings;
+	union cnxk_dpi_instr_cmd *header;
+	int rc = 0;
+	int aura;
+
+	header = (union cnxk_dpi_instr_cmd *)&dpi_conf->cmd.u;
+	header->cn20k.ct = DPI_HDR_PT_ZBW_CA;
+	header->cn20k.xt = 0;
+
+	switch (conf->direction) {
+	case RTE_DMA_DIR_DEV_TO_MEM:
+		dpi_conf->cfg.xtype = DPI_XTYPE_INBOUND;
+		dpi_conf->cfg.rport = conf->src_port.pcie.coreid;
+		dpi_conf->cfg.wport = 0;
+		dpi_conf->chan_cfg.pf_func = conf->src_port.pcie.pfid;
+		dpi_conf->chan_cfg.vf_func = conf->src_port.pcie.vfid;
+		dpi_conf->chan_cfg.valid = 1;
+		break;
+	case RTE_DMA_DIR_MEM_TO_DEV:
+		dpi_conf->cfg.xtype = DPI_XTYPE_OUTBOUND;
+		dpi_conf->cfg.rport = 0;
+		dpi_conf->cfg.wport = conf->dst_port.pcie.coreid;
+		dpi_conf->chan_cfg.pf_func = conf->dst_port.pcie.pfid;
+		dpi_conf->chan_cfg.vf_func = conf->dst_port.pcie.vfid;
+		dpi_conf->chan_cfg.valid = 1;
+		aura = dmadev_src_buf_aura_get(conf->auto_free.m2d.pool, "cn20k_mempool_ops");
+		if (aura < 0)
+			return aura;
+		header->cn20k.aura = aura;
+		break;
+	case RTE_DMA_DIR_MEM_TO_MEM:
+		dpi_conf->cfg.xtype = DPI_XTYPE_INTERNAL_ONLY;
+		dpi_conf->cfg.rport = 0;
+		dpi_conf->cfg.wport = 0;
+		break;
+	case RTE_DMA_DIR_DEV_TO_DEV:
+		dpi_conf->cfg.xtype = DPI_XTYPE_EXTERNAL_ONLY;
+		dpi_conf->cfg.rport = conf->src_port.pcie.coreid;
+		dpi_conf->cfg.wport = conf->dst_port.pcie.coreid;
+	};
+
+	max_desc = conf->nb_desc;
+	if (!rte_is_power_of_2(max_desc))
+		max_desc = rte_align32pow2(max_desc);
+
+	num_rings = dpivf->rdpi.nr_lfs << 1;
+
+	for (ridx = 0; ridx < num_rings; ridx++) {
+		if (!rconf[ridx].used) {
+			if (!rconf[ridx].num_vchans) {
+				rconf[ridx].direction = conf->direction;
+				rconf[ridx].num_desc = max_desc;
+			} else if ((rconf[ridx].direction == conf->direction) &&
+				   (rconf[ridx].num_vchans < dpivf->vchans_per_ring)) {
+				rconf[ridx].num_desc += max_desc;
+			} else {
+				continue;
+			}
+
+			rconf[ridx].num_vchans++;
+			dpi_conf->ridx = ridx;
+
+			if (rconf[ridx].num_vchans == dpivf->vchans_per_ring)
+				rconf[ridx].used = true;
+
+			break;
+		}
+	}
+
+	if (ridx == num_rings)
+		rc = -ENODEV;
+
+	return rc;
+}
+
 static int
 cnxk_dmadev_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan,
 			const struct rte_dma_vchan_conf *conf, uint32_t conf_sz)
@@ -245,9 +502,14 @@ cnxk_dmadev_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan,
 
 	RTE_SET_USED(conf_sz);
 
+	if (conf->auto_free.m2d.pool != NULL && conf->direction != RTE_DMA_DIR_MEM_TO_DEV)
+		return -EINVAL;
+
 	header = (union cnxk_dpi_instr_cmd *)&dpi_conf->cmd.u;
 
-	if (dpivf->is_cn10k)
+	if (roc_model_is_cn20k())
+		ret = cn20k_dmadev_setup(dpivf, vchan, conf);
+	else if (roc_model_is_cn10k())
 		ret = cn10k_dmadev_setup_hdr(header, conf);
 	else
 		ret = cn9k_dmadev_setup_hdr(header, conf);
@@ -262,7 +524,7 @@ cnxk_dmadev_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan,
 	if (!rte_is_power_of_2(max_desc))
 		max_desc = rte_align32pow2(max_desc);
 
-	if (max_desc > CNXK_DPI_MAX_DESC)
+	if (!roc_model_is_cn20k() && (max_desc > CNXK_DPI_MAX_DESC))
 		max_desc = CNXK_DPI_MAX_DESC;
 
 	size = (max_desc * sizeof(uint8_t) * CNXK_DPI_COMPL_OFFSET);
@@ -285,10 +547,121 @@ cnxk_dmadev_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan,
 		dpi_conf->c_desc.compl_ptr[i * CNXK_DPI_COMPL_OFFSET] = CNXK_DPI_REQ_CDATA;
 
 	dpi_conf->c_desc.max_cnt = (max_desc - 1);
+	dpi_conf->cfg_done = true;
 
 	return 0;
 }
 
+static int
+cn20k_dmadev_queue_setup(struct cnxk_dpi_vf_s *dpivf)
+{
+	struct cn20k_ring_conf *rconf = dpivf->ring_conf;
+	struct roc_dpi *rdpi = &dpivf->rdpi;
+	struct cnxk_dpi_conf *dpi_conf;
+	struct roc_dpi_lf_que *que;
+	struct roc_dpi_lf_ring_cfg cfg;
+	struct roc_dpi_lf *lf;
+	uint16_t idx, qidx, ridx, vchan;
+	int rc = 0;
+
+	for (idx = 0; idx < rdpi->nr_lfs; idx++) {
+		lf = &rdpi->lfs[idx];
+		lf->chan_tbl = dpivf->chan_tbl;
+
+		for (qidx = 0; qidx < 2; qidx++) {
+			ridx = (idx << 1) + qidx;
+
+			if (!rconf[ridx].used)
+				continue;
+
+			que = &lf->queue[qidx];
+
+			que->qsize = rconf[ridx].num_desc;
+			que->cmd_len = DPI_CMD_SIZE_128B;
+			que->first_skip = 0;
+			que->later_skip = 0;
+			memset(&cfg, 0, sizeof(cfg));
+			cfg.ring_idx = qidx;
+			cfg.isize = que->cmd_len / DPI_CMD_SIZE_128B;
+			cfg.xtype = DPI_XTYPE_INTERNAL_ONLY;
+			cfg.rport = 0; /* Default is PEM:0 */
+			cfg.wport = 0; /* Default is PEM:0 */
+			cfg.pri = 0;   /* 0 - High Priority */
+			for (vchan = 0; vchan < dpivf->num_vchans; vchan++) {
+				dpi_conf = &dpivf->conf[vchan];
+
+				if (dpi_conf->ridx == ridx)
+					cfg.xtype = dpi_conf->cfg.xtype;
+			}
+
+			rc = roc_dpi_lf_ring_init(que, &cfg);
+			if (rc)
+				return rc;
+
+			for (vchan = 0; vchan < dpivf->num_vchans; vchan++) {
+				dpi_conf = &dpivf->conf[vchan];
+
+				if (dpi_conf->ridx == ridx) {
+					dpi_conf->que = que;
+					dpi_conf->dbell = lf->rbase + DPI_LF_RINGX_WIDX(qidx);
+				}
+			}
+		}
+
+		rc = roc_dpi_lf_chan_tbl_select(lf);
+		if (rc)
+			return rc;
+
+		/* FIX ME */
+		rc = roc_dpi_lf_pffunc_cfg(lf);
+		if (rc)
+			return rc;
+	}
+
+	return rc;
+}
+
+static int
+cn20k_dmadev_chan_tbl_setup(struct cnxk_dpi_vf_s *dpivf)
+{
+	uint16_t vchan, idx = 0, offset = 0;
+	struct cnxk_dpi_conf *dpi_conf;
+	uint64_t config[64] = {0};
+	struct roc_dpi_lf *lf;
+	int rc = 0;
+
+	lf = &(dpivf->rdpi.lfs[0]);
+
+	for (vchan = 0; vchan < dpivf->num_vchans; vchan++) {
+		dpi_conf = &dpivf->conf[vchan];
+		if (!dpi_conf->cfg_done || (dpi_conf->cfg.xtype == DPI_XTYPE_INTERNAL_ONLY))
+			continue;
+
+		dpi_conf->cmd.cn20k.chan = idx;
+		config[idx++] = dpi_conf->chan_cfg.u;
+
+		if (idx == 64) {
+			rc = roc_dpi_lf_chan_tbl_update(lf, config, offset, idx);
+			if (rc < 0) {
+				plt_err("Failed to update chan tbl = %d", rc);
+				return rc;
+			}
+			offset += idx;
+			idx = 0;
+		}
+	}
+
+	if (idx) {
+		rc = roc_dpi_lf_chan_tbl_update(lf, config, offset, idx);
+		if (rc < 0) {
+			plt_err("Failed to update chan tbl = %d", rc);
+			return rc;
+		}
+	}
+
+	return rc;
+}
+
 static int
 cnxk_dmadev_start(struct rte_dma_dev *dev)
 {
@@ -306,6 +679,10 @@ cnxk_dmadev_start(struct rte_dma_dev *dev)
 		dpi_conf->c_desc.head = 0;
 		dpi_conf->c_desc.tail = 0;
 		dpi_conf->desc_idx = 0;
+
+		if (dpi_conf->c_desc.compl_ptr == NULL)
+			continue;
+
 		for (j = 0; j < dpi_conf->c_desc.max_cnt + 1; j++)
 			dpi_conf->c_desc.compl_ptr[j * CNXK_DPI_COMPL_OFFSET] = CNXK_DPI_REQ_CDATA;
 		nb_desc += dpi_conf->c_desc.max_cnt + 1;
@@ -313,6 +690,27 @@ cnxk_dmadev_start(struct rte_dma_dev *dev)
 		dpi_conf->completed_offset = 0;
 	}
 
+	if (roc_model_is_cn20k()) {
+		for (i = 0; i < (dpivf->rdpi.nr_lfs << 1); i++)
+			dpivf->ring_conf[i].pending = 0;
+		roc_dpi_reset(&dpivf->rdpi);
+
+		if (dpivf->is_ring_conf_done)
+			goto enable_dpi;
+
+		rc = cn20k_dmadev_queue_setup(dpivf);
+		if (rc)
+			goto error;
+
+		rc = cn20k_dmadev_chan_tbl_setup(dpivf);
+		if (rc)
+			goto error;
+
+		dpivf->is_ring_conf_done = true;
+
+		goto enable_dpi;
+	}
+
 	queue_buf_sz = CNXK_DPI_QUEUE_BUF_SIZE_V2;
 	/* Max block size allowed by cnxk mempool driver is (128 * 1024).
 	 * Block size = elt_size + mp->header + mp->trailer.
@@ -349,6 +747,7 @@ cnxk_dmadev_start(struct rte_dma_dev *dev)
 	dpivf->chunk_head = 0;
 	dpivf->chunk_size_m1 = (queue_buf_sz >> 3) - 2;
 
+enable_dpi:
 	roc_dpi_enable(&dpivf->rdpi);
 error:
 	return rc;
@@ -359,14 +758,18 @@ cnxk_dmadev_stop(struct rte_dma_dev *dev)
 {
 	struct cnxk_dpi_vf_s *dpivf = dev->fp_obj->dev_private;
 
-	if (roc_dpi_wait_queue_idle(&dpivf->rdpi))
-		return -EAGAIN;
+	if (!roc_model_is_cn20k()) {
+		if (roc_dpi_wait_queue_idle(&dpivf->rdpi))
+			return -EAGAIN;
+	}
 
 	roc_dpi_disable(&dpivf->rdpi);
-	rte_mempool_free(dpivf->chunk_pool);
-	dpivf->chunk_pool = NULL;
-	dpivf->chunk_base = NULL;
-	dpivf->chunk_size_m1 = 0;
+	if (!roc_model_is_cn20k()) {
+		rte_mempool_free(dpivf->chunk_pool);
+		dpivf->chunk_pool = NULL;
+		dpivf->chunk_base = NULL;
+		dpivf->chunk_size_m1 = 0;
+	}
 
 	return 0;
 }
@@ -378,6 +781,10 @@ cnxk_dmadev_close(struct rte_dma_dev *dev)
 
 	roc_dpi_disable(&dpivf->rdpi);
 	cnxk_dmadev_vchan_free(dpivf, RTE_DMA_ALL_VCHAN);
+
+	if (roc_model_is_cn20k())
+		cnxk_dmadev_vchan_rsrc_free(dpivf);
+
 	roc_dpi_dev_fini(&dpivf->rdpi);
 
 	/* Clear all flags as we close the device. */
@@ -454,11 +861,17 @@ cnxk_damdev_burst_capacity(const void *dev_private, uint16_t vchan)
 {
 	const struct cnxk_dpi_vf_s *dpivf = (const struct cnxk_dpi_vf_s *)dev_private;
 	const struct cnxk_dpi_conf *dpi_conf = &dpivf->conf[vchan];
+	struct cn20k_ring_conf *ring_conf;
 	uint16_t burst_cap;
 
 	burst_cap = dpi_conf->c_desc.max_cnt -
 		    (dpi_conf->stats.submitted - dpi_conf->stats.completed) + 1;
 
+	if (roc_model_is_cn20k()) {
+		ring_conf = &dpivf->ring_conf[dpi_conf->ridx];
+		burst_cap -= ring_conf->pending;
+	}
+
 	return burst_cap;
 }
 
@@ -480,6 +893,26 @@ cnxk_dmadev_submit(void *dev_private, uint16_t vchan)
 	return 0;
 }
 
+static int
+cn20k_dmadev_submit(void *dev_private, uint16_t vchan)
+{
+	struct cnxk_dpi_vf_s *dpivf = dev_private;
+	struct cnxk_dpi_conf *dpi_conf = &dpivf->conf[vchan];
+	struct cn20k_ring_conf *ring_conf = &dpivf->ring_conf[dpi_conf->ridx];
+	uint16_t num_words = ring_conf->pending;
+
+	if (!num_words)
+		return 0;
+
+	rte_wmb();
+	plt_write64(num_words, dpi_conf->dbell);
+	dpi_conf->stats.submitted += num_words;
+
+	ring_conf->pending = 0;
+
+	return 0;
+}
+
 static int
 cnxk_stats_get(const struct rte_dma_dev *dev, uint16_t vchan, struct rte_dma_stats *rte_stats,
 	       uint32_t size)
@@ -552,11 +985,16 @@ cnxk_set_fp_ops(struct rte_dma_dev *dev, uint8_t ena_enq_deq)
 	dev->fp_obj->submit = cnxk_dmadev_submit;
 	dev->fp_obj->completed = cnxk_dmadev_completed;
 	dev->fp_obj->completed_status = cnxk_dmadev_completed_status;
-	dev->fp_obj->burst_capacity = cnxk_damdev_burst_capacity;
+		dev->fp_obj->burst_capacity = cnxk_damdev_burst_capacity;
 
 	if (roc_model_is_cn10k()) {
 		dev->fp_obj->copy = cn10k_dmadev_copy;
 		dev->fp_obj->copy_sg = cn10k_dmadev_copy_sg;
+	} else if (roc_model_is_cn20k()) {
+		dev->fp_obj->submit = cn20k_dmadev_submit;
+		dev->fp_obj->copy = cn20k_dmadev_copy;
+		dev->fp_obj->copy_sg = cn20k_dmadev_copy_sg;
+		dev->fp_obj->fill = cn20k_dmadev_fill;
 	}
 
 	if (ena_enq_deq) {
@@ -571,6 +1009,9 @@ cnxk_set_fp_ops(struct rte_dma_dev *dev, uint8_t ena_enq_deq)
 
 		if (roc_model_is_cn10k())
 			dev->fp_obj->enqueue = cn10k_dma_ops_enqueue;
+
+		if (roc_model_is_cn20k())
+			dev->fp_obj->enqueue = cn20k_dma_ops_enqueue;
 	}
 }
 
@@ -594,8 +1035,10 @@ cnxk_dmadev_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_de
 	struct roc_dpi *rdpi = NULL;
 	int rc;
 
-	if (!pci_dev->mem_resource[0].addr)
-		return -ENODEV;
+	if (!roc_model_is_cn20k()) {
+		if (!pci_dev->mem_resource[0].addr)
+			return -ENODEV;
+	}
 
 	rc = roc_plt_init();
 	if (rc) {
@@ -612,19 +1055,65 @@ cnxk_dmadev_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_de
 	}
 
 	dpivf = dmadev->data->dev_private;
+	dmadev->device = &pci_dev->device;
+
+	if (roc_model_is_cn20k()) {
+		/* Parse devargs string */
+		rc = cn20k_dmadev_parse_devargs(dmadev->device->devargs, dpivf);
+		if (rc) {
+			plt_err("Failed to parse devargs rc=%d", rc);
+			goto err_out_free;
+		}
+		dpivf->num_vchans = dpivf->max_vchans;
+	}
 
 	dmadev->device = &pci_dev->device;
 	dmadev->fp_obj->dev_private = dpivf;
 	dmadev->dev_ops = &cnxk_dmadev_ops;
 
+	/*
+	 * dev_private (and the roc_dpi it holds) lives in shared memory. Only
+	 * the primary owns the HW and the per-process pci_dev pointer; a
+	 * secondary must not run roc_dpi_dev_init nor overwrite rdpi->pci_dev,
+	 * otherwise the primary later dereferences the secondary's stale
+	 * pointer during rte_eal_cleanup() and crashes.
+	 */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	dpivf->is_cn10k = roc_model_is_cn10k();
+	dmadev->fp_obj->submit = cnxk_dmadev_submit;
+	dmadev->fp_obj->completed = cnxk_dmadev_completed;
+	dmadev->fp_obj->completed_status = cnxk_dmadev_completed_status;
+	dmadev->fp_obj->burst_capacity = cnxk_damdev_burst_capacity;
+
+	if (roc_model_is_cn10k()) {
+		dmadev->fp_obj->copy = cn10k_dmadev_copy;
+		dmadev->fp_obj->copy_sg = cn10k_dmadev_copy_sg;
+		dpivf->num_vchans = CNXK_DPI_MAX_VCHANS_PER_QUEUE;
+	} else if (roc_model_is_cn20k()) {
+		dmadev->fp_obj->submit = cn20k_dmadev_submit;
+		dmadev->fp_obj->copy = cn20k_dmadev_copy;
+		dmadev->fp_obj->copy_sg = cn20k_dmadev_copy_sg;
+		dmadev->fp_obj->fill = cn20k_dmadev_fill;
+	} else {
+		dmadev->fp_obj->copy = cnxk_dmadev_copy;
+		dmadev->fp_obj->copy_sg = cnxk_dmadev_copy_sg;
+		dpivf->num_vchans = CNXK_DPI_MAX_VCHANS_PER_QUEUE;
+	}
+
+	dpivf->conf = rte_zmalloc("dpi_vchan_conf", dpivf->num_vchans *
+				  sizeof(struct cnxk_dpi_conf), 0);
+	if (dpivf->conf == NULL) {
+		plt_err("Failed to allocate memory for vchan conf");
+		rc = -ENOMEM;
+		goto err_out_free;
+	}
+
 	dpivf->mcs_lock = NULL;
 	rdpi = &dpivf->rdpi;
 
 	rdpi->pci_dev = pci_dev;
+
 	rc = roc_dpi_dev_init(rdpi, offsetof(struct rte_dma_op, impl_opaque));
 	if (rc < 0)
 		goto err_out_free;
@@ -653,6 +1142,8 @@ cnxk_dmadev_remove(struct rte_pci_device *pci_dev)
 
 static const struct rte_pci_id cnxk_dma_pci_map[] = {
 	{RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_CNXK_DPI_VF)},
+	{RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_CN20K_DPI_PF)},
+	{RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_CN20K_DPI_VF)},
 	{
 		.vendor_id = 0,
 	},
drivers/dma/cnxk/cnxk_dmadev.h +68 -4

127 lines not on this page · raw message

drivers/dma/cnxk/cnxk_dmadev_fp.c +214 -0

226 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/3 dma/cnxk: enable inter process domain DMA support

In reply to Vamsi Krishna

From: Vamsi Attunuru <[email protected]>

Adds support for inter domain DMA operations.

---
 drivers/dma/cnxk/cnxk_dmadev.c | 148 ++++++++++++++++++++++++++++++++-
 drivers/dma/cnxk/cnxk_dmadev.h |   1 +
 2 files changed, 148 insertions(+), 1 deletion(-)
drivers/dma/cnxk/cnxk_dmadev.c +147 -1
index 3970abe1c3..faa13abc23 100644
@@ -98,7 +98,7 @@ cnxk_dmadev_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *dev_inf
 		dev_info->min_desc = CN20K_DPI_MIN_DESC;
 		dev_info->max_sges = CN20K_DPI_MAX_POINTER;
 		dev_info->max_vchans = dpivf->max_vchans;
-		dev_info->dev_capa |= RTE_DMA_CAPA_OPS_FILL;
+		dev_info->dev_capa |= (RTE_DMA_CAPA_OPS_FILL | RTE_DMA_CAPA_INTER_PROCESS_DOMAIN);
 	} else {
 		dev_info->max_desc = CNXK_DPI_MAX_DESC;
 		dev_info->min_desc = CNXK_DPI_MIN_DESC;
@@ -446,6 +446,13 @@ cn20k_dmadev_setup(struct cnxk_dpi_vf_s *dpivf, uint16_t vchan,
 		break;
 	case RTE_DMA_DIR_MEM_TO_MEM:
 		dpi_conf->cfg.xtype = DPI_XTYPE_INTERNAL_ONLY;
+		if (conf->domain.type == RTE_DMA_INTER_PROCESS_DOMAIN) {
+			dpi_conf->chan_cfg.type = RTE_DMA_INTER_PROCESS_DOMAIN;
+			dpi_conf->chan_cfg.src_key = conf->domain.src_handler;
+			dpi_conf->chan_cfg.dst_key = conf->domain.dst_handler;
+			header->cn20k.chan = CNXK_DPI_SRC_DST_KEY(dpi_conf->chan_cfg.src_key,
+								  dpi_conf->chan_cfg.dst_key);
+		}
 		dpi_conf->cfg.rport = 0;
 		dpi_conf->cfg.wport = 0;
 		break;
@@ -1015,6 +1022,140 @@ cnxk_set_fp_ops(struct rte_dma_dev *dev, uint8_t ena_enq_deq)
 	}
 }
 
+static int
+cnxk_dmadev_access_pair_group_create(const struct rte_dma_dev *dev, rte_uuid_t domain_id,
+				       rte_uuid_t token, int16_t *group_id,
+				       rte_dma_access_pair_group_event_cb_t cb)
+{
+	struct cnxk_dpi_vf_s *dpivf = dev->fp_obj->dev_private;
+	struct roc_dpi_lf *lf;
+	int rc;
+
+	RTE_SET_USED(cb);
+
+	if (!roc_model_is_cn20k())
+		return -ENOTSUP;
+
+	if (dpivf->rdpi.lfs == NULL || dpivf->rdpi.nr_lfs == 0) {
+		plt_err("DPI LF resources are not initialized");
+		return -EINVAL;
+	}
+
+	lf = &(dpivf->rdpi.lfs[0]);
+
+	rc = roc_dpi_access_pair_group_create(lf, domain_id, token, group_id);
+
+	return rc;
+}
+
+static int
+cnxk_dmadev_access_pair_group_destroy(const struct rte_dma_dev *dev, int16_t group_id)
+{
+	struct cnxk_dpi_vf_s *dpivf = dev->fp_obj->dev_private;
+	struct roc_dpi_lf *lf;
+	int rc;
+
+	if (!roc_model_is_cn20k())
+		return -ENOTSUP;
+
+	if (dpivf->rdpi.lfs == NULL || dpivf->rdpi.nr_lfs == 0) {
+		plt_err("DPI LF resources are not initialized");
+		return -EINVAL;
+	}
+
+	lf = &(dpivf->rdpi.lfs[0]);
+
+	if (lf->group_id != group_id) {
+		plt_err("Invalid access pair group is passed");
+		return -EINVAL;
+	}
+
+	rc = roc_dpi_access_pair_group_destroy(lf, group_id);
+
+	return rc;
+}
+
+static int
+cnxk_dmadev_access_pair_group_join(const struct rte_dma_dev *dev, rte_uuid_t domain_id,
+				   rte_uuid_t token, int16_t group_id,
+				   rte_dma_access_pair_group_event_cb_t cb)
+{
+	struct cnxk_dpi_vf_s *dpivf = dev->fp_obj->dev_private;
+	struct roc_dpi_lf *lf;
+	int rc;
+
+	RTE_SET_USED(cb);
+
+	if (!roc_model_is_cn20k())
+		return -ENOTSUP;
+
+	if (dpivf->rdpi.lfs == NULL || dpivf->rdpi.nr_lfs == 0) {
+		plt_err("DPI LF resources are not initialized");
+		return -EINVAL;
+	}
+
+	lf = &(dpivf->rdpi.lfs[0]);
+
+	rc = roc_dpi_access_pair_group_join(lf, domain_id, token, group_id);
+
+	return rc;
+}
+
+static int
+cnxk_dmadev_access_pair_group_leave(const struct rte_dma_dev *dev, int16_t group_id)
+{
+	struct cnxk_dpi_vf_s *dpivf = dev->fp_obj->dev_private;
+	struct roc_dpi_lf *lf;
+	int rc;
+
+	if (!roc_model_is_cn20k())
+		return -ENOTSUP;
+
+	if (dpivf->rdpi.lfs == NULL || dpivf->rdpi.nr_lfs == 0) {
+		plt_err("DPI LF resources are not initialized");
+		return -EINVAL;
+	}
+
+	lf = &(dpivf->rdpi.lfs[0]);
+
+	if (lf->group_id != group_id) {
+		plt_err("Invalid access pair group is passed");
+		return -EINVAL;
+	}
+
+	rc = roc_dpi_access_pair_group_leave(lf, group_id);
+
+	return rc;
+}
+
+static int
+cnxk_dmadev_access_pair_group_handler_get(const struct rte_dma_dev *dev, int16_t group_id,
+					  rte_uuid_t domain_id, uint16_t *handler)
+{
+	struct cnxk_dpi_vf_s *dpivf = dev->fp_obj->dev_private;
+	struct roc_dpi_lf *lf;
+	int rc;
+
+	if (!roc_model_is_cn20k())
+		return -ENOTSUP;
+
+	if (dpivf->rdpi.lfs == NULL || dpivf->rdpi.nr_lfs == 0) {
+		plt_err("DPI LF resources are not initialized");
+		return -EINVAL;
+	}
+
+	lf = &(dpivf->rdpi.lfs[0]);
+
+	if (lf->group_id != group_id) {
+		plt_err("Invalid access pair group is passed");
+		return -EINVAL;
+	}
+
+	rc = roc_dpi_access_pair_group_handler_get(lf, group_id, domain_id, handler);
+
+	return rc;
+}
+
 static const struct rte_dma_dev_ops cnxk_dmadev_ops = {
 	.dev_close = cnxk_dmadev_close,
 	.dev_configure = cnxk_dmadev_configure,
@@ -1024,6 +1165,11 @@ static const struct rte_dma_dev_ops cnxk_dmadev_ops = {
 	.stats_get = cnxk_stats_get,
 	.stats_reset = cnxk_stats_reset,
 	.vchan_setup = cnxk_dmadev_vchan_setup,
+	.access_pair_group_create = cnxk_dmadev_access_pair_group_create,
+	.access_pair_group_destroy = cnxk_dmadev_access_pair_group_destroy,
+	.access_pair_group_join = cnxk_dmadev_access_pair_group_join,
+	.access_pair_group_leave = cnxk_dmadev_access_pair_group_leave,
+	.access_pair_group_handler_get = cnxk_dmadev_access_pair_group_handler_get,
 };
 
 static int
drivers/dma/cnxk/cnxk_dmadev.h +1 -0
index 3ba404dda8..043f48cb7e 100644
@@ -47,6 +47,7 @@
 							     CNXK_DPI_MAX_POINTER)
 #define CNXK_DPI_CHUNKS_FROM_DESC(cz, desc) (((desc) / (((cz) / 8) / CNXK_DPI_MAX_CMD_SZ)) + 1)
 #define CNXK_DPI_COMPL_OFFSET		    ROC_CACHE_LINE_SZ
+#define CNXK_DPI_SRC_DST_KEY(src, dst)	    ((0x2040) | ((src & 0x3F) << 7) | (dst & 0x3F))
 
 #define CN20K_DPI_MAX_POINTER		    4
 #define CN20K_DPI_MAX_DESC		    2048
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v0 3/3] dma/cnxk: enable inter process domain DMA support

Quoted 10 lines · Vamsi Krishna

From: Vamsi Attunuru <[email protected]>

Adds support for inter domain DMA operations.

---
 drivers/dma/cnxk/cnxk_dmadev.c | 148 ++++++++++++++++++++++++++++++++-
 drivers/dma/cnxk/cnxk_dmadev.h |   1 +
 2 files changed, 148 insertions(+), 1 deletion(-)

1) Fix
./devtools/checkpatches.sh -n 3

### [PATCH] common/cnxk: add O20 DPI DMA support

Warning in drivers/common/cnxk/roc_dpi.c:
Warning in drivers/common/cnxk/roc_dpi.h:
Use plt_ symbols instead of rte_ API in cnxk base driver

2) Change rte_wmb() etc to rte_io_* in fastpath

3) Update doc/guides/dmadevs/cnxk.rst for CN20k support and inter process domain DMA line item

4) Update doc/guides/dmadevs/cnxk.rst for CN20k support if anything needs to be updated for starting dma application like devbind etc.

5) Update doc/guides/rel_notes/release_26_11.rst as it is major feature(CN20k support and inter process domain DMA). (Make sure follow the order for release update)

#5 lore raw

v2 cover dma/cnxk: add CN20K (O20) DPI DMA and inter-process domain support

From: Vamsi Attunuru <[email protected]>

This series adds DMA support for Marvell CN20K (O20) DPI hardware to the existing cnxk dmadev driver, building on the common ROC DPI layer used by CN9K/CN10K.

CN20K DPI is LF and ring-based: commands are posted to per-LF hardware queues rather than the legacy VF chunk-buffer model. The series introduces the ROC infrastructure for LF attach/detach, ring configuration, channel table management, and access-pair group mailbox operations, then wires the dmadev PMD to expose copy, copy-SG, fill, and enqueue/dequeue on O20.

Patch 1 lays the common foundation. Patch 2 integrates O20 into the dmadev fast and slow paths. Patch 3 adds inter-process domain DMA on top of the O20 path using the dmadev access-pair group API.

Vamsi Attunuru (4):
common/cnxk: add O20 DPI DMA support dma/cnxk: add O20 DPI DMA support dma/cnxk: enable inter process domain DMA support
doc: update 26.11 release notes for cnxk dmadev
---
V2 changes:
* updated doc/guides/dmadevs/cnxk.rst
* updated cnxk base driver to use plt_ symbols
* changed rte_wmb() to rte_io_wmb()
* updated doc/guides/rel_notes/release_26_11.rst

 doc/guides/dmadevs/cnxk.rst                   | 138 +++-
 doc/guides/rel_notes/release_26_11.rst        |  17 +
 drivers/common/cnxk/hw/dpi.h                  |  72 +-
 drivers/common/cnxk/hw/rvu.h                  |   2 +
 drivers/common/cnxk/roc_constants.h           |   2 +
 drivers/common/cnxk/roc_dev.c                 |   1 +
 drivers/common/cnxk/roc_dpi.c                 | 683 +++++++++++++++++-
 drivers/common/cnxk/roc_dpi.h                 |  85 +++
 drivers/common/cnxk/roc_dpi_priv.h            |  34 +
 drivers/common/cnxk/roc_mbox.h                | 174 ++++-
 drivers/common/cnxk/roc_platform.h            |  10 +
 .../common/cnxk/roc_platform_base_symbols.c   |  17 +
 drivers/dma/cnxk/cnxk_dmadev.c                | 676 ++++++++++++++++-
 drivers/dma/cnxk/cnxk_dmadev.h                |  73 +-
 drivers/dma/cnxk/cnxk_dmadev_fp.c             | 232 +++++-
 15 files changed, 2166 insertions(+), 50 deletions(-)
Signature · 1 line
2.34.1
#6 lore raw

PATCH v2 1/4 common/cnxk: add O20 DPI DMA support

From: Vamsi Attunuru <[email protected]>

Addes ROC support for O20 DPI DMA hardware.

---
 drivers/common/cnxk/hw/dpi.h                  |  72 +-
 drivers/common/cnxk/hw/rvu.h                  |   2 +
 drivers/common/cnxk/roc_constants.h           |   2 +
 drivers/common/cnxk/roc_dev.c                 |   1 +
 drivers/common/cnxk/roc_dpi.c                 | 683 +++++++++++++++++-
 drivers/common/cnxk/roc_dpi.h                 |  85 +++
 drivers/common/cnxk/roc_dpi_priv.h            |  34 +
 drivers/common/cnxk/roc_mbox.h                | 174 ++++-
 drivers/common/cnxk/roc_platform.h            |  10 +
 .../common/cnxk/roc_platform_base_symbols.c   |  17 +
 10 files changed, 1066 insertions(+), 14 deletions(-)
drivers/common/cnxk/hw/dpi.h +70 -2
index a34713dde6..8d5a5bd0e1 100644
@@ -23,6 +23,27 @@
 #define DPI_VF_INT_ENA_W1C (0x110)
 #define DPI_VF_INT_ENA_W1S (0x118)
 
+/* DPI CN20K LF register offsets from VF_BAR2 */
+#define DPI_LF_CTL		    (0ull)
+#define DPI_LF_RINGX_CFG(x)	    ((0x20ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_BASE(x)	    ((0x30ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_RIDX(x)	    ((0x40ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_WIDX(x)	    ((0x50ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_RST(x)	    ((0x70ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_ISTAT(x)	    ((0x80ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_CMPL(x)	    ((0x90ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_INT	    (0x100ull)
+#define DPI_LF_RINGX_INT_W1S	    (0x108ull)
+#define DPI_LF_RINGX_INT_ENA_W1C    (0x110ull)
+#define DPI_LF_RINGX_INT_ENA_W1S    (0x118ull)
+#define DPI_LF_RINGX_ERR_STAT(x)    ((0x120ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_ERR	    (0x200ull)
+#define DPI_LF_RINGX_ERR_W1S	    (0x208ull)
+#define DPI_LF_RINGX_ERR_ENA_W1C    (0x210ull)
+#define DPI_LF_RINGX_ERR_ENA_W1S    (0x218ull)
+#define DPI_LF_RINGX_DMA_CNT(x)	    ((0x220ull | (uint64_t)(x) << 3))
+#define DPI_LF_RINGX_DMA_BCNT(x)    ((0x230ull | (uint64_t)(x) << 3))
+
 /**
  * Enumeration dpi_hdr_xtype_e
  *
@@ -54,6 +75,26 @@
 #define DPI_MIN_CMD_SIZE 8
 #define DPI_MAX_CMD_SIZE 64
 
+#define DPI_CMD_SIZE_64B  64
+#define DPI_CMD_SIZE_128B 128
+
+#define DPI_CMD_VLD_BIT BIT_ULL(63)
+
+#define DPI_LF_QCFG_QEN	  BIT_ULL(63)
+#define DPI_LF_QCFG_ISIZE BIT(11)
+#define DPI_LF_QUEUE_RST  BIT(0)
+
+#define DPI_LF_QIDX_WRAP_MASK 0x8000
+#define DPI_LF_QSIZE_MASK     0xFF
+#define DPI_LF_QIDX_MASK      0xFFF
+#define DPI_LF_QSIZE_SHIFT    56
+
+#define DPI_Q_RIDX(x) ((x)&0xFFF)
+#define DPI_Q_WIDX(x) ((x)&0xFFF)
+
+#define DPI_Q_RIDX_WRAP(x) (((x) >> 15) & 0x1)
+#define DPI_Q_WIDX_WRAP(x) (((x) >> 15) & 0x1)
+
 /**
  * Structure dpi_instr_hdr_s for CN9K
  *
@@ -61,7 +102,7 @@
  */
 union dpi_instr_hdr_s {
 	uint64_t u[4];
-	struct dpi_cn9k_instr_hdr_s_s {
+	struct dpi_cn9k_instr_hdr_s {
 		uint64_t tag : 32;
 		uint64_t tt : 2;
 		uint64_t grp : 10;
@@ -95,7 +136,7 @@ union dpi_instr_hdr_s {
 		/* Word 3 - End */
 	} cn9k;
 
-	struct dpi_cn10k_instr_hdr_s_s {
+	struct dpi_cn10k_instr_hdr_s {
 		uint64_t nfst : 4;
 		uint64_t reserved_4_5 : 2;
 		uint64_t nlst : 4;
@@ -128,6 +169,33 @@ union dpi_instr_hdr_s {
 		uint64_t reserved_192_255 : 64;
 		/* Word 3 - End */
 	} cn10k;
+
+	struct dpi_cn20k_instr_hdr_s {
+		uint64_t nfst : 3;
+		uint64_t reserved_3 : 1;
+		uint64_t nlst : 3;
+		uint64_t reserved_7 : 1;
+		uint64_t msix_int : 1;
+		uint64_t ct : 3;
+		uint64_t chan : 14;
+		uint64_t reserved_26_29 : 4;
+		uint64_t aura : 20;
+		uint64_t xt : 2;
+		uint64_t ivec : 9;
+		uint64_t fe : 1;
+		uint64_t reserved_62 : 1;
+		uint64_t vld : 1;
+		/* Word 0 - End */
+		uint64_t ptr : 64;
+		/* Word 1 - End */
+		uint64_t tag : 32;
+		uint64_t tt : 2;
+		uint64_t grp : 10;
+		uint64_t reserved_107_127 : 20;
+		/* Word 2 - End */
+		uint64_t reserved_128_191 : 64;
+		/* Word 3 - End */
+	} cn20k;
 };
 
 #endif /*__DEV_DPI_HW_H__*/
drivers/common/cnxk/hw/rvu.h +2 -0
index 6f02d1e3d2..01f19b0a16 100644
@@ -169,6 +169,8 @@
 #define RVU_BLOCK_ADDR_R_START (0x14ull)
 #define RVU_BLOCK_ADDR_REE0    (0x14ull)
 #define RVU_BLOCK_ADDR_REE1    (0x15ull)
+#define RVU_BLOCK_ADDR_DPI0    (0x18ULL)
+#define RVU_BLOCK_ADDR_DPI1    (0x19ULL)
 #define RVU_BLOCK_ADDR_MBOX    (0x1bULL)
 
 #define RVU_VF_INT_VEC_MBOX (0x0ull)
drivers/common/cnxk/roc_constants.h +2 -0
index 795869c9df..3218e641f0 100644
@@ -47,6 +47,8 @@
 #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_CN20K_DPI_PF        0xA0E8
+#define PCI_DEVID_CN20K_DPI_VF        0xA0E9
 
 #define PCI_DEVID_CN9K_CGX  0xA059
 #define PCI_DEVID_CN10K_RPM 0xA060
drivers/common/cnxk/roc_dev.c +1 -0
index 61aa4b3075..e2b717a214 100644
@@ -1401,6 +1401,7 @@ dev_vf_hwcap_update(struct plt_pci_device *pci_dev, struct dev *dev)
 	case PCI_DEVID_CNXK_RVU_NIX_INL_VF:
 	case PCI_DEVID_CNXK_RVU_BPHY_VF:
 	case PCI_DEVID_CNXK_RVU_ESWITCH_VF:
+	case PCI_DEVID_CN20K_DPI_VF:
 		dev->hwcap |= DEV_HWCAP_F_VF;
 		break;
 	}
drivers/common/cnxk/roc_dpi.c +674 -9

729 lines not on this page · raw message

drivers/common/cnxk/roc_dpi.h +85 -0

106 lines not on this page · raw message

drivers/common/cnxk/roc_dpi_priv.h +34 -0
index 05b6751ca6..3051abc979 100644
@@ -18,6 +18,7 @@
 #define DPI_QUEUE_OPEN_V2 0x5
 
 #define DPI_QUEUE_IDLE_TMO_MS 1E3
+#define DPI_LF_RESET_TMO_US   10000
 
 typedef union dpi_mbox_msg_t {
 	uint64_t u[2];
@@ -43,4 +44,37 @@ typedef union dpi_mbox_msg_t {
 	} s;
 } dpi_mbox_msg_t;
 
+struct dpi {
+	struct plt_pci_device *pci_dev;
+	struct dev dev;
+	uint16_t lf_msix_off[ROC_DPI_MAX_LFS];
+	uint8_t lf_blkaddr[ROC_DPI_MAX_LFS];
+};
+
+static inline struct dpi *
+roc_dpi_to_dpi_priv(struct roc_dpi *roc_dpi)
+{
+	return (struct dpi *)&roc_dpi->reserved[0];
+}
+
+static inline struct roc_dpi *
+dpi_priv_to_roc_dpi(struct dpi *dpi)
+{
+	return (struct roc_dpi *)((char *)dpi - offsetof(struct roc_dpi, reserved));
+}
+
+int dpi_lf_reset(struct roc_dpi_lf *lf);
+void dpi_lf_ena_dis(struct roc_dpi_lf *lf, uint8_t enb);
+int dpi_lfs_attach(struct dev *dev, uint8_t blkaddr, bool modify, uint16_t nb_lf);
+int dpi_lfs_detach(struct dev *dev);
+int dpi_lf_attach(struct dev *dev, uint8_t blkaddr, bool modify, uint16_t nb_lf);
+int dpi_lf_detach(struct dev *dev);
+int dpi_lf_init(struct roc_dpi_lf *lf, struct dev *dev, uint8_t slot);
+int dpi_chan_tbl_alloc(struct dev *dev, uint8_t blk_addr, uint16_t tbl_sz);
+int dpi_chan_tbl_free(struct dev *dev, uint8_t blk_addr, uint16_t tbl_num);
+int dpi_chan_tbl_ena_dis(struct dev *dev, uint32_t dpi_blkaddr, uint16_t lfid, uint16_t chan_tbl,
+			 bool enable);
+int dpi_chan_tbl_update(struct dev *dev, uint8_t blk_addr, uint16_t chan_tbl, uint64_t *tbl,
+			uint16_t off, uint16_t nb_entries);
+
 #endif
drivers/common/cnxk/roc_mbox.h +171 -3

196 lines not on this page · raw message

drivers/common/cnxk/roc_platform.h +10 -0
index ac4f76473f..6f57399d66 100644
@@ -259,6 +259,8 @@ plt_thread_is_valid(plt_thread_t thr)
 
 #define plt_strlcpy rte_strlcpy
 
+#define plt_uuid_t rte_uuid_t
+
 #define PLT_TEL_INT_VAL              RTE_TEL_INT_VAL
 #define PLT_TEL_STRING_VAL           RTE_TEL_STRING_VAL
 #define plt_tel_data                 rte_tel_data
@@ -347,6 +349,14 @@ extern int cnxk_logtype_esw;
 	RTE_LOG_DP_LINE_PREFIX(DEBUG, CNXK, "%s():%u ", __func__ RTE_LOG_COMMA __LINE__, \
 		__VA_ARGS__)
 
+/* append dbdf to name */
+#define plt_pci_dev_name(devname, name, dev)                                                       \
+	({                                                                                         \
+		snprintf((devname), sizeof(devname), "%s" PCI_PRI_FMT, (name), (dev)->addr.domain, \
+			 (dev)->addr.bus, (dev)->addr.devid, (dev)->addr.function);                \
+		devname;                                                                           \
+	})
+
 #ifdef __cplusplus
 #define CNXK_PCI_ID(subsystem_dev, dev)                                        \
 {                                                                      \
drivers/common/cnxk/roc_platform_base_symbols.c +17 -0
index 063cb21aae..c2f0355b1e 100644
@@ -70,6 +70,23 @@ RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_configure)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_configure_v2)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_dev_init)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_dev_fini)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_ring_init)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_ring_fini)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_pffunc_cfg)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_ring_chan_cfg)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_chan_tbl_select)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_chan_tbl_ena_dis)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_chan_tbl_update)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_access_pair_group_create)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_access_pair_group_destroy)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_access_pair_group_join)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_access_pair_group_leave)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_access_pair_group_handler_get)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_reset)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_rsrc_init)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_rsrc_fini)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_chan_tbl_alloc)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_dpi_lf_chan_tbl_free)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_eswitch_npc_mcam_tx_rule)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_eswitch_npc_mcam_delete_rule)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_eswitch_npc_mcam_rx_rule)
Signature · 1 line
2.34.1
#7 lore raw

PATCH v2 2/4 dma/cnxk: add O20 DPI DMA support

In reply to Vamsi Krishna

From: Vamsi Attunuru <[email protected]>

Adds DMA driver support for O20 hardware.

---
 doc/guides/dmadevs/cnxk.rst       |  65 +++-
 drivers/dma/cnxk/cnxk_dmadev.c    | 530 ++++++++++++++++++++++++++++--
 drivers/dma/cnxk/cnxk_dmadev.h    |  72 +++-
 drivers/dma/cnxk/cnxk_dmadev_fp.c | 232 ++++++++++++-
 4 files changed, 863 insertions(+), 36 deletions(-)
doc/guides/dmadevs/cnxk.rst +61 -4
index 1a7185deb9..2794f393a7 100644
@@ -7,8 +7,37 @@ CNXK DMA Device Driver
 ======================
 
 The ``cnxk`` dmadev driver provides a poll-mode driver (PMD) for Marvell DPI DMA
-Hardware Accelerator block found in OCTEON 9 and OCTEON 10 family of SoCs.
-Each DMA queue is exposed as a VF function when SRIOV is enabled.
+Hardware Accelerator block found in OCTEON CN9K, CN10K and CN20K family of SoCs.
+
+Supported OCTEON cnxk SoCs
+--------------------------
+
+- CN9XX
+- CN10XX
+- CN20XX
+
+Supported PCI devices
+---------------------
+
+.. list-table::
+   :widths: 30 20 50
+   :header-rows: 1
+
+   * - SoC family
+     - PCI device ID
+     - Description
+   * - CN9K/CN10K
+     - 0xA081
+     - DPI VF
+   * - CN20K
+     - 0xA0E8
+     - DPI PF
+   * - CN20K
+     - 0xA0E9
+     - DPI VF
+
+On CN9K/CN10K, each DMA queue is exposed as a VF function when SRIOV is enabled.
+On CN20K, both DPI PF and VF devices can be used directly by the PMD.
 
 The block supports following modes of DMA transfers:
 
@@ -38,15 +67,39 @@ For example::
 
      $ dpdk-devbind.py -b vfio-pci 0000:05:00.1
 
+On CN20K, DPI PF and VF devices can be bound directly to the ``vfio-pci`` driver
+and used by the DPDK PMD. The ``octeontx2_dpi.ko`` kernel driver is not required
+on CN20K.
+
 Device Probing and Initialization
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 To use the devices from an application, the dmadev API can be used.
 CNXK DMA device configuration requirements:
 
-* Only one ``vchan`` is supported per device.
+* CN9K/CN10K: only one ``vchan`` is supported per device.
+* CN20K: multiple ``vchans`` are supported per device.
 * CNXK DMA devices do not support silent mode.
 
+CN20K runtime config options
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The following ``devargs`` parameters can be used to configure CN20K DPI devices.
+For example::
+
+     -a 0002:02:00.0,num_vchans=16,num_lfs=8
+
+``num_vchans``
+
+  Number of virtual channels to configure per device (default ``8``).
+  The value must be a power of 2 and must not exceed ``512``.
+
+``num_lfs``
+
+  Number of local functions to configure per device (default ``num_vchans / 2``).
+  Each LF has two hardware rings. The value must be a power of 2
+  and must not exceed ``256``.
+
 Once configured, the device can then be made ready for use
 by calling the ``rte_dma_start()`` API.
 
@@ -60,7 +113,7 @@ for details on operation enqueue and submission API usage.
 Performance Tuning Parameters
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-To achieve higher performance, DMA device needs to be tuned
+On CN9K/CN10K, to achieve higher performance, DMA device needs to be tuned
 using PF kernel driver module parameters.
 The PF kernel driver is part of the OCTEON SDK.
 Module parameters shall be configured during module insert as in below example::
@@ -95,3 +148,7 @@ Module parameters shall be configured during module insert as in below example::
    MPS and MRRS performance tuning parameters help achieve higher performance
    only for inbound and outbound DMA transfers.
    The parameter has no effect for internal only DMA transfer.
+
+   Performance tuning via ``octeontx2_dpi.ko`` applies to CN9K/CN10K only.
+   CN20K DPI devices do not require the kernel driver and can be used directly
+   after binding to ``vfio-pci``.
drivers/dma/cnxk/cnxk_dmadev.c +511 -19

707 lines not on this page · raw message

drivers/dma/cnxk/cnxk_dmadev.h +68 -4

127 lines not on this page · raw message

drivers/dma/cnxk/cnxk_dmadev_fp.c +223 -9

298 lines not on this page · raw message

Signature · 1 line
2.34.1
#8 lore raw

PATCH v2 3/4 dma/cnxk: enable inter process domain DMA support

In reply to Vamsi Krishna

From: Vamsi Attunuru <[email protected]>

Adds support for inter domain DMA operations.

---
 doc/guides/dmadevs/cnxk.rst    |  73 ++++++++++++++++
 drivers/dma/cnxk/cnxk_dmadev.c | 148 ++++++++++++++++++++++++++++++++-
 drivers/dma/cnxk/cnxk_dmadev.h |   1 +
 3 files changed, 221 insertions(+), 1 deletion(-)
doc/guides/dmadevs/cnxk.rst +73 -0
index 2794f393a7..9021a0f126 100644
@@ -110,6 +110,79 @@ Refer to the :ref:`dmadev_enqueue_dequeue` section
 of the dmadev library documentation
 for details on operation enqueue and submission API usage.
 
+CN20K inter-process domain DMA transfers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+CN20K DPI devices advertise the ``RTE_DMA_CAPA_INTER_PROCESS_DOMAIN`` capability.
+This enables DMA transfers between memory owned by different DPDK processes
+running on the same CN20K SoC.
+
+Each participating process must bind its own CN20K DPI PF or VF device to
+``vfio-pci`` and probe it through the ``cnxk`` dmadev PMD.
+Inter-process domain transfers are supported only with
+``RTE_DMA_DIR_MEM_TO_MEM`` direction.
+
+Access pair group setup
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Before configuring a virtual channel for inter-process DMA, each process must
+join a common access pair group using the dmadev access pair group API.
+The general setup flow is described in
+:doc:`/prog_guide/dmadev` under *Inter-domain DMA Transfers*.
+
+At a high level:
+
+#. Each process generates a unique ``domain_id`` (``rte_uuid_t``) to identify
+   its process domain.
+#. Process#1 generates a ``token`` and calls ``rte_dma_access_pair_group_create()``.
+#. Process#1 shares the ``group_id``, ``token`` and its ``domain_id`` with
+   Process#2 through an out-of-band channel.
+#. Process#2 calls ``rte_dma_access_pair_group_join()`` with the shared
+   ``group_id``, ``token`` and its own ``domain_id``.
+#. Each process retrieves source and destination handler values using
+   ``rte_dma_access_pair_group_handler_get()``.
+#. Each process configures its virtual channel and performs DMA transfers.
+#. Process#2 calls ``rte_dma_access_pair_group_leave()`` when finished.
+#. Process#1 calls ``rte_dma_access_pair_group_destroy()`` to tear down the group.
+
+Virtual channel configuration
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+After the access pair group is established and handler values are exchanged,
+configure the virtual channel with ``RTE_DMA_INTER_PROCESS_DOMAIN`` domain type.
+For example::
+
+     struct rte_dma_vchan_conf vchan_conf = {0};
+
+     vchan_conf.direction = RTE_DMA_DIR_MEM_TO_MEM;
+     vchan_conf.nb_desc = 128;
+     vchan_conf.domain.type = RTE_DMA_INTER_PROCESS_DOMAIN;
+     vchan_conf.domain.src_handler = local_src_handler;
+     vchan_conf.domain.dst_handler = peer_dst_handler;
+
+     rte_dma_vchan_setup(dma_dev_id, vchan, &vchan_conf);
+
+``src_handler``
+
+  Handler for the local process domain, obtained from
+  ``rte_dma_access_pair_group_handler_get()`` using the local domain_id.
+
+``dst_handler``
+
+  Handler for the peer process domain, obtained from
+  ``rte_dma_access_pair_group_handler_get()`` using the peer domain_id.
+
+Once the virtual channel is configured, start the device and issue copy or
+copy-SG operations as for a regular memory-to-memory transfer.
+
+.. note::
+
+   Inter-process domain DMA is supported on CN20K only.
+   CN9K/CN10K DPI devices do not advertise
+   ``RTE_DMA_CAPA_INTER_PROCESS_DOMAIN``.
+
+   The access pair group APIs are experimental and may change in future releases.
+
 Performance Tuning Parameters
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
drivers/dma/cnxk/cnxk_dmadev.c +147 -1

172 lines not on this page · raw message

drivers/dma/cnxk/cnxk_dmadev.h +1 -0
index 3ba404dda8..043f48cb7e 100644
@@ -47,6 +47,7 @@
 							     CNXK_DPI_MAX_POINTER)
 #define CNXK_DPI_CHUNKS_FROM_DESC(cz, desc) (((desc) / (((cz) / 8) / CNXK_DPI_MAX_CMD_SZ)) + 1)
 #define CNXK_DPI_COMPL_OFFSET		    ROC_CACHE_LINE_SZ
+#define CNXK_DPI_SRC_DST_KEY(src, dst)	    ((0x2040) | ((src & 0x3F) << 7) | (dst & 0x3F))
 
 #define CN20K_DPI_MAX_POINTER		    4
 #define CN20K_DPI_MAX_DESC		    2048
Signature · 1 line
2.34.1
#9 lore raw

PATCH v2 4/4 doc: update 26.11 release notes for cnxk dmadev

In reply to Vamsi Krishna

From: Vamsi Attunuru <[email protected]>

Document CN20K DPI DMA PF/VF support and inter-process domain DMA transfers in the Marvell cnxk dmadev PMD for DPDK 26.11.

---
 doc/guides/rel_notes/release_26_11.rst | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
doc/guides/rel_notes/release_26_11.rst +17 -0
index 4b3e5d995c..f9da09ab45 100644
@@ -55,6 +55,23 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Marvell cnxk dmadev driver.**
+
+  Added support for CN20K DPI DMA hardware in the ``cnxk`` dmadev PMD.
+
+  * Added support for CN20K DPI PF (PCI device ID ``0xA0E8``) and VF
+    (PCI device ID ``0xA0E9``) devices.
+  * CN20K DPI PF and VF devices can be bound directly to ``vfio-pci`` and
+    used without the ``octeontx2_dpi.ko`` kernel driver.
+  * Added support for multiple virtual channels per device on CN20K.
+  * Added support for ``copy``, ``copy-sg``, ``fill`` and enqueue/dequeue
+    operations on CN20K.
+  * Added support for inter-process domain DMA transfers on CN20K using the
+    access pair group API
+    (``rte_dma_access_pair_group_create``,
+    ``rte_dma_access_pair_group_join``,
+    ``rte_dma_access_pair_group_handler_get`` and related functions).
+
 
 Removed Items
 -------------
Signature · 1 line
2.34.1
#10 lore raw

Re: [PATCH v2 4/4] doc: update 26.11 release notes for cnxk dmadev

Quoted 25 lines · Vamsi Krishna

From: Vamsi Attunuru <[email protected]>

Document CN20K DPI DMA PF/VF support and inter-process domain DMA transfers in the Marvell cnxk dmadev PMD for DPDK 26.11.

---
 doc/guides/rel_notes/release_26_11.rst | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
doc/guides/rel_notes/release_26_11.rst +6 -0
index 4b3e5d995c..f9da09ab45 100644
@@ -55,6 +55,23 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Marvell cnxk dmadev driver.**
+
+  Added support for CN20K DPI DMA hardware in the ``cnxk`` dmadev PMD.
+
+  * Added support for CN20K DPI PF (PCI device ID ``0xA0E8``) and VF
+    (PCI device ID ``0xA0E9``) devices.

doc/guides/rel_notes/release_26_11.rst New Features · line 73

Quoted 10 lines
doc/guides/rel_notes/release_26_11.rst +10 -0
+  * CN20K DPI PF and VF devices can be bound directly to ``vfio-pci`` and
+    used without the ``octeontx2_dpi.ko`` kernel driver.
+  * Added support for multiple virtual channels per device on CN20K.
+  * Added support for ``copy``, ``copy-sg``, ``fill`` and enqueue/dequeue
+    operations on CN20K.
+  * Added support for inter-process domain DMA transfers on CN20K using the
+    access pair group API
+    (``rte_dma_access_pair_group_create``,
+    ``rte_dma_access_pair_group_join``,
+    ``rte_dma_access_pair_group_handler_get`` and related functions).

# Moved this change to 3/4 patch.
# Updated as follows
+* **Updated Marvell cnxk dmadev driver.**
+
+ * Added support for CN20K DPI DMA hardware.
+ * Added support for inter-process domain DMA transfers using access pair group API.
+

Series applied to dpdk-next-net-mrvl/for-main. Thanks