From patchwork Fri Aug 21 18:07:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 52610 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 E394020AF6 for ; Fri, 21 Aug 2015 18:07:31 +0000 (UTC) Received: by wilj18 with SMTP id j18sf8468531wil.0 for ; Fri, 21 Aug 2015 11:07: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=wIuIJ0lQWehzlKv5hAxhzrYlcaxusvISqrzFZszH0Pc=; b=cQYTvxc6HEbkhGjqFjI5vI71egMmGw4unTKnyX5JUZheMGVRT9CRCDwfdaQeUryQZ1 m5u+uFa4JA590yHLyCR6sZG5quctaiCiPW+SdXNgyoP7eyFKKqfWlZASbNtPxJDhucy/ tiBYNl0tH7GNyCAMkWlzMZcT8583Igllzcx0VI9ZLi8kkJq4B8pR8yaUL/vjb9xLgJA6 o/FWma23tfOTiCyS9e9rtK1E+Ks2vyValpeBOqua7/WQBga/at1yNMKlmBN123QQvtKA wtbmu2Jd9uIb5gI8GPg3zlK/EihbZbrONz34QJ+j66jMwqZPKUzEgYTQZK3hyFUvTy0j ERhw== X-Gm-Message-State: ALoCoQnPfQvfICP/A3hLFZHviI7kwnAwm4LmPaTquIZ6OSfmRftWVPR2gyCwF4JTCKndWXMXluDF X-Received: by 10.180.96.226 with SMTP id dv2mr1306682wib.2.1440180451208; Fri, 21 Aug 2015 11:07:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.42 with SMTP id o10ls272902laa.87.gmail; Fri, 21 Aug 2015 11:07:31 -0700 (PDT) X-Received: by 10.152.43.77 with SMTP id u13mr8792079lal.96.1440180451027; Fri, 21 Aug 2015 11:07:31 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id qg4si6811942lbb.25.2015.08.21.11.07.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2015 11:07:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by laba3 with SMTP id a3so46029021lab.1 for ; Fri, 21 Aug 2015 11:07:30 -0700 (PDT) X-Received: by 10.152.29.132 with SMTP id k4mr8862726lah.88.1440180450900; Fri, 21 Aug 2015 11:07:30 -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.162.200 with SMTP id yc8csp849707lbb; Fri, 21 Aug 2015 11:07:29 -0700 (PDT) X-Received: by 10.170.57.202 with SMTP id 193mr13084875ykz.118.1440180448425; Fri, 21 Aug 2015 11:07:28 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c33si13971001qga.59.2015.08.21.11.07.27; Fri, 21 Aug 2015 11:07:28 -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 312B261DC8; Fri, 21 Aug 2015 18:07:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal 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 ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 1D9BA61D9F; Fri, 21 Aug 2015 18:07:22 +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 51D5161DA5; Fri, 21 Aug 2015 18:07:20 +0000 (UTC) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by lists.linaro.org (Postfix) with ESMTPS id 21AC661D9E for ; Fri, 21 Aug 2015 18:07:19 +0000 (UTC) Received: by wicne3 with SMTP id ne3so22027929wic.0 for ; Fri, 21 Aug 2015 11:07:18 -0700 (PDT) X-Received: by 10.194.47.209 with SMTP id f17mr17673541wjn.39.1440180438365; Fri, 21 Aug 2015 11:07:18 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by smtp.googlemail.com with ESMTPSA id s1sm3920981wix.13.2015.08.21.11.07.17 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Aug 2015 11:07:17 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Fri, 21 Aug 2015 19:07:00 +0100 Message-Id: <1440180420-11376-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439578544-12730-1-git-send-email-zoltan.kiss@linaro.org> References: <1439578544-12730-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v5] 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.43 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 changed the packet headers or if the platform haven't calculated the hash. Signed-off-by: Zoltan Kiss --- 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: - 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 include/odp/api/packet.h | 72 ++++++++++++++++++++++++++++++++++++++++++ include/odp/api/packet_flags.h | 18 +++++++++++ 2 files changed, 90 insertions(+) diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h index 3a454b5..9a74ca4 100644 --- a/include/odp/api/packet.h +++ b/include/odp/api/packet.h @@ -605,6 +605,78 @@ 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. + */ +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 application to recalculate hash for a modified packet. + * + * @param pkt Packet handle + * @param flow_hash Hash value to set + * + * @note The platform might use this hash on outgoing packets, so application + * should call odp_packet_flow_hash_set() with the lazy option at least before + * handing the packet back to the platform. + */ +void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash); + +/** + * Generate packet flow hash value + * + * Generates hash value from the packet headers. Hash generation is identical to + * packet input processing. The packet would have identical hash value + * when received through a packet input interface. If 'lazy' option specified, + * and the platform doesn't care about the value of this hash after it handed + * over the packet to the application, it can opt out generating one. + * + * @param pkt Packet handle + * @param hash Pointer for storing the hash + * @param lazy If 1, the platform can opt out + * + * @retval 0 Hash was generated + * @retval <0 Hash was not generated + * @note If the platform wouldn't compute any hash during receive, then it + * won't generate any here either + * @note When the platform can opt out generating a hash (lazy == 1 and platform + * doesn't care about the hash), it doesn't mean it has to. If it can do it + * really fast, implementors can decide to generate it anyway. + */ +int odp_packet_flow_hash_gen(odp_packet_t pkt, uint32_t *hash, int lazy); + +/** + * Lazy generate packet flow hash value + * + * Generates hash value from the packet headers, same as + * odp_packet_flow_hash_gen(), but with relaxed requirements. If the platform + * doesn't care about the value of this hash after it handed over the packet to + * the application, it can opt out generating one. + * + * @param pkt Packet handle + * @param hash Pointer for storing the hash + * + * @retval 0 Hash was generated + * @retval <0 Hash was not generated + * @note If the platform wouldn't compute any hash during receive, then it + * won't generate any here either + */ +int odp_packet_flow_hash_gen_lazy(odp_packet_t pkt, uint32_t *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); + +/** * @} */