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 E35DD45BB6 for ; Wed, 23 Oct 2024 23:21:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE3A640261; Wed, 23 Oct 2024 23:21:16 +0200 (CEST) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by mails.dpdk.org (Postfix) with ESMTP id BF4A240261 for ; Wed, 23 Oct 2024 23:21:15 +0200 (CEST) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-431688d5127so2206855e9.0 for ; Wed, 23 Oct 2024 14:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729718475; x=1730323275; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q6W7Ap7BQVz0pQFPDMhdPvkqKkRUY+4W/pszrmIAWBo=; b=a8MMoQXw29D6GpDueRCtK6I5KGLgkyMmzPrUrlhrsNLWqUevCkKYnljmULeGpz+T0w bMgEwlM0GHS2uyGFWJXCsKEEWZCO7EP3MM2nvzILFSfdw0qyJHZsVGh04RlbWU9qAwXR ui46JR1DzpbOWsN0E6PR6mmfKMoVe762a/1BI5TgqGZtyNjbCmdTeHmgHK1KBq/+p1Vu yuI9nP4riHm67uBolZaFuxOGt0X2gxS3/uclj1LmvoScLBdZp6m2z8YDhTLzr2dGxosR F7QvBEMr4k14Y+eT6qS9en0glJ47tm+Ibaao/LkH6zpMvI52dqoOqRHAIaaLnD67b+n9 o+og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729718475; x=1730323275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q6W7Ap7BQVz0pQFPDMhdPvkqKkRUY+4W/pszrmIAWBo=; b=B6pB+hGBRJSjnsCut+yknQVBziVzY4ncZaGW/QD8qnVBML2FPUZdZT+IsbNClpjrSd cwPtF2NMRvLJ0TvyLqihiSgXlamwBYs5601BNalkZyQdc4g0RkW/DDpdtMCl1oOz6mLT Ynrx9eVIrbd5BP3Bxn5TY6UNqAqkynrDk+PZCIXo8gB6Qh/8698S/GoJEIX+zprJ6N7A zwkLQbHtpZ/5WrEhfxnDRvq3dd36/nHwHYHg6BStXWGUVqaQksXEkGqqFSGEW31XNt3/ uCnwMUMOpiRFrKL7T/+p8QTQp7HSuaoy83J7hT1B4gdG93faUK8IIIQxmNxHO0YXt7kh KQPw== X-Forwarded-Encrypted: i=1; AJvYcCW7F1Go9iEl4ah0UDUTwbos0zvAyjkAIAI15dqti8Wvg2rcpMRAXZgyLDxZ1OBITK4b87tVsPA=@dpdk.org X-Gm-Message-State: AOJu0YwMuuFG9iSwI44v4lYqg+DFOY/4KZPD+L7004hdxOmZm+YBchkp St5LqWgCe/stR33NvcE4KfVqwDJ2GM10ULp1owhGRVO/mgfpdbT1zra4qAXu X-Google-Smtp-Source: AGHT+IG6p0ZY4R9pZzAmjBLudeiJ4pDBblr6QLOD91UJqL4Ued7GgIvRRKZ3xjabikTQYtVlIQgtFg== X-Received: by 2002:a05:600c:3b03:b0:42f:80f4:ab31 with SMTP id 5b1f17b1804b1-431841586f5mr31239375e9.18.1729718475217; Wed, 23 Oct 2024 14:21:15 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:21cd:def0:a01d:d2aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a37d25sm9781919f8f.23.2024.10.23.14.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 14:21:14 -0700 (PDT) From: luca.boccassi@gmail.com To: Stephen Hemminger Cc: Ofer Dagan , dpdk stable Subject: patch 'net/pcap: fix blocking Rx' has been queued to stable release 22.11.7 Date: Wed, 23 Oct 2024 22:16:46 +0100 Message-ID: <20241023211704.1216956-66-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023211704.1216956-1-luca.boccassi@gmail.com> References: <20241023211704.1216956-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 22.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/25/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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/2012542358d3e38ab05a224418ed088670e3c701 Thanks. Luca Boccassi --- >From 2012542358d3e38ab05a224418ed088670e3c701 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 629383cb25..025bd2daba 100644 --- a/.mailmap +++ b/.mailmap @@ -1017,6 +1017,7 @@ Noa Ezra Nobuhiro Miki Norbert Ciosek Odi Assli +Ofer Dagan Ognjen Joldzic Ola Liljedahl Oleg Polyakov diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c index 03729c0ca7..29664164b4 100644 --- a/drivers/net/pcap/pcap_ethdev.c +++ b/drivers/net/pcap/pcap_ethdev.c @@ -274,7 +274,7 @@ static uint16_t 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; struct rte_mbuf *mbuf; @@ -294,9 +294,13 @@ 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); if (unlikely(mbuf == NULL)) { @@ -304,33 +308,30 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) break; } - 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); break; } } - 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; pcap_q->rx_stat.bytes += rx_bytes; -- 2.45.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-10-23 22:16:43.019824863 +0100 +++ 0066-net-pcap-fix-blocking-Rx.patch 2024-10-23 22:16:40.527943830 +0100 @@ -1 +1 @@ -From f5ead8f84f205babb320a1d805fb436ba31a5532 Mon Sep 17 00:00:00 2001 +From 2012542358d3e38ab05a224418ed088670e3c701 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 629383cb25..025bd2daba 100644 @@ -25 +26,2 @@ -@@ -1103,6 +1103,7 @@ Nobuhiro Miki +@@ -1017,6 +1017,7 @@ Noa Ezra + Nobuhiro Miki @@ -27 +28,0 @@ - Norbert Zulinski @@ -32 +33 @@ - Oleg Akhrem + Oleg Polyakov @@ -34 +35 @@ -index 1fb98e3d2b..728ef85d53 100644 +index 03729c0ca7..29664164b4 100644