From: "Morten Brørup" <mb@smartsharesystems.com>
To: "David Marchand" <david.marchand@redhat.com>, <dev@dpdk.org>
Subject: RE: [PATCH v2] mbuf: dump Tx offload metadata
Date: Tue, 4 Nov 2025 19:45:16 +0100 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35F6552E@smartserver.smartshare.dk> (raw)
In-Reply-To: <CAJFAV8zEM4Ohdk+wg1Ryz4n1VC2KC3nCkRBX7iRMakY3scfqEg@mail.gmail.com>
> From: David Marchand [mailto:david.marchand@redhat.com]
> Sent: Tuesday, 4 November 2025 14.59
>
> On Tue, 4 Nov 2025 at 11:02, David Marchand <david.marchand@redhat.com>
> wrote:
> >
> > When debugging TSO and other checksum offloads, dumping the various
> > l*_len fields and TSO segmentation size can be helpful.
> >
> > Example in OVS that dumps a mbuf on rte_eth_tx_prepare failure:
> >
> > Before:
> > netdev_dpdk(pmd-c30/id:11)|DBG|dpdk0: First invalid packet:
> > dump mbuf at 0x2201a916c0, iova=0x2200800580, buf_len=6864
> > pkt_len=6804, ol_flags=0x3114800000000102, nb_segs=1, port=65535,
> ptype=0
> > segment at 0x2201a916c0, data=0x22008005b2, len=6804, off=50,
> refcnt=1
> > Dump data at [0x22008005b2], len=6804
> > ...
> >
> > After:
> > netdev_dpdk(pmd-c30/id:11)|DBG|dpdk0: First invalid packet:
> > dump mbuf at 0x2201a916c0, iova=0x2200800580, buf_len=6864,
> pkt_len=6804
> > outer_l2_len=14, outer_l3_len=40, l2_len=38, l3_len=40, l4_len=32
> > ol_flags=0x3114800000000102, nb_segs=1, port=65535, ptype=0
> > segment at 0x2201a916c0, data=0x22008005b2, len=6804, off=50,
> refcnt=1
> > Dump data at [0x22008005b2], len=6804
> > ...
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> > lib/mbuf/rte_mbuf.c | 41 +++++++++++++++++++++++++++++++++++++----
> > 1 file changed, 37 insertions(+), 4 deletions(-)
> >
> > diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
> > index 0d931c7a15..12710a59df 100644
> > --- a/lib/mbuf/rte_mbuf.c
> > +++ b/lib/mbuf/rte_mbuf.c
> > @@ -750,10 +750,43 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf
> *m, unsigned dump_len)
> >
> > __rte_mbuf_sanity_check(m, 1);
> >
> > - fprintf(f, "dump mbuf at %p, iova=%#" PRIx64 ",
> buf_len=%u\n", m, rte_mbuf_iova_get(m),
> > - m->buf_len);
> > - fprintf(f, " pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u,
> port=%u",
> > - m->pkt_len, m->ol_flags, m->nb_segs, m->port);
> > + fprintf(f, "dump mbuf at %p, iova=%#" PRIx64 ", buf_len=%u,
> pkt_len=%u\n",
> > + m, rte_mbuf_iova_get(m), m->buf_len, m->pkt_len);
> > + if (m->ol_flags & RTE_MBUF_F_TX_OFFLOAD_MASK) {
> > + const char *sep = "";
> > +
> > + fprintf(f, " ");
> > + if (m->outer_l2_len != 0) {
> > + fprintf(f, "%souter_l2_len=%u", sep, m-
> >outer_l2_len);
>
> One more round will be needed for MSVC (CI did not report it on v1,
> some tests did not run..).
> ../lib/mbuf/rte_mbuf.c(760): error C2220: the following warning is
> treated as an error
> ../lib/mbuf/rte_mbuf.c(760): warning C4477: 'fprintf' : format string
> '%u' requires an argument of type 'unsigned int', but variadic
> argument 2 has type 'const uint64_t'
> ../lib/mbuf/rte_mbuf.c(760): note: consider using '%llu' in the format
> string
> ../lib/mbuf/rte_mbuf.c(760): note: consider using '%Iu' in the format
> string
> ../lib/mbuf/rte_mbuf.c(760): note: consider using '%I64u' in the format
> string
>
> This is probably because of the bitfields we have for the tx_offload
> field.
> lib/mbuf/rte_mbuf_core.h: RTE_MBUF_L2_LEN_BITS = 7,
> lib/mbuf/rte_mbuf_core.h: RTE_MBUF_L3_LEN_BITS = 9,
> lib/mbuf/rte_mbuf_core.h: RTE_MBUF_L4_LEN_BITS = 8,
> lib/mbuf/rte_mbuf_core.h: RTE_MBUF_OUTL3_LEN_BITS = 9,
> lib/mbuf/rte_mbuf_core.h: RTE_MBUF_OUTL2_LEN_BITS = 7,
> lib/mbuf/rte_mbuf_core.h: uint64_t
> l2_len:RTE_MBUF_L2_LEN_BITS;
> lib/mbuf/rte_mbuf_core.h: uint64_t
> l3_len:RTE_MBUF_L3_LEN_BITS;
> lib/mbuf/rte_mbuf_core.h: uint64_t
> l4_len:RTE_MBUF_L4_LEN_BITS;
> lib/mbuf/rte_mbuf_core.h: uint64_t
> outer_l3_len:RTE_MBUF_OUTL3_LEN_BITS;
> lib/mbuf/rte_mbuf_core.h: uint64_t
> outer_l2_len:RTE_MBUF_OUTL2_LEN_BITS;
>
>
> Passing %PRIu64 instead of %u breaks build with gcc and clang.
> ../lib/mbuf/rte_mbuf.c: In function ‘rte_pktmbuf_dump’:
> ../lib/mbuf/rte_mbuf.c:760:36: error: format ‘%lu’ expects argument of
> type ‘long unsigned int’, but argument 4 has type ‘int’
> [-Werror=format=]
> 760 | fprintf(f, "%souter_l2_len=%"PRIu64, sep, m->outer_l2_len);
> | ^~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
> | |
> | int
>
Interesting difference in interpretation between the compilers.
>
> I'll go with simple casting, like:
> + fprintf(f, "%souter_l2_len=%u", sep, (unsigned
> int)m->outer_l2_len);
Agree.
>
>
> --
> David Marchand
prev parent reply other threads:[~2025-11-04 18:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-31 13:11 [PATCH] " David Marchand
2025-10-31 13:28 ` Morten Brørup
2025-10-31 14:07 ` David Marchand
2025-10-31 14:29 ` Morten Brørup
2025-11-04 7:43 ` David Marchand
2025-11-04 10:02 ` [PATCH v2] " David Marchand
2025-11-04 11:45 ` Morten Brørup
2025-11-04 13:58 ` David Marchand
2025-11-04 18:45 ` Morten Brørup [this message]
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=98CBD80474FA8B44BF855DF32C47DC35F6552E@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=david.marchand@redhat.com \
--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).