eal: added new api to only enqueue a packet in tx buffer
diff mbox series

Message ID c097dcc9ad9c4b2b8cc1007b55715746@sandvine.com
State Superseded, archived
Headers show
Series
  • eal: added new api to only enqueue a packet in tx buffer
Related show

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail apply issues

Commit Message

Nilanjan Sarkar Aug. 8, 2019, 11:17 a.m. UTC
This api is similar like api `rte_eth_tx_buffer` except it
does not attempt to flush the buffer in case buffer is full.
The advantage is that, this api does not need port id and
queue id. In case port id and queue id are shared within threads
then application can not buffer a packet until it gets access
to port and queue. So this function segregate buffering
job from flushing job and thus removes dependency on port and queue.

Signed-off-by: Nilanjan Sarkar <nsarkar@sandvine.com>
---
lib/librte_ethdev/rte_ethdev.h | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)


--
2.7.4

Disclaimer:
This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is considered confidential, proprietary, sensitive and/or otherwise legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation.

Patch
diff mbox series

diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index dc6596b..8055928 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -4569,6 +4569,37 @@  rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
        return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
}

+/**
+ * Buffer a single packet for future transmission on Tx buffer. This buffer
+ * can be sent to a port and queue of a NIC using rte_eth_tx_buffer_flush ()
+ * call.
+ *
+ * This function enqueues a packet to Tx buffer. In case there is no space
+ * in Tx buffer, this function fails.
+ * Tx buffer will be flushed using rte_eth_tx_buffer_flush () call. It is
+ * application's responsibility to flush the Tx buffer in regular interval.
+ *
+ * @param buffer
+ *  Buffer used to collect packets to be sent.
+ * @param tx_pkt
+ *  Pointer to the packet mbuf to be sent.
+ * @return
+ *  0 = packet has been buffered for later transmission
+ *  -1 = Packet can not be buffered since it reached limit
+ */
+
+static __rte_always_inline int8_t
+rte_eth_tx_enqueue(struct rte_eth_dev_tx_buffer *buffer, struct rte_mbuf *tx_pkt)
+{
+       if (buffer->length < buffer->size)
+       {
+               buffer->pkts[buffer->length++] = tx_pkt;
+               return 0;
+       }
+
+       return -1;
+}
+
#ifdef __cplusplus
}
#endif