4 * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include <rte_memzone.h>
37 #include <rte_kvargs.h>
42 #define EVENTDEV_NAME_SW_PMD event_sw
43 #define NUMA_NODE_ARG "numa_node"
44 #define SCHED_QUANTA_ARG "sched_quanta"
45 #define CREDIT_QUANTA_ARG "credit_quanta"
48 assign_numa_node(const char *key __rte_unused, const char *value, void *opaque)
50 int *socket_id = opaque;
51 *socket_id = atoi(value);
52 if (*socket_id >= RTE_MAX_NUMA_NODES)
58 set_sched_quanta(const char *key __rte_unused, const char *value, void *opaque)
61 *quanta = atoi(value);
62 if (*quanta < 0 || *quanta >= 4096)
68 set_credit_quanta(const char *key __rte_unused, const char *value, void *opaque)
71 *credit = atoi(value);
72 if (*credit < 0 || *credit >= 128)
78 sw_probe(const char *name, const char *params)
80 static const struct rte_eventdev_ops evdev_sw_ops = {
83 static const char *const args[] = {
89 struct rte_eventdev *dev;
91 int socket_id = rte_socket_id();
92 int sched_quanta = SW_DEFAULT_SCHED_QUANTA;
93 int credit_quanta = SW_DEFAULT_CREDIT_QUANTA;
95 if (params != NULL && params[0] != '\0') {
96 struct rte_kvargs *kvlist = rte_kvargs_parse(params, args);
100 "Ignoring unsupported parameters when creating device '%s'\n",
103 int ret = rte_kvargs_process(kvlist, NUMA_NODE_ARG,
104 assign_numa_node, &socket_id);
107 "%s: Error parsing numa node parameter",
109 rte_kvargs_free(kvlist);
113 ret = rte_kvargs_process(kvlist, SCHED_QUANTA_ARG,
114 set_sched_quanta, &sched_quanta);
117 "%s: Error parsing sched quanta parameter",
119 rte_kvargs_free(kvlist);
123 ret = rte_kvargs_process(kvlist, CREDIT_QUANTA_ARG,
124 set_credit_quanta, &credit_quanta);
127 "%s: Error parsing credit quanta parameter",
129 rte_kvargs_free(kvlist);
133 rte_kvargs_free(kvlist);
138 "Creating eventdev sw device %s, numa_node=%d, sched_quanta=%d, credit_quanta=%d\n",
139 name, socket_id, sched_quanta, credit_quanta);
141 dev = rte_event_pmd_vdev_init(name,
142 sizeof(struct sw_evdev), socket_id);
144 SW_LOG_ERR("eventdev vdev init() failed");
147 dev->dev_ops = &evdev_sw_ops;
149 sw = dev->data->dev_private;
150 sw->data = dev->data;
152 /* copy values passed from vdev command line to instance */
153 sw->credit_update_quanta = credit_quanta;
154 sw->sched_quanta = sched_quanta;
160 sw_remove(const char *name)
165 SW_LOG_INFO("Closing eventdev sw device %s\n", name);
167 return rte_event_pmd_vdev_uninit(name);
170 static struct rte_vdev_driver evdev_sw_pmd_drv = {
175 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_SW_PMD, evdev_sw_pmd_drv);
176 RTE_PMD_REGISTER_PARAM_STRING(event_sw, NUMA_NODE_ARG "=<int> "
177 SCHED_QUANTA_ARG "=<int>" CREDIT_QUANTA_ARG "=<int>");