From patchwork Fri Jul 14 09:12:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 107739 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp634906qge; Fri, 14 Jul 2017 02:12:26 -0700 (PDT) X-Received: by 10.237.51.3 with SMTP id u3mr10249209qtd.155.1500023546252; Fri, 14 Jul 2017 02:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500023546; cv=none; d=google.com; s=arc-20160816; b=uYW4enGndWF8RsT7dANCo4ILJgQWCkRPBfPiVikqz8AxYbSdvMoiGKvz0FMWt4PDMn xMO+vJEUejTkWgQABHBbz6vm4aediujeoBqpruz75Ie9ECWK9DJ34Zku3XzSjSvakwHE u2F7R3KAyLBJFEsweh3j8g2aZaxwtsR2w3LN4JUaqHDyO42pZd9fGsjtrbK5EPOtgI5n ct1uqaIEsim1Ww3x4cH9K1HPrIP9kYN+omFEq0RLIVNz9fd/iyiPMqxBO8P1G1qc/T0b DYCUhKz690e4aKFhpvSedPmFxMq9LBnp//DbXOS7A26RznfZmJgOOgOxCQKUvtnQDewo 3RfA== 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:message-id:date:to:from :delivered-to:arc-authentication-results; bh=LRPD9Q+DOdGH+il+1U0MIaNadufGfhtpsJuoM1GiaL8=; b=Y6ITizEiE5jIr3nGtXMOZO7bZe+SJ5ppL9/H590TPFgJ3MUPapeiPsayJTDv/hVDyM tyJGZ4suYEzdTvPYoBq6WeBDwrFRWP+pHaBX2ueGL5xclIksHz1BKGY/xYtO6QaEe4wT 2mUuch96wZP9gsBlOTxum5qhAtL4CWPYNzfCXVuFOrwb63xYSeeEpvnDvLMhCiWklfnt knFGrA1ZuF01TwZNfJg4LJlPfBZ/Ca0HfBOCp4nH+vJ+bJXJukZSR8JAOdMAYf08NsPg up4Bhbn453vxI3RZjEAS/yeJhgJmIBLWY7sPiFAG3dyJwDNw1joxW8P0/aAdoseNRzxa 4Hew== 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 2si7178610qki.248.2017.07.14.02.12.26; Fri, 14 Jul 2017 02:12:26 -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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id ECA9965BD3; Fri, 14 Jul 2017 09:12:25 +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.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, URIBL_BLOCKED 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 4103060B0F; Fri, 14 Jul 2017 09:12:20 +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 646EB60B0E; Fri, 14 Jul 2017 09:12:18 +0000 (UTC) Received: from mail-pg0-f51.google.com (mail-pg0-f51.google.com [74.125.83.51]) by lists.linaro.org (Postfix) with ESMTPS id 2EFF860B0E for ; Fri, 14 Jul 2017 09:12:17 +0000 (UTC) Received: by mail-pg0-f51.google.com with SMTP id t186so43106581pgb.1 for ; Fri, 14 Jul 2017 02:12:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LRPD9Q+DOdGH+il+1U0MIaNadufGfhtpsJuoM1GiaL8=; b=ejntIco5+q41FhDzPqNgQrYh59S/Wt9PN4C/ShvKsMjIdzF7nDYKMxzduS1cXrmFo9 siVmCGp1ahD1Hm0WElWamCNBl7vMKinh0k4tofkL5ScPmQJ7b6ojcawJhgYwx5jccwpg QPuD7X+2yUsEvlwn2I3JRpTVNe+1h99kojA4m4xHzF6HRT4FohS/nCYj4Be+NbhnKZtG C8+Mk7H3sXgOTt2A4T6iNt0RLN51KuNZQ4J5a7Dwy8v6BpLISXib5v5TaNrhX6Hoc0AF Esnx93PRoxklRAqKlPfkvn+yL5ymIeOVVpwWb4xvN/FbkMllE3dOOOhVvD6bFw9/3Uom +U4Q== X-Gm-Message-State: AIVw110a6/TMnAWIZ7dKDumagGfMSuai/JsF4ldjPA2Dhe34q9GwtfnN KICMAll+i0QLtA9gn9cw1H6k X-Received: by 10.98.178.15 with SMTP id x15mr4226164pfe.75.1500023536211; Fri, 14 Jul 2017 02:12:16 -0700 (PDT) Received: from cavium-desktop.caveonetworks.com ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id s9sm17381303pfe.67.2017.07.14.02.12.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 02:12:15 -0700 (PDT) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Fri, 14 Jul 2017 14:42:08 +0530 Message-Id: <1500023530-29025-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.7.9.5 Subject: [lng-odp] [RFC/API-NEXTv3 1/3] api: classification: add support for packet hashing in classification 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" Enable packet hashing per CoS to be able to distribute incoming packets to multiple queues linked with a CoS. Signed-off-by: Balasubramanian Manoharan --- include/odp/api/spec/classification.h | 96 +++++++++++++++++++++++++++++++-- include/odp/api/spec/packet_io.h | 21 ++++++++ 2 files changed, 112 insertions(+), 5 deletions(-) -- 1.7.9.5 diff --git a/include/odp/api/spec/classification.h b/include/odp/api/spec/classification.h index 39831b2..d31965e 100644 --- a/include/odp/api/spec/classification.h +++ b/include/odp/api/spec/classification.h @@ -4,7 +4,6 @@ * SPDX-License-Identifier: BSD-3-Clause */ - /** * @file * @@ -19,12 +18,13 @@ extern "C" { #endif +#include +#include /** @defgroup odp_classification ODP CLASSIFICATION * Classification operations. * @{ */ - /** * @typedef odp_cos_t * ODP Class of service handle @@ -126,6 +126,19 @@ typedef struct odp_cls_capability_t { /** Maximum number of CoS supported */ unsigned max_cos; + /* support mode for plain queue */ + odp_support_t plain_queue; + + /* support mode for sched queue */ + odp_support_t sched_queue; + + /** Maximun number of queue supported per CoS + * if the value is 1, then hashing is not supported*/ + unsigned max_queue_supported; + + /** Protocol header combination supported for Hashing */ + odp_pktin_hash_proto_t hash_supported; + /** A Boolean to denote support of PMR range */ odp_bool_t pmr_range_supported; } odp_cls_capability_t; @@ -164,9 +177,40 @@ typedef enum { * Used to communicate class of service creation options */ typedef struct odp_cls_cos_param { - odp_queue_t queue; /**< Queue associated with CoS */ - odp_pool_t pool; /**< Pool associated with CoS */ - odp_cls_drop_t drop_policy; /**< Drop policy associated with CoS */ + /* Number of queues to be linked to this CoS. + * If the number is greater than 1 then hashing has to be + * configured. If number is equal to 1 then hashing is disabled + * and queue has to be configured by the application. + * When hashing is enabled the queues are created by the implementation + * then application need not configure any queue to this CoS. + * Depening on the implementation this number might be rounded-off to + * nearest supported value (e.g power of 2) + * */ + uint32_t num_queue; + + /** Queue type */ + odp_queue_type_t queue_type; + + /** ODP Queue dequeue mode + * This value is valid only for PLAIN queue types */ + odp_queue_op_mode_t deq_mode; + + /** Schedule parameters for the queue created */ + odp_schedule_param_t sched_param; + + /* Protocol header fields which are included in packet input + * hash calculation */ + odp_hash_proto_t hash_proto; + + /* If hashing is disabled, then application has to configure + * this queue and packets are delivered to this queue */ + odp_queue_t queue; + + /* Pool associated with CoS */ + odp_pool_t pool; + + /* Drop policy associated with CoS */ + odp_cls_drop_t drop_policy; } odp_cls_cos_param_t; /** @@ -209,6 +253,23 @@ int odp_cls_capability(odp_cls_capability_t *capability); odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param); /** + * Queue hash result + * Returns the queue within a CoS in which a particular packet will be enqueued + * based on the packet parameters and hash protocol field configured with the + * class of service. + * + * @param cos class of service + * @param packet Packet handle + * + * @retval Returns the queue handle on which this packet will be + * enqueued. + * @retval ODP_QUEUE_INVALID for error case + * + * @note The packet has to be updated with valid header pointers L2, L3 and L4. + */ +odp_queue_t odp_queue_hash_result(odp_cos_t cos, odp_packet_t packet); + +/** * Discard a class-of-service along with all its associated resources * * @param[in] cos_id class-of-service instance. @@ -245,6 +306,31 @@ int odp_cos_queue_set(odp_cos_t cos_id, odp_queue_t queue_id); odp_queue_t odp_cos_queue(odp_cos_t cos_id); /** + * Get the number of queues linked with the specific class-of-service + * + * @param cos_id class-of-service instance. + * + * @return Number of queues linked with the class-of-service. + */ +uint32_t odp_cos_num_queue(odp_cos_t cos_id); + +/** + * Get the list of queue associated with the specific class-of-service + * + * @param[in] cos_id class-of-service instance. + * + * @param[out] queue Array of queue handles associated + * with the class-of-service. + * + * @param[in] num Maximum number of queue handles to output. + * + * @return Number of queues linked with CoS + * @retval <0 on failure + */ +uint32_t odp_cos_queue_multi(odp_cos_t cos_id, + odp_queue_t queue[], uint32_t num); + +/** * Assign packet drop policy for specific class-of-service * * @param[in] cos_id class-of-service instance. diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h index 8802089..1a40a1f 100644 --- a/include/odp/api/spec/packet_io.h +++ b/include/odp/api/spec/packet_io.h @@ -131,6 +131,27 @@ typedef union odp_pktin_hash_proto_t { } odp_pktin_hash_proto_t; /** + * Packet hash protocols + * + * The list of protocol header field combination in enum format, which are + * included in packet hash calculation. + */ +typedef enum odp_hash_proto_t { + /** IPv4 address and UDP port numbers */ + ODP_HASH_PROTO_IPV4_UDP, + /** IPv4 addresses and TCP port numbers */ + ODP_HASH_PROTO_IPV4_TCP, + /** IPv4 addresses */ + ODP_HASH_PROTO_IPV4, + /** IPv6 addresses and UDP port numbers */ + ODP_HASH_PROTO_IPV6_UDP, + /** IPv6 addresses and TCP port numbers */ + ODP_HASH_PROTO_IPV6_TCP, + /** IPv6 addresses */ + ODP_HASH_PROTO_IPV6 +} odp_hash_proto_t; + +/** * Packet IO operation mode */ typedef enum odp_pktio_op_mode_t { From patchwork Fri Jul 14 09:12:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 107740 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp635639qge; Fri, 14 Jul 2017 02:13:09 -0700 (PDT) X-Received: by 10.55.145.6 with SMTP id t6mr9655830qkd.101.1500023589042; Fri, 14 Jul 2017 02:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500023589; cv=none; d=google.com; s=arc-20160816; b=cV6pvGIKQgpkAivqbiyetqwaR4kKQfGESfttzMWq+o9KxQXJbLMyDmgF2XcJkKXuWA 0NVKe1Cug1PdM9zUHz9cAY5PVZfKn4qKpf1C7hcqvyglZOFq8XQ7Jlguy6ePHuPmxUOy FIBJUAqQqLGwHpB2fIVG+ZjZtnQDF68t+PwF2dSjB+8PPz9R/7TvaQGcSHcZ5SJjbOUs 46I6J3NmHu5KkvQiLl7i9Wyk6PwUhyPaVDy3CGzCgE31s8gmvtamSBq0ueqs9y7Te1Uk h3Up9wyJJnB37FXo/V0YjSDNvZjdzbfDTJcQadnKbhIHY6FtyTGafm0McxoRTSqZHHVX tmCg== 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:references:in-reply-to :message-id:date:to:from:delivered-to:arc-authentication-results; bh=JsV1UihKziSf8a0Cwpc8P3OERtmvF3kAOQokhCdRMtY=; b=RivYgUboTqXbasje/hUkAE+gu24coExmjY2ZaVLbe5U93f2G5IZ0+pGkiclBeBHRU0 jTxTISZgKH9XFkEEk9k12U9iOND4NSnuHguhmA3kB5TnjwZZePD8xrHWd1L7z0PFqw9N zohzgEonnjdXsqzH8+TziAUFq7vHmN7FqFP8Bg42Q7DZEwdo/sKvqVdGC2AgH4uZYyqd tmMGmF2W57It/7GzNhj9SdJhty0jkr866o6OHW7LLLrhMaQXaRCjWcSo4nd8oG36Avu4 BmvoHisW67a2q8YFlQgjHMmfpEEeBwZSzUC1WBzdTLoJX3fh1UQtthDs8yCDlr7e67FD Shnw== 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id w65si7010937qte.120.2017.07.14.02.13.08; Fri, 14 Jul 2017 02:13:09 -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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B8A6D65BEE; Fri, 14 Jul 2017 09:13:08 +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=-3.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_WEB, URIBL_BLOCKED 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 1715760BE3; Fri, 14 Jul 2017 09:13:03 +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 9AD5C65BD3; Fri, 14 Jul 2017 09:13:00 +0000 (UTC) Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by lists.linaro.org (Postfix) with ESMTPS id 1DBF360BE4 for ; Fri, 14 Jul 2017 09:12:21 +0000 (UTC) Received: by mail-pf0-f179.google.com with SMTP id c73so42777299pfk.2 for ; Fri, 14 Jul 2017 02:12:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JsV1UihKziSf8a0Cwpc8P3OERtmvF3kAOQokhCdRMtY=; b=YER+hG4Hrn/oot1XE6HD3MtGNk3ww+aCq5k4AX391WAnpa1uwnuJE9UDTv3/vx5QiW 2nuyJ2FfRNZDBIKK92+Rww6Mn2PQ9gCa0W0Md6zrOl8PBFQy7JEmGd2WjZbaTYRojkUz FGieM2/COBH1RPEiTGQp3AQ1jHlBeYUzEwRg+qANRFEdB6TUV7jPANIRzIvc5eeJpYtS +Y4/p7gko4vlWvBYGztW5/ZXNeev7BEXbZ/WrFQEWY4nUexm9sgGrPJPJlYE3Zddz4uT 9eGFTO/ebe/1c4/d5kLeghKTy45Zuhtmr78ta6cWh8CTSCFRe3Um9oWUygip4MCJldZM B77g== X-Gm-Message-State: AIVw112VAkp8pK7cDjWQPwrXv6quS0wdMYDLyKQp93Wlyd0cB1liEAF4 zFMfvOCvFInWMfWQFssAPYvW X-Received: by 10.99.112.92 with SMTP id a28mr13358987pgn.151.1500023540223; Fri, 14 Jul 2017 02:12:20 -0700 (PDT) Received: from cavium-desktop.caveonetworks.com ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id s9sm17381303pfe.67.2017.07.14.02.12.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 02:12:19 -0700 (PDT) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Fri, 14 Jul 2017 14:42:09 +0530 Message-Id: <1500023530-29025-2-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1500023530-29025-1-git-send-email-bala.manoharan@linaro.org> References: <1500023530-29025-1-git-send-email-bala.manoharan@linaro.org> Subject: [lng-odp] [RFC/API-NEXTv3 2/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" Signed-off-by: Balasubramanian Manoharan --- platform/linux-generic/include/protocols/thash.h | 108 ++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 platform/linux-generic/include/protocols/thash.h -- 1.7.9.5 diff --git a/platform/linux-generic/include/protocols/thash.h b/platform/linux-generic/include/protocols/thash.h new file mode 100644 index 0000000..fe141e3 --- /dev/null +++ b/platform/linux-generic/include/protocols/thash.h @@ -0,0 +1,108 @@ +/* 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 + +/** 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 { + uint8_t src_addr[16]; + uint8_t dst_addr[16]; + 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++) { + *((uint32_t *)tuple->v6.src_addr + i) = + odp_be_to_cpu_32(*((const uint32_t *)ipv6->src_addr.u32 + i)); + + *((uint32_t *)tuple->v6.dst_addr + i) = + odp_be_to_cpu_32(*((const uint32_t *)ipv6->dst_addr.u32 + i)); + } +} + +static inline +uint32_t thash_softrss(uint32_t *tuple, uint8_t len, + const uint8_t *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)[j]) << i | (uint32_t)((uint64_t) + (odp_cpu_to_be_32(((const uint32_t *)key) + [j + 1])) >> (32 - i)); + } + } + } + + return ret; +} + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif From patchwork Fri Jul 14 09:12:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 107741 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp636163qge; Fri, 14 Jul 2017 02:13:38 -0700 (PDT) X-Received: by 10.237.35.174 with SMTP id j43mr10599010qtc.215.1500023618815; Fri, 14 Jul 2017 02:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500023618; cv=none; d=google.com; s=arc-20160816; b=v07fY2qDu8XIpxcezmX7HsMzeuxjiQKXwkQNBKLygZbFYobACSeceLFxUWSaMcD47Q HcEhJwlCzwPugnQjZqkYUhiM0ZtJt35Tpy7K0NYjCF5qyCuhHqKG0KTLUGf2kIsMM1ks abw31BvuGA+aQQcDeQq/STx8NefKYxbPq7A99Vhpk4o8OsDBD130daFjFdvBWNNyVMsf WCgWcUaphrQVO4MpC7sBdmHSStxUsTHbkTTgIy6xWumcqhcJowQhVoPww2yRzEGh4q8X 5c4ftxyHKdC48VCTHne59QQPv9TJK0s3gZ2HdDI5dhxWf6wM7Ny9UheHpz6PebV6tC4Z HBng== 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:references:in-reply-to :message-id:date:to:from:delivered-to:arc-authentication-results; bh=VyyE/ZPaQUjAftP5dSRFmc9TrzF0XnhmiI6kL249x3Y=; b=AyhrVtzRwoycpKTP8qfOP4EN4SAN8dqyJ0NgHhh/cT07kDgnY9K5TPAbH7ywT956Wa zx4YvPNc2K+/sHQbCq4Xg1iLySasEX6w4AOciEnMA403dcg15u6ZzgnDJD+ZyVIBecI6 Wvi5vlz3N/iT7KS5jAn6VTGzQiK6Y673OXM0RMnuL9g7U+rmb/vHmP/mnovtjz+Q438V mFGE8F8z8uLr+zeT0qrRO0WGwr/iPf1SAum2S5qluM3sa4O3mKAz+EsxWlhbby+6WGUX OxKWBI+OFICnvGK9XoJS7Nv6ivUTCqFLEs3eHAg4RmyAKEMx+eHobD17i0RIHmLkix3e iaWA== 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id s185si7078918qkc.26.2017.07.14.02.13.38; Fri, 14 Jul 2017 02:13:38 -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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 6A50A60BE4; Fri, 14 Jul 2017 09:13:38 +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.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, URIBL_BLOCKED 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 97D6D65BC8; Fri, 14 Jul 2017 09:13:08 +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 68E2660BE3; Fri, 14 Jul 2017 09:13:02 +0000 (UTC) Received: from mail-pg0-f49.google.com (mail-pg0-f49.google.com [74.125.83.49]) by lists.linaro.org (Postfix) with ESMTPS id 781EA60C04 for ; Fri, 14 Jul 2017 09:12:23 +0000 (UTC) Received: by mail-pg0-f49.google.com with SMTP id j186so42884889pge.2 for ; Fri, 14 Jul 2017 02:12:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VyyE/ZPaQUjAftP5dSRFmc9TrzF0XnhmiI6kL249x3Y=; b=IeYeT8GD/74QVRVnHketI1cvpqjRj6i33E3+rgKDPaxjMB4MPfsW5Mefh3gxbRPAHm xCkvKcars02zr6rKWt0gcSGbbAUzSzao10q7d3ZjwIwGEKnc48iPsmMgYZVL/BYiVM7J RYZ+XgO1HNvwhbSamvAehcPb4LqMGQUym9DizhtCC6mnGTja94Jj2CVp5IxW8JzJJvwl kH0JGFVLfDcp41tiMODpAY3j9QZYAoy2LF8VQvcAE5nBLGzSnXGxHJjuNZcUubE9F0O7 fep7nQqLG7Ezztg5SVI6zKSR9CKRlKf/UHvZ6rKRn/r/Ntza8zx2RcV8VcWo8d0p0dNm QdiQ== X-Gm-Message-State: AIVw111n3N+bWcwsfSd+JggQRM3vo5+Xsv7ORZEbk5oSMZvHw7wX2TnO Y88fHen9/Fzdyrh/dnyGTiez X-Received: by 10.99.4.6 with SMTP id 6mr13497360pge.126.1500023542441; Fri, 14 Jul 2017 02:12:22 -0700 (PDT) Received: from cavium-desktop.caveonetworks.com ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id s9sm17381303pfe.67.2017.07.14.02.12.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 02:12:21 -0700 (PDT) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Fri, 14 Jul 2017 14:42:10 +0530 Message-Id: <1500023530-29025-3-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1500023530-29025-1-git-send-email-bala.manoharan@linaro.org> References: <1500023530-29025-1-git-send-email-bala.manoharan@linaro.org> Subject: [lng-odp] [RFC/API-NEXTv3 3/3] linux-generic: classification implement packet hashing 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" Signed-off-by: Balasubramanian Manoharan --- .../include/odp_classification_datamodel.h | 20 ++- .../include/odp_classification_internal.h | 4 + platform/linux-generic/odp_classification.c | 182 ++++++++++++++++---- 3 files changed, 176 insertions(+), 30 deletions(-) -- 1.7.9.5 diff --git a/platform/linux-generic/include/odp_classification_datamodel.h b/platform/linux-generic/include/odp_classification_datamodel.h index fbe10cb..279a198 100644 --- a/platform/linux-generic/include/odp_classification_datamodel.h +++ b/platform/linux-generic/include/odp_classification_datamodel.h @@ -46,6 +46,10 @@ extern "C" { /* Max PMR Term bits */ #define ODP_PMR_TERM_BYTES_MAX 16 +#define ODP_COS_QUEUE_MAX 32 + +#define ODP_CLS_QUEUE_GROUP_MAX (ODP_COS_MAX_ENTRY * ODP_COS_QUEUE_MAX) + /** Packet Matching Rule Term Value @@ -85,7 +89,7 @@ typedef struct pmr_term_value { Class Of Service */ struct cos_s { - queue_t queue; /* Associated Queue */ + odp_queue_t queue; /* Associated Queue */ odp_pool_t pool; /* Associated Buffer pool */ union pmr_u *pmr[ODP_PMR_PER_COS_MAX]; /* Chained PMR */ union cos_u *linked_cos[ODP_PMR_PER_COS_MAX]; /* Chained CoS with PMR*/ @@ -94,7 +98,12 @@ struct cos_s { size_t headroom; /* Headroom for this CoS */ odp_spinlock_t lock; /* cos lock */ odp_atomic_u32_t num_rule; /* num of PMRs attached with this CoS */ + bool queue_group; + odp_hash_proto_t hash_proto; + uint32_t num_queue; + odp_queue_param_t queue_param; char name[ODP_COS_NAME_LEN]; /* name */ + uint8_t index; }; typedef union cos_u { @@ -122,6 +131,15 @@ typedef union pmr_u { uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pmr_s))]; } pmr_t; +typedef struct _cls_queue_grp_tbl_s { + odp_queue_t queue[ODP_CLS_QUEUE_GROUP_MAX]; +} _cls_queue_grp_tbl_s; + +typedef union _cls_queue_grp_tbl_t { + _cls_queue_grp_tbl_s s; + uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(_cls_queue_grp_tbl_s))]; +} _cls_queue_grp_tbl_t; + /** L2 QoS and CoS Map diff --git a/platform/linux-generic/include/odp_classification_internal.h b/platform/linux-generic/include/odp_classification_internal.h index 78eaac9..f2ac608 100644 --- a/platform/linux-generic/include/odp_classification_internal.h +++ b/platform/linux-generic/include/odp_classification_internal.h @@ -138,6 +138,10 @@ Otherwise. **/ int verify_pmr(pmr_t *pmr, const uint8_t *pkt_addr, odp_packet_hdr_t *pkt_hdr); +uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr, + odp_hash_proto_t hash_proto, + const uint8_t *base); + #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index cc08b9f..1966c51 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,16 @@ static cos_tbl_t *cos_tbl; static pmr_tbl_t *pmr_tbl; +static _cls_queue_grp_tbl_t *queue_grp_tbl; + +const uint8_t default_rss[] = { + 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, + 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, + 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, + 0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c, + 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa, +}; + cos_t *get_cos_entry_internal(odp_cos_t cos_id) { @@ -45,6 +56,7 @@ int odp_classification_init_global(void) { odp_shm_t cos_shm; odp_shm_t pmr_shm; + odp_shm_t queue_grp_shm; int i; cos_shm = odp_shm_reserve("shm_odp_cos_tbl", @@ -89,8 +101,22 @@ int odp_classification_init_global(void) LOCK_INIT(&pmr->s.lock); } + queue_grp_shm = odp_shm_reserve("shm_odp_cls_queue_grp_tbl", + sizeof(_cls_queue_grp_tbl_t), + sizeof(queue_entry_t *), 0); + + if (queue_grp_shm == ODP_SHM_INVALID) { + ODP_ERR("shm allocation failed for queue_grp_tbl"); + goto error_queue_grp; + } + + queue_grp_tbl = odp_shm_addr(queue_grp_shm); + memset(queue_grp_tbl, 0, sizeof(_cls_queue_grp_tbl_t)); + return 0; +error_queue_grp: + odp_shm_free(queue_grp_shm); error_pmr: odp_shm_free(pmr_shm); error_cos: @@ -124,6 +150,11 @@ void odp_cls_cos_param_init(odp_cls_cos_param_t *param) param->queue = ODP_QUEUE_INVALID; param->pool = ODP_POOL_INVALID; param->drop_policy = ODP_COS_DROP_NEVER; + param->num_queue = 1; + param->deq_mode = ODP_QUEUE_OP_MT; + param->sched_param.prio = ODP_SCHED_PRIO_DEFAULT; + param->sched_param.sync = ODP_SCHED_SYNC_PARALLEL; + param->sched_param.group = ODP_SCHED_GROUP_ALL; } void odp_cls_pmr_param_init(odp_pmr_param_t *param) @@ -157,21 +188,22 @@ int odp_cls_capability(odp_cls_capability_t *capability) odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param) { int i, j; - queue_t queue; + odp_queue_t queue; odp_cls_drop_t drop_policy; + cos_t *cos; + uint32_t tbl_index; /* Packets are dropped if Queue or Pool is invalid*/ - if (param->queue == ODP_QUEUE_INVALID) - queue = QUEUE_NULL; - else - queue = queue_fn->from_ext(param->queue); + if (param->num_queue > ODP_COS_QUEUE_MAX) + return ODP_COS_INVALID; drop_policy = param->drop_policy; for (i = 0; i < ODP_COS_MAX_ENTRY; i++) { - LOCK(&cos_tbl->cos_entry[i].s.lock); - if (0 == cos_tbl->cos_entry[i].s.valid) { - char *cos_name = cos_tbl->cos_entry[i].s.name; + cos = &cos_tbl->cos_entry[i]; + LOCK(&cos->s.lock); + if (0 == cos->s.valid) { + char *cos_name = cos->s.name; if (name == NULL) { cos_name[0] = 0; @@ -180,20 +212,46 @@ odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param) cos_name[ODP_COS_NAME_LEN - 1] = 0; } for (j = 0; j < ODP_PMR_PER_COS_MAX; j++) { - cos_tbl->cos_entry[i].s.pmr[j] = NULL; - cos_tbl->cos_entry[i].s.linked_cos[j] = NULL; + cos->s.pmr[j] = NULL; + cos->s.linked_cos[j] = NULL; } - cos_tbl->cos_entry[i].s.queue = queue; - cos_tbl->cos_entry[i].s.pool = param->pool; - cos_tbl->cos_entry[i].s.headroom = 0; - cos_tbl->cos_entry[i].s.valid = 1; - cos_tbl->cos_entry[i].s.drop_policy = drop_policy; - odp_atomic_init_u32(&cos_tbl->cos_entry[i] - .s.num_rule, 0); - UNLOCK(&cos_tbl->cos_entry[i].s.lock); + + if (param->num_queue > 1) { + odp_queue_param_init(&cos->s.queue_param); + cos->s.queue_group = true; + cos->s.queue = ODP_QUEUE_INVALID; + cos->s.hash_proto = param->hash_proto; + cos->s.num_queue = param->num_queue; + cos->s.queue_param.type = + param->queue_type; + cos->s.queue_param.sched = + param->sched_param; + tbl_index = cos->s.index * ODP_COS_QUEUE_MAX; + for (j = 0; j < ODP_COS_QUEUE_MAX; j++) { + queue = odp_queue_create(NULL, &cos->s. + queue_param); + if (queue == ODP_QUEUE_INVALID) { + UNLOCK(&cos->s.lock); + return ODP_COS_INVALID; + } + queue_grp_tbl->s.queue[tbl_index + j] = + queue; + } + + } else { + cos->s.queue = param->queue; + } + + cos->s.pool = param->pool; + cos->s.headroom = 0; + cos->s.valid = 1; + cos->s.drop_policy = drop_policy; + odp_atomic_init_u32(&cos->s.num_rule, 0); + cos->s.index = i; + UNLOCK(&cos->s.lock); return _odp_cast_scalar(odp_cos_t, i); } - UNLOCK(&cos_tbl->cos_entry[i].s.lock); + UNLOCK(&cos->s.lock); } ODP_ERR("ODP_COS_MAX_ENTRY reached"); @@ -263,10 +321,7 @@ int odp_cos_queue_set(odp_cos_t cos_id, odp_queue_t queue_id) } /* Locking is not required as intermittent stale data during CoS modification is acceptable*/ - if (queue_id == ODP_QUEUE_INVALID) - cos->s.queue = QUEUE_NULL; - else - cos->s.queue = queue_fn->from_ext(queue_id); + cos->s.queue = queue_id; return 0; } @@ -279,10 +334,7 @@ odp_queue_t odp_cos_queue(odp_cos_t cos_id) return ODP_QUEUE_INVALID; } - if (cos->s.queue == QUEUE_NULL) - return ODP_QUEUE_INVALID; - - return queue_fn->to_ext(cos->s.queue); + return cos->s.queue; } int odp_cos_drop_set(odp_cos_t cos_id, odp_cls_drop_t drop_policy) @@ -830,6 +882,8 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base, odp_packet_hdr_t *pkt_hdr) { cos_t *cos; + uint32_t tbl_index; + uint32_t hash; packet_parse_reset(pkt_hdr); packet_set_len(pkt_hdr, pkt_len); @@ -841,16 +895,86 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base, if (cos == NULL) return -EINVAL; - if (cos->s.queue == QUEUE_NULL || cos->s.pool == ODP_POOL_INVALID) + if (cos->s.queue == ODP_QUEUE_INVALID || + cos->s.pool == ODP_POOL_INVALID) return -EFAULT; *pool = cos->s.pool; pkt_hdr->p.input_flags.dst_queue = 1; - pkt_hdr->dst_queue = cos->s.queue; + if (!cos->s.queue_group) { + pkt_hdr->dst_queue = queue_fn->from_ext(cos->s.queue); + return 0; + } + + hash = packet_rss_hash(pkt_hdr, cos->s.hash_proto, base); + /* ODP_COS_QUEUE_MAX is a power of 2 */ + hash = hash & (ODP_COS_QUEUE_MAX - 1); + tbl_index = (cos->s.index * ODP_COS_QUEUE_MAX) + hash; + pkt_hdr->dst_queue = queue_fn->from_ext(queue_grp_tbl-> + s.queue[tbl_index]); return 0; } +uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr, + odp_hash_proto_t hash_proto, + const uint8_t *base) +{ + thash_tuple_t tuple; + const _odp_ipv4hdr_t *ipv4; + const _odp_udphdr_t *udp; + const _odp_tcphdr_t *tcp; + uint32_t hash; + + hash = 0; + switch (hash_proto) { + case ODP_HASH_PROTO_IPV4_UDP: /** IPV4 + UDP */ + ipv4 = (const _odp_ipv4hdr_t *)base + pkt_hdr->p.l3_offset; + udp = (const _odp_udphdr_t *)base + pkt_hdr->p.l4_offset; + tuple.v4.src_addr = ipv4->src_addr; + tuple.v4.dst_addr = ipv4->dst_addr; + tuple.v4.sport = udp->src_port; + tuple.v4.dport = udp->dst_port; + hash = thash_softrss((uint32_t *)&tuple, + ODP_THASH_V4_L4_LEN, default_rss); + break; + + case ODP_HASH_PROTO_IPV4_TCP: /** IPV4 + TCP */ + ipv4 = (const _odp_ipv4hdr_t *)base + pkt_hdr->p.l3_offset; + tcp = (const _odp_tcphdr_t *)base + pkt_hdr->p.l4_offset; + tuple.v4.src_addr = ipv4->src_addr; + tuple.v4.dst_addr = ipv4->dst_addr; + tuple.v4.sport = tcp->src_port; + tuple.v4.dport = tcp->dst_port; + hash = thash_softrss((uint32_t *)&tuple, + ODP_THASH_V4_L4_LEN, default_rss); + + break; + case ODP_HASH_PROTO_IPV4: /** IPV4 */ + ipv4 = (const _odp_ipv4hdr_t *)base + pkt_hdr->p.l3_offset; + tuple.v4.src_addr = ipv4->src_addr; + tuple.v4.dst_addr = ipv4->dst_addr; + hash = thash_softrss((uint32_t *)&tuple, + ODP_THASH_V4_L3_LEN, default_rss); + + break; + + case ODP_HASH_PROTO_IPV6_UDP: /** IPV6 + UDP */ + break; + + case ODP_HASH_PROTO_IPV6_TCP: /** IPV6 + TCP */ + break; + + case ODP_HASH_PROTO_IPV6: /** IPV6 */ + break; + + default: + break; + } + + return hash; +} + cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, const uint8_t *pkt_addr, odp_packet_hdr_t *hdr) {