4 * Copyright (C) Cavium, Inc 2017.
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 Cavium, Inc 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_common.h>
37 #include <rte_debug.h>
38 #include <rte_eventdev.h>
39 #include <rte_service.h>
41 #define CLNRM "\x1b[0m"
42 #define CLRED "\x1b[31m"
43 #define CLGRN "\x1b[32m"
44 #define CLYEL "\x1b[33m"
46 #define evt_err(fmt, args...) \
47 fprintf(stderr, CLRED"error: %s() "fmt CLNRM "\n", __func__, ## args)
49 #define evt_info(fmt, args...) \
50 fprintf(stdout, CLYEL""fmt CLNRM "\n", ## args)
52 #define EVT_STR_FMT 20
54 #define evt_dump(str, fmt, val...) \
55 printf("\t%-*s : "fmt"\n", EVT_STR_FMT, str, ## val)
57 #define evt_dump_begin(str) printf("\t%-*s : {", EVT_STR_FMT, str)
59 #define evt_dump_end printf("\b}\n")
61 #define EVT_MAX_STAGES 64
62 #define EVT_MAX_PORTS 256
63 #define EVT_MAX_QUEUES 256
66 evt_has_distributed_sched(uint8_t dev_id)
68 struct rte_event_dev_info dev_info;
70 rte_event_dev_info_get(dev_id, &dev_info);
71 return (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED) ?
76 evt_has_burst_mode(uint8_t dev_id)
78 struct rte_event_dev_info dev_info;
80 rte_event_dev_info_get(dev_id, &dev_info);
81 return (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_BURST_MODE) ?
87 evt_has_all_types_queue(uint8_t dev_id)
89 struct rte_event_dev_info dev_info;
91 rte_event_dev_info_get(dev_id, &dev_info);
92 return (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES) ?
97 evt_service_setup(uint8_t dev_id)
101 unsigned int lcore = 0;
102 uint32_t core_array[RTE_MAX_LCORE];
104 uint8_t min_cnt = UINT8_MAX;
106 if (evt_has_distributed_sched(dev_id))
109 if (!rte_service_lcore_count())
112 if (!rte_event_dev_service_id_get(dev_id, &service_id)) {
113 core_cnt = rte_service_lcore_list(core_array,
117 /* Get the core which has least number of services running. */
119 /* Reset default mapping */
120 rte_service_map_lcore_set(service_id,
121 core_array[core_cnt], 0);
122 cnt = rte_service_lcore_count_services(
123 core_array[core_cnt]);
125 lcore = core_array[core_cnt];
129 if (rte_service_map_lcore_set(service_id, lcore, 1))
135 #endif /* _EVT_COMMON_*/