From: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
To: dev@dpdk.org
Cc: gakhil@marvell.com, ciara.power@intel.com,
Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
Subject: [PATCH v5 1/3] common/qat: isolate parser arguments configuration
Date: Fri, 1 Mar 2024 15:52:49 +0000 [thread overview]
Message-ID: <20240301155251.5101-1-arkadiuszx.kusztal@intel.com> (raw)
In-Reply-To: <20240229191427.1267-1-arkadiuszx.kusztal@intel.com>
This commit isolates qat device arguments from the common
code. Now arguments are defined per service, and only appear
in the application if the service is compiled-in.
Depends-on: patch-137678 ("common/qat: add virtual qat device (vQAT)")
Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
---
v2:
- added pmd isolation
v3:
- added fix for legacy flag
v4:
- fixed an issue with devargs segfault
v5:
- rebased against the newest changes in the pmd
drivers/common/qat/qat_common.c | 11 +++
drivers/common/qat/qat_common.h | 3 +
drivers/common/qat/qat_device.c | 189 +++++++++++++++++++-----------------
drivers/common/qat/qat_device.h | 27 ++----
drivers/compress/qat/qat_comp_pmd.c | 31 ++++--
drivers/compress/qat/qat_comp_pmd.h | 3 +-
drivers/crypto/qat/qat_asym.c | 38 +++++---
drivers/crypto/qat/qat_sym.c | 49 ++++++----
8 files changed, 198 insertions(+), 153 deletions(-)
diff --git a/drivers/common/qat/qat_common.c b/drivers/common/qat/qat_common.c
index 59e7e02622..61bc97b0f3 100644
--- a/drivers/common/qat/qat_common.c
+++ b/drivers/common/qat/qat_common.c
@@ -6,6 +6,17 @@
#include "qat_device.h"
#include "qat_logs.h"
+#define QAT_LEGACY_CAPA "qat_legacy_capa"
+
+static const char *const arguments[] = {
+ QAT_LEGACY_CAPA,
+ NULL
+};
+
+const char *const *qat_cmdline_defines[QAT_MAX_SERVICES + 1] = {
+ [QAT_MAX_SERVICES] = arguments,
+};
+
const char *
qat_service_get_str(enum qat_service_type type)
{
diff --git a/drivers/common/qat/qat_common.h b/drivers/common/qat/qat_common.h
index 12f281e5b1..6d0f4aefd5 100644
--- a/drivers/common/qat/qat_common.h
+++ b/drivers/common/qat/qat_common.h
@@ -16,6 +16,9 @@
* from one according to the generation of the device.
* QAT_GEN* is used as the index to find all devices
*/
+
+extern const char *const *qat_cmdline_defines[];
+
enum qat_device_gen {
QAT_GEN1,
QAT_GEN2,
diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c
index 09347845e0..e1f1060535 100644
--- a/drivers/common/qat/qat_device.c
+++ b/drivers/common/qat/qat_device.c
@@ -130,70 +130,6 @@ qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev)
return qat_pci_get_named_dev(name);
}
-static void
-qat_dev_parse_cmd(const char *str, struct qat_dev_cmd_param
- *qat_dev_cmd_param)
-{
- int i = 0;
- const char *param;
-
- while (1) {
- char value_str[4] = { };
-
- param = qat_dev_cmd_param[i].name;
- if (param == NULL)
- return;
- long value = 0;
- const char *arg = strstr(str, param);
- const char *arg2 = NULL;
-
- if (arg) {
- arg2 = arg + strlen(param);
- if (*arg2 != '=') {
- QAT_LOG(DEBUG, "parsing error '=' sign"
- " should immediately follow %s",
- param);
- arg2 = NULL;
- } else
- arg2++;
- } else {
- QAT_LOG(DEBUG, "%s not provided", param);
- }
- if (arg2) {
- int iter = 0;
- while (iter < 2) {
- if (!isdigit(*(arg2 + iter)))
- break;
- iter++;
- }
- if (!iter) {
- QAT_LOG(DEBUG, "parsing error %s"
- " no number provided",
- param);
- } else {
- memcpy(value_str, arg2, iter);
- value = strtol(value_str, NULL, 10);
- if (strcmp(param,
- SYM_CIPHER_CRC_ENABLE_NAME) == 0) {
- if (value < 0 || value > 1) {
- QAT_LOG(DEBUG, "The value for qat_sym_cipher_crc_enable should be set to 0 or 1, setting to 0");
- value = 0;
- }
- } else if (value > MAX_QP_THRESHOLD_SIZE) {
- QAT_LOG(DEBUG, "Exceeded max size of"
- " threshold, setting to %d",
- MAX_QP_THRESHOLD_SIZE);
- value = MAX_QP_THRESHOLD_SIZE;
- }
- QAT_LOG(DEBUG, "parsing %s = %ld",
- param, value);
- }
- }
- qat_dev_cmd_param[i].val = value;
- i++;
- }
-}
-
static enum qat_device_gen
pick_gen(const struct rte_pci_device *pci_dev)
{
@@ -231,9 +167,89 @@ wireless_slice_support(uint16_t pci_dev_id)
pci_dev_id == 0x4947;
}
-struct qat_pci_device *
-qat_pci_device_allocate(struct rte_pci_device *pci_dev,
- struct qat_dev_cmd_param *qat_dev_cmd_param)
+/* This function base on the atoi function peculiarity, non integral part
+ * other than the equals sign is ignored. It will not work with other conversion
+ * functions like strt*.
+ */
+char *qat_dev_cmdline_get_val(struct qat_pci_device *qat_dev,
+ const char *key)
+{
+ if (qat_dev->command_line == NULL)
+ return NULL;
+ key = strstr(qat_dev->command_line, key);
+ /* At this point, a key should be validated */
+ return key ? strchr(key, '=') + 1 : NULL;
+}
+
+static int cmdline_validate(const char *arg)
+{
+ int i, len;
+ char *eq_sign = strchr(arg, '=');
+ /* Check for the equal sign */
+ if (eq_sign == NULL) {
+ QAT_LOG(ERR, "malformed string, no equals sign, %s", arg);
+ return 0;
+ }
+ /* Check if an argument is not empty */
+ len = strlen(eq_sign) - 1;
+ if (len == 0) {
+ QAT_LOG(ERR, "malformed string, empty argument, %s", arg);
+ return 0;
+ }
+ len = eq_sign - arg;
+ for (i = 0; i < QAT_MAX_SERVICES + 1; i++) {
+ int j = 0;
+ const char *def = NULL;
+
+ if (!qat_cmdline_defines[i])
+ continue;
+ while ((def = qat_cmdline_defines[i][j++])) {
+ if (strncmp(def, arg, len))
+ continue;
+ QAT_LOG(DEBUG, "Found %s command line argument",
+ def);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int
+qat_dev_parse_command_line(struct qat_pci_device *qat_dev,
+ struct rte_devargs *devargs)
+{
+ int len = 0;
+ char *token = NULL;
+
+ if (!devargs)
+ return 0;
+
+ len = strlen(devargs->drv_str);
+ if (len == 0)
+ return 0;
+ /* Allocate per-device command line */
+ qat_dev->command_line = rte_malloc(NULL, len, 0);
+ if (qat_dev->command_line == NULL) {
+ QAT_LOG(ERR, "Cannot allocate memory for command line");
+ return -1;
+ }
+ strcpy(qat_dev->command_line, devargs->drv_str);
+ token = strtok(qat_dev->command_line, ",");
+ while (token != NULL) {
+ if (!cmdline_validate(token)) {
+ QAT_LOG(ERR, "Incorrect command line argument: %s",
+ token);
+ return -1;
+ }
+ token = strtok(NULL, ",");
+ }
+ /* Copy once againe the entire string, strtok already altered the contents */
+ strcpy(qat_dev->command_line, devargs->drv_str);
+ return 0;
+}
+
+static struct qat_pci_device *
+qat_pci_device_allocate(struct rte_pci_device *pci_dev)
{
struct qat_pci_device *qat_dev;
enum qat_device_gen qat_dev_gen;
@@ -244,6 +260,7 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev,
struct rte_mem_resource *mem_resource;
const struct rte_memzone *qat_dev_mz;
int qat_dev_size, extra_size;
+ char *cmdline = NULL;
rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
snprintf(name+strlen(name), QAT_DEV_NAME_MAX_LEN-strlen(name), "_qat");
@@ -324,8 +341,14 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev,
} else
qat_dev->misc_bar_io_addr = NULL;
- if (devargs && devargs->drv_str)
- qat_dev_parse_cmd(devargs->drv_str, qat_dev_cmd_param);
+ /* Parse the command line */
+ if (qat_dev_parse_command_line(qat_dev, devargs))
+ goto error;
+
+ /* Parse the arguments */
+ cmdline = qat_dev_cmdline_get_val(qat_dev, QAT_LEGACY_CAPA);
+ if (cmdline)
+ qat_legacy_capa = atoi(cmdline);
if (qat_read_qp_config(qat_dev)) {
QAT_LOG(ERR,
@@ -363,6 +386,7 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev,
return qat_dev;
error:
+ rte_free(qat_dev->command_line);
if (rte_memzone_free(qat_dev_mz)) {
QAT_LOG(DEBUG,
"QAT internal error! Trying to free already allocated memzone: %s",
@@ -434,27 +458,17 @@ static int qat_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
int sym_ret = 0, asym_ret = 0, comp_ret = 0;
int num_pmds_created = 0;
struct qat_pci_device *qat_pci_dev;
- struct qat_dev_cmd_param qat_dev_cmd_param[] = {
- { QAT_LEGACY_CAPA, 0 },
- { SYM_ENQ_THRESHOLD_NAME, 0 },
- { ASYM_ENQ_THRESHOLD_NAME, 0 },
- { COMP_ENQ_THRESHOLD_NAME, 0 },
- { SYM_CIPHER_CRC_ENABLE_NAME, 0 },
- [QAT_CMD_SLICE_MAP_POS] = { QAT_CMD_SLICE_MAP, 0},
- { NULL, 0 },
- };
QAT_LOG(DEBUG, "Found QAT device at %02x:%02x.%x",
pci_dev->addr.bus,
pci_dev->addr.devid,
pci_dev->addr.function);
- qat_pci_dev = qat_pci_device_allocate(pci_dev, qat_dev_cmd_param);
+ qat_pci_dev = qat_pci_device_allocate(pci_dev);
if (qat_pci_dev == NULL)
return -ENODEV;
- qat_dev_cmd_param[QAT_CMD_SLICE_MAP_POS].val = qat_pci_dev->slice_map;
- sym_ret = qat_sym_dev_create(qat_pci_dev, qat_dev_cmd_param);
+ sym_ret = qat_sym_dev_create(qat_pci_dev);
if (sym_ret == 0) {
num_pmds_created++;
}
@@ -463,7 +477,7 @@ static int qat_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
"Failed to create QAT SYM PMD on device %s",
qat_pci_dev->name);
- comp_ret = qat_comp_dev_create(qat_pci_dev, qat_dev_cmd_param);
+ comp_ret = qat_comp_dev_create(qat_pci_dev);
if (comp_ret == 0)
num_pmds_created++;
else
@@ -471,7 +485,7 @@ static int qat_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
"Failed to create QAT COMP PMD on device %s",
qat_pci_dev->name);
- asym_ret = qat_asym_dev_create(qat_pci_dev, qat_dev_cmd_param);
+ asym_ret = qat_asym_dev_create(qat_pci_dev);
if (asym_ret == 0)
num_pmds_created++;
else
@@ -508,15 +522,13 @@ static struct rte_pci_driver rte_qat_pmd = {
};
__rte_weak int
-qat_sym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused,
- struct qat_dev_cmd_param *qat_dev_cmd_param __rte_unused)
+qat_sym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused)
{
return 0;
}
__rte_weak int
-qat_asym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused,
- const struct qat_dev_cmd_param *qat_dev_cmd_param __rte_unused)
+qat_asym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused)
{
return 0;
}
@@ -534,8 +546,7 @@ qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused)
}
__rte_weak int
-qat_comp_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused,
- struct qat_dev_cmd_param *qat_dev_cmd_param __rte_unused)
+qat_comp_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused)
{
return 0;
}
diff --git a/drivers/common/qat/qat_device.h b/drivers/common/qat/qat_device.h
index 43e4752812..8d332e0d0b 100644
--- a/drivers/common/qat/qat_device.h
+++ b/drivers/common/qat/qat_device.h
@@ -16,15 +16,8 @@
#define QAT_ATTACHED (1)
#define QAT_DEV_NAME_MAX_LEN 64
-
-#define QAT_LEGACY_CAPA "qat_legacy_capa"
-#define SYM_ENQ_THRESHOLD_NAME "qat_sym_enq_threshold"
-#define ASYM_ENQ_THRESHOLD_NAME "qat_asym_enq_threshold"
-#define COMP_ENQ_THRESHOLD_NAME "qat_comp_enq_threshold"
-#define SYM_CIPHER_CRC_ENABLE_NAME "qat_sym_cipher_crc_enable"
-#define QAT_CMD_SLICE_MAP "qat_cmd_slice_disable"
-#define QAT_CMD_SLICE_MAP_POS 5
#define MAX_QP_THRESHOLD_SIZE 32
+#define QAT_LEGACY_CAPA "qat_legacy_capa"
/**
* Function prototypes for GENx specific device operations.
@@ -41,6 +34,9 @@ typedef int (*qat_dev_get_extra_size_t)(void);
typedef int (*qat_dev_get_slice_map_t)(uint32_t *map,
const struct rte_pci_device *pci_dev);
+extern int qat_legacy_capa;
+char *qat_dev_cmdline_get_val(struct qat_pci_device *qat_dev, const char *key);
+
struct qat_dev_hw_spec_funcs {
qat_dev_reset_ring_pairs_t qat_dev_reset_ring_pairs;
qat_dev_get_transport_bar_t qat_dev_get_transport_bar;
@@ -137,6 +133,8 @@ struct qat_pci_device {
/**< Map of the crypto and compression slices */
uint16_t has_wireless_slice;
/**< Wireless Slices supported */
+ char *command_line;
+ /**< Map of the crypto and compression slices */
};
struct qat_gen_hw_data {
@@ -157,20 +155,14 @@ struct qat_pf2vf_dev {
extern struct qat_gen_hw_data qat_gen_config[];
struct qat_pci_device *
-qat_pci_device_allocate(struct rte_pci_device *pci_dev,
- struct qat_dev_cmd_param *qat_dev_cmd_param);
-
-struct qat_pci_device *
qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev);
/* declaration needed for weak functions */
int
-qat_sym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused,
- struct qat_dev_cmd_param *qat_dev_cmd_param);
+qat_sym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused);
int
-qat_asym_dev_create(struct qat_pci_device *qat_pci_dev,
- const struct qat_dev_cmd_param *qat_dev_cmd_param);
+qat_asym_dev_create(struct qat_pci_device *qat_pci_dev);
int
qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
@@ -179,8 +171,7 @@ int
qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
int
-qat_comp_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused,
- struct qat_dev_cmd_param *qat_dev_cmd_param);
+qat_comp_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused);
int
qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
diff --git a/drivers/compress/qat/qat_comp_pmd.c b/drivers/compress/qat/qat_comp_pmd.c
index 815276fc9e..4b24929a70 100644
--- a/drivers/compress/qat/qat_comp_pmd.c
+++ b/drivers/compress/qat/qat_comp_pmd.c
@@ -9,6 +9,13 @@
#define QAT_PMD_COMP_SGL_DEF_SEGMENTS 16
+#define COMP_ENQ_THRESHOLD_NAME "qat_comp_enq_threshold"
+
+static const char *const arguments[] = {
+ COMP_ENQ_THRESHOLD_NAME,
+ NULL
+};
+
struct qat_comp_gen_dev_ops qat_comp_gen_dev_ops[QAT_N_GENS];
struct stream_create_info {
@@ -663,10 +670,8 @@ static const struct rte_driver compdev_qat_driver = {
};
int
-qat_comp_dev_create(struct qat_pci_device *qat_pci_dev,
- struct qat_dev_cmd_param *qat_dev_cmd_param)
+qat_comp_dev_create(struct qat_pci_device *qat_pci_dev)
{
- int i = 0;
struct qat_device_info *qat_dev_instance =
&qat_pci_devs[qat_pci_dev->qat_dev_id];
struct rte_compressdev_pmd_init_params init_params = {
@@ -683,6 +688,7 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev,
&qat_comp_gen_dev_ops[qat_pci_dev->qat_dev_gen];
uint64_t capa_size;
uint16_t sub_id = qat_dev_instance->pci_dev->id.subsystem_device_id;
+ char *cmdline = NULL;
snprintf(name, RTE_COMPRESSDEV_NAME_MAX_LEN, "%s_%s",
qat_pci_dev->name, "comp");
@@ -765,13 +771,13 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev,
memcpy(comp_dev->capa_mz->addr, capabilities, capa_size);
comp_dev->qat_dev_capabilities = comp_dev->capa_mz->addr;
- while (1) {
- if (qat_dev_cmd_param[i].name == NULL)
- break;
- if (!strcmp(qat_dev_cmd_param[i].name, COMP_ENQ_THRESHOLD_NAME))
- comp_dev->min_enq_burst_threshold =
- qat_dev_cmd_param[i].val;
- i++;
+ cmdline = qat_dev_cmdline_get_val(qat_pci_dev,
+ COMP_ENQ_THRESHOLD_NAME);
+ if (cmdline) {
+ comp_dev->min_enq_burst_threshold =
+ atoi(cmdline) > MAX_QP_THRESHOLD_SIZE ?
+ MAX_QP_THRESHOLD_SIZE :
+ atoi(cmdline);
}
qat_pci_dev->comp_dev = comp_dev;
@@ -804,3 +810,8 @@ qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev)
return 0;
}
+
+RTE_INIT(qat_sym_init)
+{
+ qat_cmdline_defines[QAT_SERVICE_COMPRESSION] = arguments;
+}
diff --git a/drivers/compress/qat/qat_comp_pmd.h b/drivers/compress/qat/qat_comp_pmd.h
index 3c8682a768..1f5b0facf7 100644
--- a/drivers/compress/qat/qat_comp_pmd.h
+++ b/drivers/compress/qat/qat_comp_pmd.h
@@ -107,8 +107,7 @@ qat_comp_setup_inter_buffers(struct qat_comp_dev_private *comp_dev,
uint32_t buff_size);
int
-qat_comp_dev_create(struct qat_pci_device *qat_pci_dev,
- struct qat_dev_cmd_param *qat_dev_cmd_param);
+qat_comp_dev_create(struct qat_pci_device *qat_pci_dev);
int
qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev);
diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index d96eb7ec6d..7d01ad503b 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -15,12 +15,19 @@
#include "qat_pke.h"
#include "qat_ec.h"
+#define ASYM_ENQ_THRESHOLD_NAME "qat_asym_enq_threshold"
#define RSA_MODULUS_2048_BITS 2048
uint8_t qat_asym_driver_id;
struct qat_crypto_gen_dev_ops qat_asym_gen_dev_ops[QAT_N_GENS];
+
+static const char *const arguments[] = {
+ ASYM_ENQ_THRESHOLD_NAME,
+ NULL
+};
+
/* An rte_driver is needed in the registration of both the device and the driver
* with cryptodev.
* The actual qat pci's rte_driver can't be used as its name represents
@@ -1499,8 +1506,7 @@ qat_asym_init_op_cookie(void *op_cookie)
}
int
-qat_asym_dev_create(struct qat_pci_device *qat_pci_dev,
- const struct qat_dev_cmd_param *qat_dev_cmd_param)
+qat_asym_dev_create(struct qat_pci_device *qat_pci_dev)
{
struct qat_cryptodev_private *internals;
struct rte_cryptodev *cryptodev;
@@ -1515,9 +1521,8 @@ qat_asym_dev_create(struct qat_pci_device *qat_pci_dev,
&qat_asym_gen_dev_ops[qat_pci_dev->qat_dev_gen];
char name[RTE_CRYPTODEV_NAME_MAX_LEN];
char capa_memz_name[RTE_CRYPTODEV_NAME_MAX_LEN];
- int i = 0;
- uint16_t slice_map = 0;
uint16_t sub_id = qat_dev_instance->pci_dev->id.subsystem_device_id;
+ char *cmdline = NULL;
snprintf(name, RTE_CRYPTODEV_NAME_MAX_LEN, "%s_%s",
qat_pci_dev->name, "asym");
@@ -1580,18 +1585,16 @@ qat_asym_dev_create(struct qat_pci_device *qat_pci_dev,
internals->qat_dev = qat_pci_dev;
internals->dev_id = cryptodev->data->dev_id;
- while (1) {
- if (qat_dev_cmd_param[i].name == NULL)
- break;
- if (!strcmp(qat_dev_cmd_param[i].name, ASYM_ENQ_THRESHOLD_NAME))
- internals->min_enq_burst_threshold =
- qat_dev_cmd_param[i].val;
- if (!strcmp(qat_dev_cmd_param[i].name, QAT_CMD_SLICE_MAP))
- slice_map = qat_dev_cmd_param[i].val;
- i++;
+ cmdline = qat_dev_cmdline_get_val(qat_pci_dev,
+ ASYM_ENQ_THRESHOLD_NAME);
+ if (cmdline) {
+ internals->min_enq_burst_threshold =
+ atoi(cmdline) > MAX_QP_THRESHOLD_SIZE ?
+ MAX_QP_THRESHOLD_SIZE :
+ atoi(cmdline);
}
- if (slice_map & ICP_ACCEL_MASK_PKE_SLICE) {
+ if (qat_pci_dev->slice_map & ICP_ACCEL_MASK_PKE_SLICE) {
QAT_LOG(ERR, "Device %s does not support PKE slice",
name);
rte_cryptodev_pmd_destroy(cryptodev);
@@ -1601,7 +1604,7 @@ qat_asym_dev_create(struct qat_pci_device *qat_pci_dev,
}
if (gen_dev_ops->get_capabilities(internals,
- capa_memz_name, slice_map) < 0) {
+ capa_memz_name, qat_pci_dev->slice_map) < 0) {
QAT_LOG(ERR,
"Device cannot obtain capabilities, destroying PMD for %s",
name);
@@ -1644,3 +1647,8 @@ static struct cryptodev_driver qat_crypto_drv;
RTE_PMD_REGISTER_CRYPTO_DRIVER(qat_crypto_drv,
cryptodev_qat_asym_driver,
qat_asym_driver_id);
+
+RTE_INIT(qat_asym_init)
+{
+ qat_cmdline_defines[QAT_SERVICE_ASYMMETRIC] = arguments;
+}
diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
index 3bf6ce8a75..2d7c737de7 100644
--- a/drivers/crypto/qat/qat_sym.c
+++ b/drivers/crypto/qat/qat_sym.c
@@ -13,6 +13,7 @@
#include <rte_byteorder.h>
#include <rte_security_driver.h>
+#include "qat_common.h"
#include "qat_sym.h"
#include "qat_crypto.h"
#include "qat_qp.h"
@@ -20,6 +21,15 @@
uint8_t qat_sym_driver_id;
int qat_legacy_capa;
+#define SYM_ENQ_THRESHOLD_NAME "qat_sym_enq_threshold"
+#define SYM_CIPHER_CRC_ENABLE_NAME "qat_sym_cipher_crc_enable"
+
+static const char *const arguments[] = {
+ SYM_ENQ_THRESHOLD_NAME,
+ SYM_CIPHER_CRC_ENABLE_NAME,
+ NULL
+};
+
struct qat_crypto_gen_dev_ops qat_sym_gen_dev_ops[QAT_N_GENS];
/* An rte_driver is needed in the registration of both the device and the driver
@@ -190,11 +200,9 @@ qat_sym_dequeue_burst_gen_lce(void *qp, struct rte_crypto_op **ops, uint16_t nb_
}
int
-qat_sym_dev_create(struct qat_pci_device *qat_pci_dev,
- struct qat_dev_cmd_param *qat_dev_cmd_param)
+qat_sym_dev_create(struct qat_pci_device *qat_pci_dev)
{
- int i = 0, ret = 0;
- uint16_t slice_map = 0;
+ int ret = 0;
struct qat_device_info *qat_dev_instance =
&qat_pci_devs[qat_pci_dev->qat_dev_id];
struct rte_cryptodev_pmd_init_params init_params = {
@@ -210,6 +218,7 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev,
const struct qat_crypto_gen_dev_ops *gen_dev_ops =
&qat_sym_gen_dev_ops[qat_pci_dev->qat_dev_gen];
uint16_t sub_id = qat_dev_instance->pci_dev->id.subsystem_device_id;
+ char *cmdline = NULL;
snprintf(name, RTE_CRYPTODEV_NAME_MAX_LEN, "%s_%s",
qat_pci_dev->name, "sym");
@@ -293,26 +302,23 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev,
internals = cryptodev->data->dev_private;
internals->qat_dev = qat_pci_dev;
-
internals->dev_id = cryptodev->data->dev_id;
- while (qat_dev_cmd_param[i].name != NULL) {
- if (!strcmp(qat_dev_cmd_param[i].name, SYM_ENQ_THRESHOLD_NAME))
- internals->min_enq_burst_threshold =
- qat_dev_cmd_param[i].val;
- if (!strcmp(qat_dev_cmd_param[i].name,
- SYM_CIPHER_CRC_ENABLE_NAME))
- internals->cipher_crc_offload_enable =
- qat_dev_cmd_param[i].val;
- if (!strcmp(qat_dev_cmd_param[i].name, QAT_LEGACY_CAPA))
- qat_legacy_capa = qat_dev_cmd_param[i].val;
- if (!strcmp(qat_dev_cmd_param[i].name, QAT_CMD_SLICE_MAP))
- slice_map = qat_dev_cmd_param[i].val;
- i++;
+ cmdline = qat_dev_cmdline_get_val(qat_pci_dev,
+ SYM_ENQ_THRESHOLD_NAME);
+ if (cmdline) {
+ internals->min_enq_burst_threshold =
+ atoi(cmdline) > MAX_QP_THRESHOLD_SIZE ?
+ MAX_QP_THRESHOLD_SIZE :
+ atoi(cmdline);
}
+ cmdline = qat_dev_cmdline_get_val(qat_pci_dev,
+ SYM_CIPHER_CRC_ENABLE_NAME);
+ if (cmdline)
+ internals->cipher_crc_offload_enable = atoi(cmdline);
if (gen_dev_ops->get_capabilities(internals,
- capa_memz_name, slice_map) < 0) {
+ capa_memz_name, qat_pci_dev->slice_map) < 0) {
QAT_LOG(ERR,
"Device cannot obtain capabilities, destroying PMD for %s",
name);
@@ -411,3 +417,8 @@ static struct cryptodev_driver qat_crypto_drv;
RTE_PMD_REGISTER_CRYPTO_DRIVER(qat_crypto_drv,
cryptodev_qat_sym_driver,
qat_sym_driver_id);
+
+RTE_INIT(qat_sym_init)
+{
+ qat_cmdline_defines[QAT_SERVICE_SYMMETRIC] = arguments;
+}
--
2.13.6
next prev parent reply other threads:[~2024-03-01 15:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <v4-00020240229093007.32298-1-arkadiuszx.kusztal@intel.com>
2024-02-29 19:14 ` [PATCH v4 " Arkadiusz Kusztal
2024-02-29 19:14 ` [PATCH v4 2/3] common/qat: decouple pmds from the common code Arkadiusz Kusztal
2024-02-29 19:14 ` [PATCH v4 3/3] common/qat: fix incorrectly placed legacy flag Arkadiusz Kusztal
2024-02-29 19:19 ` [EXTERNAL] [PATCH v4 1/3] common/qat: isolate parser arguments configuration Akhil Goyal
2024-03-01 15:52 ` Arkadiusz Kusztal [this message]
2024-03-01 15:52 ` [PATCH v5 2/3] common/qat: decouple pmds from the common code Arkadiusz Kusztal
2024-03-01 16:08 ` Dooley, Brian
2024-03-01 15:52 ` [PATCH v5 3/3] common/qat: fix incorrectly placed legacy flag Arkadiusz Kusztal
2024-03-01 16:08 ` Dooley, Brian
2024-03-04 7:10 ` Akhil Goyal
2024-03-01 16:07 ` [PATCH v5 1/3] common/qat: isolate parser arguments configuration Dooley, Brian
2024-03-04 7:08 ` [EXTERNAL] " Akhil Goyal
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=20240301155251.5101-1-arkadiuszx.kusztal@intel.com \
--to=arkadiuszx.kusztal@intel.com \
--cc=ciara.power@intel.com \
--cc=dev@dpdk.org \
--cc=gakhil@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).