This is a rework of how packet capture is done in DPDK. The existing mechanism using callbacks has a number of problems; the main one is that any packets sent/received in a secondary process are not visible. The root cause is that callbacks can not function across process boundaries, they are specific to the role.
The new mechanism builds on the concept of port mirroring used in Linux/FreeBSD and also router vendors (SPAN ports). The infrastructure is built around a new ethdev call to mirror a port. The internals of dumpcap are redone but the program command syntax is unchanged (no doc change needed). Usingthe new mirror mechanism, the dumpcap program creates a port using ring PMD and then directs mirror to that. Then the packets are extracted from the ring. If capturing on multiple devices, they all get mirrored to the same ring PMD. Doing this uncovered a bunch of additional missing features and bugs. The first is that test-pmd auto attach introduced in 24.11 breaks this (and it broke old pdump as well) so it is removed. The dumpcap program needs to be able to start the ring PMD it created but the existing ethdev API is broken when used from secondary process. So fix that. The mirror API has a restriction that the port being mirrored to must allow lock free transmit. This is because both rx and tx as well as multiple queues need to go over the same transmit queue. Although it might be possible to have some complex mapping between multiple ports/queues being mirrored to multiple transmit queues, that gets to be a lot of overhead in API's and implementation. Fixing the ring and null PMD to allow lockeless transmit is good enough. Added tests for the new features. The performance has not been measured but the overhead of checking for mirror port is no more that the overhead of looking at the callback list. TODO items: - need release notes for new features - more through testing on real hardware - mark old pdump API and application for deprecation in 25.07 and removal in 25.11 - more cleanup of patch wording and docs needed. Stephen Hemminger (13): app/testpmd: revert auto attach/detach ethdev: allow start/stop from secondary process test: add test for hotplug and secondary process operations net/ring: allow lockfree transmit if ring supports it net/ring: add argument to attach existing ring net/ring: add timestamp devargs net/null: all lockfree transmit mbuf: add fields for mirroring ethdev: add port mirror capability pcapng: split packet copy from header insertion test: add tests for ethdev mirror app/testpmd: support for port mirroring app/dumpcap: use port mirror instead of pdump app/dumpcap/main.c | 361 +++++++++++++++----- app/dumpcap/meson.build | 2 +- app/test-pmd/cmdline.c | 1 + app/test-pmd/cmdline_mirror.c | 120 +++++++ app/test-pmd/cmdline_mirror.h | 12 + app/test-pmd/meson.build | 1 + app/test-pmd/testpmd.c | 77 ++--- app/test/meson.build | 1 + app/test/test_ethdev_mirror.c | 286 ++++++++++++++++ app/test/test_mp_secondary.c | 51 ++- config/rte_config.h | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 + drivers/net/null/rte_eth_null.c | 1 + drivers/net/ring/rte_eth_ring.c | 91 ++++- lib/ethdev/ethdev_driver.c | 11 +- lib/ethdev/ethdev_driver.h | 3 + lib/ethdev/ethdev_private.c | 80 +++++ lib/ethdev/ethdev_private.h | 23 ++ lib/ethdev/ethdev_trace.h | 14 + lib/ethdev/ethdev_trace_points.c | 6 + lib/ethdev/rte_ethdev.c | 275 +++++++++++++-- lib/ethdev/rte_ethdev.h | 81 +++++ lib/ethdev/rte_ethdev_core.h | 6 +- lib/mbuf/rte_mbuf_core.h | 8 + lib/pcapng/rte_pcapng.c | 178 +++++----- lib/pcapng/rte_pcapng.h | 27 +- 26 files changed, 1468 insertions(+), 265 deletions(-) create mode 100644 app/test-pmd/cmdline_mirror.c create mode 100644 app/test-pmd/cmdline_mirror.h create mode 100644 app/test/test_ethdev_mirror.c -- 2.47.2