From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 9DEC74C88 for ; Fri, 31 Aug 2018 12:10:53 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us4.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 4D4AD8005E; Fri, 31 Aug 2018 10:10:52 +0000 (UTC) Received: from [192.168.38.17] (91.220.146.112) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 31 Aug 2018 11:10:47 +0100 To: Gaetan Rivet , References: <712878880719df833be5c45f866fae04ba5379aa.1535633784.git.gaetan.rivet@6wind.com> From: Andrew Rybchenko Message-ID: <4538a50d-d6fa-bca2-2dc5-5c9ee9a2c24d@solarflare.com> Date: Fri, 31 Aug 2018 13:10:48 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <712878880719df833be5c45f866fae04ba5379aa.1535633784.git.gaetan.rivet@6wind.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [91.220.146.112] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24064.003 X-TM-AS-Result: No-10.810500-8.000000-10 X-TMASE-MatchedRID: 7ySqCuYCpfgOwH4pD14DsPHkpkyUphL9m/y00tE9StZUFL8kNivfsI4t VeoS0/jn2Bzgv79yUtfijpjet3oGSG5/NyTKlG69JmbrB1j4Xwrt/okBLaEo+C3FY27PpHmsEUb gQYFHh3gDOjwJX1aGYTVq4vGUB5lAkfRhdidsajM5f9Xw/xqKXVkMvWAuahr8+gD2vYtOFhgqtq 5d3cxkNbT1o6X5fhsH09DzptcSlpveeF5Z134YZTKCD9SPVB33ffhhYvGAMJY= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--10.810500-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24064.003 X-MDID: 1535710253-wuuLTMGLOnC6 Subject: Re: [dpdk-dev] [PATCH v1 12/13] ethdev: process declarative eth devargs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Aug 2018 10:10:54 -0000 On 08/30/2018 04:42 PM, Gaetan Rivet wrote: > Process the class-specific arguments in a devargs. > This processing takes the form of setting the proper eth_dev fields when > relevant. > > Signed-off-by: Gaetan Rivet > --- > lib/librte_ethdev/eth_private.h | 5 +++ > lib/librte_ethdev/rte_class_eth.c | 62 +++++++++++++++++++++++++++++++ > lib/librte_ethdev/rte_ethdev.c | 7 ++++ > 3 files changed, 74 insertions(+) > > diff --git a/lib/librte_ethdev/eth_private.h b/lib/librte_ethdev/eth_private.h > index 0f5c6d5c4..c0c065165 100644 > --- a/lib/librte_ethdev/eth_private.h > +++ b/lib/librte_ethdev/eth_private.h > @@ -19,6 +19,11 @@ struct rte_eth_dev * > eth_find_device(const struct rte_eth_dev *_start, rte_eth_cmp_t cmp, > const void *data); > > +/* Generic rte_eth_dev parameters processor. */ > +int > +rte_eth_dev_args_parse(struct rte_eth_dev *eth_dev, > + struct rte_devargs *da); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c > index d8d8e8845..18fdef605 100644 > --- a/lib/librte_ethdev/rte_class_eth.c > +++ b/lib/librte_ethdev/rte_class_eth.c <...> > @@ -79,6 +93,54 @@ eth_dev_iterate(const void *start, > return edev; > } > > +static int > +eth_dev_set_name(struct rte_eth_dev *edev, > + const char *value) > +{ > + snprintf(edev->data->name, > + sizeof(edev->data->name), > + "%s", value); strlcpy()? Shouldn't we return error if name does fit in name buffer? > + return 0; > +} > + > +static int > +ethdev_args_process(const char *key, > + const char *value, > + void *_edev) > +{ > + static eth_dev_set_t eth_dev_set[] = { > + [RTE_ETH_PARAMS_NAME] = eth_dev_set_name, > + [RTE_ETH_PARAMS_MAX] = NULL, > + }; > + struct rte_eth_dev *edev = _edev; > + int param; > + > + param = ethdev_param_id(key); > + if (eth_dev_set[param]) > + return eth_dev_set[param](edev, value); > + return 0; > +} > + > +int > +rte_eth_dev_args_parse(struct rte_eth_dev *edev, > + struct rte_devargs *devargs) > +{ > + struct rte_kvargs *kvargs = NULL; > + > + if (devargs == NULL || devargs->cls_str == NULL) > + return 0; > + > + kvargs = rte_kvargs_parse_delim(devargs->cls_str, eth_params_keys, "/"); > + if (kvargs == NULL) { > + RTE_LOG(ERR, EAL, "cannot parse argument list\n"); > + return -EINVAL; > + } > + if (rte_kvargs_process(kvargs, NULL, ethdev_args_process, edev)) Shouldn't we free kvargs here as well? > + return -1; > + rte_kvargs_free(kvargs); > + return 0; > +} > + > struct rte_class rte_class_eth = { > .dev_iterate = eth_dev_iterate, > }; <...>