4 * Copyright(c) 2016 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.
41 * packet dump library to provide packet capturing support on dpdk.
45 #include <rte_mempool.h>
52 #define RTE_PDUMP_ALL_QUEUES UINT16_MAX
55 RTE_PDUMP_FLAG_RX = 1, /* receive direction */
56 RTE_PDUMP_FLAG_TX = 2, /* transmit direction */
57 /* both receive and transmit directions */
58 RTE_PDUMP_FLAG_RXTX = (RTE_PDUMP_FLAG_RX|RTE_PDUMP_FLAG_TX)
61 enum rte_pdump_socktype {
62 RTE_PDUMP_SOCKET_SERVER = 1,
63 RTE_PDUMP_SOCKET_CLIENT = 2
67 * Initialize packet capturing handling
69 * Creates pthread and server socket for handling clients
70 * requests to enable/disable rxtx callbacks.
73 * directory path for server socket.
76 * 0 on success, -1 on error
79 rte_pdump_init(const char *path);
82 * Un initialize packet capturing handling
84 * Cancels pthread, close server socket, removes server socket address.
87 * 0 on success, -1 on error
90 rte_pdump_uninit(void);
93 * Enables packet capturing on given port and queue.
96 * port on which packet capturing should be enabled.
98 * queue of a given port on which packet capturing should be enabled.
99 * users should pass on value UINT16_MAX to enable packet capturing on all
100 * queues of a given port.
102 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
103 * on which packet capturing should be enabled for a given port and queue.
105 * ring on which captured packets will be enqueued for user.
107 * mempool on to which original packets will be mirrored or duplicated.
109 * place holder for packet filtering.
112 * 0 on success, -1 on error, rte_errno is set accordingly.
116 rte_pdump_enable(uint8_t port, uint16_t queue, uint32_t flags,
117 struct rte_ring *ring,
118 struct rte_mempool *mp,
122 * Disables packet capturing on given port and queue.
125 * port on which packet capturing should be disabled.
127 * queue of a given port on which packet capturing should be disabled.
128 * users should pass on value UINT16_MAX to disable packet capturing on all
129 * queues of a given port.
131 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
132 * on which packet capturing should be enabled for a given port and queue.
135 * 0 on success, -1 on error, rte_errno is set accordingly.
139 rte_pdump_disable(uint8_t port, uint16_t queue, uint32_t flags);
142 * Enables packet capturing on given device id and queue.
143 * device_id can be name or pci address of device.
146 * device id on which packet capturing should be enabled.
148 * queue of a given device id on which packet capturing should be enabled.
149 * users should pass on value UINT16_MAX to enable packet capturing on all
150 * queues of a given device id.
152 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
153 * on which packet capturing should be enabled for a given port and queue.
155 * ring on which captured packets will be enqueued for user.
157 * mempool on to which original packets will be mirrored or duplicated.
159 * place holder for packet filtering.
162 * 0 on success, -1 on error, rte_errno is set accordingly.
166 rte_pdump_enable_by_deviceid(char *device_id, uint16_t queue,
168 struct rte_ring *ring,
169 struct rte_mempool *mp,
173 * Disables packet capturing on given device_id and queue.
174 * device_id can be name or pci address of device.
177 * pci address or name of the device on which packet capturing
178 * should be disabled.
180 * queue of a given device on which packet capturing should be disabled.
181 * users should pass on value UINT16_MAX to disable packet capturing on all
182 * queues of a given device id.
184 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
185 * on which packet capturing should be enabled for a given port and queue.
188 * 0 on success, -1 on error, rte_errno is set accordingly.
191 rte_pdump_disable_by_deviceid(char *device_id, uint16_t queue,
195 * Allows applications to set server and client socket paths.
196 * If specified path is null default path will be selected, i.e.
197 *"/var/run/" for root user and "$HOME" for non root user.
198 * Clients also need to call this API to set their server path if the
199 * server path is different from default path.
200 * This API is not thread-safe.
203 * directory path for server or client socket.
205 * specifies RTE_PDUMP_SOCKET_SERVER if socket path is for server.
207 * specifies RTE_PDUMP_SOCKET_CLIENT if socket path is for client.
210 * 0 on success, -EINVAL on error
214 rte_pdump_set_socket_dir(const char *path, enum rte_pdump_socktype type);
220 #endif /* _RTE_PDUMP_H_ */