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.
48 #define RTE_PDUMP_ALL_QUEUES UINT16_MAX
51 RTE_PDUMP_FLAG_RX = 1, /* receive direction */
52 RTE_PDUMP_FLAG_TX = 2, /* transmit direction */
53 /* both receive and transmit directions */
54 RTE_PDUMP_FLAG_RXTX = (RTE_PDUMP_FLAG_RX|RTE_PDUMP_FLAG_TX)
57 enum rte_pdump_socktype {
58 RTE_PDUMP_SOCKET_SERVER = 1,
59 RTE_PDUMP_SOCKET_CLIENT = 2
63 * Initialize packet capturing handling
65 * Creates pthread and server socket for handling clients
66 * requests to enable/disable rxtx callbacks.
69 * directory path for server socket.
72 * 0 on success, -1 on error
75 rte_pdump_init(const char *path);
78 * Un initialize packet capturing handling
80 * Cancels pthread, close server socket, removes server socket address.
83 * 0 on success, -1 on error
86 rte_pdump_uninit(void);
89 * Enables packet capturing on given port and queue.
92 * port on which packet capturing should be enabled.
94 * queue of a given port on which packet capturing should be enabled.
95 * users should pass on value UINT16_MAX to enable packet capturing on all
96 * queues of a given port.
98 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
99 * on which packet capturing should be enabled for a given port and queue.
101 * ring on which captured packets will be enqueued for user.
103 * mempool on to which original packets will be mirrored or duplicated.
105 * place holder for packet filtering.
108 * 0 on success, -1 on error, rte_errno is set accordingly.
112 rte_pdump_enable(uint8_t port, uint16_t queue, uint32_t flags,
113 struct rte_ring *ring,
114 struct rte_mempool *mp,
118 * Disables packet capturing on given port and queue.
121 * port on which packet capturing should be disabled.
123 * queue of a given port on which packet capturing should be disabled.
124 * users should pass on value UINT16_MAX to disable packet capturing on all
125 * queues of a given port.
127 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
128 * on which packet capturing should be enabled for a given port and queue.
131 * 0 on success, -1 on error, rte_errno is set accordingly.
135 rte_pdump_disable(uint8_t port, uint16_t queue, uint32_t flags);
138 * Enables packet capturing on given device id and queue.
139 * device_id can be name or pci address of device.
142 * device id on which packet capturing should be enabled.
144 * queue of a given device id on which packet capturing should be enabled.
145 * users should pass on value UINT16_MAX to enable packet capturing on all
146 * queues of a given device id.
148 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
149 * on which packet capturing should be enabled for a given port and queue.
151 * ring on which captured packets will be enqueued for user.
153 * mempool on to which original packets will be mirrored or duplicated.
155 * place holder for packet filtering.
158 * 0 on success, -1 on error, rte_errno is set accordingly.
162 rte_pdump_enable_by_deviceid(char *device_id, uint16_t queue,
164 struct rte_ring *ring,
165 struct rte_mempool *mp,
169 * Disables packet capturing on given device_id and queue.
170 * device_id can be name or pci address of device.
173 * pci address or name of the device on which packet capturing
174 * should be disabled.
176 * queue of a given device on which packet capturing should be disabled.
177 * users should pass on value UINT16_MAX to disable packet capturing on all
178 * queues of a given device id.
180 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
181 * on which packet capturing should be enabled for a given port and queue.
184 * 0 on success, -1 on error, rte_errno is set accordingly.
187 rte_pdump_disable_by_deviceid(char *device_id, uint16_t queue,
191 * Allows applications to set server and client socket paths.
192 * If specified path is null default path will be selected, i.e.
193 *"/var/run/" for root user and "$HOME" for non root user.
194 * Clients also need to call this API to set their server path if the
195 * server path is different from default path.
196 * This API is not thread-safe.
199 * directory path for server or client socket.
201 * specifies RTE_PDUMP_SOCKET_SERVER if socket path is for server.
203 * specifies RTE_PDUMP_SOCKET_CLIENT if socket path is for client.
206 * 0 on success, -EINVAL on error
210 rte_pdump_set_socket_dir(const char *path, enum rte_pdump_socktype type);
216 #endif /* _RTE_PDUMP_H_ */