diff mbox series

[v2,1/8] baseband: introduce NXP LA12xx driver

Message ID 20210410170252.4587-2-hemant.agrawal@nxp.com
State Superseded
Headers show
Series baseband: add NXP LA12xx driver | expand

Commit Message

Hemant Agrawal April 10, 2021, 5:02 p.m. UTC
This patch introduce the baseband device drivers for NXP's
LA1200 series software defined baseband modem.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

---
 drivers/baseband/la12xx/bbdev_la12xx.c        | 109 ++++++++++++++++++
 .../baseband/la12xx/bbdev_la12xx_pmd_logs.h   |  38 ++++++
 drivers/baseband/la12xx/meson.build           |   6 +
 drivers/baseband/la12xx/version.map           |   3 +
 drivers/baseband/meson.build                  |   2 +-
 5 files changed, 157 insertions(+), 1 deletion(-)
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx.c
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h
 create mode 100644 drivers/baseband/la12xx/meson.build
 create mode 100644 drivers/baseband/la12xx/version.map

-- 
2.17.1
diff mbox series

Patch

diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c b/drivers/baseband/la12xx/bbdev_la12xx.c
new file mode 100644
index 0000000000..7050b17728
--- /dev/null
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -0,0 +1,109 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020-2021 NXP
+ */
+
+#include <string.h>
+
+#include <rte_common.h>
+#include <rte_bus_vdev.h>
+#include <rte_malloc.h>
+#include <rte_ring.h>
+#include <rte_kvargs.h>
+
+#include <rte_bbdev.h>
+#include <rte_bbdev_pmd.h>
+
+#include <bbdev_la12xx_pmd_logs.h>
+
+#define DRIVER_NAME baseband_la12xx
+
+RTE_LOG_REGISTER(bbdev_la12xx_logtype, pmd.bb.la12xx, NOTICE);
+
+/* private data structure */
+struct bbdev_la12xx_private {
+	unsigned int max_nb_queues;  /**< Max number of queues */
+};
+/* Create device */
+static int
+la12xx_bbdev_create(struct rte_vdev_device *vdev)
+{
+	struct rte_bbdev *bbdev;
+	const char *name = rte_vdev_device_name(vdev);
+
+	PMD_INIT_FUNC_TRACE();
+
+	bbdev = rte_bbdev_allocate(name);
+	if (bbdev == NULL)
+		return -ENODEV;
+
+	bbdev->data->dev_private = rte_zmalloc(name,
+			sizeof(struct bbdev_la12xx_private),
+			RTE_CACHE_LINE_SIZE);
+	if (bbdev->data->dev_private == NULL) {
+		rte_bbdev_release(bbdev);
+		return -ENOMEM;
+	}
+
+	bbdev->dev_ops = NULL;
+	bbdev->device = &vdev->device;
+	bbdev->data->socket_id = 0;
+	bbdev->intr_handle = NULL;
+
+	/* register rx/tx burst functions for data path */
+	bbdev->dequeue_enc_ops = NULL;
+	bbdev->dequeue_dec_ops = NULL;
+	bbdev->enqueue_enc_ops = NULL;
+	bbdev->enqueue_dec_ops = NULL;
+
+	return 0;
+}
+
+/* Initialise device */
+static int
+la12xx_bbdev_probe(struct rte_vdev_device *vdev)
+{
+	const char *name;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (vdev == NULL)
+		return -EINVAL;
+
+	name = rte_vdev_device_name(vdev);
+	if (name == NULL)
+		return -EINVAL;
+
+	return la12xx_bbdev_create(vdev);
+}
+
+/* Uninitialise device */
+static int
+la12xx_bbdev_remove(struct rte_vdev_device *vdev)
+{
+	struct rte_bbdev *bbdev;
+	const char *name;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (vdev == NULL)
+		return -EINVAL;
+
+	name = rte_vdev_device_name(vdev);
+	if (name == NULL)
+		return -EINVAL;
+
+	bbdev = rte_bbdev_get_named_dev(name);
+	if (bbdev == NULL)
+		return -EINVAL;
+
+	rte_free(bbdev->data->dev_private);
+
+	return rte_bbdev_release(bbdev);
+}
+
+static struct rte_vdev_driver bbdev_la12xx_pmd_drv = {
+	.probe = la12xx_bbdev_probe,
+	.remove = la12xx_bbdev_remove
+};
+
+RTE_PMD_REGISTER_VDEV(DRIVER_NAME, bbdev_la12xx_pmd_drv);
diff --git a/drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h b/drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h
new file mode 100644
index 0000000000..71613a5bac
--- /dev/null
+++ b/drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h
@@ -0,0 +1,38 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 NXP
+ */
+
+#ifndef _BBDEV_LA12XX_PMD_LOGS_H_
+#define _BBDEV_LA12XX_PMD_LOGS_H_
+
+#define BBDEV_LA12XX_PMD_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, bbdev_la12xx_logtype, "bbdev_la12xx: " \
+		fmt "\n", ##args)
+
+#define BBDEV_LA12XX_PMD_DEBUG(fmt, args...) \
+	rte_log(RTE_LOG_DEBUG, bbdev_la12xx_logtype, "bbdev_la12xx: %s(): "\
+		fmt "\n", __func__, ##args)
+
+#define PMD_INIT_FUNC_TRACE() BBDEV_LA12XX_PMD_DEBUG(">>")
+
+#define BBDEV_LA12XX_PMD_CRIT(fmt, args...) \
+	BBDEV_LA12XX_PMD_LOG(CRIT, fmt, ## args)
+#define BBDEV_LA12XX_PMD_INFO(fmt, args...) \
+	BBDEV_LA12XX_PMD_LOG(INFO, fmt, ## args)
+#define BBDEV_LA12XX_PMD_ERR(fmt, args...) \
+	BBDEV_LA12XX_PMD_LOG(ERR, fmt, ## args)
+#define BBDEV_LA12XX_PMD_WARN(fmt, args...) \
+	BBDEV_LA12XX_PMD_LOG(WARNING, fmt, ## args)
+
+/* DP Logs, toggled out at compile time if level lower than current level */
+#define BBDEV_LA12XX_PMD_DP_LOG(level, fmt, args...) \
+	RTE_LOG_DP(level, PMD, fmt, ## args)
+
+#define BBDEV_LA12XX_PMD_DP_DEBUG(fmt, args...) \
+	BBDEV_LA12XX_PMD_DP_LOG(DEBUG, fmt, ## args)
+#define BBDEV_LA12XX_PMD_DP_INFO(fmt, args...) \
+	BBDEV_LA12XX_PMD_DP_LOG(INFO, fmt, ## args)
+#define BBDEV_LA12XX_PMD_DP_WARN(fmt, args...) \
+	BBDEV_LA12XX_PMD_DP_LOG(WARNING, fmt, ## args)
+
+#endif /* _BBDEV_LA12XX_PMD_LOGS_H_ */
diff --git a/drivers/baseband/la12xx/meson.build b/drivers/baseband/la12xx/meson.build
new file mode 100644
index 0000000000..7a017dcffa
--- /dev/null
+++ b/drivers/baseband/la12xx/meson.build
@@ -0,0 +1,6 @@ 
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2020-2021 NXP
+
+deps += ['bbdev', 'bus_vdev', 'ring']
+
+sources = files('bbdev_la12xx.c')
diff --git a/drivers/baseband/la12xx/version.map b/drivers/baseband/la12xx/version.map
new file mode 100644
index 0000000000..4a76d1d52d
--- /dev/null
+++ b/drivers/baseband/la12xx/version.map
@@ -0,0 +1,3 @@ 
+DPDK_21 {
+	local: *;
+};
diff --git a/drivers/baseband/meson.build b/drivers/baseband/meson.build
index 920e3b02ee..ba5b2e570a 100644
--- a/drivers/baseband/meson.build
+++ b/drivers/baseband/meson.build
@@ -5,4 +5,4 @@  if is_windows
 	subdir_done()
 endif
 
-drivers = ['null', 'turbo_sw', 'fpga_lte_fec', 'fpga_5gnr_fec', 'acc100']
+drivers = ['null', 'turbo_sw', 'fpga_lte_fec', 'fpga_5gnr_fec', 'acc100', 'la12xx']