From patchwork Thu Jul 27 13:08:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 108846 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2369103qge; Thu, 27 Jul 2017 10:49:57 -0700 (PDT) X-Received: by 10.237.34.39 with SMTP id n36mr7111951qtc.258.1501177797675; Thu, 27 Jul 2017 10:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501177797; cv=none; d=google.com; s=arc-20160816; b=OpzxbVJ86kvUtiu+X0wS+x1009tRBsS9cZ/Na1+HJ8QFjH7LrZziIi/K4XqaACBcvV BT+pItQfL6fQs9EOtRDXoq1L4lwaueZ/la95yRoCdkFuZJ5pn1PpuqMRiK22zfZuAA0H TXieXVW9quG6dHRko6ZNTSdchWzcXk5NsXh1oLasksVSFBzILHwq7W7BxwJpdOLEoDr/ 0IIo3S/qTyI6/SA4jBtWOJ7ypSVKGidbHQTfPLu+bdfd1y/o+BX04vsS7JuLInhptTeW Oyg3r/1hBXT3eSllh5VuwglyMb0q+nMJVvsmuIeERk/ow1HjC73h41U8543OhN32Vhyd Q92Q== 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=1f+uKoqFc1p43fjKxAwvxnJ1ZAHdHUEyBSaWTitJx/M=; b=wAmQ07o5pqvH7YOMG99jFBqQotuCuh64YztCJoEceLzJxJUCAFePSB8GAzczm+XaEG T9QJRRwOeoVZGMKp3pHPWvRMASkDXEavPanBGGBx1S82HMdcAgkx3LeKQ0qFpvyxP7xx EpuuHqlP7ksWIP0nZnmANa0IQ2pbMXbwFUY6zRf8+OqpSc5g5EJju1ynAh+OopADoiDR RcPmFaXc2Qf1YwafaIbYnm8v+prXWIrR8tyNy6ABCnznTbvVNzpRG4hCc4YBWJfe2tlV PRZKmATagbUYO0x37iRtE0hZur8N3EVDEGtBIDQvACFuWCvLCMzdPY7bSke92R9Mlz+b ardg== 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 z123si12525472qkc.122.2017.07.27.10.49.56; Thu, 27 Jul 2017 10:49:57 -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 5993C65C07; Thu, 27 Jul 2017 17:49:56 +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=-2.6 required=5.0 tests=BAYES_00, DATE_IN_PAST_03_06, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_SPAM, 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 A309665BFD; Thu, 27 Jul 2017 17:49:50 +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 5FA4E65BFE; Thu, 27 Jul 2017 17:49:49 +0000 (UTC) Received: from mail-pg0-f43.google.com (mail-pg0-f43.google.com [74.125.83.43]) by lists.linaro.org (Postfix) with ESMTPS id 2CF3565BFA for ; Thu, 27 Jul 2017 17:49:48 +0000 (UTC) Received: by mail-pg0-f43.google.com with SMTP id c14so8265351pgn.0 for ; Thu, 27 Jul 2017 10:49:48 -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=1f+uKoqFc1p43fjKxAwvxnJ1ZAHdHUEyBSaWTitJx/M=; b=ANM0ZsbnPlcI5CnHZP6pE4XxOh2m7huymVGYO0hmgZCfe+f5vkcTA8iem/feZKE1PL uDQzUqWu3qV0Yt35WyJDzMF/PEPbexyth3gp10iXA75+YNisJMve4FZKAJyipEr9PPCk 8AIWbazqO1FPWjDrNsuSTuRLMdpsb+OY7u7ZN6aYLgH+7iiVbA7YZ2n38lGRZxJjkAEp E5DawWlnsKyD/CqoTHrQtLrFnjuHabeaV+qbiVEu4Bg42xBPBXk3U9XDz9sJb+H/r2Ux JJ42hatOPIXAQSuKNLiwzctlJO1g19RPeVg/4iF4s5hUtmPBozYh7QZagnh4rSRd6pS1 iE+Q== X-Gm-Message-State: AIVw113gtqvz6HZjbNYrIOtuBBdSqm9IRXNyqYw6kqYHTnZRoDKYpFoy t1gLgo7ckzv0l8PTgcltM+j6 X-Received: by 10.99.170.75 with SMTP id x11mr4779607pgo.140.1501177787113; Thu, 27 Jul 2017 10:49:47 -0700 (PDT) Received: from bala.domain.name ([117.199.137.21]) by smtp.gmail.com with ESMTPSA id 10sm39229655pfo.134.2017.07.27.10.49.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Jul 2017 10:49:46 -0700 (PDT) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 27 Jul 2017 06:08:21 -0700 Message-Id: <1501160903-25098-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [lng-odp] [API-NEXTv5 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 | 90 +++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 5 deletions(-) -- 1.9.1 diff --git a/include/odp/api/spec/classification.h b/include/odp/api/spec/classification.h index 39831b2..c76555b 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,13 @@ typedef struct odp_cls_capability_t { /** Maximum number of CoS supported */ unsigned max_cos; + /** Maximun number of queue supported per CoS + * if the value is 1, then hashing is not supported*/ + unsigned max_hash_queues; + + /** Protocol header combination supported for Hashing */ + odp_pktin_hash_proto_t hash_protocols; + /** A Boolean to denote support of PMR range */ odp_bool_t pmr_range_supported; } odp_cls_capability_t; @@ -164,9 +171,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 is enabled. + * If number is equal to 1 then hashing is disabled. + * When hashing is enabled the queues are created by the implementation + * and application need not configure any queue to the class of service. + * When hashing is disabled application has to configure the queue to + * the class of service. + * Depening on the implementation this number might be rounded-off to + * nearest supported value (e.g power of 2) + * */ + uint32_t num_queue; + + union { + /* Mapping used when num_queue = 1, hashing is disabled in + * this case and application has to configure this queue and + * packets are delivered to this queue */ + odp_queue_t queue; + + /* Mapping used when num_queue > 1, hashing is enabled in + * this case and queues are created by the implementation */ + struct { + /** Queue parameters */ + odp_queue_param_t queue_param; + + /* Protocol header fields which are included in + * packet input hash calculation */ + odp_pktin_hash_proto_t hash_proto; + }; + }; + /* 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 +247,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_cls_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 +300,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_cls_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_cls_cos_queues(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. From patchwork Thu Jul 27 13:08:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 108847 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2369746qge; Thu, 27 Jul 2017 10:50:33 -0700 (PDT) X-Received: by 10.200.35.215 with SMTP id r23mr7789533qtr.229.1501177833895; Thu, 27 Jul 2017 10:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501177833; cv=none; d=google.com; s=arc-20160816; b=CYaR09i0FlnZ+vNZPOGTr9+eYMI4c9aNN5EdVbvLYMrECWitdBKjs+AHS6AOYky4FH IF20dnucTsZiHJll54/RftkbBtjHgY0QvPwOcLFLGXalMErvtlnInrD+JH5tKlACrKrS y6xEOPFFFYbuQKi2A/eqii+May14ze8jyy15Zy9V8sO5n62ZmbBo+pcdLd1ipe1RTpas UXQmKUZYEr3va1ppRwmHczo2HJ00ZmJ0VV6JzlEQSQwRElE+GvdinMJpH41nMfGtts93 CFEUzkByo3cK0tZgfFdcz13cm4wphIg0KZWkzMpyQmHABKFZgqbgOE7KJQ4UfCVwSxBl eWfg== 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=9hzgRGyQ2eEPDWGwyhrEL1EajRLj6OxfZZ+C/oJtP8c=; b=gUEB4p8CWbcQgIyOIEgFXE2wTOk+mzwS5vtnLXRhZZO76nSIE1ZHqsPgRlFH8wjIyZ 7CHilVFUWzbBc3wMiLafmRCMCZeLC5+xOceceT6yDS8YWxwgjWB0e/PIgytZGwDgr9Og ftWTsaynssN439fmJCuyLlf7+qG9BIPwjSu8Y/Qp7CO0fh02GHRt8zvuFF9sRJ80KzFo 86ED41gbtODFKm1TMPAEPQH5t6XuJyLFeR0Uho97vSxA1J1vyLTRxOsXsOy2CgGgl3Qg bloL2zxYqP1Mh1CVIUZEdpz3wx/dV6PwIzgMm3WmScjjpaoy4nd5/VbIUDwvta2MU6qn tk7g== 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 c37si2029248qtd.212.2017.07.27.10.50.33; Thu, 27 Jul 2017 10:50:33 -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 6CD5865BFA; Thu, 27 Jul 2017 17:50:33 +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.2 required=5.0 tests=BAYES_00, DATE_IN_PAST_03_06, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, 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 9EE4F65BFE; Thu, 27 Jul 2017 17:50:30 +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 E95F765C00; Thu, 27 Jul 2017 17:50:27 +0000 (UTC) Received: from mail-pg0-f45.google.com (mail-pg0-f45.google.com [74.125.83.45]) by lists.linaro.org (Postfix) with ESMTPS id 9510865C00 for ; Thu, 27 Jul 2017 17:49:52 +0000 (UTC) Received: by mail-pg0-f45.google.com with SMTP id 123so100818056pgj.1 for ; Thu, 27 Jul 2017 10:49:52 -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=9hzgRGyQ2eEPDWGwyhrEL1EajRLj6OxfZZ+C/oJtP8c=; b=Z21oxJrgm+/9puB9+/dWCwEU7twnIVXZiv+eOMMA6fButjZyhgpLVzLYGQveuBaH9g k+VZKjirDnwnf3e0RaMxGPE3iOTIG7Mnvuy/2vdaruMgh89zNj0ujT9FJpIVW0qIJJLy 73v8I9OTch2O4ZBPdfiwDcYeLKrd/IcJd+AGH6CbYVdUp6Vc1tywDrjM9tzLRln7dTSY E1lZ1vGX9JWP07tDLLk3JtEMyYxBu9OmKsO3I6jk02cVXkb87zpmmRrEdEEppXklT2s4 51TdoQvUH60HHKIggUySpqkvhEOHi4b+wqBSaqNzxWe6LWdJBILdym0dacISRU+j97XB ulbA== X-Gm-Message-State: AIVw113WLM3CH7bfu0WVDp0dWFbhDGeKx7HvDbKaOeUiuHlZ8qkot5Zo 6QIQAj84Slkbb0KkplRrOmUY X-Received: by 10.99.119.206 with SMTP id s197mr4887588pgc.439.1501177791575; Thu, 27 Jul 2017 10:49:51 -0700 (PDT) Received: from bala.domain.name ([117.199.137.21]) by smtp.gmail.com with ESMTPSA id 10sm39229655pfo.134.2017.07.27.10.49.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Jul 2017 10:49:51 -0700 (PDT) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 27 Jul 2017 06:08:22 -0700 Message-Id: <1501160903-25098-2-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501160903-25098-1-git-send-email-bala.manoharan@linaro.org> References: <1501160903-25098-1-git-send-email-bala.manoharan@linaro.org> Subject: [lng-odp] [API-NEXTv5 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" Adds toeplitz hash algorithm implementation for RSS hashing 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.9.1 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 Thu Jul 27 13:08:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 108848 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2370290qge; Thu, 27 Jul 2017 10:51:07 -0700 (PDT) X-Received: by 10.237.36.6 with SMTP id r6mr7336021qtc.159.1501177867299; Thu, 27 Jul 2017 10:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501177867; cv=none; d=google.com; s=arc-20160816; b=WauptG3TqIph1Htk9HdME8/1M7Odvm5kylfHGfF4JDrz9pHpQliyHY6mOPviD8bYr0 QMHlCj8PStgGoaqglwUWyTxAjavZUnK0DT18aYyigXD4wKr3fZEZK/f5C/HQnpKAWPAV kHhDdIswSoA/SCRSvFk93qzHEgvAhxwGfeGcBIM+9PZcZO6Th2E0XNkkLf8hI3IxOHo0 5vEYq100SBMYERJPyum4D+w2e3IzUo7H6DkEPgaunXEAwQsHPCWmFd4iudcvLDWqficl K2SvpOVprYIVg/GtWW4BsYWK1/CajAng+OshAeD+mlleYr51UGrqdsRvNZnHYbchYPSG 5tRQ== 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=UB1LfVkcxPAf6Bvq0X8VxB7TUBjYv4FY9rqHSaiIcCE=; b=LIbaZtYqOa0LmpdaF3ofXkNY7H6sqhF8pLrxuboumrIkUIayNNam3fue3FPVCPVSqz LvIHygAS8MML9nqQHtG1WtORHa0aWONmciY7uoXMePdtennFu5gThXPh/o93BSjeMF7Z EjdDjHcj039f1/nSyLL85QArArIT9Y1LG9p6FOosGnyRXZCHtgNTtuHPgZ+pjaFuBcWc RKnMKJKYlbyJbyQYfMERjHL6W6gqPIU1YHvsX5AFiQyb+ist9wA4LhMhjxipMgrJMjDa 3D583/Unp6P/LX780dx15dYxtbZDgWaHq6L/eVT37UmSCPW66myT6PhiLPkI4N5s1S6f WUuw== 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 m126si2212611qkc.39.2017.07.27.10.51.07; Thu, 27 Jul 2017 10:51:07 -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 E936665C02; Thu, 27 Jul 2017 17:51:06 +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.1 required=5.0 tests=BAYES_00, DATE_IN_PAST_03_06, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 0351065C09; Thu, 27 Jul 2017 17:50:36 +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 E313465C00; Thu, 27 Jul 2017 17:50:29 +0000 (UTC) Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) by lists.linaro.org (Postfix) with ESMTPS id C5DC965BFA for ; Thu, 27 Jul 2017 17:49:54 +0000 (UTC) Received: by mail-pf0-f174.google.com with SMTP id d67so18350689pfc.0 for ; Thu, 27 Jul 2017 10:49:54 -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=UB1LfVkcxPAf6Bvq0X8VxB7TUBjYv4FY9rqHSaiIcCE=; b=qGgvgMt9xuatHE+RMWoWQT+2/f2dCc1TqeCrH1ZIbUwWa7UwbQ1SHcSaae1UO+K/lI a2B5YsXGISBBvcVh/6DzCtsAfFE7aH9eSNkXYBFnlbxE2GLW0A7qerS/OoBJmFxdbrNY /pS2Wo7BuC7BRVtF3fIsSomWlTytkE0sHq7dEgnaHDyeHPDRNXnL4vP9j/c5P0rrdMDM WrNe8zeeUktUCvaUyKhsoaLvjQACUHh3geCCbrWOb+CaBLJxrRZ9UKlNq5z1lVczCzJk kwcaBbyBX2mOBZZNgrTcZyjh+eXnq6qLqn1m2fgkLaXe4DiCDQwhN7r5gO1sdR6kjWsv DcNA== X-Gm-Message-State: AIVw110DJj+flA1PAiTNDcl8nGD5P7BWn/a08ETfoQOG8W6Gwr8xYz6A GYBFBuULolNteDaR2Hr14J2x X-Received: by 10.99.145.196 with SMTP id l187mr4847916pge.425.1501177793739; Thu, 27 Jul 2017 10:49:53 -0700 (PDT) Received: from bala.domain.name ([117.199.137.21]) by smtp.gmail.com with ESMTPSA id 10sm39229655pfo.134.2017.07.27.10.49.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Jul 2017 10:49:53 -0700 (PDT) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 27 Jul 2017 06:08:23 -0700 Message-Id: <1501160903-25098-3-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501160903-25098-1-git-send-email-bala.manoharan@linaro.org> References: <1501160903-25098-1-git-send-email-bala.manoharan@linaro.org> Subject: [lng-odp] [API-NEXTv5 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" implementation for packet hashing on classification Signed-off-by: Balasubramanian Manoharan --- .../include/odp_classification_datamodel.h | 32 ++- .../include/odp_classification_internal.h | 7 + platform/linux-generic/odp_classification.c | 234 ++++++++++++++++++--- 3 files changed, 244 insertions(+), 29 deletions(-) -- 1.9.1 diff --git a/platform/linux-generic/include/odp_classification_datamodel.h b/platform/linux-generic/include/odp_classification_datamodel.h index fbe10cb..3cfe8c5 100644 --- a/platform/linux-generic/include/odp_classification_datamodel.h +++ b/platform/linux-generic/include/odp_classification_datamodel.h @@ -46,6 +46,22 @@ 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) + +typedef union { + /* All proto fileds */ + uint32_t all; + + struct { + uint32_t ipv4:1; + uint32_t ipv6:1; + uint32_t udp:1; + uint32_t tcp:1; + }; +} odp_cls_hash_proto_t; + /** Packet Matching Rule Term Value @@ -85,7 +101,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 +110,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_cls_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 +143,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..aca8e8c 100644 --- a/platform/linux-generic/include/odp_classification_internal.h +++ b/platform/linux-generic/include/odp_classification_internal.h @@ -79,6 +79,9 @@ This function returns the CoS associated with L3 QoS value cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, const uint8_t *pkt_addr, odp_packet_hdr_t *hdr); +void _odp_cls_update_hash_proto(cos_t *cos, + odp_pktin_hash_proto_t hash_proto); + /** @internal CoS associated with L2 QoS value @@ -138,6 +141,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_cls_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..1959493 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,15 @@ 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 +55,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 +100,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 +149,8 @@ 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; + odp_queue_param_init(¶m->queue_param); } void odp_cls_pmr_param_init(odp_pmr_param_t *param) @@ -154,24 +181,39 @@ int odp_cls_capability(odp_cls_capability_t *capability) return 0; } +void _odp_cls_update_hash_proto(cos_t *cos, odp_pktin_hash_proto_t hash_proto) +{ + if (hash_proto.proto.ipv4 || hash_proto.proto.ipv4_tcp || + hash_proto.proto.ipv4_udp) + cos->s.hash_proto.ipv4 = 1; + if (hash_proto.proto.ipv6 || hash_proto.proto.ipv6_tcp || + hash_proto.proto.ipv6_udp) + cos->s.hash_proto.ipv6 = 1; + if (hash_proto.proto.ipv4_tcp || hash_proto.proto.ipv6_tcp) + cos->s.hash_proto.tcp = 1; + if (hash_proto.proto.ipv4_udp || hash_proto.proto.ipv6_udp) + cos->s.hash_proto.udp = 1; +} + 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 +222,43 @@ 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; + } + + 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.num_queue = param->num_queue; + _odp_cls_update_hash_proto(cos, + param->hash_proto); + 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_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); + + 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 +328,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 +341,45 @@ 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 cos->s.queue; +} + +uint32_t odp_cls_cos_num_queue(odp_cos_t cos_id) +{ + cos_t *cos = get_cos_entry(cos_id); + + if (!cos) { + ODP_ERR("Invalid odp_cos_t handle"); + return 0; + } + + return cos->s.num_queue; +} + +uint32_t odp_cls_cos_queues(odp_cos_t cos_id, odp_queue_t queue[], + uint32_t num) +{ + uint32_t num_queues; + cos_t *cos; + uint32_t tbl_index; + uint32_t i; + + cos = get_cos_entry(cos_id); + if (!cos) { + ODP_ERR("Invalid odp_cos_t handle"); + return 0; + } - return queue_fn->to_ext(cos->s.queue); + if (num < cos->s.num_queue) + num_queues = num; + else + num_queues = cos->s.num_queue; + + tbl_index = cos->s.index * ODP_COS_QUEUE_MAX; + for (i = 0; i < num_queues; i++) + queue[i] = queue_grp_tbl->s.queue[tbl_index + i]; + + return num_queues; } int odp_cos_drop_set(odp_cos_t cos_id, odp_cls_drop_t drop_policy) @@ -830,6 +927,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 +940,95 @@ 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_cls_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; + const _odp_ipv6hdr_t *ipv6; + uint32_t hash; + uint32_t tuple_len; + + tuple_len = 0; + hash = 0; + if (pkt_hdr->p.input_flags.ipv4) { + if (hash_proto.ipv4) { + /* add 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; + tuple_len += 2; + } + + if (pkt_hdr->p.input_flags.tcp && hash_proto.tcp) { + /* add tcp */ + tcp = (const _odp_tcphdr_t *)base + + pkt_hdr->p.l4_offset; + tuple.v4.sport = tcp->src_port; + tuple.v4.dport = tcp->dst_port; + tuple_len += 1; + } else if (pkt_hdr->p.input_flags.udp && hash_proto.udp) { + /* add udp */ + udp = (const _odp_udphdr_t *)base + + pkt_hdr->p.l4_offset; + tuple.v4.sport = udp->src_port; + tuple.v4.dport = udp->dst_port; + tuple_len += 1; + } + } else if (pkt_hdr->p.input_flags.ipv6) { + if (hash_proto.ipv6) { + /* add ipv6 */ + ipv6 = (const _odp_ipv6hdr_t *)base + + pkt_hdr->p.l3_offset; + thash_load_ipv6_addr(ipv6, &tuple); + tuple_len += 8; + } + if (pkt_hdr->p.input_flags.tcp && hash_proto.tcp) { + tcp = (const _odp_tcphdr_t *)base + + pkt_hdr->p.l4_offset; + tuple.v4.sport = tcp->src_port; + tuple.v4.dport = tcp->dst_port; + tuple_len += 1; + } else if (pkt_hdr->p.input_flags.udp && hash_proto.udp) { + /* add udp */ + udp = (const _odp_udphdr_t *)base + + pkt_hdr->p.l4_offset; + tuple.v4.sport = udp->src_port; + tuple.v4.dport = udp->dst_port; + tuple_len += 1; + } + } + if (tuple_len) + hash = thash_softrss((uint32_t *)&tuple, + tuple_len, default_rss); + return hash; +} + cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, const uint8_t *pkt_addr, odp_packet_hdr_t *hdr) {