From patchwork Mon Feb 20 16:40: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: 124191 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 32C3541CEC; Mon, 20 Feb 2023 17:41:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 35978430A9; Mon, 20 Feb 2023 17:41: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 ACB53430A1 for ; Mon, 20 Feb 2023 17:41:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676911299; 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=ffreHUI2KHU4zA/xbCcobx0D7TrWDhGcjU4LN3iil45JxfWKZvpPJr7bu5pK6Xhhcr/Z6f Yo7QRSj6VzJMA5PKtum/fZK/e+J9wG6IuaeCtk8mxcRNNc+WcAhdUa04WZ+wTbHcNdUbFN mrW+axXXfIpOlDfa+03lqNUdAX+NY+o= 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-68-S9bFMvmLOeqSS4LZjtObhQ-1; Mon, 20 Feb 2023 11:41:34 -0500 X-MC-Unique: S9bFMvmLOeqSS4LZjtObhQ-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 A4861299E743; Mon, 20 Feb 2023 16:41:33 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34F5E40C83B6; Mon, 20 Feb 2023 16:41:32 +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 v2 1/9] app/testpmd: fix Tx preparation in checksum engine Date: Mon, 20 Feb 2023 17:40:55 +0100 Message-Id: <20230220164103.3041538-2-david.marchand@redhat.com> In-Reply-To: <20230220164103.3041538-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220164103.3041538-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 "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 16:40: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: 124190 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 3D0A841CEC; Mon, 20 Feb 2023 17:41:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DDDB430A2; Mon, 20 Feb 2023 17:41:40 +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 11447430A1 for ; Mon, 20 Feb 2023 17:41:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676911298; 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=GDxbjD+Z3Dv4a6NBWV9BYAYN3OtL854MhcPNrvnSfnepOeC0rjcgvgk9/vIf0m1MQmhGIk e1liM40PTUGJF8/s3cqQxtgPX8A2FRW2UMWmT8ev+R0cd0r69EEhzaWrHUCGV496dnsvq+ Eu4uLLf/vW9LFN2YdgnlbHB0zoEBQx4= 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-563-i-pJuRAOOjumRV3kL_D3dw-1; Mon, 20 Feb 2023 11:41:37 -0500 X-MC-Unique: i-pJuRAOOjumRV3kL_D3dw-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 C9995101A521; Mon, 20 Feb 2023 16:41:36 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id A129A492B05; Mon, 20 Feb 2023 16:41:35 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry , stable@dpdk.org Subject: [PATCH v2 2/9] app/testpmd: fix packet count in ieee15888 engine Date: Mon, 20 Feb 2023 17:40:56 +0100 Message-Id: <20230220164103.3041538-3-david.marchand@redhat.com> In-Reply-To: <20230220164103.3041538-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220164103.3041538-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 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 --- 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 16:40: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: 124192 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 9465C41CEC; Mon, 20 Feb 2023 17:41:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7EF5F430B1; Mon, 20 Feb 2023 17:41:45 +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 CE380430AE for ; Mon, 20 Feb 2023 17:41:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676911303; 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=cYf7oC/3YEQ+5Rb5MWompv56yJJZDYClLKg3t1dePDzol0/clvM2qgW+CFUmhNJlutoh2i HJVN9+YTndJvbKrYTqNPoHEPc4Lm6/XmaqojmxUlDKe86UNhvBi9g5+xmAy0YzAOp268uB RBt0DYRQ2havqTFuPZi8IG/Vh0fLasU= 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-433-3iuF3qoCMIO9NoW96ayOjQ-1; Mon, 20 Feb 2023 11:41:40 -0500 X-MC-Unique: 3iuF3qoCMIO9NoW96ayOjQ-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 DE84538123A3; Mon, 20 Feb 2023 16:41:39 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7A3A492B00; Mon, 20 Feb 2023 16:41:38 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v2 3/9] app/testpmd: rework ieee1588 engine fwd configuration Date: Mon, 20 Feb 2023 17:40:57 +0100 Message-Id: <20230220164103.3041538-4-david.marchand@redhat.com> In-Reply-To: <20230220164103.3041538-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220164103.3041538-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 Acked-by: Aman Singh --- 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 16:40: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: 124193 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 7CD1D41CEC; Mon, 20 Feb 2023 17:41:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 937C3430A7; Mon, 20 Feb 2023 17:41: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 6DEB8430B6 for ; Mon, 20 Feb 2023 17:41:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676911307; 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=ZoAF7NW9JtUF08sV9IwC98TpOCaQJZcQtEzGTO3nwPhss8iKfdo1bBXH260cjdEF3nCYWI M+yFpIxopjIkgF9xVrt85j8vgc5/XTp/5VsAYdjPDof6jasgHNaMQR3oKdjhzniHaxkfEO Mq/oVaeQRvxMRuwsdvPou10ceyld+IY= 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-602-b0_EqwZQOvm3bwoC57C7Uw-1; Mon, 20 Feb 2023 11:41:43 -0500 X-MC-Unique: b0_EqwZQOvm3bwoC57C7Uw-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 6DC03802C16; Mon, 20 Feb 2023 16:41:43 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9799140EBF6; Mon, 20 Feb 2023 16:41:41 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry , stable@dpdk.org, Jens Freimann , Kevin Traynor , Bernard Iremonger Subject: [PATCH v2 4/9] app/testpmd: fix packet transmission in noisy VNF engine Date: Mon, 20 Feb 2023 17:40:58 +0100 Message-Id: <20230220164103.3041538-5-david.marchand@redhat.com> In-Reply-To: <20230220164103.3041538-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220164103.3041538-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 --- 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 16:40: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: 124194 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 04E5041CEC; Mon, 20 Feb 2023 17:42:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DCDC9430BE; Mon, 20 Feb 2023 17:41:52 +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 72692430BB for ; Mon, 20 Feb 2023 17:41:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676911311; 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=cuWI/8bhEC+c7le+0b6BdYI6++NhoMeLBcWdzyvYfxWkRiiJ838NB7OGd55F3A/WaFK0Le /ffp10ytfwWXVD2rwuMZ+9VC8i6vtSoEgsM4VBrjUii75XJ6iwdfvd3Wgkh+TbUgB0liQ9 96+qCam/o1AtyOYujorCbkCbTVChk6M= 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-235-6kbQZkP_Otqef8_F0DwhTw-1; Mon, 20 Feb 2023 11:41:47 -0500 X-MC-Unique: 6kbQZkP_Otqef8_F0DwhTw-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 8E066101A521; Mon, 20 Feb 2023 16:41:46 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84EEDC15BAD; Mon, 20 Feb 2023 16:41:45 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v2 5/9] app/testpmd: bulk free mbufs Date: Mon, 20 Feb 2023 17:40:59 +0100 Message-Id: <20230220164103.3041538-6-david.marchand@redhat.com> In-Reply-To: <20230220164103.3041538-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220164103.3041538-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 Use the bulk free helper. Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- 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 16:41: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: 124195 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 C30E941CEC; Mon, 20 Feb 2023 17:42:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 608BD430C8; Mon, 20 Feb 2023 17:41:55 +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 DC88A430C0 for ; Mon, 20 Feb 2023 17:41:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676911313; 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=+4xoPA127Ep0v2SKqcqyL4rcqsUAnbTx9KFmQkfoJz0=; b=M1zKiumQ1Y6yVPvuxWkcNOrnaxTKyGlUQFR/ITos+yAfb1gbxnYLPjOxHSeq5Ur4WkdgSC pe3D6zqGw2d4CzppxPJoHTxe1a2YZIFOvliAEehkEYjud5N0ivM4IbkIXgrb0LpLDry0ac TNd8Zn0EiEP9uTJGFE6l5BMUFeQnH/o= 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-107-IM2NjxbfO_qYQ_lbM3mCNA-1; Mon, 20 Feb 2023 11:41:50 -0500 X-MC-Unique: IM2NjxbfO_qYQ_lbM3mCNA-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 AF14D3C10221; Mon, 20 Feb 2023 16:41:49 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8249440C83B6; Mon, 20 Feb 2023 16:41:48 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v2 6/9] app/testpmd: factorize core cycles record Date: Mon, 20 Feb 2023 17:41:00 +0100 Message-Id: <20230220164103.3041538-7-david.marchand@redhat.com> In-Reply-To: <20230220164103.3041538-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220164103.3041538-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 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 | 19 ++++++++++++++----- app/test-pmd/testpmd.h | 16 +--------------- app/test-pmd/txonly.c | 9 +++------ 14 files changed, 58 insertions(+), 94 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..cf2215d390 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2253,7 +2253,6 @@ flush_fwd_rx_queues(void) static void run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) { - struct fwd_stream **fsm; uint64_t prev_tsc; streamid_t nb_fs; streamid_t sm_id; @@ -2267,13 +2266,23 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) tics_datum = rte_rdtsc(); tics_per_1sec = rte_get_timer_hz(); #endif - fsm = &fwd_streams[fc->stream_idx]; 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++) { + uint64_t start_fs_tsc = 0; + struct fwd_stream *fs; + bool busy; + + fs = &fwd_streams[fc->stream_idx][sm_id]; + 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 16:41: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: 124196 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 A707141CEC; Mon, 20 Feb 2023 17:42:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A0816430A1; Mon, 20 Feb 2023 17:41:58 +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 1F9BD430B0 for ; Mon, 20 Feb 2023 17:41:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676911316; 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=msC5NooUBh3r7dfSHmstQlRD+XJEp4AP2zh5O3gMnLE=; b=dVhFpq44YNWs5C/6J3ScJWeD5d1CNgweKOdGl6NaF5URuOS//2/2DGllDyjqhoQl31zRjt aqvAMR1uuFBa2zLK2tKgw1UPgSe4pedxTb4ALHE7F4nmyyeOxC436m4FKJDsk8u8rBYzT2 OZQpiZ5UTs3JgUCxcKj9kJNVMxaaL+w= 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-486-TwgCR8NWMJS5QI8DcCZTkg-1; Mon, 20 Feb 2023 11:41:53 -0500 X-MC-Unique: TwgCR8NWMJS5QI8DcCZTkg-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 F2B6F3C10222; Mon, 20 Feb 2023 16:41:52 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6C43C15BAD; Mon, 20 Feb 2023 16:41:51 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v2 7/9] app/testpmd: factorize fwd engine init Date: Mon, 20 Feb 2023 17:41:01 +0100 Message-Id: <20230220164103.3041538-8-david.marchand@redhat.com> In-Reply-To: <20230220164103.3041538-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220164103.3041538-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 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 cf2215d390..99eea989ae 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2386,6 +2386,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 16:41: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: 124197 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 5FBFB41CEC; Mon, 20 Feb 2023 17:42:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0BB89430D3; Mon, 20 Feb 2023 17:42:01 +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 E24D4430CD for ; Mon, 20 Feb 2023 17:41:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676911319; 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=HrZUBvk1vxf0aesGjGxX/1CLyolllfSjutp9hGrkiu6sSj8ocJjKMZYVGAWw/QXIorGcuO iTNboyog3ur0b+Pyx6GJXCocipfC3ZyB/yUGasAYnVYnKx6Aa9CCfFHwGEKaOh2Mzf/joy J0rsJpn3LGvPNXb5ajJex+rYyx1K+PA= 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-597-A6Kr1-jXMU6jtnbbFGwu6Q-1; Mon, 20 Feb 2023 11:41:56 -0500 X-MC-Unique: A6Kr1-jXMU6jtnbbFGwu6Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F00571C0433F; Mon, 20 Feb 2023 16:41:55 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5A2C1121314; Mon, 20 Feb 2023 16:41:54 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v2 8/9] app/testpmd: factorize fwd engine Rx Date: Mon, 20 Feb 2023 17:41:02 +0100 Message-Id: <20230220164103.3041538-9-david.marchand@redhat.com> In-Reply-To: <20230220164103.3041538-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220164103.3041538-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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 16:41:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124198 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 E297C41CEC; Mon, 20 Feb 2023 17:42:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 42910430DC; Mon, 20 Feb 2023 17:42:04 +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 73148430DB for ; Mon, 20 Feb 2023 17:42:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676911323; 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=bvk6ftmMKGvm3BMn1DOr0mmB1qX7WWkbEzAz2wZysvFCd7YCouVRXdbe7BTRTxmZxZ4px9 ka1rkPdY41imYZFyFHjZle2S2jb697hXflJQoEZAlEzLZMhN+8hXy3Ukz8c35GGisbkpdt fBPS8WhX013g843N0suyOQl7L2SLAh8= 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-369-xuaPtpsiPL25h-2FicfbEQ-1; Mon, 20 Feb 2023 11:41:59 -0500 X-MC-Unique: xuaPtpsiPL25h-2FicfbEQ-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 40E1380D0E0; Mon, 20 Feb 2023 16:41:59 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F83740CF8E7; Mon, 20 Feb 2023 16:41:57 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Ferruh Yigit , Aman Singh , Yuying Zhang , Robin Jarry Subject: [PATCH v2 9/9] app/testpmd: factorize fwd engine Tx Date: Mon, 20 Feb 2023 17:41:03 +0100 Message-Id: <20230220164103.3041538-10-david.marchand@redhat.com> In-Reply-To: <20230220164103.3041538-1-david.marchand@redhat.com> References: <20230124104742.1265439-1-david.marchand@redhat.com> <20230220164103.3041538-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 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 --- 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;