1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
4 #ifndef __INCLUDE_RTE_SWX_PORT_H__
5 #define __INCLUDE_RTE_SWX_PORT_H__
15 * Packet I/O port interface.
22 /** Opaque packet handle. */
25 /** Buffer where the packet is stored. */
28 /** Packet buffer offset of the first packet byte. */
31 /** Packet length in bytes. */
43 * Arguments for input port creation. Format specific to each port type.
45 * Handle to input port instance on success, NULL on error.
48 (*rte_swx_port_in_create_t)(void *args);
57 (*rte_swx_port_in_free_t)(void *port);
60 * Input port packet receive
65 * Received packet. Only valid when the function returns 1. Must point to
68 * 0 when no packet was received, 1 when a packet was received. No other
69 * return values are allowed.
72 (*rte_swx_port_in_pkt_rx_t)(void *port,
73 struct rte_swx_pkt *pkt);
75 /** Input port statistics counters. */
76 struct rte_swx_port_in_stats {
77 /** Number of packets. */
80 /** Number of bytes. */
83 /** Number of empty polls. */
88 * Input port statistics counters read
93 * Input port statistics counters. Must point to valid memory.
96 (*rte_swx_port_in_stats_read_t)(void *port,
97 struct rte_swx_port_in_stats *stats);
99 /** Input port operations. */
100 struct rte_swx_port_in_ops {
101 /** Create. Must be non-NULL. */
102 rte_swx_port_in_create_t create;
104 /** Free. Must be non-NULL. */
105 rte_swx_port_in_free_t free;
107 /** Packet reception. Must be non-NULL. */
108 rte_swx_port_in_pkt_rx_t pkt_rx;
110 /** Statistics counters read. Must be non-NULL. */
111 rte_swx_port_in_stats_read_t stats_read;
122 * Arguments for output port creation. Format specific to each port type.
124 * Handle to output port instance on success, NULL on error.
127 (*rte_swx_port_out_create_t)(void *args);
133 * Output port handle.
136 (*rte_swx_port_out_free_t)(void *port);
139 * Output port packet transmit
142 * Output port handle.
144 * Packet to be transmitted.
147 (*rte_swx_port_out_pkt_tx_t)(void *port,
148 struct rte_swx_pkt *pkt);
151 * Output port packet fast clone and transmit
154 * Output port handle.
156 * Packet to be transmitted.
159 (*rte_swx_port_out_pkt_fast_clone_tx_t)(void *port,
160 struct rte_swx_pkt *pkt);
163 * Output port packet clone and transmit
166 * Output port handle.
168 * Packet to be transmitted.
169 * @param[in] truncation_length
170 * Packet length to be cloned.
173 (*rte_swx_port_out_pkt_clone_tx_t)(void *port,
174 struct rte_swx_pkt *pkt,
175 uint32_t truncation_length);
181 * Output port handle.
184 (*rte_swx_port_out_flush_t)(void *port);
186 /** Output port statistics counters. */
187 struct rte_swx_port_out_stats {
188 /** Number of packets. */
191 /** Number of bytes. */
194 /** Number of packets cloned successfully. */
195 uint64_t n_pkts_clone;
197 /** Number of packets with clone errors. */
198 uint64_t n_pkts_clone_err;
202 * Output port statistics counters read
205 * Output port handle.
207 * Output port statistics counters. Must point to valid memory.
210 (*rte_swx_port_out_stats_read_t)(void *port,
211 struct rte_swx_port_out_stats *stats);
213 /** Output port operations. */
214 struct rte_swx_port_out_ops {
215 /** Create. Must be non-NULL. */
216 rte_swx_port_out_create_t create;
218 /** Free. Must be non-NULL. */
219 rte_swx_port_out_free_t free;
221 /** Packet transmission. Must be non-NULL. */
222 rte_swx_port_out_pkt_tx_t pkt_tx;
224 /** Packet fast clone and transmission. Must be non-NULL. */
225 rte_swx_port_out_pkt_fast_clone_tx_t pkt_fast_clone_tx;
227 /** Packet clone and transmission. Must be non-NULL. */
228 rte_swx_port_out_pkt_clone_tx_t pkt_clone_tx;
230 /** Flush. May be NULL. */
231 rte_swx_port_out_flush_t flush;
233 /** Statistics counters read. Must be non-NULL. */
234 rte_swx_port_out_stats_read_t stats_read;