From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v5 00/13] Packet capture using port mirroring
Date: Fri, 18 Jul 2025 09:28:17 -0700 [thread overview]
Message-ID: <20250718163236.9870-1-stephen@networkplumber.org> (raw)
In-Reply-To: <20250411234927.114568-1-stephen@networkplumber.org>
This is a rework of how packet capture is done in DPDK.
The existing mechanism using callbacks has a number of problems:
- can't work when packets are sent and received in secondary process
because callbacks only function in the primary process
- requires "opt-in" from application
The new mechanism builds on the concept of port mirroring used
in Linux/FreeBSD and also router vendors (SPAN ports).
See: https://en.wikipedia.org/wiki/Port_mirroring for a general description.
The implementation uses two new ethdev API's:
one to add a port mirror, and one to remove it.
The internals of dumpcap are redone but the program command syntax is
unchanged (no doc change needed). Using the new mirror mechanism, the
dumpcap program creates a port using ring PMD and then directs a port
mirror to that new ring PMD instance. Then the packets are extracted
from the ring. If capturing on multiple devices, they all get
mirrored to the same ring PMD.
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.
One of the patches fixes that, it was also reported previously in Bugzilla.
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 lockless
transmit is good enough.
Added tests for the mirror 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 (will wait till 25.11)
- more through testing on real hardware
v5 - fix build warnings when experimental not enabled.
Stephen Hemminger (13):
ethdev: allow start/stop from secondary process
ethdev: make sure all necessary headers included
test: add test for hotplug and secondary process operations
net/ring: allow lockfree transmit if ring supports it
net/ring: add new devarg to create vdev from existing ring
mbuf: add dynamic flag for use by port mirroring
ethdev: add port mirroring feature
pcapng: split packet copy from header insertion
pcapng: make queue optional
test: add tests for ethdev mirror
app/testpmd: support for port mirroring
app/dumpcap: use port mirror instead of pdump
pdump: mark API and application as deprecated
app/dumpcap/main.c | 443 +++++++++++++++---
app/dumpcap/meson.build | 2 +-
app/pdump/main.c | 3 +
app/pdump/meson.build | 1 +
app/test-pmd/cmdline.c | 1 +
app/test-pmd/cmdline_mirror.c | 129 +++++
app/test-pmd/cmdline_mirror.h | 12 +
app/test-pmd/meson.build | 2 +
app/test/meson.build | 7 +-
app/test/test_ethdev_mirror.c | 286 +++++++++++
app/test/test_mp_secondary.c | 51 +-
config/rte_config.h | 1 +
doc/guides/howto/packet_capture_framework.rst | 15 +-
doc/guides/nics/bnxt.rst | 2 +-
doc/guides/prog_guide/ethdev/index.rst | 1 +
doc/guides/prog_guide/pdump_lib.rst | 4 +
doc/guides/rel_notes/deprecation.rst | 3 +
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 +
doc/guides/tools/pdump.rst | 2 +
drivers/net/ring/rte_eth_ring.c | 47 ++
lib/ethdev/ethdev_driver.c | 11 +-
lib/ethdev/ethdev_driver.h | 6 +
lib/ethdev/ethdev_private.c | 142 ++++++
lib/ethdev/ethdev_private.h | 29 ++
lib/ethdev/ethdev_trace.h | 17 +
lib/ethdev/ethdev_trace_points.c | 6 +
lib/ethdev/meson.build | 1 +
lib/ethdev/rte_ethdev.c | 101 ++--
lib/ethdev/rte_ethdev.h | 23 +-
lib/ethdev/rte_ethdev_core.h | 12 +-
lib/ethdev/rte_mirror.c | 359 ++++++++++++++
lib/ethdev/rte_mirror.h | 99 ++++
lib/mbuf/rte_mbuf_dyn.h | 9 +
lib/pcapng/rte_pcapng.c | 179 +++----
lib/pcapng/rte_pcapng.h | 27 +-
lib/pdump/rte_pdump.h | 12 +-
36 files changed, 1843 insertions(+), 217 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
create mode 100644 lib/ethdev/rte_mirror.c
create mode 100644 lib/ethdev/rte_mirror.h
--
2.47.2
next prev parent reply other threads:[~2025-07-18 16:32 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 23:44 [RFC " Stephen Hemminger
2025-04-11 23:44 ` [RFC 01/13] app/testpmd: revert auto attach/detach Stephen Hemminger
2025-04-15 13:28 ` lihuisong (C)
2025-04-16 0:06 ` Stephen Hemminger
2025-04-17 3:14 ` lihuisong (C)
2025-04-11 23:44 ` [RFC 02/13] ethdev: allow start/stop from secondary process Stephen Hemminger
2025-04-15 0:19 ` Stephen Hemminger
2025-04-11 23:44 ` [RFC 03/13] test: add test for hotplug and secondary process operations Stephen Hemminger
2025-04-11 23:44 ` [RFC 04/13] net/ring: allow lockfree transmit if ring supports it Stephen Hemminger
2025-04-11 23:44 ` [RFC 05/13] net/ring: add argument to attach existing ring Stephen Hemminger
2025-04-11 23:44 ` [RFC 06/13] net/ring: add timestamp devargs Stephen Hemminger
2025-04-11 23:44 ` [RFC 07/13] net/null: all lockfree transmit Stephen Hemminger
2025-04-11 23:44 ` [RFC 08/13] mbuf: add fields for mirroring Stephen Hemminger
2025-04-12 9:59 ` Morten Brørup
2025-04-12 16:56 ` Stephen Hemminger
2025-04-13 7:00 ` Morten Brørup
2025-04-13 14:31 ` Stephen Hemminger
2025-04-13 14:44 ` Morten Brørup
2025-04-11 23:44 ` [RFC 09/13] ethdev: add port mirror capability Stephen Hemminger
2025-04-11 23:44 ` [RFC 10/13] pcapng: split packet copy from header insertion Stephen Hemminger
2025-04-11 23:44 ` [RFC 11/13] test: add tests for ethdev mirror Stephen Hemminger
2025-04-11 23:44 ` [RFC 12/13] app/testpmd: support for port mirroring Stephen Hemminger
2025-04-11 23:44 ` [RFC 13/13] app/dumpcap: use port mirror instead of pdump Stephen Hemminger
2025-04-12 11:06 ` [RFC 00/13] Packet capture using port mirroring Morten Brørup
2025-04-12 17:04 ` Stephen Hemminger
2025-04-13 9:26 ` Morten Brørup
2025-07-15 16:15 ` [PATCH v4 " Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 01/13] ethdev: allow start/stop from secondary process Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 02/13] ethdev: make sure all necessary headers included Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 03/13] test: add test for hotplug and secondary process operations Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 04/13] net/ring: allow lockfree transmit if ring supports it Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 05/13] net/ring: add new devarg to create vdev from existing ring Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 06/13] mbuf: add dynamic flag for use by port mirroring Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 07/13] ethdev: add port mirroring feature Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 08/13] pcapng: split packet copy from header insertion Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 09/13] pcapng: make queue optional Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 10/13] test: add tests for ethdev mirror Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 11/13] app/testpmd: support for port mirroring Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 12/13] app/dumpcap: use port mirror instead of pdump Stephen Hemminger
2025-07-15 16:15 ` [PATCH v4 13/13] pdump: mark API and application as deprecated Stephen Hemminger
2025-07-18 16:28 ` Stephen Hemminger [this message]
2025-07-18 16:28 ` [PATCH v5 01/13] ethdev: allow start/stop from secondary process Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 02/13] ethdev: make sure all necessary headers included Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 03/13] test: add test for hotplug and secondary process operations Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 04/13] net/ring: allow lockfree transmit if ring supports it Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 05/13] net/ring: add new devarg to create vdev from existing ring Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 06/13] mbuf: add dynamic flag for use by port mirroring Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 07/13] ethdev: add port mirroring feature Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 08/13] pcapng: split packet copy from header insertion Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 09/13] pcapng: make queue optional Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 10/13] test: add tests for ethdev mirror Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 11/13] app/testpmd: support for port mirroring Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 12/13] app/dumpcap: use port mirror instead of pdump Stephen Hemminger
2025-07-18 16:28 ` [PATCH v5 13/13] pdump: mark API and application as deprecated Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250718163236.9870-1-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).