DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anoob Joseph <anoobj@marvell.com>
To: Chengwen Feng <fengchengwen@huawei.com>,
	Kevin Laatz <kevin.laatz@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	"Jerin Jacob" <jerinj@marvell.com>,
	Thomas Monjalon <thomas@monjalon.net>
Cc: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>,
	"Vidya Sagar Velumuri" <vvelumuri@marvell.com>, <dev@dpdk.org>
Subject: [PATCH 2/8] dma/odm: add framework for ODM DMA device
Date: Mon, 15 Apr 2024 21:01:53 +0530	[thread overview]
Message-ID: <20240415153159.86-3-anoobj@marvell.com> (raw)
In-Reply-To: <20240415153159.86-1-anoobj@marvell.com>

Add framework for Odyssey ODM DMA device.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Signed-off-by: Vidya Sagar Velumuri <vvelumuri@marvell.com>
---
 MAINTAINERS                  |  6 +++
 drivers/dma/meson.build      |  1 +
 drivers/dma/odm/meson.build  | 14 +++++++
 drivers/dma/odm/odm.h        | 29 ++++++++++++++
 drivers/dma/odm/odm_dmadev.c | 74 ++++++++++++++++++++++++++++++++++++
 5 files changed, 124 insertions(+)
 create mode 100644 drivers/dma/odm/meson.build
 create mode 100644 drivers/dma/odm/odm.h
 create mode 100644 drivers/dma/odm/odm_dmadev.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 7abb3aee49..b8d2f7b3d8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1268,6 +1268,12 @@ T: git://dpdk.org/next/dpdk-next-net-mrvl
 F: drivers/dma/cnxk/
 F: doc/guides/dmadevs/cnxk.rst
 
+Marvell Odyssey ODM DMA
+M: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
+M: Vidya Sagar Velumuri <vvelumuri@marvell.com>
+T: git://dpdk.org/next/dpdk-next-net-mrvl
+F: drivers/dma/odm/
+
 NXP DPAA DMA
 M: Gagandeep Singh <g.singh@nxp.com>
 M: Sachin Saxena <sachin.saxena@oss.nxp.com>
diff --git a/drivers/dma/meson.build b/drivers/dma/meson.build
index 582654ea1b..358132759a 100644
--- a/drivers/dma/meson.build
+++ b/drivers/dma/meson.build
@@ -8,6 +8,7 @@ drivers = [
         'hisilicon',
         'idxd',
         'ioat',
+        'odm',
         'skeleton',
 ]
 std_deps = ['dmadev']
diff --git a/drivers/dma/odm/meson.build b/drivers/dma/odm/meson.build
new file mode 100644
index 0000000000..227b10c890
--- /dev/null
+++ b/drivers/dma/odm/meson.build
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2024 Marvell.
+
+if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on 64-bit Linux'
+    subdir_done()
+endif
+
+deps += ['bus_pci', 'dmadev', 'eal', 'mempool', 'pci']
+
+sources = files('odm_dmadev.c')
+
+pmd_supports_disable_iova_as_pa = true
diff --git a/drivers/dma/odm/odm.h b/drivers/dma/odm/odm.h
new file mode 100644
index 0000000000..aeeb6f9e9a
--- /dev/null
+++ b/drivers/dma/odm/odm.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#ifndef _ODM_H_
+#define _ODM_H_
+
+#include <rte_log.h>
+
+extern int odm_logtype;
+
+#define odm_err(...)                                                                               \
+	rte_log(RTE_LOG_ERR, odm_logtype,                                                          \
+		RTE_FMT("%s(): %u" RTE_FMT_HEAD(__VA_ARGS__, ), __func__, __LINE__,                \
+			RTE_FMT_TAIL(__VA_ARGS__, )))
+#define odm_info(...)                                                                              \
+	rte_log(RTE_LOG_INFO, odm_logtype,                                                         \
+		RTE_FMT("%s(): %u" RTE_FMT_HEAD(__VA_ARGS__, ), __func__, __LINE__,                \
+			RTE_FMT_TAIL(__VA_ARGS__, )))
+
+struct __rte_cache_aligned odm_dev {
+	struct rte_pci_device *pci_dev;
+	uint8_t *rbase;
+	uint16_t vfid;
+	uint8_t max_qs;
+	uint8_t num_qs;
+};
+
+#endif /* _ODM_H_ */
diff --git a/drivers/dma/odm/odm_dmadev.c b/drivers/dma/odm/odm_dmadev.c
new file mode 100644
index 0000000000..cc3342cf7b
--- /dev/null
+++ b/drivers/dma/odm/odm_dmadev.c
@@ -0,0 +1,74 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell.
+ */
+
+#include <string.h>
+
+#include <bus_pci_driver.h>
+#include <rte_bus_pci.h>
+#include <rte_common.h>
+#include <rte_dmadev.h>
+#include <rte_dmadev_pmd.h>
+#include <rte_pci.h>
+
+#include "odm.h"
+
+#define PCI_VENDOR_ID_CAVIUM	 0x177D
+#define PCI_DEVID_ODYSSEY_ODM_VF 0xA08C
+#define PCI_DRIVER_NAME		 dma_odm
+
+static int
+odm_dmadev_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev)
+{
+	char name[RTE_DEV_NAME_MAX_LEN];
+	struct odm_dev *odm = NULL;
+	struct rte_dma_dev *dmadev;
+
+	if (!pci_dev->mem_resource[0].addr)
+		return -ENODEV;
+
+	memset(name, 0, sizeof(name));
+	rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
+
+	dmadev = rte_dma_pmd_allocate(name, pci_dev->device.numa_node, sizeof(*odm));
+	if (dmadev == NULL) {
+		odm_err("DMA device allocation failed for %s", name);
+		return -ENOMEM;
+	}
+
+	odm_info("DMA device %s probed", name);
+
+	return 0;
+}
+
+static int
+odm_dmadev_remove(struct rte_pci_device *pci_dev)
+{
+	char name[RTE_DEV_NAME_MAX_LEN];
+
+	memset(name, 0, sizeof(name));
+	rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
+
+	return rte_dma_pmd_release(name);
+}
+
+static const struct rte_pci_id odm_dma_pci_map[] = {
+	{
+		RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_ODYSSEY_ODM_VF)
+	},
+	{
+		.vendor_id = 0,
+	},
+};
+
+static struct rte_pci_driver odm_dmadev = {
+	.id_table = odm_dma_pci_map,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+	.probe = odm_dmadev_probe,
+	.remove = odm_dmadev_remove,
+};
+
+RTE_PMD_REGISTER_PCI(PCI_DRIVER_NAME, odm_dmadev);
+RTE_PMD_REGISTER_PCI_TABLE(PCI_DRIVER_NAME, odm_dma_pci_map);
+RTE_PMD_REGISTER_KMOD_DEP(PCI_DRIVER_NAME, "vfio-pci");
+RTE_LOG_REGISTER_DEFAULT(odm_logtype, NOTICE);
-- 
2.25.1


  parent reply	other threads:[~2024-04-15 15:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 15:31 [PATCH 0/8] Add " Anoob Joseph
2024-04-15 15:31 ` [PATCH 1/8] usertools/devbind: add " Anoob Joseph
2024-04-15 15:31 ` Anoob Joseph [this message]
2024-04-15 15:31 ` [PATCH 3/8] dma/odm: add hardware defines Anoob Joseph
2024-04-15 15:31 ` [PATCH 4/8] dma/odm: add dev init and fini Anoob Joseph
2024-04-15 15:31 ` [PATCH 5/8] dma/odm: add device ops Anoob Joseph
2024-04-15 15:31 ` [PATCH 6/8] dma/odm: add stats Anoob Joseph
2024-04-15 15:31 ` [PATCH 7/8] dma/odm: add copy and copy sg ops Anoob Joseph
2024-04-15 15:31 ` [PATCH 8/8] dma/odm: add remaining ops Anoob Joseph
2024-04-17  7:27 ` [PATCH v2 0/7] Add ODM DMA device Anoob Joseph
2024-04-17  7:27   ` [PATCH v2 1/7] dma/odm: add framework for " Anoob Joseph
2024-04-17  7:27   ` [PATCH v2 2/7] dma/odm: add hardware defines Anoob Joseph
2024-04-17  7:27   ` [PATCH v2 3/7] dma/odm: add dev init and fini Anoob Joseph
2024-04-17  7:27   ` [PATCH v2 4/7] dma/odm: add device ops Anoob Joseph
2024-04-17  7:27   ` [PATCH v2 5/7] dma/odm: add stats Anoob Joseph
2024-04-17  7:27   ` [PATCH v2 6/7] dma/odm: add copy and copy sg ops Anoob Joseph
2024-04-17  7:27   ` [PATCH v2 7/7] dma/odm: add remaining ops Anoob Joseph
2024-04-19  6:43   ` [PATCH v3 0/7] Add ODM DMA device Anoob Joseph
2024-04-19  6:43     ` [PATCH v3 1/7] dma/odm: add framework for " Anoob Joseph
2024-04-19  6:43     ` [PATCH v3 2/7] dma/odm: add hardware defines Anoob Joseph
2024-04-19  6:43     ` [PATCH v3 3/7] dma/odm: add dev init and fini Anoob Joseph
2024-04-19  6:43     ` [PATCH v3 4/7] dma/odm: add device ops Anoob Joseph
2024-04-19  6:43     ` [PATCH v3 5/7] dma/odm: add stats Anoob Joseph
2024-04-19  6:43     ` [PATCH v3 6/7] dma/odm: add copy and copy sg ops Anoob Joseph
2024-04-19  6:43     ` [PATCH v3 7/7] dma/odm: add remaining ops Anoob Joseph

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240415153159.86-3-anoobj@marvell.com \
    --to=anoobj@marvell.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=gmuthukrishn@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=kevin.laatz@intel.com \
    --cc=thomas@monjalon.net \
    --cc=vvelumuri@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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).