From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by dpdk.org (Postfix) with ESMTP id 1A63C1B5E7 for ; Wed, 11 Jul 2018 23:46:08 +0200 (CEST) Received: by mail-wr1-f42.google.com with SMTP id m1-v6so6882746wrg.5 for ; Wed, 11 Jul 2018 14:46:08 -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=AH2FVVkX2u7mtYa50M6VFZU+7mr+o4oKgHe0E7heEC8=; b=RoTFGEfmsvYYfnwqbf3InFltObwdIjpbe2a8m7wDCSTl2FHmEg8tvh2Az0BtoAEV/y wSTK4YgrTyCrfOjB/xAYcXWAWipXXOTxsAr+Ro7d2L+mo4ilPrUiOpvwDXARizRR2kWU QsNxqeuuRUSYvLRMoO5QddhxMTHfhd0pJ0qRX/jaiLHxWduQusNHdMO0wI7NkQtAMnK1 qsTD7Kb5KobeLQshD9G2wYMFby6pIFZykWFTiSUW/1zHPjkC7wN6vGqL7H3YHwP2zKHH pein/3I3YwDzw2GzI1LNaP7z6UQizrLdSBNatOXL6jnTP7FVdDpMCLbRPfthw8CX+ypN 4v2A== 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=AH2FVVkX2u7mtYa50M6VFZU+7mr+o4oKgHe0E7heEC8=; b=Ib5DebAgVLpZK3nl98cOpQChtIgZY8GLlwEzfR/Q9pjOLMzEVbFogXhQYTj8sZb3cX h+MY+D9L8c/RizcvMkC5fs+g4SFpUlMz9HpI6Dox6MEmo7c+p/Ong8/xjFmAjHU574ea QMHD9H/FQwG5OglYZ1sNx7+HIdKBp+l2uxJeE7RpIoEprce7M4Jq0WpNTgVI4ZBjXftv jSimB8WorCQxdaqJBb3YhfzjRKuLF7UZT2EFC68WvlbDZ6TYuMGSY8gkI8AtAOsByC3Z PewRrN32uUKiMRovdqcm2sN3UnHOZmEgYNODhRZW9U2BTXjXotSmzeXXTa6AYKuK88QM m8/A== X-Gm-Message-State: AOUpUlGpEhJSUWvtC5KVF+yul15sySZEZGeXuizBX0OXJiqTzWAxfU5o CzGcpoMzNleF03WPx5c53wbrirgP X-Google-Smtp-Source: AAOMgpcFg5JiUpKI4yUQfjShA7BR2GabwPwJiy2zpCEayDBvYWNWbw0LkOPWg5tomtVAvjyF2FUS6g== X-Received: by 2002:adf:99ea:: with SMTP id y97-v6mr196193wrb.215.1531345567457; Wed, 11 Jul 2018 14:46:07 -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 h5-v6sm10550936wrr.19.2018.07.11.14.46.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 14:46:06 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 11 Jul 2018 23:45:14 +0200 Message-Id: <408a2d49131bfc2cf0af8d4d723af070a40005d0.1531345404.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v11 24/25] 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: Wed, 11 Jul 2018 21:46:08 -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 | 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 @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,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 +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); + 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)) + 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 98e089e58..cee4f5bee 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" int rte_eth_dev_logtype; @@ -3486,6 +3487,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