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 4CE6A5A29 for ; Mon, 7 Sep 2015 11:35:47 +0200 (CEST) Received: from was59-1-82-226-113-214.fbx.proxad.net ([82.226.113.214] helo=[192.168.0.10]) by mail.droids-corp.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1ZYsq8-0001JY-Lh; Mon, 07 Sep 2015 11:35:53 +0200 Message-ID: <55ED5A6A.1000803@6wind.com> Date: Mon, 07 Sep 2015 11:35:38 +0200 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: "Ananyev, Konstantin" , Simon Kagstrom , "dev@dpdk.org" , "Zhang, Helin" , "Gonzalez Monroy, Sergio" , "Burakov, Anatoly" References: <20150831144110.4a7afa27@miho> <55ED3D9A.7070607@6wind.com> <2601191342CEEE43887BDE71AB97725836A83CBA@irsmsx105.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB97725836A83CBA@irsmsx105.ger.corp.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH RFC] mbuf/ip_frag: Move mbuf chaining to common code X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 09:35:47 -0000 Hi, >>> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h >>> index 8c2db1b..ef47256 100644 >>> --- a/lib/librte_mbuf/rte_mbuf.h >>> +++ b/lib/librte_mbuf/rte_mbuf.h >>> @@ -1801,6 +1801,29 @@ static inline int rte_pktmbuf_is_contiguous(const struct rte_mbuf *m) >>> } >>> >>> /** >>> + * Chain an mbuf to another, thereby creating a segmented packet. >>> + * >>> + * @param head the head of the mbuf chain (the first packet) >>> + * @param tail the mbuf to put last in the chain >>> + */ >>> +static inline void rte_pktmbuf_chain(struct rte_mbuf *head, struct rte_mbuf *tail) >>> +{ >>> + struct rte_mbuf *cur_tail; >>> + >> >> Here, we could check if the pkt_len of tail mbuf is 0. If >> it's the case, we can just free it and return. It would avoid >> to have an empty segment inside the mbuf chain, which can be >> annoying. >> >> if (unlikely(rte_pktmbuf_pkt_len(tail) == 0)) { >> rte_pktmbuf_free(tail); >> return; >> } > > Wonder why do we need to do that? > Probably head mbuf is out of space and want to expand it using pktmbuf_chain()? > So in that case seems logical: > 1) allocate new mbuf (it's pkt_len will be 0) > b) call pktmbuf_chain() By experience, having empty segments in the middle of a mbuf chain is problematic (functions getting ptr at offsets, some pmds or hardware may behave badly), I wanted to avoid that risk. Now, the use-case you described is legitimate. Another option would be to have another function pktmbuf_append_new(m) that returns a new mbuf that is already chained to the other. But I'm also fine with removing the test, it's maybe simpler. Regards, Olivier