@@ -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 BBDEV_LA12XX_MAX_NB_QUEUES_ARG "max_nb_queues"
+#define BBDEV_LA12XX_VDEV_MODEM_ID_ARG "modem"
+#define LA12XX_MAX_MODEM 4
static const char * const bbdev_la12xx_valid_params[] = {
BBDEV_LA12XX_MAX_NB_QUEUES_ARG,
+ BBDEV_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) {
+ BBDEV_LA12XX_PMD_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,
+ ¶ms->modem_id);
+
+ if (params->modem_id >= LA12XX_MAX_MODEM) {
+ BBDEV_LA12XX_PMD_ERR("Invalid modem id, must be < %u",
+ LA12XX_MAX_MODEM);
+ goto exit;
+ }
}
exit:
@@ -88,6 +122,7 @@ la12xx_bbdev_create(struct rte_vdev_device *vdev,
{
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;
+
+ BBDEV_LA12XX_PMD_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 = {
- RTE_BBDEV_DEFAULT_MAX_NB_QUEUES
+ RTE_BBDEV_DEFAULT_MAX_NB_QUEUES, -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,
- BBDEV_LA12XX_MAX_NB_QUEUES_ARG"=<int>");
+ BBDEV_LA12XX_MAX_NB_QUEUES_ARG"=<int>"
+ BBDEV_LA12XX_VDEV_MODEM_ID_ARG "=<int> ");
new file mode 100644
@@ -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
new file mode 100644
@@ -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
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 | 62 +++++++++++++++++++--- drivers/baseband/la12xx/bbdev_la12xx.h | 56 +++++++++++++++++++ drivers/baseband/la12xx/bbdev_la12xx_ipc.h | 20 +++++++ 3 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 drivers/baseband/la12xx/bbdev_la12xx.h create mode 100644 drivers/baseband/la12xx/bbdev_la12xx_ipc.h -- 2.17.1