From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 68967A04F2;
	Mon, 30 Dec 2019 09:11:58 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 37B2A1C0C5;
	Mon, 30 Dec 2019 09:11:57 +0100 (CET)
Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com
 [209.85.128.67]) by dpdk.org (Postfix) with ESMTP id 73D4E1C031
 for <dev@dpdk.org>; Mon, 30 Dec 2019 09:11:55 +0100 (CET)
Received: by mail-wm1-f67.google.com with SMTP id p17so13537499wma.1
 for <dev@dpdk.org>; Mon, 30 Dec 2019 00:11:55 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google;
 h=date:from:to:cc:subject:message-id:references:mime-version
 :content-disposition:in-reply-to:user-agent;
 bh=j2A7UWWGUUu1OeRyGOwWET6dlarACu0WIHIpNI5iQ5c=;
 b=Cd/kgpLc5Nvm2oPnykWdInm4N5hRrPXfUABTuiZp/kk8y4bKzYId8ZFqx5xOUAYFZy
 iYKkAWOFLnFUj5YZItXvbzHHyhvBXRMN/Vsfk2/skScUDZZaYi8PP/kL6o6NeBRKyj/u
 DUCtve8ZuggjxiXxFD2Hst21EGxaTk+5hHMoYlWa/5DZP1b6gBgKt29tiGCHyYXM2MlR
 GLoiHsSbeO8qVCcK2T+fnDc3kDPrkaUbmi3iw8i7YgMbWFtIDpNc1RMo4BNcWttb9WYf
 CMR9LUruHB6TzGJTqQc4CjZBaG2kKjI5vHphSRxkTG5P07uZJ37xWm1uV19hExJ1ILgA
 pKjA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:references
 :mime-version:content-disposition:in-reply-to:user-agent;
 bh=j2A7UWWGUUu1OeRyGOwWET6dlarACu0WIHIpNI5iQ5c=;
 b=b6ToYAnHj53pUPLuVLpPEQFNOWTck6C37kGnkECR3AKNQjhS30wO2l5+mBcO1bJQQf
 Ashxp1XdA6xupHFzcjOW1GI09yV6aUTbDTrhdzkNRJJSlOXUianzO1OT/ZkhgKc+usMG
 Cka1IE0UZXH7h5F4omy7FahFNHSJa9XqNInEdRJg2NG2WIJ5e95gCAyVPu0wGqvSvQea
 SNiprWFLCQbXgNGyp+A4P+0NTxhFAx9v/ZvB1lqS9Hie8/3FnTKo6EFDGhye9zGi4OEO
 yzRm2DdPp6pB/Fe2EAxue6cxcK6uGJZk7NgTdiUGiUEkzxMTmz8pD53QDRPjqvihoX7D
 hVKA==
X-Gm-Message-State: APjAAAWo39nurrknJZotBAOzsWQ0XJEvDybEi8ANpPtvC/aggtmiZT99
 6cypIxs3YFRvEAWTarBHTNO89JGQ8ow=
X-Google-Smtp-Source: APXvYqy9YqA9TkCbKuHxtaoza7lmOD6rsN1/AWZ+YGcd2XYeUq80gai2E42QH+CxOyOOEjUtQd4t+A==
X-Received: by 2002:a7b:c949:: with SMTP id i9mr8441620wml.131.1577693515066; 
 Mon, 30 Dec 2019 00:11:55 -0800 (PST)
Received: from 6wind.com (2a01cb0c0005a600345636f7e65ed1a0.ipv6.abo.wanadoo.fr.
 [2a01:cb0c:5:a600:3456:36f7:e65e:d1a0])
 by smtp.gmail.com with ESMTPSA id s15sm45743543wrp.4.2019.12.30.00.11.54
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 30 Dec 2019 00:11:54 -0800 (PST)
Date: Mon, 30 Dec 2019 09:11:53 +0100
From: Olivier Matz <olivier.matz@6wind.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org
Message-ID: <20191230081153.GT22738@platinum>
References: <20191120174125.23704-1-stephen@networkplumber.org>
 <20191121183055.8096-1-stephen@networkplumber.org>
 <20191226161539.GI22738@platinum>
 <20191226085851.7f47ed81@hermes.lan>
 <20191227091018.GN22738@platinum>
 <20191227090507.0fd48cd6@hermes.lan>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20191227090507.0fd48cd6@hermes.lan>
User-Agent: Mutt/1.10.1 (2018-07-13)
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: display more fields in dump
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

On Fri, Dec 27, 2019 at 09:05:07AM -0800, Stephen Hemminger wrote:
> On Fri, 27 Dec 2019 10:10:18 +0100
> Olivier Matz <olivier.matz@6wind.com> wrote:
> 
> > Hi,
> > 
> > On Thu, Dec 26, 2019 at 08:58:51AM -0800, Stephen Hemminger wrote:
> > > On Thu, 26 Dec 2019 17:15:39 +0100
> > > Olivier Matz <olivier.matz@6wind.com> wrote:
> > >   
> > > > Hi,
> > > > 
> > > > On Thu, Nov 21, 2019 at 10:30:55AM -0800, Stephen Hemminger wrote:  
> > > > > The rte_pktmbuf_dump should display offset, refcount, and vlan
> > > > > info since these are often useful during debugging.
> > > > > 
> > > > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > > > > ---
> > > > > v2 - remove casts, change in_port to port
> > > > >      the refcount and offset are property of per-segment
> > > > > 
> > > > >  lib/librte_mbuf/rte_mbuf.c | 17 ++++++++++-------
> > > > >  1 file changed, 10 insertions(+), 7 deletions(-)
> > > > > 
> > > > > diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> > > > > index 35df1c4c38a5..4894d46628e3 100644
> > > > > --- a/lib/librte_mbuf/rte_mbuf.c
> > > > > +++ b/lib/librte_mbuf/rte_mbuf.c
> > > > > @@ -473,18 +473,21 @@ 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, (uint64_t)m->buf_iova, (unsigned)m->buf_len);
> > > > > -	fprintf(f, "  pkt_len=%"PRIu32", ol_flags=%"PRIx64", nb_segs=%u, "
> > > > > -	       "in_port=%u\n", m->pkt_len, m->ol_flags,
> > > > > -	       (unsigned)m->nb_segs, (unsigned)m->port);
> > > > > +	fprintf(f, "dump mbuf at %p, iova=%#"PRIx64", buf_len=%u\n",
> > > > > +		m, m->buf_iova, m->buf_len);
> > > > > +	fprintf(f,
> > > > > +		"  pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u, port=%u, vlan_tci=%#x\n",
> > > > > +		m->pkt_len, m->ol_flags, m->nb_segs, m->port, m->vlan_tci);
> > > > > +
> > > > >  	nb_segs = m->nb_segs;
> > > > >  
> > > > >  	while (m && nb_segs != 0) {
> > > > >  		__rte_mbuf_sanity_check(m, 0);
> > > > >  
> > > > > -		fprintf(f, "  segment at %p, data=%p, data_len=%u\n",
> > > > > -			m, rte_pktmbuf_mtod(m, void *), (unsigned)m->data_len);
> > > > > +		fprintf(f, "  segment at %p, data=%p, len=%u, off=%u, refcnt=%u\n",
> > > > > +			m, rte_pktmbuf_mtod(m, void *),
> > > > > +			m->data_len, m->data_off, rte_mbuf_refcnt_read(m));
> > > > > +
> > > > >  		len = dump_len;
> > > > >  		if (len > m->data_len)
> > > > >  			len = m->data_len;
> > > > > -- 
> > > > > 2.20.1
> > > > >     
> > > > 
> > > > Thanks for this enhancement.
> > > > 
> > > > One comment however: I don't see why vlan_tci would be important than
> > > > packet type or rss tag. It is also a bit confusing to display a field
> > > > which can have a random value (if the vlan flag is not set in ol_flags).
> > > > 
> > > > I'd prefer to dump vlan_tci only if the flag is present. Later we could
> > > > add more fields with the same logic. What do you think?  
> > > 
> > > Because this is a debugging hook and easier to always display the value.
> > > Thats all.  
> > 
> > This is precisely because it is a debug hook that I find dangerous to
> > display a wrong value. As the mbuf are recycled, a mbuf that does not
> > have a vlan_tci can display its previous value, which may look valid.
> > 
> > What about simply doing this?
> > 
> > 	fprintf(f,
> > 		"  pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u, port=%u",
> > 		m->pkt_len, m->ol_flags, m->nb_segs, m->port);
> > 	if (m->ol_flags & PKT_RX_VLAN)
> > 		fprintf(f, ", vlan_tci=%#x", m->vlan_tci);
> > 	fprintf(f, "\n");
> > 
> > If you want I can submit an updated version of your patch
> 
> The right flags are more complex, you need to deal with TX vlan.
> And PKT_RX_VLAN means "this is a vlan packet" it doesn't mean
> vlan tag is stripped into TCI.  That is PKT_RX_VLAN_STRIPPED

PKT_RX_VLAN means that m->vlan_tci is valid, and this is what we
want here.