From patchwork Fri Oct 7 16:17:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 679462 X-Patchwork-Delegate: diproiettod@vmware.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3srFBw3hjwz9s3v for ; Sat, 8 Oct 2016 03:21:28 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id D5ACE109CF; Fri, 7 Oct 2016 09:21:08 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 7CC3A109AD for ; Fri, 7 Oct 2016 09:21:06 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 0B3F9162D24 for ; Fri, 7 Oct 2016 10:21:06 -0600 (MDT) X-ASG-Debug-ID: 1475857265-0b323747b508680001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar6.cudamail.com with ESMTP id WvZELXHBGQIpM9MW (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 07 Oct 2016 10:21:05 -0600 (MDT) X-Barracuda-Envelope-From: bhanuprakash.bodireddy@intel.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mga05.intel.com) (192.55.52.43) by mx3-pf3.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 7 Oct 2016 16:21:04 -0000 Received-SPF: pass (mx3-pf3.cudamail.com: SPF record at intel.com designates 192.55.52.43 as permitted sender) X-Barracuda-Apparent-Source-IP: 192.55.52.43 X-Barracuda-RBL-IP: 192.55.52.43 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 07 Oct 2016 09:21:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,456,1473145200"; d="scan'208";a="177488313" Received: from silpixa00393942.ir.intel.com ([10.237.223.42]) by fmsmga004.fm.intel.com with ESMTP; 07 Oct 2016 09:21:04 -0700 X-CudaMail-Envelope-Sender: bhanuprakash.bodireddy@intel.com From: Bhanuprakash Bodireddy To: dev@openvswitch.org X-CudaMail-MID: CM-V3-1006023244 X-CudaMail-DTE: 100716 X-CudaMail-Originating-IP: 192.55.52.43 Date: Fri, 7 Oct 2016 17:17:32 +0100 X-ASG-Orig-Subj: [##CM-V3-1006023244##][PATCH 02/12] flow: Add comments to mf_get_next_in_map() Message-Id: <1475857062-55311-3-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1475857062-55311-1-git-send-email-bhanuprakash.bodireddy@intel.com> References: <1475857062-55311-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-GBUdb-Analysis: 0, 192.55.52.43, Ugly c=0 p=0 Source New X-MessageSniffer-Rules: 0-0-0-6106-c X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1475857265 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.33546 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH 02/12] flow: Add comments to mf_get_next_in_map() X-BeenThere: dev@openvswitch.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: dev-bounces@openvswitch.org Sender: "dev" Signed-off-by: Bhanuprakash Bodireddy Signed-off-by: Antonio Fischetti --- lib/flow.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/flow.h b/lib/flow.h index ea24e28..4eb19ae 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -570,15 +570,27 @@ struct mf_for_each_in_map_aux { const uint64_t *values; }; +/* + * Parse the bitmap mask of the subtable and output the next value + * from the search-key. + */ static inline bool mf_get_next_in_map(struct mf_for_each_in_map_aux *aux, uint64_t *value) { - map_t *map, *fmap; + map_t *map; /* map refers to the bitmap mask of the subtable. */ + map_t *fmap; /* fmap refers to the bitmap of the search-key. */ map_t rm1bit; + /* The bitmap mask selects which value must be considered from the + * search-key. We process the corresponding 'unit' of size 64 bits. + * 'aux->unit' is an index to the current unit of 64 bits. */ while (OVS_UNLIKELY(!*(map = &aux->map.bits[aux->unit]))) { - /* Skip remaining data in the previous unit. */ + /* No bits are enabled, so no search-key value will be output. + * In case some of the corresponding data chunks in the search-key + * bitmap are set, the data chunks must be skipped, as they are not + * considered by this mask. This is handled by incrementing aux->values + * accordingly. */ aux->values += count_1bits(aux->fmap.bits[aux->unit]); if (++aux->unit == FLOWMAP_UNITS) { return false; @@ -589,7 +601,12 @@ mf_get_next_in_map(struct mf_for_each_in_map_aux *aux, *map -= rm1bit; fmap = &aux->fmap.bits[aux->unit]; + /* If the 8-byte value referred by 'rm1bit' is present in the + * search-key return 'value', otherwise return 0. */ if (OVS_LIKELY(*fmap & rm1bit)) { + /* The value is in the search-key, if the search-key contains other + * values preceeding the 'rm1bit' bit, we consider it trash and the + * corresponding data chunks should be skipped accordingly. */ map_t trash = *fmap & (rm1bit - 1); *fmap -= trash; @@ -600,6 +617,8 @@ mf_get_next_in_map(struct mf_for_each_in_map_aux *aux, *value = *aux->values; } else { + /* The search-key does not contain a value that corresponds to + * rm1bit. */ *value = 0; } return true;