From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D043845DB9 for ; Wed, 27 Nov 2024 18:21:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CD392406BB; Wed, 27 Nov 2024 18:21: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 1F7534066C for ; Wed, 27 Nov 2024 18:21:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732728098; 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=gDIN5F4kXVz/L7kiF4y2DXWof/ldRfLlhjqvQoj628o=; b=Kp4DTNVy1U61OxznEmfNpbgDNezJ2wWAKYZw+uX7RXwLJTB0W5iS9R/x8DuvSWY2ohBFjK upxSrnKIDj4iNlgZaDrJSkL+iFlKs8GFZDxAB/Rjf+XS8Zsl49/B+wnoPl8EJWDKMKgxNN +E32E2ILhgJFTI506hG4gbgCfSDwjAc= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-479-KwE5PPAwO7iHqufUem0T-g-1; Wed, 27 Nov 2024 12:21:35 -0500 X-MC-Unique: KwE5PPAwO7iHqufUem0T-g-1 X-Mimecast-MFC-AGG-ID: KwE5PPAwO7iHqufUem0T-g Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8E700195608D; Wed, 27 Nov 2024 17:21:34 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.52]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 262DD300019E; Wed, 27 Nov 2024 17:21:32 +0000 (UTC) From: Kevin Traynor To: Stephen Hemminger Cc: Ofer Dagan , dpdk stable Subject: patch 'net/pcap: fix blocking Rx' has been queued to stable release 21.11.9 Date: Wed, 27 Nov 2024 17:18:05 +0000 Message-ID: <20241127171916.690404-58-ktraynor@redhat.com> In-Reply-To: <20241127171916.690404-1-ktraynor@redhat.com> References: <20241127171916.690404-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: l2O-69nbF5ZVHpk-QCqvLsr67H88ZLX9E38CGa06HVA_1732728094 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/02/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/614cecd1fde8a6546360cdb557c6c4da237ba857 Thanks. Kevin --- >From 614cecd1fde8a6546360cdb557c6c4da237ba857 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 5 Sep 2024 09:10:40 -0700 Subject: [PATCH] net/pcap: fix blocking Rx [ upstream commit f5ead8f84f205babb320a1d805fb436ba31a5532 ] Use pcap_next_ex rather than just pcap_next because pcap_next always blocks if there is no packets to receive. Bugzilla ID: 1526 Fixes: 4c173302c307 ("pcap: add new driver") Reported-by: Ofer Dagan Signed-off-by: Stephen Hemminger Tested-by: Ofer Dagan --- .mailmap | 1 + drivers/net/pcap/pcap_ethdev.c | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.mailmap b/.mailmap index 13eacdbc33..5e0de73ae0 100644 --- a/.mailmap +++ b/.mailmap @@ -1017,4 +1017,5 @@ Nobuhiro Miki Norbert Ciosek Odi Assli +Ofer Dagan Ognjen Joldzic Ola Liljedahl diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c index 4d79565460..0d837835d1 100644 --- a/drivers/net/pcap/pcap_ethdev.c +++ b/drivers/net/pcap/pcap_ethdev.c @@ -274,5 +274,5 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { unsigned int i; - struct pcap_pkthdr header; + struct pcap_pkthdr *header; struct pmd_process_private *pp; const u_char *packet; @@ -294,7 +294,11 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) for (i = 0; i < nb_pkts; i++) { /* Get the next PCAP packet */ - packet = pcap_next(pcap, &header); - if (unlikely(packet == NULL)) + int ret = pcap_next_ex(pcap, &header, &packet); + if (ret != 1) { + if (ret == PCAP_ERROR) + pcap_q->rx_stat.err_pkts++; + break; + } mbuf = rte_pktmbuf_alloc(pcap_q->mb_pool); @@ -304,15 +308,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } - if (header.caplen <= rte_pktmbuf_tailroom(mbuf)) { + uint32_t len = header->caplen; + if (len <= rte_pktmbuf_tailroom(mbuf)) { /* pcap packet will fit in the mbuf, can copy it */ - rte_memcpy(rte_pktmbuf_mtod(mbuf, void *), packet, - header.caplen); - mbuf->data_len = (uint16_t)header.caplen; + rte_memcpy(rte_pktmbuf_mtod(mbuf, void *), packet, len); + mbuf->data_len = len; } else { /* Try read jumbo frame into multi mbufs. */ if (unlikely(eth_pcap_rx_jumbo(pcap_q->mb_pool, - mbuf, - packet, - header.caplen) == -1)) { + mbuf, packet, len) == -1)) { pcap_q->rx_stat.err_pkts++; rte_pktmbuf_free(mbuf); @@ -321,14 +323,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } - mbuf->pkt_len = (uint16_t)header.caplen; - *RTE_MBUF_DYNFIELD(mbuf, timestamp_dynfield_offset, - rte_mbuf_timestamp_t *) = - (uint64_t)header.ts.tv_sec * 1000000 + - header.ts.tv_usec; + mbuf->pkt_len = len; + uint64_t us = (uint64_t)header->ts.tv_sec * US_PER_S + header->ts.tv_usec; + + *RTE_MBUF_DYNFIELD(mbuf, timestamp_dynfield_offset, rte_mbuf_timestamp_t *) = us; mbuf->ol_flags |= timestamp_rx_dynflag; mbuf->port = pcap_q->port_id; bufs[num_rx] = mbuf; num_rx++; - rx_bytes += header.caplen; + rx_bytes += len; } pcap_q->rx_stat.pkts += num_rx; -- 2.47.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-11-27 17:17:40.086325511 +0000 +++ 0058-net-pcap-fix-blocking-Rx.patch 2024-11-27 17:17:38.233269414 +0000 @@ -1 +1 @@ -From f5ead8f84f205babb320a1d805fb436ba31a5532 Mon Sep 17 00:00:00 2001 +From 614cecd1fde8a6546360cdb557c6c4da237ba857 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit f5ead8f84f205babb320a1d805fb436ba31a5532 ] + @@ -11 +12,0 @@ -Cc: stable@dpdk.org @@ -22 +23 @@ -index 3e9e8b416e..bd7958652a 100644 +index 13eacdbc33..5e0de73ae0 100644 @@ -25,2 +26,2 @@ -@@ -1104,4 +1104,5 @@ Norbert Ciosek - Norbert Zulinski +@@ -1017,4 +1017,5 @@ Nobuhiro Miki + Norbert Ciosek @@ -32 +33 @@ -index 1fb98e3d2b..728ef85d53 100644 +index 4d79565460..0d837835d1 100644 @@ -35 +36 @@ -@@ -275,5 +275,5 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) +@@ -274,5 +274,5 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) @@ -42 +43 @@ -@@ -295,7 +295,11 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) +@@ -294,7 +294,11 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) @@ -56 +57 @@ -@@ -305,15 +309,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) +@@ -304,15 +308,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) @@ -77 +78 @@ -@@ -322,14 +324,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) +@@ -321,14 +323,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)