1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016 Intel Corporation
12 * packet dump library to provide packet capturing support on dpdk.
22 #define RTE_PDUMP_ALL_QUEUES UINT16_MAX
25 RTE_PDUMP_FLAG_RX = 1, /* receive direction */
26 RTE_PDUMP_FLAG_TX = 2, /* transmit direction */
27 /* both receive and transmit directions */
28 RTE_PDUMP_FLAG_RXTX = (RTE_PDUMP_FLAG_RX|RTE_PDUMP_FLAG_TX),
30 RTE_PDUMP_FLAG_PCAPNG = 4, /* format for pcapng */
34 * Initialize packet capturing handling
36 * Register the IPC action for communication with target (primary) process.
39 * 0 on success, -1 on error
45 * Un initialize packet capturing handling
47 * Unregister the IPC action for communication with target (primary) process.
50 * 0 on success, -1 on error
53 rte_pdump_uninit(void);
56 * Enables packet capturing on given port and queue.
59 * port on which packet capturing should be enabled.
61 * queue of a given port on which packet capturing should be enabled.
62 * users should pass on value UINT16_MAX to enable packet capturing on all
63 * queues of a given port.
65 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
66 * on which packet capturing should be enabled for a given port and queue.
68 * ring on which captured packets will be enqueued for user.
70 * mempool on to which original packets will be mirrored or duplicated.
72 * Unused should be NULL.
75 * 0 on success, -1 on error, rte_errno is set accordingly.
79 rte_pdump_enable(uint16_t port, uint16_t queue, uint32_t flags,
80 struct rte_ring *ring,
81 struct rte_mempool *mp,
86 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
88 * Enables packet capturing on given port and queue with filtering.
91 * The Ethernet port on which packet capturing should be enabled.
93 * The queue on the Ethernet port which packet capturing
94 * should be enabled. Pass UINT16_MAX to enable packet capturing on all
95 * queues of a given port.
97 * Pdump library flags that specify direction and packet format.
99 * The upper limit on bytes to copy.
100 * Passing UINT32_MAX means capture all the possible data.
102 * The ring on which captured packets will be enqueued for user.
104 * The mempool on to which original packets will be mirrored or duplicated.
106 * Use BPF program to run to filter packes (can be NULL)
109 * 0 on success, -1 on error, rte_errno is set accordingly.
113 rte_pdump_enable_bpf(uint16_t port_id, uint16_t queue,
114 uint32_t flags, uint32_t snaplen,
115 struct rte_ring *ring,
116 struct rte_mempool *mp,
117 const struct rte_bpf_prm *prm);
120 * Disables packet capturing on given port and queue.
123 * port on which packet capturing should be disabled.
125 * queue of a given port on which packet capturing should be disabled.
126 * users should pass on value UINT16_MAX to disable packet capturing on all
127 * queues of a given port.
129 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
130 * on which packet capturing should be enabled for a given port and queue.
133 * 0 on success, -1 on error, rte_errno is set accordingly.
137 rte_pdump_disable(uint16_t port, uint16_t queue, uint32_t flags);
140 * Enables packet capturing on given device id and queue.
141 * device_id can be name or pci address of device.
144 * device id on which packet capturing should be enabled.
146 * queue of a given device id on which packet capturing should be enabled.
147 * users should pass on value UINT16_MAX to enable packet capturing on all
148 * queues of a given device id.
150 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
151 * on which packet capturing should be enabled for a given port and queue.
153 * ring on which captured packets will be enqueued for user.
155 * mempool on to which original packets will be mirrored or duplicated.
157 * unused should be NULL
160 * 0 on success, -1 on error, rte_errno is set accordingly.
164 rte_pdump_enable_by_deviceid(char *device_id, uint16_t queue,
166 struct rte_ring *ring,
167 struct rte_mempool *mp,
172 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
174 * Enables packet capturing on given device id and queue with filtering.
175 * device_id can be name or pci address of device.
178 * device id on which packet capturing should be enabled.
180 * The queue on the Ethernet port which packet capturing
181 * should be enabled. Pass UINT16_MAX to enable packet capturing on all
182 * queues of a given port.
184 * Pdump library flags that specify direction and packet format.
186 * The upper limit on bytes to copy.
187 * Passing UINT32_MAX means capture all the possible data.
189 * The ring on which captured packets will be enqueued for user.
191 * The mempool on to which original packets will be mirrored or duplicated.
193 * Use BPF program to run to filter packes (can be NULL)
196 * 0 on success, -1 on error, rte_errno is set accordingly.
200 rte_pdump_enable_bpf_by_deviceid(const char *device_id, uint16_t queue,
201 uint32_t flags, uint32_t snaplen,
202 struct rte_ring *ring,
203 struct rte_mempool *mp,
204 const struct rte_bpf_prm *filter);
208 * Disables packet capturing on given device_id and queue.
209 * device_id can be name or pci address of device.
212 * pci address or name of the device on which packet capturing
213 * should be disabled.
215 * queue of a given device on which packet capturing should be disabled.
216 * users should pass on value UINT16_MAX to disable packet capturing on all
217 * queues of a given device id.
219 * flags specifies RTE_PDUMP_FLAG_RX/RTE_PDUMP_FLAG_TX/RTE_PDUMP_FLAG_RXTX
220 * on which packet capturing should be enabled for a given port and queue.
223 * 0 on success, -1 on error, rte_errno is set accordingly.
226 rte_pdump_disable_by_deviceid(char *device_id, uint16_t queue,
231 * A structure used to retrieve statistics from packet capture.
232 * The statistics are sum of both receive and transmit queues.
234 struct rte_pdump_stats {
235 uint64_t accepted; /**< Number of packets accepted by filter. */
236 uint64_t filtered; /**< Number of packets rejected by filter. */
237 uint64_t nombuf; /**< Number of mbuf allocation failures. */
238 uint64_t ringfull; /**< Number of missed packets due to ring full. */
240 uint64_t reserved[4]; /**< Reserved and pad to cache line */
245 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
247 * Retrieve the packet capture statistics for a queue.
250 * The port identifier of the Ethernet device.
252 * A pointer to structure of type *rte_pdump_stats* to be filled in.
254 * Zero if successful. -1 on error and rte_errno is set.
258 rte_pdump_stats(uint16_t port_id, struct rte_pdump_stats *stats);
265 #endif /* _RTE_PDUMP_H_ */