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 C7FEAA04A6; Thu, 27 Jan 2022 16:40:52 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0A0844286D; Thu, 27 Jan 2022 16:40:12 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2044.outbound.protection.outlook.com [40.107.93.44]) by mails.dpdk.org (Postfix) with ESMTP id 4509742811 for ; Thu, 27 Jan 2022 16:40:11 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EVf+r2SY+QEHBX3lt5FskGozsWzKZ7AMXcBLfLfZ71vYHPWwpkVluQdspc7WrYId5+snA/6FY+MZxNm7hRnKgI9whnJ7LgNfRUpAMuXRkEfXDDU5po+fe3SDAXBqM6z6xgNZUBAhnDahcYRC5bTIlNIiaOdWrEs9jREAxtDLpZ49/oR7bEu8ncEb8ifdzvh9Yx2DyvJ/qo0nd4ajXluVUJuD6AVRsM2JTqKHSvhM/JQDgIa/ELtcibOViU0rqSDDC3Qd2nUa2ACqkvvgnoWXLWCSRm8NW/jdWvOY7O9Rgjbwq+WMCVRFOND7onTmFXEHF6wuoKuLQWkH1gMY2RzuzQ== 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=X7w5IpYm/Oi/n4sF9wlk5qWsJ9u1IGxsYsSFvY2Fy8I=; b=nzN+iaPRmbkqvuVarXyd6d6A1mB6HUurpG/BrwWm4c0YyBa9dQghXkbwoH3AV/xyfSHLhqrkSn32rP6NVGROj7uWXpCc70is8j/bb6t4lQz+ruC895k5woVhP98KL5JQ5piLUrVfwdnudmO5+M0lTXXDLw0wyZVFnNYhGXuqEjAn3v0lMLtMj0c/wwXrJ6cWmsNgwtY5mckxTigABUDVzRt6ZRpWhy2QphX+jR6CjEsFvoUU4mo97o5I5daQohXFpU3sO85bC/1vL9LeO/r+uP6QHVa4surqN58GNMrtgKY3IajoW5MjVK0AQw1qcL9OdjHG8QQaz0ibFOqHjdyrdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=dpdk.org 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=X7w5IpYm/Oi/n4sF9wlk5qWsJ9u1IGxsYsSFvY2Fy8I=; b=qLPzHXnulwlJy9k3FX2rpDeN3W+tBvOk1xMNAz6fJcFK5tDd1/N8yxHSiGQLiboefPhAshQuZnr7drIVzXMBtiuOlT/EF/UiMRD+ebANheHqSFuXD2ipqy45jcsdnR8ExYGRSOeea56rLhdBzR1XsRgjkTfhwLpGQ6L/nstwF5EXdN1K6n9L3xwgxl9XwFRRdd2T7kuJm3Y3A95/20gTWKugywb7X0uU/UuICT3mnLLJAx8otoej8uTE0w+BZDiGQOQtRFMLKUxYKNZXIO+cL9EoXO+BlXXdJyF72i1khRFy7oykqEE72vUt5VKU1bBP78LqUwun704ZoayrY2GoEA== Received: from BN8PR04CA0017.namprd04.prod.outlook.com (2603:10b6:408:70::30) by BN9PR12MB5276.namprd12.prod.outlook.com (2603:10b6:408:101::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 15:40:09 +0000 Received: from BN8NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::69) by BN8PR04CA0017.outlook.office365.com (2603:10b6:408:70::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 15:40:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT049.mail.protection.outlook.com (10.13.177.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 15:40:08 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 27 Jan 2022 15:40:07 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 27 Jan 2022 07:40:07 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9 via Frontend Transport; Thu, 27 Jan 2022 07:40:06 -0800 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Subject: [PATCH 06/20] net/mlx5: remove checking devargs duplication Date: Thu, 27 Jan 2022 17:39:36 +0200 Message-ID: <20220127153950.812953-7-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127153950.812953-1-michaelba@nvidia.com> References: <20220127153950.812953-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ffb30b5a-a97a-459a-b47b-08d9e1ab4caf X-MS-TrafficTypeDiagnostic: BN9PR12MB5276:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:669; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rFXNvhGTvNJr2zKzIRiTwalA/wfvJxq9C/WfubF1CaYrXUPLdBGiPrbq6uU5ISQz5W8AwQDLR9IWmrxfSlIF+Tm1VzQfre1ZNUOmivjvPJUEdG8+5cGppcXJvNixWRI+q7q3NpiRIPr8xSyLP2vFFsK5KuPQY11aapCJYZJ83ivPeHBuObsEudCllL/jv54937I8LG7ZZ3xyWK2EZ7eh8IVmf3nznmfXqsIaQkCZ7mbJAGfhOjduMpfFjlhJtP74icJOw/9KcHMbxFbmQUKPxYz4OazjS+L/tEF2syc6B0y7I8DjMTJX6MojUkvededjUgcLXqWFFMH2PRg5DmgvSFiFoPntpn5DlJ/o9+wktJwH7aI4DxHrMHxzeWXmA3dbBFtLBTDDzdb+UDL6CZGJxHbo9Fl4gYh79NtO+2Oz6OZLqJNNeZFfCTKZXsRju6UwCefojcRsuvBaLchtXP60ZWyrE2T13zSQJ2uehoLeoDx2g4JUjRDIEc2wfh4iwsnWICO4OgMKH9Vf8LhZ8OXLOTvtXcccU3V2MhaKCKdj5a8xi+wg+I5xW/QR76gDgLhgkc7DjV/5UuZWQFIfmj45uD0CqpP/b4AQS7NOYuQqLvJWShMG7Akl+PiF+GeMaAhmUc9sD689caL3nPE7D2PGjo2d46ZwQ1/eU75CRkaOyJs3c485muFGv3Y2FT+wgBIJMWCK8VMQnvolJuHc7t5p+A== X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(316002)(40460700003)(336012)(54906003)(6916009)(26005)(6286002)(107886003)(82310400004)(426003)(86362001)(8936002)(83380400001)(8676002)(4326008)(186003)(47076005)(1076003)(36860700001)(70206006)(2906002)(5660300002)(2616005)(70586007)(36756003)(81166007)(356005)(55016003)(7696005)(508600001)(6666004)(36900700001)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 15:40:08.9376 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ffb30b5a-a97a-459a-b47b-08d9e1ab4caf 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.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5276 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 The device arguments are parsed and updated twice during spawning. First time before creating the share device context, and again later after updating a default value to one of the arguments. This patch consolidates them into one parsing and updates the default values before it. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 73 +++++++++++++----------------- drivers/net/mlx5/mlx5.c | 23 +++++----- drivers/net/mlx5/mlx5.h | 2 +- drivers/net/mlx5/windows/mlx5_os.c | 49 ++++++++------------ 4 files changed, 65 insertions(+), 82 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index f587a47f6e..11d15d0aef 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -968,22 +968,45 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, mlx5_dev_close(eth_dev); return NULL; } - /* - * Some parameters ("tx_db_nc" in particularly) are needed in - * advance to create dv/verbs device context. We proceed the - * devargs here to get ones, and later proceed devargs again - * to override some hardware settings. - */ + /* Process parameters. */ err = mlx5_args(config, dpdk_dev->devargs); if (err) { - err = rte_errno; DRV_LOG(ERR, "failed to process device arguments: %s", strerror(rte_errno)); - goto error; + return NULL; } sh = mlx5_alloc_shared_dev_ctx(spawn, config); if (!sh) return NULL; + /* Update final values for devargs before check sibling config. */ + if (config->dv_miss_info) { + if (switch_info->master || switch_info->representor) + config->dv_xmeta_en = MLX5_XMETA_MODE_META16; + } +#if !defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_MLX5DV_DR) + if (config->dv_flow_en) { + DRV_LOG(WARNING, "DV flow is not supported."); + config->dv_flow_en = 0; + } +#endif +#ifdef HAVE_MLX5DV_DR_ESWITCH + if (!(sh->cdev->config.hca_attr.eswitch_manager && config->dv_flow_en && + (switch_info->representor || switch_info->master))) + config->dv_esw_en = 0; +#else + config->dv_esw_en = 0; +#endif + if (!config->dv_esw_en && + config->dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) { + DRV_LOG(WARNING, + "Metadata mode %u is not supported (no E-Switch).", + config->dv_xmeta_en); + config->dv_xmeta_en = MLX5_XMETA_MODE_LEGACY; + } + /* Check sibling device configurations. */ + err = mlx5_dev_check_sibling_config(sh, config, dpdk_dev); + if (err) + goto error; #ifdef HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR config->dest_tir = 1; #endif @@ -1049,8 +1072,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, mprq_caps.max_single_wqe_log_num_of_strides; } #endif - /* Rx CQE compression is enabled by default. */ - config->cqe_comp = 1; #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) { config->tunnel_en = dv_attr.tunnel_offloads_caps & @@ -1239,37 +1260,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, DRV_LOG(DEBUG, "dev_port-%u new domain_id=%u\n", priv->dev_port, priv->domain_id); } - /* Override some values set by hardware configuration. */ - mlx5_args(config, dpdk_dev->devargs); - /* Update final values for devargs before check sibling config. */ - if (config->dv_miss_info) { - if (switch_info->master || switch_info->representor) - config->dv_xmeta_en = MLX5_XMETA_MODE_META16; - } -#if !defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_MLX5DV_DR) - if (config->dv_flow_en) { - DRV_LOG(WARNING, "DV flow is not supported."); - config->dv_flow_en = 0; - } -#endif -#ifdef HAVE_MLX5DV_DR_ESWITCH - if (!(sh->cdev->config.hca_attr.eswitch_manager && config->dv_flow_en && - (switch_info->representor || switch_info->master))) - config->dv_esw_en = 0; -#else - config->dv_esw_en = 0; -#endif - if (!priv->config.dv_esw_en && - priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) { - DRV_LOG(WARNING, - "Metadata mode %u is not supported (no E-Switch).", - priv->config.dv_xmeta_en); - priv->config.dv_xmeta_en = MLX5_XMETA_MODE_LEGACY; - } - /* Check sibling device configurations. */ - err = mlx5_dev_check_sibling_config(priv, config, dpdk_dev); - if (err) - goto error; config->hw_csum = !!(sh->device_attr.device_cap_flags_ex & IBV_DEVICE_RAW_IP_CSUM); DRV_LOG(DEBUG, "checksum offloading is %ssupported", @@ -2049,6 +2039,7 @@ mlx5_os_config_default(struct mlx5_dev_config *config, { memset(config, 0, sizeof(*config)); config->mps = MLX5_ARG_UNSET; + config->cqe_comp = 1; config->rx_vec_en = 1; config->txq_inline_max = MLX5_ARG_UNSET; config->txq_inline_min = MLX5_ARG_UNSET; diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 25d4d2082b..60167450e4 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2216,25 +2216,26 @@ rte_pmd_mlx5_get_dyn_flag_names(char *names[], unsigned int n) } /** - * Comparison callback to sort device data. + * Check sibling device configurations. * - * This is meant to be used with qsort(). + * Sibling devices sharing the Infiniband device context should have compatible + * configurations. This regards representors and bonding device. * - * @param a[in] - * Pointer to pointer to first data object. - * @param b[in] - * Pointer to pointer to second data object. + * @param sh + * Shared device context. + * @param config + * Configuration of the device is going to be created. + * @param dpdk_dev + * Backing DPDK device. * * @return - * 0 if both objects are equal, less than 0 if the first argument is less - * than the second, greater than 0 otherwise. + * 0 on success, EINVAL otherwise */ int -mlx5_dev_check_sibling_config(struct mlx5_priv *priv, +mlx5_dev_check_sibling_config(struct mlx5_dev_ctx_shared *sh, struct mlx5_dev_config *config, struct rte_device *dpdk_dev) { - struct mlx5_dev_ctx_shared *sh = priv->sh; struct mlx5_dev_config *sh_conf = NULL; uint16_t port_id; @@ -2247,7 +2248,7 @@ mlx5_dev_check_sibling_config(struct mlx5_priv *priv, struct mlx5_priv *opriv = rte_eth_devices[port_id].data->dev_private; - if (opriv && opriv != priv && opriv->sh == sh) { + if (opriv && opriv->sh == sh) { sh_conf = &opriv->config; break; } diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 823a943978..e4b2523eb0 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1529,7 +1529,7 @@ int mlx5_alloc_table_hash_list(struct mlx5_priv *priv); void mlx5_set_min_inline(struct mlx5_dev_spawn_data *spawn, struct mlx5_dev_config *config); void mlx5_set_metadata_mask(struct rte_eth_dev *dev); -int mlx5_dev_check_sibling_config(struct mlx5_priv *priv, +int mlx5_dev_check_sibling_config(struct mlx5_dev_ctx_shared *sh, struct mlx5_dev_config *config, struct rte_device *dpdk_dev); bool mlx5_flex_parser_ecpri_exist(struct rte_eth_dev *dev); diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index d31de6a5e8..c1f8bc9ee3 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -321,7 +321,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, struct rte_eth_dev *eth_dev = NULL; struct mlx5_priv *priv = NULL; int err = 0; - unsigned int cqe_comp; struct rte_ether_addr mac; char name[RTE_ETH_NAME_MAX_LEN]; int own_domain_id = 0; @@ -336,11 +335,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, return NULL; } DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name); - /* - * Some parameters are needed in advance to create device context. We - * process the devargs here to get ones, and later process devargs - * again to override some hardware settings. - */ + /* Process parameters. */ err = mlx5_args(config, dpdk_dev->devargs); if (err) { err = rte_errno; @@ -351,6 +346,24 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, sh = mlx5_alloc_shared_dev_ctx(spawn, config); if (!sh) return NULL; + /* Update final values for devargs before check sibling config. */ + config->dv_esw_en = 0; + if (!config->dv_flow_en) { + DRV_LOG(ERR, "Windows flow mode must be DV flow enable."); + err = ENOTSUP; + goto error; + } + if (!config->dv_esw_en && + config->dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) { + DRV_LOG(WARNING, + "Metadata mode %u is not supported (no E-Switch).", + config->dv_xmeta_en); + config->dv_xmeta_en = MLX5_XMETA_MODE_LEGACY; + } + /* Check sibling device configurations. */ + err = mlx5_dev_check_sibling_config(sh, config, dpdk_dev); + if (err) + goto error; /* Initialize the shutdown event in mlx5_dev_spawn to * support mlx5_is_removed for Windows. */ @@ -367,8 +380,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, MLX5_SW_PARSING_TSO_CAP); config->ind_table_max_size = sh->device_attr.max_rwq_indirection_table_size; - cqe_comp = 0; - config->cqe_comp = cqe_comp; config->tunnel_en = device_attr.tunnel_offloads_caps & (MLX5_TUNNELED_OFFLOADS_VXLAN_CAP | MLX5_TUNNELED_OFFLOADS_GRE_CAP | @@ -437,26 +448,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, } own_domain_id = 1; } - /* Override some values set by hardware configuration. */ - mlx5_args(config, dpdk_dev->devargs); - /* Update final values for devargs before check sibling config. */ - config->dv_esw_en = 0; - if (!config->dv_flow_en) { - DRV_LOG(ERR, "Windows flow mode must be DV flow enable."); - err = ENOTSUP; - goto error; - } - if (!priv->config.dv_esw_en && - priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) { - DRV_LOG(WARNING, - "Metadata mode %u is not supported (no E-Switch).", - priv->config.dv_xmeta_en); - priv->config.dv_xmeta_en = MLX5_XMETA_MODE_LEGACY; - } - /* Check sibling device configurations. */ - err = mlx5_dev_check_sibling_config(priv, config, dpdk_dev); - if (err) - goto error; DRV_LOG(DEBUG, "counters are not supported"); config->ind_table_max_size = sh->device_attr.max_rwq_indirection_table_size; @@ -479,7 +470,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, config->mps == MLX5_MPW_ENHANCED ? "enhanced " : config->mps == MLX5_MPW ? "legacy " : "", config->mps != MLX5_MPW_DISABLED ? "enabled" : "disabled"); - if (config->cqe_comp && !cqe_comp) { + if (config->cqe_comp) { DRV_LOG(WARNING, "Rx CQE compression isn't supported."); config->cqe_comp = 0; } -- 2.25.1