4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
34 #ifndef __INCLUDE_RTE_PORT_H__
35 #define __INCLUDE_RTE_PORT_H__
45 * This tool is part of the Intel DPDK Packet Framework tool suite and provides
46 * a standard interface to implement different types of packet ports.
54 * Macros to allow accessing metadata stored in the mbuf headroom
55 * just beyond the end of the mbuf data structure returned by a port
57 #define RTE_MBUF_METADATA_UINT8(mbuf, offset) \
58 (((uint8_t *)&(mbuf)[1])[offset])
59 #define RTE_MBUF_METADATA_UINT16(mbuf, offset) \
60 (((uint16_t *)&(mbuf)[1])[offset/sizeof(uint16_t)])
61 #define RTE_MBUF_METADATA_UINT32(mbuf, offset) \
62 (((uint32_t *)&(mbuf)[1])[offset/sizeof(uint32_t)])
63 #define RTE_MBUF_METADATA_UINT64(mbuf, offset) \
64 (((uint64_t *)&(mbuf)[1])[offset/sizeof(uint64_t)])
66 #define RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset) \
67 (&RTE_MBUF_METADATA_UINT8(mbuf, offset))
68 #define RTE_MBUF_METADATA_UINT16_PTR(mbuf, offset) \
69 (&RTE_MBUF_METADATA_UINT16(mbuf, offset))
70 #define RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset) \
71 (&RTE_MBUF_METADATA_UINT32(mbuf, offset))
72 #define RTE_MBUF_METADATA_UINT64_PTR(mbuf, offset) \
73 (&RTE_MBUF_METADATA_UINT64(mbuf, offset))
80 /** Maximum number of packets read from any input port in a single burst.
82 #define RTE_PORT_IN_BURST_SIZE_MAX 64
88 * Parameters for input port creation
90 * CPU socket ID (e.g. for memory allocation purpose)
92 * Handle to input port instance
94 typedef void* (*rte_port_in_op_create)(void *params, int socket_id);
100 * Handle to input port instance
102 * 0 on success, error code otherwise
104 typedef int (*rte_port_in_op_free)(void *port);
107 * Input port packet burst RX
110 * Handle to input port instance
112 * Burst of input packets
114 * Number of packets in the input burst
116 * 0 on success, error code otherwise
118 typedef int (*rte_port_in_op_rx)(
120 struct rte_mbuf **pkts,
123 /** Input port interface defining the input port operation */
124 struct rte_port_in_ops {
125 rte_port_in_op_create f_create; /**< Create */
126 rte_port_in_op_free f_free; /**< Free */
127 rte_port_in_op_rx f_rx; /**< Packet RX (packet burst) */
138 * Parameters for output port creation
140 * CPU socket ID (e.g. for memory allocation purpose)
142 * Handle to output port instance
144 typedef void* (*rte_port_out_op_create)(void *params, int socket_id);
150 * Handle to output port instance
152 * 0 on success, error code otherwise
154 typedef int (*rte_port_out_op_free)(void *port);
157 * Output port single packet TX
160 * Handle to output port instance
164 * 0 on success, error code otherwise
166 typedef int (*rte_port_out_op_tx)(
168 struct rte_mbuf *pkt);
171 * Output port packet burst TX
174 * Handle to output port instance
176 * Burst of input packets specified as array of up to 64 pointers to struct
179 * 64-bit bitmask specifying which packets in the input burst are valid. When
180 * pkts_mask bit n is set, then element n of pkts array is pointing to a
181 * valid packet. Otherwise, element n of pkts array will not be accessed.
183 * 0 on success, error code otherwise
185 typedef int (*rte_port_out_op_tx_bulk)(
187 struct rte_mbuf **pkt,
194 * Handle to output port instance
196 * 0 on success, error code otherwise
198 typedef int (*rte_port_out_op_flush)(void *port);
200 /** Output port interface defining the output port operation */
201 struct rte_port_out_ops {
202 rte_port_out_op_create f_create; /**< Create */
203 rte_port_out_op_free f_free; /**< Free */
204 rte_port_out_op_tx f_tx; /**< Packet TX (single packet) */
205 rte_port_out_op_tx_bulk f_tx_bulk; /**< Packet TX (packet burst) */
206 rte_port_out_op_flush f_flush; /**< Flush */