* [dpdk-dev] [PATCH 2/3] pmd: add new header containing TCP offload specific definitions
2014-10-13 14:38 [dpdk-dev] [PATCH 1/3] pmd: add new flag to indicate TX TSO operation on the packet miroslaw.walukiewicz
@ 2014-10-13 14:38 ` miroslaw.walukiewicz
2014-10-14 9:50 ` Thomas Monjalon
2014-10-13 14:38 ` [dpdk-dev] [PATCH 3/3] pmd i40e: Enable Transmit Segmentation Offload for TCP traffic miroslaw.walukiewicz
2014-10-14 7:47 ` [dpdk-dev] [PATCH 1/3] pmd: add new flag to indicate TX TSO operation on the packet Liu, Jijiang
2 siblings, 1 reply; 5+ messages in thread
From: miroslaw.walukiewicz @ 2014-10-13 14:38 UTC (permalink / raw)
To: dev
From: Miroslaw Walukiewicz <miroslaw.walukiewicz@intel.com>
The function for computing initial TCP header checksum.
The file is common for both i40e and ixgbe PMD drivers
Signed-off-by: Mirek Walukiewicz <miroslaw.walukiewicz@intel.com>
---
lib/librte_net/Makefile | 3 +
lib/librte_net/rte_tcp_off.h | 122 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 124 insertions(+), 1 deletion(-)
create mode 100644 lib/librte_net/rte_tcp_off.h
diff --git a/lib/librte_net/Makefile b/lib/librte_net/Makefile
index ad2e482..83e76d1 100644
--- a/lib/librte_net/Makefile
+++ b/lib/librte_net/Makefile
@@ -34,7 +34,8 @@ include $(RTE_SDK)/mk/rte.vars.mk
CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
# install includes
-SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h rte_sctp.h rte_icmp.h rte_arp.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h rte_sctp.h rte_icmp.h rte_arp.h \
+rte_tcp_off.h
include $(RTE_SDK)/mk/rte.install.mk
diff --git a/lib/librte_net/rte_tcp_off.h b/lib/librte_net/rte_tcp_off.h
new file mode 100644
index 0000000..6143396
--- /dev/null
+++ b/lib/librte_net/rte_tcp_off.h
@@ -0,0 +1,122 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)in.h 8.3 (Berkeley) 1/3/94
+ * $FreeBSD: src/sys/netinet/in.h,v 1.82 2003/10/25 09:37:10 ume Exp $
+ */
+
+#ifndef _RTE_TCP_OFF_H_
+#define _RTE_TCP_OFF_H_
+
+/**
+ * @file
+ *
+ * TCP offload -related defines
+ */
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * function computes the TCP pseudo checksum for TSO
+ * it is a commnon function for i40e/ixgbe drivers
+ * it computes the IP header initial checksum as input
+ * for computing TCP data checksum made by HW
+ */
+static inline u_short
+rte_in_pseudo(uint32_t src_ipv4, uint32_t dst_ipv4, uint32_t proto)
+{
+ uint64_t sum;
+ union l_val {
+ uint16_t s[2];
+ uint32_t l;
+ } l_val;
+ union q_val {
+ uint16_t s[4];
+ uint32_t l[2];
+ uint64_t q;
+ } q_val;
+
+ sum = (uint64_t) src_ipv4 + dst_ipv4 + proto;
+
+ q_val.q = sum;
+ l_val.l = q_val.s[0] + q_val.s[1] + q_val.s[2] + q_val.s[3];
+ sum = l_val.s[0] + l_val.s[1];
+
+ sum > 65535 ? sum -= 65535 : sum;
+
+ return (sum);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _RTE_TCP_OFF_H_ */
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 3/3] pmd i40e: Enable Transmit Segmentation Offload for TCP traffic
2014-10-13 14:38 [dpdk-dev] [PATCH 1/3] pmd: add new flag to indicate TX TSO operation on the packet miroslaw.walukiewicz
2014-10-13 14:38 ` [dpdk-dev] [PATCH 2/3] pmd: add new header containing TCP offload specific definitions miroslaw.walukiewicz
@ 2014-10-13 14:38 ` miroslaw.walukiewicz
2014-10-14 7:47 ` [dpdk-dev] [PATCH 1/3] pmd: add new flag to indicate TX TSO operation on the packet Liu, Jijiang
2 siblings, 0 replies; 5+ messages in thread
From: miroslaw.walukiewicz @ 2014-10-13 14:38 UTC (permalink / raw)
To: dev
From: Miroslaw Walukiewicz <miroslaw.walukiewicz@intel.com>
The patch enables the TSO HW feature for i40e PMD driver.
The feature is reported by rte_dev_info_get() if enabled.
Signed-off-by: Mirek Walukiewicz <miroslaw.walukiewicz@intel.com>
---
lib/librte_pmd_i40e/i40e_ethdev.c | 1 +
lib/librte_pmd_i40e/i40e_rxtx.c | 56 ++++++++++++++++++++++++++++++++++---
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c
index 46c43a7..01b21eb 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1399,6 +1399,7 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
DEV_TX_OFFLOAD_IPV4_CKSUM |
DEV_TX_OFFLOAD_UDP_CKSUM |
DEV_TX_OFFLOAD_TCP_CKSUM |
+ DEV_TX_OFFLOAD_TCP_TSO |
DEV_TX_OFFLOAD_SCTP_CKSUM;
dev_info->default_rxconf = (struct rte_eth_rxconf) {
diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 2b53677..bc7af2b 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -50,6 +50,8 @@
#include <rte_tcp.h>
#include <rte_sctp.h>
#include <rte_udp.h>
+#include <rte_ip.h>
+#include <rte_tcp_off.h>
#include "i40e_logs.h"
#include "i40e/i40e_prototype.h"
@@ -440,6 +442,11 @@ i40e_txd_enable_checksum(uint32_t ol_flags,
*td_offset |= (l3_len >> 2) << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
}
+ if (ol_flags & PKT_TX_TCP_TSO) {
+ *td_cmd |= I40E_TX_DESC_CMD_L4T_EOFT_TCP;
+ /* td offset will be set next */
+ return;
+ }
/* Enable L4 checksum offloads */
switch (ol_flags & PKT_TX_L4_MASK) {
case PKT_TX_TCP_CKSUM:
@@ -1073,12 +1080,46 @@ i40e_calc_context_desc(uint64_t flags)
#ifdef RTE_LIBRTE_IEEE1588
mask |= PKT_TX_IEEE1588_TMST;
#endif
+ /* need for context descriptor when TSO enabled */
+ mask |= PKT_TX_TCP_TSO;
if (flags & mask)
return 1;
return 0;
}
+/* set i40e TSO context descriptor */
+static inline uint64_t
+i40e_set_tso_ctx(struct rte_mbuf *mbuf, uint8_t l2_len, uint8_t l3_len, uint32_t *td_offset)
+{
+ uint64_t ctx_desc;
+ struct ipv4_hdr *ip;
+ struct tcp_hdr *th;
+ uint32_t tcp_hlen;
+ uint32_t hdrlen;
+ uint32_t paylen;
+
+ /* set mss */
+ ip = (struct ipv4_hdr *) (rte_pktmbuf_mtod(mbuf, unsigned char *) + l2_len);
+ ip->hdr_checksum = 0;
+ ip->total_length = 0;
+ th = (struct tcp_hdr *)((caddr_t)ip + l3_len);
+ th->cksum = rte_in_pseudo(ip->src_addr, ip->dst_addr, I40E_HTONS(IPPROTO_TCP));
+ tcp_hlen = (th->data_off >> 4) << 2;
+ *td_offset |= (tcp_hlen >> 2) <<
+ I40E_TX_DESC_LENGTH_L4_FC_LEN_SHIFT;
+ hdrlen = l2_len + l3_len + tcp_hlen;
+ paylen = mbuf->pkt_len - hdrlen;
+
+ ctx_desc = ((uint64_t)mbuf->tso_segsz <<
+ I40E_TXD_CTX_QW1_MSS_SHIFT) |
+ ((uint64_t)paylen << I40E_TXD_CTX_QW1_TSO_LEN_SHIFT) |
+ ((uint64_t)I40E_TX_CTX_DESC_TSO <<
+ I40E_TXD_CTX_QW1_CMD_SHIFT);
+
+ return ctx_desc;
+}
+
uint16_t
i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
{
@@ -1192,12 +1233,19 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
rte_pktmbuf_free_seg(txe->mbuf);
txe->mbuf = NULL;
}
+ /* TSO enabled means no timestamp */
+ if (ol_flags & PKT_TX_TCP_TSO) {
+ cd_type_cmd_tso_mss |=
+ i40e_set_tso_ctx(tx_pkt, l2_len, l3_len, &td_offset);
+ }
+ else {
#ifdef RTE_LIBRTE_IEEE1588
- if (ol_flags & PKT_TX_IEEE1588_TMST)
- cd_type_cmd_tso_mss |=
- ((uint64_t)I40E_TX_CTX_DESC_TSYN <<
- I40E_TXD_CTX_QW1_CMD_SHIFT);
+ if (ol_flags & PKT_TX_IEEE1588_TMST)
+ cd_type_cmd_tso_mss |=
+ ((uint64_t)I40E_TX_CTX_DESC_TSYN <<
+ I40E_TXD_CTX_QW1_CMD_SHIFT);
#endif
+ }
ctx_txd->tunneling_params =
rte_cpu_to_le_32(cd_tunneling_params);
ctx_txd->l2tag2 = rte_cpu_to_le_16(cd_l2tag2);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] pmd: add new flag to indicate TX TSO operation on the packet
2014-10-13 14:38 [dpdk-dev] [PATCH 1/3] pmd: add new flag to indicate TX TSO operation on the packet miroslaw.walukiewicz
2014-10-13 14:38 ` [dpdk-dev] [PATCH 2/3] pmd: add new header containing TCP offload specific definitions miroslaw.walukiewicz
2014-10-13 14:38 ` [dpdk-dev] [PATCH 3/3] pmd i40e: Enable Transmit Segmentation Offload for TCP traffic miroslaw.walukiewicz
@ 2014-10-14 7:47 ` Liu, Jijiang
2 siblings, 0 replies; 5+ messages in thread
From: Liu, Jijiang @ 2014-10-14 7:47 UTC (permalink / raw)
To: Walukiewicz, Miroslaw; +Cc: dev
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of
> miroslaw.walukiewicz@intel.com
> Sent: Monday, October 13, 2014 10:39 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 1/3] pmd: add new flag to indicate TX TSO operation
> on the packet
>
> From: Miroslaw Walukiewicz <miroslaw.walukiewicz@intel.com>
>
> Transmission of TCP packets could be accelerated by HW Transmit Segmentation
> Offload. With TSO packets up to 64K could be transmismitted.
>
> When this flag is set the PMD drived will enable TCP segmentation.
>
> The new field tso_segsz is added to indicate how long is TCP TSO segment.
>
> Signed-off-by: Mirek Walukiewicz <miroslaw.walukiewicz@intel.com>
> ---
> lib/librte_mbuf/rte_mbuf.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index
> ddadc21..63cbc36 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -117,6 +117,9 @@ extern "C" {
> /* Use final bit of flags to indicate a control mbuf */
> #define CTRL_MBUF_FLAG (1ULL << 63) /**< Mbuf contains control data */
>
> +/* Bit 50 - TSO (TCP Transmit Segmenation Offload) */
> +#define PKT_TX_TCP_TSO (1ULL << 50) /**< Mbuf needs TSO enabling */
In VxLAN patch set [PATCH v5 7/8]i40e:support VxLAN Tx checksum offload, the bit (1ULL << 50) in offload flag have already been used.
+#define PKT_TX_VXLAN_CKSUM (1ULL << 50) /**< TX checksum of VxLAN computed by NIC */
> /**
> * Bit Mask to indicate what bits required for building TX context
> */
> @@ -196,6 +199,8 @@ struct rte_mbuf {
> uint16_t l2_len:7; /**< L2 (MAC) Header Length. */
> };
> };
> + /* field to support TSO segment size */
> + uint32_t tso_segsz;
> } __rte_cache_aligned;
>
> /**
^ permalink raw reply [flat|nested] 5+ messages in thread