From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id D0FDA1BF2A for ; Thu, 5 Jul 2018 13:49:30 +0200 (CEST) Received: by mail-wm0-f47.google.com with SMTP id s14-v6so10374829wmc.1 for ; Thu, 05 Jul 2018 04:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EQK0dT0i7rzxsss/dg1hwvBBBCm+0OxnIM+fdFet49Y=; b=y/5wAJjU+y0gSMYsg5vA+BQNDaPYrEliwtjYqaj6VlzaJHBsF+39fhYLAPriKbnOOl IrHkqxwj4BqeYoakt5UtcZEY3Whq/IKMb1pQ8Cxbjdw6lKGw+EFPRS9CosbG9ibfVUp4 9Wz0xhzH/UbLjPhl9KG4E1ywGYaCT/d2wuGxgjdayURLQnAJzW8+iaZ620KJnyD/D8/u PgGQ46X0atUKhtPWGSd2RVNlY6PyQFpSkg7SH5V189h46SUcHNqbQHCRDwk1dJnGCb3b Weakmcna4ucVECsSm6ih8MH9MuMkAWZW7SAmF8/2W32afM1RApgjQhoNTbcn4LWPqrHF V53g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EQK0dT0i7rzxsss/dg1hwvBBBCm+0OxnIM+fdFet49Y=; b=nbGZ6x7/i5xc73cFM/+zDo6DW6pqd7nRxP+aBhOV+mi0XHnsbLfloqRkpzYVqbaoY8 sheeJBnDNxw5vq/pi4x1N9PAAYN2IY5rdKkG50lHZWsAVUIQWFJeEPbMdhppscElr7dN M0el9ABWQ4HDMN87CofOUgGYRayCVNzHKurksOCXET2coDwsp0vs3VHcM8Lo07DdU5xl LUHhdeX6kES1M+jZAzAm56aox10/+4nnmMB8oFSPLa2QiMxDWviUcJz4JaPuZqaBjEP3 t0o3B5vH0uAgbpq226QNnf8okqbE7ZuXi1vfI3TFFCLeKs8uS/YTlpwsT6lw235ez15E JfJQ== X-Gm-Message-State: APt69E0xILsDs7QWF7FdvY/M+DEYFtUmfOhyllnTNm0k+uu96Sox1bzH 1WOm0i8TvUXqixYeSz3Exv2UwnmT X-Google-Smtp-Source: AAOMgpeJSJK6iJynZAWzr0XU/H9oJm8ufMzWALKDjbTkZW/xJxx/pC8Jbp+FOPofsyx5nQdPZfE6Ag== X-Received: by 2002:adf:c5d2:: with SMTP id v18-v6mr4095805wrg.151.1530791370207; Thu, 05 Jul 2018 04:49:30 -0700 (PDT) Received: from bidouze.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id o42-v6sm15809183wrc.50.2018.07.05.04.49.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 04:49:29 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 5 Jul 2018 13:48:33 +0200 Message-Id: <1b2f9ef1c7a81fbda26e960017f4ec55c39c7925.1530791217.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v10 26/27] 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: Thu, 05 Jul 2018 11:49:31 -0000 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 | 61 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 7 ++++ 3 files changed, 73 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..f02b6fd6a 100644 --- a/lib/librte_ethdev/rte_class_eth.c +++ b/lib/librte_ethdev/rte_class_eth.c @@ -35,6 +35,19 @@ struct eth_dev_match_arg { .kvlist = (k), \ }) +typedef int (*eth_dev_set_t)(struct rte_eth_dev *edev, const char *value); + +static enum eth_params +ethdev_param_id(const char *key) +{ + int i; + + for (i = 0; i < RTE_ETH_PARAMS_MAX; i++) + if (strcmp(key, eth_params_keys[i]) == 0) + return i; + return RTE_ETH_PARAMS_MAX; +} + static int eth_dev_match(const struct rte_eth_dev *edev, const void *_arg) @@ -79,6 +92,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); + 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 *da) +{ + struct rte_kvargs *kvargs = NULL; + + if (da == NULL || da->clsstr == NULL) + return 0; + + kvargs = rte_kvargs_parse2(da->clsstr, 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)) + return -1; + rte_kvargs_free(kvargs); + return 0; +} + struct rte_class rte_class_eth = { .dev_iterate = eth_dev_iterate, }; diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index cce20d9ae..4583509dd 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -41,6 +41,7 @@ #include "rte_ethdev.h" #include "rte_ethdev_driver.h" #include "ethdev_profile.h" +#include "eth_private.h" static int ethdev_logtype; @@ -3594,6 +3595,12 @@ rte_eth_dev_create(struct rte_device *device, const char *name, } } + retval = rte_eth_dev_args_parse(ethdev, device->devargs); + if (retval) { + RTE_LOG(ERR, EAL, "ethdev parsing failed"); + goto probe_failed; + } + retval = ethdev_init(ethdev, init_params); if (retval) { RTE_LOG(ERR, EAL, "ethdev initialisation failed"); -- 2.18.0