DPDK  17.02.1
rte_distributor.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of Intel Corporation nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef _RTE_DISTRIBUTE_H_
35 #define _RTE_DISTRIBUTE_H_
36 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #define RTE_DISTRIBUTOR_NAMESIZE 32
51 struct rte_distributor;
52 struct rte_mbuf;
53 
70 struct rte_distributor *
71 rte_distributor_create(const char *name, unsigned socket_id,
72  unsigned num_workers);
73 
74 /* *** APIS to be called on the distributor lcore *** */
75 /*
76  * The following APIs are the public APIs which are designed for use on a
77  * single lcore which acts as the distributor lcore for a given distributor
78  * instance. These functions cannot be called on multiple cores simultaneously
79  * without using locking to protect access to the internals of the distributor.
80  *
81  * NOTE: a given lcore cannot act as both a distributor lcore and a worker lcore
82  * for the same distributor instance, otherwise deadlock will result.
83  */
84 
105 int
106 rte_distributor_process(struct rte_distributor *d,
107  struct rte_mbuf **mbufs, unsigned num_mbufs);
108 
123 int
124 rte_distributor_returned_pkts(struct rte_distributor *d,
125  struct rte_mbuf **mbufs, unsigned max_mbufs);
126 
138 int
139 rte_distributor_flush(struct rte_distributor *d);
140 
150 void
151 rte_distributor_clear_returns(struct rte_distributor *d);
152 
153 /* *** APIS to be called on the worker lcores *** */
154 /*
155  * The following APIs are the public APIs which are designed for use on
156  * multiple lcores which act as workers for a distributor. Each lcore should use
157  * a unique worker id when requesting packets.
158  *
159  * NOTE: a given lcore cannot act as both a distributor lcore and a worker lcore
160  * for the same distributor instance, otherwise deadlock will result.
161  */
162 
179 struct rte_mbuf *
180 rte_distributor_get_pkt(struct rte_distributor *d,
181  unsigned worker_id, struct rte_mbuf *oldpkt);
182 
195 int
196 rte_distributor_return_pkt(struct rte_distributor *d, unsigned worker_id,
197  struct rte_mbuf *mbuf);
198 
219 void
220 rte_distributor_request_pkt(struct rte_distributor *d,
221  unsigned worker_id, struct rte_mbuf *oldpkt);
222 
239 struct rte_mbuf *
240 rte_distributor_poll_pkt(struct rte_distributor *d,
241  unsigned worker_id);
242 
243 #ifdef __cplusplus
244 }
245 #endif
246 
247 #endif