aboutsummaryrefslogtreecommitdiff
path: root/include/odp/api/spec/packet_io.h
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@nokia.com>2016-03-08 12:56:34 +0200
committerMaxim Uvarov <maxim.uvarov@linaro.org>2016-03-15 10:52:52 +0300
commit8498ba6cf9c4187f3f5c929814a687b1b16daf3a (patch)
treeabf1a99c629724b9e0957924b3d34b662587e804 /include/odp/api/spec/packet_io.h
parent0130e62cb9f331100871d109cd7a006738ef5346 (diff)
api: pktio: add recv from multiple queues with tmo
Added odp_pktin_recv_mq_tmo() which allows application to poll multiple input queues (interfaces) with single call. The call includes timeout parameter which allows thread to e.g. sleep while waiting for more packets to arrive and thus avoid 100% CPU utilization when packet rate is low. Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com> Signed-off-by: Juha-Matti Tilli <juha-matti.tilli@nokia.com> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'include/odp/api/spec/packet_io.h')
-rw-r--r--include/odp/api/spec/packet_io.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h
index 302d43116..6fe2cac2b 100644
--- a/include/odp/api/spec/packet_io.h
+++ b/include/odp/api/spec/packet_io.h
@@ -63,6 +63,15 @@ extern "C" {
* Actual MAC address sizes may be different.
*/
+/**
+ * @def ODP_PKTIN_NO_WAIT
+ * Do not wait on packet input
+ */
+
+/**
+ * @def ODP_PKTIN_WAIT
+ * Wait infinitely on packet input
+ */
/**
* Packet input mode
@@ -530,6 +539,57 @@ odp_pktio_t odp_pktio_lookup(const char *name);
int odp_pktin_recv(odp_pktin_queue_t queue, odp_packet_t packets[], int num);
/**
+ * Receive packets directly from multiple interface input queues
+ *
+ * Receives up to 'num' packets from one of the specified pktio interface input
+ * queues. The index of the source queue is stored into 'from' output
+ * parameter. If there are no packets available on any of the queues, waits for
+ * packets depeding on 'wait' parameter value. Returns the number of packets
+ * received.
+ *
+ * When an input queue has been configured with 'op_mode' value
+ * ODP_PKTIO_OP_MT_UNSAFE, the operation is optimized for single thread
+ * operation and the same queue must not be accessed simultaneously from
+ * multiple threads.
+ *
+ * It is implementation specific in which order the queues are checked for
+ * packets. Application may improve fairness of queue service levels by
+ * circulating queue handles between consecutive calls (e.g. [q0, q1, q2, q3] ->
+ * [q1, q2, q3, q0] -> [q2, q3, ...).
+ *
+ * @param queues[] Packet input queue handles for receiving packets
+ * @param num_q Number of input queues
+ * @param[out] from Pointer for output of the source queue index. Ignored
+ * when NULL.
+ * @param[out] packets[] Packet handle array for output of received packets
+ * @param num Maximum number of packets to receive
+ * @param wait Wait time specified as as follows:
+ * * ODP_PKTIN_NO_WAIT: Do not wait
+ * * ODP_PKTIN_WAIT: Wait infinitely
+ * * Other values specify the minimum time to wait.
+ * Use odp_pktin_wait_time() to convert nanoseconds
+ * to a valid parameter value. Wait time may be
+ * rounded up a small, platform specific amount.
+ *
+ * @return Number of packets received
+ * @retval <0 on failure
+ */
+int odp_pktin_recv_mq_tmo(const odp_pktin_queue_t queues[], unsigned num_q,
+ unsigned *from, odp_packet_t packets[], int num,
+ uint64_t wait);
+
+/**
+ * Packet input wait time
+ *
+ * Converts nanoseconds to wait time values for packet input functions.
+ *
+ * @param nsec Minimum number of nanoseconds to wait
+ *
+ * @return Wait parameter value for packet input functions
+ */
+uint64_t odp_pktin_wait_time(uint64_t nsec);
+
+/**
* Send packets directly to an interface output queue
*
* Sends out a number of packets to the interface output queue. When