DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] distributor: split get_pkt into request and poll
@ 2014-06-19 21:12 Bruce Richardson
  2014-06-20  9:57 ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2014-06-19 21:12 UTC (permalink / raw)
  To: dev

Take the existing get_pkt API and split out the parts for requesting a new
packet from the part to poll for arrival of a new packet. These individual
functions can then be used independently of the get function, which still acts
as before.

The split functions for request and poll will allow a worker to pull
packets from multiple distributors, or to act as multiple workers with a
single distributor if needed for better performance.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_distributor/rte_distributor.c | 27 ++++++++++++++++---
 lib/librte_distributor/rte_distributor.h | 45 ++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 5eee442..ec6094f 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -103,8 +103,8 @@ TAILQ_HEAD(rte_distributor_list, rte_distributor);
 
 /**** APIs called by workers ****/
 
-struct rte_mbuf *
-rte_distributor_get_pkt(struct rte_distributor *d,
+void
+rte_distributor_request_pkt(struct rte_distributor *d,
 		unsigned worker_id, struct rte_mbuf *oldpkt)
 {
 	union rte_distributor_buffer *buf = &d->bufs[worker_id];
@@ -113,13 +113,32 @@ rte_distributor_get_pkt(struct rte_distributor *d,
 	while (unlikely(buf->bufptr64 & RTE_DISTRIB_FLAGS_MASK))
 		rte_pause();
 	buf->bufptr64 = req;
-	while (buf->bufptr64 & RTE_DISTRIB_GET_BUF)
-		rte_pause();
+}
+
+struct rte_mbuf *
+rte_distributor_poll_pkt(struct rte_distributor *d,
+		unsigned worker_id)
+{
+	union rte_distributor_buffer *buf = &d->bufs[worker_id];
+	if (buf->bufptr64 & RTE_DISTRIB_GET_BUF)
+		return NULL;
+
 	/* since bufptr64 is signed, this should be an arithmetic shift */
 	int64_t ret = buf->bufptr64 >> RTE_DISTRIB_FLAG_BITS;
 	return (struct rte_mbuf *)((uintptr_t)ret);
 }
 
+struct rte_mbuf *
+rte_distributor_get_pkt(struct rte_distributor *d,
+		unsigned worker_id, struct rte_mbuf *oldpkt)
+{
+	struct rte_mbuf *ret;
+	rte_distributor_request_pkt(d, worker_id, oldpkt);
+	while ((ret = rte_distributor_poll_pkt(d, worker_id)) == NULL)
+		rte_pause();
+	return ret;
+}
+
 int
 rte_distributor_return_pkt(struct rte_distributor *d,
 		unsigned worker_id, struct rte_mbuf *oldpkt)
diff --git a/lib/librte_distributor/rte_distributor.h b/lib/librte_distributor/rte_distributor.h
index 1e41dce..8e391ed 100644
--- a/lib/librte_distributor/rte_distributor.h
+++ b/lib/librte_distributor/rte_distributor.h
@@ -193,6 +193,51 @@ int
 rte_distributor_return_pkt(struct rte_distributor *d, unsigned worker_id,
 		struct rte_mbuf *mbuf);
 
+/**
+ * API called by a worker to request a new packet to process.
+ * Any previous packet given to the worker is assumed to have completed
+ * processing, and may be optionally returned to the distributor via
+ * the oldpkt parameter.
+ * Unlike rte_distributor_get_pkt(), this function does not wait for a new
+ * packet to be provided by the distributor.
+ *
+ * NOTE: after calling this function, rte_distributor_poll_pkt() should
+ * be used to poll for the packet requested. The rte_distributor_get_pkt()
+ * API should *not* be used to try and retrieve the new packet.
+ *
+ * @param d
+ *   The distributor instance to be used
+ * @param worker_id
+ *   The worker instance number to use - must be less that num_workers passed
+ *   at distributor creation time.
+ * @param oldpkt
+ *   The previous packet, if any, being processed by the worker
+ */
+void
+rte_distributor_request_pkt(struct rte_distributor *d,
+		unsigned worker_id, struct rte_mbuf *oldpkt);
+
+/**
+ * API called by a worker to check for a new packet that was previously
+ * requested by a call to rte_distributor_request_pkt(). It does not wait
+ * for the new packet to be available, but returns NULL if the request has
+ * not yet been fulfilled by the distributor.
+ *
+ * @param d
+ *   The distributor instance to be used
+ * @param worker_id
+ *   The worker instance number to use - must be less that num_workers passed
+ *   at distributor creation time.
+ *
+ * @return
+ *   A new packet to be processed by the worker thread, or NULL if no
+ *   packet is yet available.
+ */
+struct rte_mbuf *
+rte_distributor_poll_pkt(struct rte_distributor *d,
+		unsigned worker_id);
+
+
 /******************************************/
 
 #ifdef __cplusplus
-- 
1.9.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] distributor: split get_pkt into request and poll
  2014-06-19 21:12 [dpdk-dev] [PATCH] distributor: split get_pkt into request and poll Bruce Richardson
@ 2014-06-20  9:57 ` De Lara Guarch, Pablo
  2014-06-20 16:03   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: De Lara Guarch, Pablo @ 2014-06-20  9:57 UTC (permalink / raw)
  To: Richardson, Bruce, dev

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson
> Sent: Thursday, June 19, 2014 10:13 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] distributor: split get_pkt into request and poll
> 
> Take the existing get_pkt API and split out the parts for requesting a new
> packet from the part to poll for arrival of a new packet. These individual
> functions can then be used independently of the get function, which still acts
> as before.
> 
> The split functions for request and poll will allow a worker to pull
> packets from multiple distributors, or to act as multiple workers with a
> single distributor if needed for better performance.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] distributor: split get_pkt into request and poll
  2014-06-20  9:57 ` De Lara Guarch, Pablo
@ 2014-06-20 16:03   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2014-06-20 16:03 UTC (permalink / raw)
  To: Richardson, Bruce; +Cc: dev

> > Take the existing get_pkt API and split out the parts for requesting a new
> > packet from the part to poll for arrival of a new packet. These individual
> > functions can then be used independently of the get function, which still 
acts
> > as before.
> > 
> > The split functions for request and poll will allow a worker to pull
> > packets from multiple distributors, or to act as multiple workers with a
> > single distributor if needed for better performance.
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Applied for version 1.7.0.

Thanks
-- 
Thomas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-20 16:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-19 21:12 [dpdk-dev] [PATCH] distributor: split get_pkt into request and poll Bruce Richardson
2014-06-20  9:57 ` De Lara Guarch, Pablo
2014-06-20 16:03   ` Thomas Monjalon

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).