1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2016-2018 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
13 #include <rte_devargs.h>
14 #include <rte_kvargs.h>
17 #include "sfc_kvargs.h"
20 sfc_kvargs_parse(struct sfc_adapter *sa)
22 struct rte_eth_dev *eth_dev = (sa)->eth_dev;
23 struct rte_devargs *devargs = eth_dev->device->devargs;
24 const char **params = (const char *[]){
25 SFC_KVARG_STATS_UPDATE_PERIOD_MS,
26 SFC_KVARG_PERF_PROFILE,
27 SFC_KVARG_RX_DATAPATH,
28 SFC_KVARG_TX_DATAPATH,
36 sa->kvargs = rte_kvargs_parse(devargs->args, params);
37 if (sa->kvargs == NULL)
44 sfc_kvargs_cleanup(struct sfc_adapter *sa)
46 rte_kvargs_free(sa->kvargs);
50 sfc_kvarg_match_value(const char *value, const char * const *values,
51 unsigned int n_values)
55 for (i = 0; i < n_values; ++i)
56 if (strcasecmp(value, values[i]) == 0)
63 sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
64 arg_handler_t handler, void *opaque_arg)
66 if (sa->kvargs == NULL)
69 return -rte_kvargs_process(sa->kvargs, key_match, handler, opaque_arg);
73 sfc_kvarg_bool_handler(__rte_unused const char *key,
74 const char *value_str, void *opaque)
76 const char * const true_strs[] = {
77 "1", "y", "yes", "on", "true"
79 const char * const false_strs[] = {
80 "0", "n", "no", "off", "false"
84 if (sfc_kvarg_match_value(value_str, true_strs,
87 else if (sfc_kvarg_match_value(value_str, false_strs,
97 sfc_kvarg_long_handler(__rte_unused const char *key,
98 const char *value_str, void *opaque)
103 if (!value_str || !opaque)
106 value = strtol(value_str, &endptr, 0);
107 if (endptr == value_str)
110 *(long *)opaque = value;
116 sfc_kvarg_string_handler(__rte_unused const char *key,
117 const char *value_str, void *opaque)
119 *(const char **)opaque = value_str;