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 DDF1EA0C43; Thu, 30 Sep 2021 19:40:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0BC194111F; Thu, 30 Sep 2021 19:39:50 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.74]) by mails.dpdk.org (Postfix) with ESMTP id F370C4067E for ; Thu, 30 Sep 2021 19:28:53 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Aomvji6j62OA80UmxuVxhyISngRMH3qmfPCLLvROOdWjbYu6ruqv+C+2qJcTZngdYceGGFgdGYc2K5Ba82PGy4lAuSLF/IxgEnJFPjhKLcALIKIRFTcOSHbvboJKPB4v2xDKOuxwwdRBjJe+OFuEJ0n+DDI5EdFUwcGYq8ck1E3H3nO4Ay34I03ULPGp5qr2moERFWfJAqcBaxvI3dArrW2/RDLHvn1QOqdxO7dyiCwr9kqUwHyEpa98SRfimgyvzFYajr1CNFOphahcIyGHvsjK7Wbjk81vgqZGTKPCCaZCIMN3nL4/F1CgWqgTQtOAkyZrwEnasNShi+mQsQRKUA== 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; bh=ACJLbjfkUCCawFpofiPkYhu5hkDGc9xHKWFzRsHNGk8=; b=R5pxe/PUKpf6ZMoDJa54U1b9VnhHxs1lWI7OxjwfMM6iQtIsf786zCKLyR4A3OoRTV1AImAjhFuGQ0/LynJsK/wqZoPGgs6EZF4/lk3f8obPl6FhZ3TfUSlZDODxpv9kwdL5LvknWiTI80voplM0CUhdWV3hmOQlwIbXuWpwWbpwspOvioTtHhD0tiVxTm4ztzGTQjr/xvYYGFJAw/jNQhD+b2OfdHsIn4JUifBVPa3tSd5mIGjtLIHIWoGgly/M9k4Zf4JQxfydP7P7TYF283EpyLVv1O3ZJ7515VErHi59rc+AFMlKquEeeD8XK91LDNI1/WrCyGLpdDPZXslogA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=ACJLbjfkUCCawFpofiPkYhu5hkDGc9xHKWFzRsHNGk8=; b=AXj5A7VrA8dDcPbM9wJz/qWMYQzu5GdVQa9RTEHVS6mt7pXs/fo3j186KA1upVLiXbWZ/sl3t2Ex89/H/ojXdjvCt619w1oG3aovC2q4AjM/HZgaZnv+l2aFtwL3UIysPCnP0YvkI9wBO4MXVHyDz4yh24r+RwzeF25ZyyH6OSh1VZ34akV6tbl1cWZ1a+1AckV7F4ceaykH9o5/IrOjMLzjvTs7Dgo0JZv5sUlF1UpB8qUAfEdi4AsUlcxFZ9aBKEuh/nWX3mGcXtjzbwUhsmwLjKdsPmW2D1vamdQBzXKJKCs+4Rx+9qly7ezGBm8aD0lKjchyTQbe/EFuXMZHVg== Received: from BN9PR03CA0886.namprd03.prod.outlook.com (2603:10b6:408:13c::21) by BN6PR1201MB0193.namprd12.prod.outlook.com (2603:10b6:405:56::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 17:28:52 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13c:cafe::2c) by BN9PR03CA0886.outlook.office365.com (2603:10b6:408:13c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 17:28:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 17:28:51 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 30 Sep 2021 17:28:49 +0000 From: To: CC: Matan Azrad , Thomas Monjalon , Michael Baum Date: Thu, 30 Sep 2021 20:28:08 +0300 Message-ID: <20210930172822.1949969-5-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930172822.1949969-1-michaelba@nvidia.com> References: <20210930172822.1949969-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: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0170728c-25e5-4e07-c7ea-08d98437c57b X-MS-TrafficTypeDiagnostic: BN6PR1201MB0193: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:178; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZHBrBmDPBNuefm6FyuFfAjAR2AINAOybYI3t01oOcnZHqfJ3fnAAeZYANrZGf6KvizVZqq+Ck/KT2UWmZ7H8w0MObucrVkTGYIXCFc9LlSeDLNHMyH0JkPQJzsmsYK6lK3Ik9dSWhS4d3xfQDRyDvT1XGtg3KEt61N5tcqv0c26pgY89E9VvFRN9Cm2iXQ+uN3utfRGxtC/HrHfQ1qhz3oWWFHtGEg98Nlt1G/wcuUxYc9P1nVpDxiX23wrHPu99D7jUwo7QQvAQPABTOiuVgEcOl1MQYBaVZinnJSO8FEYFb9qOQTa/+0A7mvxl5a/7bWMEJUBUAemivgfgsjNide3cniIhWTVH4TD814PQIDBS+MXLPTm+DLBTNvUffsro/y5FZmT3/BGD/Wr133RbVrby7fmcP+2kS/X/Sa5M3w99nKl/yJrSNTgiWQz5PYcZBW9prcmRzS6OtiO+7acyunMUdvFJd8uyAr5+WG9m6TOB3XNZChDB4bl1RhA10H3FvkVYZRCyLEBDfnl998liZ92+ZKp78U5tdM2FScSJWT1hobybGeVm7FElRLkQGr0401u4c7WCACHUwY0HEwROh6YA4QcN0xA+aF4Cud8zZ5zblYLX1nsU+8z0/4ejKIXzroJakUmCZi/KTjVKkSEkGiYN1Ypda3W8KVfyC2sdBKHyva3b9X+BujFi2SLdNCvYuLkadmHKV+Fi6Aub4vaZ7Wl0/qY2xr2926GQ6BpEEu4= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(6286002)(2616005)(1076003)(508600001)(7696005)(36756003)(426003)(356005)(86362001)(6916009)(186003)(107886003)(336012)(30864003)(26005)(55016002)(5660300002)(16526019)(54906003)(7636003)(2876002)(316002)(36906005)(82310400003)(8676002)(47076005)(8936002)(83380400001)(2906002)(70586007)(70206006)(6666004)(4326008)(36860700001)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 17:28:51.9288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0170728c-25e5-4e07-c7ea-08d98437c57b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB0193 X-Mailman-Approved-At: Thu, 30 Sep 2021 19:39:43 +0200 Subject: [dpdk-dev] [PATCH 04/18] common/mlx5: share memory related devargs 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 Sender: "dev" From: Michael Baum Add device configure structure and function to parse user device arguments into it. Move parsing and management of relevant device arguments to common. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_common.c | 184 ++++++++++++++++++++++------ drivers/common/mlx5/mlx5_common.h | 18 +++ drivers/common/mlx5/mlx5_malloc.h | 1 - drivers/common/mlx5/version.map | 1 - drivers/net/mlx5/linux/mlx5_mp_os.c | 4 +- drivers/net/mlx5/linux/mlx5_os.c | 11 +- drivers/net/mlx5/mlx5.c | 29 ++--- drivers/net/mlx5/mlx5.h | 7 -- drivers/net/mlx5/mlx5_mr.c | 8 +- drivers/net/mlx5/mlx5_txq.c | 4 +- drivers/net/mlx5/windows/mlx5_os.c | 8 -- 11 files changed, 186 insertions(+), 89 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 8e3ea073e3..0ad9e09972 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -90,6 +90,93 @@ driver_get(uint32_t class) return NULL; } +/** + * Verify and store value for devargs. + * + * @param[in] key + * Key argument to verify. + * @param[in] val + * Value associated with key. + * @param opaque + * User data. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_common_args_check_handler(const char *key, const char *val, void *opaque) +{ + struct mlx5_common_dev_config *config = opaque; + signed long tmp; + + errno = 0; + tmp = strtol(val, NULL, 0); + if (errno) { + rte_errno = errno; + DRV_LOG(WARNING, "%s: \"%s\" is an invalid integer.", key, val); + return -rte_errno; + } + if (strcmp(key, "tx_db_nc") == 0) { + if (tmp != MLX5_TXDB_CACHED && + tmp != MLX5_TXDB_NCACHED && + tmp != MLX5_TXDB_HEURISTIC) { + DRV_LOG(ERR, "Invalid Tx doorbell mapping parameter."); + rte_errno = EINVAL; + return -rte_errno; + } + config->dbnc = tmp; + } else if (strcmp(key, "mr_ext_memseg_en") == 0) { + config->mr_ext_memseg_en = !!tmp; + } else if (strcmp(key, "mr_mempool_reg_en") == 0) { + config->mr_mempool_reg_en = !!tmp; + } else if (strcmp(key, "sys_mem_en") == 0) { + config->sys_mem_en = !!tmp; + } + return 0; +} + +/** + * Parse common device parameters. + * + * @param devargs + * Device arguments structure. + * @param config + * Pointer to device configuration structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_common_config_get(struct rte_devargs *devargs, + struct mlx5_common_dev_config *config) +{ + struct rte_kvargs *kvlist; + int ret = 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) { + 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); + DRV_LOG(DEBUG, "Tx doorbell mapping parameter is %d.", config->dbnc); + return ret; +} + static int devargs_class_handler(__rte_unused const char *key, const char *class_names, void *opaque) @@ -189,11 +276,11 @@ mlx5_bus_match(const struct mlx5_class_driver *drv, static struct mlx5_common_device * to_mlx5_device(const struct rte_device *rte_dev) { - struct mlx5_common_device *dev; + struct mlx5_common_device *cdev; - TAILQ_FOREACH(dev, &devices_list, next) { - if (rte_dev == dev->dev) - return dev; + TAILQ_FOREACH(cdev, &devices_list, next) { + if (rte_dev == cdev->dev) + return cdev; } return NULL; } @@ -222,29 +309,60 @@ mlx5_dev_to_pci_str(const struct rte_device *dev, char *addr, size_t size) } static void -dev_release(struct mlx5_common_device *dev) +mlx5_common_dev_release(struct mlx5_common_device *cdev) +{ + pthread_mutex_lock(&devices_list_lock); + TAILQ_REMOVE(&devices_list, cdev, next); + pthread_mutex_unlock(&devices_list_lock); + rte_free(cdev); +} + +static struct mlx5_common_device * +mlx5_common_dev_create(struct rte_device *eal_dev) { + struct mlx5_common_device *cdev; + int ret; + + cdev = rte_zmalloc("mlx5_common_device", sizeof(*cdev), 0); + if (!cdev) { + DRV_LOG(ERR, "Device allocation failure."); + rte_errno = ENOMEM; + return NULL; + } + cdev->dev = eal_dev; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + goto exit; + /* Parse device parameters. */ + ret = mlx5_common_config_get(eal_dev->devargs, &cdev->config); + if (ret < 0) { + DRV_LOG(ERR, "Failed to process device arguments: %s", + strerror(rte_errno)); + rte_free(cdev); + return NULL; + } + mlx5_malloc_mem_select(cdev->config.sys_mem_en); +exit: pthread_mutex_lock(&devices_list_lock); - TAILQ_REMOVE(&devices_list, dev, next); + TAILQ_INSERT_HEAD(&devices_list, cdev, next); pthread_mutex_unlock(&devices_list_lock); - rte_free(dev); + return cdev; } static int -drivers_remove(struct mlx5_common_device *dev, uint32_t enabled_classes) +drivers_remove(struct mlx5_common_device *cdev, uint32_t enabled_classes) { struct mlx5_class_driver *driver; int local_ret = -ENODEV; unsigned int i = 0; int ret = 0; - enabled_classes &= dev->classes_loaded; + enabled_classes &= cdev->classes_loaded; while (enabled_classes) { driver = driver_get(RTE_BIT64(i)); if (driver != NULL) { - local_ret = driver->remove(dev); + local_ret = driver->remove(cdev); if (local_ret == 0) - dev->classes_loaded &= ~RTE_BIT64(i); + cdev->classes_loaded &= ~RTE_BIT64(i); else if (ret == 0) ret = local_ret; } @@ -257,7 +375,7 @@ drivers_remove(struct mlx5_common_device *dev, uint32_t enabled_classes) } static int -drivers_probe(struct mlx5_common_device *dev, uint32_t user_classes) +drivers_probe(struct mlx5_common_device *cdev, uint32_t user_classes) { struct mlx5_class_driver *driver; uint32_t enabled_classes = 0; @@ -267,16 +385,16 @@ drivers_probe(struct mlx5_common_device *dev, uint32_t user_classes) TAILQ_FOREACH(driver, &drivers_list, next) { if ((driver->drv_class & user_classes) == 0) continue; - if (!mlx5_bus_match(driver, dev->dev)) + if (!mlx5_bus_match(driver, cdev->dev)) continue; - already_loaded = dev->classes_loaded & driver->drv_class; + already_loaded = cdev->classes_loaded & driver->drv_class; if (already_loaded && driver->probe_again == 0) { DRV_LOG(ERR, "Device %s is already probed", - dev->dev->name); + cdev->dev->name); ret = -EEXIST; goto probe_err; } - ret = driver->probe(dev); + ret = driver->probe(cdev); if (ret < 0) { DRV_LOG(ERR, "Failed to load driver %s", driver->name); @@ -284,20 +402,20 @@ drivers_probe(struct mlx5_common_device *dev, uint32_t user_classes) } enabled_classes |= driver->drv_class; } - dev->classes_loaded |= enabled_classes; + cdev->classes_loaded |= enabled_classes; return 0; probe_err: /* Only unload drivers which are enabled which were enabled * in this probe instance. */ - drivers_remove(dev, enabled_classes); + drivers_remove(cdev, enabled_classes); return ret; } int mlx5_common_dev_probe(struct rte_device *eal_dev) { - struct mlx5_common_device *dev; + struct mlx5_common_device *cdev; uint32_t classes = 0; bool new_device = false; int ret; @@ -313,15 +431,11 @@ mlx5_common_dev_probe(struct rte_device *eal_dev) if (classes == 0) /* Default to net class. */ classes = MLX5_CLASS_ETH; - dev = to_mlx5_device(eal_dev); - if (!dev) { - dev = rte_zmalloc("mlx5_common_device", sizeof(*dev), 0); - if (!dev) + cdev = to_mlx5_device(eal_dev); + if (!cdev) { + cdev = mlx5_common_dev_create(eal_dev); + if (!cdev) return -ENOMEM; - dev->dev = eal_dev; - pthread_mutex_lock(&devices_list_lock); - TAILQ_INSERT_HEAD(&devices_list, dev, next); - pthread_mutex_unlock(&devices_list_lock); new_device = true; } /* @@ -329,34 +443,34 @@ mlx5_common_dev_probe(struct rte_device *eal_dev) * For new device, the classes_loaded field is 0 and it check only * the classes given as user device arguments. */ - ret = is_valid_class_combination(classes | dev->classes_loaded); + ret = is_valid_class_combination(classes | cdev->classes_loaded); if (ret != 0) { DRV_LOG(ERR, "Unsupported mlx5 classes combination."); goto class_err; } - ret = drivers_probe(dev, classes); + ret = drivers_probe(cdev, classes); if (ret) goto class_err; return 0; class_err: if (new_device) - dev_release(dev); + mlx5_common_dev_release(cdev); return ret; } int mlx5_common_dev_remove(struct rte_device *eal_dev) { - struct mlx5_common_device *dev; + struct mlx5_common_device *cdev; int ret; - dev = to_mlx5_device(eal_dev); - if (!dev) + cdev = to_mlx5_device(eal_dev); + if (!cdev) return -ENODEV; /* Matching device found, cleanup and unload drivers. */ - ret = drivers_remove(dev, dev->classes_loaded); + ret = drivers_remove(cdev, cdev->classes_loaded); if (ret == 0) - dev_release(dev); + mlx5_common_dev_release(cdev); return ret; } diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index b7e2ad1a82..f922757da1 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -324,10 +324,28 @@ void mlx5_common_init(void); * from devargs, locating target RDMA device and probing with it. */ +/* + * Device configuration structure. + * + * Merged configuration from: + * + * - Device capabilities, + * - User device parameters disabled features. + */ +struct mlx5_common_dev_config { + int dbnc; /* Skip doorbell register write barrier. */ + unsigned int sys_mem_en:1; /* The default memory allocator. */ + unsigned int mr_mempool_reg_en:1; + /* Allow/prevent implicit mempool memory registration. */ + unsigned int mr_ext_memseg_en:1; + /* Whether memseg should be extended for MR creation. */ +}; + struct mlx5_common_device { struct rte_device *dev; TAILQ_ENTRY(mlx5_common_device) next; uint32_t classes_loaded; + struct mlx5_common_dev_config config; /* Device configuration. */ }; /** diff --git a/drivers/common/mlx5/mlx5_malloc.h b/drivers/common/mlx5/mlx5_malloc.h index 8aea414635..74b7eeb26e 100644 --- a/drivers/common/mlx5/mlx5_malloc.h +++ b/drivers/common/mlx5/mlx5_malloc.h @@ -38,7 +38,6 @@ enum mlx5_mem_flags { * @param sys_mem_en * Use system memory or not. */ -__rte_internal void mlx5_malloc_mem_select(uint32_t sys_mem_en); /** diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index d5e9635a14..37a0ffef4b 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -93,7 +93,6 @@ INTERNAL { mlx5_hlist_destroy; mlx5_malloc; - mlx5_malloc_mem_select; mlx5_memory_stat_dump; # WINDOWS_NO_EXPORT diff --git a/drivers/net/mlx5/linux/mlx5_mp_os.c b/drivers/net/mlx5/linux/mlx5_mp_os.c index d2ac375a47..b0996813dc 100644 --- a/drivers/net/mlx5/linux/mlx5_mp_os.c +++ b/drivers/net/mlx5/linux/mlx5_mp_os.c @@ -68,6 +68,7 @@ mlx5_mp_os_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer) (const struct mlx5_mp_param *)mp_msg->param; struct rte_eth_dev *dev; struct mlx5_priv *priv; + struct mlx5_common_device *cdev; struct mr_cache_entry entry; uint32_t lkey; int ret; @@ -85,13 +86,14 @@ mlx5_mp_os_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer) } dev = &rte_eth_devices[param->port_id]; priv = dev->data->dev_private; + cdev = priv->sh->cdev; switch (param->type) { case MLX5_MP_REQ_CREATE_MR: mp_init_msg(&priv->mp_id, &mp_res, param->type); lkey = mlx5_mr_create_primary(priv->sh->pd, &priv->sh->share_cache, &entry, param->args.addr, - priv->config.mr_ext_memseg_en); + cdev->config.mr_ext_memseg_en); if (lkey == UINT32_MAX) res->result = -rte_errno; ret = rte_mp_reply(&mp_res, peer); diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 0aad08aba4..a808325412 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1072,7 +1072,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, if (switch_info->master || switch_info->representor) config->dv_xmeta_en = MLX5_XMETA_MODE_META16; } - mlx5_malloc_mem_select(config->sys_mem_en); sh = mlx5_alloc_shared_dev_ctx(spawn, config); if (!sh) return NULL; @@ -2124,15 +2123,12 @@ mlx5_os_config_default(struct mlx5_dev_config *config) { memset(config, 0, sizeof(*config)); config->mps = MLX5_ARG_UNSET; - config->dbnc = MLX5_ARG_UNSET; config->rx_vec_en = 1; config->txq_inline_max = MLX5_ARG_UNSET; config->txq_inline_min = MLX5_ARG_UNSET; config->txq_inline_mpw = MLX5_ARG_UNSET; config->txqs_inline = MLX5_ARG_UNSET; config->vf_nl_en = 1; - config->mr_ext_memseg_en = 1; - config->mr_mempool_reg_en = 1; config->mprq.max_memcpy_len = MLX5_MPRQ_MEMCPY_DEFAULT_LEN; config->mprq.min_rxqs_num = MLX5_MPRQ_MIN_RXQS; config->dv_esw_en = 1; @@ -2796,7 +2792,7 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev) } static int -mlx5_config_doorbell_mapping_env(const struct mlx5_dev_config *config) +mlx5_config_doorbell_mapping_env(const struct mlx5_common_dev_config *config) { char *env; int value; @@ -2866,8 +2862,6 @@ mlx5_os_get_pdn(void *pd, uint32_t *pdn) * * @param[in] spawn * Pointer to the IB device attributes (name, port, etc). - * @param[out] config - * Pointer to device configuration structure. * @param[out] sh * Pointer to shared context structure. * @@ -2876,7 +2870,6 @@ mlx5_os_get_pdn(void *pd, uint32_t *pdn) */ int mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn, - const struct mlx5_dev_config *config, struct mlx5_dev_ctx_shared *sh) { int dbmap_env; @@ -2889,7 +2882,7 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn, * checks the variable at device creation and * stores the result internally. */ - dbmap_env = mlx5_config_doorbell_mapping_env(config); + dbmap_env = mlx5_config_doorbell_mapping_env(&spawn->mlx5_dev->config); /* Try to open IB device with DV first, then usual Verbs. */ errno = 0; sh->ctx = mlx5_glue->dv_open_device(spawn->phys_dev); diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index e39e77aa9d..b5af21b0f6 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -968,7 +968,7 @@ mlx5_flex_parser_ecpri_release(struct rte_eth_dev *dev) */ static int mlx5_alloc_rxtx_uars(struct mlx5_dev_ctx_shared *sh, - const struct mlx5_dev_config *config) + const struct mlx5_common_dev_config *config) { uint32_t uar_mapping, retry; int err = 0; @@ -1210,7 +1210,7 @@ mlx5_dev_ctx_shared_mempool_subscribe(struct rte_eth_dev *dev) int ret; /* Check if we only need to track Rx mempool destruction. */ - if (!priv->config.mr_mempool_reg_en) { + if (!sh->cdev->config.mr_mempool_reg_en) { ret = rte_mempool_event_callback_register (mlx5_dev_ctx_shared_rx_mempool_event_cb, sh); return ret == 0 || rte_errno == EEXIST ? 0 : ret; @@ -1283,7 +1283,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, sh->cdev = spawn->cdev; if (spawn->bond_info) sh->bond = *spawn->bond_info; - err = mlx5_os_open_device(spawn, config, sh); + err = mlx5_os_open_device(spawn, sh); if (!sh->ctx) goto error; err = mlx5_os_get_dev_attr(sh->ctx, &sh->device_attr); @@ -1332,7 +1332,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, err = ENOMEM; goto error; } - err = mlx5_alloc_rxtx_uars(sh, config); + err = mlx5_alloc_rxtx_uars(sh, &sh->cdev->config); if (err) goto error; MLX5_ASSERT(sh->tx_uar); @@ -2016,7 +2016,10 @@ mlx5_args_check(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)) + 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_MR_EXT_MEMSEG_EN, key)) return 0; errno = 0; tmp = strtol(val, NULL, 0); @@ -2069,16 +2072,6 @@ mlx5_args_check(const char *key, const char *val, void *opaque) DRV_LOG(WARNING, "%s: deprecated parameter, ignored", key); } else if (strcmp(MLX5_TXQ_MPW_EN, key) == 0) { config->mps = !!tmp; - } else if (strcmp(MLX5_TX_DB_NC, key) == 0) { - if (tmp != MLX5_TXDB_CACHED && - tmp != MLX5_TXDB_NCACHED && - tmp != MLX5_TXDB_HEURISTIC) { - DRV_LOG(ERR, "invalid Tx doorbell " - "mapping parameter"); - rte_errno = EINVAL; - return -rte_errno; - } - config->dbnc = tmp; } else if (strcmp(MLX5_TXQ_MPW_HDR_DSEG_EN, key) == 0) { DRV_LOG(WARNING, "%s: deprecated parameter, ignored", key); } else if (strcmp(MLX5_TXQ_MAX_INLINE_LEN, key) == 0) { @@ -2122,8 +2115,6 @@ mlx5_args_check(const char *key, const char *val, void *opaque) config->dv_miss_info = 1; } else if (strcmp(MLX5_LACP_BY_USER, key) == 0) { config->lacp_by_user = !!tmp; - } else if (strcmp(MLX5_MR_EXT_MEMSEG_EN, key) == 0) { - config->mr_ext_memseg_en = !!tmp; } else if (strcmp(MLX5_MAX_DUMP_FILES_NUM, key) == 0) { config->max_dump_files_num = tmp; } else if (strcmp(MLX5_LRO_TIMEOUT_USEC, key) == 0) { @@ -2141,14 +2132,10 @@ mlx5_args_check(const char *key, const char *val, void *opaque) return -rte_errno; } config->reclaim_mode = tmp; - } else if (strcmp(MLX5_SYS_MEM_EN, key) == 0) { - config->sys_mem_en = !!tmp; } else if (strcmp(MLX5_DECAP_EN, key) == 0) { config->decap_en = !!tmp; } else if (strcmp(MLX5_ALLOW_DUPLICATE_PATTERN, key) == 0) { config->allow_duplicate_pattern = !!tmp; - } else if (strcmp(MLX5_MR_MEMPOOL_REG_EN, key) == 0) { - config->mr_mempool_reg_en = !!tmp; } else { DRV_LOG(WARNING, "%s: unknown parameter", key); rte_errno = EINVAL; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 2e93ce2a3e..4c8e633fb6 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -256,8 +256,6 @@ struct mlx5_dev_config { unsigned int cqe_comp_fmt:3; /* CQE compression format. */ unsigned int tso:1; /* Whether TSO is supported. */ unsigned int rx_vec_en:1; /* Rx vector is enabled. */ - unsigned int mr_ext_memseg_en:1; - /* Whether memseg should be extended for MR creation. */ unsigned int l3_vxlan_en:1; /* Enable L3 VXLAN flow creation. */ unsigned int vf_nl_en:1; /* Enable Netlink requests in VF mode. */ unsigned int dv_esw_en:1; /* Enable E-Switch DV flow. */ @@ -270,13 +268,10 @@ struct mlx5_dev_config { unsigned int dest_tir:1; /* Whether advanced DR API is available. */ unsigned int reclaim_mode:2; /* Memory reclaim mode. */ unsigned int rt_timestamp:1; /* realtime timestamp format. */ - unsigned int sys_mem_en:1; /* The default memory allocator. */ unsigned int decap_en:1; /* Whether decap will be used or not. */ unsigned int dv_miss_info:1; /* restore packet after partial hw miss */ unsigned int allow_duplicate_pattern:1; /* Allow/Prevent the duplicate rules pattern. */ - unsigned int mr_mempool_reg_en:1; - /* Allow/prevent implicit mempool memory registration. */ struct { unsigned int enabled:1; /* Whether MPRQ is enabled. */ unsigned int stride_num_n; /* Number of strides. */ @@ -289,7 +284,6 @@ struct mlx5_dev_config { /* Rx queue count threshold to enable MPRQ. */ } mprq; /* Configurations for Multi-Packet RQ. */ int mps; /* Multi-packet send supported mode. */ - int dbnc; /* Skip doorbell register write barrier. */ unsigned int flow_prio; /* Number of flow priorities. */ enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM]; /* Availibility of mreg_c's. */ @@ -1778,7 +1772,6 @@ struct rte_pci_driver; int mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *dev_attr); void mlx5_os_free_shared_dr(struct mlx5_priv *priv); int mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn, - const struct mlx5_dev_config *config, struct mlx5_dev_ctx_shared *sh); int mlx5_os_get_pdn(void *pd, uint32_t *pdn); int mlx5_os_net_probe(struct mlx5_common_device *cdev); diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index 55d27b50b9..f16f4f6a67 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -86,7 +86,7 @@ mlx5_tx_addr2mr_bh(struct mlx5_txq_data *txq, uintptr_t addr) return mlx5_mr_addr2mr_bh(priv->sh->pd, &priv->mp_id, &priv->sh->share_cache, mr_ctrl, addr, - priv->config.mr_ext_memseg_en); + priv->sh->cdev->config.mr_ext_memseg_en); } /** @@ -111,7 +111,7 @@ mlx5_tx_mb2mr_bh(struct mlx5_txq_data *txq, struct rte_mbuf *mb) uintptr_t addr = (uintptr_t)mb->buf_addr; uint32_t lkey; - if (priv->config.mr_mempool_reg_en) { + if (priv->sh->cdev->config.mr_mempool_reg_en) { struct rte_mempool *mp = NULL; struct mlx5_mprq_buf *buf; @@ -196,8 +196,8 @@ mlx5_mr_update_ext_mp_cb(struct rte_mempool *mp, void *opaque, mlx5_mr_insert_cache(&sh->share_cache, mr); rte_rwlock_write_unlock(&sh->share_cache.rwlock); /* Insert to the local cache table */ - mlx5_mr_addr2mr_bh(sh->pd, &priv->mp_id, &sh->share_cache, - mr_ctrl, addr, priv->config.mr_ext_memseg_en); + mlx5_mr_addr2mr_bh(sh->pd, &priv->mp_id, &sh->share_cache, mr_ctrl, + addr, priv->sh->cdev->config.mr_ext_memseg_en); } /** diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index eb4d34ca55..a9c8ce52c9 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -505,10 +505,10 @@ mlx5_tx_queue_release(void *dpdk_txq) static void txq_uar_ncattr_init(struct mlx5_txq_ctrl *txq_ctrl, size_t page_size) { - struct mlx5_priv *priv = txq_ctrl->priv; + struct mlx5_common_device *cdev = txq_ctrl->priv->sh->cdev; off_t cmd; - txq_ctrl->txq.db_heu = priv->config.dbnc == MLX5_TXDB_HEURISTIC; + txq_ctrl->txq.db_heu = cdev->config.dbnc == MLX5_TXDB_HEURISTIC; txq_ctrl->txq.db_nc = 0; /* Check the doorbell register mapping type. */ cmd = txq_ctrl->uar_mmap_offset / page_size; diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index 8ffbb9ff54..ea2d45bbce 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -260,8 +260,6 @@ mlx5_os_set_nonblock_channel_fd(int fd) * * @param[in] spawn * Pointer to the device attributes (name, port, etc). - * @param[out] config - * Pointer to device configuration structure. * @param[out] sh * Pointer to shared context structure. * @@ -270,10 +268,8 @@ mlx5_os_set_nonblock_channel_fd(int fd) */ int mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn, - const struct mlx5_dev_config *config, struct mlx5_dev_ctx_shared *sh) { - RTE_SET_USED(config); int err = 0; struct mlx5_context *mlx5_ctx; @@ -390,7 +386,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, strerror(rte_errno)); goto error; } - mlx5_malloc_mem_select(config->sys_mem_en); sh = mlx5_alloc_shared_dev_ctx(spawn, config); if (!sh) return NULL; @@ -1122,15 +1117,12 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev) memset(&dev_config, 0, sizeof(struct mlx5_dev_config)); dev_config.vf = dev_config_vf; dev_config.mps = 0; - dev_config.dbnc = MLX5_ARG_UNSET; dev_config.rx_vec_en = 1; dev_config.txq_inline_max = MLX5_ARG_UNSET; dev_config.txq_inline_min = MLX5_ARG_UNSET; dev_config.txq_inline_mpw = MLX5_ARG_UNSET; dev_config.txqs_inline = MLX5_ARG_UNSET; dev_config.vf_nl_en = 0; - dev_config.mr_ext_memseg_en = 1; - dev_config.mr_mempool_reg_en = 1; dev_config.mprq.max_memcpy_len = MLX5_MPRQ_MEMCPY_DEFAULT_LEN; dev_config.mprq.min_rxqs_num = MLX5_MPRQ_MIN_RXQS; dev_config.dv_esw_en = 0; -- 2.25.1