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 47535A0C52; Wed, 24 Nov 2021 12:07:08 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D0A1941155; Wed, 24 Nov 2021 12:07:07 +0100 (CET) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mails.dpdk.org (Postfix) with ESMTP id EEACB40DF7 for ; Wed, 24 Nov 2021 12:07:05 +0100 (CET) Received: by mail-wm1-f48.google.com with SMTP id i12so1903747wmq.4 for ; Wed, 24 Nov 2021 03:07:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=AVdVJuj7W357B6PjcINkONb/TVx//H8VHOEXLmBfaMM=; b=EBCvqKCOAKzS2dFyi50/c3XeEMYaG9sWaIoIH35MT/6oBlN2Wo9N/HpYNUg1kKY3tE MaP3eldMlhrEUKO9w1oYRtEjHmPpOcddCx2GBsG8VRTzYDwrkCkuZpM0slCLGmhtIFMm tnYgh3cG9ScaK/ZroUTWGoGIlAk2pIxvzInGeYjIO+BG5YYJpM7CXYF0AwQf8LG1vt5m nn/hFxUjp233VAkzjQmkDdNNR9W7In4AliCOmK7h7n2s88fA4I6+PAcKUkN3KVdcG+w/ 7VPgmIR/8JdKGBwCblWal69IyMQeIZAn6iSxueEHkBE74xgeIUjIrvjWmyK4Ydf3ujEs H2gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=AVdVJuj7W357B6PjcINkONb/TVx//H8VHOEXLmBfaMM=; b=whgDdXdHVuFC2QM7UBVVSUAjfhq8yG0ewiuRqbnRmTiT9Y0vH0lFSAXZCTbVXb8kV9 T3YVOe26oKErbeAOlGbOzPNA2iGLX9PHDNCmHQ5Sh0cLD1FWLmID0SNMCRAnVOvkBjaW haGe83kEuzSGKYmymuwRmOztSGKnfWoFrSMGoXiwrrdw2vr1D4g+hVmrJ8LgUQvoYLj1 IvsevfOxQ0ulpAzdfYmPXb0WKPI3GHIb86JgcU8qz3qdpWhOcJn2JswOSs1Apuwm3bmV f6P4khBfvfUCzB64B0jPyxZvX+koTigBnq8UtDmwJkCHTJx97iLkNI35s8Cfmj0+CDCG VFrw== X-Gm-Message-State: AOAM532BRWavWFYwfMOx13KmxEbAt18YuWhEiIHP6JQ3fV/fkEImh8Qe 630+GoTjhB+39qejEGA7zBnghA== X-Google-Smtp-Source: ABdhPJziphDLk3dYZAoPGoE7D3h1hYApoB1xBjIGUexm0GTsHvJXs5xLalng0jeP8XhiXfPBtc9Z0w== X-Received: by 2002:a05:600c:1e26:: with SMTP id ay38mr13964784wmb.14.1637752025589; Wed, 24 Nov 2021 03:07:05 -0800 (PST) Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25]) by smtp.gmail.com with ESMTPSA id a10sm4610393wmq.27.2021.11.24.03.07.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 03:07:05 -0800 (PST) Date: Wed, 24 Nov 2021 12:07:04 +0100 From: Olivier Matz To: Xueming Li Cc: dev@dpdk.org, Lior Margalit , Parav Pandit , David Marchand , Ray Kinsella Subject: Re: [PATCH v2] kvargs: fix device iterator match from arguments Message-ID: References: <20211122061250.3220823-1-xuemingl@nvidia.com> <20211124101740.3479061-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211124101740.3479061-1-xuemingl@nvidia.com> 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 Hi Xueming, On Wed, Nov 24, 2021 at 06:17:40PM +0800, Xueming Li wrote: > 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 I just sent a v3 with the unit test. In case there is an issue with it, your v2 looks good to me: Acked-by: Olivier Matz As a side note, I was wondering if we should keep rte_kvargs_get_with_value() in kvargs api, since there is no more user. I think there it can still be useful, let's keep it for now. Thanks! Olivier > --- > 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 >