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>
24 #define RTE_PDUMP_ALL_QUEUES UINT16_MAX
27 RTE_PDUMP_FLAG_RX = 1, /* receive direction */
28 RTE_PDUMP_FLAG_TX = 2, /* transmit direction */
29 /* both receive and transmit directions */
30 RTE_PDUMP_FLAG_RXTX = (RTE_PDUMP_FLAG_RX|RTE_PDUMP_FLAG_TX),
32 RTE_PDUMP_FLAG_PCAPNG = 4, /* format for pcapng */
36 * Initialize packet capturing handling
38 * Register the IPC action for communication with target (primary) process.
41 * 0 on success, -1 on error
47 * Un initialize packet capturing handling
49 * Unregister the IPC action for communication with target (primary) process.
52 * 0 on success, -1 on error
55 rte_pdump_uninit(void);
58 * Enables packet capturing on given port and queue.
61 * port on which packet capturing should be enabled.
63 * queue of a given port on which packet capturing should be enabled.
64 * users should pass on value UINT16_MAX to enable packet capturing on all
65 * queues of a given port.
67 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
68 * on which packet capturing should be enabled for a given port and queue.
70 * ring on which captured packets will be enqueued for user.
72 * mempool on to which original packets will be mirrored or duplicated.
74 * Unused should be NULL.
77 * 0 on success, -1 on error, rte_errno is set accordingly.
81 rte_pdump_enable(uint16_t port, uint16_t queue, uint32_t flags,
82 struct rte_ring *ring,
83 struct rte_mempool *mp,
88 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
90 * Enables packet capturing on given port and queue with filtering.
93 * The Ethernet port on which packet capturing should be enabled.
95 * The queue on the Ethernet port which packet capturing
96 * should be enabled. Pass UINT16_MAX to enable packet capturing on all
97 * queues of a given port.
99 * Pdump library flags that specify direction and packet format.
101 * The upper limit on bytes to copy.
102 * Passing UINT32_MAX means capture all the possible data.
104 * The ring on which captured packets will be enqueued for user.
106 * The mempool on to which original packets will be mirrored or duplicated.
108 * Use BPF program to run to filter packes (can be NULL)
111 * 0 on success, -1 on error, rte_errno is set accordingly.
115 rte_pdump_enable_bpf(uint16_t port_id, uint16_t queue,
116 uint32_t flags, uint32_t snaplen,
117 struct rte_ring *ring,
118 struct rte_mempool *mp,
119 const struct rte_bpf_prm *prm);
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(uint16_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 * unused should be NULL
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,
174 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
176 * Enables packet capturing on given device id and queue with filtering.
177 * device_id can be name or pci address of device.
180 * device id on which packet capturing should be enabled.
182 * The queue on the Ethernet port which packet capturing
183 * should be enabled. Pass UINT16_MAX to enable packet capturing on all
184 * queues of a given port.
186 * Pdump library flags that specify direction and packet format.
188 * The upper limit on bytes to copy.
189 * Passing UINT32_MAX means capture all the possible data.
191 * The ring on which captured packets will be enqueued for user.
193 * The mempool on to which original packets will be mirrored or duplicated.
195 * Use BPF program to run to filter packes (can be NULL)
198 * 0 on success, -1 on error, rte_errno is set accordingly.
202 rte_pdump_enable_bpf_by_deviceid(const char *device_id, uint16_t queue,
203 uint32_t flags, uint32_t snaplen,
204 struct rte_ring *ring,
205 struct rte_mempool *mp,
206 const struct rte_bpf_prm *filter);
210 * Disables packet capturing on given device_id and queue.
211 * device_id can be name or pci address of device.
214 * pci address or name of the device on which packet capturing
215 * should be disabled.
217 * queue of a given device on which packet capturing should be disabled.
218 * users should pass on value UINT16_MAX to disable packet capturing on all
219 * queues of a given device id.
221 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
222 * on which packet capturing should be enabled for a given port and queue.
225 * 0 on success, -1 on error, rte_errno is set accordingly.
228 rte_pdump_disable_by_deviceid(char *device_id, uint16_t queue,
233 * A structure used to retrieve statistics from packet capture.
234 * The statistics are sum of both receive and transmit queues.
236 struct rte_pdump_stats {
237 uint64_t accepted; /**< Number of packets accepted by filter. */
238 uint64_t filtered; /**< Number of packets rejected by filter. */
239 uint64_t nombuf; /**< Number of mbuf allocation failures. */
240 uint64_t ringfull; /**< Number of missed packets due to ring full. */
242 uint64_t reserved[4]; /**< Reserved and pad to cache line */
247 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
249 * Retrieve the packet capture statistics for a queue.
252 * The port identifier of the Ethernet device.
254 * A pointer to structure of type *rte_pdump_stats* to be filled in.
256 * Zero if successful. -1 on error and rte_errno is set.
260 rte_pdump_stats(uint16_t port_id, struct rte_pdump_stats *stats);
267 #endif /* _RTE_PDUMP_H_ */