diff mbox series

[v5,4/9] baseband/la12xx: add support for multiple modems

Message ID 20210912121510.22699-5-nipun.gupta@nxp.com (mailing list archive)
State Superseded
Delegated to: akhil goyal
Headers show
Series baseband: add NXP LA12xx driver | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Nipun Gupta Sept. 12, 2021, 12:15 p.m. UTC
From: Hemant Agrawal <hemant.agrawal@nxp.com>

This patch add support for multiple modems by assigning
a modem id as dev args in vdev creation.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/baseband/la12xx/bbdev_la12xx.c     | 64 +++++++++++++++++++---
 drivers/baseband/la12xx/bbdev_la12xx.h     | 56 +++++++++++++++++++
 drivers/baseband/la12xx/bbdev_la12xx_ipc.h | 20 +++++++
 3 files changed, 133 insertions(+), 7 deletions(-)
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx.h
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx_ipc.h
diff mbox series

Patch

diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c b/drivers/baseband/la12xx/bbdev_la12xx.c
index 8886b35429..f26f3f2a08 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -14,6 +14,8 @@ 
 #include <rte_bbdev_pmd.h>
 
 #include <bbdev_la12xx_pmd_logs.h>
+#include <bbdev_la12xx_ipc.h>
+#include <bbdev_la12xx.h>
 
 #define DRIVER_NAME baseband_la12xx
 
@@ -22,18 +24,18 @@  RTE_LOG_REGISTER(bbdev_la12xx_logtype, pmd.bb.la12xx, NOTICE);
 /*  Initialisation params structure that can be used by LA12xx BBDEV driver */
 struct bbdev_la12xx_params {
 	uint8_t queues_num; /*< LA12xx BBDEV queues number */
+	int8_t modem_id; /*< LA12xx modem instance id */
 };
 
 #define LA12XX_MAX_NB_QUEUES_ARG	"max_nb_queues"
+#define LA12XX_VDEV_MODEM_ID_ARG	"modem"
+#define LA12XX_MAX_MODEM 4
 
 static const char * const bbdev_la12xx_valid_params[] = {
 	LA12XX_MAX_NB_QUEUES_ARG,
+	LA12XX_VDEV_MODEM_ID_ARG,
 };
 
-/* private data structure */
-struct bbdev_la12xx_private {
-	unsigned int max_nb_queues;  /**< Max number of queues */
-};
 static inline int
 parse_u16_arg(const char *key, const char *value, void *extra_args)
 {
@@ -52,6 +54,28 @@  parse_u16_arg(const char *key, const char *value, void *extra_args)
 	return 0;
 }
 
+/* Parse integer from integer argument */
+static int
+parse_integer_arg(const char *key __rte_unused,
+		const char *value, void *extra_args)
+{
+	int i;
+	char *end;
+
+	errno = 0;
+
+	i = strtol(value, &end, 10);
+	if (*end != 0 || errno != 0 || i < 0 || i > LA12XX_MAX_MODEM) {
+		rte_bbdev_log(ERR, "Supported Port IDS are 0 to %d",
+			LA12XX_MAX_MODEM - 1);
+		return -EINVAL;
+	}
+
+	*((uint32_t *)extra_args) = i;
+
+	return 0;
+}
+
 /* Parse parameters used to create device */
 static int
 parse_bbdev_la12xx_params(struct bbdev_la12xx_params *params,
@@ -73,6 +97,16 @@  parse_bbdev_la12xx_params(struct bbdev_la12xx_params *params,
 		if (ret < 0)
 			goto exit;
 
+		ret = rte_kvargs_process(kvlist,
+					bbdev_la12xx_valid_params[1],
+					&parse_integer_arg,
+					&params->modem_id);
+
+		if (params->modem_id >= LA12XX_MAX_MODEM) {
+			rte_bbdev_log(ERR, "Invalid modem id, must be < %u",
+					LA12XX_MAX_MODEM);
+			goto exit;
+		}
 	}
 
 exit:
@@ -84,10 +118,11 @@  parse_bbdev_la12xx_params(struct bbdev_la12xx_params *params,
 /* Create device */
 static int
 la12xx_bbdev_create(struct rte_vdev_device *vdev,
-		struct bbdev_la12xx_params *init_params __rte_unused)
+		struct bbdev_la12xx_params *init_params)
 {
 	struct rte_bbdev *bbdev;
 	const char *name = rte_vdev_device_name(vdev);
+	struct bbdev_la12xx_private *priv;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -103,6 +138,20 @@  la12xx_bbdev_create(struct rte_vdev_device *vdev,
 		return -ENOMEM;
 	}
 
+	priv = bbdev->data->dev_private;
+	priv->modem_id = init_params->modem_id;
+	/* if modem id is not configured */
+	if (priv->modem_id == -1)
+		priv->modem_id = bbdev->data->dev_id;
+
+	/* Reset Global variables */
+	priv->num_ldpc_enc_queues = 0;
+	priv->num_ldpc_dec_queues = 0;
+	priv->num_valid_queues = 0;
+	priv->max_nb_queues = init_params->queues_num;
+
+	rte_bbdev_log(INFO, "Setting Up %s: DevId=%d, ModemId=%d",
+				name, bbdev->data->dev_id, priv->modem_id);
 	bbdev->dev_ops = NULL;
 	bbdev->device = &vdev->device;
 	bbdev->data->socket_id = 0;
@@ -122,7 +171,7 @@  static int
 la12xx_bbdev_probe(struct rte_vdev_device *vdev)
 {
 	struct bbdev_la12xx_params init_params = {
-		8
+		8, -1,
 	};
 	const char *name;
 	const char *input_args;
@@ -174,4 +223,5 @@  static struct rte_vdev_driver bbdev_la12xx_pmd_drv = {
 
 RTE_PMD_REGISTER_VDEV(DRIVER_NAME, bbdev_la12xx_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
-	LA12XX_MAX_NB_QUEUES_ARG"=<int>");
+	LA12XX_MAX_NB_QUEUES_ARG"=<int>"
+	LA12XX_VDEV_MODEM_ID_ARG "=<int> ");
diff --git a/drivers/baseband/la12xx/bbdev_la12xx.h b/drivers/baseband/la12xx/bbdev_la12xx.h
new file mode 100644
index 0000000000..5228502331
--- /dev/null
+++ b/drivers/baseband/la12xx/bbdev_la12xx.h
@@ -0,0 +1,56 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020-2021 NXP
+ */
+
+#ifndef __BBDEV_LA12XX_H__
+#define __BBDEV_LA12XX_H__
+
+#define BBDEV_IPC_ENC_OP_TYPE	1
+#define BBDEV_IPC_DEC_OP_TYPE	2
+
+#define MAX_LDPC_ENC_FECA_QUEUES	4
+#define MAX_LDPC_DEC_FECA_QUEUES	4
+
+#define MAX_CHANNEL_DEPTH 16
+/* private data structure */
+struct bbdev_la12xx_private {
+	void *ipc_priv;
+	uint8_t num_valid_queues;
+	uint8_t max_nb_queues;
+	uint8_t num_ldpc_enc_queues;
+	uint8_t num_ldpc_dec_queues;
+	int8_t modem_id;
+	struct bbdev_la12xx_q_priv *queues_priv[32];
+};
+
+struct hugepage_info {
+	void *vaddr;
+	phys_addr_t paddr;
+	size_t len;
+};
+
+struct bbdev_la12xx_q_priv {
+	struct bbdev_la12xx_private *bbdev_priv;
+	uint32_t q_id;	/**< Channel ID */
+	uint32_t feca_blk_id;	/** FECA block ID for processing */
+	uint32_t feca_blk_id_be32; /**< FECA Block ID for this queue */
+	uint8_t en_napi; /* 0: napi disabled, 1: napi enabled */
+	uint16_t queue_size;	/**< Queue depth */
+	int32_t eventfd;	/**< Event FD value */
+	enum rte_bbdev_op_type op_type; /**< Operation type */
+	uint32_t la12xx_core_id;
+		/* LA12xx core ID on which this will be scheduled */
+	struct rte_mempool *mp; /**< Pool from where buffers would be cut */
+	void *bbdev_op[MAX_CHANNEL_DEPTH];
+			/**< Stores bbdev op for each index */
+	void *msg_ch_vaddr[MAX_CHANNEL_DEPTH];
+			/**< Stores msg channel addr for modem->host */
+	uint32_t host_pi;	/**< Producer_Index for HOST->MODEM */
+	uint32_t host_ci;	/**< Consumer Index for MODEM->HOST */
+	host_ipc_params_t *host_params; /**< Host parameters */
+};
+
+#define lower_32_bits(x) ((uint32_t)((uint64_t)x))
+#define upper_32_bits(x) ((uint32_t)(((uint64_t)(x) >> 16) >> 16))
+
+#endif
diff --git a/drivers/baseband/la12xx/bbdev_la12xx_ipc.h b/drivers/baseband/la12xx/bbdev_la12xx_ipc.h
new file mode 100644
index 0000000000..9aa5562981
--- /dev/null
+++ b/drivers/baseband/la12xx/bbdev_la12xx_ipc.h
@@ -0,0 +1,20 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020-2021 NXP
+ */
+#ifndef __BBDEV_LA12XX_IPC_H__
+#define __BBDEV_LA12XX_IPC_H__
+
+/** No. of max channel per instance */
+#define IPC_MAX_DEPTH	(16)
+
+/* This shared memory would be on the host side which have copy of some
+ * of the parameters which are also part of Shared BD ring. Read access
+ * of these parameters from the host side would not be over PCI.
+ */
+typedef struct host_ipc_params {
+	volatile uint32_t pi;
+	volatile uint32_t ci;
+	volatile uint32_t modem_ptr[IPC_MAX_DEPTH];
+} __rte_packed host_ipc_params_t;
+
+#endif