From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id 054EDF8D755 for ; Thu, 16 Apr 2026 18:48:22 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8486F406BA; Thu, 16 Apr 2026 20:47:51 +0200 (CEST) Received: from mail-dy1-f177.google.com (mail-dy1-f177.google.com [74.125.82.177]) by mails.dpdk.org (Postfix) with ESMTP id 430CB4067E for ; Thu, 16 Apr 2026 20:47:50 +0200 (CEST) Received: by mail-dy1-f177.google.com with SMTP id 5a478bee46e88-2b6b0500e06so15832659eec.1 for ; Thu, 16 Apr 2026 11:47:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20251104.gappssmtp.com; s=20251104; t=1776365269; x=1776970069; 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=ZyalasysJlPdibjKnXvfd7oiWH3kcw+5X46h8LoA3C4=; b=qd2M2GwhfDdbpc7T9xHs1RcxtHocw7Apf3dL3QHsL4kbClOse0VpI6N5krVK3k8O/0 XUXp4Mg91kSD3RR2rnr2Wr6o4koeV4a+LMQVAT6cromeInSe+YOTJd4jD9r+3KAR2HEI un9RGxrpthRTGCGCDuI0Wv7npPAIYa98I3v5314aeIry7Hjirtr8RkcnjOZJa8/1j5Br J9zHhaTRo5MHTvKP3wi+L/0v0R1/HuJ9ySY3fF+jvpDYlbgmp5G45ddtAzN1eoTMzIJi voacs1psRlUL3E0LHNWpouHHANQQSzY0kMxXqP2v5JaQ9PR3+UCa3eobY8p7uOLQZ7Zy N5mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776365269; x=1776970069; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZyalasysJlPdibjKnXvfd7oiWH3kcw+5X46h8LoA3C4=; b=hbTG45mj6mqziDj1o7IGThp+GEHUHkSaAtW69lRyHcTcSe2ie0bXa3hako+ElWcah+ qRr7aPhdhDq0cqrqY1gAfrlCjY+hwBAUMY+fQ+nDyt5o/R6mKstnLtaKk2ZaNR1RWzBF tVaDTX8gNfGcy9dTecVS3MToQyreNpzxeZm//LAwOxGmHZcXw17J0j2lkvt+J487wZ7q DQwNKgGVh1oMbn05HJujWfkwBk5uiuLwp6HUkyowmNDrAatfSswDVWAru79Pl3KkLEv1 sWLEW3nZm9PwsCnpGoNegZ72EFbAq4p568UtnvmaLtqu65YQFe0X6bxOiP2BN1nRzP3Z G6WQ== X-Gm-Message-State: AOJu0Ywtx3R4Ef45ejDeVT+7SqxS4eExpQHHVHThu/wzool562b+M510 wrtsmqVjvb7pV8LHg6MLb0WlbdLT48q1f33AsavfvNfYvRvbJD+XsGy5apwY23wlyRutqfxvl8z kL22e X-Gm-Gg: AeBDieuF6KRz8PSHLIwhL6kGZwi1s477AILJMuWFUxpb9jmdWjQcXPp/44CYTt90YKP 5nIUyGNrD8q/zlQzE2diuj1EX3ehPPnosGNrL1M1guNm54L1bYkaZu9Jml/H8ZhPz7EPkTsYUwG lAh0YX1LGK0CmXyyRXmIGtjyQ8nEQVs8Cn9UTbutmLPcGj0L1rO9bzt7T1BWM4gOXdp/TvaVvC5 K+V9sUPY9wb5N/lLsLNIDc9JU9O8tJtpt2l+sGdCVsfNhtuXQe9o12uOk6C9BLTU81A8h5sCd0Q dKcnbcO0VeIvjaY71wFBDCZeAx4mOJiJNOq24BFa1HWLXW5IcxCCXP+Jqt2dOw+su5LEkvJbMjI VGIczYI3+Ljvxeo1LT17dlx4O2cpWaMtT5UVCoSQ4h+6/utdL0RoS3nfQqDnGFYbxA38gypE2GJ bR/INXp7TALrsg+XlNvEqQ2Muaa5FjqfDJAiv5Y0Voi4Q= X-Received: by 2002:a05:7301:5781:b0:2df:7882:1ce0 with SMTP id 5a478bee46e88-2e2e5bf7d32mr262975eec.29.1776365269173; Thu, 16 Apr 2026 11:47:49 -0700 (PDT) Received: from phoenix.lan ([104.202.41.210]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2de8c606222sm10741314eec.8.2026.04.16.11.47.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2026 11:47:48 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson Subject: [PATCH v24 08/24] net/pcap: replace stack bounce buffer Date: Thu, 16 Apr 2026 11:45:30 -0700 Message-ID: <20260416184731.1347342-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260416184731.1347342-1-stephen@networkplumber.org> References: <20260106182823.192350-1-stephen@networkplumber.org> <20260416184731.1347342-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Replace the 64K stack-allocated bounce buffer with a per-queue buffer allocated from hugepages via rte_malloc at queue setup. This is necessary because the buffer may be used in a secondary process transmit path where the primary process allocated it. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- drivers/net/pcap/pcap_ethdev.c | 60 +++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c index ebc96fafe5..02d5cb591f 100644 --- a/drivers/net/pcap/pcap_ethdev.c +++ b/drivers/net/pcap/pcap_ethdev.c @@ -91,6 +91,9 @@ struct pcap_tx_queue { struct queue_stat tx_stat; char name[PATH_MAX]; char type[ETH_PCAP_ARG_MAXLEN]; + + /* Temp buffer used for non-linear packets */ + uint8_t *bounce_buf; }; struct pmd_internals { @@ -385,18 +388,17 @@ static uint16_t eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { unsigned int i; - struct rte_mbuf *mbuf; struct pmd_process_private *pp; struct pcap_tx_queue *dumper_q = queue; uint16_t num_tx = 0; uint32_t tx_bytes = 0; struct pcap_pkthdr header; pcap_dumper_t *dumper; - unsigned char temp_data[RTE_ETH_PCAP_SNAPLEN]; - size_t len, caplen; + unsigned char *temp_data; pp = rte_eth_devices[dumper_q->port_id].process_private; dumper = pp->tx_dumper[dumper_q->queue_id]; + temp_data = dumper_q->bounce_buf; if (dumper == NULL || nb_pkts == 0) return 0; @@ -404,12 +406,11 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) /* writes the nb_pkts packets to the previously opened pcap file * dumper */ for (i = 0; i < nb_pkts; i++) { - mbuf = bufs[i]; - len = caplen = rte_pktmbuf_pkt_len(mbuf); - if (unlikely(!rte_pktmbuf_is_contiguous(mbuf) && - len > sizeof(temp_data))) { - caplen = sizeof(temp_data); - } + struct rte_mbuf *mbuf = bufs[i]; + size_t len, caplen; + + len = rte_pktmbuf_pkt_len(mbuf); + caplen = RTE_MIN(len, RTE_ETH_PCAP_SNAPSHOT_LEN); calculate_timestamp(&header.ts); header.len = len; @@ -449,9 +450,6 @@ eth_tx_drop(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) uint32_t tx_bytes = 0; struct pcap_tx_queue *tx_queue = queue; - if (unlikely(nb_pkts == 0)) - return 0; - for (i = 0; i < nb_pkts; i++) { tx_bytes += bufs[i]->pkt_len; rte_pktmbuf_free(bufs[i]); @@ -460,7 +458,7 @@ eth_tx_drop(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) tx_queue->tx_stat.pkts += nb_pkts; tx_queue->tx_stat.bytes += tx_bytes; - return i; + return nb_pkts; } /* @@ -470,30 +468,30 @@ static uint16_t eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { unsigned int i; - int ret; - struct rte_mbuf *mbuf; struct pmd_process_private *pp; struct pcap_tx_queue *tx_queue = queue; uint16_t num_tx = 0; uint32_t tx_bytes = 0; pcap_t *pcap; - unsigned char temp_data[RTE_ETH_PCAP_SNAPLEN]; - size_t len; + unsigned char *temp_data; pp = rte_eth_devices[tx_queue->port_id].process_private; pcap = pp->tx_pcap[tx_queue->queue_id]; + temp_data = tx_queue->bounce_buf; if (unlikely(nb_pkts == 0 || pcap == NULL)) return 0; for (i = 0; i < nb_pkts; i++) { - mbuf = bufs[i]; - len = rte_pktmbuf_pkt_len(mbuf); + struct rte_mbuf *mbuf = bufs[i]; + size_t len = rte_pktmbuf_pkt_len(mbuf); + int ret; + if (unlikely(!rte_pktmbuf_is_contiguous(mbuf) && - len > sizeof(temp_data))) { + len > RTE_ETH_PCAP_SNAPSHOT_LEN)) { PMD_LOG(ERR, - "Dropping multi segment PCAP packet. Size (%zd) > max size (%zd).", - len, sizeof(temp_data)); + "Dropping multi segment PCAP packet. Size (%zd) > max size (%u).", + len, RTE_ETH_PCAP_SNAPSHOT_LEN); rte_pktmbuf_free(mbuf); continue; } @@ -966,7 +964,7 @@ static int eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, uint16_t nb_tx_desc __rte_unused, - unsigned int socket_id __rte_unused, + unsigned int socket_id, const struct rte_eth_txconf *tx_conf __rte_unused) { struct pmd_internals *internals = dev->data->dev_private; @@ -974,11 +972,26 @@ eth_tx_queue_setup(struct rte_eth_dev *dev, pcap_q->port_id = dev->data->port_id; pcap_q->queue_id = tx_queue_id; + pcap_q->bounce_buf = rte_malloc_socket(NULL, RTE_ETH_PCAP_SNAPSHOT_LEN, + RTE_CACHE_LINE_SIZE, socket_id); + if (pcap_q->bounce_buf == NULL) + return -ENOMEM; + dev->data->tx_queues[tx_queue_id] = pcap_q; return 0; } +static void +eth_tx_queue_release(struct rte_eth_dev *dev, uint16_t tx_queue_id) +{ + struct pmd_internals *internals = dev->data->dev_private; + struct pcap_tx_queue *pcap_q = &internals->tx_queue[tx_queue_id]; + + rte_free(pcap_q->bounce_buf); + pcap_q->bounce_buf = NULL; +} + static int eth_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) { @@ -1019,6 +1032,7 @@ static const struct eth_dev_ops ops = { .dev_infos_get = eth_dev_info, .rx_queue_setup = eth_rx_queue_setup, .tx_queue_setup = eth_tx_queue_setup, + .tx_queue_release = eth_tx_queue_release, .rx_queue_start = eth_rx_queue_start, .tx_queue_start = eth_tx_queue_start, .rx_queue_stop = eth_rx_queue_stop, -- 2.53.0