From patchwork Thu Aug 8 12:28:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nilanjan Sarkar X-Patchwork-Id: 57593 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 768381BE25; Thu, 8 Aug 2019 14:28:40 +0200 (CEST) Received: from mail1.sandvine.com (Mail1.sandvine.com [64.7.137.134]) by dpdk.org (Postfix) with ESMTP id 29BE81BE1F for ; Thu, 8 Aug 2019 14:28:38 +0200 (CEST) Received: from WTL-EXCHSV2-1.sandvine.com (192.168.194.58) by WTL-EXCHSV2-1.sandvine.com (192.168.194.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P521) id 15.1.1034.26; Thu, 8 Aug 2019 08:28:36 -0400 Received: from blr-exchsv1-1.sandvine.com (10.30.4.73) by WTL-EXCHSV2-1.sandvine.com (192.168.194.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P521) id 15.1.1034.26 via Frontend Transport; Thu, 8 Aug 2019 08:28:36 -0400 Received: from localhost.localdomain (10.187.156.146) by blr-exchsv1-1.sandvine.com (10.30.4.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P521) id 15.1.1034.26; Thu, 8 Aug 2019 17:58:29 +0530 From: Nilanjan Sarkar To: CC: Nilanjan Sarkar Date: Thu, 8 Aug 2019 12:28:19 +0000 Message-ID: <20190808122819.6015-1-nsarkar@sandvine.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 X-Originating-IP: [10.187.156.146] X-ClientProxiedBy: WTL-EXCHSV2-1.sandvine.com (192.168.194.58) To blr-exchsv1-1.sandvine.com (10.30.4.73) X-C2ProcessedOrg: b2f06e69-072f-40ee-90c5-80a34e700794 Subject: [dpdk-dev] [PATCH] eal: added new api to only enqueue a packet in tx buffer X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- lib/librte_ethdev/rte_ethdev.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index dc6596bc9..bd8b8fee4 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -4569,6 +4569,35 @@ 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 int +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