From patchwork Thu Oct 12 17:24:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Melton X-Patchwork-Id: 30312 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9FE7E1B3D3; Thu, 12 Oct 2017 19:24:41 +0200 (CEST) Received: from alln-iport-1.cisco.com (alln-iport-1.cisco.com [173.37.142.88]) by dpdk.org (Postfix) with ESMTP id 5DFBB1B332 for ; Thu, 12 Oct 2017 19:24:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=4441; q=dns/txt; s=iport; t=1507829079; x=1509038679; h=from:to:cc:subject:date:message-id; bh=SxFRGKmsoNN3uU4k9Jex9BiNrSxPoEa3G/+bUyfJkYQ=; b=JOOS53RTRWdsepQtwT5OIPPzDxCi8HSPrz1ZOA7A0Ivik3CxZvkC8e6U pQpRdW7updJUi204Nb8zuk4nzbAQPiyepNg0MRoKOfTRtZotl0W0pAja+ 1x90OFEj57OR8GUh7FWOgGGALRgK0YzbnyXpiPePHbbG5XgytHC3Nk4F2 Y=; X-IronPort-AV: E=Sophos;i="5.43,367,1503360000"; d="scan'208";a="16174940" Received: from alln-core-4.cisco.com ([173.36.13.137]) by alln-iport-1.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Oct 2017 17:24:38 +0000 Received: from cpp-rtpbld-54.cisco.com (cpp-rtpbld-54.cisco.com [172.18.5.198]) by alln-core-4.cisco.com (8.14.5/8.14.5) with ESMTP id v9CHOcJU014997; Thu, 12 Oct 2017 17:24:38 GMT Received: by cpp-rtpbld-54.cisco.com (Postfix, from userid 51544) id 4D7E0609F9; Thu, 12 Oct 2017 13:24:38 -0400 (EDT) From: Roger B Melton To: wenzhuo.lu@intel.com Cc: dev@dpdk.org, Roger B Melton Date: Thu, 12 Oct 2017 13:24:35 -0400 Message-Id: <20171012172435.34700-1-rmelton@cisco.com> X-Mailer: git-send-email 2.10.3.dirty Subject: [dpdk-dev] [PATCH v2] net/e1000: correct VLAN tag byte order for i35x LB packets X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When copying VLAN tags from the RX descriptor to the vlan_tci field in the mbuf header, igb_rxtx.c:eth_igb_recv_pkts() and eth_igb_recv_scattered_pkts() both assume that the VLAN tag is always little endian. While i350, i354 and /i350vf VLAN non-loopback packets are stored little endian, VLAN tags in loopback packets for those devices are big endian. For i350, i354 and i350vf VLAN loopback packets, swap the tag when copying from the RX descriptor to the mbuf header. This will ensure that the mbuf vlan_tci is always little endian. Signed-off-by: Roger B Melton Acked-by: Wenzhuo Lu --- v2: * PF: Limit swap to i350 and i354 * VF: Limit swap to i350VF drivers/net/e1000/igb_rxtx.c | 55 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 1c80a2a..3eb547b 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -105,6 +105,13 @@ struct igb_tx_entry { }; /** + * rx queue flags + */ +enum igb_rxq_flags { + IGB_RXQ_FLAG_LB_BSWAP_VLAN = 0x01, +}; + +/** * Structure associated with each RX queue. */ struct igb_rx_queue { @@ -128,6 +135,7 @@ struct igb_rx_queue { uint8_t wthresh; /**< Write-back threshold register. */ uint8_t crc_len; /**< 0 if CRC stripped, 4 otherwise. */ uint8_t drop_en; /**< If not 0, set SRRCTL.Drop_En. */ + uint32_t flags; /**< RX flags. */ }; /** @@ -946,9 +954,16 @@ eth_igb_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxm->hash.rss = rxd.wb.lower.hi_dword.rss; hlen_type_rss = rte_le_to_cpu_32(rxd.wb.lower.lo_dword.data); - /* Only valid if PKT_RX_VLAN_PKT set in pkt_flags */ - rxm->vlan_tci = rte_le_to_cpu_16(rxd.wb.upper.vlan); - + /* + * The vlan_tci field is only valid when PKT_RX_VLAN_PKT is + * set in the pkt_flags field and must be in CPU byte order. + */ + if ((staterr & rte_cpu_to_le_32(E1000_RXDEXT_STATERR_LB)) && + (rxq->flags & IGB_RXQ_FLAG_LB_BSWAP_VLAN)) { + rxm->vlan_tci = rte_be_to_cpu_16(rxd.wb.upper.vlan); + } else { + rxm->vlan_tci = rte_le_to_cpu_16(rxd.wb.upper.vlan); + } pkt_flags = rx_desc_hlen_type_rss_to_pkt_flags(rxq, hlen_type_rss); pkt_flags = pkt_flags | rx_desc_status_to_pkt_flags(staterr); pkt_flags = pkt_flags | rx_desc_error_to_pkt_flags(staterr); @@ -1181,9 +1196,16 @@ eth_igb_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, /* * The vlan_tci field is only valid when PKT_RX_VLAN_PKT is - * set in the pkt_flags field. + * set in the pkt_flags field and must be in CPU byte order. */ - first_seg->vlan_tci = rte_le_to_cpu_16(rxd.wb.upper.vlan); + if ((staterr & rte_cpu_to_le_32(E1000_RXDEXT_STATERR_LB)) && + (rxq->flags & IGB_RXQ_FLAG_LB_BSWAP_VLAN)) { + first_seg->vlan_tci = + rte_be_to_cpu_16(rxd.wb.upper.vlan); + } else { + first_seg->vlan_tci = + rte_le_to_cpu_16(rxd.wb.upper.vlan); + } hlen_type_rss = rte_le_to_cpu_32(rxd.wb.lower.lo_dword.data); pkt_flags = rx_desc_hlen_type_rss_to_pkt_flags(rxq, hlen_type_rss); pkt_flags = pkt_flags | rx_desc_status_to_pkt_flags(staterr); @@ -2278,6 +2300,18 @@ eth_igb_rx_init(struct rte_eth_dev *dev) rxq = dev->data->rx_queues[i]; + rxq->flags = 0; + /* + * i350 and i354 vlan packets have vlan tags byte swapped. + */ + if ((hw->mac.type == e1000_i350) || + (hw->mac.type == e1000_i354)) { + rxq->flags |= IGB_RXQ_FLAG_LB_BSWAP_VLAN; + PMD_INIT_LOG(DEBUG, "IGB rx vlan bswap required"); + } else { + PMD_INIT_LOG(DEBUG, "IGB rx vlan bswap not required"); + } + /* Allocate buffers for descriptor rings and set up queue */ ret = igb_alloc_rx_queue_mbufs(rxq); if (ret) @@ -2557,6 +2591,17 @@ eth_igbvf_rx_init(struct rte_eth_dev *dev) rxq = dev->data->rx_queues[i]; + rxq->flags = 0; + /* + * i350VF LB vlan packets have vlan tags byte swapped. + */ + if (hw->mac.type == e1000_vfadapt_i350) { + rxq->flags |= IGB_RXQ_FLAG_LB_BSWAP_VLAN; + PMD_INIT_LOG(DEBUG, "IGB rx vlan bswap required"); + } else { + PMD_INIT_LOG(DEBUG, "IGB rx vlan bswap not required"); + } + /* Allocate buffers for descriptor rings and set up queue */ ret = igb_alloc_rx_queue_mbufs(rxq); if (ret)