From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 1F9CE7E52 for ; Mon, 13 Oct 2014 16:32:41 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 13 Oct 2014 07:37:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,711,1406617200"; d="scan'208";a="588053845" Received: from gklab-18-011.igk.intel.com ([10.102.18.11]) by orsmga001.jf.intel.com with ESMTP; 13 Oct 2014 07:38:41 -0700 From: miroslaw.walukiewicz@intel.com To: dev@dpdk.org Date: Mon, 13 Oct 2014 10:38:40 -0400 Message-ID: <20141013143840.19211.79771.stgit@gklab-18-011.igk.intel.com> In-Reply-To: <20141013143834.19211.44077.stgit@gklab-18-011.igk.intel.com> References: <20141013143834.19211.44077.stgit@gklab-18-011.igk.intel.com> User-Agent: StGit/0.17-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [dpdk-dev] [PATCH 2/3] pmd: add new header containing TCP offload specific definitions 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: Mon, 13 Oct 2014 14:32:43 -0000 From: Miroslaw Walukiewicz The function for computing initial TCP header checksum. The file is common for both i40e and ixgbe PMD drivers Signed-off-by: Mirek Walukiewicz --- 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 + +#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_ */