From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id D4D187E75 for ; Thu, 6 Nov 2014 14:46:35 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 06 Nov 2014 05:54:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,326,1413270000"; d="scan'208";a="603453902" Received: from bricha3-mobl3.ger.corp.intel.com ([10.243.20.32]) by orsmga001.jf.intel.com with SMTP; 06 Nov 2014 05:56:00 -0800 Received: by (sSMTP sendmail emulation); Thu, 06 Nov 2014 13:55:59 +0025 From: Bruce Richardson To: dev@dpdk.org Date: Thu, 6 Nov 2014 13:55:32 +0000 Message-Id: <1415282132-11056-1-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <9190772.1rnKUO3oNV@xps13> References: <9190772.1rnKUO3oNV@xps13> Subject: [dpdk-dev] [PATCH] distributor: add comments to make code more readable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2014 13:46:36 -0000 From: "Bruce Richardson" Add in some additional comments around more complex areas of the code so as to make the code easier to read and understand. Signed-off-by: Bruce Richardson --- lib/librte_distributor/rte_distributor.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index 585ff88..656ee5c 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -92,6 +92,7 @@ struct rte_distributor { unsigned num_workers; /**< Number of workers polling */ uint32_t in_flight_tags[RTE_MAX_LCORE]; + /**< Tracks the tag being processed per core, 0 == no pkt */ struct rte_distributor_backlog backlog[RTE_MAX_LCORE]; union rte_distributor_buffer bufs[RTE_MAX_LCORE]; @@ -282,10 +283,22 @@ rte_distributor_process(struct rte_distributor *d, next_mb = mbufs[next_idx++]; next_value = (((int64_t)(uintptr_t)next_mb) << RTE_DISTRIB_FLAG_BITS); + /* + * Set the low bit on the tag, so we can guarantee that + * we never store a tag value of zero. That means we can + * use the zero-value to indicate that no packet is + * being processed by a worker. + */ new_tag = (next_mb->hash.rss | 1); uint32_t match = 0; unsigned i; + /* + * to scan for a match use "xor" and "not" to get a 0/1 + * value, then use shifting to merge to single "match" + * variable, where a one-bit indicates a match for the + * worker given by the bit-position + */ for (i = 0; i < d->num_workers; i++) match |= (!(d->in_flight_tags[i] ^ new_tag) << i); -- 2.1.1