1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016 Intel Corporation
12 * packet dump library to provide packet capturing support on dpdk.
16 #include <rte_mempool.h>
23 #define RTE_PDUMP_ALL_QUEUES UINT16_MAX
26 RTE_PDUMP_FLAG_RX = 1, /* receive direction */
27 RTE_PDUMP_FLAG_TX = 2, /* transmit direction */
28 /* both receive and transmit directions */
29 RTE_PDUMP_FLAG_RXTX = (RTE_PDUMP_FLAG_RX|RTE_PDUMP_FLAG_TX)
32 enum rte_pdump_socktype {
33 RTE_PDUMP_SOCKET_SERVER = 1,
34 RTE_PDUMP_SOCKET_CLIENT = 2
38 * Initialize packet capturing handling
40 * Creates pthread and server socket for handling clients
41 * requests to enable/disable rxtx callbacks.
44 * directory path for server socket.
47 * 0 on success, -1 on error
50 rte_pdump_init(const char *path);
53 * Un initialize packet capturing handling
55 * Cancels pthread, close server socket, removes server socket address.
58 * 0 on success, -1 on error
61 rte_pdump_uninit(void);
64 * Enables packet capturing on given port and queue.
67 * port on which packet capturing should be enabled.
69 * queue of a given port on which packet capturing should be enabled.
70 * users should pass on value UINT16_MAX to enable packet capturing on all
71 * queues of a given port.
73 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
74 * on which packet capturing should be enabled for a given port and queue.
76 * ring on which captured packets will be enqueued for user.
78 * mempool on to which original packets will be mirrored or duplicated.
80 * place holder for packet filtering.
83 * 0 on success, -1 on error, rte_errno is set accordingly.
87 rte_pdump_enable(uint16_t port, uint16_t queue, uint32_t flags,
88 struct rte_ring *ring,
89 struct rte_mempool *mp,
93 * Disables packet capturing on given port and queue.
96 * port on which packet capturing should be disabled.
98 * queue of a given port on which packet capturing should be disabled.
99 * users should pass on value UINT16_MAX to disable 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.
106 * 0 on success, -1 on error, rte_errno is set accordingly.
110 rte_pdump_disable(uint16_t port, uint16_t queue, uint32_t flags);
113 * Enables packet capturing on given device id and queue.
114 * device_id can be name or pci address of device.
117 * device id on which packet capturing should be enabled.
119 * queue of a given device id on which packet capturing should be enabled.
120 * users should pass on value UINT16_MAX to enable packet capturing on all
121 * queues of a given device id.
123 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
124 * on which packet capturing should be enabled for a given port and queue.
126 * ring on which captured packets will be enqueued for user.
128 * mempool on to which original packets will be mirrored or duplicated.
130 * place holder for packet filtering.
133 * 0 on success, -1 on error, rte_errno is set accordingly.
137 rte_pdump_enable_by_deviceid(char *device_id, uint16_t queue,
139 struct rte_ring *ring,
140 struct rte_mempool *mp,
144 * Disables packet capturing on given device_id and queue.
145 * device_id can be name or pci address of device.
148 * pci address or name of the device on which packet capturing
149 * should be disabled.
151 * queue of a given device on which packet capturing should be disabled.
152 * users should pass on value UINT16_MAX to disable packet capturing on all
153 * queues of a given device id.
155 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
156 * on which packet capturing should be enabled for a given port and queue.
159 * 0 on success, -1 on error, rte_errno is set accordingly.
162 rte_pdump_disable_by_deviceid(char *device_id, uint16_t queue,
166 * Allows applications to set server and client socket paths.
167 * If specified path is null default path will be selected, i.e.
168 *"/var/run/" for root user and "$HOME" for non root user.
169 * Clients also need to call this API to set their server path if the
170 * server path is different from default path.
171 * This API is not thread-safe.
174 * directory path for server or client socket.
176 * specifies RTE_PDUMP_SOCKET_SERVER if socket path is for server.
178 * specifies RTE_PDUMP_SOCKET_CLIENT if socket path is for client.
181 * 0 on success, -EINVAL on error
185 rte_pdump_set_socket_dir(const char *path, enum rte_pdump_socktype type);
191 #endif /* _RTE_PDUMP_H_ */