From patchwork Wed Aug 26 18:52:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 52739 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id 6902D22E8B for ; Wed, 26 Aug 2015 18:54:00 +0000 (UTC) Received: by labth1 with SMTP id th1sf69145364lab.2 for ; Wed, 26 Aug 2015 11:53:59 -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: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=8AfkdT++qaZG5rtLi4FybDcPIgK+ySIMoB5hyGoYMIk=; b=G12tn4iJC7qlOo2U4YlXYdGAoQwgbebePPMO1wNKmorN60dO0bEzF0SP0yY4wBGtp9 jm5GqmUmqw+Kmxby9sQTrrBY3peQOBBTYakj0aHRSsNV9PAUJeb0ERSY1zIRGstc7NZa qs4qqZel5fgbWeYj/ZAA2toRjeLz1JI+p1v8XDmRYweq1pAcW8O6klbXBY1PK1ICSJMj YAZRpURrJgxY2MGpXi/MQFCT6Uc5OpzbRZ8NziI1j29YN1q+XRlQEQmHx9lYW+rvUv/a ksYE2idRlFCT5Ylu4BdC+IaVcjjjj7DHCXydT7LPMmmvYsnE+vgGO+C7LMFg7LntuCMq muoA== X-Gm-Message-State: ALoCoQky8eyN7LFjCACNlvaXXA1z9YweJ8huFRHETMWWS4JzjYAaMNH90+joT4AyEsgfh9ftpYbs X-Received: by 10.152.6.103 with SMTP id z7mr50041laz.8.1440615239336; Wed, 26 Aug 2015 11:53:59 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.101 with SMTP id 5ls999667lal.59.gmail; Wed, 26 Aug 2015 11:53:59 -0700 (PDT) X-Received: by 10.112.11.233 with SMTP id t9mr31982916lbb.104.1440615239049; Wed, 26 Aug 2015 11:53:59 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id yp3si19458702lbb.43.2015.08.26.11.53.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 11:53:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbpu9 with SMTP id pu9so125935412lbb.3 for ; Wed, 26 Aug 2015 11:53:58 -0700 (PDT) X-Received: by 10.152.203.134 with SMTP id kq6mr32297142lac.106.1440615238901; Wed, 26 Aug 2015 11:53:58 -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 yc8csp4120259lbb; Wed, 26 Aug 2015 11:53:57 -0700 (PDT) X-Received: by 10.107.47.168 with SMTP id v40mr5825851iov.30.1440615236767; Wed, 26 Aug 2015 11:53:56 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h142si12809972ioh.159.2015.08.26.11.53.55; Wed, 26 Aug 2015 11:53:56 -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 6306261FCD; Wed, 26 Aug 2015 18:53:55 +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 D498261FAE; Wed, 26 Aug 2015 18:53:19 +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 930A661FAE; Wed, 26 Aug 2015 18:53:12 +0000 (UTC) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by lists.linaro.org (Postfix) with ESMTPS id 8D4A761FCD for ; Wed, 26 Aug 2015 18:53:08 +0000 (UTC) Received: by wijn1 with SMTP id n1so33550634wij.0 for ; Wed, 26 Aug 2015 11:53:07 -0700 (PDT) X-Received: by 10.194.84.211 with SMTP id b19mr63294980wjz.120.1440615187686; Wed, 26 Aug 2015 11:53:07 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by smtp.googlemail.com with ESMTPSA id cw8sm5127775wjb.49.2015.08.26.11.53.06 for (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Aug 2015 11:53:07 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Wed, 26 Aug 2015 19:52:59 +0100 Message-Id: <1440615179-24021-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v8] 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.217.175 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: 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); + +/** * @} */