* [PATCH v4 1/3] common/qat: isolate parser arguments configuration [not found] <v4-00020240229093007.32298-1-arkadiuszx.kusztal@intel.com> @ 2024-02-29 19:14 ` Arkadiusz Kusztal 2024-02-29 19:14 ` [PATCH v4 2/3] common/qat: decouple pmds from the common code Arkadiusz Kusztal ` (3 more replies) 0 siblings, 4 replies; 12+ messages in thread From: Arkadiusz Kusztal @ 2024-02-29 19:14 UTC (permalink / raw) To: dev; +Cc: gakhil, ciara.power, Arkadiusz Kusztal 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 <arkadiuszx.kusztal@intel.com> --- 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 <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 @@ -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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v4 2/3] common/qat: decouple pmds from the common code 2024-02-29 19:14 ` [PATCH v4 1/3] common/qat: isolate parser arguments configuration Arkadiusz Kusztal @ 2024-02-29 19:14 ` Arkadiusz Kusztal 2024-02-29 19:14 ` [PATCH v4 3/3] common/qat: fix incorrectly placed legacy flag Arkadiusz Kusztal ` (2 subsequent siblings) 3 siblings, 0 replies; 12+ messages in thread From: Arkadiusz Kusztal @ 2024-02-29 19:14 UTC (permalink / raw) To: dev; +Cc: gakhil, ciara.power, Arkadiusz Kusztal Service specific functions were moved to services files. Weak symbols for device create/destroy were removed, named private devs were replaced by an opaque array. Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com> --- drivers/common/qat/qat_device.c | 112 ++++++++++-------------------------- drivers/common/qat/qat_device.h | 47 ++++----------- drivers/compress/qat/qat_comp_pmd.c | 34 +++++------ drivers/compress/qat/qat_comp_pmd.h | 7 --- drivers/crypto/qat/qat_asym.c | 20 ++++--- drivers/crypto/qat/qat_sym.c | 19 +++--- 6 files changed, 83 insertions(+), 156 deletions(-) diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c index 6c5b81acc2..dab34dbcd5 100644 --- a/drivers/common/qat/qat_device.c +++ b/drivers/common/qat/qat_device.c @@ -26,6 +26,8 @@ struct qat_gen_hw_data qat_gen_config[QAT_N_GENS]; struct qat_dev_hw_spec_funcs *qat_dev_hw_spec[QAT_N_GENS]; +struct qat_service qat_service[QAT_MAX_SERVICES]; + /* per-process array of device data */ struct qat_device_info qat_pci_devs[RTE_PMD_QAT_MAX_PCI_DEVICES]; static int qat_nb_pci_devices; @@ -111,7 +113,7 @@ qat_pci_find_free_device_index(void) return dev_id; } -struct qat_pci_device * +static struct qat_pci_device * qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev) { char name[QAT_DEV_NAME_MAX_LEN]; @@ -287,7 +289,8 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev) return NULL; } - qat_dev_size = sizeof(struct qat_pci_device) + extra_size; + qat_dev_size = sizeof(struct qat_pci_device) + sizeof(void *) * + QAT_MAX_SERVICES + extra_size; qat_dev_mz = rte_memzone_reserve(name, qat_dev_size, rte_socket_id(), 0); @@ -376,7 +379,7 @@ qat_pci_device_release(struct rte_pci_device *pci_dev) { struct qat_pci_device *qat_dev; char name[QAT_DEV_NAME_MAX_LEN]; - int busy = 0; + int busy = 0, i; if (pci_dev == NULL) return -EINVAL; @@ -391,24 +394,16 @@ qat_pci_device_release(struct rte_pci_device *pci_dev) /* Check that there are no service devs still on pci device */ if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - if (qat_dev->sym_dev != NULL) { - QAT_LOG(DEBUG, "QAT sym device %s is busy", - name); - busy = 1; - } - if (qat_dev->asym_dev != NULL) { - QAT_LOG(DEBUG, "QAT asym device %s is busy", - name); - busy = 1; - } - if (qat_dev->comp_dev != NULL) { - QAT_LOG(DEBUG, "QAT comp device %s is busy", - name); + for (i = 0; i < QAT_MAX_SERVICES; i++) { + if (qat_dev->pmd[i] == NULL) + continue; + QAT_LOG(DEBUG, "QAT %s device %s is busy", + qat_service[i].name, name); busy = 1; - } if (busy) return -EBUSY; rte_memzone_free(inst->mz); + } } memset(inst, 0, sizeof(struct qat_device_info)); qat_nb_pci_devices--; @@ -422,17 +417,20 @@ static int qat_pci_dev_destroy(struct qat_pci_device *qat_pci_dev, struct rte_pci_device *pci_dev) { - qat_sym_dev_destroy(qat_pci_dev); - qat_comp_dev_destroy(qat_pci_dev); - qat_asym_dev_destroy(qat_pci_dev); + int i; + + for (i = 0; i < QAT_MAX_SERVICES; i++) { + if (!qat_service[i].dev_create) + continue; + qat_service[i].dev_destroy(qat_pci_dev); + } return qat_pci_device_release(pci_dev); } static int qat_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) { - int sym_ret = 0, asym_ret = 0, comp_ret = 0; - int num_pmds_created = 0; + int i, ret = 0, num_pmds_created = 0; struct qat_pci_device *qat_pci_dev; QAT_LOG(DEBUG, "Found QAT device at %02x:%02x.%x", @@ -444,30 +442,18 @@ static int qat_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, if (qat_pci_dev == NULL) return -ENODEV; - sym_ret = qat_sym_dev_create(qat_pci_dev); - if (sym_ret == 0) { - num_pmds_created++; - } - else - QAT_LOG(WARNING, - "Failed to create QAT SYM PMD on device %s", - qat_pci_dev->name); - - comp_ret = qat_comp_dev_create(qat_pci_dev); - if (comp_ret == 0) - num_pmds_created++; - else - QAT_LOG(WARNING, - "Failed to create QAT COMP PMD on device %s", - qat_pci_dev->name); - - asym_ret = qat_asym_dev_create(qat_pci_dev); - if (asym_ret == 0) - num_pmds_created++; - else - QAT_LOG(WARNING, - "Failed to create QAT ASYM PMD on device %s", + for (i = 0; i < QAT_MAX_SERVICES; i++) { + if (!qat_service[i].dev_create) + continue; + ret = qat_service[i].dev_create(qat_pci_dev); + if (ret == 0) + num_pmds_created++; + else { + QAT_LOG(WARNING, "Failed to create %s PMD on device %s", + qat_service[i].name, qat_pci_dev->name); + } + } if (num_pmds_created == 0) qat_pci_dev_destroy(qat_pci_dev, pci_dev); @@ -497,42 +483,6 @@ static struct rte_pci_driver rte_qat_pmd = { .remove = qat_pci_remove }; -__rte_weak int -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) -{ - return 0; -} - -__rte_weak int -qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused) -{ - return 0; -} - -__rte_weak int -qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused) -{ - return 0; -} - -__rte_weak int -qat_comp_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused) -{ - return 0; -} - -__rte_weak int -qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused) -{ - return 0; -} - RTE_PMD_REGISTER_PCI(QAT_PCI_NAME, rte_qat_pmd); RTE_PMD_REGISTER_PCI_TABLE(QAT_PCI_NAME, pci_id_qat_map); RTE_PMD_REGISTER_KMOD_DEP(QAT_PCI_NAME, "* igb_uio | uio_pci_generic | vfio-pci"); diff --git a/drivers/common/qat/qat_device.h b/drivers/common/qat/qat_device.h index f0f2f61c04..ec25e1d78b 100644 --- a/drivers/common/qat/qat_device.h +++ b/drivers/common/qat/qat_device.h @@ -19,6 +19,14 @@ #define MAX_QP_THRESHOLD_SIZE 32 #define QAT_LEGACY_CAPA "qat_legacy_capa" +struct qat_service { + const char *name; + int (*dev_create)(struct qat_pci_device *qat_pci_dev); + int (*dev_destroy)(struct qat_pci_device *qat_pci_dev); +}; + +extern struct qat_service qat_service[]; + /** * Function prototypes for GENx specific device operations. **/ @@ -104,27 +112,12 @@ struct qat_pci_device { /**< QAT device generation */ rte_spinlock_t arb_csr_lock; /**< lock to protect accesses to the arbiter CSR */ - struct qat_qp *qps_in_use[QAT_MAX_SERVICES][ADF_MAX_QPS_ON_ANY_SERVICE]; /**< links to qps set up for each service, index same as on API */ - - /* Data relating to symmetric crypto service */ - struct qat_cryptodev_private *sym_dev; - /**< link back to cryptodev private data */ - int qat_sym_driver_id; /**< Symmetric driver id used by this device */ - - /* Data relating to asymmetric crypto service */ - struct qat_cryptodev_private *asym_dev; - /**< link back to cryptodev private data */ - int qat_asym_driver_id; /**< Symmetric driver id used by this device */ - - /* Data relating to compression service */ - struct qat_comp_dev_private *comp_dev; - /**< link back to compressdev private data */ void *misc_bar_io_addr; /**< Address of misc bar */ void *dev_private; @@ -133,6 +126,8 @@ struct qat_pci_device { /**< Map of the crypto and compression slices */ char *command_line; /**< Map of the crypto and compression slices */ + void *pmd[QAT_MAX_SERVICES]; + /**< link back to pmd private data */ }; struct qat_gen_hw_data { @@ -152,26 +147,4 @@ struct qat_pf2vf_dev { extern struct qat_gen_hw_data qat_gen_config[]; -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); - -int -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); - -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); - -int -qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused); - #endif /* _QAT_DEVICE_H_ */ diff --git a/drivers/compress/qat/qat_comp_pmd.c b/drivers/compress/qat/qat_comp_pmd.c index 4b24929a70..c5f7c7dc67 100644 --- a/drivers/compress/qat/qat_comp_pmd.c +++ b/drivers/compress/qat/qat_comp_pmd.c @@ -636,22 +636,24 @@ qat_comp_pmd_dequeue_first_op_burst(void *qp, struct rte_comp_op **ops, { uint16_t ret = qat_comp_dequeue_burst(qp, ops, nb_ops); struct qat_qp *tmp_qp = (struct qat_qp *)qp; + struct qat_comp_dev_private *dev = + tmp_qp->qat_dev->pmd[QAT_SERVICE_COMPRESSION]; if (ret) { if ((*ops)->debug_status == (uint64_t)ERR_CODE_QAT_COMP_WRONG_FW) { - tmp_qp->qat_dev->comp_dev->compressdev->enqueue_burst = + dev->compressdev->enqueue_burst = qat_comp_pmd_enq_deq_dummy_op_burst; - tmp_qp->qat_dev->comp_dev->compressdev->dequeue_burst = + dev->compressdev->dequeue_burst = qat_comp_pmd_enq_deq_dummy_op_burst; - tmp_qp->qat_dev->comp_dev->compressdev->dev_ops = + dev->compressdev->dev_ops = &compress_qat_dummy_ops; QAT_LOG(ERR, "This QAT hardware doesn't support compression operation"); } else { - tmp_qp->qat_dev->comp_dev->compressdev->dequeue_burst = + dev->compressdev->dequeue_burst = qat_comp_dequeue_burst; } } @@ -669,7 +671,7 @@ static const struct rte_driver compdev_qat_driver = { .alias = qat_comp_drv_name }; -int +static int qat_comp_dev_create(struct qat_pci_device *qat_pci_dev) { struct qat_device_info *qat_dev_instance = @@ -779,7 +781,7 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev) MAX_QP_THRESHOLD_SIZE : atoi(cmdline); } - qat_pci_dev->comp_dev = comp_dev; + qat_pci_dev->pmd[QAT_SERVICE_COMPRESSION] = comp_dev; QAT_LOG(DEBUG, "Created QAT COMP device %s as compressdev instance %d", @@ -787,26 +789,23 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev) return 0; } -int +static int qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev) { - struct qat_comp_dev_private *comp_dev; + struct qat_comp_dev_private *dev = + qat_pci_dev->pmd[QAT_SERVICE_COMPRESSION]; if (qat_pci_dev == NULL) return -ENODEV; - comp_dev = qat_pci_dev->comp_dev; - if (comp_dev == NULL) - return 0; - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_memzone_free(qat_pci_dev->comp_dev->capa_mz); + rte_memzone_free(dev->capa_mz); /* clean up any resources used by the device */ - qat_comp_dev_close(comp_dev->compressdev); + qat_comp_dev_close(dev->compressdev); - rte_compressdev_pmd_destroy(comp_dev->compressdev); - qat_pci_dev->comp_dev = NULL; + rte_compressdev_pmd_destroy(dev->compressdev); + qat_pci_dev->pmd[QAT_SERVICE_COMPRESSION] = NULL; return 0; } @@ -814,4 +813,7 @@ qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev) RTE_INIT(qat_sym_init) { qat_cmdline_defines[QAT_SERVICE_COMPRESSION] = arguments; + qat_service[QAT_SERVICE_COMPRESSION].name = "symmetric crypto"; + qat_service[QAT_SERVICE_COMPRESSION].dev_create = qat_comp_dev_create; + qat_service[QAT_SERVICE_COMPRESSION].dev_destroy = qat_comp_dev_destroy; } diff --git a/drivers/compress/qat/qat_comp_pmd.h b/drivers/compress/qat/qat_comp_pmd.h index 1f5b0facf7..01a8983287 100644 --- a/drivers/compress/qat/qat_comp_pmd.h +++ b/drivers/compress/qat/qat_comp_pmd.h @@ -106,13 +106,6 @@ const struct rte_memzone * 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); - -int -qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev); - - static __rte_always_inline unsigned int qat_comp_get_num_im_bufs_required(enum qat_device_gen gen) { diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c index 7d01ad503b..8ec9f65156 100644 --- a/drivers/crypto/qat/qat_asym.c +++ b/drivers/crypto/qat/qat_asym.c @@ -1505,7 +1505,7 @@ qat_asym_init_op_cookie(void *op_cookie) } } -int +static int qat_asym_dev_create(struct qat_pci_device *qat_pci_dev) { struct qat_cryptodev_private *internals; @@ -1614,31 +1614,32 @@ qat_asym_dev_create(struct qat_pci_device *qat_pci_dev) return -1; } - qat_pci_dev->asym_dev = internals; + qat_pci_dev->pmd[QAT_SERVICE_ASYMMETRIC] = internals; internals->service_type = QAT_SERVICE_ASYMMETRIC; QAT_LOG(DEBUG, "Created QAT ASYM device %s as cryptodev instance %d", cryptodev->data->name, internals->dev_id); return 0; } -int +static int qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev) { struct rte_cryptodev *cryptodev; + struct qat_cryptodev_private *dev = + qat_pci_dev->pmd[QAT_SERVICE_ASYMMETRIC]; if (qat_pci_dev == NULL) return -ENODEV; - if (qat_pci_dev->asym_dev == NULL) + if (dev == NULL) return 0; if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_memzone_free(qat_pci_dev->asym_dev->capa_mz); + rte_memzone_free(dev->capa_mz); /* free crypto device */ - cryptodev = rte_cryptodev_pmd_get_dev( - qat_pci_dev->asym_dev->dev_id); + cryptodev = rte_cryptodev_pmd_get_dev(dev->dev_id); rte_cryptodev_pmd_destroy(cryptodev); qat_pci_devs[qat_pci_dev->qat_dev_id].asym_rte_dev.name = NULL; - qat_pci_dev->asym_dev = NULL; + qat_pci_dev->pmd[QAT_SERVICE_ASYMMETRIC] = NULL; return 0; } @@ -1651,4 +1652,7 @@ RTE_PMD_REGISTER_CRYPTO_DRIVER(qat_crypto_drv, RTE_INIT(qat_asym_init) { qat_cmdline_defines[QAT_SERVICE_ASYMMETRIC] = arguments; + qat_service[QAT_SERVICE_ASYMMETRIC].name = "asymmetric crypto"; + qat_service[QAT_SERVICE_ASYMMETRIC].dev_create = qat_asym_dev_create; + qat_service[QAT_SERVICE_ASYMMETRIC].dev_destroy = qat_asym_dev_destroy; } diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index d23e876368..ac16051b19 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -193,7 +193,7 @@ qat_sym_dequeue_burst(void *qp, struct rte_crypto_op **ops, qat_sym_process_response, nb_ops); } -int +static int qat_sym_dev_create(struct qat_pci_device *qat_pci_dev) { int ret = 0; @@ -316,7 +316,7 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev) goto error; } internals->service_type = QAT_SERVICE_SYMMETRIC; - qat_pci_dev->sym_dev = internals; + qat_pci_dev->pmd[QAT_SERVICE_SYMMETRIC] = internals; QAT_LOG(DEBUG, "Created QAT SYM device %s as cryptodev instance %d", cryptodev->data->name, internals->dev_id); @@ -332,25 +332,27 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev) return ret; } -int +static int qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev) { struct rte_cryptodev *cryptodev; + struct qat_cryptodev_private *dev = + qat_pci_dev->pmd[QAT_SERVICE_SYMMETRIC]; if (qat_pci_dev == NULL) return -ENODEV; - if (qat_pci_dev->sym_dev == NULL) + if (dev == NULL) return 0; if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_memzone_free(qat_pci_dev->sym_dev->capa_mz); + rte_memzone_free(dev->capa_mz); /* free crypto device */ - cryptodev = rte_cryptodev_pmd_get_dev(qat_pci_dev->sym_dev->dev_id); + cryptodev = rte_cryptodev_pmd_get_dev(dev->dev_id); rte_free(cryptodev->security_ctx); cryptodev->security_ctx = NULL; rte_cryptodev_pmd_destroy(cryptodev); qat_pci_devs[qat_pci_dev->qat_dev_id].sym_rte_dev.name = NULL; - qat_pci_dev->sym_dev = NULL; + qat_pci_dev->pmd[QAT_SERVICE_SYMMETRIC] = NULL; return 0; } @@ -411,4 +413,7 @@ RTE_PMD_REGISTER_CRYPTO_DRIVER(qat_crypto_drv, RTE_INIT(qat_sym_init) { qat_cmdline_defines[QAT_SERVICE_SYMMETRIC] = arguments; + qat_service[QAT_SERVICE_SYMMETRIC].name = "symmetric crypto"; + qat_service[QAT_SERVICE_SYMMETRIC].dev_create = qat_sym_dev_create; + qat_service[QAT_SERVICE_SYMMETRIC].dev_destroy = qat_sym_dev_destroy; } -- 2.13.6 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v4 3/3] common/qat: fix incorrectly placed legacy flag 2024-02-29 19:14 ` [PATCH v4 1/3] common/qat: isolate parser arguments configuration 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 ` 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 ` [PATCH v5 " Arkadiusz Kusztal 3 siblings, 0 replies; 12+ messages in thread From: Arkadiusz Kusztal @ 2024-02-29 19:14 UTC (permalink / raw) To: dev; +Cc: gakhil, ciara.power, Arkadiusz Kusztal, vikash.chandrax.poddar This commit fixes a legacy flag, which was placed in a file that may not be included in a building process. Fixes: cffb726b7797 ("crypto/qat: enable insecure algorithms") Cc: vikash.chandrax.poddar@intel.com Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com> --- drivers/common/qat/qat_device.c | 1 + drivers/crypto/qat/qat_sym.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c index dab34dbcd5..3d99425751 100644 --- a/drivers/common/qat/qat_device.c +++ b/drivers/common/qat/qat_device.c @@ -31,6 +31,7 @@ struct qat_service qat_service[QAT_MAX_SERVICES]; /* per-process array of device data */ struct qat_device_info qat_pci_devs[RTE_PMD_QAT_MAX_PCI_DEVICES]; static int qat_nb_pci_devices; +int qat_legacy_capa; /* * The set of PCI devices this driver supports diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index ac16051b19..6982ec2902 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -19,7 +19,6 @@ #include "qat_qp.h" 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" -- 2.13.6 ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [EXTERNAL] [PATCH v4 1/3] common/qat: isolate parser arguments configuration 2024-02-29 19:14 ` [PATCH v4 1/3] common/qat: isolate parser arguments configuration 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 ` Akhil Goyal 2024-03-01 15:52 ` [PATCH v5 " Arkadiusz Kusztal 3 siblings, 0 replies; 12+ messages in thread From: Akhil Goyal @ 2024-02-29 19:19 UTC (permalink / raw) To: Arkadiusz Kusztal, dev; +Cc: ciara.power > Subject: [EXTERNAL] [PATCH v4 1/3] common/qat: isolate parser arguments > configuration > > Prioritize security for external emails: Confirm sender and content safety before > clicking links or opening attachments > > ---------------------------------------------------------------------- > 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)") Ciara's Gen3/5 series has been merged to next-crypto. vQAT series does not apply and hence this would also not apply. Please rebase and mark dependencies. Also mark previous versions as superseded. It creates lot of confusion. I have been marking your patches as superseded. Please so it while sending the next version. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v5 1/3] common/qat: isolate parser arguments configuration 2024-02-29 19:14 ` [PATCH v4 1/3] common/qat: isolate parser arguments configuration Arkadiusz Kusztal ` (2 preceding siblings ...) 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 2024-03-01 15:52 ` [PATCH v5 2/3] common/qat: decouple pmds from the common code Arkadiusz Kusztal ` (3 more replies) 3 siblings, 4 replies; 12+ messages in thread From: Arkadiusz Kusztal @ 2024-03-01 15:52 UTC (permalink / raw) To: dev; +Cc: gakhil, ciara.power, Arkadiusz Kusztal 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v5 2/3] common/qat: decouple pmds from the common code 2024-03-01 15:52 ` [PATCH v5 " Arkadiusz Kusztal @ 2024-03-01 15:52 ` 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 ` (2 subsequent siblings) 3 siblings, 1 reply; 12+ messages in thread From: Arkadiusz Kusztal @ 2024-03-01 15:52 UTC (permalink / raw) To: dev; +Cc: gakhil, ciara.power, Arkadiusz Kusztal Service specific functions were moved to services files. Weak symbols for device create/destroy were removed, named private devs were replaced by an opaque array. Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com> --- drivers/common/qat/qat_device.c | 112 ++++++++++-------------------------- drivers/common/qat/qat_device.h | 47 ++++----------- drivers/compress/qat/qat_comp_pmd.c | 34 +++++------ drivers/compress/qat/qat_comp_pmd.h | 7 --- drivers/crypto/qat/qat_asym.c | 20 ++++--- drivers/crypto/qat/qat_sym.c | 19 +++--- 6 files changed, 83 insertions(+), 156 deletions(-) diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c index e1f1060535..a27252ea4d 100644 --- a/drivers/common/qat/qat_device.c +++ b/drivers/common/qat/qat_device.c @@ -26,6 +26,8 @@ struct qat_gen_hw_data qat_gen_config[QAT_N_GENS]; struct qat_dev_hw_spec_funcs *qat_dev_hw_spec[QAT_N_GENS]; +struct qat_service qat_service[QAT_MAX_SERVICES]; + /* per-process array of device data */ struct qat_device_info qat_pci_devs[RTE_PMD_QAT_MAX_PCI_DEVICES]; static int qat_nb_pci_devices; @@ -120,7 +122,7 @@ qat_pci_find_free_device_index(void) return dev_id; } -struct qat_pci_device * +static struct qat_pci_device * qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev) { char name[QAT_DEV_NAME_MAX_LEN]; @@ -308,7 +310,8 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev) return NULL; } - qat_dev_size = sizeof(struct qat_pci_device) + extra_size; + qat_dev_size = sizeof(struct qat_pci_device) + sizeof(void *) * + QAT_MAX_SERVICES + extra_size; qat_dev_mz = rte_memzone_reserve(name, qat_dev_size, rte_socket_id(), 0); @@ -400,7 +403,7 @@ qat_pci_device_release(struct rte_pci_device *pci_dev) { struct qat_pci_device *qat_dev; char name[QAT_DEV_NAME_MAX_LEN]; - int busy = 0; + int busy = 0, i; if (pci_dev == NULL) return -EINVAL; @@ -415,24 +418,16 @@ qat_pci_device_release(struct rte_pci_device *pci_dev) /* Check that there are no service devs still on pci device */ if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - if (qat_dev->sym_dev != NULL) { - QAT_LOG(DEBUG, "QAT sym device %s is busy", - name); - busy = 1; - } - if (qat_dev->asym_dev != NULL) { - QAT_LOG(DEBUG, "QAT asym device %s is busy", - name); - busy = 1; - } - if (qat_dev->comp_dev != NULL) { - QAT_LOG(DEBUG, "QAT comp device %s is busy", - name); + for (i = 0; i < QAT_MAX_SERVICES; i++) { + if (qat_dev->pmd[i] == NULL) + continue; + QAT_LOG(DEBUG, "QAT %s device %s is busy", + qat_service[i].name, name); busy = 1; - } if (busy) return -EBUSY; rte_memzone_free(inst->mz); + } } memset(inst, 0, sizeof(struct qat_device_info)); qat_nb_pci_devices--; @@ -446,17 +441,20 @@ static int qat_pci_dev_destroy(struct qat_pci_device *qat_pci_dev, struct rte_pci_device *pci_dev) { - qat_sym_dev_destroy(qat_pci_dev); - qat_comp_dev_destroy(qat_pci_dev); - qat_asym_dev_destroy(qat_pci_dev); + int i; + + for (i = 0; i < QAT_MAX_SERVICES; i++) { + if (!qat_service[i].dev_create) + continue; + qat_service[i].dev_destroy(qat_pci_dev); + } return qat_pci_device_release(pci_dev); } static int qat_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) { - int sym_ret = 0, asym_ret = 0, comp_ret = 0; - int num_pmds_created = 0; + int i, ret = 0, num_pmds_created = 0; struct qat_pci_device *qat_pci_dev; QAT_LOG(DEBUG, "Found QAT device at %02x:%02x.%x", @@ -468,30 +466,18 @@ static int qat_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, if (qat_pci_dev == NULL) return -ENODEV; - sym_ret = qat_sym_dev_create(qat_pci_dev); - if (sym_ret == 0) { - num_pmds_created++; - } - else - QAT_LOG(WARNING, - "Failed to create QAT SYM PMD on device %s", - qat_pci_dev->name); - - comp_ret = qat_comp_dev_create(qat_pci_dev); - if (comp_ret == 0) - num_pmds_created++; - else - QAT_LOG(WARNING, - "Failed to create QAT COMP PMD on device %s", - qat_pci_dev->name); - - asym_ret = qat_asym_dev_create(qat_pci_dev); - if (asym_ret == 0) - num_pmds_created++; - else - QAT_LOG(WARNING, - "Failed to create QAT ASYM PMD on device %s", + for (i = 0; i < QAT_MAX_SERVICES; i++) { + if (!qat_service[i].dev_create) + continue; + ret = qat_service[i].dev_create(qat_pci_dev); + if (ret == 0) + num_pmds_created++; + else { + QAT_LOG(WARNING, "Failed to create %s PMD on device %s", + qat_service[i].name, qat_pci_dev->name); + } + } if (num_pmds_created == 0) qat_pci_dev_destroy(qat_pci_dev, pci_dev); @@ -521,42 +507,6 @@ static struct rte_pci_driver rte_qat_pmd = { .remove = qat_pci_remove }; -__rte_weak int -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) -{ - return 0; -} - -__rte_weak int -qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused) -{ - return 0; -} - -__rte_weak int -qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused) -{ - return 0; -} - -__rte_weak int -qat_comp_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused) -{ - return 0; -} - -__rte_weak int -qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused) -{ - return 0; -} - RTE_PMD_REGISTER_PCI(QAT_PCI_NAME, rte_qat_pmd); RTE_PMD_REGISTER_PCI_TABLE(QAT_PCI_NAME, pci_id_qat_map); RTE_PMD_REGISTER_KMOD_DEP(QAT_PCI_NAME, "* igb_uio | uio_pci_generic | vfio-pci"); diff --git a/drivers/common/qat/qat_device.h b/drivers/common/qat/qat_device.h index 8d332e0d0b..9275156ef8 100644 --- a/drivers/common/qat/qat_device.h +++ b/drivers/common/qat/qat_device.h @@ -19,6 +19,14 @@ #define MAX_QP_THRESHOLD_SIZE 32 #define QAT_LEGACY_CAPA "qat_legacy_capa" +struct qat_service { + const char *name; + int (*dev_create)(struct qat_pci_device *qat_pci_dev); + int (*dev_destroy)(struct qat_pci_device *qat_pci_dev); +}; + +extern struct qat_service qat_service[]; + /** * Function prototypes for GENx specific device operations. **/ @@ -104,27 +112,12 @@ struct qat_pci_device { /**< QAT device generation */ rte_spinlock_t arb_csr_lock; /**< lock to protect accesses to the arbiter CSR */ - struct qat_qp *qps_in_use[QAT_MAX_SERVICES][ADF_MAX_QPS_ON_ANY_SERVICE]; /**< links to qps set up for each service, index same as on API */ - - /* Data relating to symmetric crypto service */ - struct qat_cryptodev_private *sym_dev; - /**< link back to cryptodev private data */ - int qat_sym_driver_id; /**< Symmetric driver id used by this device */ - - /* Data relating to asymmetric crypto service */ - struct qat_cryptodev_private *asym_dev; - /**< link back to cryptodev private data */ - int qat_asym_driver_id; /**< Symmetric driver id used by this device */ - - /* Data relating to compression service */ - struct qat_comp_dev_private *comp_dev; - /**< link back to compressdev private data */ void *misc_bar_io_addr; /**< Address of misc bar */ void *dev_private; @@ -135,6 +128,8 @@ struct qat_pci_device { /**< Wireless Slices supported */ char *command_line; /**< Map of the crypto and compression slices */ + void *pmd[QAT_MAX_SERVICES]; + /**< link back to pmd private data */ }; struct qat_gen_hw_data { @@ -154,26 +149,4 @@ struct qat_pf2vf_dev { extern struct qat_gen_hw_data qat_gen_config[]; -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); - -int -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); - -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); - -int -qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused); - #endif /* _QAT_DEVICE_H_ */ diff --git a/drivers/compress/qat/qat_comp_pmd.c b/drivers/compress/qat/qat_comp_pmd.c index 4b24929a70..c5f7c7dc67 100644 --- a/drivers/compress/qat/qat_comp_pmd.c +++ b/drivers/compress/qat/qat_comp_pmd.c @@ -636,22 +636,24 @@ qat_comp_pmd_dequeue_first_op_burst(void *qp, struct rte_comp_op **ops, { uint16_t ret = qat_comp_dequeue_burst(qp, ops, nb_ops); struct qat_qp *tmp_qp = (struct qat_qp *)qp; + struct qat_comp_dev_private *dev = + tmp_qp->qat_dev->pmd[QAT_SERVICE_COMPRESSION]; if (ret) { if ((*ops)->debug_status == (uint64_t)ERR_CODE_QAT_COMP_WRONG_FW) { - tmp_qp->qat_dev->comp_dev->compressdev->enqueue_burst = + dev->compressdev->enqueue_burst = qat_comp_pmd_enq_deq_dummy_op_burst; - tmp_qp->qat_dev->comp_dev->compressdev->dequeue_burst = + dev->compressdev->dequeue_burst = qat_comp_pmd_enq_deq_dummy_op_burst; - tmp_qp->qat_dev->comp_dev->compressdev->dev_ops = + dev->compressdev->dev_ops = &compress_qat_dummy_ops; QAT_LOG(ERR, "This QAT hardware doesn't support compression operation"); } else { - tmp_qp->qat_dev->comp_dev->compressdev->dequeue_burst = + dev->compressdev->dequeue_burst = qat_comp_dequeue_burst; } } @@ -669,7 +671,7 @@ static const struct rte_driver compdev_qat_driver = { .alias = qat_comp_drv_name }; -int +static int qat_comp_dev_create(struct qat_pci_device *qat_pci_dev) { struct qat_device_info *qat_dev_instance = @@ -779,7 +781,7 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev) MAX_QP_THRESHOLD_SIZE : atoi(cmdline); } - qat_pci_dev->comp_dev = comp_dev; + qat_pci_dev->pmd[QAT_SERVICE_COMPRESSION] = comp_dev; QAT_LOG(DEBUG, "Created QAT COMP device %s as compressdev instance %d", @@ -787,26 +789,23 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev) return 0; } -int +static int qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev) { - struct qat_comp_dev_private *comp_dev; + struct qat_comp_dev_private *dev = + qat_pci_dev->pmd[QAT_SERVICE_COMPRESSION]; if (qat_pci_dev == NULL) return -ENODEV; - comp_dev = qat_pci_dev->comp_dev; - if (comp_dev == NULL) - return 0; - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_memzone_free(qat_pci_dev->comp_dev->capa_mz); + rte_memzone_free(dev->capa_mz); /* clean up any resources used by the device */ - qat_comp_dev_close(comp_dev->compressdev); + qat_comp_dev_close(dev->compressdev); - rte_compressdev_pmd_destroy(comp_dev->compressdev); - qat_pci_dev->comp_dev = NULL; + rte_compressdev_pmd_destroy(dev->compressdev); + qat_pci_dev->pmd[QAT_SERVICE_COMPRESSION] = NULL; return 0; } @@ -814,4 +813,7 @@ qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev) RTE_INIT(qat_sym_init) { qat_cmdline_defines[QAT_SERVICE_COMPRESSION] = arguments; + qat_service[QAT_SERVICE_COMPRESSION].name = "symmetric crypto"; + qat_service[QAT_SERVICE_COMPRESSION].dev_create = qat_comp_dev_create; + qat_service[QAT_SERVICE_COMPRESSION].dev_destroy = qat_comp_dev_destroy; } diff --git a/drivers/compress/qat/qat_comp_pmd.h b/drivers/compress/qat/qat_comp_pmd.h index 1f5b0facf7..01a8983287 100644 --- a/drivers/compress/qat/qat_comp_pmd.h +++ b/drivers/compress/qat/qat_comp_pmd.h @@ -106,13 +106,6 @@ const struct rte_memzone * 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); - -int -qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev); - - static __rte_always_inline unsigned int qat_comp_get_num_im_bufs_required(enum qat_device_gen gen) { diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c index 7d01ad503b..8ec9f65156 100644 --- a/drivers/crypto/qat/qat_asym.c +++ b/drivers/crypto/qat/qat_asym.c @@ -1505,7 +1505,7 @@ qat_asym_init_op_cookie(void *op_cookie) } } -int +static int qat_asym_dev_create(struct qat_pci_device *qat_pci_dev) { struct qat_cryptodev_private *internals; @@ -1614,31 +1614,32 @@ qat_asym_dev_create(struct qat_pci_device *qat_pci_dev) return -1; } - qat_pci_dev->asym_dev = internals; + qat_pci_dev->pmd[QAT_SERVICE_ASYMMETRIC] = internals; internals->service_type = QAT_SERVICE_ASYMMETRIC; QAT_LOG(DEBUG, "Created QAT ASYM device %s as cryptodev instance %d", cryptodev->data->name, internals->dev_id); return 0; } -int +static int qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev) { struct rte_cryptodev *cryptodev; + struct qat_cryptodev_private *dev = + qat_pci_dev->pmd[QAT_SERVICE_ASYMMETRIC]; if (qat_pci_dev == NULL) return -ENODEV; - if (qat_pci_dev->asym_dev == NULL) + if (dev == NULL) return 0; if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_memzone_free(qat_pci_dev->asym_dev->capa_mz); + rte_memzone_free(dev->capa_mz); /* free crypto device */ - cryptodev = rte_cryptodev_pmd_get_dev( - qat_pci_dev->asym_dev->dev_id); + cryptodev = rte_cryptodev_pmd_get_dev(dev->dev_id); rte_cryptodev_pmd_destroy(cryptodev); qat_pci_devs[qat_pci_dev->qat_dev_id].asym_rte_dev.name = NULL; - qat_pci_dev->asym_dev = NULL; + qat_pci_dev->pmd[QAT_SERVICE_ASYMMETRIC] = NULL; return 0; } @@ -1651,4 +1652,7 @@ RTE_PMD_REGISTER_CRYPTO_DRIVER(qat_crypto_drv, RTE_INIT(qat_asym_init) { qat_cmdline_defines[QAT_SERVICE_ASYMMETRIC] = arguments; + qat_service[QAT_SERVICE_ASYMMETRIC].name = "asymmetric crypto"; + qat_service[QAT_SERVICE_ASYMMETRIC].dev_create = qat_asym_dev_create; + qat_service[QAT_SERVICE_ASYMMETRIC].dev_destroy = qat_asym_dev_destroy; } diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index 2d7c737de7..efca8f3ba1 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -199,7 +199,7 @@ qat_sym_dequeue_burst_gen_lce(void *qp, struct rte_crypto_op **ops, uint16_t nb_ return qat_dequeue_op_burst(qp, (void **)ops, qat_sym_process_response_gen_lce, nb_ops); } -int +static int qat_sym_dev_create(struct qat_pci_device *qat_pci_dev) { int ret = 0; @@ -326,7 +326,7 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev) goto error; } internals->service_type = QAT_SERVICE_SYMMETRIC; - qat_pci_dev->sym_dev = internals; + qat_pci_dev->pmd[QAT_SERVICE_SYMMETRIC] = internals; QAT_LOG(DEBUG, "Created QAT SYM device %s as cryptodev instance %d", cryptodev->data->name, internals->dev_id); @@ -342,25 +342,27 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev) return ret; } -int +static int qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev) { struct rte_cryptodev *cryptodev; + struct qat_cryptodev_private *dev = + qat_pci_dev->pmd[QAT_SERVICE_SYMMETRIC]; if (qat_pci_dev == NULL) return -ENODEV; - if (qat_pci_dev->sym_dev == NULL) + if (dev == NULL) return 0; if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_memzone_free(qat_pci_dev->sym_dev->capa_mz); + rte_memzone_free(dev->capa_mz); /* free crypto device */ - cryptodev = rte_cryptodev_pmd_get_dev(qat_pci_dev->sym_dev->dev_id); + cryptodev = rte_cryptodev_pmd_get_dev(dev->dev_id); rte_free(cryptodev->security_ctx); cryptodev->security_ctx = NULL; rte_cryptodev_pmd_destroy(cryptodev); qat_pci_devs[qat_pci_dev->qat_dev_id].sym_rte_dev.name = NULL; - qat_pci_dev->sym_dev = NULL; + qat_pci_dev->pmd[QAT_SERVICE_SYMMETRIC] = NULL; return 0; } @@ -421,4 +423,7 @@ RTE_PMD_REGISTER_CRYPTO_DRIVER(qat_crypto_drv, RTE_INIT(qat_sym_init) { qat_cmdline_defines[QAT_SERVICE_SYMMETRIC] = arguments; + qat_service[QAT_SERVICE_SYMMETRIC].name = "symmetric crypto"; + qat_service[QAT_SERVICE_SYMMETRIC].dev_create = qat_sym_dev_create; + qat_service[QAT_SERVICE_SYMMETRIC].dev_destroy = qat_sym_dev_destroy; } -- 2.13.6 ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v5 2/3] common/qat: decouple pmds from the common code 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 0 siblings, 0 replies; 12+ messages in thread From: Dooley, Brian @ 2024-03-01 16:08 UTC (permalink / raw) To: Kusztal, ArkadiuszX, dev; +Cc: gakhil, Power, Ciara, Kusztal, ArkadiuszX > -----Original Message----- > From: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com> > Sent: Friday, March 1, 2024 3:53 PM > To: dev@dpdk.org > Cc: gakhil@marvell.com; Power, Ciara <ciara.power@intel.com>; Kusztal, > ArkadiuszX <arkadiuszx.kusztal@intel.com> > Subject: [PATCH v5 2/3] common/qat: decouple pmds from the common > code > > Service specific functions were moved to services files. Weak symbols for > device create/destroy were removed, named private devs were replaced by an > opaque array. > > Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com> > --- > drivers/common/qat/qat_device.c | 112 ++++++++++------------------------- > - > drivers/common/qat/qat_device.h | 47 ++++----------- > drivers/compress/qat/qat_comp_pmd.c | 34 +++++------ > drivers/compress/qat/qat_comp_pmd.h | 7 --- > drivers/crypto/qat/qat_asym.c | 20 ++++--- > drivers/crypto/qat/qat_sym.c | 19 +++--- > 6 files changed, 83 insertions(+), 156 deletions(-) > <snip> Acked-by: Brian Dooley <brian.dooley@intel.com> ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v5 3/3] common/qat: fix incorrectly placed legacy flag 2024-03-01 15:52 ` [PATCH v5 " Arkadiusz Kusztal 2024-03-01 15:52 ` [PATCH v5 2/3] common/qat: decouple pmds from the common code Arkadiusz Kusztal @ 2024-03-01 15:52 ` Arkadiusz Kusztal 2024-03-01 16:08 ` Dooley, Brian 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 3 siblings, 1 reply; 12+ messages in thread From: Arkadiusz Kusztal @ 2024-03-01 15:52 UTC (permalink / raw) To: dev; +Cc: gakhil, ciara.power, Arkadiusz Kusztal This commit fixes a legacy flag, which was placed in a file that may not be included in a building process. Fixes: cffb726b7797 ("crypto/qat: enable insecure algorithms") Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com> --- drivers/common/qat/qat_device.c | 1 + drivers/crypto/qat/qat_sym.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c index a27252ea4d..500ca0f308 100644 --- a/drivers/common/qat/qat_device.c +++ b/drivers/common/qat/qat_device.c @@ -31,6 +31,7 @@ struct qat_service qat_service[QAT_MAX_SERVICES]; /* per-process array of device data */ struct qat_device_info qat_pci_devs[RTE_PMD_QAT_MAX_PCI_DEVICES]; static int qat_nb_pci_devices; +int qat_legacy_capa; /* * The set of PCI devices this driver supports diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index efca8f3ba1..6c7b1724ef 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -19,7 +19,6 @@ #include "qat_qp.h" 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" -- 2.13.6 ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v5 3/3] common/qat: fix incorrectly placed legacy flag 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 0 siblings, 1 reply; 12+ messages in thread From: Dooley, Brian @ 2024-03-01 16:08 UTC (permalink / raw) To: Kusztal, ArkadiuszX, dev; +Cc: gakhil, Power, Ciara, Kusztal, ArkadiuszX > -----Original Message----- > From: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com> > Sent: Friday, March 1, 2024 3:53 PM > To: dev@dpdk.org > Cc: gakhil@marvell.com; Power, Ciara <ciara.power@intel.com>; Kusztal, > ArkadiuszX <arkadiuszx.kusztal@intel.com> > Subject: [PATCH v5 3/3] common/qat: fix incorrectly placed legacy flag > > This commit fixes a legacy flag, which was placed in a file that may not be > included in a building process. > > Fixes: cffb726b7797 ("crypto/qat: enable insecure algorithms") > > Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com> > --- > drivers/common/qat/qat_device.c | 1 + > drivers/crypto/qat/qat_sym.c | 1 - > 2 files changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/common/qat/qat_device.c > b/drivers/common/qat/qat_device.c index a27252ea4d..500ca0f308 100644 > --- a/drivers/common/qat/qat_device.c > +++ b/drivers/common/qat/qat_device.c > @@ -31,6 +31,7 @@ struct qat_service qat_service[QAT_MAX_SERVICES]; > /* per-process array of device data */ > struct qat_device_info qat_pci_devs[RTE_PMD_QAT_MAX_PCI_DEVICES]; > static int qat_nb_pci_devices; > +int qat_legacy_capa; > > /* > * The set of PCI devices this driver supports diff --git > a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index > efca8f3ba1..6c7b1724ef 100644 > --- a/drivers/crypto/qat/qat_sym.c > +++ b/drivers/crypto/qat/qat_sym.c > @@ -19,7 +19,6 @@ > #include "qat_qp.h" > > 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" > -- > 2.13.6 Acked-by: Brian Dooley <brian.dooley@intel.com> ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v5 3/3] common/qat: fix incorrectly placed legacy flag 2024-03-01 16:08 ` Dooley, Brian @ 2024-03-04 7:10 ` Akhil Goyal 0 siblings, 0 replies; 12+ messages in thread From: Akhil Goyal @ 2024-03-04 7:10 UTC (permalink / raw) To: Dooley, Brian, Kusztal, ArkadiuszX, dev Cc: Power, Ciara, Kusztal, ArkadiuszX, stable > > Subject: [PATCH v5 3/3] common/qat: fix incorrectly placed legacy flag > > > > This commit fixes a legacy flag, which was placed in a file that may not be > > included in a building process. > > > > Fixes: cffb726b7797 ("crypto/qat: enable insecure algorithms") > > > > Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com> Cc: stable@dpdk.org Series Applied to dpdk-next-crypto ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v5 1/3] common/qat: isolate parser arguments configuration 2024-03-01 15:52 ` [PATCH v5 " Arkadiusz Kusztal 2024-03-01 15:52 ` [PATCH v5 2/3] common/qat: decouple pmds from the common code Arkadiusz Kusztal 2024-03-01 15:52 ` [PATCH v5 3/3] common/qat: fix incorrectly placed legacy flag Arkadiusz Kusztal @ 2024-03-01 16:07 ` Dooley, Brian 2024-03-04 7:08 ` [EXTERNAL] " Akhil Goyal 3 siblings, 0 replies; 12+ messages in thread From: Dooley, Brian @ 2024-03-01 16:07 UTC (permalink / raw) To: Kusztal, ArkadiuszX, dev; +Cc: gakhil, Power, Ciara, Kusztal, ArkadiuszX Hi Arek, > -----Original Message----- > From: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com> > Sent: Friday, March 1, 2024 3:53 PM > To: dev@dpdk.org > Cc: gakhil@marvell.com; Power, Ciara <ciara.power@intel.com>; Kusztal, > ArkadiuszX <arkadiuszx.kusztal@intel.com> > Subject: [PATCH v5 1/3] common/qat: isolate parser arguments configuration > > 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(-) > <snip> Acked-by: Brian Dooley <brian.dooley@intel.com> ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [EXTERNAL] [PATCH v5 1/3] common/qat: isolate parser arguments configuration 2024-03-01 15:52 ` [PATCH v5 " Arkadiusz Kusztal ` (2 preceding siblings ...) 2024-03-01 16:07 ` [PATCH v5 1/3] common/qat: isolate parser arguments configuration Dooley, Brian @ 2024-03-04 7:08 ` Akhil Goyal 3 siblings, 0 replies; 12+ messages in thread From: Akhil Goyal @ 2024-03-04 7:08 UTC (permalink / raw) To: Arkadiusz Kusztal, dev; +Cc: ciara.power > 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> Applied to dpdk-next-crypto Thanks. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-03-04 7:10 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <v4-00020240229093007.32298-1-arkadiuszx.kusztal@intel.com> 2024-02-29 19:14 ` [PATCH v4 1/3] common/qat: isolate parser arguments configuration 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 ` [PATCH v5 " Arkadiusz Kusztal 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
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).