From patchwork Mon Feb 20 18:34:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124202 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 13D8641CEE; Mon, 20 Feb 2023 19:35:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 03BF8430CA; Mon, 20 Feb 2023 19:35:25 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 01522430CB for ; Mon, 20 Feb 2023 19:35:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676918123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8dB3xH8Qd5agJ39G43KCX+LIjqoP3+D7AAGDzIFSo7g=; b=VGOXnVYdINqzsRpBwCdk2VUFaBK7lije9uzIqSiHlW00rDd5EXO/2UPoPZisiQPe3Mr1Ds 4mvPgbhk2Y/JqtQR1MTI4mn/ssDjfORcvYccuk+8xfT6hQ0hSQY18QL6aXzKPXDpOLi+mo moZ+L4wRf4mTVpfYe9kBQAbR2/XeER0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-158-6D0TAi47NQS_opcmL-Ge-Q-1; Mon, 20 Feb 2023 13:35:18 -0500 X-MC-Unique: 6D0TAi47NQS_opcmL-Ge-Q-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B33CB185A794; Mon, 20 Feb 2023 18:35:17 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44DA1492B05; Mon, 20 Feb 2023 18:35:16 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry , stable@dpdk.org, Tomasz Kulasek , Konstantin Ananyev Subject: [PATCH v3 1/9] app/testpmd: fix Tx preparation in checksum engine Date: Mon, 20 Feb 2023 19:34:54 +0100 Message-Id: <20230220183502.3348368-2-david.marchand@redhat.com> In-Reply-To: <20230220183502.3348368-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220183502.3348368-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org "unprepared" packets could get to the wire in the retry loop. Split packets freeing in two stages: one for preparation failure, and one for transmission failure. Adjust dropped counter update accordingly. Fixes: 6b520d54ebfe ("app/testpmd: use Tx preparation in checksum engine") Cc: stable@dpdk.org Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- app/test-pmd/csumonly.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 1c24598515..90a59e0aa5 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -1168,10 +1168,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) nb_prep = rte_eth_tx_prepare(fs->tx_port, fs->tx_queue, tx_pkts_burst, nb_rx); - if (nb_prep != nb_rx) + if (nb_prep != nb_rx) { fprintf(stderr, "Preparing packet burst to transmit failed: %s\n", rte_strerror(rte_errno)); + fs->fwd_dropped += (nb_rx - nb_prep); + rte_pktmbuf_free_bulk(&tx_pkts_burst[nb_prep], nb_rx - nb_prep); + } nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, tx_pkts_burst, nb_prep); @@ -1179,12 +1182,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* * Retry if necessary */ - if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { + if (unlikely(nb_tx < nb_prep) && fs->retry_enabled) { retry = 0; - while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { + while (nb_tx < nb_prep && retry++ < burst_tx_retry_num) { rte_delay_us(burst_tx_delay_time); nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - &tx_pkts_burst[nb_tx], nb_rx - nb_tx); + &tx_pkts_burst[nb_tx], nb_prep - nb_tx); } } fs->tx_packets += nb_tx; @@ -1194,11 +1197,11 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) fs->rx_bad_outer_ip_csum += rx_bad_outer_ip_csum; inc_tx_burst_stats(fs, nb_tx); - if (unlikely(nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); + if (unlikely(nb_tx < nb_prep)) { + fs->fwd_dropped += (nb_prep - nb_tx); do { rte_pktmbuf_free(tx_pkts_burst[nb_tx]); - } while (++nb_tx < nb_rx); + } while (++nb_tx < nb_prep); } get_end_cycles(fs, start_tsc); From patchwork Mon Feb 20 18:34:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124203 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8018441CEE; Mon, 20 Feb 2023 19:35:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 486E6430D6; Mon, 20 Feb 2023 19:35:28 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id A4C93430CE for ; Mon, 20 Feb 2023 19:35:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676918126; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CFloPvUE7SrT4Krc9+shZ19eUEkP5DA/nKstA+Tio3Y=; b=bUERGLU5T0iskR7G6hwBTQD+vZU47zKGE68SlRRU0A176xQoNBMuW66q44mu5C30/frpBq loyNu7fisdeGfu0NANmAgfaVo3R4FRDYI+U0+1rHheHoM8tbXPYq1J2i/Yol0ovkgHCoPr NoxSHP1A7iTaxKtcnISS9uoEl9K8aU8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-410-3EJjMFkMOdOmTP8H_-8AJA-1; Mon, 20 Feb 2023 13:35:21 -0500 X-MC-Unique: 3EJjMFkMOdOmTP8H_-8AJA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D0AB8858F09; Mon, 20 Feb 2023 18:35:20 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA14F492B00; Mon, 20 Feb 2023 18:35:19 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry , stable@dpdk.org Subject: [PATCH v3 2/9] app/testpmd: fix packet count in ieee15888 engine Date: Mon, 20 Feb 2023 19:34:55 +0100 Message-Id: <20230220183502.3348368-3-david.marchand@redhat.com> In-Reply-To: <20230220183502.3348368-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220183502.3348368-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Don't count a packet has been transmitted before it is done. Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: David Marchand Acked-by: Aman Singh --- app/test-pmd/ieee1588fwd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c index fc4e2d014c..896d5ef26a 100644 --- a/app/test-pmd/ieee1588fwd.c +++ b/app/test-pmd/ieee1588fwd.c @@ -184,13 +184,13 @@ ieee1588_packet_fwd(struct fwd_stream *fs) /* Forward PTP packet with hardware TX timestamp */ mb->ol_flags |= RTE_MBUF_F_TX_IEEE1588_TMST; - fs->tx_packets += 1; if (rte_eth_tx_burst(fs->rx_port, fs->tx_queue, &mb, 1) == 0) { printf("Port %u sent PTP packet dropped\n", fs->rx_port); fs->fwd_dropped += 1; rte_pktmbuf_free(mb); return; } + fs->tx_packets += 1; /* * Check the TX timestamp. From patchwork Mon Feb 20 18:34:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124204 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 18F7541CEE; Mon, 20 Feb 2023 19:35:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 69A3A430D9; Mon, 20 Feb 2023 19:35:29 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 8CD88430D5 for ; Mon, 20 Feb 2023 19:35:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676918127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fWiSG1Ux7y6BujLhoys+3EZU3EOHRDJZThF41O4yP9s=; b=M4RUKBAAIUF/12KlptDW/rpDntaMAn7V+5WvnFfgiO3v6wXlnxmdg6al9/LRNand5jUyM9 Ndnkl6YNCKccdfviv27L+N+je3M6RRxHzxLkOT+vSgZvflzvz278CdhKAI/QYCispQkAxL wgW5L4mDe9TAjXw4WklWu2DAyufsOJg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-2nrI3l_9PISFD3cbcE-8-w-1; Mon, 20 Feb 2023 13:35:24 -0500 X-MC-Unique: 2nrI3l_9PISFD3cbcE-8-w-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E73D13C0F187; Mon, 20 Feb 2023 18:35:23 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEDDD492B00; Mon, 20 Feb 2023 18:35:22 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v3 3/9] app/testpmd: rework ieee1588 engine fwd configuration Date: Mon, 20 Feb 2023 19:34:56 +0100 Message-Id: <20230220183502.3348368-4-david.marchand@redhat.com> In-Reply-To: <20230220183502.3348368-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220183502.3348368-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This fwd engine currently ignores the forwarding configuration. Force it explicitly when initialising the stream. The code is then more consistent with other fwd engines (i.e. receiving on fs->rx_port, transmitting on fs->tx_port). Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- app/test-pmd/ieee1588fwd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c index 896d5ef26a..242d272948 100644 --- a/app/test-pmd/ieee1588fwd.c +++ b/app/test-pmd/ieee1588fwd.c @@ -184,8 +184,8 @@ ieee1588_packet_fwd(struct fwd_stream *fs) /* Forward PTP packet with hardware TX timestamp */ mb->ol_flags |= RTE_MBUF_F_TX_IEEE1588_TMST; - if (rte_eth_tx_burst(fs->rx_port, fs->tx_queue, &mb, 1) == 0) { - printf("Port %u sent PTP packet dropped\n", fs->rx_port); + if (rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &mb, 1) == 0) { + printf("Port %u sent PTP packet dropped\n", fs->tx_port); fs->fwd_dropped += 1; rte_pktmbuf_free(mb); return; @@ -195,7 +195,7 @@ ieee1588_packet_fwd(struct fwd_stream *fs) /* * Check the TX timestamp. */ - port_ieee1588_tx_timestamp_check(fs->rx_port); + port_ieee1588_tx_timestamp_check(fs->tx_port); } static int @@ -216,6 +216,9 @@ port_ieee1588_stream_init(struct fwd_stream *fs) { bool rx_stopped, tx_stopped; + /* Force transmission on reception port */ + fs->tx_port = fs->rx_port; + rx_stopped = ports[fs->rx_port].rxq[fs->rx_queue].state == RTE_ETH_QUEUE_STATE_STOPPED; tx_stopped = ports[fs->tx_port].txq[fs->tx_queue].state == From patchwork Mon Feb 20 18:34:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124205 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7F0541CEE; Mon, 20 Feb 2023 19:35:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C2458430E0; Mon, 20 Feb 2023 19:35:33 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id DEAF5430E4 for ; Mon, 20 Feb 2023 19:35:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676918131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1Dji4/wCD978V1OBVX9B/v0EzSSjtqEv2rPwixNvdhc=; b=M8uIbpOPzbsC7fLPCERTrNTqbYkD3TOrsUfu++dqAAGJYxyJ6n4QOnnL0Ll8lTow2UgdMk 4MS5geC4dnUTj6Qj7443A/huU8OG4n12J+CF6glBYVzwM5ffKedukSYi41VU6x2nFBzM7Z jFEkh5TjsbRMEWMdIhDkxmTTQZ/Nw7A= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-156-bnjPsIXLNcy7Fpc-la8fsA-1; Mon, 20 Feb 2023 13:35:28 -0500 X-MC-Unique: bnjPsIXLNcy7Fpc-la8fsA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 311263C0F185; Mon, 20 Feb 2023 18:35:28 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D77EE140EBF6; Mon, 20 Feb 2023 18:35:25 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry , stable@dpdk.org, Kevin Traynor , Bernard Iremonger , Jens Freimann Subject: [PATCH v3 4/9] app/testpmd: fix packet transmission in noisy VNF engine Date: Mon, 20 Feb 2023 19:34:57 +0100 Message-Id: <20230220183502.3348368-5-david.marchand@redhat.com> In-Reply-To: <20230220183502.3348368-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220183502.3348368-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org nb_rx relates to the number of packets received from the driver. nb_tx is the total number of packets transmitted by this forward engine. Fix the retry stage, for dequeued packets, as it was incorrectly passing nb_rx / nb_tx as bounds of the tmp_pkts[] array, and fix tx stats accordingly. Fixes: 3c156061b938 ("app/testpmd: add noisy neighbour forwarding mode") Cc: stable@dpdk.org Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- app/test-pmd/noisy_vnf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/noisy_vnf.c b/app/test-pmd/noisy_vnf.c index ce5a3e5e69..0e72dc034f 100644 --- a/app/test-pmd/noisy_vnf.c +++ b/app/test-pmd/noisy_vnf.c @@ -217,9 +217,10 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs) sent = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, tmp_pkts, nb_deqd); if (unlikely(sent < nb_deqd) && fs->retry_enabled) - nb_tx += do_retry(nb_rx, nb_tx, tmp_pkts, fs); - inc_tx_burst_stats(fs, nb_tx); + sent += do_retry(nb_deqd, sent, tmp_pkts, fs); + inc_tx_burst_stats(fs, sent); fs->fwd_dropped += drop_pkts(tmp_pkts, nb_deqd, sent); + nb_tx += sent; ncf->prev_time = rte_get_timer_cycles(); } end: From patchwork Mon Feb 20 18:34:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124206 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3BDD241CEE; Mon, 20 Feb 2023 19:35:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D9EBF430E6; Mon, 20 Feb 2023 19:35:36 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 66ED0430E6 for ; Mon, 20 Feb 2023 19:35:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676918135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bGQSfsn1WU1PHwBwC981l2ri/gxPePjzW3KGikx6eYQ=; b=gf21jzp9LhTFsP4mO6WzXAi1QRapuR1gODQ06LbBUGLk9fP39yJFEyrrzZDJDkC7JntgiY jwcp6mds0XHHxa7XAfi2AVN8invkUbMobdk6WvfywMS2huVvSXC4Lv4IVGeN42vc7JJbWh kDmuWuoShrSlSA6sEmpJgMm3bz72hjk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-438-N40UgonIO3OeMuDTj7ZIpg-1; Mon, 20 Feb 2023 13:35:31 -0500 X-MC-Unique: N40UgonIO3OeMuDTj7ZIpg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 520D33814596; Mon, 20 Feb 2023 18:35:31 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45EC8140EBF6; Mon, 20 Feb 2023 18:35:30 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v3 5/9] app/testpmd: bulk free mbufs Date: Mon, 20 Feb 2023 19:34:58 +0100 Message-Id: <20230220183502.3348368-6-david.marchand@redhat.com> In-Reply-To: <20230220183502.3348368-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220183502.3348368-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Use the bulk free helper. Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit Acked-by: Stephen Hemminger --- app/test-pmd/5tswap.c | 4 +--- app/test-pmd/csumonly.c | 4 +--- app/test-pmd/flowgen.c | 8 ++------ app/test-pmd/icmpecho.c | 4 +--- app/test-pmd/iofwd.c | 4 +--- app/test-pmd/macfwd.c | 4 +--- app/test-pmd/macswap.c | 4 +--- app/test-pmd/noisy_vnf.c | 7 ++----- app/test-pmd/rxonly.c | 4 +--- app/test-pmd/shared_rxq_fwd.c | 3 +-- app/test-pmd/testpmd.c | 4 +--- app/test-pmd/txonly.c | 4 +--- 12 files changed, 14 insertions(+), 40 deletions(-) diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c index f041a5e1d5..c45a811f59 100644 --- a/app/test-pmd/5tswap.c +++ b/app/test-pmd/5tswap.c @@ -178,9 +178,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_rx)) { fs->fwd_dropped += (nb_rx - nb_tx); - do { - rte_pktmbuf_free(pkts_burst[nb_tx]); - } while (++nb_tx < nb_rx); + rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); } get_end_cycles(fs, start_tsc); } diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 90a59e0aa5..0b2d4c0593 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -1199,9 +1199,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_prep)) { fs->fwd_dropped += (nb_prep - nb_tx); - do { - rte_pktmbuf_free(tx_pkts_burst[nb_tx]); - } while (++nb_tx < nb_prep); + rte_pktmbuf_free_bulk(&tx_pkts_burst[nb_tx], nb_prep - nb_tx); } get_end_cycles(fs, start_tsc); diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index fd6abc0f41..bc3d684496 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -75,7 +75,6 @@ pkt_burst_flow_gen(struct fwd_stream *fs) uint16_t nb_dropped; uint16_t nb_pkt; uint16_t nb_clones = nb_pkt_flowgen_clones; - uint16_t i; uint32_t retry; uint64_t tx_offloads; uint64_t start_tsc = 0; @@ -89,8 +88,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs) inc_rx_burst_stats(fs, nb_rx); fs->rx_packets += nb_rx; - for (i = 0; i < nb_rx; i++) - rte_pktmbuf_free(pkts_burst[i]); + rte_pktmbuf_free_bulk(pkts_burst, nb_rx); mbp = current_fwd_lcore()->mbp; vlan_tci = ports[fs->tx_port].tx_vlan_id; @@ -189,9 +187,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs) next_flow += nb_flows_flowgen; fs->fwd_dropped += nb_dropped; - do { - rte_pktmbuf_free(pkts_burst[nb_tx]); - } while (++nb_tx < nb_pkt); + rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_pkt - nb_tx); } RTE_PER_LCORE(_next_flow) = next_flow; diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index 066f2a3ab7..5a779fca3c 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -503,9 +503,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_replies)) { fs->fwd_dropped += (nb_replies - nb_tx); - do { - rte_pktmbuf_free(pkts_burst[nb_tx]); - } while (++nb_tx < nb_replies); + rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_replies - nb_tx); } } diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c index 8fafdec548..2bcdf15728 100644 --- a/app/test-pmd/iofwd.c +++ b/app/test-pmd/iofwd.c @@ -79,9 +79,7 @@ pkt_burst_io_forward(struct fwd_stream *fs) inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_rx)) { fs->fwd_dropped += (nb_rx - nb_tx); - do { - rte_pktmbuf_free(pkts_burst[nb_tx]); - } while (++nb_tx < nb_rx); + rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); } get_end_cycles(fs, start_tsc); diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c index beb220fbb4..ba08b8f323 100644 --- a/app/test-pmd/macfwd.c +++ b/app/test-pmd/macfwd.c @@ -110,9 +110,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs) inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_rx)) { fs->fwd_dropped += (nb_rx - nb_tx); - do { - rte_pktmbuf_free(pkts_burst[nb_tx]); - } while (++nb_tx < nb_rx); + rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); } get_end_cycles(fs, start_tsc); diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index 4f8deb3382..9f0933bbff 100644 --- a/app/test-pmd/macswap.c +++ b/app/test-pmd/macswap.c @@ -89,9 +89,7 @@ pkt_burst_mac_swap(struct fwd_stream *fs) inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_rx)) { fs->fwd_dropped += (nb_rx - nb_tx); - do { - rte_pktmbuf_free(pkts_burst[nb_tx]); - } while (++nb_tx < nb_rx); + rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); } get_end_cycles(fs, start_tsc); } diff --git a/app/test-pmd/noisy_vnf.c b/app/test-pmd/noisy_vnf.c index 0e72dc034f..055a80a62c 100644 --- a/app/test-pmd/noisy_vnf.c +++ b/app/test-pmd/noisy_vnf.c @@ -111,11 +111,8 @@ do_retry(uint16_t nb_rx, uint16_t nb_tx, struct rte_mbuf **pkts, static uint32_t drop_pkts(struct rte_mbuf **pkts, uint16_t nb_rx, uint16_t nb_tx) { - if (nb_tx < nb_rx) { - do { - rte_pktmbuf_free(pkts[nb_tx]); - } while (++nb_tx < nb_rx); - } + if (nb_tx < nb_rx) + rte_pktmbuf_free_bulk(&pkts[nb_tx], nb_rx - nb_tx); return nb_rx - nb_tx; } diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index d528d4f34e..8fa5e95ad4 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -46,7 +46,6 @@ pkt_burst_receive(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; uint16_t nb_rx; - uint16_t i; uint64_t start_tsc = 0; get_start_cycles(&start_tsc); @@ -61,8 +60,7 @@ pkt_burst_receive(struct fwd_stream *fs) return; fs->rx_packets += nb_rx; - for (i = 0; i < nb_rx; i++) - rte_pktmbuf_free(pkts_burst[i]); + rte_pktmbuf_free_bulk(pkts_burst, nb_rx); get_end_cycles(fs, start_tsc); } diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c index 2e9047804b..05f90185df 100644 --- a/app/test-pmd/shared_rxq_fwd.c +++ b/app/test-pmd/shared_rxq_fwd.c @@ -53,8 +53,7 @@ forward_sub_burst(struct fwd_stream *src_fs, uint16_t port, uint16_t nb_rx, } else { /* Source stream not found, drop all packets. */ src_fs->fwd_dropped += nb_rx; - while (nb_rx > 0) - rte_pktmbuf_free(pkts[--nb_rx]); + rte_pktmbuf_free_bulk(pkts, nb_rx); } } diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 0c14325b8d..964cd0ce2b 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2204,7 +2204,6 @@ flush_fwd_rx_queues(void) portid_t port_id; queueid_t rxq; uint16_t nb_rx; - uint16_t i; uint8_t j; uint64_t prev_tsc = 0, diff_tsc, cur_tsc, timer_tsc = 0; uint64_t timer_period; @@ -2237,8 +2236,7 @@ flush_fwd_rx_queues(void) do { nb_rx = rte_eth_rx_burst(port_id, rxq, pkts_burst, MAX_PKT_BURST); - for (i = 0; i < nb_rx; i++) - rte_pktmbuf_free(pkts_burst[i]); + rte_pktmbuf_free_bulk(pkts_burst, nb_rx); cur_tsc = rte_rdtsc(); diff_tsc = cur_tsc - prev_tsc; diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 021624952d..076cdb86d5 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -421,9 +421,7 @@ pkt_burst_transmit(struct fwd_stream *fs) (unsigned) nb_pkt, (unsigned) nb_tx, (unsigned) (nb_pkt - nb_tx)); fs->fwd_dropped += (nb_pkt - nb_tx); - do { - rte_pktmbuf_free(pkts_burst[nb_tx]); - } while (++nb_tx < nb_pkt); + rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_pkt - nb_tx); } get_end_cycles(fs, start_tsc); From patchwork Mon Feb 20 18:34:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124207 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AC59741CEE; Mon, 20 Feb 2023 19:35:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 94B35430F3; Mon, 20 Feb 2023 19:35:39 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id A9435430F3 for ; Mon, 20 Feb 2023 19:35:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676918138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O/Q0MJqTFgCzYIJw1HmHdwLjbl0n3RMPTJUg4oF1tSY=; b=WZ5tYkEFIIVA68V2ntvRN85qj2DFapdPO6KF2Ii4gHwqI9AuYhYjHWfaDn8JIsD/HMw+1y vTjO/RUjtLQqSi1AxV766le/NnFFnc26Q7E225ns303LCRw75IqeYuIeFbmjZ/S3kBQL8r +bD7ZtiN9R0YuoGa5PzOCw7cyUOQwIg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-RFr8FaqCMoimY2QXxJ5gmw-1; Mon, 20 Feb 2023 13:35:34 -0500 X-MC-Unique: RFr8FaqCMoimY2QXxJ5gmw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 75FF8858F09; Mon, 20 Feb 2023 18:35:34 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 418F440B40D7; Mon, 20 Feb 2023 18:35:33 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v3 6/9] app/testpmd: factorize core cycles record Date: Mon, 20 Feb 2023 19:34:59 +0100 Message-Id: <20230220183502.3348368-7-david.marchand@redhat.com> In-Reply-To: <20230220183502.3348368-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220183502.3348368-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Rather than have each forward engines deal with core cycles recording, move this to testpmd common code. fwd engines just need to report that they did some busy work. By doing this, get_*_cycles() helpers are unneeded and removed. Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- Changes since v2: - fixed fwd_streams[] access, Changes since v1: - removed (now unneeded) get_*_cycles() helpers, - removed unrelated changes on noisy_vnf change, --- app/test-pmd/5tswap.c | 11 ++++------- app/test-pmd/csumonly.c | 10 +++------- app/test-pmd/flowgen.c | 7 ++----- app/test-pmd/icmpecho.c | 9 +++------ app/test-pmd/ieee1588fwd.c | 17 +++++++++-------- app/test-pmd/iofwd.c | 9 +++------ app/test-pmd/macfwd.c | 9 +++------ app/test-pmd/macswap.c | 10 ++++------ app/test-pmd/noisy_vnf.c | 8 ++------ app/test-pmd/rxonly.c | 9 +++------ app/test-pmd/shared_rxq_fwd.c | 9 ++++----- app/test-pmd/testpmd.c | 16 +++++++++++++--- app/test-pmd/testpmd.h | 16 +--------------- app/test-pmd/txonly.c | 9 +++------ 14 files changed, 57 insertions(+), 92 deletions(-) diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c index c45a811f59..0a3a897e7b 100644 --- a/app/test-pmd/5tswap.c +++ b/app/test-pmd/5tswap.c @@ -81,7 +81,7 @@ swap_udp(struct rte_udp_hdr *udp_hdr) * 2,3,4. Swaps source and destination for MAC, IPv4/IPv6, UDP/TCP. * Parses each layer and swaps it. When the next layer doesn't match it stops. */ -static void +static bool pkt_burst_5tuple_swap(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; @@ -105,10 +105,6 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) uint8_t *byte; } h; - uint64_t start_tsc = 0; - - get_start_cycles(&start_tsc); - /* * Receive a burst of packets and forward them. */ @@ -116,7 +112,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) nb_pkt_per_burst); inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) - return; + return false; fs->rx_packets += nb_rx; txp = &ports[fs->tx_port]; @@ -180,7 +176,8 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) fs->fwd_dropped += (nb_rx - nb_tx); rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); } - get_end_cycles(fs, start_tsc); + + return true; } static void diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 0b2d4c0593..07850501f4 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -828,7 +828,7 @@ pkts_ip_csum_recalc(struct rte_mbuf **pkts_burst, const uint16_t nb_pkts, uint64 * IP, UDP, TCP and SCTP flags always concern the inner layer. The * OUTER_IP is only useful for tunnel packets. */ -static void +static bool pkt_burst_checksum_forward(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; @@ -859,16 +859,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) uint32_t rx_bad_outer_ip_csum; struct testpmd_offload_info info; - uint64_t start_tsc = 0; - - get_start_cycles(&start_tsc); - /* receive a burst of packet */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) - return; + return false; fs->rx_packets += nb_rx; rx_bad_ip_csum = 0; @@ -1202,7 +1198,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) rte_pktmbuf_free_bulk(&tx_pkts_burst[nb_tx], nb_prep - nb_tx); } - get_end_cycles(fs, start_tsc); + return true; } static void diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index bc3d684496..b3bd4f7c65 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -58,7 +58,7 @@ RTE_DEFINE_PER_LCORE(int, _next_flow); * terminate receive traffic. Received traffic is simply discarded, but we * still do so in order to maintain traffic statistics. */ -static void +static bool pkt_burst_flow_gen(struct fwd_stream *fs) { unsigned pkt_size = tx_pkt_length - 4; /* Adjust FCS */ @@ -77,11 +77,8 @@ pkt_burst_flow_gen(struct fwd_stream *fs) uint16_t nb_clones = nb_pkt_flowgen_clones; uint32_t retry; uint64_t tx_offloads; - uint64_t start_tsc = 0; int next_flow = RTE_PER_LCORE(_next_flow); - get_start_cycles(&start_tsc); - /* Receive a burst of packets and discard them. */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); @@ -192,7 +189,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs) RTE_PER_LCORE(_next_flow) = next_flow; - get_end_cycles(fs, start_tsc); + return true; } static int diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index 5a779fca3c..5ef1116141 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -269,7 +269,7 @@ ipv4_hdr_cksum(struct rte_ipv4_hdr *ip_h) * Receive a burst of packets, lookup for ICMP echo requests, and, if any, * send back ICMP echo replies. */ -static void +static bool reply_to_icmp_echo_rqsts(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; @@ -292,9 +292,6 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) uint32_t cksum; uint8_t i; int l2_len; - uint64_t start_tsc = 0; - - get_start_cycles(&start_tsc); /* * First, receive a burst of packets. @@ -303,7 +300,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) nb_pkt_per_burst); inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) - return; + return false; fs->rx_packets += nb_rx; nb_replies = 0; @@ -507,7 +504,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) } } - get_end_cycles(fs, start_tsc); + return true; } static void diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c index 242d272948..103c01fcb7 100644 --- a/app/test-pmd/ieee1588fwd.c +++ b/app/test-pmd/ieee1588fwd.c @@ -89,7 +89,7 @@ port_ieee1588_tx_timestamp_check(portid_t pi) (wait_us == 1) ? "" : "s"); } -static void +static bool ieee1588_packet_fwd(struct fwd_stream *fs) { struct rte_mbuf *mb; @@ -103,7 +103,7 @@ ieee1588_packet_fwd(struct fwd_stream *fs) * Receive 1 packet at a time. */ if (rte_eth_rx_burst(fs->rx_port, fs->rx_queue, &mb, 1) == 0) - return; + return false; fs->rx_packets += 1; @@ -126,14 +126,14 @@ ieee1588_packet_fwd(struct fwd_stream *fs) (unsigned) mb->pkt_len); } rte_pktmbuf_free(mb); - return; + return false; } if (eth_type != RTE_ETHER_TYPE_1588) { printf("Port %u Received NON PTP packet incorrectly" " detected by hardware\n", fs->rx_port); rte_pktmbuf_free(mb); - return; + return false; } /* @@ -147,14 +147,14 @@ ieee1588_packet_fwd(struct fwd_stream *fs) " protocol version 0x%x (should be 0x02)\n", fs->rx_port, ptp_hdr->version); rte_pktmbuf_free(mb); - return; + return false; } if (ptp_hdr->msg_id != PTP_SYNC_MESSAGE) { printf("Port %u Received PTP V2 Ethernet frame with unexpected" " message ID 0x%x (expected 0x0 - PTP_SYNC_MESSAGE)\n", fs->rx_port, ptp_hdr->msg_id); rte_pktmbuf_free(mb); - return; + return false; } printf("Port %u IEEE1588 PTP V2 SYNC Message filtered by hardware\n", fs->rx_port); @@ -168,7 +168,7 @@ ieee1588_packet_fwd(struct fwd_stream *fs) " by hardware\n", fs->rx_port); rte_pktmbuf_free(mb); - return; + return false; } /* For i40e we need the timesync register index. It is ignored for the @@ -188,7 +188,7 @@ ieee1588_packet_fwd(struct fwd_stream *fs) printf("Port %u sent PTP packet dropped\n", fs->tx_port); fs->fwd_dropped += 1; rte_pktmbuf_free(mb); - return; + return false; } fs->tx_packets += 1; @@ -196,6 +196,7 @@ ieee1588_packet_fwd(struct fwd_stream *fs) * Check the TX timestamp. */ port_ieee1588_tx_timestamp_check(fs->tx_port); + return true; } static int diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c index 2bcdf15728..9d0af5f667 100644 --- a/app/test-pmd/iofwd.c +++ b/app/test-pmd/iofwd.c @@ -41,16 +41,13 @@ * This is the fastest possible forwarding operation, as it does not access * to packets data. */ -static void +static bool pkt_burst_io_forward(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; uint16_t nb_rx; uint16_t nb_tx; uint32_t retry; - uint64_t start_tsc = 0; - - get_start_cycles(&start_tsc); /* * Receive a burst of packets and forward them. @@ -59,7 +56,7 @@ pkt_burst_io_forward(struct fwd_stream *fs) pkts_burst, nb_pkt_per_burst); inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) - return; + return false; fs->rx_packets += nb_rx; nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, @@ -82,7 +79,7 @@ pkt_burst_io_forward(struct fwd_stream *fs) rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); } - get_end_cycles(fs, start_tsc); + return true; } static void diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c index ba08b8f323..3a840247c7 100644 --- a/app/test-pmd/macfwd.c +++ b/app/test-pmd/macfwd.c @@ -41,7 +41,7 @@ * Change the source and the destination Ethernet addressed of packets * before forwarding them. */ -static void +static bool pkt_burst_mac_forward(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; @@ -54,9 +54,6 @@ pkt_burst_mac_forward(struct fwd_stream *fs) uint16_t i; uint64_t ol_flags = 0; uint64_t tx_offloads; - uint64_t start_tsc = 0; - - get_start_cycles(&start_tsc); /* * Receive a burst of packets and forward them. @@ -65,7 +62,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs) nb_pkt_per_burst); inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) - return; + return false; fs->rx_packets += nb_rx; txp = &ports[fs->tx_port]; @@ -113,7 +110,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs) rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); } - get_end_cycles(fs, start_tsc); + return true; } static void diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index 9f0933bbff..14b3eefffd 100644 --- a/app/test-pmd/macswap.c +++ b/app/test-pmd/macswap.c @@ -47,7 +47,7 @@ * MAC swap forwarding mode: Swap the source and the destination Ethernet * addresses of packets before forwarding them. */ -static void +static bool pkt_burst_mac_swap(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; @@ -55,9 +55,6 @@ pkt_burst_mac_swap(struct fwd_stream *fs) uint16_t nb_rx; uint16_t nb_tx; uint32_t retry; - uint64_t start_tsc = 0; - - get_start_cycles(&start_tsc); /* * Receive a burst of packets and forward them. @@ -66,7 +63,7 @@ pkt_burst_mac_swap(struct fwd_stream *fs) nb_pkt_per_burst); inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) - return; + return false; fs->rx_packets += nb_rx; txp = &ports[fs->tx_port]; @@ -91,7 +88,8 @@ pkt_burst_mac_swap(struct fwd_stream *fs) fs->fwd_dropped += (nb_rx - nb_tx); rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); } - get_end_cycles(fs, start_tsc); + + return true; } static void diff --git a/app/test-pmd/noisy_vnf.c b/app/test-pmd/noisy_vnf.c index 055a80a62c..396fdd7814 100644 --- a/app/test-pmd/noisy_vnf.c +++ b/app/test-pmd/noisy_vnf.c @@ -134,14 +134,13 @@ drop_pkts(struct rte_mbuf **pkts, uint16_t nb_rx, uint16_t nb_tx) * out of the FIFO * 4. Cases 2 and 3 combined */ -static void +static bool pkt_burst_noisy_vnf(struct fwd_stream *fs) { const uint64_t freq_khz = rte_get_timer_hz() / 1000; struct noisy_config *ncf = noisy_cfg[fs->rx_port]; struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; struct rte_mbuf *tmp_pkts[MAX_PKT_BURST]; - uint64_t start_tsc = 0; uint16_t nb_deqd = 0; uint16_t nb_rx = 0; uint16_t nb_tx = 0; @@ -151,8 +150,6 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs) bool needs_flush = false; uint64_t now; - get_start_cycles(&start_tsc); - nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); inc_rx_burst_stats(fs, nb_rx); @@ -221,8 +218,7 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs) ncf->prev_time = rte_get_timer_cycles(); } end: - if (nb_rx > 0 || nb_tx > 0) - get_end_cycles(fs, start_tsc); + return nb_rx > 0 || nb_tx > 0; } #define NOISY_STRSIZE 256 diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index 8fa5e95ad4..ad4597cf9a 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -41,14 +41,11 @@ /* * Received a burst of packets. */ -static void +static bool pkt_burst_receive(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; uint16_t nb_rx; - uint64_t start_tsc = 0; - - get_start_cycles(&start_tsc); /* * Receive a burst of packets. @@ -57,12 +54,12 @@ pkt_burst_receive(struct fwd_stream *fs) nb_pkt_per_burst); inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) - return; + return false; fs->rx_packets += nb_rx; rte_pktmbuf_free_bulk(pkts_burst, nb_rx); - get_end_cycles(fs, start_tsc); + return true; } static void diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c index 05f90185df..4902ec407e 100644 --- a/app/test-pmd/shared_rxq_fwd.c +++ b/app/test-pmd/shared_rxq_fwd.c @@ -89,21 +89,20 @@ forward_shared_rxq(struct fwd_stream *fs, uint16_t nb_rx, &pkts_burst[nb_rx - nb_sub_burst]); } -static void +static bool shared_rxq_fwd(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[nb_pkt_per_burst]; uint16_t nb_rx; - uint64_t start_tsc = 0; - get_start_cycles(&start_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) - return; + return false; forward_shared_rxq(fs, nb_rx, pkts_burst); - get_end_cycles(fs, start_tsc); + + return true; } static void diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 964cd0ce2b..f80b1c1ca7 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2271,9 +2271,19 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) nb_fs = fc->stream_nb; prev_tsc = rte_rdtsc(); do { - for (sm_id = 0; sm_id < nb_fs; sm_id++) - if (!fsm[sm_id]->disabled) - (*pkt_fwd)(fsm[sm_id]); + for (sm_id = 0; sm_id < nb_fs; sm_id++) { + struct fwd_stream *fs = fsm[sm_id]; + uint64_t start_fs_tsc = 0; + bool busy; + + if (fs->disabled) + continue; + if (record_core_cycles) + start_fs_tsc = rte_rdtsc(); + busy = (*pkt_fwd)(fs); + if (record_core_cycles && busy) + fs->busy_cycles += rte_rdtsc() - start_fs_tsc; + } #ifdef RTE_LIB_BITRATESTATS if (bitrate_enabled != 0 && bitrate_lcore_id == rte_lcore_id()) { diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 329a6378a1..ce47d1ed92 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -382,7 +382,7 @@ struct fwd_lcore { typedef int (*port_fwd_begin_t)(portid_t pi); typedef void (*port_fwd_end_t)(portid_t pi); typedef void (*stream_init_t)(struct fwd_stream *fs); -typedef void (*packet_fwd_t)(struct fwd_stream *fs); +typedef bool (*packet_fwd_t)(struct fwd_stream *fs); struct fwd_engine { const char *fwd_mode_name; /**< Forwarding mode name. */ @@ -837,20 +837,6 @@ mbuf_pool_find(unsigned int sock_id, uint16_t idx) return rte_mempool_lookup((const char *)pool_name); } -static inline void -get_start_cycles(uint64_t *start_tsc) -{ - if (record_core_cycles) - *start_tsc = rte_rdtsc(); -} - -static inline void -get_end_cycles(struct fwd_stream *fs, uint64_t start_tsc) -{ - if (record_core_cycles) - fs->busy_cycles += rte_rdtsc() - start_tsc; -} - static inline void inc_rx_burst_stats(struct fwd_stream *fs, uint16_t nb_rx) { diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 076cdb86d5..63ad5e69bf 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -323,7 +323,7 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp, /* * Transmit a burst of multi-segments packets. */ -static void +static bool pkt_burst_transmit(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; @@ -337,9 +337,6 @@ pkt_burst_transmit(struct fwd_stream *fs) uint32_t retry; uint64_t ol_flags = 0; uint64_t tx_offloads; - uint64_t start_tsc = 0; - - get_start_cycles(&start_tsc); mbp = current_fwd_lcore()->mbp; txp = &ports[fs->tx_port]; @@ -392,7 +389,7 @@ pkt_burst_transmit(struct fwd_stream *fs) } if (nb_pkt == 0) - return; + return false; nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); @@ -424,7 +421,7 @@ pkt_burst_transmit(struct fwd_stream *fs) rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_pkt - nb_tx); } - get_end_cycles(fs, start_tsc); + return true; } static int From patchwork Mon Feb 20 18:35:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124208 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3AFE441CEE; Mon, 20 Feb 2023 19:36:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A960C430F6; Mon, 20 Feb 2023 19:35:42 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id A4DE7430F2 for ; Mon, 20 Feb 2023 19:35:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676918141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rLFjBRMHA/qP/OyCmDcIirsn9TDJFaopaPpKH4gmFxw=; b=NerSh9iQr8XR9rsB+H2Rq4KSF8Mp3NcYKGg6AdPC6beQgzEkg0eBvLnIXvEaZvVLLuA4JI gPl4nIT9JZKAdzZQcbenMIiq/oExYh/79sJHDjE/eWjKcoq3t5Oci7Dmzt1tlkefvn6sE1 qcEujfZfdTo7jq6FhptGukmdVt8JdaE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-288-b489ERi0PI61QjK7I3YsVA-1; Mon, 20 Feb 2023 13:35:38 -0500 X-MC-Unique: b489ERi0PI61QjK7I3YsVA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BEABF18A63ED; Mon, 20 Feb 2023 18:35:37 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FC962026D4B; Mon, 20 Feb 2023 18:35:36 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v3 7/9] app/testpmd: factorize fwd engine init Date: Mon, 20 Feb 2023 19:35:00 +0100 Message-Id: <20230220183502.3348368-8-david.marchand@redhat.com> In-Reply-To: <20230220183502.3348368-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220183502.3348368-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Reduce code duplication by introducing a helper that takes care of initialising the fs object. While at it, remove unneeded initialisation of fwd_engine empty fields. Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- Changes since v1: - updated ieee1588, --- app/test-pmd/5tswap.c | 16 +--------------- app/test-pmd/csumonly.c | 16 +--------------- app/test-pmd/flowgen.c | 15 +-------------- app/test-pmd/icmpecho.c | 16 +--------------- app/test-pmd/ieee1588fwd.c | 8 +------- app/test-pmd/iofwd.c | 16 +--------------- app/test-pmd/macfwd.c | 16 +--------------- app/test-pmd/macswap.c | 16 +--------------- app/test-pmd/noisy_vnf.c | 14 +------------- app/test-pmd/rxonly.c | 2 -- app/test-pmd/shared_rxq_fwd.c | 2 -- app/test-pmd/testpmd.c | 10 ++++++++++ app/test-pmd/testpmd.h | 2 ++ app/test-pmd/txonly.c | 1 - 14 files changed, 21 insertions(+), 129 deletions(-) diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c index 0a3a897e7b..7b5f58f4d4 100644 --- a/app/test-pmd/5tswap.c +++ b/app/test-pmd/5tswap.c @@ -180,22 +180,8 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) return true; } -static void -stream_init_5tuple_swap(struct fwd_stream *fs) -{ - bool rx_stopped, tx_stopped; - - rx_stopped = ports[fs->rx_port].rxq[fs->rx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - tx_stopped = ports[fs->tx_port].txq[fs->tx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - fs->disabled = rx_stopped || tx_stopped; -} - struct fwd_engine five_tuple_swap_fwd_engine = { .fwd_mode_name = "5tswap", - .port_fwd_begin = NULL, - .port_fwd_end = NULL, - .stream_init = stream_init_5tuple_swap, + .stream_init = common_fwd_stream_init, .packet_fwd = pkt_burst_5tuple_swap, }; diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 07850501f4..f72e2d74c7 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -1201,22 +1201,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) return true; } -static void -stream_init_checksum_forward(struct fwd_stream *fs) -{ - bool rx_stopped, tx_stopped; - - rx_stopped = ports[fs->rx_port].rxq[fs->rx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - tx_stopped = ports[fs->tx_port].txq[fs->tx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - fs->disabled = rx_stopped || tx_stopped; -} - struct fwd_engine csum_fwd_engine = { .fwd_mode_name = "csum", - .port_fwd_begin = NULL, - .port_fwd_end = NULL, - .stream_init = stream_init_checksum_forward, + .stream_init = common_fwd_stream_init, .packet_fwd = pkt_burst_checksum_forward, }; diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index b3bd4f7c65..6f42019353 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -199,22 +199,9 @@ flowgen_begin(portid_t pi) return 0; } -static void -flowgen_stream_init(struct fwd_stream *fs) -{ - bool rx_stopped, tx_stopped; - - rx_stopped = ports[fs->rx_port].rxq[fs->rx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - tx_stopped = ports[fs->tx_port].txq[fs->tx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - fs->disabled = rx_stopped || tx_stopped; -} - struct fwd_engine flow_gen_engine = { .fwd_mode_name = "flowgen", .port_fwd_begin = flowgen_begin, - .port_fwd_end = NULL, - .stream_init = flowgen_stream_init, + .stream_init = common_fwd_stream_init, .packet_fwd = pkt_burst_flow_gen, }; diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index 5ef1116141..eba8b99f1e 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -507,22 +507,8 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) return true; } -static void -icmpecho_stream_init(struct fwd_stream *fs) -{ - bool rx_stopped, tx_stopped; - - rx_stopped = ports[fs->rx_port].rxq[fs->rx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - tx_stopped = ports[fs->tx_port].txq[fs->tx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - fs->disabled = rx_stopped || tx_stopped; -} - struct fwd_engine icmp_echo_engine = { .fwd_mode_name = "icmpecho", - .port_fwd_begin = NULL, - .port_fwd_end = NULL, - .stream_init = icmpecho_stream_init, + .stream_init = common_fwd_stream_init, .packet_fwd = reply_to_icmp_echo_rqsts, }; diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c index 103c01fcb7..fd8ba27b2f 100644 --- a/app/test-pmd/ieee1588fwd.c +++ b/app/test-pmd/ieee1588fwd.c @@ -215,16 +215,10 @@ port_ieee1588_fwd_end(portid_t pi) static void port_ieee1588_stream_init(struct fwd_stream *fs) { - bool rx_stopped, tx_stopped; - /* Force transmission on reception port */ fs->tx_port = fs->rx_port; - rx_stopped = ports[fs->rx_port].rxq[fs->rx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - tx_stopped = ports[fs->tx_port].txq[fs->tx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - fs->disabled = rx_stopped || tx_stopped; + common_fwd_stream_init(fs); } struct fwd_engine ieee1588_fwd_engine = { diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c index 9d0af5f667..12be06fa79 100644 --- a/app/test-pmd/iofwd.c +++ b/app/test-pmd/iofwd.c @@ -82,22 +82,8 @@ pkt_burst_io_forward(struct fwd_stream *fs) return true; } -static void -stream_init_forward(struct fwd_stream *fs) -{ - bool rx_stopped, tx_stopped; - - rx_stopped = ports[fs->rx_port].rxq[fs->rx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - tx_stopped = ports[fs->tx_port].txq[fs->tx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - fs->disabled = rx_stopped || tx_stopped; -} - struct fwd_engine io_fwd_engine = { .fwd_mode_name = "io", - .port_fwd_begin = NULL, - .port_fwd_end = NULL, - .stream_init = stream_init_forward, + .stream_init = common_fwd_stream_init, .packet_fwd = pkt_burst_io_forward, }; diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c index 3a840247c7..953d9ea089 100644 --- a/app/test-pmd/macfwd.c +++ b/app/test-pmd/macfwd.c @@ -113,22 +113,8 @@ pkt_burst_mac_forward(struct fwd_stream *fs) return true; } -static void -stream_init_mac_forward(struct fwd_stream *fs) -{ - bool rx_stopped, tx_stopped; - - rx_stopped = ports[fs->rx_port].rxq[fs->rx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - tx_stopped = ports[fs->tx_port].txq[fs->tx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - fs->disabled = rx_stopped || tx_stopped; -} - struct fwd_engine mac_fwd_engine = { .fwd_mode_name = "mac", - .port_fwd_begin = NULL, - .port_fwd_end = NULL, - .stream_init = stream_init_mac_forward, + .stream_init = common_fwd_stream_init, .packet_fwd = pkt_burst_mac_forward, }; diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index 14b3eefffd..062542dc53 100644 --- a/app/test-pmd/macswap.c +++ b/app/test-pmd/macswap.c @@ -92,22 +92,8 @@ pkt_burst_mac_swap(struct fwd_stream *fs) return true; } -static void -stream_init_mac_swap(struct fwd_stream *fs) -{ - bool rx_stopped, tx_stopped; - - rx_stopped = ports[fs->rx_port].rxq[fs->rx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - tx_stopped = ports[fs->tx_port].txq[fs->tx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - fs->disabled = rx_stopped || tx_stopped; -} - struct fwd_engine mac_swap_engine = { .fwd_mode_name = "macswap", - .port_fwd_begin = NULL, - .port_fwd_end = NULL, - .stream_init = stream_init_mac_swap, + .stream_init = common_fwd_stream_init, .packet_fwd = pkt_burst_mac_swap, }; diff --git a/app/test-pmd/noisy_vnf.c b/app/test-pmd/noisy_vnf.c index 396fdd7814..7bcab84db3 100644 --- a/app/test-pmd/noisy_vnf.c +++ b/app/test-pmd/noisy_vnf.c @@ -278,22 +278,10 @@ noisy_fwd_begin(portid_t pi) return 0; } -static void -stream_init_noisy_vnf(struct fwd_stream *fs) -{ - bool rx_stopped, tx_stopped; - - rx_stopped = ports[fs->rx_port].rxq[fs->rx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - tx_stopped = ports[fs->tx_port].txq[fs->tx_queue].state == - RTE_ETH_QUEUE_STATE_STOPPED; - fs->disabled = rx_stopped || tx_stopped; -} - struct fwd_engine noisy_vnf_engine = { .fwd_mode_name = "noisy", .port_fwd_begin = noisy_fwd_begin, .port_fwd_end = noisy_fwd_end, - .stream_init = stream_init_noisy_vnf, + .stream_init = common_fwd_stream_init, .packet_fwd = pkt_burst_noisy_vnf, }; diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index ad4597cf9a..d4bff9b5ea 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -71,8 +71,6 @@ stream_init_receive(struct fwd_stream *fs) struct fwd_engine rx_only_engine = { .fwd_mode_name = "rxonly", - .port_fwd_begin = NULL, - .port_fwd_end = NULL, .stream_init = stream_init_receive, .packet_fwd = pkt_burst_receive, }; diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c index 4902ec407e..67e5494735 100644 --- a/app/test-pmd/shared_rxq_fwd.c +++ b/app/test-pmd/shared_rxq_fwd.c @@ -114,8 +114,6 @@ shared_rxq_stream_init(struct fwd_stream *fs) struct fwd_engine shared_rxq_engine = { .fwd_mode_name = "shared_rxq", - .port_fwd_begin = NULL, - .port_fwd_end = NULL, .stream_init = shared_rxq_stream_init, .packet_fwd = shared_rxq_fwd, }; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index f80b1c1ca7..b6197aa258 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2387,6 +2387,16 @@ launch_packet_forwarding(lcore_function_t *pkt_fwd_on_lcore) } } +void +common_fwd_stream_init(struct fwd_stream *fs) +{ + bool rx_stopped, tx_stopped; + + rx_stopped = (ports[fs->rx_port].rxq[fs->rx_queue].state == RTE_ETH_QUEUE_STATE_STOPPED); + tx_stopped = (ports[fs->tx_port].txq[fs->tx_queue].state == RTE_ETH_QUEUE_STATE_STOPPED); + fs->disabled = rx_stopped || tx_stopped; +} + /* * Launch packet forwarding configuration. */ diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index ce47d1ed92..4b28cd0d0d 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -392,6 +392,8 @@ struct fwd_engine { packet_fwd_t packet_fwd; /**< Mandatory. */ }; +void common_fwd_stream_init(struct fwd_stream *fs); + #define FLEX_ITEM_MAX_SAMPLES_NUM 16 #define FLEX_ITEM_MAX_LINKS_NUM 16 #define FLEX_MAX_FLOW_PATTERN_LENGTH 64 diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 63ad5e69bf..b80ab6f5df 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -508,7 +508,6 @@ tx_only_stream_init(struct fwd_stream *fs) struct fwd_engine tx_only_engine = { .fwd_mode_name = "txonly", .port_fwd_begin = tx_only_begin, - .port_fwd_end = NULL, .stream_init = tx_only_stream_init, .packet_fwd = pkt_burst_transmit, }; From patchwork Mon Feb 20 18:35:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124209 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BAFD641CEE; Mon, 20 Feb 2023 19:36:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 25E5C430FB; Mon, 20 Feb 2023 19:35:46 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 87A4B430D0 for ; Mon, 20 Feb 2023 19:35:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676918144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lE441bsX29J96p+i3F/ri9/vtQP0Cp0NV9NZk3TM63Y=; b=ibCki/MD5FGMJd98+jRTt086QQB+k8r5nopM/3l1W93I4sDi2TVsihjGXN7U+OLfgjVEen rW1E8ZfddTZyF0hSEXtbVsuInrJTGVwXiWHEyfCNFa6AETPpgKd7N5VmGvVlXeYcZ8Z05r YnngS27p38ZcJjK7y/b9ezNb5h/IYus= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-lEazZYOnNUSAgO3Hp8wEQg-1; Mon, 20 Feb 2023 13:35:41 -0500 X-MC-Unique: lEazZYOnNUSAgO3Hp8wEQg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B806A101A52E; Mon, 20 Feb 2023 18:35:40 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACECC140EBF6; Mon, 20 Feb 2023 18:35:39 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v3 8/9] app/testpmd: factorize fwd engine Rx Date: Mon, 20 Feb 2023 19:35:01 +0100 Message-Id: <20230220183502.3348368-9-david.marchand@redhat.com> In-Reply-To: <20230220183502.3348368-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220183502.3348368-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Reduce code duplication by introducing a helper that takes care of receiving packets and incrementing rx counter. inc_rx_burst_stats() is then unneeded and removed. Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- Changes since v1: - updated shared_rxq fwd engine, - removed inc_rx_burst_stats helper, - removed likely() around rx stats update, --- app/test-pmd/5tswap.c | 5 +---- app/test-pmd/csumonly.c | 5 +---- app/test-pmd/flowgen.c | 5 +---- app/test-pmd/icmpecho.c | 5 +---- app/test-pmd/ieee1588fwd.c | 4 +--- app/test-pmd/iofwd.c | 5 +---- app/test-pmd/macfwd.c | 5 +---- app/test-pmd/macswap.c | 5 +---- app/test-pmd/noisy_vnf.c | 5 +---- app/test-pmd/rxonly.c | 5 +---- app/test-pmd/shared_rxq_fwd.c | 4 +--- app/test-pmd/testpmd.h | 10 ++++++++-- 12 files changed, 19 insertions(+), 44 deletions(-) diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c index 7b5f58f4d4..27da867d7f 100644 --- a/app/test-pmd/5tswap.c +++ b/app/test-pmd/5tswap.c @@ -108,13 +108,10 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) /* * Receive a burst of packets and forward them. */ - nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, - nb_pkt_per_burst); - inc_rx_burst_stats(fs, nb_rx); + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); if (unlikely(nb_rx == 0)) return false; - fs->rx_packets += nb_rx; txp = &ports[fs->tx_port]; ol_flags = ol_flags_init(txp->dev_conf.txmode.offloads); vlan_qinq_set(pkts_burst, nb_rx, ol_flags, diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index f72e2d74c7..d758ae0ac6 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -860,13 +860,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) struct testpmd_offload_info info; /* receive a burst of packet */ - nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, - nb_pkt_per_burst); - inc_rx_burst_stats(fs, nb_rx); + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); if (unlikely(nb_rx == 0)) return false; - fs->rx_packets += nb_rx; rx_bad_ip_csum = 0; rx_bad_l4_csum = 0; rx_bad_outer_l4_csum = 0; diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index 6f42019353..3705cc60c5 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -80,10 +80,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs) int next_flow = RTE_PER_LCORE(_next_flow); /* Receive a burst of packets and discard them. */ - nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, - nb_pkt_per_burst); - inc_rx_burst_stats(fs, nb_rx); - fs->rx_packets += nb_rx; + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); rte_pktmbuf_free_bulk(pkts_burst, nb_rx); diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index eba8b99f1e..48f8fe0bf1 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -296,13 +296,10 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) /* * First, receive a burst of packets. */ - nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, - nb_pkt_per_burst); - inc_rx_burst_stats(fs, nb_rx); + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); if (unlikely(nb_rx == 0)) return false; - fs->rx_packets += nb_rx; nb_replies = 0; for (i = 0; i < nb_rx; i++) { if (likely(i < nb_rx - 1)) diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c index fd8ba27b2f..1d51ebfe9d 100644 --- a/app/test-pmd/ieee1588fwd.c +++ b/app/test-pmd/ieee1588fwd.c @@ -102,11 +102,9 @@ ieee1588_packet_fwd(struct fwd_stream *fs) /* * Receive 1 packet at a time. */ - if (rte_eth_rx_burst(fs->rx_port, fs->rx_queue, &mb, 1) == 0) + if (common_fwd_stream_receive(fs, &mb, 1) == 0) return false; - fs->rx_packets += 1; - /* * Check that the received packet is a PTP packet that was detected * by the hardware. diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c index 12be06fa79..69b583cb5b 100644 --- a/app/test-pmd/iofwd.c +++ b/app/test-pmd/iofwd.c @@ -52,12 +52,9 @@ pkt_burst_io_forward(struct fwd_stream *fs) /* * Receive a burst of packets and forward them. */ - nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, - pkts_burst, nb_pkt_per_burst); - inc_rx_burst_stats(fs, nb_rx); + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); if (unlikely(nb_rx == 0)) return false; - fs->rx_packets += nb_rx; nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c index 953d9ea089..a72f5ccb75 100644 --- a/app/test-pmd/macfwd.c +++ b/app/test-pmd/macfwd.c @@ -58,13 +58,10 @@ pkt_burst_mac_forward(struct fwd_stream *fs) /* * Receive a burst of packets and forward them. */ - nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, - nb_pkt_per_burst); - inc_rx_burst_stats(fs, nb_rx); + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); if (unlikely(nb_rx == 0)) return false; - fs->rx_packets += nb_rx; txp = &ports[fs->tx_port]; tx_offloads = txp->dev_conf.txmode.offloads; if (tx_offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index 062542dc53..ab37123404 100644 --- a/app/test-pmd/macswap.c +++ b/app/test-pmd/macswap.c @@ -59,13 +59,10 @@ pkt_burst_mac_swap(struct fwd_stream *fs) /* * Receive a burst of packets and forward them. */ - nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, - nb_pkt_per_burst); - inc_rx_burst_stats(fs, nb_rx); + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); if (unlikely(nb_rx == 0)) return false; - fs->rx_packets += nb_rx; txp = &ports[fs->tx_port]; do_macswap(pkts_burst, nb_rx, txp); diff --git a/app/test-pmd/noisy_vnf.c b/app/test-pmd/noisy_vnf.c index 7bcab84db3..e543adc865 100644 --- a/app/test-pmd/noisy_vnf.c +++ b/app/test-pmd/noisy_vnf.c @@ -150,12 +150,9 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs) bool needs_flush = false; uint64_t now; - nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, - pkts_burst, nb_pkt_per_burst); - inc_rx_burst_stats(fs, nb_rx); + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); if (unlikely(nb_rx == 0)) goto flush; - fs->rx_packets += nb_rx; if (!ncf->do_buffering) { sim_memory_lookups(ncf, nb_rx); diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index d4bff9b5ea..315f9286cd 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -50,13 +50,10 @@ pkt_burst_receive(struct fwd_stream *fs) /* * Receive a burst of packets. */ - nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, - nb_pkt_per_burst); - inc_rx_burst_stats(fs, nb_rx); + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); if (unlikely(nb_rx == 0)) return false; - fs->rx_packets += nb_rx; rte_pktmbuf_free_bulk(pkts_burst, nb_rx); return true; diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c index 67e5494735..623d62da88 100644 --- a/app/test-pmd/shared_rxq_fwd.c +++ b/app/test-pmd/shared_rxq_fwd.c @@ -95,9 +95,7 @@ shared_rxq_fwd(struct fwd_stream *fs) struct rte_mbuf *pkts_burst[nb_pkt_per_burst]; uint16_t nb_rx; - nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, - nb_pkt_per_burst); - inc_rx_burst_stats(fs, nb_rx); + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); if (unlikely(nb_rx == 0)) return false; forward_shared_rxq(fs, nb_rx, pkts_burst); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 4b28cd0d0d..6c82cbab45 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -839,11 +839,17 @@ mbuf_pool_find(unsigned int sock_id, uint16_t idx) return rte_mempool_lookup((const char *)pool_name); } -static inline void -inc_rx_burst_stats(struct fwd_stream *fs, uint16_t nb_rx) +static inline uint16_t +common_fwd_stream_receive(struct fwd_stream *fs, struct rte_mbuf **burst, + unsigned int nb_pkts) { + uint16_t nb_rx; + + nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, burst, nb_pkts); if (record_burst_stats) fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; + fs->rx_packets += nb_rx; + return nb_rx; } static inline void From patchwork Mon Feb 20 18:35:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124210 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DA80F41CEE; Mon, 20 Feb 2023 19:36:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 341CF430F1; Mon, 20 Feb 2023 19:35:49 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id DE7F7430D1 for ; Mon, 20 Feb 2023 19:35:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676918145; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zlkKsejOwA69Ke0yMgZNTuX+DEhPXcAMeaaIgzkWbp8=; b=Gzp6eUQIVITwUvGSGPPuDpG1BX0/A+mVgk91OV2QCgy5FUhitoaBT0BgHPDxKz1U/y1fCQ h6auNAACARagO7m5iQ5nQrHM48xgGK2xA94xBxnP6JHPfND7QJOvV7QGp8l3VqxGm/tt6p YaFw4Sp/sIvrE7VSuQHLKN+bGPEah5k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-128-tniId93CNQyT_i7DRtOkgw-1; Mon, 20 Feb 2023 13:35:44 -0500 X-MC-Unique: tniId93CNQyT_i7DRtOkgw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 09F43858F0E; Mon, 20 Feb 2023 18:35:44 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D01A4C15BA0; Mon, 20 Feb 2023 18:35:42 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v3 9/9] app/testpmd: factorize fwd engine Tx Date: Mon, 20 Feb 2023 19:35:02 +0100 Message-Id: <20230220183502.3348368-10-david.marchand@redhat.com> In-Reply-To: <20230220183502.3348368-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220183502.3348368-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Reduce code duplication by introducing a helper that takes care of transmitting, retrying if enabled and incrementing tx counter. inc_tx_burst_stats() is then unneeded and removed. Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- Changes since v1: - changed Tx helper so it matches rte_eth_tx_burst() semantic, - updated ieee1588, - removed inc_tx_burst_stats helper, --- app/test-pmd/5tswap.c | 22 +----------- app/test-pmd/csumonly.c | 23 +------------ app/test-pmd/flowgen.c | 20 +---------- app/test-pmd/icmpecho.c | 28 ++-------------- app/test-pmd/ieee1588fwd.c | 5 +-- app/test-pmd/iofwd.c | 22 +----------- app/test-pmd/macfwd.c | 21 +----------- app/test-pmd/macswap.c | 27 ++------------- app/test-pmd/noisy_vnf.c | 68 ++++++-------------------------------- app/test-pmd/testpmd.h | 27 +++++++++++++-- app/test-pmd/txonly.c | 19 +---------- 11 files changed, 47 insertions(+), 235 deletions(-) diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c index 27da867d7f..ff8c2dcde5 100644 --- a/app/test-pmd/5tswap.c +++ b/app/test-pmd/5tswap.c @@ -91,9 +91,6 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) uint64_t ol_flags; uint16_t proto; uint16_t nb_rx; - uint16_t nb_tx; - uint32_t retry; - int i; union { struct rte_ether_hdr *eth; @@ -155,24 +152,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) } mbuf_field_set(mb, ol_flags); } - nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); - /* - * Retry if necessary - */ - if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { - retry = 0; - while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { - rte_delay_us(burst_tx_delay_time); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; - inc_tx_burst_stats(fs, nb_tx); - if (unlikely(nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); - rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); - } + common_fwd_stream_transmit(fs, pkts_burst, nb_rx); return true; } diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index d758ae0ac6..fc85c22a77 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -847,12 +847,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) uint8_t gro_enable; #endif uint16_t nb_rx; - uint16_t nb_tx; uint16_t nb_prep; uint16_t i; uint64_t rx_ol_flags, tx_ol_flags; uint64_t tx_offloads; - uint32_t retry; uint32_t rx_bad_ip_csum; uint32_t rx_bad_l4_csum; uint32_t rx_bad_outer_l4_csum; @@ -1169,32 +1167,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) rte_pktmbuf_free_bulk(&tx_pkts_burst[nb_prep], nb_rx - nb_prep); } - nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, tx_pkts_burst, - nb_prep); + common_fwd_stream_transmit(fs, tx_pkts_burst, nb_prep); - /* - * Retry if necessary - */ - if (unlikely(nb_tx < nb_prep) && fs->retry_enabled) { - retry = 0; - while (nb_tx < nb_prep && retry++ < burst_tx_retry_num) { - rte_delay_us(burst_tx_delay_time); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - &tx_pkts_burst[nb_tx], nb_prep - nb_tx); - } - } - fs->tx_packets += nb_tx; fs->rx_bad_ip_csum += rx_bad_ip_csum; fs->rx_bad_l4_csum += rx_bad_l4_csum; fs->rx_bad_outer_l4_csum += rx_bad_outer_l4_csum; fs->rx_bad_outer_ip_csum += rx_bad_outer_ip_csum; - inc_tx_burst_stats(fs, nb_tx); - if (unlikely(nb_tx < nb_prep)) { - fs->fwd_dropped += (nb_prep - nb_tx); - rte_pktmbuf_free_bulk(&tx_pkts_burst[nb_tx], nb_prep - nb_tx); - } - return true; } diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index 3705cc60c5..53b5f24f11 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -75,7 +75,6 @@ pkt_burst_flow_gen(struct fwd_stream *fs) uint16_t nb_dropped; uint16_t nb_pkt; uint16_t nb_clones = nb_pkt_flowgen_clones; - uint32_t retry; uint64_t tx_offloads; int next_flow = RTE_PER_LCORE(_next_flow); @@ -158,30 +157,13 @@ pkt_burst_flow_gen(struct fwd_stream *fs) next_flow = 0; } - nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); - /* - * Retry if necessary - */ - if (unlikely(nb_tx < nb_pkt) && fs->retry_enabled) { - retry = 0; - while (nb_tx < nb_pkt && retry++ < burst_tx_retry_num) { - rte_delay_us(burst_tx_delay_time); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_pkt - nb_tx); - } - } - fs->tx_packets += nb_tx; - - inc_tx_burst_stats(fs, nb_tx); + nb_tx = common_fwd_stream_transmit(fs, pkts_burst, nb_pkt); nb_dropped = nb_pkt - nb_tx; if (unlikely(nb_dropped > 0)) { /* Back out the flow counter. */ next_flow -= nb_dropped; while (next_flow < 0) next_flow += nb_flows_flowgen; - - fs->fwd_dropped += nb_dropped; - rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_pkt - nb_tx); } RTE_PER_LCORE(_next_flow) = next_flow; diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index 48f8fe0bf1..68524484e3 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -280,10 +280,8 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) struct rte_ipv4_hdr *ip_h; struct rte_icmp_hdr *icmp_h; struct rte_ether_addr eth_addr; - uint32_t retry; uint32_t ip_addr; uint16_t nb_rx; - uint16_t nb_tx; uint16_t nb_replies; uint16_t eth_type; uint16_t vlan_id; @@ -476,30 +474,8 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) } /* Send back ICMP echo replies, if any. */ - if (nb_replies > 0) { - nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, - nb_replies); - /* - * Retry if necessary - */ - if (unlikely(nb_tx < nb_replies) && fs->retry_enabled) { - retry = 0; - while (nb_tx < nb_replies && - retry++ < burst_tx_retry_num) { - rte_delay_us(burst_tx_delay_time); - nb_tx += rte_eth_tx_burst(fs->tx_port, - fs->tx_queue, - &pkts_burst[nb_tx], - nb_replies - nb_tx); - } - } - fs->tx_packets += nb_tx; - inc_tx_burst_stats(fs, nb_tx); - if (unlikely(nb_tx < nb_replies)) { - fs->fwd_dropped += (nb_replies - nb_tx); - rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_replies - nb_tx); - } - } + if (nb_replies > 0) + common_fwd_stream_transmit(fs, pkts_burst, nb_replies); return true; } diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c index 1d51ebfe9d..386d9f10e6 100644 --- a/app/test-pmd/ieee1588fwd.c +++ b/app/test-pmd/ieee1588fwd.c @@ -182,13 +182,10 @@ ieee1588_packet_fwd(struct fwd_stream *fs) /* Forward PTP packet with hardware TX timestamp */ mb->ol_flags |= RTE_MBUF_F_TX_IEEE1588_TMST; - if (rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &mb, 1) == 0) { + if (common_fwd_stream_transmit(fs, &mb, 1) == 0) { printf("Port %u sent PTP packet dropped\n", fs->tx_port); - fs->fwd_dropped += 1; - rte_pktmbuf_free(mb); return false; } - fs->tx_packets += 1; /* * Check the TX timestamp. diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c index 69b583cb5b..ba06fae4a6 100644 --- a/app/test-pmd/iofwd.c +++ b/app/test-pmd/iofwd.c @@ -46,8 +46,6 @@ pkt_burst_io_forward(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; uint16_t nb_rx; - uint16_t nb_tx; - uint32_t retry; /* * Receive a burst of packets and forward them. @@ -56,25 +54,7 @@ pkt_burst_io_forward(struct fwd_stream *fs) if (unlikely(nb_rx == 0)) return false; - nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - pkts_burst, nb_rx); - /* - * Retry if necessary - */ - if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { - retry = 0; - while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { - rte_delay_us(burst_tx_delay_time); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; - inc_tx_burst_stats(fs, nb_tx); - if (unlikely(nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); - rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); - } + common_fwd_stream_transmit(fs, pkts_burst, nb_rx); return true; } diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c index a72f5ccb75..7316d73315 100644 --- a/app/test-pmd/macfwd.c +++ b/app/test-pmd/macfwd.c @@ -48,9 +48,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs) struct rte_port *txp; struct rte_mbuf *mb; struct rte_ether_hdr *eth_hdr; - uint32_t retry; uint16_t nb_rx; - uint16_t nb_tx; uint16_t i; uint64_t ol_flags = 0; uint64_t tx_offloads; @@ -87,25 +85,8 @@ pkt_burst_mac_forward(struct fwd_stream *fs) mb->vlan_tci = txp->tx_vlan_id; mb->vlan_tci_outer = txp->tx_vlan_id_outer; } - nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); - /* - * Retry if necessary - */ - if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { - retry = 0; - while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { - rte_delay_us(burst_tx_delay_time); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; - inc_tx_burst_stats(fs, nb_tx); - if (unlikely(nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); - rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); - } + common_fwd_stream_transmit(fs, pkts_burst, nb_rx); return true; } diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index ab37123404..57f77003fe 100644 --- a/app/test-pmd/macswap.c +++ b/app/test-pmd/macswap.c @@ -51,10 +51,7 @@ static bool pkt_burst_mac_swap(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; - struct rte_port *txp; uint16_t nb_rx; - uint16_t nb_tx; - uint32_t retry; /* * Receive a burst of packets and forward them. @@ -63,28 +60,8 @@ pkt_burst_mac_swap(struct fwd_stream *fs) if (unlikely(nb_rx == 0)) return false; - txp = &ports[fs->tx_port]; - - do_macswap(pkts_burst, nb_rx, txp); - - nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); - /* - * Retry if necessary - */ - if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { - retry = 0; - while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { - rte_delay_us(burst_tx_delay_time); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; - inc_tx_burst_stats(fs, nb_tx); - if (unlikely(nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); - rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx); - } + do_macswap(pkts_burst, nb_rx, &ports[fs->tx_port]); + common_fwd_stream_transmit(fs, pkts_burst, nb_rx); return true; } diff --git a/app/test-pmd/noisy_vnf.c b/app/test-pmd/noisy_vnf.c index e543adc865..2bf90a983c 100644 --- a/app/test-pmd/noisy_vnf.c +++ b/app/test-pmd/noisy_vnf.c @@ -93,30 +93,6 @@ sim_memory_lookups(struct noisy_config *ncf, uint16_t nb_pkts) } } -static uint16_t -do_retry(uint16_t nb_rx, uint16_t nb_tx, struct rte_mbuf **pkts, - struct fwd_stream *fs) -{ - uint32_t retry = 0; - - while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { - rte_delay_us(burst_tx_delay_time); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - &pkts[nb_tx], nb_rx - nb_tx); - } - - return nb_tx; -} - -static uint32_t -drop_pkts(struct rte_mbuf **pkts, uint16_t nb_rx, uint16_t nb_tx) -{ - if (nb_tx < nb_rx) - rte_pktmbuf_free_bulk(&pkts[nb_tx], nb_rx - nb_tx); - - return nb_rx - nb_tx; -} - /* * Forwarding of packets in noisy VNF mode. Forward packets but perform * memory operations first as specified on cmdline. @@ -156,37 +132,22 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs) if (!ncf->do_buffering) { sim_memory_lookups(ncf, nb_rx); - nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - pkts_burst, nb_rx); - if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) - nb_tx += do_retry(nb_rx, nb_tx, pkts_burst, fs); - inc_tx_burst_stats(fs, nb_tx); - fs->tx_packets += nb_tx; - fs->fwd_dropped += drop_pkts(pkts_burst, nb_rx, nb_tx); + nb_tx = common_fwd_stream_transmit(fs, pkts_burst, nb_rx); goto end; } fifo_free = rte_ring_free_count(ncf->f); if (fifo_free >= nb_rx) { - nb_enqd = rte_ring_enqueue_burst(ncf->f, - (void **) pkts_burst, nb_rx, NULL); - if (nb_enqd < nb_rx) - fs->fwd_dropped += drop_pkts(pkts_burst, - nb_rx, nb_enqd); - } else { - nb_deqd = rte_ring_dequeue_burst(ncf->f, - (void **) tmp_pkts, nb_rx, NULL); - nb_enqd = rte_ring_enqueue_burst(ncf->f, - (void **) pkts_burst, nb_deqd, NULL); - if (nb_deqd > 0) { - nb_tx = rte_eth_tx_burst(fs->tx_port, - fs->tx_queue, tmp_pkts, - nb_deqd); - if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) - nb_tx += do_retry(nb_rx, nb_tx, tmp_pkts, fs); - inc_tx_burst_stats(fs, nb_tx); - fs->fwd_dropped += drop_pkts(tmp_pkts, nb_deqd, nb_tx); + nb_enqd = rte_ring_enqueue_burst(ncf->f, (void **) pkts_burst, nb_rx, NULL); + if (nb_enqd < nb_rx) { + fs->fwd_dropped += nb_rx - nb_enqd; + rte_pktmbuf_free_bulk(&pkts_burst[nb_enqd], nb_rx - nb_enqd); } + } else { + nb_deqd = rte_ring_dequeue_burst(ncf->f, (void **) tmp_pkts, nb_rx, NULL); + nb_enqd = rte_ring_enqueue_burst(ncf->f, (void **) pkts_burst, nb_deqd, NULL); + if (nb_deqd > 0) + nb_tx = common_fwd_stream_transmit(fs, tmp_pkts, nb_deqd); } sim_memory_lookups(ncf, nb_enqd); @@ -202,16 +163,9 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs) noisy_tx_sw_buf_flush_time > 0 && !nb_tx; } while (needs_flush && !rte_ring_empty(ncf->f)) { - unsigned int sent; nb_deqd = rte_ring_dequeue_burst(ncf->f, (void **)tmp_pkts, MAX_PKT_BURST, NULL); - sent = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - tmp_pkts, nb_deqd); - if (unlikely(sent < nb_deqd) && fs->retry_enabled) - sent += do_retry(nb_deqd, sent, tmp_pkts, fs); - inc_tx_burst_stats(fs, sent); - fs->fwd_dropped += drop_pkts(tmp_pkts, nb_deqd, sent); - nb_tx += sent; + nb_tx += common_fwd_stream_transmit(fs, tmp_pkts, nb_deqd); ncf->prev_time = rte_get_timer_cycles(); } end: diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 6c82cbab45..b9215720b6 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -852,11 +852,34 @@ common_fwd_stream_receive(struct fwd_stream *fs, struct rte_mbuf **burst, return nb_rx; } -static inline void -inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx) +static inline uint16_t +common_fwd_stream_transmit(struct fwd_stream *fs, struct rte_mbuf **burst, + unsigned int nb_pkts) { + uint16_t nb_tx; + uint32_t retry; + + nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, burst, nb_pkts); + /* + * Retry if necessary + */ + if (unlikely(nb_tx < nb_pkts) && fs->retry_enabled) { + retry = 0; + while (nb_tx < nb_pkts && retry++ < burst_tx_retry_num) { + rte_delay_us(burst_tx_delay_time); + nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, + &burst[nb_tx], nb_pkts - nb_tx); + } + } + fs->tx_packets += nb_tx; if (record_burst_stats) fs->tx_burst_stats.pkt_burst_spread[nb_tx]++; + if (unlikely(nb_tx < nb_pkts)) { + fs->fwd_dropped += (nb_pkts - nb_tx); + rte_pktmbuf_free_bulk(&burst[nb_tx], nb_pkts - nb_tx); + } + + return nb_tx; } /* Prototypes */ diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index b80ab6f5df..b3d6873104 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -334,7 +334,6 @@ pkt_burst_transmit(struct fwd_stream *fs) uint16_t nb_tx; uint16_t nb_pkt; uint16_t vlan_tci, vlan_tci_outer; - uint32_t retry; uint64_t ol_flags = 0; uint64_t tx_offloads; @@ -391,25 +390,11 @@ pkt_burst_transmit(struct fwd_stream *fs) if (nb_pkt == 0) return false; - nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); - - /* - * Retry if necessary - */ - if (unlikely(nb_tx < nb_pkt) && fs->retry_enabled) { - retry = 0; - while (nb_tx < nb_pkt && retry++ < burst_tx_retry_num) { - rte_delay_us(burst_tx_delay_time); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_pkt - nb_tx); - } - } - fs->tx_packets += nb_tx; + nb_tx = common_fwd_stream_transmit(fs, pkts_burst, nb_pkt); if (txonly_multi_flow) RTE_PER_LCORE(_ip_var) -= nb_pkt - nb_tx; - inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_pkt)) { if (verbose_level > 0 && fs->fwd_dropped == 0) printf("port %d tx_queue %d - drop " @@ -417,8 +402,6 @@ pkt_burst_transmit(struct fwd_stream *fs) fs->tx_port, fs->tx_queue, (unsigned) nb_pkt, (unsigned) nb_tx, (unsigned) (nb_pkt - nb_tx)); - fs->fwd_dropped += (nb_pkt - nb_tx); - rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_pkt - nb_tx); } return true;