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 EFB757CC0 for ; Tue, 5 Sep 2017 09:55:40 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Sep 2017 00:55:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,479,1498546800"; d="scan'208";a="1169183483" Received: from dpdk15.sh.intel.com ([10.67.111.77]) by orsmga001.jf.intel.com with ESMTP; 05 Sep 2017 00:55:32 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, mark.b.kavanagh@intel.com, jianfeng.tan@intel.com, Jiayu Hu Date: Tue, 5 Sep 2017 15:57:49 +0800 Message-Id: <1504598270-60080-5-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504598270-60080-1-git-send-email-jiayu.hu@intel.com> References: <1503584144-63181-1-git-send-email-jiayu.hu@intel.com> <1504598270-60080-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH v2 4/5] gso: add GRE GSO support 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: , X-List-Received-Date: Tue, 05 Sep 2017 07:55:41 -0000 From: Mark Kavanagh This patch adds GSO support for GRE-tunneled packets. Supported GRE packets must contain an outer IPv4 header, and inner TCP/IPv4 headers. They may also contain a single VLAN tag. GRE GSO assumes that all input packets have correct checksums and doesn't update checksums for output packets. Additionally, it doesn't process IP fragmented packets. As with VxLAN GSO, GRE GSO uses a two-segment MBUF to organize each output packet, which requires multi-segment mbuf support in the TX functions of the NIC driver. Also, if a packet is GSOed, GRE GSO reduces its MBUF refcnt by 1. As a result, when all of its GSOed segments are freed, the packet is freed automatically. Signed-off-by: Mark Kavanagh Signed-off-by: Jiayu Hu --- lib/librte_gso/gso_common.c | 24 ++++++++++++++++++++++++ lib/librte_gso/gso_common.h | 15 +++++++++++++++ lib/librte_gso/rte_gso.c | 2 ++ 3 files changed, 41 insertions(+) diff --git a/lib/librte_gso/gso_common.c b/lib/librte_gso/gso_common.c index 1e16c9c..668d2d0 100644 --- a/lib/librte_gso/gso_common.c +++ b/lib/librte_gso/gso_common.c @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -238,6 +239,25 @@ update_ipv4_vxlan_tcp4_header(struct rte_mbuf *pkt, uint8_t ipid_delta, update_inner_tcp4_header(pkt, ipid_delta, segs, nb_segs); } +static inline void +update_ipv4_gre_tcp4_header(struct rte_mbuf *pkt, uint8_t ipid_delta, + struct rte_mbuf **segs, uint16_t nb_segs) +{ + struct ipv4_hdr *ipv4_hdr; + uint16_t i, id; + + ipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) + + pkt->outer_l2_len); + id = rte_be_to_cpu_16(ipv4_hdr->packet_id); + for (i = 0; i < nb_segs; i++) { + update_outer_ipv4_header(segs[i], id); + id += ipid_delta; + } + + /* update inner TCP/IPv4 headers */ + update_inner_tcp4_header(pkt, ipid_delta, segs, nb_segs); +} + void gso_update_pkt_headers(struct rte_mbuf *pkt, uint8_t ipid_delta, struct rte_mbuf **segs, uint16_t nb_segs) @@ -249,6 +269,10 @@ gso_update_pkt_headers(struct rte_mbuf *pkt, uint8_t ipid_delta, case ETHER_IPv4_UDP_VXLAN_IPv4_TCP_PKT: update_ipv4_vxlan_tcp4_header(pkt, ipid_delta, segs, nb_segs); break; + case ETHER_VLAN_IPv4_GRE_IPv4_TCP_PKT: + case ETHER_IPv4_GRE_IPv4_TCP_PKT: + update_ipv4_gre_tcp4_header(pkt, ipid_delta, segs, nb_segs); + break; case ETHER_VLAN_IPv4_TCP_PKT: case ETHER_IPv4_TCP_PKT: update_inner_tcp4_header(pkt, ipid_delta, segs, nb_segs); diff --git a/lib/librte_gso/gso_common.h b/lib/librte_gso/gso_common.h index 3f76fd1..bd53bde 100644 --- a/lib/librte_gso/gso_common.h +++ b/lib/librte_gso/gso_common.h @@ -85,6 +85,21 @@ RTE_PTYPE_TUNNEL_VXLAN | \ INNER_ETHER_VLAN_IPv4_TCP_PKT) +/* GRE packet. */ +#define ETHER_IPv4_GRE_IPv4_TCP_PKT (\ + ETHER_IPv4_PKT | \ + RTE_PTYPE_TUNNEL_GRE | \ + RTE_PTYPE_INNER_L3_IPV4 | \ + RTE_PTYPE_INNER_L4_TCP) + +/* GRE packet with VLAN tag. */ +#define ETHER_VLAN_IPv4_GRE_IPv4_TCP_PKT (\ + RTE_PTYPE_L2_ETHER_VLAN | \ + RTE_PTYPE_L3_IPV4 | \ + RTE_PTYPE_TUNNEL_GRE | \ + RTE_PTYPE_INNER_L3_IPV4 | \ + RTE_PTYPE_INNER_L4_TCP) + /** * Internal function which updates relevant packet headers, following * segmentation. This is required to update, for example, the IPv4 diff --git a/lib/librte_gso/rte_gso.c b/lib/librte_gso/rte_gso.c index 0170abc..d40fda9 100644 --- a/lib/librte_gso/rte_gso.c +++ b/lib/librte_gso/rte_gso.c @@ -76,6 +76,8 @@ rte_gso_segment(struct rte_mbuf *pkt, case ETHER_VLAN_IPv4_UDP_VXLAN_IPv4_TCP_PKT: case ETHER_IPv4_UDP_VXLAN_VLAN_IPv4_TCP_PKT: case ETHER_IPv4_UDP_VXLAN_IPv4_TCP_PKT: + case ETHER_VLAN_IPv4_GRE_IPv4_TCP_PKT: + case ETHER_IPv4_GRE_IPv4_TCP_PKT: ret = gso_tunnel_segment(pkt, gso_size, ipid_delta, direct_pool, indirect_pool, pkts_out, nb_pkts_out); -- 2.7.4