From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by dpdk.org (Postfix) with ESMTP id 4514DADDD for ; Fri, 13 Feb 2015 10:23:03 +0100 (CET) Received: by mail-wi0-f180.google.com with SMTP id h11so10568540wiw.1 for ; Fri, 13 Feb 2015 01:23:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9rdC5Kx/oEw9dZ3uaBdPyP+SPbC0WeDkAjZ5NbMZv/A=; b=a4LNs6w5PkhANic/53BX0J+isqHxeX0v5KtxEkar6CD/Kb9Eo7xEEH6V2g7AMbUhbQ rMVX0gBRm+CB6PZUpdjw7QHTOInIWZlFnDZb3sGkZyqhO5I+Ndrkp/IUOmZaFZZZwMRW 5z448tGqosRy1k9SXUD3FM4RgRUlM444sksV9CSaE+U5drryj0qdIUwHpC+dZ3pq6Nm/ NEH2T1EXM3FELU+iPqVbgo4ZeT1ECYajf5I75Q2jAIqAalFYVkUr6SbwPzW7UAb4LBnN jPAuu5zm8W3FUHhwENaaH+BLlNkEebTK/O3nn0HzzKeOnDoHZz6qzdHg2OEJPj1BWVp5 YBIA== X-Gm-Message-State: ALoCoQkEcvNB6XS7c6CpOh8nUEHMP/VKM0w916ZWTm0HfdMrx6NBI1GZCBhcd+Uy2xHccNYTQwdo X-Received: by 10.195.13.104 with SMTP id ex8mr16298377wjd.12.1423819383167; Fri, 13 Feb 2015 01:23:03 -0800 (PST) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id a5sm2100153wib.20.2015.02.13.01.23.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Feb 2015 01:23:02 -0800 (PST) From: Olivier Matz To: dev@dpdk.org Date: Fri, 13 Feb 2015 10:22:33 +0100 Message-Id: <1423819371-24222-3-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1423819371-24222-1-git-send-email-olivier.matz@6wind.com> References: <1423041925-26956-1-git-send-email-olivier.matz@6wind.com> <1423819371-24222-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH v3 02/20] mbuf: enhance the API documentation of offload flags 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, 13 Feb 2015 09:23:03 -0000 Based on http://dpdk.org/ml/archives/dev/2015-January/011127.html Also adapt the csum forward engine code to the API. Signed-off-by: Olivier Matz --- app/test-pmd/csumonly.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 45 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 41711fd..4b438d1 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -183,16 +183,15 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, ipv4_hdr = l3_hdr; ipv4_hdr->hdr_checksum = 0; + ol_flags |= PKT_TX_IPV4; if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { ol_flags |= PKT_TX_IP_CKSUM; } else { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ol_flags |= PKT_TX_IP_CKSUM; - else { + else ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); - ol_flags |= PKT_TX_IPV4; - } } } else if (ethertype == _htons(ETHER_TYPE_IPv6)) ol_flags |= PKT_TX_IPV6; @@ -261,6 +260,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; + ol_flags |= PKT_TX_OUTER_IPV4; if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ol_flags |= PKT_TX_OUTER_IP_CKSUM; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index a554247..cefb54a 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -141,24 +141,55 @@ extern "C" { #define PKT_TX_UDP_CKSUM (3ULL << 52) /**< UDP cksum of TX pkt. computed by NIC. */ #define PKT_TX_L4_MASK (3ULL << 52) /**< Mask for L4 cksum offload request. */ -#define PKT_TX_IP_CKSUM (1ULL << 54) /**< IP cksum of TX pkt. computed by NIC. */ +/** + * Offload the IP checksum in the hardware. The flag PKT_TX_IPV4 should + * also be set by the application, although a PMD will only check + * PKT_TX_IP_CKSUM. + * - set the IP checksum field in the packet to 0 + * - fill the mbuf offload information: l2_len, l3_len + */ +#define PKT_TX_IP_CKSUM (1ULL << 54) -/** Packet is IPv4 without requiring IP checksum offload. */ +/** + * Packet is IPv4. This flag must be set when using any offload feature + * (TSO, L3 or L4 checksum) to tell the NIC that the packet is an IPv4 + * packet. If the packet is a tunneled packet, this flag is related to + * the inner headers. + */ #define PKT_TX_IPV4 (1ULL << 55) -/** Tell the NIC it's an IPv6 packet.*/ +/** + * Packet is IPv6. This flag must be set when using an offload feature + * (TSO or L4 checksum) to tell the NIC that the packet is an IPv6 + * packet. If the packet is a tunneled packet, this flag is related to + * the inner headers. + */ #define PKT_TX_IPV6 (1ULL << 56) #define PKT_TX_VLAN_PKT (1ULL << 57) /**< TX packet is a 802.1q VLAN packet. */ -/** Outer IP checksum of TX packet, computed by NIC for tunneling packet. - * The tunnel type must also be specified, ex: PKT_TX_UDP_TUNNEL_PKT. */ +/** + * Offload the IP checksum of an external header in the hardware. The + * flag PKT_TX_OUTER_IPV4 should also be set by the application, alto ugh + * a PMD will only check PKT_TX_IP_CKSUM. The IP checksum field in the + * packet must be set to 0. + * - set the outer IP checksum field in the packet to 0 + * - fill the mbuf offload information: outer_l2_len, outer_l3_len + */ #define PKT_TX_OUTER_IP_CKSUM (1ULL << 58) -/** Packet is outer IPv4 without requiring IP checksum offload for tunneling packet. */ +/** + * Packet outer header is IPv4. This flag must be set when using any + * outer offload feature (L3 or L4 checksum) to tell the NIC that the + * outer header of the tunneled packet is an IPv4 packet. + */ #define PKT_TX_OUTER_IPV4 (1ULL << 59) -/** Tell the NIC it's an outer IPv6 packet for tunneling packet */ +/** + * Packet outer header is IPv6. This flag must be set when using any + * outer offload feature (L4 checksum) to tell the NIC that the outer + * header of the tunneled packet is an IPv6 packet. + */ #define PKT_TX_OUTER_IPV6 (1ULL << 60) /* Use final bit of flags to indicate a control mbuf */ -- 2.1.4