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 B08D4A0C52; Wed, 24 Nov 2021 11:18:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7A55C41159; Wed, 24 Nov 2021 11:18:16 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2063.outbound.protection.outlook.com [40.107.244.63]) by mails.dpdk.org (Postfix) with ESMTP id A270840E03 for ; Wed, 24 Nov 2021 11:18:15 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ncqay3NiJ2fES8ZEFdroK5g1OJ45FCxY/VcA0Z/g+tDPEx3qqQc3cr3YZqQ0C/vWXf4VkN3O+m9HbySZgR36eL/XdSlpbtmR9P+yrQVgUiOqUD3WxBqRE9a8veTwSqb7zyKFI3yXoNiAQo7zq2GVhgY0tYkt9zdWw61/jRcwmfJSbJpwGoYcMMPgqgP19ncIrrMUTRJSTpugXwZCNjcl5lJaDXRnGSaId5R/w7bKR9lSBhU/qN3zUaHZthm33Wwy8WzRtweHRcqkONktOaL3kIUKammWK9/+80c1ST7fyov13ZVLsgzN3L5VMZfw5XcWvFpxYMMUrYG6Qd/clc8YsQ== 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=976beStu6vbNfpQyrrGP8G6drUShjJK204VEf6iCFCk=; b=F9IoNJrM6d8yzvuc8zVBFmA7RSHGJMRWQwl7q88I8hbiMTxEEPkaWWoGy6FXzzZwE9b0k6w6r8OI08GTyYDndTrVEOtJjug15WoJ/307r/8RcxyeMreSCciafsryFwhMPucwQ5MqbTrvHSFdLQT2t8XZcRzBQhg3aiESVaPjD+TpBa+JPjlzsh9POl7WmQvsMWScgMlegVbEB9Uon2AXZvifDapxv0XCPH9PeDpYBr1dzpZxu+smeRc8IM40kfIPwr4UcDs2vZwKpW2/1b4GVxgBy2EwPue5i8c2+8POPsHlst8YE38L+XB/ZfP0auDOX23/YIAXEuHsrm514g/SdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=976beStu6vbNfpQyrrGP8G6drUShjJK204VEf6iCFCk=; b=b/v6C4q5GVXchzpMoL7FhNO6ixPv5FZ/pN+xey9H3/NKN63/zbCJxV56yvSoySaix16RpAuBweW1D2I8LOZL4HerOMP98zbc54LWNvA9cAVG0OAtOsTTM4tZ21cXnWNes1rwL/M+4jlx4vdnbxW4l53q6s/0KRO/VSzGil+Z662Ki96lIlGvuJyiP/a6tg+5vjNC6ZMSiIUa7+5kz1G5xlghU/xbSr2Z29MsPfEZgT5SlqRoedNDBlMABm0odQ5yxHfSeEip+H5e3n3ojrX71WvZ5S12ZJ6eGetJ9rw2D8ORLuEX6bevlglatPa1UG8j7IgNJSo5HaJvRj5o4w39ZQ== Received: from BN6PR13CA0024.namprd13.prod.outlook.com (2603:10b6:404:10a::34) by BY5PR12MB3649.namprd12.prod.outlook.com (2603:10b6:a03:1ad::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20; Wed, 24 Nov 2021 10:18:13 +0000 Received: from BN8NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:404:10a:cafe::e6) by BN6PR13CA0024.outlook.office365.com (2603:10b6:404:10a::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20 via Frontend Transport; Wed, 24 Nov 2021 10:18:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) 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 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 BN8NAM11FT046.mail.protection.outlook.com (10.13.177.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4713.20 via Frontend Transport; Wed, 24 Nov 2021 10:18:11 +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; Wed, 24 Nov 2021 10:18:09 +0000 From: Xueming Li To: CC: , Lior Margalit , , Parav Pandit , David Marchand , Ray Kinsella Subject: [PATCH v2] kvargs: fix device iterator match from arguments Date: Wed, 24 Nov 2021 18:17:40 +0800 Message-ID: <20211124101740.3479061-1-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211122061250.3220823-1-xuemingl@nvidia.com> References: <20211122061250.3220823-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d5ef0b9d-2a64-4396-ed2c-08d9af33b85a X-MS-TrafficTypeDiagnostic: BY5PR12MB3649: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SvJqqYPbIuNUh8aDlo3tELrpQgncDZIPxpHnZoWpfFk2IMWHVr7luo4AUyWN7OCKpsYzmEMkkUigYOBgWsQSVtt6eHy9njB86rwZQTo5NMAwIl8gTocbTxjcaFxFNT5C3sQqtz7EoVMigomkO+y9TKuvWjXpbU3thozYK/xwhWPmNvfiZkQQeRThtkBqLXaKLShlF57zXt0RquMH+F6MacnQLOFmfYFwaogMVXUEqHiY3P7nblZmbe4CyEkitp6M4gpKTJSL/Eu/04qPVLTagXBipMj1rB42NL7ahzdlmUp9NXJ46Xz0PGlG7HJfm68wzqF5a9Ed0Op2KfoTlBuL+Dxz4tg5lPGIoN5q+1CdksDtpI28/dZXAokfNtaA6d4HSCvwldBfF3UeUTrLvuUBPSkp34vLcGIU0XUPVRAmK9RmvjBZ+sPYjvlHsrmndsuvHTkRZBcJZbQuPRdANDRjLbd75NiS3FRsSxvsaMsuYt5Eq+y88+EBtQbczI5/Qfr9NpQamPvsAGL4kRbt+dUU6UeuKZUGgFS1s/gxolSmzjFN4+AWGWoeGgdh7UIBBYArLZ4p9RDoXY7don119mi6B8pQpY9s4sUbtAV+abu0vsn6x5p0YpWdp0rYA310yu4bornYf0TlYvrR4VrPojaZscgRSfiuzIfAMtbJtG+/9LGhF1Eud358iAbKMXWexnF3LmDy5jsBOQEd70s8dvGyLg== 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)(46966006)(36840700001)(70206006)(7636003)(86362001)(4326008)(55016003)(8676002)(6286002)(356005)(70586007)(508600001)(2616005)(6916009)(1076003)(8936002)(426003)(82310400004)(83380400001)(16526019)(186003)(316002)(7696005)(2906002)(5660300002)(54906003)(47076005)(26005)(6666004)(36756003)(36860700001)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2021 10:18:11.8896 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5ef0b9d-2a64-4396-ed2c-08d9af33b85a 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: BN8NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3649 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 Device iterator RTE_DEV_FOREACH() failed to return devices from classifier like "class=vdpa", because matching name from empty kvargs returns no result. If device name not specified in kvargs, the function should iterate all devices. This patch allows empty devargs or devargs without name specified. Fixes: 6aebb942907d ("kvargs: add function to get from key and value") Cc: olivier.matz@6wind.com Signed-off-by: Xueming Li --- 21.11 specific bug, no copy to stable.org --- drivers/bus/auxiliary/auxiliary_params.c | 14 +++++++++----- drivers/bus/vdev/vdev_params.c | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/bus/auxiliary/auxiliary_params.c b/drivers/bus/auxiliary/auxiliary_params.c index a9c7853ed1d..9cbc1f7c777 100644 --- a/drivers/bus/auxiliary/auxiliary_params.c +++ b/drivers/bus/auxiliary/auxiliary_params.c @@ -26,11 +26,15 @@ auxiliary_dev_match(const struct rte_device *dev, { const struct rte_kvargs *kvlist = _kvlist; const char *key = auxiliary_params_keys[RTE_AUXILIARY_PARAM_NAME]; - - if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL) - return -1; - - return 0; + const char *name; + + if (kvlist == NULL) + return 0; + name = rte_kvargs_get(kvlist, key); + if (name == NULL) + /* Iterate all devices if name not specified. */ + return 0; + return strcmp(name, dev->name); } void * diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c index 37d95395e7a..b4baecb7c0d 100644 --- a/drivers/bus/vdev/vdev_params.c +++ b/drivers/bus/vdev/vdev_params.c @@ -28,11 +28,15 @@ vdev_dev_match(const struct rte_device *dev, { const struct rte_kvargs *kvlist = _kvlist; const char *key = vdev_params_keys[RTE_VDEV_PARAM_NAME]; - - if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL) - return -1; - - return 0; + const char *name; + + if (kvlist == NULL) + return 0; + name = rte_kvargs_get(kvlist, key); + if (name == NULL) + /* Iterate all devices if name not specified. */ + return 0; + return strcmp(name, dev->name); } void * -- 2.34.0