diff mbox

[dpdk-dev,2/3] pmd: add new header containing TCP offload specific definitions

Message ID 20141013143840.19211.79771.stgit@gklab-18-011.igk.intel.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

miroslaw.walukiewicz@intel.com Oct. 13, 2014, 2:38 p.m. UTC
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

Comments

Thomas Monjalon Oct. 14, 2014, 9:50 a.m. UTC | #1
Hi Miroslaw,

2014-10-13 10:38, miroslaw.walukiewicz@intel.com:
> 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 ++++++++++++++++++++++++++++++++++++++++++

There is a work in progress about TSO:
	http://thread.gmane.org/gmane.comp.networking.dpdk.devel/2541/focus=2553
This API was discussed and implemented for ixgbe.
Then there was an agreement to rework mbuf in 1.8 version to implement TSO
on top of it. Then it was suggested to rebase his work:
	http://dpdk.org/ml/archives/dev/2014-September/006151.html

How does your patchset match with Olivier's work on TSO and ixgbe driver?
I would like to ensure the API works fine for all TSO-capable driver,
this would be a good start.

Thanks
diff mbox

Patch

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_ */