DPDK  16.11.11
rte_port.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 __INCLUDE_RTE_PORT_H__
35 #define __INCLUDE_RTE_PORT_H__
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
50 #include <stdint.h>
51 #include <rte_mbuf.h>
52 
57 #define RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset) \
58  (&((uint8_t *)(mbuf))[offset])
59 #define RTE_MBUF_METADATA_UINT16_PTR(mbuf, offset) \
60  ((uint16_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset))
61 #define RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset) \
62  ((uint32_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset))
63 #define RTE_MBUF_METADATA_UINT64_PTR(mbuf, offset) \
64  ((uint64_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset))
65 
66 #define RTE_MBUF_METADATA_UINT8(mbuf, offset) \
67  (*RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset))
68 #define RTE_MBUF_METADATA_UINT16(mbuf, offset) \
69  (*RTE_MBUF_METADATA_UINT16_PTR(mbuf, offset))
70 #define RTE_MBUF_METADATA_UINT32(mbuf, offset) \
71  (*RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset))
72 #define RTE_MBUF_METADATA_UINT64(mbuf, offset) \
73  (*RTE_MBUF_METADATA_UINT64_PTR(mbuf, offset))
74 
76 /*
77  * Port IN
78  *
79  */
82 #define RTE_PORT_IN_BURST_SIZE_MAX 64
83 
86  uint64_t n_pkts_in;
87  uint64_t n_pkts_drop;
88 };
89 
100 typedef void* (*rte_port_in_op_create)(void *params, int socket_id);
101 
110 typedef int (*rte_port_in_op_free)(void *port);
111 
124 typedef int (*rte_port_in_op_rx)(
125  void *port,
126  struct rte_mbuf **pkts,
127  uint32_t n_pkts);
128 
143  void *port,
144  struct rte_port_in_stats *stats,
145  int clear);
146 
153 };
154 
155 /*
156  * Port OUT
157  *
158  */
161  uint64_t n_pkts_in;
162  uint64_t n_pkts_drop;
163 };
164 
175 typedef void* (*rte_port_out_op_create)(void *params, int socket_id);
176 
185 typedef int (*rte_port_out_op_free)(void *port);
186 
197 typedef int (*rte_port_out_op_tx)(
198  void *port,
199  struct rte_mbuf *pkt);
200 
216 typedef int (*rte_port_out_op_tx_bulk)(
217  void *port,
218  struct rte_mbuf **pkt,
219  uint64_t pkts_mask);
220 
229 typedef int (*rte_port_out_op_flush)(void *port);
230 
245  void *port,
246  struct rte_port_out_stats *stats,
247  int clear);
248 
257 };
258 
259 #ifdef __cplusplus
260 }
261 #endif
262 
263 #endif
uint8_t port
Definition: rte_mbuf.h:385
int(* rte_port_in_op_rx)(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)
Definition: rte_port.h:124
rte_port_out_op_create f_create
Definition: rte_port.h:251
rte_port_out_op_tx_bulk f_tx_bulk
Definition: rte_port.h:254
rte_port_out_op_stats_read f_stats
Definition: rte_port.h:256
rte_port_in_op_rx f_rx
Definition: rte_port.h:151
rte_port_in_op_stats_read f_stats
Definition: rte_port.h:152
void *(* rte_port_in_op_create)(void *params, int socket_id)
Definition: rte_port.h:100
void *(* rte_port_out_op_create)(void *params, int socket_id)
Definition: rte_port.h:175
int(* rte_port_out_op_free)(void *port)
Definition: rte_port.h:185
int(* rte_port_out_op_flush)(void *port)
Definition: rte_port.h:229
rte_port_out_op_tx f_tx
Definition: rte_port.h:253
int(* rte_port_in_op_stats_read)(void *port, struct rte_port_in_stats *stats, int clear)
Definition: rte_port.h:142
int(* rte_port_out_op_tx)(void *port, struct rte_mbuf *pkt)
Definition: rte_port.h:197
rte_port_out_op_flush f_flush
Definition: rte_port.h:255
int(* rte_port_out_op_stats_read)(void *port, struct rte_port_out_stats *stats, int clear)
Definition: rte_port.h:244
rte_port_in_op_create f_create
Definition: rte_port.h:149
rte_port_out_op_free f_free
Definition: rte_port.h:252
int(* rte_port_out_op_tx_bulk)(void *port, struct rte_mbuf **pkt, uint64_t pkts_mask)
Definition: rte_port.h:216
rte_port_in_op_free f_free
Definition: rte_port.h:150
int(* rte_port_in_op_free)(void *port)
Definition: rte_port.h:110