From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] distributor: add comments to make code more readable
Date: Thu, 6 Nov 2014 13:55:32 +0000 [thread overview]
Message-ID: <1415282132-11056-1-git-send-email-bruce.richardson@intel.com> (raw)
In-Reply-To: <9190772.1rnKUO3oNV@xps13>
From: "Bruce Richardson" <bruce.richardson@intel.com>
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 <bruce.richardson@intel.com>
---
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
next prev parent reply other threads:[~2014-11-06 13:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-05 13:30 [dpdk-dev] [PATCH] Add user defined tag calculation callback to librte_distributor Qinglai Xiao
2014-11-05 14:27 ` Bruce Richardson
2014-11-05 15:11 ` jigsaw
2014-11-05 16:36 ` Bruce Richardson
2014-11-05 17:24 ` jigsaw
2014-11-06 9:22 ` Bruce Richardson
2014-11-06 10:14 ` jigsaw
2014-11-06 10:36 ` Thomas Monjalon
2014-11-06 12:36 ` [dpdk-dev] 答复: [PATCH] Add user defined tag calculation callback tolibrte_distributor Qinglai Xiao
2014-11-06 13:59 ` Bruce Richardson
2014-11-06 18:01 ` jigsaw
2014-11-06 19:52 ` jigsaw
2014-11-07 9:45 ` Bruce Richardson
2014-11-07 12:38 ` jigsaw
2014-11-07 13:53 ` Bruce Richardson
2014-11-07 14:31 ` jigsaw
[not found] ` <20141107144410.GC12092@bricha3-MOBL3>
2014-11-07 14:52 ` jigsaw
2014-11-07 15:04 ` Bruce Richardson
2014-11-07 15:18 ` jigsaw
2014-11-06 13:55 ` Bruce Richardson [this message]
2014-11-07 14:08 ` [dpdk-dev] [PATCH] distributor: add comments to make code more readable Thomas Monjalon
2014-11-07 14:31 ` jigsaw
2014-11-06 13:57 ` [dpdk-dev] [PATCH] Add user defined tag calculation callback to librte_distributor Bruce Richardson
2014-11-05 15:13 ` Ananyev, Konstantin
2014-11-05 15:24 ` jigsaw
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1415282132-11056-1-git-send-email-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).