DPDK  17.05.2
rte_distributor.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2017 Intel Corporation. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
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
15  * distribution.
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.
19  *
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.
31  */
32 
33 #ifndef _RTE_DISTRIBUTOR_H_
34 #define _RTE_DISTRIBUTOR_H_
35 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /* Type of distribution (burst/single) */
49 enum rte_distributor_alg_type {
50  RTE_DIST_ALG_BURST = 0,
51  RTE_DIST_ALG_SINGLE,
52  RTE_DIST_NUM_ALG_TYPES
53 };
54 
55 struct rte_distributor;
56 struct rte_mbuf;
57 
78 struct rte_distributor *
79 rte_distributor_create(const char *name, unsigned int socket_id,
80  unsigned int num_workers,
81  unsigned int alg_type);
82 
83 /* *** APIS to be called on the distributor lcore *** */
84 /*
85  * The following APIs are the public APIs which are designed for use on a
86  * single lcore which acts as the distributor lcore for a given distributor
87  * instance. These functions cannot be called on multiple cores simultaneously
88  * without using locking to protect access to the internals of the distributor.
89  *
90  * NOTE: a given lcore cannot act as both a distributor lcore and a worker lcore
91  * for the same distributor instance, otherwise deadlock will result.
92  */
93 
115 int
116 rte_distributor_process(struct rte_distributor *d,
117  struct rte_mbuf **mbufs, unsigned int num_mbufs);
118 
133 int
134 rte_distributor_returned_pkts(struct rte_distributor *d,
135  struct rte_mbuf **mbufs, unsigned int max_mbufs);
136 
148 int
149 rte_distributor_flush(struct rte_distributor *d);
150 
160 void
161 rte_distributor_clear_returns(struct rte_distributor *d);
162 
163 /* *** APIS to be called on the worker lcores *** */
164 /*
165  * The following APIs are the public APIs which are designed for use on
166  * multiple lcores which act as workers for a distributor. Each lcore should use
167  * a unique worker id when requesting packets.
168  *
169  * NOTE: a given lcore cannot act as both a distributor lcore and a worker lcore
170  * for the same distributor instance, otherwise deadlock will result.
171  */
172 
193 int
194 rte_distributor_get_pkt(struct rte_distributor *d,
195  unsigned int worker_id, struct rte_mbuf **pkts,
196  struct rte_mbuf **oldpkt, unsigned int retcount);
197 
212 int
213 rte_distributor_return_pkt(struct rte_distributor *d,
214  unsigned int worker_id, struct rte_mbuf **oldpkt, int num);
215 
238 void
239 rte_distributor_request_pkt(struct rte_distributor *d,
240  unsigned int worker_id, struct rte_mbuf **oldpkt,
241  unsigned int count);
242 
261 int
262 rte_distributor_poll_pkt(struct rte_distributor *d,
263  unsigned int worker_id, struct rte_mbuf **mbufs);
264 
265 #ifdef __cplusplus
266 }
267 #endif
268 
269 #endif