From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 65B4EA0C4D; Wed, 13 Oct 2021 04:45:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AC50341150; Wed, 13 Oct 2021 04:45:44 +0200 (CEST) Received: from smtpbgeu2.qq.com (smtpbgeu2.qq.com [18.194.254.142]) by mails.dpdk.org (Postfix) with ESMTP id 2FDE641150 for ; Wed, 13 Oct 2021 04:45:43 +0200 (CEST) X-QQ-mid: bizesmtp45t1634093132taqkjjqd Received: from jiawenwu.trustnetic.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Wed, 13 Oct 2021 10:45:32 +0800 (CST) X-QQ-SSF: 01400000000000E0H000B00A0000000 X-QQ-FEAT: dpyQmELDBxGLGv+sFxvm4v5JFXFrzaL8mrE52kltY3VnctdeTlihdIK/v+gH1 SLQINb+kF5oAadqBi9vvej3oj+Z1y1zZdXnv591f3hadE+wVCnwFkJz+aYglR8fnSE/M3T4 JZwxx8zWsRCqUy0czwayLDKWjdb2OOoDMx1t7JHTaHS/k0a9kTWudHCYiQXM/XH78qjcbB/ 8GQGhk5zNJkkTQAsggwKZC7XooQn/sJENUu2UpeJAKUaP+JZbY7no/QoA0MfOOb4fqOtSqj LJSTJ25bGowFoulCyJI12/TQVZFMQ5NN6pwk+ASoAEeszwesWwYxyP1kZ+zPYrKaP3RrqdA WOp+4HxkzkdtfNZ9zZG5q+y9Gsjsg== X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu , stable@dpdk.org Date: Wed, 13 Oct 2021 10:45:21 +0800 Message-Id: <20211013024521.20520-4-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20211013024521.20520-1-jiawenwu@trustnetic.com> References: <20211013024521.20520-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH 3/3] net/txgbe: fix VXLAN-GPE packet checksum X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Parse inner L2 length to set correct packet type, and ensure that hardware can compute the checksum successfully. Fixes: b950203be7f1 ("net/txgbe: support VXLAN-GPE") Cc: stable@dpdk.org Signed-off-by: Jiawen Wu --- drivers/net/txgbe/txgbe_ptypes.c | 24 +++++++++++----------- drivers/net/txgbe/txgbe_rxtx.c | 35 +++++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/drivers/net/txgbe/txgbe_ptypes.c b/drivers/net/txgbe/txgbe_ptypes.c index c8a8a3839d..0ed757d820 100644 --- a/drivers/net/txgbe/txgbe_ptypes.c +++ b/drivers/net/txgbe/txgbe_ptypes.c @@ -102,17 +102,17 @@ static u32 txgbe_ptype_lookup[TXGBE_PTID_MAX] __rte_cache_aligned = { TPTE(0x8C, ETHER, IPV4, NONE, IP, NONE, IPV6, TCP), TPTE(0x8D, ETHER, IPV4, NONE, IP, NONE, IPV6, SCTP), /* IPv4 -> GRE/Teredo/VXLAN -> NONE/IPv4/IPv6 */ - TPTE(0x90, ETHER, IPV4, NONE, VXLAN_GPE, NONE, NONE, NONE), - TPTE(0x91, ETHER, IPV4, NONE, VXLAN_GPE, NONE, IPV4, FRAG), - TPTE(0x92, ETHER, IPV4, NONE, VXLAN_GPE, NONE, IPV4, NONFRAG), - TPTE(0x93, ETHER, IPV4, NONE, VXLAN_GPE, NONE, IPV4, UDP), - TPTE(0x94, ETHER, IPV4, NONE, VXLAN_GPE, NONE, IPV4, TCP), - TPTE(0x95, ETHER, IPV4, NONE, VXLAN_GPE, NONE, IPV4, SCTP), - TPTE(0x99, ETHER, IPV4, NONE, VXLAN_GPE, NONE, IPV6, FRAG), - TPTE(0x9A, ETHER, IPV4, NONE, VXLAN_GPE, NONE, IPV6, NONFRAG), - TPTE(0x9B, ETHER, IPV4, NONE, VXLAN_GPE, NONE, IPV6, UDP), - TPTE(0x9C, ETHER, IPV4, NONE, VXLAN_GPE, NONE, IPV6, TCP), - TPTE(0x9D, ETHER, IPV4, NONE, VXLAN_GPE, NONE, IPV6, SCTP), + TPTE(0x90, ETHER, IPV4, NONE, GRENAT, NONE, NONE, NONE), + TPTE(0x91, ETHER, IPV4, NONE, GRENAT, NONE, IPV4, FRAG), + TPTE(0x92, ETHER, IPV4, NONE, GRENAT, NONE, IPV4, NONFRAG), + TPTE(0x93, ETHER, IPV4, NONE, GRENAT, NONE, IPV4, UDP), + TPTE(0x94, ETHER, IPV4, NONE, GRENAT, NONE, IPV4, TCP), + TPTE(0x95, ETHER, IPV4, NONE, GRENAT, NONE, IPV4, SCTP), + TPTE(0x99, ETHER, IPV4, NONE, GRENAT, NONE, IPV6, FRAG), + TPTE(0x9A, ETHER, IPV4, NONE, GRENAT, NONE, IPV6, NONFRAG), + TPTE(0x9B, ETHER, IPV4, NONE, GRENAT, NONE, IPV6, UDP), + TPTE(0x9C, ETHER, IPV4, NONE, GRENAT, NONE, IPV6, TCP), + TPTE(0x9D, ETHER, IPV4, NONE, GRENAT, NONE, IPV6, SCTP), /* IPv4 -> GRE/Teredo/VXLAN -> MAC -> NONE/IPv4/IPv6 */ TPTE(0xA0, ETHER, IPV4, NONE, GRENAT, ETHER, NONE, NONE), TPTE(0xA1, ETHER, IPV4, NONE, GRENAT, ETHER, IPV4, FRAG), @@ -320,10 +320,10 @@ txgbe_encode_ptype_tunnel(u32 ptype) ptid |= TXGBE_PTID_TUN_EI; break; case RTE_PTYPE_TUNNEL_GRE: - case RTE_PTYPE_TUNNEL_VXLAN_GPE: ptid |= TXGBE_PTID_TUN_EIG; break; case RTE_PTYPE_TUNNEL_VXLAN: + case RTE_PTYPE_TUNNEL_VXLAN_GPE: case RTE_PTYPE_TUNNEL_NVGRE: case RTE_PTYPE_TUNNEL_GENEVE: case RTE_PTYPE_TUNNEL_GRENAT: diff --git a/drivers/net/txgbe/txgbe_rxtx.c b/drivers/net/txgbe/txgbe_rxtx.c index b6339fe50b..b8efe57248 100644 --- a/drivers/net/txgbe/txgbe_rxtx.c +++ b/drivers/net/txgbe/txgbe_rxtx.c @@ -562,10 +562,10 @@ tx_desc_ol_flags_to_ptid(uint64_t oflags, uint32_t ptype) /* Tunnel */ switch (oflags & PKT_TX_TUNNEL_MASK) { case PKT_TX_TUNNEL_VXLAN: + case PKT_TX_TUNNEL_VXLAN_GPE: ptype |= RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | - RTE_PTYPE_TUNNEL_VXLAN; - ptype |= RTE_PTYPE_INNER_L2_ETHER; + RTE_PTYPE_TUNNEL_GRENAT; break; case PKT_TX_TUNNEL_GRE: ptype |= RTE_PTYPE_L2_ETHER | @@ -579,11 +579,6 @@ tx_desc_ol_flags_to_ptid(uint64_t oflags, uint32_t ptype) RTE_PTYPE_TUNNEL_GENEVE; ptype |= RTE_PTYPE_INNER_L2_ETHER; break; - case PKT_TX_TUNNEL_VXLAN_GPE: - ptype |= RTE_PTYPE_L2_ETHER | - RTE_PTYPE_L3_IPV4 | - RTE_PTYPE_TUNNEL_VXLAN_GPE; - break; case PKT_TX_TUNNEL_IPIP: case PKT_TX_TUNNEL_IP: ptype |= RTE_PTYPE_L2_ETHER | @@ -696,6 +691,30 @@ txgbe_get_tun_len(struct rte_mbuf *mbuf) return tun_len; } +static inline uint8_t +txgbe_parse_tun_ptid(struct rte_mbuf *tx_pkt) +{ + uint64_t l2_none, l2_mac, l2_mac_vlan; + uint8_t ptid = 0; + + if ((tx_pkt->ol_flags & (PKT_TX_TUNNEL_VXLAN | + PKT_TX_TUNNEL_VXLAN_GPE)) == 0) + return ptid; + + l2_none = sizeof(struct txgbe_udphdr) + sizeof(struct txgbe_vxlanhdr); + l2_mac = l2_none + sizeof(struct rte_ether_hdr); + l2_mac_vlan = l2_mac + sizeof(struct rte_vlan_hdr); + + if (tx_pkt->l2_len == l2_none) + ptid = TXGBE_PTID_TUN_EIG; + else if (tx_pkt->l2_len == l2_mac) + ptid = TXGBE_PTID_TUN_EIGM; + else if (tx_pkt->l2_len == l2_mac_vlan) + ptid = TXGBE_PTID_TUN_EIGMV; + + return ptid; +} + uint16_t txgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) @@ -759,6 +778,8 @@ txgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, if (tx_ol_req) { tx_offload.ptid = tx_desc_ol_flags_to_ptid(tx_ol_req, tx_pkt->packet_type); + if (tx_offload.ptid & TXGBE_PTID_PKT_TUN) + tx_offload.ptid |= txgbe_parse_tun_ptid(tx_pkt); tx_offload.l2_len = tx_pkt->l2_len; tx_offload.l3_len = tx_pkt->l3_len; tx_offload.l4_len = tx_pkt->l4_len; -- 2.21.0.windows.1