Command line parameters was moved to the device struct.

Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusz...@intel.com>
---
 drivers/common/qat/qat_device.c     | 54 ++++++++++++++++++-------------------
 drivers/common/qat/qat_device.h     | 35 ++++++++++++------------
 drivers/compress/qat/qat_comp_pmd.c |  9 +++----
 drivers/compress/qat/qat_comp_pmd.h |  3 +--
 drivers/crypto/qat/qat_asym.c       | 13 +++++----
 drivers/crypto/qat/qat_sym.c        | 23 ++++++++--------
 6 files changed, 66 insertions(+), 71 deletions(-)

diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c
index 93aef9aeb1..d9604e666d 100644
--- a/drivers/common/qat/qat_device.c
+++ b/drivers/common/qat/qat_device.c
@@ -22,6 +22,16 @@
                }                               \
        } while (0)
 
+const char *cmd_arg_strings[] = {
+       [QAT_LEGACY_CAPA_POS]           = "qat_legacy_capa",
+       [SYM_ENQ_THRESHOLD_POS]         = "qat_sym_enq_threshold",
+       [ASYM_ENQ_THRESHOLD_POS]        = "qat_asym_enq_threshold",
+       [COMP_ENQ_THRESHOLD_POS]        = "qat_comp_enq_threshold",
+       [SYM_CIPHER_CRC_ENABLE_POS]     = "qat_sym_cipher_crc_enable",
+       [QAT_CMD_SLICE_MAP_POS]         = "qat_cmd_slice_disable",
+       [QAT_CMD_SLICE_MAP_POS + 1]     = NULL,
+};
+
 /* Hardware device information per generation */
 struct qat_gen_hw_data qat_gen_config[QAT_N_GENS];
 struct qat_dev_hw_spec_funcs *qat_dev_hw_spec[QAT_N_GENS];
@@ -117,7 +127,7 @@ qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev)
 
 static void
 qat_dev_parse_cmd(const char *str, struct qat_dev_cmd_param
-               *qat_dev_cmd_param)
+               *cmd_line_param)
 {
        int i = 0;
        const char *param;
@@ -125,7 +135,7 @@ qat_dev_parse_cmd(const char *str, struct qat_dev_cmd_param
        while (1) {
                char value_str[4] = { };
 
-               param = qat_dev_cmd_param[i].name;
+               param = cmd_arg_strings[i];
                if (param == NULL)
                        return;
                long value = 0;
@@ -174,7 +184,7 @@ qat_dev_parse_cmd(const char *str, struct qat_dev_cmd_param
                                                param, value);
                        }
                }
-               qat_dev_cmd_param[i].val = value;
+               cmd_line_param[i].val = value;
                i++;
        }
 }
@@ -201,9 +211,8 @@ pick_gen(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)
+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;
@@ -291,7 +300,7 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev,
                qat_dev->misc_bar_io_addr = NULL;
 
        if (devargs && devargs->drv_str)
-               qat_dev_parse_cmd(devargs->drv_str, qat_dev_cmd_param);
+               qat_dev_parse_cmd(devargs->drv_str, qat_dev->cmd_line_param);
 
        if (qat_read_qp_config(qat_dev)) {
                QAT_LOG(ERR,
@@ -311,7 +320,9 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev,
        NOT_NULL(ops_hw->qat_dev_get_slice_map, goto error,
                "QAT internal error! Reset ring pairs function not set, gen : 
%d",
                qat_dev_gen);
-       if (ops_hw->qat_dev_get_slice_map(&qat_dev->slice_map, pci_dev) < 0) {
+       if (ops_hw->qat_dev_get_slice_map(
+                       &qat_dev->cmd_line_param[QAT_CMD_SLICE_MAP_POS].val,
+                       pci_dev) < 0) {
                RTE_LOG(ERR, EAL,
                        "Cannot read slice configuration\n");
                goto error;
@@ -401,27 +412,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++;
        }
@@ -430,7 +431,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
@@ -438,7 +439,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
@@ -475,15 +476,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;
 }
@@ -501,8 +500,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 23d7f54b61..dcb5a42c89 100644
--- a/drivers/common/qat/qat_device.h
+++ b/drivers/common/qat/qat_device.h
@@ -17,14 +17,21 @@
 
 #define QAT_DEV_NAME_MAX_LEN   64
 
-#define QAT_LEGACY_CAPA "qat_legacy_capa"
+#define QAT_LEGACY_CAPA_NAME "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_CMD_SLICE_MAP_NAME "qat_cmd_slice_disable"
+#define QAT_LEGACY_CAPA_POS            0
+#define SYM_ENQ_THRESHOLD_POS          1
+#define ASYM_ENQ_THRESHOLD_POS         2
+#define COMP_ENQ_THRESHOLD_POS         3
+#define SYM_CIPHER_CRC_ENABLE_POS      4
+#define QAT_CMD_SLICE_MAP_POS          5
+#define MAX_QP_THRESHOLD_SIZE          32
+
+extern const char *cmd_arg_strings[];
 
 /**
  * Function prototypes for GENx specific device operations.
@@ -53,8 +60,7 @@ struct qat_dev_hw_spec_funcs {
 extern struct qat_dev_hw_spec_funcs *qat_dev_hw_spec[];
 
 struct qat_dev_cmd_param {
-       const char *name;
-       uint16_t val;
+       uint32_t val;
 };
 
 struct qat_device_info {
@@ -133,8 +139,8 @@ struct qat_pci_device {
        /**< Address of misc bar */
        void *dev_private;
        /**< Per generation specific information */
-       uint32_t slice_map;
-       /**< QAT slice map */
+       struct qat_dev_cmd_param cmd_line_param[QAT_CMD_SLICE_MAP_POS + 1];
+       /**< Command line parameters values */
 };
 
 struct qat_gen_hw_data {
@@ -155,20 +161,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 +177,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 6fb8cf69be..cc91edca3a 100644
--- a/drivers/compress/qat/qat_comp_pmd.c
+++ b/drivers/compress/qat/qat_comp_pmd.c
@@ -663,8 +663,7 @@ 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 =
@@ -759,11 +758,11 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev,
        comp_dev->qat_dev_capabilities = comp_dev->capa_mz->addr;
 
        while (1) {
-               if (qat_dev_cmd_param[i].name == NULL)
+               if (cmd_arg_strings[i] == NULL)
                        break;
-               if (!strcmp(qat_dev_cmd_param[i].name, COMP_ENQ_THRESHOLD_NAME))
+               if (!strcmp(cmd_arg_strings[i], COMP_ENQ_THRESHOLD_NAME))
                        comp_dev->min_enq_burst_threshold =
-                                       qat_dev_cmd_param[i].val;
+                               qat_pci_dev->cmd_line_param[i].val;
                i++;
        }
        qat_pci_dev->comp_dev = comp_dev;
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 7abd513423..2b54b63e8f 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -1415,8 +1415,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;
@@ -1490,13 +1489,13 @@ qat_asym_dev_create(struct qat_pci_device *qat_pci_dev,
        internals->dev_id = cryptodev->data->dev_id;
 
        while (1) {
-               if (qat_dev_cmd_param[i].name == NULL)
+               if (cmd_arg_strings[i] == NULL)
                        break;
-               if (!strcmp(qat_dev_cmd_param[i].name, ASYM_ENQ_THRESHOLD_NAME))
+               if (!strcmp(cmd_arg_strings[i], 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;
+                               qat_pci_dev->cmd_line_param[i].val;
+               if (!strcmp(cmd_arg_strings[i], QAT_CMD_SLICE_MAP_NAME))
+                       slice_map = qat_pci_dev->cmd_line_param[i].val;
                i++;
        }
 
diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
index 936c2615e4..c06b7120c0 100644
--- a/drivers/crypto/qat/qat_sym.c
+++ b/drivers/crypto/qat/qat_sym.c
@@ -15,6 +15,8 @@
 #include "qat_crypto.h"
 #include "qat_qp.h"
 
+extern const char *cmd_arg_strings[];
+
 uint8_t qat_sym_driver_id;
 int qat_legacy_capa;
 
@@ -182,8 +184,7 @@ 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;
@@ -277,18 +278,18 @@ qat_sym_dev_create(struct qat_pci_device *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))
+       while (cmd_arg_strings[i] != NULL) {
+               if (!strcmp(cmd_arg_strings[i], SYM_ENQ_THRESHOLD_NAME))
                        internals->min_enq_burst_threshold =
-                                       qat_dev_cmd_param[i].val;
-               if (!strcmp(qat_dev_cmd_param[i].name,
+                               qat_pci_dev->cmd_line_param[i].val;
+               if (!strcmp(cmd_arg_strings[i],
                                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;
+                               qat_pci_dev->cmd_line_param[i].val;
+               if (!strcmp(cmd_arg_strings[i], QAT_LEGACY_CAPA_NAME))
+                       qat_legacy_capa = qat_pci_dev->cmd_line_param[i].val;
+               if (!strcmp(cmd_arg_strings[i], QAT_CMD_SLICE_MAP_NAME))
+                       slice_map = qat_pci_dev->cmd_line_param[i].val;
                i++;
        }
 
-- 
2.13.6

Reply via email to