From patchwork Tue Aug 1 13:00:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 109160 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp1465694qge; Tue, 1 Aug 2017 06:00:37 -0700 (PDT) X-Received: by 10.55.99.14 with SMTP id x14mr25969884qkb.331.1501592437229; Tue, 01 Aug 2017 06:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501592437; cv=none; d=google.com; s=arc-20160816; b=XO5QVWDXMLaXVJyXqttKk9K2QOJua5ZY/sssrGLifxhG2/g/wENC2/XNbfOoIjqLi9 8d9DyQJ2uxeIjTL3695GFoZ2AxE9BuqnaONMyAkyJMwTJcQ+hXwcVj41GykB78dtOA0f O7BYkPTpDytivdagUgAlGlknSN6ky3LjRe9IgN9+gHoWoBAOvvSyMylfA6b1XNMlD6x7 oh1Cscq0OckxwgJ5HhGP5W6HHe/pJtHXOrhuw4inn+nC82V6+V/tIQz6Or9T7DEbOV8E ydSIJJSHJEYF7Gxa9tHWyfu8qnYDUvFlUSKcJE8exqxQt319JGITBHHkmw1m1Gs+JThi 6URw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=yg8Ave9GJKMnPj+rBgRGe1TTBk8/FIgZbDYveid1tc4=; b=FAc47FDk1uO3D3rDLUyAXhRDi3rGn6kGukk1UmzDMICWeKllVC+w78K3qaF8Yo88M6 tUobZGIghIRBPiXRvveKa9yn8i+pB0i8WwFOgz3vdmSW+4csP9LzCtSqOYcTNK20Kfj/ PoMK7OeTG3DbrUXpGdiOJOIwj7ceMXawTU3zZauT9te3glLaYZBaO7h57LL1vSZsJeyb HN9HWe/1qWYvS5/uGSm8YTQjyR/njy87vG93t0QOoZNoOSHPslc/MgIEoIJlW05NQvmV 4sNZ9R4+5jYvFhd8YCtwArbwdTCY9/iO7J+KHRPtGm76TsUMXLBJgBAbupU/ljJXajog VqBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q19si22633552qke.344.2017.08.01.06.00.36; Tue, 01 Aug 2017 06:00:37 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id BF312644D0; Tue, 1 Aug 2017 13:00:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, URIBL_BLOCKED, URIBL_SBL, URIBL_SBL_A autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id BAE626446F; Tue, 1 Aug 2017 13:00:31 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 8FA42644CB; Tue, 1 Aug 2017 13:00:28 +0000 (UTC) Received: from forward2p.cmail.yandex.net (forward2p.cmail.yandex.net [77.88.31.17]) by lists.linaro.org (Postfix) with ESMTPS id E27C36446F for ; Tue, 1 Aug 2017 13:00:25 +0000 (UTC) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::25]) by forward2p.cmail.yandex.net (Yandex) with ESMTP id ED252213A6 for ; Tue, 1 Aug 2017 16:00:23 +0300 (MSK) Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp1o.mail.yandex.net (Yandex) with ESMTP id E259F1300D72 for ; Tue, 1 Aug 2017 16:00:20 +0300 (MSK) Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Ccurv0bJo7-0ItGUxic; Tue, 01 Aug 2017 16:00:18 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 1 Aug 2017 16:00:04 +0300 Message-Id: <1501592406-28838-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501592406-28838-1-git-send-email-odpbot@yandex.ru> References: <1501592406-28838-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 100 Subject: [lng-odp] [PATCH API-NEXT v1 1/3] linux-generic: add toeplitz hash algorithm X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Balasubramanian Manoharan Adds toeplitz hash algorithm implementation for RSS hashing Signed-off-by: Balasubramanian Manoharan --- /** Email created from pull request 100 (bala-manoharan:cls-queue-hashing3) ** https://github.com/Linaro/odp/pull/100 ** Patch: https://github.com/Linaro/odp/pull/100.patch ** Base sha: c16f1363303cd5fc11324acbc4dfebe0a9680a41 ** Merge commit sha: 28aa7c613703fab9c13fd1a88f8a9eefa4d0a2cc **/ platform/linux-generic/Makefile.am | 1 + platform/linux-generic/include/protocols/thash.h | 114 +++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 platform/linux-generic/include/protocols/thash.h diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index f43e14be..cfccaa98 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -206,6 +206,7 @@ noinst_HEADERS = \ ${srcdir}/include/protocols/ip.h \ ${srcdir}/include/protocols/ipsec.h \ ${srcdir}/include/protocols/tcp.h \ + ${srcdir}/include/protocols/thash.h \ ${srcdir}/include/protocols/udp.h \ ${srcdir}/Makefile.inc diff --git a/platform/linux-generic/include/protocols/thash.h b/platform/linux-generic/include/protocols/thash.h new file mode 100644 index 00000000..82c318e1 --- /dev/null +++ b/platform/linux-generic/include/protocols/thash.h @@ -0,0 +1,114 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP Toeplitz hash function + */ + +#ifndef ODPH_THASH_H_ +#define ODPH_THASH_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** rss data type */ +typedef union { + uint8_t u8[40]; + uint32_t u32[10]; +} rss_key; + +/** IPv4 tuple + * + */ +typedef struct thash_ipv4_tuple { + uint32_t src_addr; + uint32_t dst_addr; + union { + struct { + uint16_t sport; + uint16_t dport; + }; + uint32_t sctp_tag; + }; +} thash_ipv4_tuple_t; + +typedef struct thash_ipv6_tuple { + _odp_ipv6_addr_t src_addr; + _odp_ipv6_addr_t dst_addr; + union { + struct { + uint16_t sport; + uint16_t dport; + }; + uint32_t sctp_tag; + }; +} thash_ipv6_tuple_t; + +#define ODP_THASH_V4_L4_LEN (sizeof(thash_ipv4_tuple_t) / 4) + +#define ODP_THASH_V4_L3_LEN ((sizeof(thash_ipv4_tuple_t) - \ + sizeof(((thash_ipv4_tuple_t *)0)->sctp_tag)) / 4) + +#define ODP_THASH_V6_L4_LEN (sizeof(thash_ipv6_tuple_t) / 4) + +#define ODP_THASH_V6_L3_LEN ((sizeof(thash_ipv6_tuple_t) - \ + sizeof(((thash_ipv6_tuple_t *)0)->sctp_tag)) / 4) + +typedef union { + thash_ipv4_tuple_t v4; + thash_ipv6_tuple_t v6; +} thash_tuple_t; + +static inline +void thash_load_ipv6_addr(const _odp_ipv6hdr_t *ipv6, + thash_tuple_t *tuple) +{ + int i; + + for (i = 0; i < 4; i++) { + *(tuple->v6.src_addr.u32 + i) = + odp_be_to_cpu_32(*(ipv6->src_addr.u32 + i)); + + *(tuple->v6.dst_addr.u32 + i) = + odp_be_to_cpu_32(*(ipv6->dst_addr.u32 + i)); + } +} + +static inline +uint32_t thash_softrss(uint32_t *tuple, uint8_t len, + const rss_key key) +{ + uint32_t i, j, ret; + + ret = 0; + for (j = 0; j < len; j++) { + for (i = 0; i < 32; i++) { + if (tuple[j] & (1 << (31 - i))) { + ret ^= odp_cpu_to_be_32(((const uint32_t *) + key.u32)[j]) << i | (uint32_t)((uint64_t) + (odp_cpu_to_be_32(((const uint32_t *)key.u32) + [j + 1])) >> (32 - i)); + } + } + } + + return ret; +} + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif