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 2F2E25398 for ; Mon, 23 May 2016 11:20:41 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 23 May 2016 02:20:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,354,1459839600"; d="scan'208";a="812751249" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga003.jf.intel.com with ESMTP; 23 May 2016 02:20:38 -0700 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.27]) by IRSMSX103.ger.corp.intel.com ([169.254.3.198]) with mapi id 14.03.0248.002; Mon, 23 May 2016 10:20:37 +0100 From: "Ananyev, Konstantin" To: Olivier Matz , "dev@dpdk.org" CC: "johndale@cisco.com" , "Zhang, Helin" , "adrien.mazarguil@6wind.com" , "rahul.lakkireddy@chelsio.com" , "alejandro.lucero@netronome.com" , "sony.chacko@qlogic.com" Thread-Topic: [PATCH] mbuf: new flag when Vlan is stripped Thread-Index: AQHRtM/PhEApRKY/Yk+xvqrmesFPo5/GO2lg Date: Mon, 23 May 2016 09:20:36 +0000 Message-ID: <2601191342CEEE43887BDE71AB97725836B5CAB4@irsmsx105.ger.corp.intel.com> References: <1462897493-6567-1-git-send-email-olivier.matz@6wind.com> <1463993205-5623-1-git-send-email-olivier.matz@6wind.com> In-Reply-To: <1463993205-5623-1-git-send-email-olivier.matz@6wind.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.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] mbuf: new flag when Vlan is stripped 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, 23 May 2016 09:20:42 -0000 > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Monday, May 23, 2016 9:47 AM > To: dev@dpdk.org > Cc: johndale@cisco.com; Ananyev, Konstantin; Zhang, Helin; adrien.mazargu= il@6wind.com; rahul.lakkireddy@chelsio.com; > alejandro.lucero@netronome.com; sony.chacko@qlogic.com > Subject: [PATCH] mbuf: new flag when Vlan is stripped >=20 > The behavior of PKT_RX_VLAN_PKT was not very well defined, resulting in > PMDs not advertising the same flags in similar conditions. >=20 > Following discussion in [1], introduce 2 new flags PKT_RX_VLAN_STRIPPED > and PKT_RX_QINQ_STRIPPED that are better defined: >=20 > PKT_RX_VLAN_STRIPPED: a vlan has been stripped by the hardware and its > tci is saved in mbuf->vlan_tci. This can only happen if vlan stripping > is enabled in the RX configuration of the PMD. >=20 > For now, the old flag PKT_RX_VLAN_PKT is kept but marked as deprecated. > It should be removed from applications and PMDs in a future revision. >=20 > This patch also updates the drivers. For PKT_RX_VLAN_PKT: >=20 > - e1000, enic, i40e, mlx5, nfp, vmxnet3: done, PKT_RX_VLAN_PKT already > had the same meaning than PKT_RX_VLAN_STRIPPED, minor update is > required. > - fm10k: done, PKT_RX_VLAN_PKT already had the same meaning than > PKT_RX_VLAN_STRIPPED, and vlan stripping is always enabled on fm10k. > - ixgbe: modification done for standard mode (vector does not support > vlan stripping) > - the other drivers do not support vlan stripping. >=20 > For PKT_RX_QINQ_PKT, it was only supported on i40e, and the meaning was > already correct, so we can reuse the same value for PKT_RX_QINQ_STRIPPED. >=20 > [1] http://dpdk.org/ml/archives/dev/2016-April/037837.html, >=20 > Signed-off-by: Olivier Matz > --- >=20 > RFC -> v1: > - fix checkpatch and check-git-log.sh issues > - add a deprecation notice for the old vlan flags > - rebase on head >=20 >=20 > app/test-pmd/rxonly.c | 4 +-- > doc/guides/rel_notes/deprecation.rst | 5 ++++ > drivers/net/e1000/em_rxtx.c | 3 ++- > drivers/net/e1000/igb_rxtx.c | 3 ++- > drivers/net/enic/enic_rx.c | 2 +- > drivers/net/i40e/i40e_rxtx.c | 2 +- > drivers/net/ixgbe/ixgbe_ethdev.c | 7 +++++ > drivers/net/ixgbe/ixgbe_rxtx.c | 21 +++++++++++---- > drivers/net/ixgbe/ixgbe_rxtx.h | 1 + > drivers/net/mlx5/mlx5_rxtx.c | 6 +++-- > drivers/net/nfp/nfp_net.c | 2 +- > drivers/net/vmxnet3/vmxnet3_rxtx.c | 2 +- > lib/librte_mbuf/rte_mbuf.c | 2 ++ > lib/librte_mbuf/rte_mbuf.h | 50 ++++++++++++++++++++++++++++++= ++---- > 14 files changed, 90 insertions(+), 20 deletions(-) >=20 > diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c > index 14555ab..c69b344 100644 > --- a/app/test-pmd/rxonly.c > +++ b/app/test-pmd/rxonly.c > @@ -156,9 +156,9 @@ pkt_burst_receive(struct fwd_stream *fs) > printf("hash=3D0x%x ID=3D0x%x ", > mb->hash.fdir.hash, mb->hash.fdir.id); > } > - if (ol_flags & PKT_RX_VLAN_PKT) > + if (ol_flags & PKT_RX_VLAN_STRIPPED) > printf(" - VLAN tci=3D0x%x", mb->vlan_tci); > - if (ol_flags & PKT_RX_QINQ_PKT) > + if (ol_flags & PKT_RX_QINQ_STRIPPED) > printf(" - QinQ VLAN tci=3D0x%x, VLAN tci outer=3D0x%x", > mb->vlan_tci, mb->vlan_tci_outer); > if (mb->packet_type) { > diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/= deprecation.rst > index ad05eba..2233a90 100644 > --- a/doc/guides/rel_notes/deprecation.rst > +++ b/doc/guides/rel_notes/deprecation.rst > @@ -57,3 +57,8 @@ Deprecation Notices > a handle, like the way kernel exposes an fd to user for locating a > specific file, and to keep all major structures internally, so that > we are likely to be free from ABI violations in future. > + > +* The mbuf flags PKT_RX_VLAN_PKT and PKT_RX_QINQ_PKT are deprecated and > + are respectively replaced by PKT_RX_VLAN_STRIPPED and > + PKT_RX_QINQ_STRIPPED, that are better described. The old flags and > + their behavior will be kept in 16.07 and will be removed in 16.11. > diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c > index 3d36f21..6d8750a 100644 > --- a/drivers/net/e1000/em_rxtx.c > +++ b/drivers/net/e1000/em_rxtx.c > @@ -629,7 +629,8 @@ rx_desc_status_to_pkt_flags(uint32_t rx_status) > uint64_t pkt_flags; >=20 > /* Check if VLAN present */ > - pkt_flags =3D ((rx_status & E1000_RXD_STAT_VP) ? PKT_RX_VLAN_PKT : 0); > + pkt_flags =3D ((rx_status & E1000_RXD_STAT_VP) ? > + PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED : 0); >=20 > return pkt_flags; > } > diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c > index 18aeead..9d80a0b 100644 > --- a/drivers/net/e1000/igb_rxtx.c > +++ b/drivers/net/e1000/igb_rxtx.c > @@ -729,7 +729,8 @@ rx_desc_status_to_pkt_flags(uint32_t rx_status) > uint64_t pkt_flags; >=20 > /* Check if VLAN present */ > - pkt_flags =3D (rx_status & E1000_RXD_STAT_VP) ? PKT_RX_VLAN_PKT : 0; > + pkt_flags =3D ((rx_status & E1000_RXD_STAT_VP) ? > + PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED : 0); >=20 > #if defined(RTE_LIBRTE_IEEE1588) > if (rx_status & E1000_RXD_STAT_TMST) > diff --git a/drivers/net/enic/enic_rx.c b/drivers/net/enic/enic_rx.c > index f92f6bc..6459e97 100644 > --- a/drivers/net/enic/enic_rx.c > +++ b/drivers/net/enic/enic_rx.c > @@ -197,7 +197,7 @@ enic_cq_rx_to_pkt_flags(struct cq_desc *cqd, struct r= te_mbuf *mbuf) >=20 > /* VLAN stripping */ > if (bwflags & CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED) { > - pkt_flags |=3D PKT_RX_VLAN_PKT; > + pkt_flags |=3D PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED; > mbuf->vlan_tci =3D enic_cq_rx_desc_vlan(cqrd); > } else { > mbuf->vlan_tci =3D 0; > diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c > index c833aa3..aa161a9 100644 > --- a/drivers/net/i40e/i40e_rxtx.c > +++ b/drivers/net/i40e/i40e_rxtx.c > @@ -99,7 +99,7 @@ i40e_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile unio= n i40e_rx_desc *rxdp) > #ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC > if (rte_le_to_cpu_16(rxdp->wb.qword2.ext_status) & > (1 << I40E_RX_DESC_EXT_STATUS_L2TAG2P_SHIFT)) { > - mb->ol_flags |=3D PKT_RX_QINQ_PKT; > + mb->ol_flags |=3D PKT_RX_QINQ_STRIPPED; > mb->vlan_tci_outer =3D mb->vlan_tci; > mb->vlan_tci =3D rte_le_to_cpu_16(rxdp->wb.qword2.l2tag2_2); > PMD_RX_LOG(DEBUG, "Descriptor l2tag2_1: %u, l2tag2_2: %u", > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_e= thdev.c > index a2b170b..e7717e3 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > @@ -1636,6 +1636,7 @@ ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *= dev, uint16_t queue, bool on) > { > struct ixgbe_hwstrip *hwstrip =3D > IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(dev->data->dev_private); > + struct ixgbe_rx_queue *rxq; >=20 > if (queue >=3D IXGBE_MAX_RX_QUEUE_NUM) > return; > @@ -1644,6 +1645,12 @@ ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev = *dev, uint16_t queue, bool on) > IXGBE_SET_HWSTRIP(hwstrip, queue); > else > IXGBE_CLEAR_HWSTRIP(hwstrip, queue); > + > + if (queue >=3D dev->data->nb_rx_queues) > + return; > + > + rxq =3D dev->data->rx_queues[queue]; > + rxq->vlan_strip =3D on; > } >=20 > static void > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxt= x.c > index 9c6eaf2..3d740df 100644 > --- a/drivers/net/ixgbe/ixgbe_rxtx.c > +++ b/drivers/net/ixgbe/ixgbe_rxtx.c > @@ -1221,16 +1221,23 @@ ixgbe_rxd_pkt_info_to_pkt_flags(uint16_t pkt_info= ) > } >=20 > static inline uint64_t > -rx_desc_status_to_pkt_flags(uint32_t rx_status) > +rx_desc_status_to_pkt_flags(uint32_t rx_status, uint8_t vlan_strip) > { > uint64_t pkt_flags; > + uint64_t vlan_flags; > + > + /* if vlan is stripped, set the proper flag */ > + if (vlan_strip) > + vlan_flags =3D PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED; > + else > + vlan_flags =3D PKT_RX_VLAN_PKT; >=20 > /* > * Check if VLAN present only. > * Do not check whether L3/L4 rx checksum done by NIC or not, > * That can be found from rte_eth_rxmode.hw_ip_checksum flag > */ > - pkt_flags =3D (rx_status & IXGBE_RXD_STAT_VP) ? PKT_RX_VLAN_PKT : 0; > + pkt_flags =3D (rx_status & IXGBE_RXD_STAT_VP) ? vlan_flags : 0; Instead of storing in rxq (and passing as a parameter) a bool value for vla= n_strip (=3Don/off), you probably can store in rxq and pass as a parameter here uint64_t vlan_fl= ags; Then it will be: =20 rx_desc_status_to_pkt_flags(uint32_t rx_status, uint64_t vlan_flags) { ... pkt_flags =3D (rx_status & IXGBE_RXD_STAT_VP) ? vlan_flags : 0; ... } ... pkt_flags =3D rx_desc_status_to_pkt_flags(s[j], rxq->vlan_flags); Might help to save few cycles here. Konstantin >=20 > #ifdef RTE_LIBRTE_IEEE1588 > if (rx_status & IXGBE_RXD_STAT_TMST) > @@ -1287,6 +1294,7 @@ ixgbe_rx_scan_hw_ring(struct ixgbe_rx_queue *rxq) > uint32_t pkt_info[LOOK_AHEAD]; > int i, j, nb_rx =3D 0; > uint32_t status; > + uint8_t vlan_strip =3D rxq->vlan_strip; >=20 > /* get references to current descriptor and S/W ring entry */ > rxdp =3D &rxq->rx_ring[rxq->rx_tail]; > @@ -1328,7 +1336,8 @@ ixgbe_rx_scan_hw_ring(struct ixgbe_rx_queue *rxq) > mb->vlan_tci =3D rte_le_to_cpu_16(rxdp[j].wb.upper.vlan); >=20 > /* convert descriptor fields to rte mbuf flags */ > - pkt_flags =3D rx_desc_status_to_pkt_flags(s[j]); > + pkt_flags =3D rx_desc_status_to_pkt_flags(s[j], > + vlan_strip); > pkt_flags |=3D rx_desc_error_to_pkt_flags(s[j]); > pkt_flags |=3D ixgbe_rxd_pkt_info_to_pkt_flags > ((uint16_t)pkt_info[j]); > @@ -1544,6 +1553,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **r= x_pkts, > uint16_t nb_rx; > uint16_t nb_hold; > uint64_t pkt_flags; > + uint8_t vlan_strip; >=20 > nb_rx =3D 0; > nb_hold =3D 0; > @@ -1551,6 +1561,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **r= x_pkts, > rx_id =3D rxq->rx_tail; > rx_ring =3D rxq->rx_ring; > sw_ring =3D rxq->sw_ring; > + vlan_strip =3D rxq->vlan_strip; > while (nb_rx < nb_pkts) { > /* > * The order of operations here is important as the DD status > @@ -1660,7 +1671,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **r= x_pkts, > /* Only valid if PKT_RX_VLAN_PKT set in pkt_flags */ > rxm->vlan_tci =3D rte_le_to_cpu_16(rxd.wb.upper.vlan); >=20 > - pkt_flags =3D rx_desc_status_to_pkt_flags(staterr); > + pkt_flags =3D rx_desc_status_to_pkt_flags(staterr, vlan_strip); > pkt_flags =3D pkt_flags | rx_desc_error_to_pkt_flags(staterr); > pkt_flags =3D pkt_flags | > ixgbe_rxd_pkt_info_to_pkt_flags((uint16_t)pkt_info); > @@ -1753,7 +1764,7 @@ ixgbe_fill_cluster_head_buf( > */ > head->vlan_tci =3D rte_le_to_cpu_16(desc->wb.upper.vlan); > pkt_info =3D rte_le_to_cpu_32(desc->wb.lower.lo_dword.data); > - pkt_flags =3D rx_desc_status_to_pkt_flags(staterr); > + pkt_flags =3D rx_desc_status_to_pkt_flags(staterr, rxq->vlan_strip); > pkt_flags |=3D rx_desc_error_to_pkt_flags(staterr); > pkt_flags |=3D ixgbe_rxd_pkt_info_to_pkt_flags((uint16_t)pkt_info); > head->ol_flags =3D pkt_flags; > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxt= x.h > index 3691a19..9ca0e8b 100644 > --- a/drivers/net/ixgbe/ixgbe_rxtx.h > +++ b/drivers/net/ixgbe/ixgbe_rxtx.h > @@ -146,6 +146,7 @@ struct ixgbe_rx_queue { > uint8_t crc_len; /**< 0 if CRC stripped, 4 otherwise. */ > uint8_t drop_en; /**< If not 0, set SRRCTL.Drop_En. */ > uint8_t rx_deferred_start; /**< not in global dev start. */ > + uint8_t vlan_strip; /**< 1 if vlan stripping enabled. */ > /** need to alloc dummy mbuf, for wraparound when scanning hw ring */ > struct rte_mbuf fake_mbuf; > /** hold packets to return to application */