tle_dpdk_wrapper.h revision fbba0a3b
1/*
2 * Copyright (c) 2017  Intel Corporation.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef TLE_DPDK_WRAPPER_H_
17#define TLE_DPDK_WRAPPER_H_
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include <rte_version.h>
24
25#if RTE_VERSION >= RTE_VERSION_NUM(17, 5, 0, 0)
26
27static inline uint32_t
28_rte_ring_mp_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
29	uint32_t n)
30{
31	uint32_t rc;
32
33	rc = rte_ring_mp_enqueue_bulk(r, (void * const *)obj_table, n, NULL);
34	if (rc == n)
35		return 0;
36	else
37		return -ENOSPC;
38}
39
40static inline uint32_t
41_rte_ring_mp_enqueue_burst(struct rte_ring *r, void * const *obj_table,
42	uint32_t n)
43{
44	return rte_ring_mp_enqueue_burst(r, (void * const *)obj_table, n, NULL);
45}
46
47static inline uint32_t
48_rte_ring_mc_dequeue_burst(struct rte_ring *r, void **obj_table, uint32_t n)
49{
50	return rte_ring_mc_dequeue_burst(r, (void **)obj_table, n, NULL);
51}
52
53static inline uint32_t
54_rte_ring_enqueue_burst(struct rte_ring *r, void * const *obj_table, uint32_t n)
55{
56	return rte_ring_enqueue_burst(r, (void * const *)obj_table, n, NULL);
57}
58
59static inline uint32_t
60_rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, uint32_t n)
61{
62	return rte_ring_dequeue_burst(r, (void **)obj_table, n, NULL);
63}
64
65static inline uint32_t
66_rte_ring_get_size(struct rte_ring *r)
67{
68	return r->size;
69}
70
71static inline uint32_t
72_rte_ring_get_mask(struct rte_ring *r)
73{
74	return r->mask;
75}
76
77static inline void **
78_rte_ring_get_data(struct rte_ring *r)
79{
80	return (void **)(&r[1]);
81}
82
83#else
84
85static inline uint32_t
86_rte_ring_mp_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
87	uint32_t n)
88{
89	return rte_ring_mp_enqueue_bulk(r, (void * const *)obj_table, n);
90}
91
92static inline uint32_t
93_rte_ring_mp_enqueue_burst(struct rte_ring *r, void * const *obj_table,
94	uint32_t n)
95{
96	return rte_ring_mp_enqueue_burst(r, (void * const *)obj_table, n);
97}
98
99static inline uint32_t
100_rte_ring_mc_dequeue_burst(struct rte_ring *r, void **obj_table, uint32_t n)
101{
102	return rte_ring_mc_dequeue_burst(r, (void **)obj_table, n);
103}
104
105static inline uint32_t
106_rte_ring_enqueue_burst(struct rte_ring *r, void * const *obj_table, uint32_t n)
107{
108	return rte_ring_enqueue_burst(r, (void * const *)obj_table, n);
109}
110
111static inline uint32_t
112_rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, uint32_t n)
113{
114	return rte_ring_dequeue_burst(r, (void **)obj_table, n);
115}
116
117static inline uint32_t
118_rte_ring_get_size(struct rte_ring *r)
119{
120	return r->prod.size;
121}
122
123static inline uint32_t
124_rte_ring_get_mask(struct rte_ring *r)
125{
126	return r->prod.mask;
127}
128
129static inline void **
130_rte_ring_get_data(struct rte_ring *r)
131{
132	return (void **)r->ring;
133}
134
135#endif
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif /* TLE_DPDK_WRAPPER_H_ */
142