From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id F155119F5 for ; Thu, 8 Jan 2015 15:41:35 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 08 Jan 2015 06:38:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,691,1406617200"; d="scan'208";a="509323146" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by orsmga003.jf.intel.com with ESMTP; 08 Jan 2015 06:35:46 -0800 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.244]) by IRSMSX110.ger.corp.intel.com ([169.254.15.55]) with mapi id 14.03.0195.001; Thu, 8 Jan 2015 14:41:32 +0000 From: "Pattan, Reshma" To: Neil Horman Thread-Topic: [dpdk-dev] [PATCH 1/3] librte_reorder: New reorder library Thread-Index: AQHQKpiDjILGhYpI3kagulLGqv9iMZy07iqAgAFV6yA= Date: Thu, 8 Jan 2015 14:41:32 +0000 Message-ID: <3AEA2BF9852C6F48A459DA490692831FE50886@IRSMSX109.ger.corp.intel.com> References: <1420648753-17136-1-git-send-email-reshma.pattan@intel.com> <20150107174509.GC16558@hmsreliant.think-freely.org> In-Reply-To: <20150107174509.GC16558@hmsreliant.think-freely.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 1/3] librte_reorder: New reorder library 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: Thu, 08 Jan 2015 14:41:36 -0000 > -----Original Message----- > From: Neil Horman [mailto:nhorman@tuxdriver.com] > Sent: Wednesday, January 7, 2015 5:45 PM > To: Pattan, Reshma > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH 1/3] librte_reorder: New reorder library >=20 > On Wed, Jan 07, 2015 at 04:39:11PM +0000, Reshma Pattan wrote: > > From: Reshma Pattan > > > > 1)New library to provide reordering of out of ordered > > mbufs based on sequence number of mbuf. Library uses reorde= r buffer > structure > > which in tern uses two circular buffers called ready and or= der buffers. > > *rte_reorder_create API creates instance of reorder buffer. > > *rte_reorder_init API initializes given reorder buffer inst= ance. > > *rte_reorder_reset API resets given reorder buffer instance= . > > *rte_reorder_insert API inserts the mbuf into order circula= r buffer. > > *rte_reorder_fill_overflow moves mbufs from order buffer to= ready > buffer > > to accomodate early packets in order buffer. > > *rte_reorder_drain API provides draining facility to fetch = out > > reordered mbufs from order and ready buffers. > > > > Signed-off-by: Reshma Pattan > > Signed-off-by: Richardson Bruce > > --- > > config/common_bsdapp | 5 + > > config/common_linuxapp | 5 + > > lib/Makefile | 1 + > > lib/librte_eal/common/include/rte_tailq_elem.h | 2 + > > lib/librte_mbuf/rte_mbuf.h | 3 + > > lib/librte_reorder/Makefile | 50 +++ > > lib/librte_reorder/rte_reorder.c | 464 +++++++++++++++++= ++++++++ > > lib/librte_reorder/rte_reorder.h | 184 ++++++++++ > > 8 files changed, 714 insertions(+) > > create mode 100644 lib/librte_reorder/Makefile create mode 100644 > > lib/librte_reorder/rte_reorder.c create mode 100644 > > lib/librte_reorder/rte_reorder.h > > + > > +int > > +rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf > > +*mbuf) { > > + uint32_t offset, position; > > + struct cir_buffer *order_buf =3D &b->order_buf; > > + > > + /* > > + * calculate the offset from the head pointer we need to go. > > + * The subtraction takes care of the sequence number wrapping. > > + * For example (using 16-bit for brevity): > > + * min_seqn =3D 0xFFFD > > + * mbuf_seqn =3D 0x0010 > > + * offset =3D 0x0010 - 0xFFFD =3D 0x13 > > + */ > > + offset =3D mbuf->seqn - b->min_seqn; > > + > > + /* > > + * action to take depends on offset. > > + * offset < buffer->size: the mbuf fits within the current window of > > + * sequence numbers we can reorder. EXPECTED CASE. > > + * offset > buffer->size: the mbuf is outside the current window. The= re > > + * are a number of cases to consider: > > + * 1. The packet sequence is just outside the window, then we need > > + * to see about shifting the head pointer and taking any ready > > + * to return packets out of the ring. If there was a delayed > > + * or dropped packet preventing drains from shifting the window > > + * this case will skip over the dropped packet instead, and any > > + * packets dequeued here will be returned on the next drain cal= l. > > + * 2. The packet sequence number is vastly outside our window, tak= en > > + * here as having offset greater than twice the buffer size. In > > + * this case, the packet is probably an old or late packet that > > + * was previously skipped, so just enqueue the packet for > > + * immediate return on the next drain call, or else return erro= r. > > + */ > > + if (offset < b->order_buf.size) { > > + position =3D (order_buf->head + offset) & order_buf->mask; > > + order_buf->entries[position] =3D mbuf; > > + } else if (offset < 2 * b->order_buf.size) { > > + if (rte_reorder_fill_overflow(b, offset - order_buf->size) < > > + offset - order_buf->size) { > > + /* Put in handling for enqueue straight to output */ > > + rte_errno =3D ENOSPC; > > + return -1; > > + } > > + offset =3D mbuf->seqn - b->min_seqn; > > + position =3D (order_buf->head + offset) & order_buf->mask; > > + order_buf->entries[position] =3D mbuf; > > + } else { > > + /* Put in handling for enqueue straight to output */ > > + rte_errno =3D ERANGE; > > + return -1; > > + } > How does this work if you get two packets with the same sequence number? > That situation seems like it would happen frequently with your example ap= p, and > from my read of the above, you just wind up overwriting the same pointer = in > ther entries array here, which leads to silent packet loss. Hi Neil, Sequence numbers are assigned globally by a single core , and not per port.= So it is impossible to get the packets with same sequence number. Getting packets with same sequence number should happen only when sequence= number wraps around in same window of earlier same sequence number packet = and which is not drained, but this is unlikely as there will be sufficient= wrap around times . Thanks, Reshma