From patchwork Thu Jan 27 15:39:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 106637 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ADF62A04A6; Thu, 27 Jan 2022 16:42:29 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2506242909; Thu, 27 Jan 2022 16:40:35 +0100 (CET) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2063.outbound.protection.outlook.com [40.107.100.63]) by mails.dpdk.org (Postfix) with ESMTP id 51C72428CB for ; Thu, 27 Jan 2022 16:40:34 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hHtMAEkNy3AkbqZZtS1PM0KFSScGqChZpFQMdMeDfveONCdQ0bU+lC0IXG637jegk18Qpod+S1VwsIhMP+CTRfyR6BCe6jrlBdGaqgytNfwu6S5fTGoSJNTPpxhE0E1b1aSma0Ey9muZGDmprbOl76+28zRFfuB2vOhOmoagVpg29ZWS9Kosw2+qVFXmrNq0lX8CheRAP2hPPa59PjaSCjRGNcEcWjsRezNqsgVYCxysVAugqcsSgKYekQxjxw7pPRUDFNsLTm6F2sTHuv+oAMTpZWcRlU4GJi/6X/+xdQ3ALZ4iDSD9poh3etr5rfOMHbq1vJsWnbfj3kVdKFfiIA== 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=7LdWAm/1G4k2B0QnsyFZk57yluue2EWzSVxy9r7jduI=; b=B+DKaOiHKx78j4TSvicz0HXIzaBldVyqXb8F0ZIdoQf9KQov76dyfattcsK0LyV9Wgq7DLy8kcgH+fC/gX2IejT8G6bVl16kEr78EEoM2iODhttKbasm5lxg0l0YX2Ac/yVdoeATzabuzJQEWrJPcEcOc1r4yMJ6tyhg27rXrJLHT/qvGv3zMs9mL6FmHtUMIaq3QYxnkEmLPvW0xaMCg/fV5aKr6cESweodRAgjX9EAqmMGqnsHMsdm0oDsOt4hRUJqW6oyt4eI/yuXD+7+FausEhNVbmHToApFP3S3k9AXZMFBaSz34noM6DZ1u6mxKZXL5omBGCaCjHHijAlL+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) 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=7LdWAm/1G4k2B0QnsyFZk57yluue2EWzSVxy9r7jduI=; b=gkO0tcn3DAIkE5bjYACpFR2qTOwKaRuN5GyJ4R3MB8zwicE5LsG4+POJbVHaExeXglsl6PTWSMMvLmj18w0jua7aJcevvAp3Q5VsmoMLf7ARGyw2+QADRSEdmq75mEAZRfuPvK4eA69o7Fux0XSV2xpiRzA4TQJ2ZAHH7mivcPFKbRTh1LNlWrMpa+EEqAP0wNcRUjDi11JFNPTZv9eHMfeFePti274E/EtQN9IxReC3FmWzJZzaiyvaycbCIXuyr6B6JqwB0HJzNhY2SAt7vieXoC2HEg3wD2YlChYtOrgPy5W27D1PUHTKGfLZpsQebrx4amwwWwTo3RKmFvWAGQ== Received: from BN9PR03CA0700.namprd03.prod.outlook.com (2603:10b6:408:ef::15) by CH2PR12MB4055.namprd12.prod.outlook.com (2603:10b6:610:78::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Thu, 27 Jan 2022 15:40:33 +0000 Received: from BN8NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ef:cafe::e5) by BN9PR03CA0700.outlook.office365.com (2603:10b6:408:ef::15) 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:33 +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 BN8NAM11FT041.mail.protection.outlook.com (10.13.177.18) 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:32 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 27 Jan 2022 15:40:31 +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:30 -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:29 -0800 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Subject: [PATCH 19/20] common/mlx5: add check for common devargs in probing again Date: Thu, 27 Jan 2022 17:39:49 +0200 Message-ID: <20220127153950.812953-20-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 660a03f9-01b9-4e49-dde5-08d9e1ab5aac X-MS-TrafficTypeDiagnostic: CH2PR12MB4055:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NuZ6QCDDXi+kUzwX42DmA/qSJiyyTl0jksllK6Vm4lgDo/kArBH5BJ1M+urAg3w9svtU1aLHm1+mt/xZX1jdQgA8oDWQJyaE4gQGEEj0ONLwRcT0Uz4PV0IDa7JxPoRnMmlIjO7VW7snLlDjo2jzdedgcuUJ18tUxUsyBvLXJ1rvA+/J+0o1uVbW0p/itfCWWLSvz+9fq6z/gtUmTRdO65O2w+4P6Px5s7yzuyGNNAB4F01L9haW3lGE57k1YKGRCDtUAz90eQLgdRaVdsHPzL3CKp62j8igXG2Uwp25Uha57Fd7dHrJUeNU4zQUTe9q7VPaBUHmsCfoEEKSu0MYwZdP8c6RdR8JDkSDGfuBIccXG43DjL9MVEQjYeaEIZ6Hik/0DFkymrKu++VFD6Orps5B1xWYg6oq0eiT839TCx9CYlMtLJJkH7qHmmZ/VBriPxmce1dHTZxaEAeh8SP5YpBEc7+F1+33j2oN+EAeKfltuzils78ToGXBl2wfDniI9VQX1qkmqg1KKVSZQbTgXiMSktYmoJT1CvFUum86jMSvndoMkw2UYy48QUnJOMtbPE/kRa7m8ag46GVaDQAGT4UwUl3hOeRDsifmAqXtwPgT5ergwEQ7ukyv38fS5gEyODUhTLXYnnvkdvMTOkSvd+xAJVAB7uV6wlh8Z2CZJp+I6/VN+0HV385qKZLCPdnwHikT1LPR0iDpSROTv1a7Ig== 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:(13230001)(4636009)(40470700004)(36840700001)(46966006)(36756003)(86362001)(1076003)(2616005)(54906003)(83380400001)(5660300002)(7696005)(107886003)(426003)(508600001)(336012)(26005)(2906002)(316002)(40460700003)(186003)(6286002)(6916009)(8936002)(70206006)(70586007)(4326008)(8676002)(6666004)(81166007)(36860700001)(47076005)(356005)(82310400004)(55016003)(36900700001)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 15:40:32.4852 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 660a03f9-01b9-4e49-dde5-08d9e1ab5aac 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: BN8NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4055 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 MLX5 common driver supports probing again in two scenarios: - Add new driver under existing device. common probe function gets it in devargs, then calls the requested driver's probe function (regardless of the driver's own support in probing again) with the existing device as parameter. - Transfer the probing again support of the drivers themselves (currently only net). In this scenario, the existing device is sent as a parameter to the existing driver's probe too. In both cases it gets a new set of arguments that do not necessarily match the configured arguments in the existing device. Some of the arguments belong to the configuration of the existing device, so they can't be updated in the probing again. On the other hand, there are arguments that belong to a specific driver or specific port and might get a new value in the probing again. The user might generate any argument he wants in probing again, but when he generates arguments belonging to the common device configuration, it does not affect. This patch adds an explicit check for the devargs belonging to the common device configuration. If there is no match to the existing configuration, it returns an error. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_common.c | 100 ++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 47a541f5ef..f74d27e74d 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -613,6 +613,86 @@ mlx5_common_dev_create(struct rte_device *eal_dev, uint32_t classes) return cdev; } +/** + * Validate common devargs when probing again. + * + * When common device probing again, it cannot change its configurations. + * If user ask non compatible configurations in devargs, it is error. + * This function checks the match between: + * - Common device configurations requested by probe again devargs. + * - Existing common device configurations. + * + * @param cdev + * Pointer to mlx5 device structure. + * + * @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_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 generate devargs. */ + if (cdev->dev->devargs == 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; + } + /* + * Creates a temporary common configure structure according to new + * devargs attached in probing again. + */ + ret = mlx5_common_config_get(cdev->dev->devargs, config); + if (ret) { + DRV_LOG(ERR, "Failed to process device configure: %s", + strerror(rte_errno)); + mlx5_free(config); + return ret; + } + /* + * Checks the match between the temporary structure and the existing + * common device structure. + */ + 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) { @@ -699,12 +779,32 @@ mlx5_common_dev_probe(struct rte_device *eal_dev) if (classes == 0) /* Default to net class. */ classes = MLX5_CLASS_ETH; + /* + * MLX5 common driver supports probing again in two scenarios: + * - Add new driver under existing common device (regardless of the + * driver's own support in probing again). + * - Transfer the probing again support of the drivers themselves. + * + * In both scenarios it uses in the existing device. here it looks for + * device that match to rte device, if it exists, the request classes + * were probed with this device. + */ cdev = to_mlx5_device(eal_dev); if (!cdev) { + /* It isn't probing again, creates a new device. */ cdev = mlx5_common_dev_create(eal_dev, classes); if (!cdev) return -ENOMEM; new_device = true; + } else { + /* It is probing again, validate common devargs match. */ + ret = mlx5_common_probe_again_args_validate(cdev); + if (ret) { + DRV_LOG(ERR, + "Probe again parameters aren't compatible : %s", + strerror(rte_errno)); + return ret; + } } /* * Validate combination here.