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>
40 #define CLNRM "\x1b[0m"
41 #define CLRED "\x1b[31m"
42 #define CLGRN "\x1b[32m"
43 #define CLYEL "\x1b[33m"
45 #define evt_err(fmt, args...) \
46 fprintf(stderr, CLRED"error: %s() "fmt CLNRM "\n", __func__, ## args)
48 #define evt_info(fmt, args...) \
49 fprintf(stdout, CLYEL""fmt CLNRM "\n", ## args)
51 #define EVT_STR_FMT 20
53 #define evt_dump(str, fmt, val...) \
54 printf("\t%-*s : "fmt"\n", EVT_STR_FMT, str, ## val)
56 #define evt_dump_begin(str) printf("\t%-*s : {", EVT_STR_FMT, str)
58 #define evt_dump_end printf("\b}\n")
60 #define EVT_MAX_STAGES 64
61 #define EVT_MAX_PORTS 256
62 #define EVT_MAX_QUEUES 256
65 evt_has_distributed_sched(uint8_t dev_id)
67 struct rte_event_dev_info dev_info;
69 rte_event_dev_info_get(dev_id, &dev_info);
70 return (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED) ?
75 evt_has_burst_mode(uint8_t dev_id)
77 struct rte_event_dev_info dev_info;
79 rte_event_dev_info_get(dev_id, &dev_info);
80 return (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_BURST_MODE) ?
86 evt_has_all_types_queue(uint8_t dev_id)
88 struct rte_event_dev_info dev_info;
90 rte_event_dev_info_get(dev_id, &dev_info);
91 return (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES) ?
95 static inline uint32_t
96 evt_sched_type2queue_cfg(uint8_t sched_type)
100 switch (sched_type) {
101 case RTE_SCHED_TYPE_ATOMIC:
102 ret = RTE_EVENT_QUEUE_CFG_ATOMIC_ONLY;
104 case RTE_SCHED_TYPE_ORDERED:
105 ret = RTE_EVENT_QUEUE_CFG_ORDERED_ONLY;
107 case RTE_SCHED_TYPE_PARALLEL:
108 ret = RTE_EVENT_QUEUE_CFG_PARALLEL_ONLY;
111 rte_panic("Invalid sched_type %d\n", sched_type);
116 #endif /* _EVT_COMMON_*/