From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 2D7932C3F for ; Fri, 1 Dec 2017 17:37:46 +0100 (CET) Received: from lfbn-1-6068-189.w90-110.abo.wanadoo.fr ([90.110.3.189] helo=droids-corp.org) by mail.droids-corp.org with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1eKoPt-0001L6-QA; Fri, 01 Dec 2017 17:43:59 +0100 Received: by droids-corp.org (sSMTP sendmail emulation); Fri, 01 Dec 2017 17:37:38 +0100 Date: Fri, 1 Dec 2017 17:37:38 +0100 From: Olivier MATZ To: Ilya Matveychikov Cc: Stephen Hemminger , dev@dpdk.org Message-ID: <20171201163737.egt5zbjate2sqhkm@platinum> References: <20171116090155.31419fe3@xeon-e3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH 2/2] mbuf: reset nb_segs of chained packet X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Dec 2017 16:37:46 -0000 Hi Ilya, On Thu, Nov 16, 2017 at 11:15:18PM +0400, Ilya Matveychikov wrote: > > > On Nov 16, 2017, at 9:01 PM, Stephen Hemminger wrote: > > > > On Thu, 16 Nov 2017 18:05:35 +0400 > > Ilya Matveychikov wrote: > > > >> Fixes: 139debc42dc0 ("mbuf: move chaining from ip_frag library") > >> Cc: simon.kagstrom@netinsight.net > >> > >> Signed-off-by: Ilya V. Matveychikov > >> --- > >> lib/librte_mbuf/rte_mbuf.h | 5 ++++- > >> 1 file changed, 4 insertions(+), 1 deletion(-) > >> > >> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > >> index ce8a05ddf..2126dc94b 100644 > >> --- a/lib/librte_mbuf/rte_mbuf.h > >> +++ b/lib/librte_mbuf/rte_mbuf.h > >> @@ -1828,9 +1828,12 @@ static inline int rte_pktmbuf_chain(struct rte_mbuf *head, struct rte_mbuf *tail > >> head->nb_segs += tail->nb_segs; > >> head->pkt_len += tail->pkt_len; > >> > >> - /* pkt_len is only set in the head */ > >> + /* nb_segs and pkt_len are only set in the head */ > >> + tail->nb_segs = 1; > >> tail->pkt_len = tail->data_len; > >> > >> + __rte_mbuf_sanity_check(head, 1); > >> + > >> return 0; > >> } > > > > My understanding is that nb_segs and pkt_len are only valid > > in head. For other packets in the chain nb_segs and pkt_len > > can be anything. > > So why not to keep them in consistency with multi-seg logic? > I mean that pkt_len/nb_segs for the head always have meaning but for > the rest of chain pkt_len is the same as data_len and nb_segs := 1 > Stephen is right: like most mbuf fields, nb_segs and pkt_len are only valid for the first mbuf of the chain. What would be the advantage of changing this? In addition, I think it would require to do the same change that in many places, like drivers that build multi-seg mbufs. If you are fixing an issue, please describe it in the commit log. Olivier