From patchwork Fri Aug 28 11:05:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 52787 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 9755722E8B for ; Fri, 28 Aug 2015 11:06:32 +0000 (UTC) Received: by wibvo5 with SMTP id vo5sf1636197wib.0 for ; Fri, 28 Aug 2015 04:06:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=n2IhRO/T6VAUGHvx5gOmUfZikXo6wv7M+ifx8kZZd8E=; b=RvFNbSillujNCZtAL2/W7/HQcX6+AgsPrBE8SaY/ywqANLr0O89RFnABJK58xSPBXj LkaMqeE2GAVyaSaFENtWue1xirVYTN5Lv8un4RfJ7ECIfEXJKG9XiHZ+64XSgfnDqmLS 3FQ86eXI481RwX0w8IPds0VNiQNJQqFYoEjSvBC4ENjKzeUE4X+KQ9DqoZ1g9mC6d8h7 C2VcespsO+7Wv6vwLZP+nJ2lGm9CVf5DrS6UG550aKAuTtzie8lIJ4YWYtnuCH+AkqP6 8d6pkxUiZaAS10fCbzcXCI3zalsqJ9vCpfD6qsHvsvblOoPDuqM+R1ved9VeDIHSUEIP jSGA== X-Gm-Message-State: ALoCoQnriU5Osy/C35ktJJxoPa61lCeH2hiS3UHjkzgenD57nU593Tr1Lt9PaARrsFIWVwYYb2XK X-Received: by 10.112.167.201 with SMTP id zq9mr2651898lbb.2.1440759991565; Fri, 28 Aug 2015 04:06:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.1 with SMTP id o1ls214852lao.12.gmail; Fri, 28 Aug 2015 04:06:31 -0700 (PDT) X-Received: by 10.112.25.69 with SMTP id a5mr4852129lbg.16.1440759991429; Fri, 28 Aug 2015 04:06:31 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id ms1si5443573lbb.53.2015.08.28.04.06.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2015 04:06:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by labnh1 with SMTP id nh1so5445973lab.3 for ; Fri, 28 Aug 2015 04:06:31 -0700 (PDT) X-Received: by 10.152.87.10 with SMTP id t10mr483973laz.76.1440759991304; Fri, 28 Aug 2015 04:06:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.151.194 with SMTP id us2csp454792lbb; Fri, 28 Aug 2015 04:06:30 -0700 (PDT) X-Received: by 10.50.122.36 with SMTP id lp4mr2931364igb.37.1440759989908; Fri, 28 Aug 2015 04:06:29 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h10si1898556iga.77.2015.08.28.04.06.29; Fri, 28 Aug 2015 04:06:29 -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; Received: by lists.linaro.org (Postfix, from userid 109) id D9F0561B54; Fri, 28 Aug 2015 11:06:28 +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, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 7D5DB61A38; Fri, 28 Aug 2015 11:05:56 +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 106E861A1F; Fri, 28 Aug 2015 11:05:54 +0000 (UTC) Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by lists.linaro.org (Postfix) with ESMTPS id AB60A619B3 for ; Fri, 28 Aug 2015 11:05:52 +0000 (UTC) Received: by wibcx1 with SMTP id cx1so10670483wib.1 for ; Fri, 28 Aug 2015 04:05:52 -0700 (PDT) X-Received: by 10.180.214.70 with SMTP id ny6mr3782387wic.20.1440759951899; Fri, 28 Aug 2015 04:05:51 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by smtp.googlemail.com with ESMTPSA id i6sm7505091wje.33.2015.08.28.04.05.51 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 28 Aug 2015 04:05:51 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Fri, 28 Aug 2015 12:05:38 +0100 Message-Id: <1440759940-17679-2-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440759940-17679-1-git-send-email-zoltan.kiss@linaro.org> References: <1440759940-17679-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v8 1/3] api: packet: allow access to packet flow hash values X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zoltan.kiss@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Applications can read the computed hash (if any) and set it if they want to store any extra information in it. Signed-off-by: Zoltan Kiss Reviewed-by: Petri Savolainen Reviewed-by: Balasubramanian Manoharan --- v2: - focus on RSS hash only - use setter/getter's v3: - do not mention pointers - add a note - add new patches for implementation and test v4: I've accidentally skipped this version v5: - use separate flag get and clear, as hash can have any value (that maps to checking ol_flags in DPDK) - change terminology to "flow hash", it reflects better what is actually hashed - add function to generate hash by the platform v6: - remove stale function definition from the end of packet.h - spell out in hash_set that if platform cares about the validity of this value, it has to maintain it internally. - with the above change OVS doesn't need the hash generator function anymore, so remove that too. We can introduce it later on. v7: add more comments on Bala's request v8: - previous version doesn't contain the mentioned changes, resend it - fix grammar on Petri's note include/odp/api/packet.h | 37 +++++++++++++++++++++++++++++++++++++ include/odp/api/packet_flags.h | 18 ++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h index 3a454b5..5d46b7b 100644 --- a/include/odp/api/packet.h +++ b/include/odp/api/packet.h @@ -605,6 +605,43 @@ uint32_t odp_packet_l4_offset(odp_packet_t pkt); int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset); /** + * Packet flow hash value + * + * Returns the hash generated from the packet header. Use + * odp_packet_has_flow_hash() to check if packet contains a hash. + * + * @param pkt Packet handle + * + * @return Hash value + * + * @note Zero can be a valid hash value. + * @note The hash algorithm and the header fields defining the flow (therefore + * used for hashing) is platform dependent. It is possible a platform doesn't + * generate any hash at all. + * @note The returned hash is either the platform generated (if any), or if + * odp_packet_flow_hash_set() were called then the value set there. + */ +uint32_t odp_packet_flow_hash(odp_packet_t pkt); + +/** + * Set packet flow hash value + * + * Store the packet flow hash for the packet and sets the flow hash flag. This + * enables (but does not require!) application to reflect packet header + * changes in the hash. + * + * @param pkt Packet handle + * @param flow_hash Hash value to set + * + * @note If the platform needs to keep the original hash value, it has to + * maintain it internally. Overwriting the platform provided value doesn't + * change how the platform handles this packet after it. + * @note The application is not required to keep this hash valid for new or + * modified packets. + */ +void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash); + +/** * Tests if packet is segmented * * @param pkt Packet handle diff --git a/include/odp/api/packet_flags.h b/include/odp/api/packet_flags.h index bfbcc94..7c3b247 100644 --- a/include/odp/api/packet_flags.h +++ b/include/odp/api/packet_flags.h @@ -191,6 +191,15 @@ int odp_packet_has_sctp(odp_packet_t pkt); int odp_packet_has_icmp(odp_packet_t pkt); /** + * Check for packet flow hash + * + * @param pkt Packet handle + * @retval non-zero if packet contains a hash value + * @retval 0 if packet does not contain a hash value + */ +int odp_packet_has_flow_hash(odp_packet_t pkt); + +/** * Set flag for L2 header, e.g. ethernet * * @param pkt Packet handle @@ -327,6 +336,15 @@ void odp_packet_has_sctp_set(odp_packet_t pkt, int val); void odp_packet_has_icmp_set(odp_packet_t pkt, int val); /** + * Clear flag for packet flow hash + * + * @param pkt Packet handle + * + * @note Set this flag is only possible through odp_packet_flow_hash_set() + */ +void odp_packet_has_flow_hash_clr(odp_packet_t pkt); + +/** * @} */