From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 0E5F75947 for ; Thu, 12 Feb 2015 05:04:13 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 11 Feb 2015 19:57:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,562,1418112000"; d="scan'208";a="453488860" Received: from pgsmsx106.gar.corp.intel.com ([10.221.44.98]) by FMSMGA003.fm.intel.com with ESMTP; 11 Feb 2015 19:49:30 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by PGSMSX106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 12 Feb 2015 12:04:07 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.62]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.209]) with mapi id 14.03.0195.001; Thu, 12 Feb 2015 12:04:07 +0800 From: "Chen, Jing D" To: "Shaw, Jeffrey B" Thread-Topic: [PATCH v4 10/15] fm10k: add receive and tranmit function Thread-Index: AQHQRZqcOcOdZYJmJk2l1cK3Q6oUFZzrLxCAgAE3fAA= Date: Thu, 12 Feb 2015 04:04:06 +0000 Message-ID: <4341B239C0EFF9468EE453F9E9F4604D01675C19@shsmsx102.ccr.corp.intel.com> References: <1423551775-3604-2-git-send-email-jing.d.chen@intel.com> <1423618298-2933-1-git-send-email-jing.d.chen@intel.com> <1423618298-2933-11-git-send-email-jing.d.chen@intel.com> <20150211172847.GA2984@plxv1143.pdx.intel.com> In-Reply-To: <20150211172847.GA2984@plxv1143.pdx.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] 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 v4 10/15] fm10k: add receive and tranmit function 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, 12 Feb 2015 04:04:14 -0000 > -----Original Message----- > From: Shaw, Jeffrey B > Sent: Thursday, February 12, 2015 1:29 AM > To: Chen, Jing D > Cc: dev@dpdk.org; Zhang, Helin; Qiu, Michael; nhorman@tuxdriver.com; > thomas.monjalon@6wind.com; david.marchand@6wind.com > Subject: Re: [PATCH v4 10/15] fm10k: add receive and tranmit function >=20 > On Wed, Feb 11, 2015 at 09:31:33AM +0800, Chen Jing D(Mark) wrote: >=20 > > +uint16_t > > +fm10k_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, > > + uint16_t nb_pkts) > > +{ > > + struct rte_mbuf *mbuf; > > + union fm10k_rx_desc desc; > > + struct fm10k_rx_queue *q =3D rx_queue; > > + uint16_t count =3D 0; > > + int alloc =3D 0; > > + uint16_t next_dd; > > + > > + next_dd =3D q->next_dd; > > + > > + nb_pkts =3D RTE_MIN(nb_pkts, q->alloc_thresh); > > + for (count =3D 0; count < nb_pkts; ++count) { > > + mbuf =3D q->sw_ring[next_dd]; > > + desc =3D q->hw_ring[next_dd]; > > + if (!(desc.d.staterr & FM10K_RXD_STATUS_DD)) > > + break; > > +#ifdef RTE_LIBRTE_FM10K_DEBUG_RX > > + dump_rxd(&desc); > > +#endif > > + rte_pktmbuf_pkt_len(mbuf) =3D desc.w.length; > > + rte_pktmbuf_data_len(mbuf) =3D desc.w.length; > > + > > + mbuf->ol_flags =3D 0; > > +#ifdef RTE_LIBRTE_FM10K_RX_OLFLAGS_ENABLE > > + rx_desc_to_ol_flags(mbuf, &desc); > > +#endif > > + > > + mbuf->hash.rss =3D desc.d.rss; > > + > > + rx_pkts[count] =3D mbuf; > > + if (++next_dd =3D=3D q->nb_desc) { > > + next_dd =3D 0; > > + alloc =3D 1; > > + } > > + > > + /* Prefetch next mbuf while processing current one. */ > > + rte_prefetch0(q->sw_ring[next_dd]); > > + > > + /* > > + * When next RX descriptor is on a cache-line boundary, > > + * prefetch the next 4 RX descriptors and the next 8 pointers > > + * to mbufs. > > + */ > > + if ((next_dd & 0x3) =3D=3D 0) { > > + rte_prefetch0(&q->hw_ring[next_dd]); > > + rte_prefetch0(&q->sw_ring[next_dd]); > > + } > > + } > > + > > + q->next_dd =3D next_dd; > > + > > + if ((q->next_dd > q->next_trigger) || (alloc =3D=3D 1)) { > > + rte_mempool_get_bulk(q->mp, (void **)&q->sw_ring[q- > >next_alloc], > > + q->alloc_thresh); >=20 > The return value should be checked here in case the mempool runs out > of buffers. Thanks Helin for spotting this. I'm not sure how I missed it > originally. Thanks! I'll change accordingly. >=20 > > + for (; q->next_alloc <=3D q->next_trigger; ++q->next_alloc) { > > + mbuf =3D q->sw_ring[q->next_alloc]; > > + > > + /* setup static mbuf fields */ > > + fm10k_pktmbuf_reset(mbuf, q->port_id); > > + > > + /* write descriptor */ > > + desc.q.pkt_addr =3D > MBUF_DMA_ADDR_DEFAULT(mbuf); > > + desc.q.hdr_addr =3D > MBUF_DMA_ADDR_DEFAULT(mbuf); > > + q->hw_ring[q->next_alloc] =3D desc; > > + } > > + FM10K_PCI_REG_WRITE(q->tail_ptr, q->next_trigger); > > + q->next_trigger +=3D q->alloc_thresh; > > + if (q->next_trigger >=3D q->nb_desc) { > > + q->next_trigger =3D q->alloc_thresh - 1; > > + q->next_alloc =3D 0; > > + } > > + } > > + > > + return count; > > +} > > + >=20 > Thanks, > Jeff