From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 61C3FA0093; Sun, 2 Jan 2022 08:00:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2468941148; Sun, 2 Jan 2022 08:00:06 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2048.outbound.protection.outlook.com [40.107.244.48]) by mails.dpdk.org (Postfix) with ESMTP id 2540F406FF for ; Sun, 2 Jan 2022 08:00:04 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S8OR3GYVqTpxSGlxlJNGkhEKdo1okYaoP8Lt0fIvaeA2crvIoyeULfYx5KNrLm7mQIbuxiPNII9EVK2MQKWDTau6m6QG/Q1s+hWcthhjvQQ+W+HsUJcFn94bhXVsHG4J4UmFTXhUc89fqEuhjO3CaAE2rCl4+2xSYJklBXKcQqelbX32oeFfGktGWBU/gVoGnJkVoMQsN7W3yegzlwaVmJZBX1ltJhCcVAh2SqB0W2CGXSXTxGsQw7ZGf521kuNhNdrHQH1zBsQZoiom4KBaahscDjw7i+mZyUaxlpaxdG645EIKAzHWcFtm4rM/UXsrfuscLF9SLmcLiqkmEgED+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZIyVAixOgj+pAP73cl+owV1GNmi2to9EU4DAE9Srjbw=; b=E3SvB0gVFZuqVXF8dk4luPkcNTMtiGQZnL4e/TraUCQ3/gCBgktuFiV+L2nyfpJLqpm0j3tgsmEYYM1jtig/XDp+aFoYzXFswu/X5Y5SrhDlIzOB7StyBOH8RYgnDlMrQFwYuL1Fp68hPZIwrCYarcwpfTjkTuGJJHqTwO9JCmfKacYJcSuy/muCbBrATVUCi7OaT1jJGvmUTqo0w5Cypa2F0vtld53fsk7s50DPJh3oNBAjPKA5oUINtCBl29YgkkkCatl2Abhaq0e3Cd/Oo1ffupjNtjOY/24oyQaK3q/2wd9d/C0aGpMcHuuF+aGREVAIRvZYfSGdK5ePzHofiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZIyVAixOgj+pAP73cl+owV1GNmi2to9EU4DAE9Srjbw=; b=Ar8NPBXYdswaGDAxJo7TY0jZaPDh4HxfS/OHbsWaOApaVzh72x26i1Ogy8iIJ5JlKOC20WyAoEVGE6sDT1R0dg+enHOm10aAtCGjgNnCSpFQ9m40HH/J7ODaNQqn47G6Ezxb9gKhtEtnoz0+JEDSDiYxnTwiLtqSzghqWFM9ogMmC8u6VDAX8OoAv5G0eKdXPOf31ScHY2ZHJ6Lc7m0P/yenpK/YbbjMCr1fkuZ62xu/KFTlq+j9lJdSK1mySPkxqu5mgoVH6qFZQFU240qn3kPJYx0WMMzZASO9QlOUe/AzRcGM2dZ+kQWogoR1RSx1+d+FZ0AHigN2FRVkRn8a7Q== Received: from DM6PR18CA0034.namprd18.prod.outlook.com (2603:10b6:5:15b::47) by BN6PR12MB1732.namprd12.prod.outlook.com (2603:10b6:404:107::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.15; Sun, 2 Jan 2022 06:59:58 +0000 Received: from DM6NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::79) by DM6PR18CA0034.outlook.office365.com (2603:10b6:5:15b::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.14 via Frontend Transport; Sun, 2 Jan 2022 06:59:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT004.mail.protection.outlook.com (10.13.172.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4844.14 via Frontend Transport; Sun, 2 Jan 2022 06:59:57 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 2 Jan 2022 06:59:57 +0000 Received: from nvidia.com (172.20.187.5) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.9; Sat, 1 Jan 2022 22:59:55 -0800 From: To: CC: Matan Azrad , Thomas Monjalon , Michael Baum Subject: [RFC 3/3] common/mlx5: refactore devargs management Date: Sun, 2 Jan 2022 08:59:26 +0200 Message-ID: <20220102065927.2210733-4-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220102065927.2210733-1-michaelba@nvidia.com> References: <20220102065927.2210733-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ab6f7c5-b882-4276-6f55-08d9cdbd7cf6 X-MS-TrafficTypeDiagnostic: BN6PR12MB1732:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AYojOO9uyGTB/FC1N+aDM4uguDncWg6TaR+WZbsgANKIqxv2e5tIVtEwb77mogbK/bjtIeYjU7LCdJbIl9mrthlzp5AcjcPyS0hgIeiaAqQyRRtxoIUmZDpnqURwr+jfa6/D1uHPXekmcAfodnTwMXAgMOPXpuHbiqvL+eJ3ozzMVa/xUX7JhGBQHhTfo7Fpa+iOawwPYm6szYuTEqdBIxsggsEP3E5ICFJ0M8wpM8uknrMyxN7CvQ6C7zZhEDgt+92GjSpzrba4cILVyefU3bGJJIVmDbUkAFxqX0Yzqi9mn++Z7t8bGy0kpP724u2Q7LROIvaBKSVy1uVSuTBz4E8YIqMjz+D2JQKLvPMBVQ+ZwDrsc01T+MiUFoo/2GkkZ6XGiGDpnTcwcHCza1QIk0jze8MbePN5eG5eVx1bSTU/95N87ixIU9wAfMYRQHsAbQmn915ah/OSx5OA3B4bhaD8laEWQMpDh7Wwzx0FTnaon2o25xe4ZZdLjZJ6oLwKunu/3RNQlKQ0D2J19qA42k+T76H/JxP30VNtjoaSpK8sFpH4FcPD1TmvcKmLBQV6Q45SasWaCEUHAN+cycmas8kUi2diMp3BjJYx7rCLGAb8X8Bfu2Q/roEiW6NNl6KQpOn2LQG5VFmgGry09bJOMbI1kFBR9whx/dxXgfYzH29/tM45Jh/iW423OQQcKzCorPPmRFDsfvaTCcNWcNPt9i0e6hcj/shEEPO5LjiPvksmj0QlRzWhgoVrYu2RdWi9eLO37EZQkE3Gv9eeeekEkcHyRiGtGGjpoP/PXPxU5JA= X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(40470700002)(26005)(82310400004)(81166007)(186003)(16526019)(1076003)(316002)(356005)(8676002)(2616005)(336012)(8936002)(83380400001)(5660300002)(70586007)(70206006)(426003)(2876002)(36756003)(2906002)(6916009)(6666004)(107886003)(36860700001)(508600001)(7696005)(86362001)(30864003)(55016003)(40460700001)(6286002)(54906003)(47076005)(4326008)(36900700001)(579004)(559001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2022 06:59:57.6955 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ab6f7c5-b882-4276-6f55-08d9cdbd7cf6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1732 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Michael Baum Improve the devargs handling in the following aspects: - Parse the devargs string only once. - Return error and report for unknown keys. - Return error for changing common devargs in probe again. Signed-off-by: Michael Baum --- drivers/common/mlx5/mlx5_common.c | 313 +++++++++++++++++++++++--- drivers/common/mlx5/mlx5_common.h | 36 ++- drivers/common/mlx5/version.map | 2 + drivers/compress/mlx5/mlx5_compress.c | 38 ++-- drivers/crypto/mlx5/mlx5_crypto.c | 39 ++-- drivers/net/mlx5/linux/mlx5_os.c | 127 +++++++---- drivers/net/mlx5/mlx5.c | 176 +-------------- drivers/net/mlx5/mlx5.h | 139 +++++++++++- drivers/net/mlx5/windows/mlx5_os.c | 147 ++++++++---- drivers/regex/mlx5/mlx5_regex.c | 3 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 32 +-- 11 files changed, 703 insertions(+), 349 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index bc34399e22..9a21961965 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -21,6 +21,24 @@ uint8_t haswell_broadwell_cpu; +/* Driver type key for new device global syntax. */ +#define MLX5_DRIVER_KEY "driver" + +/* Enable extending memsegs when creating a MR. */ +#define MLX5_MR_EXT_MEMSEG_EN "mr_ext_memseg_en" + +/* Device parameter to configure implicit registration of mempool memory. */ +#define MLX5_MR_MEMPOOL_REG_EN "mr_mempool_reg_en" + +/* The default memory allocator used in PMD. */ +#define MLX5_SYS_MEM_EN "sys_mem_en" + +/* + * Device parameter to force doorbell register mapping + * to non-cahed region eliminating the extra write memory barrier. + */ +#define MLX5_TX_DB_NC "tx_db_nc" + /* In case this is an x86_64 intel processor to check if * we should use relaxed ordering. */ @@ -92,6 +110,120 @@ driver_get(uint32_t class) return NULL; } +int +mlx5_kvargs_process(struct mlx5_kvargs_ctrl *mkvlist, const char *const keys[], + arg_handler_t handler, void *opaque_arg) +{ + const struct rte_kvargs_pair *pair; + uint32_t i, j; + + MLX5_ASSERT(mkvlist && mkvlist->kvlist); + /* Process parameters. */ + for (i = 0; i < mkvlist->kvlist->count; i++) { + pair = &mkvlist->kvlist->pairs[i]; + for (j = 0; keys[j] != NULL; ++j) { + if (strcmp(pair->key, keys[j]) != 0) + continue; + if ((*handler)(pair->key, pair->value, opaque_arg) < 0) + return -1; + mkvlist->is_used[i] = true; + break; + } + } + return 0; +} + +/** + * Prepare a mlx5 kvargs control. + * + * @param[out] mkvlist + * Pointer to mlx5 kvargs control. + * @param[in] devargs + * The input string containing the key/value associations. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_kvargs_prepare(struct mlx5_kvargs_ctrl *mkvlist, + const struct rte_devargs *devargs) +{ + struct rte_kvargs *kvlist; + uint32_t i; + + if (devargs == NULL) + return 0; + kvlist = rte_kvargs_parse(devargs->args, NULL); + if (kvlist == NULL) { + rte_errno = EINVAL; + return -rte_errno; + } + /* + * rte_kvargs_parse enable key without value, in mlx5 PMDs we disable + * this syntax. + */ + for (i = 0; i < kvlist->count; i++) { + const struct rte_kvargs_pair *pair = &kvlist->pairs[i]; + if (pair->value == NULL || *(pair->value) == '\0') { + DRV_LOG(ERR, "Key %s is missing value.", pair->key); + rte_kvargs_free(kvlist); + rte_errno = EINVAL; + return -rte_errno; + } + } + /* Makes sure all devargs used array is false. */ + memset(mkvlist, 0, sizeof(*mkvlist)); + mkvlist->kvlist = kvlist; + DRV_LOG(DEBUG, "Parse successfully %u devargs.", + mkvlist->kvlist->count); + return 0; +} + +/** + * Release a mlx5 kvargs control. + * + * @param[out] mkvlist + * Pointer to mlx5 kvargs control. + */ +static void +mlx5_kvargs_release(struct mlx5_kvargs_ctrl *mkvlist) +{ + if (mkvlist == NULL) + return; + rte_kvargs_free(mkvlist->kvlist); +} + +/** + * Validate device arguments list. + * It report about the first unknown parameter. + * + * @param[in] mkvlist + * Pointer to mlx5 kvargs control. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_kvargs_validate(struct mlx5_kvargs_ctrl *mkvlist) +{ + uint32_t i; + + /* Secondary process should not handle devargs. */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + if (mkvlist == NULL) + return 0; + for (i = 0; i < mkvlist->kvlist->count; i++) { + if (mkvlist->is_used[i] == 0) { + DRV_LOG(ERR, "Key \"%s\" is unknown.", + mkvlist->kvlist->pairs[i].key); + rte_errno = EINVAL; + return -rte_errno; + } + } + return 0; +} + /** * Verify and store value for devargs. * @@ -111,11 +243,9 @@ mlx5_common_args_check_handler(const char *key, const char *val, void *opaque) struct mlx5_common_dev_config *config = opaque; signed long tmp; - if (val == NULL || *val == '\0') { - DRV_LOG(ERR, "Key %s is missing value.", key); - rte_errno = EINVAL; - return -rte_errno; - } + if (strcmp(MLX5_DRIVER_KEY, key) == 0 || + strcmp(RTE_DEVARGS_KEY_CLASS, key) == 0) + return 0; errno = 0; tmp = strtol(val, NULL, 0); if (errno) { @@ -154,29 +284,34 @@ mlx5_common_args_check_handler(const char *key, const char *val, void *opaque) * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_common_config_get(struct rte_devargs *devargs, +mlx5_common_config_get(struct mlx5_kvargs_ctrl *mkvlist, struct mlx5_common_dev_config *config) { - struct rte_kvargs *kvlist; + const char **params = (const char *[]){ + RTE_DEVARGS_KEY_CLASS, + MLX5_DRIVER_KEY, + MLX5_TX_DB_NC, + MLX5_MR_EXT_MEMSEG_EN, + MLX5_SYS_MEM_EN, + MLX5_MR_MEMPOOL_REG_EN, + NULL, + }; int ret = 0; + if (mkvlist == NULL) + return 0; /* Set defaults. */ config->mr_ext_memseg_en = 1; config->mr_mempool_reg_en = 1; config->sys_mem_en = 0; config->dbnc = MLX5_ARG_UNSET; - if (devargs == NULL) - return 0; - kvlist = rte_kvargs_parse(devargs->args, NULL); - if (kvlist == NULL) { + /* Process common parameters. */ + ret = mlx5_kvargs_process(mkvlist, params, + mlx5_common_args_check_handler, config); + if (ret) { rte_errno = EINVAL; - return -rte_errno; - } - ret = rte_kvargs_process(kvlist, NULL, mlx5_common_args_check_handler, - config); - if (ret) ret = -rte_errno; - rte_kvargs_free(kvlist); + } DRV_LOG(DEBUG, "mr_ext_memseg_en is %u.", config->mr_ext_memseg_en); DRV_LOG(DEBUG, "mr_mempool_reg_en is %u.", config->mr_mempool_reg_en); DRV_LOG(DEBUG, "sys_mem_en is %u.", config->sys_mem_en); @@ -225,9 +360,9 @@ devargs_class_handler(__rte_unused const char *key, } static int -parse_class_options(const struct rte_devargs *devargs) +parse_class_options(const struct rte_devargs *devargs, + struct mlx5_kvargs_ctrl *mkvlist) { - struct rte_kvargs *kvlist; int ret = 0; if (devargs == NULL) @@ -236,12 +371,8 @@ parse_class_options(const struct rte_devargs *devargs) /* Global syntax, only one class type. */ return class_name_to_value(devargs->cls->name); /* Legacy devargs support multiple classes. */ - kvlist = rte_kvargs_parse(devargs->args, NULL); - if (kvlist == NULL) - return 0; - rte_kvargs_process(kvlist, RTE_DEVARGS_KEY_CLASS, + rte_kvargs_process(mkvlist->kvlist, RTE_DEVARGS_KEY_CLASS, devargs_class_handler, &ret); - rte_kvargs_free(kvlist); return ret; } @@ -564,7 +695,8 @@ mlx5_common_dev_release(struct mlx5_common_device *cdev) } static struct mlx5_common_device * -mlx5_common_dev_create(struct rte_device *eal_dev, uint32_t classes) +mlx5_common_dev_create(struct rte_device *eal_dev, uint32_t classes, + struct mlx5_kvargs_ctrl *mkvlist) { struct mlx5_common_device *cdev; int ret; @@ -579,7 +711,7 @@ mlx5_common_dev_create(struct rte_device *eal_dev, uint32_t classes) if (rte_eal_process_type() != RTE_PROC_PRIMARY) goto exit; /* Parse device parameters. */ - ret = mlx5_common_config_get(eal_dev->devargs, &cdev->config); + ret = mlx5_common_config_get(mkvlist, &cdev->config); if (ret < 0) { DRV_LOG(ERR, "Failed to process device arguments: %s", strerror(rte_errno)); @@ -613,6 +745,79 @@ mlx5_common_dev_create(struct rte_device *eal_dev, uint32_t classes) return cdev; } +/** + * Check sibling device configurations when probing again. + * + * Sibling devices sharing infiniband device context should have compatible + * configurations. This regards representors and bonding slaves. + * + * @param cdev + * Pointer to mlx5 device structure. + * @param mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_common_probe_again_args_validate(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist) +{ + struct mlx5_common_dev_config *config; + int ret; + + /* Secondary process should not handle devargs. */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + /* Probe again doesn't have to send devargs. */ + if (mkvlist == NULL) + return 0; + config = mlx5_malloc(MLX5_MEM_ZERO | MLX5_MEM_RTE, + sizeof(struct mlx5_common_dev_config), + RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); + if (config == NULL) { + rte_errno = -ENOMEM; + return -rte_errno; + } + ret = mlx5_common_config_get(mkvlist, config); + if (ret) { + DRV_LOG(ERR, "Failed to process device configure: %s", + strerror(rte_errno)); + mlx5_free(config); + return ret; + } + /* Check sibling device configurations. */ + if (cdev->config.mr_ext_memseg_en ^ config->mr_ext_memseg_en) { + DRV_LOG(ERR, "\"mr_ext_memseg_en\" " + "configuration mismatch for device %s.", + cdev->dev->name); + goto error; + } + if (cdev->config.mr_mempool_reg_en ^ config->mr_mempool_reg_en) { + DRV_LOG(ERR, "\"mr_mempool_reg_en\" " + "configuration mismatch for device %s.", + cdev->dev->name); + goto error; + } + if (cdev->config.sys_mem_en ^ config->sys_mem_en) { + DRV_LOG(ERR, + "\"sys_mem_en\" configuration mismatch for device %s.", + cdev->dev->name); + goto error; + } + if (cdev->config.dbnc ^ config->dbnc) { + DRV_LOG(ERR, "\"dbnc\" configuration mismatch for device %s.", + cdev->dev->name); + goto error; + } + mlx5_free(config); + return 0; +error: + mlx5_free(config); + rte_errno = EINVAL; + return -rte_errno; +} + static int drivers_remove(struct mlx5_common_device *cdev, uint32_t enabled_classes) { @@ -639,7 +844,8 @@ drivers_remove(struct mlx5_common_device *cdev, uint32_t enabled_classes) } static int -drivers_probe(struct mlx5_common_device *cdev, uint32_t user_classes) +drivers_probe(struct mlx5_common_device *cdev, uint32_t user_classes, + struct mlx5_kvargs_ctrl *mkvlist) { struct mlx5_class_driver *driver; uint32_t enabled_classes = 0; @@ -658,7 +864,7 @@ drivers_probe(struct mlx5_common_device *cdev, uint32_t user_classes) ret = -EEXIST; goto probe_err; } - ret = driver->probe(cdev); + ret = driver->probe(cdev, mkvlist); if (ret < 0) { DRV_LOG(ERR, "Failed to load driver %s", driver->name); @@ -682,16 +888,26 @@ int mlx5_common_dev_probe(struct rte_device *eal_dev) { struct mlx5_common_device *cdev; + struct mlx5_kvargs_ctrl mkvlist; + struct mlx5_kvargs_ctrl *mkvlist_p = NULL; uint32_t classes = 0; bool new_device = false; int ret; DRV_LOG(INFO, "probe device \"%s\".", eal_dev->name); - ret = parse_class_options(eal_dev->devargs); + if (eal_dev->devargs != NULL) + mkvlist_p = &mkvlist; + ret = mlx5_kvargs_prepare(mkvlist_p, eal_dev->devargs); + if (ret < 0) { + DRV_LOG(ERR, "Unsupported device arguments: %s", + eal_dev->devargs->args); + goto class_err; + } + ret = parse_class_options(eal_dev->devargs, mkvlist_p); if (ret < 0) { DRV_LOG(ERR, "Unsupported mlx5 class type: %s", eal_dev->devargs->args); - return ret; + goto class_err; } classes = ret; if (classes == 0) @@ -699,10 +915,20 @@ mlx5_common_dev_probe(struct rte_device *eal_dev) classes = MLX5_CLASS_ETH; cdev = to_mlx5_device(eal_dev); if (!cdev) { - cdev = mlx5_common_dev_create(eal_dev, classes); - if (!cdev) - return -ENOMEM; + cdev = mlx5_common_dev_create(eal_dev, classes, mkvlist_p); + if (!cdev) { + ret = -ENOMEM; + goto class_err; + } new_device = true; + } else { + ret = mlx5_common_probe_again_args_validate(cdev, mkvlist_p); + if (ret) { + DRV_LOG(ERR, + "Probe again parameters aren't compatible : %s", + strerror(rte_errno)); + return ret; + } } /* * Validate combination here. @@ -714,13 +940,30 @@ mlx5_common_dev_probe(struct rte_device *eal_dev) DRV_LOG(ERR, "Unsupported mlx5 classes combination."); goto class_err; } - ret = drivers_probe(cdev, classes); + ret = drivers_probe(cdev, classes, mkvlist_p); + if (ret) + goto class_err; + /* + * Validate that all devargs have been used, unused key -> unknown Key. + * When probe again validate is failed, the added drivers aren't removed + * here but when device is released. + */ + ret = mlx5_kvargs_validate(mkvlist_p); if (ret) goto class_err; + mlx5_kvargs_release(mkvlist_p); return 0; class_err: - if (new_device) + if (new_device) { + /* + * For new device, classes_loaded is always 0 before + * drivers_probe function. + */ + if (cdev->classes_loaded) + drivers_remove(cdev, cdev->classes_loaded); mlx5_common_dev_release(cdev); + } + mlx5_kvargs_release(mkvlist_p); return ret; } diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 80f59c81fb..49bcea1d91 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -281,6 +281,37 @@ struct mlx5_klm { uint64_t address; }; +/** Control for key/values list. */ +struct mlx5_kvargs_ctrl { + struct rte_kvargs *kvlist; /* Structure containing list of key/values.*/ + bool is_used[RTE_KVARGS_MAX]; /* Indicator which devargs were used. */ +}; + +/** + * Call a handler function for each key/value in the list of keys. + * + * For each key/value association that matches the given key, calls the + * handler function with the for a given arg_name passing the value on the + * dictionary for that key and a given extra argument. + * + * @param mkvlist + * The mlx5_kvargs structure. + * @param keys + * A list of keys to process (table of const char *, the last must be NULL). + * @param handler + * The function to call for each matching key. + * @param opaque_arg + * A pointer passed unchanged to the handler. + * + * @return + * - 0 on success + * - Negative on error + */ +__rte_internal +int +mlx5_kvargs_process(struct mlx5_kvargs_ctrl *mkvlist, const char *const keys[], + arg_handler_t handler, void *opaque_arg); + /* All UAR arguments using doorbell register in datapath. */ struct mlx5_uar_data { uint64_t *db; @@ -437,12 +468,13 @@ struct mlx5_common_device { /** * Initialization function for the driver called during device probing. */ -typedef int (mlx5_class_driver_probe_t)(struct mlx5_common_device *dev); +typedef int (mlx5_class_driver_probe_t)(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist); /** * Uninitialization function for the driver called during hot-unplugging. */ -typedef int (mlx5_class_driver_remove_t)(struct mlx5_common_device *dev); +typedef int (mlx5_class_driver_remove_t)(struct mlx5_common_device *cdev); /** Device already probed can be probed again to check for new ports. */ #define MLX5_DRV_PROBE_AGAIN 0x0004 diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index 30caa090fd..558b334118 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -85,6 +85,8 @@ INTERNAL { mlx5_glue; + mlx5_kvargs_process; + mlx5_list_create; mlx5_list_register; mlx5_list_unregister; diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c index 82b871bd86..3fc7f4c434 100644 --- a/drivers/compress/mlx5/mlx5_compress.c +++ b/drivers/compress/mlx5/mlx5_compress.c @@ -657,41 +657,36 @@ mlx5_compress_args_check_handler(const char *key, const char *val, void *opaque) errno = 0; devarg_prms->log_block_sz = (uint32_t)strtoul(val, NULL, 10); if (errno) { - DRV_LOG(WARNING, "%s: \"%s\" is an invalid integer." - , key, val); + DRV_LOG(WARNING, "%s: \"%s\" is an invalid integer.", + key, val); return -errno; } - return 0; } return 0; } static int -mlx5_compress_handle_devargs(struct rte_devargs *devargs, - struct mlx5_compress_devarg_params *devarg_prms, - struct mlx5_hca_attr *att) +mlx5_compress_handle_devargs(struct mlx5_kvargs_ctrl *mkvlist, + struct mlx5_compress_devarg_params *devarg_prms, + struct mlx5_hca_attr *att) { - struct rte_kvargs *kvlist; + const char **params = (const char *[]){ + "log-block-size", + NULL, + }; devarg_prms->log_block_sz = MLX5_GGA_COMP_LOG_BLOCK_SIZE_MAX; - if (devargs == NULL) + if (mkvlist == NULL) return 0; - kvlist = rte_kvargs_parse(devargs->args, NULL); - if (kvlist == NULL) { - DRV_LOG(ERR, "Failed to parse devargs."); - rte_errno = EINVAL; - return -1; - } - if (rte_kvargs_process(kvlist, NULL, mlx5_compress_args_check_handler, - devarg_prms) != 0) { + if (mlx5_kvargs_process(mkvlist, params, + mlx5_compress_args_check_handler, + devarg_prms) != 0) { DRV_LOG(ERR, "Devargs handler function Failed."); - rte_kvargs_free(kvlist); rte_errno = EINVAL; return -1; } - rte_kvargs_free(kvlist); if (devarg_prms->log_block_sz > MLX5_GGA_COMP_LOG_BLOCK_SIZE_MAX || - devarg_prms->log_block_sz < att->compress_min_block_size) { + devarg_prms->log_block_sz < att->compress_min_block_size) { DRV_LOG(WARNING, "Log block size provided is out of range(" "%u); default it to %u.", devarg_prms->log_block_sz, @@ -702,7 +697,8 @@ mlx5_compress_handle_devargs(struct rte_devargs *devargs, } static int -mlx5_compress_dev_probe(struct mlx5_common_device *cdev) +mlx5_compress_dev_probe(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist) { struct rte_compressdev *compressdev; struct mlx5_compress_priv *priv; @@ -726,7 +722,7 @@ mlx5_compress_dev_probe(struct mlx5_common_device *cdev) rte_errno = ENOTSUP; return -ENOTSUP; } - mlx5_compress_handle_devargs(cdev->dev->devargs, &devarg_prms, attr); + mlx5_compress_handle_devargs(mkvlist, &devarg_prms, attr); compressdev = rte_compressdev_pmd_create(ibdev_name, cdev->dev, sizeof(*priv), &init_params); if (compressdev == NULL) { diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index 421c23748a..e14f867797 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -722,8 +722,6 @@ mlx5_crypto_args_check_handler(const char *key, const char *val, void *opaque) int ret; int i; - if (strcmp(key, "class") == 0) - return 0; if (strcmp(key, "wcs_file") == 0) { file = fopen(val, "rb"); if (file == NULL) { @@ -763,48 +761,44 @@ mlx5_crypto_args_check_handler(const char *key, const char *val, void *opaque) attr->credential_pointer = (uint32_t)tmp; } else if (strcmp(key, "keytag") == 0) { devarg_prms->keytag = tmp; - } else { - DRV_LOG(WARNING, "Invalid key %s.", key); } return 0; } static int -mlx5_crypto_parse_devargs(struct rte_devargs *devargs, +mlx5_crypto_parse_devargs(struct mlx5_kvargs_ctrl *mkvlist, struct mlx5_crypto_devarg_params *devarg_prms) { struct mlx5_devx_crypto_login_attr *attr = &devarg_prms->login_attr; - struct rte_kvargs *kvlist; + const char **params = (const char *[]){ + "credential_id", + "import_kek_id", + "keytag", + "max_segs_num", + "wcs_file", + NULL, + }; /* Default values. */ attr->credential_pointer = 0; attr->session_import_kek_ptr = 0; devarg_prms->keytag = 0; devarg_prms->max_segs_num = 8; - if (devargs == NULL) { + if (mkvlist == NULL) { DRV_LOG(ERR, - "No login devargs in order to enable crypto operations in the device."); - rte_errno = EINVAL; - return -1; - } - kvlist = rte_kvargs_parse(devargs->args, NULL); - if (kvlist == NULL) { - DRV_LOG(ERR, "Failed to parse devargs."); + "No login devargs in order to enable crypto operations in the device."); rte_errno = EINVAL; return -1; } - if (rte_kvargs_process(kvlist, NULL, mlx5_crypto_args_check_handler, - devarg_prms) != 0) { + if (mlx5_kvargs_process(mkvlist, params, mlx5_crypto_args_check_handler, + devarg_prms) != 0) { DRV_LOG(ERR, "Devargs handler function Failed."); - rte_kvargs_free(kvlist); rte_errno = EINVAL; return -1; } - rte_kvargs_free(kvlist); if (devarg_prms->login_devarg == false) { DRV_LOG(ERR, - "No login credential devarg in order to enable crypto operations " - "in the device."); + "No login credential devarg in order to enable crypto operations in the device."); rte_errno = EINVAL; return -1; } @@ -887,7 +881,8 @@ mlx5_crypto_configure_wqe_size(struct mlx5_crypto_priv *priv, } static int -mlx5_crypto_dev_probe(struct mlx5_common_device *cdev) +mlx5_crypto_dev_probe(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist) { struct rte_cryptodev *crypto_dev; struct mlx5_devx_obj *login; @@ -914,7 +909,7 @@ mlx5_crypto_dev_probe(struct mlx5_common_device *cdev) rte_errno = ENOTSUP; return -ENOTSUP; } - ret = mlx5_crypto_parse_devargs(cdev->dev->devargs, &devarg_prms); + ret = mlx5_crypto_parse_devargs(mkvlist, &devarg_prms); if (ret) { DRV_LOG(ERR, "Failed to parse devargs."); return -rte_errno; diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index f90888fe72..8e4ddf2ae3 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -825,8 +825,8 @@ mlx5_representor_match(struct mlx5_dev_spawn_data *spawn, * * @param priv * Pointer to shared device context. - * @param devargs - * Device arguments structure. + * @param mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * @param config * Pointer to port configuration structure. * @@ -834,13 +834,39 @@ mlx5_representor_match(struct mlx5_dev_spawn_data *spawn, * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_os_port_args_config(struct mlx5_priv *priv, struct rte_devargs *devargs, +mlx5_os_port_args_config(struct mlx5_priv *priv, + struct mlx5_kvargs_ctrl *mkvlist, struct mlx5_port_config *config) { - struct rte_kvargs *kvlist; struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr; struct mlx5_dev_attr *dev_attr = &priv->sh->device_attr; bool devx = priv->sh->cdev->config.devx; + const char **params = (const char *[]){ + MLX5_RXQ_CQE_COMP_EN, + MLX5_RXQ_PKT_PAD_EN, + MLX5_RX_MPRQ_EN, + MLX5_RX_MPRQ_LOG_STRIDE_NUM, + MLX5_RX_MPRQ_LOG_STRIDE_SIZE, + MLX5_RX_MPRQ_MAX_MEMCPY_LEN, + MLX5_RXQS_MIN_MPRQ, + MLX5_TXQ_INLINE, + MLX5_TXQ_INLINE_MIN, + MLX5_TXQ_INLINE_MAX, + MLX5_TXQ_INLINE_MPW, + MLX5_TXQS_MIN_INLINE, + MLX5_TXQS_MAX_VEC, + MLX5_TXQ_MPW_EN, + MLX5_TXQ_MPW_HDR_DSEG_EN, + MLX5_TXQ_MAX_INLINE_LEN, + MLX5_TX_VEC_EN, + MLX5_RX_VEC_EN, + MLX5_REPRESENTOR, + MLX5_MAX_DUMP_FILES_NUM, + MLX5_LRO_TIMEOUT_USEC, + MLX5_HP_BUF_SIZE, + MLX5_DELAY_DROP, + NULL, + }; uint32_t hw_padding = 0; uint32_t mps; int ret = 0; @@ -860,19 +886,10 @@ mlx5_os_port_args_config(struct mlx5_priv *priv, struct rte_devargs *devargs, config->log_hp_size = MLX5_ARG_UNSET; config->std_delay_drop = 0; config->hp_delay_drop = 0; - /* Parse device parameters. */ - if (devargs != NULL) { - kvlist = rte_kvargs_parse(devargs->args, NULL); - if (kvlist == NULL) { - DRV_LOG(ERR, - "Failed to parse device arguments."); - rte_errno = EINVAL; - return -rte_errno; - } + if (mkvlist != NULL) { /* Process parameters. */ - ret = rte_kvargs_process(kvlist, NULL, - mlx5_port_args_check_handler, config); - rte_kvargs_free(kvlist); + ret = mlx5_kvargs_process(mkvlist, params, + mlx5_port_args_check_handler, config); if (ret) { DRV_LOG(ERR, "Failed to process port arguments: %s", strerror(rte_errno)); @@ -1012,8 +1029,8 @@ mlx5_os_port_args_config(struct mlx5_priv *priv, struct rte_devargs *devargs, * * @param sh * Pointer to shared device context. - * @param devargs - * Device arguments structure. + * @param mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * @param config * Pointer to shared device configuration structure. * @@ -1022,11 +1039,24 @@ mlx5_os_port_args_config(struct mlx5_priv *priv, struct rte_devargs *devargs, */ int mlx5_os_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, - struct rte_devargs *devargs, + struct mlx5_kvargs_ctrl *mkvlist, struct mlx5_sh_config *config) { - struct rte_kvargs *kvlist; struct mlx5_hca_attr *hca_attr = &sh->cdev->config.hca_attr; + const char **params = (const char *[]){ + MLX5_TX_PP, + MLX5_TX_SKEW, + MLX5_L3_VXLAN_EN, + MLX5_VF_NL_EN, + MLX5_DV_ESW_EN, + MLX5_DV_FLOW_EN, + MLX5_DV_XMETA_EN, + MLX5_LACP_BY_USER, + MLX5_RECLAIM_MEM, + MLX5_DECAP_EN, + MLX5_ALLOW_DUPLICATE_PATTERN, + NULL, + }; int ret = 0; /* Default configuration. */ @@ -1036,19 +1066,10 @@ mlx5_os_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, config->dv_flow_en = 1; config->decap_en = 1; config->allow_duplicate_pattern = 1; - /* Parse device parameters. */ - if (devargs != NULL) { - kvlist = rte_kvargs_parse(devargs->args, NULL); - if (kvlist == NULL) { - DRV_LOG(ERR, - "Failed to parse shared device arguments."); - rte_errno = EINVAL; - return -rte_errno; - } + if (mkvlist != NULL) { /* Process parameters. */ - ret = rte_kvargs_process(kvlist, NULL, - mlx5_dev_args_check_handler, config); - rte_kvargs_free(kvlist); + ret = mlx5_kvargs_process(mkvlist, params, + mlx5_dev_args_check_handler, config); if (ret) { DRV_LOG(ERR, "Failed to process device arguments: %s", strerror(rte_errno)); @@ -1379,6 +1400,8 @@ mlx5_os_cap_config(struct mlx5_dev_ctx_shared *sh) * Verbs device parameters (name, port, switch_info) to spawn. * @param eth_da * Device arguments. + * @param mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * * @return * A valid Ethernet device object on success, NULL otherwise and rte_errno @@ -1390,7 +1413,8 @@ mlx5_os_cap_config(struct mlx5_dev_ctx_shared *sh) static struct rte_eth_dev * mlx5_dev_spawn(struct rte_device *dpdk_dev, struct mlx5_dev_spawn_data *spawn, - struct rte_eth_devargs *eth_da) + struct rte_eth_devargs *eth_da, + struct mlx5_kvargs_ctrl *mkvlist) { const struct mlx5_switch_info *switch_info = &spawn->info; struct mlx5_dev_ctx_shared *sh = NULL; @@ -1481,7 +1505,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, mlx5_dev_close(eth_dev); return NULL; } - sh = mlx5_alloc_shared_dev_ctx(spawn); + sh = mlx5_alloc_shared_dev_ctx(spawn, mkvlist); if (!sh) return NULL; nl_rdma = mlx5_nl_init(NETLINK_RDMA); @@ -1637,7 +1661,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->dev_port, priv->domain_id); } /* Process parameters and store port configuration on priv structure. */ - err = mlx5_os_port_args_config(priv, dpdk_dev->devargs, &priv->config); + err = mlx5_os_port_args_config(priv, mkvlist, &priv->config); if (err) { err = rte_errno; DRV_LOG(ERR, "Failed to process port configure: %s", @@ -2123,6 +2147,8 @@ mlx5_device_bond_pci_match(const char *ibdev_name, * Requested ethdev device argument. * @param[in] owner_id * Requested owner PF port ID within bonding device, default to 0. + * @param[in, out] mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. @@ -2130,7 +2156,8 @@ mlx5_device_bond_pci_match(const char *ibdev_name, static int mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev, struct rte_eth_devargs *req_eth_da, - uint16_t owner_id) + uint16_t owner_id, + struct mlx5_kvargs_ctrl *mkvlist) { struct ibv_device **ibv_list; /* @@ -2500,7 +2527,8 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev, for (i = 0; i != ns; ++i) { uint32_t restore; - list[i].eth_dev = mlx5_dev_spawn(cdev->dev, &list[i], ð_da); + list[i].eth_dev = mlx5_dev_spawn(cdev->dev, &list[i], ð_da, + mkvlist); if (!list[i].eth_dev) { if (rte_errno != EBUSY && rte_errno != EEXIST) break; @@ -2612,12 +2640,15 @@ mlx5_os_parse_eth_devargs(struct rte_device *dev, * * @param[in] cdev * Pointer to common mlx5 device structure. + * @param[in, out] mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_os_pci_probe(struct mlx5_common_device *cdev) +mlx5_os_pci_probe(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist) { struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(cdev->dev); struct rte_eth_devargs eth_da = { .nb_ports = 0 }; @@ -2632,7 +2663,7 @@ mlx5_os_pci_probe(struct mlx5_common_device *cdev) /* Iterate all port if devargs pf is range: "pf[0-1]vf[...]". */ for (p = 0; p < eth_da.nb_ports; p++) { ret = mlx5_os_pci_probe_pf(cdev, ð_da, - eth_da.ports[p]); + eth_da.ports[p], mkvlist); if (ret) break; } @@ -2645,14 +2676,15 @@ mlx5_os_pci_probe(struct mlx5_common_device *cdev) mlx5_net_remove(cdev); } } else { - ret = mlx5_os_pci_probe_pf(cdev, ð_da, 0); + ret = mlx5_os_pci_probe_pf(cdev, ð_da, 0, mkvlist); } return ret; } /* Probe a single SF device on auxiliary bus, no representor support. */ static int -mlx5_os_auxiliary_probe(struct mlx5_common_device *cdev) +mlx5_os_auxiliary_probe(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist) { struct rte_eth_devargs eth_da = { .nb_ports = 0 }; struct mlx5_dev_spawn_data spawn = { .pf_bond = -1 }; @@ -2677,7 +2709,7 @@ mlx5_os_auxiliary_probe(struct mlx5_common_device *cdev) spawn.ifindex = ret; spawn.cdev = cdev; /* Spawn device. */ - eth_dev = mlx5_dev_spawn(dev, &spawn, ð_da); + eth_dev = mlx5_dev_spawn(dev, &spawn, ð_da, mkvlist); if (eth_dev == NULL) return -rte_errno; /* Post create. */ @@ -2698,12 +2730,15 @@ mlx5_os_auxiliary_probe(struct mlx5_common_device *cdev) * * @param[in] cdev * Pointer to the common mlx5 device. + * @param[in, out] mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ int -mlx5_os_net_probe(struct mlx5_common_device *cdev) +mlx5_os_net_probe(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist) { int ret; @@ -2715,16 +2750,16 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev) strerror(rte_errno)); return -rte_errno; } - ret = mlx5_probe_again_args_validate(cdev); + ret = mlx5_probe_again_args_validate(cdev, mkvlist); if (ret) { DRV_LOG(ERR, "Probe again parameters are not compatible : %s", strerror(rte_errno)); return -rte_errno; } if (mlx5_dev_is_pci(cdev->dev)) - return mlx5_os_pci_probe(cdev); + return mlx5_os_pci_probe(cdev, mkvlist); else - return mlx5_os_auxiliary_probe(cdev); + return mlx5_os_auxiliary_probe(cdev, mkvlist); } /** diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 12113f2811..7c4aa5db90 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -43,150 +43,6 @@ #define MLX5_ETH_DRIVER_NAME mlx5_eth -/* Driver type key for new device global syntax. */ -#define MLX5_DRIVER_KEY "driver" - -/* Device parameter to enable RX completion queue compression. */ -#define MLX5_RXQ_CQE_COMP_EN "rxq_cqe_comp_en" - -/* Device parameter to enable padding Rx packet to cacheline size. */ -#define MLX5_RXQ_PKT_PAD_EN "rxq_pkt_pad_en" - -/* Device parameter to enable Multi-Packet Rx queue. */ -#define MLX5_RX_MPRQ_EN "mprq_en" - -/* Device parameter to configure log 2 of the number of strides for MPRQ. */ -#define MLX5_RX_MPRQ_LOG_STRIDE_NUM "mprq_log_stride_num" - -/* Device parameter to configure log 2 of the stride size for MPRQ. */ -#define MLX5_RX_MPRQ_LOG_STRIDE_SIZE "mprq_log_stride_size" - -/* Device parameter to limit the size of memcpy'd packet for MPRQ. */ -#define MLX5_RX_MPRQ_MAX_MEMCPY_LEN "mprq_max_memcpy_len" - -/* Device parameter to set the minimum number of Rx queues to enable MPRQ. */ -#define MLX5_RXQS_MIN_MPRQ "rxqs_min_mprq" - -/* Device parameter to configure inline send. Deprecated, ignored.*/ -#define MLX5_TXQ_INLINE "txq_inline" - -/* Device parameter to limit packet size to inline with ordinary SEND. */ -#define MLX5_TXQ_INLINE_MAX "txq_inline_max" - -/* Device parameter to configure minimal data size to inline. */ -#define MLX5_TXQ_INLINE_MIN "txq_inline_min" - -/* Device parameter to limit packet size to inline with Enhanced MPW. */ -#define MLX5_TXQ_INLINE_MPW "txq_inline_mpw" - -/* - * Device parameter to configure the number of TX queues threshold for - * enabling inline send. - */ -#define MLX5_TXQS_MIN_INLINE "txqs_min_inline" - -/* - * Device parameter to configure the number of TX queues threshold for - * enabling vectorized Tx, deprecated, ignored (no vectorized Tx routines). - */ -#define MLX5_TXQS_MAX_VEC "txqs_max_vec" - -/* Device parameter to enable multi-packet send WQEs. */ -#define MLX5_TXQ_MPW_EN "txq_mpw_en" - -/* - * Device parameter to force doorbell register mapping - * to non-cahed region eliminating the extra write memory barrier. - */ -#define MLX5_TX_DB_NC "tx_db_nc" - -/* - * Device parameter to include 2 dsegs in the title WQEBB. - * Deprecated, ignored. - */ -#define MLX5_TXQ_MPW_HDR_DSEG_EN "txq_mpw_hdr_dseg_en" - -/* - * Device parameter to limit the size of inlining packet. - * Deprecated, ignored. - */ -#define MLX5_TXQ_MAX_INLINE_LEN "txq_max_inline_len" - -/* - * Device parameter to enable Tx scheduling on timestamps - * and specify the packet pacing granularity in nanoseconds. - */ -#define MLX5_TX_PP "tx_pp" - -/* - * Device parameter to specify skew in nanoseconds on Tx datapath, - * it represents the time between SQ start WQE processing and - * appearing actual packet data on the wire. - */ -#define MLX5_TX_SKEW "tx_skew" - -/* - * Device parameter to enable hardware Tx vector. - * Deprecated, ignored (no vectorized Tx routines anymore). - */ -#define MLX5_TX_VEC_EN "tx_vec_en" - -/* Device parameter to enable hardware Rx vector. */ -#define MLX5_RX_VEC_EN "rx_vec_en" - -/* Allow L3 VXLAN flow creation. */ -#define MLX5_L3_VXLAN_EN "l3_vxlan_en" - -/* Activate DV E-Switch flow steering. */ -#define MLX5_DV_ESW_EN "dv_esw_en" - -/* Activate DV flow steering. */ -#define MLX5_DV_FLOW_EN "dv_flow_en" - -/* Enable extensive flow metadata support. */ -#define MLX5_DV_XMETA_EN "dv_xmeta_en" - -/* Device parameter to let the user manage the lacp traffic of bonded device */ -#define MLX5_LACP_BY_USER "lacp_by_user" - -/* Activate Netlink support in VF mode. */ -#define MLX5_VF_NL_EN "vf_nl_en" - -/* Enable extending memsegs when creating a MR. */ -#define MLX5_MR_EXT_MEMSEG_EN "mr_ext_memseg_en" - -/* Select port representors to instantiate. */ -#define MLX5_REPRESENTOR "representor" - -/* Device parameter to configure the maximum number of dump files per queue. */ -#define MLX5_MAX_DUMP_FILES_NUM "max_dump_files_num" - -/* Configure timeout of LRO session (in microseconds). */ -#define MLX5_LRO_TIMEOUT_USEC "lro_timeout_usec" - -/* - * Device parameter to configure the total data buffer size for a single - * hairpin queue (logarithm value). - */ -#define MLX5_HP_BUF_SIZE "hp_buf_log_sz" - -/* Flow memory reclaim mode. */ -#define MLX5_RECLAIM_MEM "reclaim_mem_mode" - -/* The default memory allocator used in PMD. */ -#define MLX5_SYS_MEM_EN "sys_mem_en" -/* Decap will be used or not. */ -#define MLX5_DECAP_EN "decap_en" - -/* Device parameter to configure allow or prevent duplicate rules pattern. */ -#define MLX5_ALLOW_DUPLICATE_PATTERN "allow_duplicate_pattern" - -/* Device parameter to configure implicit registration of mempool memory. */ -#define MLX5_MR_MEMPOOL_REG_EN "mr_mempool_reg_en" - -/* Device parameter to configure the delay drop when creating Rxqs. */ -#define MLX5_DELAY_DROP "delay_drop" - /* Shared memory between primary and secondary processes. */ struct mlx5_shared_data *mlx5_shared_data; @@ -1276,13 +1132,16 @@ mlx5_rt_timestamp_config(struct mlx5_dev_ctx_shared *sh, * * @param[in] spawn * Pointer to the device attributes (name, port, etc). + * @param mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * * @return * Pointer to mlx5_dev_ctx_shared object on success, * otherwise NULL and rte_errno is set. */ struct mlx5_dev_ctx_shared * -mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn) +mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, + struct mlx5_kvargs_ctrl *mkvlist) { struct mlx5_dev_ctx_shared *sh; int err = 0; @@ -1321,8 +1180,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn) DRV_LOG(DEBUG, "mlx5_os_get_dev_attr() failed"); goto error; } - err = mlx5_os_shared_dev_ctx_args_config(sh, sh->cdev->dev->devargs, - &sh->config); + err = mlx5_os_shared_dev_ctx_args_config(sh, mkvlist, &sh->config); if (err) { DRV_LOG(ERR, "Failed to process device configure: %s", strerror(rte_errno)); @@ -2066,15 +1924,7 @@ mlx5_port_args_check_handler(const char *key, const char *val, void *opaque) signed long tmp; /* No-op, port representors are processed in mlx5_dev_spawn(). */ - if (!strcmp(MLX5_DRIVER_KEY, key) || !strcmp(MLX5_REPRESENTOR, key) || - !strcmp(MLX5_SYS_MEM_EN, key) || !strcmp(MLX5_TX_DB_NC, key) || - !strcmp(MLX5_MR_MEMPOOL_REG_EN, key) || !strcmp(MLX5_TX_PP, key) || - !strcmp(MLX5_MR_EXT_MEMSEG_EN, key) || !strcmp(MLX5_TX_SKEW, key) || - !strcmp(MLX5_RECLAIM_MEM, key) || !strcmp(MLX5_DECAP_EN, key) || - !strcmp(MLX5_ALLOW_DUPLICATE_PATTERN, key) || - !strcmp(MLX5_L3_VXLAN_EN, key) || !strcmp(MLX5_VF_NL_EN, key) || - !strcmp(MLX5_DV_ESW_EN, key) || !strcmp(MLX5_DV_FLOW_EN, key) || - !strcmp(MLX5_DV_XMETA_EN, key) || !strcmp(MLX5_LACP_BY_USER, key)) + if (!strcmp(MLX5_REPRESENTOR, key)) return 0; errno = 0; tmp = strtol(val, NULL, 0); @@ -2140,17 +1990,11 @@ mlx5_port_args_check_handler(const char *key, const char *val, void *opaque) config->max_dump_files_num = tmp; } else if (strcmp(MLX5_LRO_TIMEOUT_USEC, key) == 0) { config->lro.timeout = tmp; - } else if (strcmp(RTE_DEVARGS_KEY_CLASS, key) == 0) { - DRV_LOG(DEBUG, "class argument is %s.", val); } else if (strcmp(MLX5_HP_BUF_SIZE, key) == 0) { config->log_hp_size = tmp; } else if (strcmp(MLX5_DELAY_DROP, key) == 0) { config->std_delay_drop = !!(tmp & MLX5_DELAY_DROP_STANDARD); config->hp_delay_drop = !!(tmp & MLX5_DELAY_DROP_HAIRPIN); - } else { - DRV_LOG(WARNING, - "%s: unknown parameter, maybe it's for another class.", - key); } return 0; } @@ -2363,12 +2207,15 @@ rte_pmd_mlx5_get_dyn_flag_names(char *names[], unsigned int n) * * @param cdev * Pointer to mlx5 device structure. + * @param mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ int -mlx5_probe_again_args_validate(struct mlx5_common_device *cdev) +mlx5_probe_again_args_validate(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist) { struct mlx5_dev_ctx_shared *sh = NULL; struct mlx5_sh_config *config; @@ -2393,8 +2240,7 @@ mlx5_probe_again_args_validate(struct mlx5_common_device *cdev) rte_errno = -ENOMEM; return -rte_errno; } - ret = mlx5_os_shared_dev_ctx_args_config(sh, sh->cdev->dev->devargs, - config); + ret = mlx5_os_shared_dev_ctx_args_config(sh, mkvlist, config); if (ret) { DRV_LOG(ERR, "Failed to process device configure: %s", strerror(rte_errno)); diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index ed4c71aca9..c8dc42fef6 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -37,6 +37,134 @@ #define MLX5_SH(dev) (((struct mlx5_priv *)(dev)->data->dev_private)->sh) + +/* Device parameter to enable RX completion queue compression. */ +#define MLX5_RXQ_CQE_COMP_EN "rxq_cqe_comp_en" + +/* Device parameter to enable padding Rx packet to cacheline size. */ +#define MLX5_RXQ_PKT_PAD_EN "rxq_pkt_pad_en" + +/* Device parameter to enable Multi-Packet Rx queue. */ +#define MLX5_RX_MPRQ_EN "mprq_en" + +/* Device parameter to configure log 2 of the number of strides for MPRQ. */ +#define MLX5_RX_MPRQ_LOG_STRIDE_NUM "mprq_log_stride_num" + +/* Device parameter to configure log 2 of the stride size for MPRQ. */ +#define MLX5_RX_MPRQ_LOG_STRIDE_SIZE "mprq_log_stride_size" + +/* Device parameter to limit the size of memcpy'd packet for MPRQ. */ +#define MLX5_RX_MPRQ_MAX_MEMCPY_LEN "mprq_max_memcpy_len" + +/* Device parameter to set the minimum number of Rx queues to enable MPRQ. */ +#define MLX5_RXQS_MIN_MPRQ "rxqs_min_mprq" + +/* Device parameter to configure inline send. Deprecated, ignored.*/ +#define MLX5_TXQ_INLINE "txq_inline" + +/* Device parameter to limit packet size to inline with ordinary SEND. */ +#define MLX5_TXQ_INLINE_MAX "txq_inline_max" + +/* Device parameter to configure minimal data size to inline. */ +#define MLX5_TXQ_INLINE_MIN "txq_inline_min" + +/* Device parameter to limit packet size to inline with Enhanced MPW. */ +#define MLX5_TXQ_INLINE_MPW "txq_inline_mpw" + +/* + * Device parameter to configure the number of TX queues threshold for + * enabling inline send. + */ +#define MLX5_TXQS_MIN_INLINE "txqs_min_inline" + +/* + * Device parameter to configure the number of TX queues threshold for + * enabling vectorized Tx, deprecated, ignored (no vectorized Tx routines). + */ +#define MLX5_TXQS_MAX_VEC "txqs_max_vec" + +/* Device parameter to enable multi-packet send WQEs. */ +#define MLX5_TXQ_MPW_EN "txq_mpw_en" + +/* + * Device parameter to include 2 dsegs in the title WQEBB. + * Deprecated, ignored. + */ +#define MLX5_TXQ_MPW_HDR_DSEG_EN "txq_mpw_hdr_dseg_en" + +/* + * Device parameter to limit the size of inlining packet. + * Deprecated, ignored. + */ +#define MLX5_TXQ_MAX_INLINE_LEN "txq_max_inline_len" + +/* + * Device parameter to enable hardware Tx vector. + * Deprecated, ignored (no vectorized Tx routines anymore). + */ +#define MLX5_TX_VEC_EN "tx_vec_en" + +/* Device parameter to enable hardware Rx vector. */ +#define MLX5_RX_VEC_EN "rx_vec_en" + +/* Select port representors to instantiate. */ +#define MLX5_REPRESENTOR "representor" + +/* Device parameter to configure the maximum number of dump files per queue. */ +#define MLX5_MAX_DUMP_FILES_NUM "max_dump_files_num" + +/* Configure timeout of LRO session (in microseconds). */ +#define MLX5_LRO_TIMEOUT_USEC "lro_timeout_usec" + +/* + * Device parameter to configure the total data buffer size for a single + * hairpin queue (logarithm value). + */ +#define MLX5_HP_BUF_SIZE "hp_buf_log_sz" + +/* Device parameter to configure the delay drop when creating Rxqs. */ +#define MLX5_DELAY_DROP "delay_drop" + +/* + * Device parameter to enable Tx scheduling on timestamps + * and specify the packet pacing granularity in nanoseconds. + */ +#define MLX5_TX_PP "tx_pp" + +/* + * Device parameter to specify skew in nanoseconds on Tx datapath, + * it represents the time between SQ start WQE processing and + * appearing actual packet data on the wire. + */ +#define MLX5_TX_SKEW "tx_skew" + +/* Allow L3 VXLAN flow creation. */ +#define MLX5_L3_VXLAN_EN "l3_vxlan_en" + +/* Activate DV E-Switch flow steering. */ +#define MLX5_DV_ESW_EN "dv_esw_en" + +/* Activate DV flow steering. */ +#define MLX5_DV_FLOW_EN "dv_flow_en" + +/* Enable extensive flow metadata support. */ +#define MLX5_DV_XMETA_EN "dv_xmeta_en" + +/* Device parameter to let the user manage the lacp traffic of bonded device */ +#define MLX5_LACP_BY_USER "lacp_by_user" + +/* Activate Netlink support in VF mode. */ +#define MLX5_VF_NL_EN "vf_nl_en" + +/* Flow memory reclaim mode. */ +#define MLX5_RECLAIM_MEM "reclaim_mem_mode" + +/* Decap will be used or not. */ +#define MLX5_DECAP_EN "decap_en" + +/* Device parameter to configure allow or prevent duplicate rules pattern. */ +#define MLX5_ALLOW_DUPLICATE_PATTERN "allow_duplicate_pattern" + /* * Number of modification commands. * The maximal actions amount in FW is some constant, and it is 16 in the @@ -1530,7 +1658,8 @@ void mlx5_age_event_prepare(struct mlx5_dev_ctx_shared *sh); void mlx5_rt_timestamp_config(struct mlx5_dev_ctx_shared *sh, struct mlx5_hca_attr *hca_attr); struct mlx5_dev_ctx_shared * -mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn); +mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, + struct mlx5_kvargs_ctrl *mkvlist); void mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh); int mlx5_dev_ctx_shared_mempool_subscribe(struct rte_eth_dev *dev); void mlx5_free_table_hash_list(struct mlx5_priv *priv); @@ -1540,7 +1669,8 @@ void mlx5_set_metadata_mask(struct rte_eth_dev *dev); int mlx5_port_args_check_handler(const char *key, const char *val, void *opaque); int mlx5_dev_args_check_handler(const char *key, const char *val, void *opaque); -int mlx5_probe_again_args_validate(struct mlx5_common_device *cdev); +int mlx5_probe_again_args_validate(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist); int mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info); int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size); int mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu); @@ -1806,11 +1936,12 @@ struct rte_pci_driver; int mlx5_os_get_dev_attr(struct mlx5_common_device *dev, struct mlx5_dev_attr *dev_attr); int mlx5_os_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, - struct rte_devargs *devargs, + struct mlx5_kvargs_ctrl *mkvlist, struct mlx5_sh_config *config); void mlx5_os_cap_config(struct mlx5_dev_ctx_shared *sh); void mlx5_os_free_shared_dr(struct mlx5_priv *priv); -int mlx5_os_net_probe(struct mlx5_common_device *cdev); +int mlx5_os_net_probe(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist); void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh); void mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh); void mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index 2e24f864d9..e38b2bd340 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -239,13 +239,45 @@ mlx5_os_set_nonblock_channel_fd(int fd) return -ENOTSUP; } +/** + * Report for unsupported devargs. + * + * @param mkvlist + * Pointer to mlx5 kvargs control. + * @param params + * A list of keys to check (table of const char *, the last must be NULL). + */ +static void +mlx5_kvargs_unsupported_report(struct mlx5_kvargs_ctrl *mkvlist, + const char *const params[]) +{ + const struct rte_kvargs_pair *pair; + uint32_t i, j; + + if (!mkvlist) + return; + MLX5_ASSERT(mkvlist && mkvlist->kvlist); + /* Check parameters. */ + for (i = 0; i < mkvlist->kvlist->count; i++) { + pair = &mkvlist->kvlist->pairs[i]; + for (j = 0; params[j] != NULL; ++j) { + if (strcmp(pair->key, params[j]) != 0) + continue; + DRV_LOG(WARNING, "Key %s is not supported on Windows.", + params[j]); + mkvlist->is_used[i] = true; + break; + } + } +} + /** * Parse user port parameters and adjust them according to device capabilities. * * @param priv * Pointer to shared device context. - * @param devargs - * Device arguments structure. + * @param mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * @param config * Pointer to port configuration structure. * @@ -253,10 +285,39 @@ mlx5_os_set_nonblock_channel_fd(int fd) * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_os_port_args_config(struct mlx5_priv *priv, struct rte_devargs *devargs, +mlx5_os_port_args_config(struct mlx5_priv *priv, + struct mlx5_kvargs_ctrl *mkvlist, struct mlx5_port_config *config) { - struct rte_kvargs *kvlist; + const char **params = (const char *[]){ + MLX5_TXQ_INLINE, + MLX5_TXQ_INLINE_MIN, + MLX5_TXQ_INLINE_MAX, + MLX5_TXQ_INLINE_MPW, + MLX5_TXQS_MIN_INLINE, + MLX5_TXQS_MAX_VEC, + MLX5_TXQ_MPW_EN, + MLX5_TXQ_MPW_HDR_DSEG_EN, + MLX5_TXQ_MAX_INLINE_LEN, + MLX5_TX_VEC_EN, + MLX5_RX_VEC_EN, + MLX5_MAX_DUMP_FILES_NUM, + MLX5_HP_BUF_SIZE, + MLX5_DELAY_DROP, + NULL, + }; + const char **unsupported_params = (const char *[]){ + MLX5_RXQ_CQE_COMP_EN, + MLX5_RXQ_PKT_PAD_EN, + MLX5_RX_MPRQ_EN, + MLX5_RX_MPRQ_LOG_STRIDE_NUM, + MLX5_RX_MPRQ_LOG_STRIDE_SIZE, + MLX5_RX_MPRQ_MAX_MEMCPY_LEN, + MLX5_RXQS_MIN_MPRQ, + MLX5_REPRESENTOR, + MLX5_LRO_TIMEOUT_USEC, + NULL, + }; int ret = 0; /* Default configuration. */ @@ -272,19 +333,12 @@ mlx5_os_port_args_config(struct mlx5_priv *priv, struct rte_devargs *devargs, config->log_hp_size = MLX5_ARG_UNSET; config->std_delay_drop = 0; config->hp_delay_drop = 0; - /* Parse device parameters. */ - if (devargs != NULL) { - kvlist = rte_kvargs_parse(devargs->args, NULL); - if (kvlist == NULL) { - DRV_LOG(ERR, - "Failed to parse device arguments."); - rte_errno = EINVAL; - return -rte_errno; - } + if (mkvlist != NULL) { + /* Report unsupported parameters. */ + mlx5_kvargs_unsupported_report(mkvlist, unsupported_params); /* Process parameters. */ - ret = rte_kvargs_process(kvlist, NULL, - mlx5_port_args_check_handler, config); - rte_kvargs_free(kvlist); + ret = mlx5_kvargs_process(mkvlist, params, + mlx5_port_args_check_handler, config); if (ret) { DRV_LOG(ERR, "Failed to process port arguments: %s", strerror(rte_errno)); @@ -334,8 +388,8 @@ mlx5_os_port_args_config(struct mlx5_priv *priv, struct rte_devargs *devargs, * * @param sh * Pointer to shared device context. - * @param devargs - * Device arguments structure. + * @param mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * @param config * Pointer to shared device configuration structure. * @@ -344,30 +398,39 @@ mlx5_os_port_args_config(struct mlx5_priv *priv, struct rte_devargs *devargs, */ int mlx5_os_shared_dev_ctx_args_config(struct mlx5_dev_ctx_shared *sh, - struct rte_devargs *devargs, + struct mlx5_kvargs_ctrl *mkvlist, struct mlx5_sh_config *config) { RTE_SET_USED(sh); - struct rte_kvargs *kvlist; + const char **params = (const char *[]){ + MLX5_L3_VXLAN_EN, + MLX5_LACP_BY_USER, + MLX5_RECLAIM_MEM, + MLX5_DECAP_EN, + NULL, + }; + const char **unsupported_params = (const char *[]){ + MLX5_TX_PP, + MLX5_TX_SKEW, + MLX5_VF_NL_EN, + MLX5_DV_ESW_EN, + MLX5_DV_FLOW_EN, + MLX5_DV_XMETA_EN, + MLX5_ALLOW_DUPLICATE_PATTERN, + NULL, + }; int ret = 0; /* Default configuration. */ memset(config, 0, sizeof(*config)); config->dv_flow_en = 1; config->decap_en = 1; /* TODO: check it with Tal */ - /* Parse device parameters. */ - if (devargs != NULL) { - kvlist = rte_kvargs_parse(devargs->args, NULL); - if (kvlist == NULL) { - DRV_LOG(ERR, - "Failed to parse shared device arguments."); - rte_errno = EINVAL; - return -rte_errno; - } + if (mkvlist != NULL) { + /* Report unsupported parameters. */ + mlx5_kvargs_unsupported_report(mkvlist, unsupported_params); /* Process parameters. */ - ret = rte_kvargs_process(kvlist, NULL, - mlx5_dev_args_check_handler, config); - rte_kvargs_free(kvlist); + ret = mlx5_kvargs_process(mkvlist, params, + mlx5_dev_args_check_handler, config); if (ret) { DRV_LOG(ERR, "Failed to process device arguments: %s", strerror(rte_errno)); @@ -485,6 +548,8 @@ mlx5_os_cap_config(struct mlx5_dev_ctx_shared *sh) * Backing DPDK device. * @param spawn * Verbs device parameters (name, port, switch_info) to spawn. + * @param mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * * @return * A valid Ethernet device object on success, NULL otherwise and rte_errno @@ -494,7 +559,8 @@ mlx5_os_cap_config(struct mlx5_dev_ctx_shared *sh) */ static struct rte_eth_dev * mlx5_dev_spawn(struct rte_device *dpdk_dev, - struct mlx5_dev_spawn_data *spawn) + struct mlx5_dev_spawn_data *spawn, + struct mlx5_kvargs_ctrl *mkvlist) { const struct mlx5_switch_info *switch_info = &spawn->info; struct mlx5_dev_ctx_shared *sh = NULL; @@ -515,7 +581,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, return NULL; } DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name); - sh = mlx5_alloc_shared_dev_ctx(spawn); + sh = mlx5_alloc_shared_dev_ctx(spawn, mkvlist); if (!sh) return NULL; /* Initialize the shutdown event in mlx5_dev_spawn to @@ -579,7 +645,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, own_domain_id = 1; } /* Process parameters and store port configuration on priv structure. */ - err = mlx5_os_port_args_config(priv, dpdk_dev->devargs, &priv->config); + err = mlx5_os_port_args_config(priv, mkvlist, &priv->config); if (err) { err = rte_errno; DRV_LOG(ERR, "Failed to process port configure: %s", @@ -960,14 +1026,17 @@ mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable) * * This function spawns Ethernet devices out of a given device. * - * @param[in] dev + * @param[in] cdev * Pointer to the common device. + * @param[in, out] mkvlist + * Pointer to mlx5 kvargs control, can be NULL if there is no devargs. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ int -mlx5_os_net_probe(struct mlx5_common_device *cdev) +mlx5_os_net_probe(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist) { struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(cdev->dev); struct mlx5_dev_spawn_data spawn = { @@ -995,13 +1064,13 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev) strerror(rte_errno)); return -rte_errno; } - ret = mlx5_probe_again_args_validate(cdev); + ret = mlx5_probe_again_args_validate(cdev, mkvlist); if (ret) { DRV_LOG(ERR, "Probe again parameters are not compatible : %s", strerror(rte_errno)); return -rte_errno; } - spawn.eth_dev = mlx5_dev_spawn(cdev->dev, &spawn); + spawn.eth_dev = mlx5_dev_spawn(cdev->dev, &spawn, mkvlist); if (!spawn.eth_dev) return -rte_errno; restore = spawn.eth_dev->data->dev_flags; diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c index e5a12fb3cc..dc2bd868ea 100644 --- a/drivers/regex/mlx5/mlx5_regex.c +++ b/drivers/regex/mlx5/mlx5_regex.c @@ -67,7 +67,8 @@ mlx5_regex_get_name(char *name, struct rte_device *dev) } static int -mlx5_regex_dev_probe(struct mlx5_common_device *cdev) +mlx5_regex_dev_probe(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist __rte_unused) { struct mlx5_regex_priv *priv = NULL; struct mlx5_hca_attr *attr = &cdev->config.hca_attr; diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index b9e84dd9bf..cb3a1ac340 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -443,8 +443,6 @@ mlx5_vdpa_args_check_handler(const char *key, const char *val, void *opaque) unsigned long tmp; int n_cores = sysconf(_SC_NPROCESSORS_ONLN); - if (strcmp(key, RTE_DEVARGS_KEY_CLASS) == 0) - return 0; errno = 0; tmp = strtoul(val, NULL, 0); if (errno) { @@ -471,28 +469,33 @@ mlx5_vdpa_args_check_handler(const char *key, const char *val, void *opaque) priv->hw_max_latency_us = (uint32_t)tmp; } else if (strcmp(key, "hw_max_pending_comp") == 0) { priv->hw_max_pending_comp = (uint32_t)tmp; - } else { - DRV_LOG(WARNING, "Invalid key %s.", key); } return 0; } static void -mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv) +mlx5_vdpa_config_get(struct mlx5_kvargs_ctrl *mkvlist, + struct mlx5_vdpa_priv *priv) { - struct rte_kvargs *kvlist; + const char **params = (const char *[]){ + "event_core", + "event_mode", + "event_us", + "hw_latency_mode", + "hw_max_latency_us", + "hw_max_pending_comp", + "no_traffic_time", + NULL, + }; priv->event_mode = MLX5_VDPA_EVENT_MODE_FIXED_TIMER; priv->event_us = 0; priv->event_core = -1; priv->no_traffic_max = MLX5_VDPA_DEFAULT_NO_TRAFFIC_MAX; - if (devargs == NULL) - return; - kvlist = rte_kvargs_parse(devargs->args, NULL); - if (kvlist == NULL) + if (mkvlist == NULL) return; - rte_kvargs_process(kvlist, NULL, mlx5_vdpa_args_check_handler, priv); - rte_kvargs_free(kvlist); + mlx5_kvargs_process(mkvlist, params, mlx5_vdpa_args_check_handler, + priv); if (!priv->event_us && priv->event_mode == MLX5_VDPA_EVENT_MODE_DYNAMIC_TIMER) priv->event_us = MLX5_VDPA_DEFAULT_TIMER_STEP_US; @@ -502,7 +505,8 @@ mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv) } static int -mlx5_vdpa_dev_probe(struct mlx5_common_device *cdev) +mlx5_vdpa_dev_probe(struct mlx5_common_device *cdev, + struct mlx5_kvargs_ctrl *mkvlist) { struct mlx5_vdpa_priv *priv = NULL; struct mlx5_hca_attr *attr = &cdev->config.hca_attr; @@ -555,7 +559,7 @@ mlx5_vdpa_dev_probe(struct mlx5_common_device *cdev) rte_errno = rte_errno ? rte_errno : EINVAL; goto error; } - mlx5_vdpa_config_get(cdev->dev->devargs, priv); + mlx5_vdpa_config_get(mkvlist, priv); SLIST_INIT(&priv->mr_list); pthread_mutex_init(&priv->vq_config_lock, NULL); pthread_mutex_lock(&priv_list_lock); -- 2.25.1