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,
30 SFC_KVARG_RXD_WAIT_TIMEOUT_NS,
37 sa->kvargs = rte_kvargs_parse(devargs->args, params);
38 if (sa->kvargs == NULL)
45 sfc_kvargs_cleanup(struct sfc_adapter *sa)
47 rte_kvargs_free(sa->kvargs);
51 sfc_kvarg_match_value(const char *value, const char * const *values,
52 unsigned int n_values)
56 for (i = 0; i < n_values; ++i)
57 if (strcasecmp(value, values[i]) == 0)
64 sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
65 arg_handler_t handler, void *opaque_arg)
67 if (sa->kvargs == NULL)
70 return -rte_kvargs_process(sa->kvargs, key_match, handler, opaque_arg);
74 sfc_kvarg_bool_handler(__rte_unused const char *key,
75 const char *value_str, void *opaque)
77 const char * const true_strs[] = {
78 "1", "y", "yes", "on", "true"
80 const char * const false_strs[] = {
81 "0", "n", "no", "off", "false"
85 if (sfc_kvarg_match_value(value_str, true_strs,
88 else if (sfc_kvarg_match_value(value_str, false_strs,
98 sfc_kvarg_long_handler(__rte_unused const char *key,
99 const char *value_str, void *opaque)
104 if (!value_str || !opaque)
107 value = strtol(value_str, &endptr, 0);
108 if (endptr == value_str)
111 *(long *)opaque = value;
117 sfc_kvarg_string_handler(__rte_unused const char *key,
118 const char *value_str, void *opaque)
120 *(const char **)opaque = value_str;