From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2730743B8D; Thu, 29 Feb 2024 20:14:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5DC542D78; Thu, 29 Feb 2024 20:14:35 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by mails.dpdk.org (Postfix) with ESMTP id 2C8F9402ED for ; Thu, 29 Feb 2024 20:14:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709234074; x=1740770074; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=woyEy/juZZTC98hCvtzCt9ajolNBkDr7nQ0YYwvEzk0=; b=c0AvxXOwjTO05NA76hqSHRDse7ogEiAXliKHGkANqnHVLvPiTYmBiwM2 yyrDtI1toit6voSjH4//+rbD80CPlaoy8T51+uS9cX3Wea9bjuOK6O1I7 7RlUdgI6HyrAzz0M/RXFMbO0PiclFCHg+TWl+HP0rstL69bzv7kQjP4hE vnIXShFkGN2Vu7fJOlN6uJmRAA9AE1q5mnGsqsWV6weuZ87ZIBVfhQPuI l0VV7RxV1kxYaEZmHzSg5OeUoK9Cdb5+JWyON4uHXkVCXFP5PL7f4bUXG dAxzNhxSql35G3VDZbxUxNT1M88+ifk/7B8YTDxzEqOABYuSbMkGYjKfo w==; X-IronPort-AV: E=McAfee;i="6600,9927,10999"; a="3580501" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="3580501" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 11:14:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="12619562" Received: from silpixa00400308.ir.intel.com ([10.237.214.154]) by orviesa005.jf.intel.com with ESMTP; 29 Feb 2024 11:14:31 -0800 From: Arkadiusz Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, ciara.power@intel.com, Arkadiusz Kusztal Subject: [PATCH v4 1/3] common/qat: isolate parser arguments configuration Date: Thu, 29 Feb 2024 19:14:25 +0000 Message-Id: <20240229191427.1267-1-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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-137466 ("common/qat: add virtual qat device (vQAT)") Signed-off-by: Arkadiusz Kusztal --- v2: - added pmd isolation v3: - added fix for legacy flag v4: - fixed an issue with devargs segfault 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 53799ce174..7425600506 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 a9ea4af5df..6c5b81acc2 100644 --- a/drivers/common/qat/qat_device.c +++ b/drivers/common/qat/qat_device.c @@ -121,70 +121,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) { @@ -210,9 +146,89 @@ pick_gen(const struct rte_pci_device *pci_dev) } } -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 ingored. 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; @@ -223,6 +239,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"); @@ -300,8 +317,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, @@ -339,6 +362,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", @@ -410,27 +434,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++; } @@ -439,7 +453,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 @@ -447,7 +461,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 @@ -484,15 +498,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; } @@ -510,8 +522,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 aa7988bb74..f0f2f61c04 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; @@ -135,6 +131,8 @@ struct qat_pci_device { /**< Per generation specific information */ uint32_t slice_map; /**< Map of the crypto and compression slices */ + char *command_line; + /**< Map of the crypto and compression slices */ }; struct qat_gen_hw_data { @@ -155,20 +153,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); @@ -177,8 +169,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 6301fdec0e..d23e876368 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -13,6 +13,7 @@ #include #include +#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 @@ -184,11 +194,9 @@ qat_sym_dequeue_burst(void *qp, struct rte_crypto_op **ops, } 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 = { @@ -203,6 +211,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"); @@ -283,26 +292,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); @@ -401,3 +407,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