From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id A25457E62 for ; Fri, 24 Oct 2014 12:37:40 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 24 Oct 2014 03:46:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,779,1406617200"; d="scan'208";a="619746869" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by fmsmga002.fm.intel.com with ESMTP; 24 Oct 2014 03:46:07 -0700 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.56]) by IRSMSX104.ger.corp.intel.com ([169.254.5.58]) with mapi id 14.03.0195.001; Fri, 24 Oct 2014 11:46:07 +0100 From: "Ananyev, Konstantin" To: "Ouyang, Changchun" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 2/3] pmd: RX function need keep EXTERNAL_MBUF flag Thread-Index: AQHP72II3cEQXzazwEuf9kL3IfWzwJw/Dd9A Date: Fri, 24 Oct 2014 10:46:06 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772582139EBAF@IRSMSX105.ger.corp.intel.com> References: <1414138209-24431-1-git-send-email-changchun.ouyang@intel.com> <1414138209-24431-3-git-send-email-changchun.ouyang@intel.com> In-Reply-To: <1414138209-24431-3-git-send-email-changchun.ouyang@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 2/3] pmd: RX function need keep EXTERNAL_MBUF flag 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: Fri, 24 Oct 2014 10:37:41 -0000 Hi Changchun, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ouyang Changchun > Sent: Friday, October 24, 2014 9:10 AM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH 2/3] pmd: RX function need keep EXTERNAL_MBUF = flag >=20 > Every pmd RX function need keep the EXTERNAL_MBUF flag > in mbuf.ol_flags, and can't overwrite it when filling ol_flags from > descriptor to mbuf, otherwise, it probably cause to crash when freeing a = mbuf > and trying to freeing its attached external buffer, say, from guest space= . >=20 Don't really like the idea to put: mb->ol_flags =3D pkt_flags | (mb->ol_flags & EXTERNAL_MBUF);=20 in each and every PMD from now on... >>From other side, it is probably not very good that RX functions update whol= e ol_flags, not only RX related part. Wonder can we reserve low 32bits of ol_flags for RX, and high 32bits for TX= and generic stuff. So our ol_flags will look something like that: union { uint64_t ol_raw_flags; struct { uint32_t rx; uint32_t gen_tx; } ol_flags }; And make all PMD RX functions to operate on rx part of the flags only: mb->ol_flags.rx =3D pkt_flags; ? Konstantin > Signed-off-by: Changchun Ouyang > --- > lib/librte_pmd_e1000/igb_rxtx.c | 5 +++-- > lib/librte_pmd_i40e/i40e_rxtx.c | 8 +++++--- > lib/librte_pmd_ixgbe/ixgbe_rxtx.c | 8 +++++--- > lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c | 12 ++++++++---- > 4 files changed, 21 insertions(+), 12 deletions(-) >=20 > diff --git a/lib/librte_pmd_e1000/igb_rxtx.c b/lib/librte_pmd_e1000/igb_r= xtx.c > index f09c525..4123310 100644 > --- a/lib/librte_pmd_e1000/igb_rxtx.c > +++ b/lib/librte_pmd_e1000/igb_rxtx.c > @@ -786,7 +786,7 @@ eth_igb_recv_pkts(void *rx_queue, struct rte_mbuf **r= x_pkts, > pkt_flags =3D rx_desc_hlen_type_rss_to_pkt_flags(hlen_type_rss); > pkt_flags =3D pkt_flags | rx_desc_status_to_pkt_flags(staterr); > pkt_flags =3D pkt_flags | rx_desc_error_to_pkt_flags(staterr); > - rxm->ol_flags =3D pkt_flags; > + rxm->ol_flags =3D pkt_flags | (rxm->ol_flags & EXTERNAL_MBUF); >=20 > /* > * Store the mbuf address into the next entry of the array > @@ -1020,7 +1020,8 @@ eth_igb_recv_scattered_pkts(void *rx_queue, struct = rte_mbuf **rx_pkts, > pkt_flags =3D rx_desc_hlen_type_rss_to_pkt_flags(hlen_type_rss); > pkt_flags =3D pkt_flags | rx_desc_status_to_pkt_flags(staterr); > pkt_flags =3D pkt_flags | rx_desc_error_to_pkt_flags(staterr); > - first_seg->ol_flags =3D pkt_flags; > + first_seg->ol_flags =3D pkt_flags | > + (first_seg->ol_flags & EXTERNAL_MBUF); >=20 > /* Prefetch data of first segment, if configured to do so. */ > rte_packet_prefetch((char *)first_seg->buf_addr + > diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_r= xtx.c > index 2b53677..68c3695 100644 > --- a/lib/librte_pmd_i40e/i40e_rxtx.c > +++ b/lib/librte_pmd_i40e/i40e_rxtx.c > @@ -637,7 +637,8 @@ i40e_rx_scan_hw_ring(struct i40e_rx_queue *rxq) > pkt_flags =3D i40e_rxd_status_to_pkt_flags(qword1); > pkt_flags |=3D i40e_rxd_error_to_pkt_flags(qword1); > pkt_flags |=3D i40e_rxd_ptype_to_pkt_flags(qword1); > - mb->ol_flags =3D pkt_flags; > + mb->ol_flags =3D pkt_flags | > + (mb->ol_flags & EXTERNAL_MBUF); > if (pkt_flags & PKT_RX_RSS_HASH) > mb->hash.rss =3D rte_le_to_cpu_32(\ > rxdp->wb.qword0.hi_dword.rss); > @@ -873,7 +874,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_p= kts, uint16_t nb_pkts) > pkt_flags =3D i40e_rxd_status_to_pkt_flags(qword1); > pkt_flags |=3D i40e_rxd_error_to_pkt_flags(qword1); > pkt_flags |=3D i40e_rxd_ptype_to_pkt_flags(qword1); > - rxm->ol_flags =3D pkt_flags; > + rxm->ol_flags =3D pkt_flags | (rxm->ol_flags & EXTERNAL_MBUF); > if (pkt_flags & PKT_RX_RSS_HASH) > rxm->hash.rss =3D > rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss); > @@ -1027,7 +1028,8 @@ i40e_recv_scattered_pkts(void *rx_queue, > pkt_flags =3D i40e_rxd_status_to_pkt_flags(qword1); > pkt_flags |=3D i40e_rxd_error_to_pkt_flags(qword1); > pkt_flags |=3D i40e_rxd_ptype_to_pkt_flags(qword1); > - first_seg->ol_flags =3D pkt_flags; > + first_seg->ol_flags =3D pkt_flags | > + (first_seg->ol_flags & EXTERNAL_MBUF); > if (pkt_flags & PKT_RX_RSS_HASH) > rxm->hash.rss =3D > rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss); > diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c b/lib/librte_pmd_ixgbe/ixg= be_rxtx.c > index 1aefe5c..77e8689 100644 > --- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c > +++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c > @@ -949,7 +949,8 @@ ixgbe_rx_scan_hw_ring(struct igb_rx_queue *rxq) > /* reuse status field from scan list */ > pkt_flags |=3D rx_desc_status_to_pkt_flags(s[j]); > pkt_flags |=3D rx_desc_error_to_pkt_flags(s[j]); > - mb->ol_flags =3D pkt_flags; > + mb->ol_flags =3D pkt_flags | > + (mb->ol_flags & EXTERNAL_MBUF); >=20 > if (likely(pkt_flags & PKT_RX_RSS_HASH)) > mb->hash.rss =3D rxdp[j].wb.lower.hi_dword.rss; > @@ -1271,7 +1272,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **r= x_pkts, > pkt_flags =3D rx_desc_hlen_type_rss_to_pkt_flags(hlen_type_rss); > pkt_flags =3D pkt_flags | rx_desc_status_to_pkt_flags(staterr); > pkt_flags =3D pkt_flags | rx_desc_error_to_pkt_flags(staterr); > - rxm->ol_flags =3D pkt_flags; > + rxm->ol_flags =3D pkt_flags | (rxm->ol_flags & EXTERNAL_MBUF); >=20 > if (likely(pkt_flags & PKT_RX_RSS_HASH)) > rxm->hash.rss =3D rxd.wb.lower.hi_dword.rss; > @@ -1515,7 +1516,8 @@ ixgbe_recv_scattered_pkts(void *rx_queue, struct rt= e_mbuf **rx_pkts, > rx_desc_status_to_pkt_flags(staterr)); > pkt_flags =3D (uint16_t)(pkt_flags | > rx_desc_error_to_pkt_flags(staterr)); > - first_seg->ol_flags =3D pkt_flags; > + first_seg->ol_flags =3D pkt_flags | > + (first_seg->ol_flags & EXTERNAL_MBUF); >=20 > if (likely(pkt_flags & PKT_RX_RSS_HASH)) > first_seg->hash.rss =3D rxd.wb.lower.hi_dword.rss; > diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c b/lib/librte_pmd_ixgbe= /ixgbe_rxtx_vec.c > index e813e43..af7b1cd 100644 > --- a/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c > +++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c > @@ -156,10 +156,14 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf= **rx_pkts) > ptype1 =3D _mm_or_si128(ptype1, vtag1); > vol.dword =3D _mm_cvtsi128_si64(ptype1) & OLFLAGS_MASK_V; >=20 > - rx_pkts[0]->ol_flags =3D vol.e[0]; > - rx_pkts[1]->ol_flags =3D vol.e[1]; > - rx_pkts[2]->ol_flags =3D vol.e[2]; > - rx_pkts[3]->ol_flags =3D vol.e[3]; > + rx_pkts[0]->ol_flags =3D vol.e[0] | > + (rx_pkts[0]->ol_flags & EXTERNAL_MBUF); > + rx_pkts[1]->ol_flags =3D vol.e[1] | > + (rx_pkts[1]->ol_flags & EXTERNAL_MBUF); > + rx_pkts[2]->ol_flags =3D vol.e[2] | > + (rx_pkts[2]->ol_flags & EXTERNAL_MBUF); > + rx_pkts[3]->ol_flags =3D vol.e[3] | > + (rx_pkts[3]->ol_flags & EXTERNAL_MBUF); > } > #else > #define desc_to_olflags_v(desc, rx_pkts) do {} while (0) > -- > 1.8.4.2