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.
57 /** Maximum number of packets read from any input port in a single burst.
59 #define RTE_PORT_IN_BURST_SIZE_MAX 64
65 * Parameters for input port creation
67 * CPU socket ID (e.g. for memory allocation purpose)
69 * Handle to input port instance
71 typedef void* (*rte_port_in_op_create)(void *params, int socket_id);
77 * Handle to input port instance
79 * 0 on success, error code otherwise
81 typedef int (*rte_port_in_op_free)(void *port);
84 * Input port packet burst RX
87 * Handle to input port instance
89 * Burst of input packets
91 * Number of packets in the input burst
93 * 0 on success, error code otherwise
95 typedef int (*rte_port_in_op_rx)(
97 struct rte_mbuf **pkts,
100 /** Input port interface defining the input port operation */
101 struct rte_port_in_ops {
102 rte_port_in_op_create f_create; /**< Create */
103 rte_port_in_op_free f_free; /**< Free */
104 rte_port_in_op_rx f_rx; /**< Packet RX (packet burst) */
115 * Parameters for output port creation
117 * CPU socket ID (e.g. for memory allocation purpose)
119 * Handle to output port instance
121 typedef void* (*rte_port_out_op_create)(void *params, int socket_id);
127 * Handle to output port instance
129 * 0 on success, error code otherwise
131 typedef int (*rte_port_out_op_free)(void *port);
134 * Output port single packet TX
137 * Handle to output port instance
141 * 0 on success, error code otherwise
143 typedef int (*rte_port_out_op_tx)(
145 struct rte_mbuf *pkt);
148 * Output port packet burst TX
151 * Handle to output port instance
153 * Burst of input packets specified as array of up to 64 pointers to struct
156 * 64-bit bitmask specifying which packets in the input burst are valid. When
157 * pkts_mask bit n is set, then element n of pkts array is pointing to a
158 * valid packet. Otherwise, element n of pkts array will not be accessed.
160 * 0 on success, error code otherwise
162 typedef int (*rte_port_out_op_tx_bulk)(
164 struct rte_mbuf **pkt,
171 * Handle to output port instance
173 * 0 on success, error code otherwise
175 typedef int (*rte_port_out_op_flush)(void *port);
177 /** Output port interface defining the output port operation */
178 struct rte_port_out_ops {
179 rte_port_out_op_create f_create; /**< Create */
180 rte_port_out_op_free f_free; /**< Free */
181 rte_port_out_op_tx f_tx; /**< Packet TX (single packet) */
182 rte_port_out_op_tx_bulk f_tx_bulk; /**< Packet TX (packet burst) */
183 rte_port_out_op_flush f_flush; /**< Flush */