From patchwork Tue Nov 4 18:07:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 158434 X-Patchwork-Delegate: thomas@monjalon.net 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 A723C48AB2; Tue, 4 Nov 2025 19:09:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C78540653; Tue, 4 Nov 2025 19:09:33 +0100 (CET) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by mails.dpdk.org (Postfix) with ESMTP id 3AAF840299 for ; Tue, 4 Nov 2025 19:09:32 +0100 (CET) Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-7aae5f2633dso2539843b3a.3 for ; Tue, 04 Nov 2025 10:09:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1762279771; x=1762884571; 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=VSFS6Xja25kswmX5YHSMeQ3EFy5NE/0X5r6+3S33NNE=; b=27nosIBQ5hoGccRWxGRACjf6B+8c0xkCzWhN1BVsPX0tcpAtA6HXwg0o8DdSJFKhrO A3u24sEH5utsoF+pHTm+YRXgjxprvs6pfu4G4eqmqT7+KGg7J5xvABtnZ1Uyg37fWazf ZTnhgE3FZX6AAKdwpRqNkFR4HJNb2jrUvf72uUOAD1NfbnZ/ypJfX/6PA1RU7UF7kkAa 7oJ8nDKNznPkFKV23ORt4h6eYCtDJKgzbjXm1r7zG40U4p4FbbduxU5+IFlSlCSb1kdI lEOGlT5nBsKK0lGM1ke/7l194cjfO6jIcYKsTwrgN5djW6GKegfjj+gRHAYKb19q0w0X kr1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762279771; x=1762884571; 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=VSFS6Xja25kswmX5YHSMeQ3EFy5NE/0X5r6+3S33NNE=; b=jkUBpzK1CfMwCTa4Or82T8ZscDt2wTXlU6oGlNjrB91KeCLg/4vSuZiMqOLF0Rmihz Ris8CR9OPuX9ncU9jn5yPSEwT0Vomh++mMIgQJRiJ+5wT1BQO6yUXWewRfe2PfqCb/aE K3FzrO0VXRTmVfPpPDo9PTU+Pl10L62dVkyaYTiOB8/CiZELwvDC8EChyxwNMR1+sm2x imW+XQhkZ95lfHUnIQ4uP5AuPg+60aAjcKfJqwy2bpeuUwn8WgOqGoH/b6lacjIA4c8c yasvshIt2FitbL5mblWqjJiM1GqQE+J1ZpLLR7vXBjOF1JKZPxudpHMEJ1oN3QSQd6I5 WXIQ== X-Gm-Message-State: AOJu0Yz930BAl8RYGGMnpUWefqJe4ZvE8sMfuSMisrOqeVri+tEN2SGE TkZVkrds7cfALlC+S9fknKC+DNzuEt7SRNe1Bgm8QiB4fpwnB8gttYuNgxO6jvDkt8lnAWEwwJv ODJXc X-Gm-Gg: ASbGncvh71ZWjZuDFqwiUqYwhpzNHBzBjWTvH+0TTSEEhJGlVdUAWG4qL02jLzqB6K7 RGiRWV6It0a+rx7JCTq3TnFzheFw31WKZuruptLMgYqYwonheN8cfWL4acco/QxEuXLCSbbm/kT T7RMD2K8L39ADLp/dpGaLra62yZi6ifR5fRdyWkf3gUYmFoyygT5lbp0Cku6ZPf+LtCNm4B1RiG UiyU5tNJF+Q5E+dRQGlTPNR1tmqjsGIGYAn6h3ZSyygHfT0eKIvypGQzAmHGYgaF1BgunXTQHMf P+LcVlgyDg3Ct7xwfju1MrU3XjC73jG9XCe2EVoxPqOHJWcS5o9IZJ543pz6n+sMC1KZ5447mUk Ol23EBkiotq15jv9ETXVdNcl700FTDVoOT0bem0JGQl6VTJ09UnQkIHux3zq/ZGpKry5TEzpIC0 M7OF3s8Io/fayL7pjvI62ZuTI/3EaOH7/xXINdCY4= X-Google-Smtp-Source: AGHT+IEy26xOMV5o8ca3H9dFf5DST8uxc7LbB/RsgmkJxKAbwHGsBVzB7F6pPJLK8L/QO5qVY+sHvA== X-Received: by 2002:a05:6300:2189:b0:342:44f3:d1bc with SMTP id adf61e73a8af0-34f8580ba48mr184896637.35.1762279771302; Tue, 04 Nov 2025 10:09:31 -0800 (PST) Received: from phoenix.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba1f86b0688sm3035988a12.28.2025.11.04.10.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Nov 2025 10:09:30 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Bruce Richardson , Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>, Reshma Pattan Subject: [PATCH v6 1/8] dumpcap: handle primary process exit Date: Tue, 4 Nov 2025 10:07:05 -0800 Message-ID: <20251104180927.403355-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251104180927.403355-1-stephen@networkplumber.org> References: <20250811213632.16023-1-stephen@networkplumber.org> <20251104180927.403355-1-stephen@networkplumber.org> MIME-Version: 1.0 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 If primary process exits, then it is not possible (or needed) to cleanup resources. Instead just exit after closing the capture file. Bugzilla ID: 1760 Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson Acked-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> --- app/dumpcap/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c index e5ba36350b..3621c0ebe3 100644 --- a/app/dumpcap/main.c +++ b/app/dumpcap/main.c @@ -1059,6 +1059,10 @@ int main(int argc, char **argv) else pcap_dump_close(out.dumper); + /* If primary has exited, do not try and communicate with it */ + if (!rte_eal_primary_proc_alive(NULL)) + return 0; + cleanup_pdump_resources(); rte_ring_free(r); From patchwork Tue Nov 4 18:07:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 158435 X-Patchwork-Delegate: thomas@monjalon.net 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 9A50E48AB2; Tue, 4 Nov 2025 19:09:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 285244067B; Tue, 4 Nov 2025 19:09:35 +0100 (CET) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id 8507D4065B for ; Tue, 4 Nov 2025 19:09:33 +0100 (CET) Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-7aae5f2633dso2539878b3a.3 for ; Tue, 04 Nov 2025 10:09:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1762279773; x=1762884573; 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=DCYjS8lCU4ey/Xq/QimMFCgJnsxEn9LlKb03adqG16o=; b=o7I7/YuTTfpotZNgQUQRMDU40iOuGRKyR5z1oNzU81L8I+ucaDYP+l62lIU9mglBpO tmSgU/jX95mFwDxRvoqoL2AJtGEPgtyf3qYayF4r2AsqXvfCjKUxUGYGBlbzkyYBjoU7 MM+r0gO72uEnCjf7iTBFTxVu8hK0b/EmuK93q5h8arL1oEEkj1Ha5H/LbmJOxEcyDDCR 5Tt4L3vuFpW8okFNFOZ16VBkvyGWv2D0fs/gvSREWKnN4DOJp63NcOH0HnLXxRHycD2h zEB0ge9IvgdhB+uhx4lco97yN8iI65VV1aHcwWZr3Y+hE5OWqGJ8jJNxMtHX68U5qxH1 BGmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762279773; x=1762884573; 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=DCYjS8lCU4ey/Xq/QimMFCgJnsxEn9LlKb03adqG16o=; b=MxzTHK0YPw2OtGDDNPksIuF5OJAyAQFVdrNs9p1OvbNa0w+m1/dkl+2phSHt+KoJeu lJvEzpOUTH/j+OZD3/YguzxVDJEfu3F4jXqezN9HQuOA+3iv4f+nnhLljv9CQlPxC8kH nj5hEKM9jAbtnPS2y3XWKdbBK5AvfTH4Y8LiCTEX6o+JiEBE9YZpmXzdPXI0aeJ0ioL9 0ThTw6oCVyE5VYguxUEgJOdi+fkxM6JgBaEa2Q5aMqXaZCUNK9ca05pUEDtVnvafMbTu Ou/xunLbOVj9vt9feWyp1NxaCq1z7XFB9c+v69iHcNBYAUtG83Zci2euwSZyaYMHWi/3 t10w== X-Gm-Message-State: AOJu0Yxqy+SJvBuUS8C72hdgX+wu8zcuh2ck2f47mpBcsSZHhEo3oESR fBiRCIde+xU1rTs8ZCwlcK6ISrfYqh+mTpwEAPBCJXbD417ohUDv9UgyZSh7pg8xL1IL2MD2qG6 D3nX7j8E= X-Gm-Gg: ASbGncthloOlHAhgDxbPZthceTHk937hbDd9KNJh00barFNJ8+5VrzcIj/MdMdXQWU6 UEGoMZEc3EinBqT8B9u0Din9mpnpNGpYPG8Sw+x67ZfICjpTx3JOr96BHnWSwKRmaB491Zf/yx0 6ZqCHZckR+hHIbUNUTEYwvw8kCnhFDHVyDdFdalOE3lga/SpCc5xl7akIKQUaXp1KYqQMqcTxSz 9Fl52LcLSompRHIy7JvlI4cgu0VouCrgPp+bJn/OVzEr8YDUcge9MnYRgk9aBW441u0bOLgUcju onVu1DzizptpbH5+6kbUKqRwVtdAX7RF5e7Lo4UEFghC9ItPCOLxRyK/vT+EXSuUi2bU9YIan0Q nTrGFVSx7eLROZxGa2skcpHaAmtMjZ7LPC7xfpojmGd95wBaZJRLvtZBo7A/WhfhftaY2DDuu/X gqDUNY5SsF193SOau7vTXS66fKZ69H1S21EzJczwU= X-Google-Smtp-Source: AGHT+IEYlTuDbKeh5HNkZQt+84UbVONdsd/IRueYhp1NbhC/XGdWShReIpDhBQPvg/4XqWwgzdAwWg== X-Received: by 2002:a05:6a20:958f:b0:2d8:ce9e:87a2 with SMTP id adf61e73a8af0-34f869e8df5mr191272637.57.1762279772717; Tue, 04 Nov 2025 10:09:32 -0800 (PST) Received: from phoenix.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba1f86b0688sm3035988a12.28.2025.11.04.10.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Nov 2025 10:09:32 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Bruce Richardson , Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>, Reshma Pattan , Anatoly Burakov , Suanming Mou Subject: [PATCH v6 2/8] pdump: handle primary process exit Date: Tue, 4 Nov 2025 10:07:06 -0800 Message-ID: <20251104180927.403355-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251104180927.403355-1-stephen@networkplumber.org> References: <20250811213632.16023-1-stephen@networkplumber.org> <20251104180927.403355-1-stephen@networkplumber.org> MIME-Version: 1.0 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 If primary process exits, then it is not possible (or needed) to cleanup resources. Instead just exit after closing the capture file. Bugzilla ID: 1760 Fixes: a99a311ba101 ("app/pdump: exit with primary process") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson Acked-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> --- app/pdump/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index fa85859703..1741d7e709 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -1028,13 +1028,15 @@ main(int argc, char **argv) dump_packets(); disable_primary_monitor(); - cleanup_pdump_resources(); + /* dump debug stats */ print_pdump_stats(); - ret = rte_eal_cleanup(); - if (ret) - printf("Error from rte_eal_cleanup(), %d\n", ret); + /* If primary has exited, do not try and communicate with it */ + if (!rte_eal_primary_proc_alive(NULL)) + return 0; - return 0; + cleanup_pdump_resources(); + + return rte_eal_cleanup() ? EXIT_FAILURE : 0; } From patchwork Tue Nov 4 18:07:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 158436 X-Patchwork-Delegate: thomas@monjalon.net 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 86EAA48AB2; Tue, 4 Nov 2025 19:09:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 28C5240696; Tue, 4 Nov 2025 19:09:36 +0100 (CET) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id DC5504067B for ; Tue, 4 Nov 2025 19:09:34 +0100 (CET) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2953ad5517dso44285185ad.0 for ; Tue, 04 Nov 2025 10:09:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1762279774; x=1762884574; 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=aNcJNAY8IpCOth2IwLeY6CPaoXveWEBftcfLb9K4uF0=; b=FVHK0retK67XO1nTkVIc89+4Xpn71pu5ODBTcXuTBvlWgiAIjpJ3bE+T0M9uECbXmT gCFhYLW1cFdFs2RvjakIeu3OqWLw3LMYR//dk+cJ2d5cg+ziTKqztSKK3yt2wfvGyRYh 9YdENlVH+48Jx/T+JUg+i7HZtqmiQJmjvf/JV4UBjrFeoOscIK97eWDIKYY2OOMo1s5N 5Ggh6dlQ4nU6B+Wzq2HAWnFgBd7RsnMpg1ZFaEeDcy4Lea4rLbhBjUcWYpNYpJxeFmLd d8LcklS6tGVjYPDiOW64dHPRwug7dNdqASZ+IPFWn9qmyYCINoMKQpw9Jgbzax7PeRal cqGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762279774; x=1762884574; 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=aNcJNAY8IpCOth2IwLeY6CPaoXveWEBftcfLb9K4uF0=; b=HXa4DldXWlW17U/LIHRof9Q+VKjbVV7ulKhJn1Rvg+dOiAM0kwQ0qCBAmhegiGMKMS MoZkyTIdfeXT9LS4TNLUHCbwiknFKiTTzEpZyR9OupJ0/skOCqxVRCr7vM6QCLI+/z7w lltZ6yt3LptuAUakv/SKWV6rIRmAE4YeBqBbgS28d4pjH6VjWmx4GrysAtE5oEvx5ZyX 7xg1kOsyUBC7+AdkYS51OyTStdDZaFkNZpvIp4KtOGzZppEORugbMOX/CoMZGBTC1v0Z 4buS0hyScbQGIVXGC1U2uCwkdYrrgvl2kLAam2htNIdfPGwxiVEB2YKiu5Tw3mL78+3Q abQw== X-Gm-Message-State: AOJu0YyC4XACGyijHAawBop/ic2sqmxMbFUntIJc2//hSZJHcaCPW0jj nYSZmRmec+9wZzn4CnBOcAM9r/JUXwUJjQiRLxqa5VchQ43OowDXXxBTR1NSe+jCfqhmVY/naTf uLPO/ X-Gm-Gg: ASbGncsAindvVlKqc7zJSvIdZvgbhNSDHlWk5mS30QoHtxOboCaiE6zoecQ3sPVQBbQ hNJFZi5yEYf1kP3/4Mkrut66j4U1MaN/ho0aH9TO6DmecNkhsPWFIQEaPETNiZQawFpP9t385Zb FXgf+L1jEIX1HvyEg42IhKvpSY57AFBDUPjbAuRA8oFPe+P786E6FZW0+PFT24MN+m5Iztq3kw2 3Ay0nOcs72jjGQxXKJmgbqRoxASv/t3r1lmgPs7Qp6npTjrWevCnc6TLFXB2DXDF5HddgkfNDM/ hgLLcMxUfWitS7/7QVchXRe5MelOd2j8cuIxUxpFimqYI5z1euTln8K1nOraIaCJHzTTu9AeGez vG3+tDWopB42/W21FcH8MCqwGXrVMDReuCoLypT10AIO3UUad1vxZV0xQqx8Owkxc8G5pOBE41r 17H04UFio0KICtHxx+oWvAwo1sLh6bZYpTq0jNUUs= X-Google-Smtp-Source: AGHT+IGoH1i3VrCMDLalyl7ofJL8H44ZJ3EaGtgcgsfZnBPQ8qmX844oOw4Zv8HsuNgqzqCHbc1AMQ== X-Received: by 2002:a17:902:f609:b0:26d:58d6:3fb2 with SMTP id d9443c01a7336-2962adb413bmr5242405ad.12.1762279773882; Tue, 04 Nov 2025 10:09:33 -0800 (PST) Received: from phoenix.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba1f86b0688sm3035988a12.28.2025.11.04.10.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Nov 2025 10:09:33 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>, Reshma Pattan Subject: [PATCH v6 3/8] pdump: fix races in callbacks Date: Tue, 4 Nov 2025 10:07:07 -0800 Message-ID: <20251104180927.403355-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251104180927.403355-1-stephen@networkplumber.org> References: <20250811213632.16023-1-stephen@networkplumber.org> <20251104180927.403355-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The pdump callback can race with other cpu's in the datapath. Handle this by using reference counts and LSB in manner similar to seqcount and bpf code. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson Acked-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> --- lib/pdump/rte_pdump.c | 48 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/lib/pdump/rte_pdump.c b/lib/pdump/rte_pdump.c index ba75b828f2..bfd63fa8c2 100644 --- a/lib/pdump/rte_pdump.c +++ b/lib/pdump/rte_pdump.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "rte_pdump.h" @@ -62,6 +63,7 @@ static struct pdump_rxtx_cbs { const struct rte_bpf *filter; enum pdump_version ver; uint32_t snaplen; + RTE_ATOMIC(uint32_t) use_count; } rx_cbs[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT], tx_cbs[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT]; @@ -78,6 +80,36 @@ static struct { const struct rte_memzone *mz; } *pdump_stats; +static void +pdump_cb_wait(struct pdump_rxtx_cbs *cbs) +{ + /* make sure the data loads happens before the use count load */ + rte_atomic_thread_fence(rte_memory_order_acquire); + + /* wait until use_count is even (not in use) */ + RTE_WAIT_UNTIL_MASKED(&cbs->use_count, 1, ==, 0, rte_memory_order_relaxed); +} + +static __rte_always_inline void +pdump_cb_hold(struct pdump_rxtx_cbs *cbs) +{ + uint32_t count = cbs->use_count + 1; + + rte_atomic_store_explicit(&cbs->use_count, count, rte_memory_order_relaxed); + + /* prevent stores after this from happening before the use_count update */ + rte_atomic_thread_fence(rte_memory_order_release); +} + +static __rte_always_inline void +pdump_cb_release(struct pdump_rxtx_cbs *cbs) +{ + uint32_t count = cbs->use_count + 1; + + /* Synchronizes-with the load acquire in pdump_cb_wait */ + rte_atomic_store_explicit(&cbs->use_count, count, rte_memory_order_release); +} + /* Create a clone of mbuf to be placed into ring. */ static void pdump_copy(uint16_t port_id, uint16_t queue, @@ -146,11 +178,14 @@ pdump_rx(uint16_t port, uint16_t queue, struct rte_mbuf **pkts, uint16_t nb_pkts, uint16_t max_pkts __rte_unused, void *user_params) { - const struct pdump_rxtx_cbs *cbs = user_params; + struct pdump_rxtx_cbs *cbs = user_params; struct rte_pdump_stats *stats = &pdump_stats->rx[port][queue]; + pdump_cb_hold(cbs); pdump_copy(port, queue, RTE_PCAPNG_DIRECTION_IN, pkts, nb_pkts, cbs, stats); + pdump_cb_release(cbs); + return nb_pkts; } @@ -158,14 +193,18 @@ static uint16_t pdump_tx(uint16_t port, uint16_t queue, struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params) { - const struct pdump_rxtx_cbs *cbs = user_params; + struct pdump_rxtx_cbs *cbs = user_params; struct rte_pdump_stats *stats = &pdump_stats->tx[port][queue]; + pdump_cb_hold(cbs); pdump_copy(port, queue, RTE_PCAPNG_DIRECTION_OUT, pkts, nb_pkts, cbs, stats); + pdump_cb_release(cbs); + return nb_pkts; } + static int pdump_register_rx_callbacks(enum pdump_version ver, uint16_t end_q, uint16_t port, uint16_t queue, @@ -186,6 +225,7 @@ pdump_register_rx_callbacks(enum pdump_version ver, port, qid); return -EEXIST; } + cbs->use_count = 0; cbs->ver = ver; cbs->ring = ring; cbs->mp = mp; @@ -218,6 +258,7 @@ pdump_register_rx_callbacks(enum pdump_version ver, -ret); return ret; } + pdump_cb_wait(cbs); cbs->cb = NULL; } } @@ -246,6 +287,7 @@ pdump_register_tx_callbacks(enum pdump_version ver, port, qid); return -EEXIST; } + cbs->use_count = 0; cbs->ver = ver; cbs->ring = ring; cbs->mp = mp; @@ -277,6 +319,8 @@ pdump_register_tx_callbacks(enum pdump_version ver, -ret); return ret; } + + pdump_cb_wait(cbs); cbs->cb = NULL; } } From patchwork Tue Nov 4 18:07:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 158437 X-Patchwork-Delegate: thomas@monjalon.net 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 9E48548AB2; Tue, 4 Nov 2025 19:09:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 34299406B4; Tue, 4 Nov 2025 19:09:37 +0100 (CET) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id 3C152406A2 for ; Tue, 4 Nov 2025 19:09:36 +0100 (CET) Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-33db8fde85cso5627915a91.0 for ; Tue, 04 Nov 2025 10:09:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1762279775; x=1762884575; 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=PPQTx0z2LrGhFBoUFfqMhsEtngbOKeBe2Sa3KcccjjA=; b=0b6pZFd8yiLk4gFvcqinTrs/Y00+s9X4FnmYPBrclhYi4KbVS6QKuPuVRAooYD62jQ 7s24ZavGtUmErPpiPpwIPmflibF2OuOpycyHZVm9/6m8KMn9AF9TfH5dgVfT4q+ex9Om T4XBoIJRf58mVRPYigdxj+bC2IfVlvXWxu9fMshtSEvgddognfWK0xepS9a7IkQiUQh0 54jIuYKpHq8oqCi4cZp24kzBOj0H0dp2MYKxptKlVY420NywQh1dJamELBheA8hdb5vn nwj9qalFzQMZA7pB/Ev7HucLEDWyh8fSgrbVL6m02kPxDHX1PVNN1FqACJp6omb6AOqH bt/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762279775; x=1762884575; 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=PPQTx0z2LrGhFBoUFfqMhsEtngbOKeBe2Sa3KcccjjA=; b=KqPqbaJ/hLDC/xP1NONJ3nOFAs0jHlFi18EvNKvWbRfXPxvwWU9+1zlCqpQ419v/Tp Uc80oRWfNxIqunoi4x/bDLxHIfa7kDn7uG0lA25XQbwrUotV1oVDi9ExHzUpukADdAvI B2DiF/dq/ukVCuMk/ubrow8XM3/xSNT9PKGs93Y2xBFEw8lG6tSMMSWgcNW8Luh1j0+w 1N3ddySV1kshWw+le9bEN1BzjxZ2jFj2J4218MgbsXzHRJXIuAx4yqGJPh2MTmHLPz5t Fmbw2/3WKbA3dczPqaprI/gEkVePlu9ccw+IL3bV/GAQCzgwCni7J1ld6bYaCYG6V0PJ V93A== X-Gm-Message-State: AOJu0YyDkYeOBneWo/1+mzSa6CZ3PLyOKn54+8SySm+4vvvz5HTdETJo Wn9VL/UrhuZ3tbIpkvTVmSQv0b3kfDsPV9fNDnqP3T+5nTg47pdA0FjS79JG+mwnTvwtKSVogvk pqILh X-Gm-Gg: ASbGncuBAT/xfbgsCe8ZOKYiHBxCCgL1mVEMsHq3PRA6rv9dsOzQIcqzrYGvt3aWRnT M/7V8spkrchEEurSB0dQ8XSzcaQ8WmdgZLb2hFV9dFAAZL2e8ck+bBlw8Joyvl72wOz2XT096lP v+AeGp0qbLstwS5n1q9p1uM8VWr4djSNV/PJGVXpnZr+ex+2gh1RzlTzpTrvXrL3ch2GqUzTsjw VqZ7aE7fCY05/np5uQ1Z7eytkVchDIzH5CEnme7Chz6w1GRe5XeC+IfsOhSVInpARnoDxs8GaOy zzxldn6WNZt7FAREtoXwY2vdcCjzr7Fzn+sGj0ZriCrmBZBfWgTqtzio1RCdtPbz7AOXQdDyQBm 8HK5vXfLhZdA6mKr6LB3U5+tL/cQP0D2WeJCwRL2WBYEYbSZKOmuy8ipqjmbw7n9r9v6JtOy7YV a/yygfp8l1NbfDtEzDEPb8VhMQQTBhr0LN1bRxYuL5sl3YAbYPIw== X-Google-Smtp-Source: AGHT+IGEwX+3mG+zAdycDDo2UywzC66qsNFeD/TA3ULVoaxyEpPC1lJXN7TPU5ABkwSgLqRje+68GQ== X-Received: by 2002:a17:903:46c3:b0:294:cc1d:e28d with SMTP id d9443c01a7336-2962ad3c72cmr6158435ad.25.1762279775102; Tue, 04 Nov 2025 10:09:35 -0800 (PST) Received: from phoenix.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba1f86b0688sm3035988a12.28.2025.11.04.10.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Nov 2025 10:09:34 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>, Reshma Pattan Subject: [PATCH v6 4/8] dumpcap: handle pdump requests from primary Date: Tue, 4 Nov 2025 10:07:08 -0800 Message-ID: <20251104180927.403355-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251104180927.403355-1-stephen@networkplumber.org> References: <20250811213632.16023-1-stephen@networkplumber.org> <20251104180927.403355-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The primary process will start to notify all secondary processes about pdump changes. The dumpcap secondary process can just call rte_pdump_init() and it take care of that. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson Acked-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> --- app/dumpcap/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c index 3621c0ebe3..46a6cb251e 100644 --- a/app/dumpcap/main.c +++ b/app/dumpcap/main.c @@ -528,6 +528,8 @@ cleanup_pdump_resources(void) if (intf->opts.promisc_mode) rte_eth_promiscuous_disable(intf->port); } + + rte_pdump_uninit(); } /* Alarm signal handler, used to check that primary process */ @@ -659,6 +661,14 @@ static void dpdk_init(void) if (rte_eal_init(eal_argc, eal_argv) < 0) rte_exit(EXIT_FAILURE, "EAL init failed: is primary process running?\n"); + /* + * Register pdump callback handler. + * Primary will notify all secondary processes of change. + * No impact for this application, but need to reply. + */ + if (rte_pdump_init() < 0) + rte_exit(EXIT_FAILURE, "EAL pdump init failed\n"); + /* * If no lcore argument was specified, then run this program as a normal process * which can be scheduled on any non-isolated CPU. From patchwork Tue Nov 4 18:07:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 158438 X-Patchwork-Delegate: thomas@monjalon.net 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 69B6948AB2; Tue, 4 Nov 2025 19:10:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 411464066E; Tue, 4 Nov 2025 19:09:39 +0100 (CET) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id 2D9CB40668 for ; Tue, 4 Nov 2025 19:09:37 +0100 (CET) Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-340ba29d518so3031705a91.3 for ; Tue, 04 Nov 2025 10:09:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1762279776; x=1762884576; 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=k0J06KJzDzXhPV3N4fCx7IN8y3PaQHpxuTDCF2EhH3Q=; b=KP1ftdfTyfrLSJvOaa6X7MkAZTv0da6syZv15q6T3zMJeT682nVVOXqBq6ZWrf7/ED 3hX2RXpR3YsD2kZqrFzcHgp3Ku0ngkNynDm0tV7kWen/QNworo43F7x8Jd2hzWj3VM+F 7bZ1ykb0tBxX77YLfk19Ozdc7pgssRO4jxdqXHzia04xOmMwK597/8fEekgE8TlbddKW 8jHDgbzjfnG//tJ1ZOjXEIgjE7dJ7U2v4haQ+vxmmJ8OC02UfWOyqek7eSZYWp9vjpZQ 2gAoZeCckubxkSqzEbNXMBZvcIZex93R2DIpv+ZlcrhLrjlYnJkR3WsKE2I0LWwS9dHd ZKUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762279776; x=1762884576; 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=k0J06KJzDzXhPV3N4fCx7IN8y3PaQHpxuTDCF2EhH3Q=; b=qCIkxPQU9KIWaUFo81/aEeA6BEFmLUccqXfGrdz/OobCLqwa0ljbO+nBobe/wu2C4r RNh/X8IRmIlyhk1EV0MC5Z/HLyTMHtlt5rqKXM0Cr5kMWRxFjoIcmX9MAAk4tzorjqm5 5kVpGvg9U3tQbUJ1bk606r4AK1GNCCJ7o+OjKSStDzBsznosIfQuxA5XZgJFrxLthw+p Fa/Ja+L5kvnjVDCUo6BYCOnoKXZIUASRskE8Ct+EfPEy5mgRvWyX+5/Gph4xO5lkZrCO anKlw3lVttGQqgOYTpMIDZkn1E4ny8KafyUNZFjkhX0+ls0qxTJBsKSgJQ6Ufw+lLOP5 Ta4Q== X-Gm-Message-State: AOJu0YzUJ5vdWUq5aKDPGXqRndft7/aSi1pzK2WWL6APidqrs6+mXhCR SJiFWnoj0jTyXgkPHeXd2Wyh5KeEmQmwMGUy4cfOgZnqLubJCbF0GfANGzJS77cuUGgnt4yUdCY NVF3C X-Gm-Gg: ASbGncu3WK76uoXxzO+W7KNdyBNUSAUBBLcO++f25yha2Cp5u/gjLgvQpmrgVZP6tsC gCRmsfXFuFwxnbOg+h4BLGJpFMhX9ouQcRwIIPFRJQKCgul/Sa1I9OZF/3+E4FyC+SzCxVXvfs/ TqE0XvsUquTEg2DUQ6bT4ed2XE25vffO3dF2wH+yPhUBT3d7Gg9ww699BAGlxeq6iBV1vHNCPC4 NVOuWBqNAFwC5NnMxIxbeRpWMIIJ2gfTWsKaCR17jvE9kehRE/bF2+X26S+pWBeHPiTZuUhleI8 J116vj15/x5YOaPWtHlKP9dVjdlwYewbqNLQbX7wAGdVo3dVreEnxBHTcHF0A6FwtmbyUJhAul2 PZ2Nj+4fccpic8murUivUBkAkf+YRwM4k/V48gtf+JAn2SKKbUExVERWMhZ2e5PNkqqVcpvhoPy zxOpV1On4gUq0zqt53wxTXKZXUSJAjykzOyDUgOIw= X-Google-Smtp-Source: AGHT+IFmukkfKgxJlXvSqu9g+rNPP2G2LpkgAGnbOxnj2CBgLwiCzrcyFcnzE6RPJn09UKFeUhsFpw== X-Received: by 2002:a17:90b:3e4f:b0:340:ec8f:82d8 with SMTP id 98e67ed59e1d1-341a6c4891cmr125908a91.12.1762279776309; Tue, 04 Nov 2025 10:09:36 -0800 (PST) Received: from phoenix.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba1f86b0688sm3035988a12.28.2025.11.04.10.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Nov 2025 10:09:35 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>, Reshma Pattan Subject: [PATCH v6 5/8] pdump: handle pdump requests from primary Date: Tue, 4 Nov 2025 10:07:09 -0800 Message-ID: <20251104180927.403355-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251104180927.403355-1-stephen@networkplumber.org> References: <20250811213632.16023-1-stephen@networkplumber.org> <20251104180927.403355-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The primary process will start to notify all secondary processes about pdump changes. The pdump secondary process can just call rte_pdump_init() and it take care of that. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson Acked-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> --- app/pdump/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/pdump/main.c b/app/pdump/main.c index 1741d7e709..626ba0ce93 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -552,6 +552,7 @@ cleanup_pdump_resources(void) } } + rte_pdump_uninit(); cleanup_rings(); } @@ -822,6 +823,9 @@ enable_pdump(void) struct pdump_tuples *pt; int ret = 0, ret1 = 0; + if (rte_pdump_init() < 0) + rte_exit(EXIT_FAILURE, "pdump init failed\n"); + for (i = 0; i < num_tuples; i++) { pt = &pdump_t[i]; if (pt->dir == RTE_PDUMP_FLAG_RXTX) { From patchwork Tue Nov 4 18:07:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 158439 X-Patchwork-Delegate: thomas@monjalon.net 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 3D46048AB2; Tue, 4 Nov 2025 19:10:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3659C406B8; Tue, 4 Nov 2025 19:09:40 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id 8B3B84066E for ; Tue, 4 Nov 2025 19:09:38 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-b98a619f020so2912635a12.2 for ; Tue, 04 Nov 2025 10:09:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1762279778; x=1762884578; 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=2GhICTPCcR4to+IJPGyGkVMcyTpmFwL/A3UPuI3sIT0=; b=GBBrA0GldVFWHJltPufJcfGE2h2YHVJ8JPmCK7QY+uzt368TnF1Ys10QPIJAe9tek+ g4Bui1ffCHoXSFNxtlDfx7H8dhU0PULMbX3SiioSFPN0Gn40EoYiVvZihVLG+4ZzLl04 Hv32lphMbMuIXhSCAiGqoAY+J/ybArPt5+bcmwbZEAcm0Ub35oW9W2nYh4gRna//bxU7 Ds4BaD3QIHqmeEgj6949iWvV4LaowzmqiE3mmV3RndJHCGouo0hTitH8V7wNpNS8mVf2 gEzsGq4ly73U/reBhVqVz9mrl0pPhuM/c+NooVq/OQVQj2Tz1RElrBFrsXMWuswvOt/H ix8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762279778; x=1762884578; 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=2GhICTPCcR4to+IJPGyGkVMcyTpmFwL/A3UPuI3sIT0=; b=PQgKlmusVuNjZWffMhuFlv8hCct9dBPG2U12ReLIgnxZRFPDTL4rWAyDuNDGtOSlwJ Wronp8X7vfA6pwhskdMjcIADs0qJP0Y3S7UP+aS6tKJr7EhhoLV5LQLDEnIjBlvAuU9+ lDa3jpfBv1ly1NQcUvzT0cvcagtpZ0sGzYhOggSgW5XcGUisvBLAk+owS1SWso6s5zER SvjQ6D1BRfBs13RuILN98+Q3lMI3mKYO0crGsD3GA1QdfGn0CRnK6ZCpXeqW/XnbcyXo wNUxMTRduQ0Gqx7I05504I00rRB59OSAcFMGi9o+tFSB2A3JpKwsBczLfu0rGbOGQBry Blqg== X-Gm-Message-State: AOJu0Yw7+LEdDepmTAJsbePtdOw1oXjWqRmkB1VSMZ0EekRDufYYm5/7 YANOkf3mBOrWfnGKuoubymRNfXH5LJ8CsMmpgp5IW0uHm0R7Fcso7j428cZkoqepvQ2u/qhsNVp o0AoV X-Gm-Gg: ASbGncuXjQBe4phUhB+BQb8diMJ7MboggtHoKNxASB5jeUHQMuvNZa/HtTelWRZnEHf Q4RisTONonpS45go/GobkqDhKTKtAZf5nFlXqDpdT+3S/akwTFEOCHBvxU/vXWs3Sdi5ZtCslXu l+D3oXA/osgzYEZ8Ui/wy9AR9DIPlh8jsX2eYsIj4DU8xYPZp3jUGYIOP+2p69GXv8p/cSkOCMa k2CYCaMsM4izD48TCioU63H+4I0tKfJQYzROnZWUMgCXTTBKblOPb+KVAm0a0sOlO5viLIRt8qF 2OTMj2AsaTNNffwJe56nZ2QQHJiL/I+ZiySO9w5LrUT2I3SEozYy/6Y/3Xw4oyinaCMy+Gf6h0k 3J6KtSfK4tQJTomixl6+/5t+f+lb6TFL0XNrbRe2LilRAmE9mNabjfZ4E/gFYIw+NY1QBOSXUOB o1eK1ao/kuB4AJf8TPWQpRrCWdqLBgZOFZMpazvRg= X-Google-Smtp-Source: AGHT+IG5XzJIrS86whimr3WcdfWTx6drntMAcHkLl1jHK2QoTRoLLSKuE1Wy1tBttjEpYq9Jcf2Djw== X-Received: by 2002:a05:6a20:432c:b0:341:4caf:bd53 with SMTP id adf61e73a8af0-34f839ea3f5mr273779637.3.1762279777612; Tue, 04 Nov 2025 10:09:37 -0800 (PST) Received: from phoenix.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba1f86b0688sm3035988a12.28.2025.11.04.10.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Nov 2025 10:09:37 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>, Reshma Pattan , Anatoly Burakov Subject: [PATCH v6 6/8] pdump: forward callback enable to secondary Date: Tue, 4 Nov 2025 10:07:10 -0800 Message-ID: <20251104180927.403355-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251104180927.403355-1-stephen@networkplumber.org> References: <20250811213632.16023-1-stephen@networkplumber.org> <20251104180927.403355-1-stephen@networkplumber.org> MIME-Version: 1.0 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 When packet capture is enabled, need to also notify secondary processes to force them to do the callbacks. Requires that all secondary processes also call rte_pdump_init() or there will be warning about not responding secondary. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson Acked-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> --- lib/pdump/rte_pdump.c | 213 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 185 insertions(+), 28 deletions(-) diff --git a/lib/pdump/rte_pdump.c b/lib/pdump/rte_pdump.c index bfd63fa8c2..305325847c 100644 --- a/lib/pdump/rte_pdump.c +++ b/lib/pdump/rte_pdump.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -26,11 +27,28 @@ RTE_LOG_REGISTER_DEFAULT(pdump_logtype, NOTICE); /* Used for the multi-process communication */ #define PDUMP_MP "mp_pdump" +/* Overly generous timeout for secondary to respond */ +#define MP_TIMEOUT_S 5 + enum pdump_operation { DISABLE = 1, ENABLE = 2 }; +static const char * +pdump_opname(enum pdump_operation op) +{ + static char buf[32]; + + if (op == DISABLE) + return "disable"; + if (op == ENABLE) + return "enable"; + + snprintf(buf, sizeof(buf), "op%u", op); + return buf; +} + /* Internal version number in request */ enum pdump_version { V1 = 1, /* no filtering or snap */ @@ -56,6 +74,11 @@ struct pdump_response { int32_t err_value; }; +struct pdump_bundle { + struct rte_mp_msg msg; + char peer[]; +}; + static struct pdump_rxtx_cbs { struct rte_ring *ring; struct rte_mempool *mp; @@ -432,34 +455,150 @@ set_pdump_rxtx_cbs(const struct pdump_request *p) return ret; } +static void +pdump_request_to_secondary(const struct pdump_request *req) +{ + struct rte_mp_msg mp_req = { }; + struct rte_mp_reply mp_reply; + struct timespec ts = {.tv_sec = MP_TIMEOUT_S, .tv_nsec = 0}; + + PDUMP_LOG_LINE(DEBUG, "forward req %s to secondary", pdump_opname(req->op)); + + memcpy(mp_req.param, req, sizeof(*req)); + strlcpy(mp_req.name, PDUMP_MP, sizeof(mp_req.name)); + mp_req.len_param = sizeof(*req); + + if (rte_mp_request_sync(&mp_req, &mp_reply, &ts) != 0) + PDUMP_LOG_LINE(ERR, "rte_mp_request_sync failed"); + + else if (mp_reply.nb_sent != mp_reply.nb_received) + PDUMP_LOG_LINE(ERR, "not all secondary's replied (sent %u recv %u)", + mp_reply.nb_sent, mp_reply.nb_received); + + free(mp_reply.msgs); +} + +/* Allocate temporary storage for passing state to the alarm thread for deferred handling */ +static struct pdump_bundle * +pdump_bundle_alloc(const struct rte_mp_msg *mp_msg, const char *peer) +{ + struct pdump_bundle *bundle; + size_t peer_len = strlen(peer) + 1; + + /* peer is the unix domain socket path */ + bundle = malloc(sizeof(*bundle) + peer_len); + if (bundle == NULL) + return NULL; + + bundle->msg = *mp_msg; + memcpy(bundle->peer, peer, peer_len); + return bundle; +} + +/* Send response to peer */ static int -pdump_server(const struct rte_mp_msg *mp_msg, const void *peer) +pdump_send_response(const struct pdump_request *req, int result, const void *peer) { - struct rte_mp_msg mp_resp; - const struct pdump_request *cli_req; - struct pdump_response *resp = (struct pdump_response *)&mp_resp.param; + struct rte_mp_msg mp_resp = { }; + struct pdump_response *resp = (struct pdump_response *)mp_resp.param; + int ret; - /* recv client requests */ - if (mp_msg->len_param != sizeof(*cli_req)) { - PDUMP_LOG_LINE(ERR, "failed to recv from client"); - resp->err_value = -EINVAL; - } else { - cli_req = (const struct pdump_request *)mp_msg->param; - resp->ver = cli_req->ver; - resp->res_op = cli_req->op; - resp->err_value = set_pdump_rxtx_cbs(cli_req); + if (req) { + resp->ver = req->ver; + resp->res_op = req->op; } + resp->err_value = result; rte_strscpy(mp_resp.name, PDUMP_MP, RTE_MP_MAX_NAME_LEN); mp_resp.len_param = sizeof(*resp); - mp_resp.num_fds = 0; - if (rte_mp_reply(&mp_resp, peer) < 0) { - PDUMP_LOG_LINE(ERR, "failed to send to client:%s", + + ret = rte_mp_reply(&mp_resp, peer); + if (ret != 0) + PDUMP_LOG_LINE(ERR, "failed to send response: %s", strerror(rte_errno)); - return -1; + return ret; +} + +/* Callback from MP request handler in secondary process */ +static int +pdump_handle_primary_request(const struct rte_mp_msg *mp_msg, const void *peer) +{ + const struct pdump_request *req = NULL; + int ret; + + if (mp_msg->len_param != sizeof(*req)) { + PDUMP_LOG_LINE(ERR, "invalid request from primary"); + ret = -EINVAL; + } else { + req = (const struct pdump_request *)mp_msg->param; + PDUMP_LOG_LINE(DEBUG, "secondary pdump %s", pdump_opname(req->op)); + + /* Can just do it now, no need for interrupt thread */ + ret = set_pdump_rxtx_cbs(req); } + return pdump_send_response(req, ret, peer); + +} + +/* Callback from the alarm handler (in interrupt thread) which does actual change */ +static void +__pdump_request(void *param) +{ + struct pdump_bundle *bundle = param; + struct rte_mp_msg *msg = &bundle->msg; + const struct pdump_request *req = + (const struct pdump_request *)msg->param; + int ret; + + PDUMP_LOG_LINE(DEBUG, "primary pdump %s", pdump_opname(req->op)); + + ret = set_pdump_rxtx_cbs(req); + ret = pdump_send_response(req, ret, bundle->peer); + + /* Primary process is responsible for broadcasting request to all secondaries */ + if (ret == 0) + pdump_request_to_secondary(req); + + free(bundle); +} + +/* Callback from MP request handler in primary process */ +static int +pdump_handle_secondary_request(const struct rte_mp_msg *mp_msg, const void *peer) +{ + struct pdump_bundle *bundle = NULL; + const struct pdump_request *req = NULL; + int ret; + + if (mp_msg->len_param != sizeof(*req)) { + PDUMP_LOG_LINE(ERR, "invalid request from secondary"); + ret = -EINVAL; + goto error; + } + + req = (const struct pdump_request *)mp_msg->param; + + bundle = pdump_bundle_alloc(mp_msg, peer); + if (bundle == NULL) { + PDUMP_LOG_LINE(ERR, "not enough memory"); + ret = -ENOMEM; + goto error; + } + + /* + * We are in IPC callback thread, sync IPC is not possible + * since sending to secondary would cause livelock. + * Delegate the task to interrupt thread. + */ + ret = rte_eal_alarm_set(1, __pdump_request, bundle); + if (ret != 0) + goto error; return 0; + +error: + free(bundle); + return pdump_send_response(req, ret, peer); } RTE_EXPORT_SYMBOL(rte_pdump_init) @@ -469,19 +608,36 @@ rte_pdump_init(void) const struct rte_memzone *mz; int ret; - mz = rte_memzone_reserve(MZ_RTE_PDUMP_STATS, sizeof(*pdump_stats), - SOCKET_ID_ANY, 0); - if (mz == NULL) { - PDUMP_LOG_LINE(ERR, "cannot allocate pdump statistics"); - rte_errno = ENOMEM; - return -1; + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + ret = rte_mp_action_register(PDUMP_MP, pdump_handle_secondary_request); + if (ret && rte_errno != ENOTSUP) + return -1; + + mz = rte_memzone_reserve(MZ_RTE_PDUMP_STATS, sizeof(*pdump_stats), + SOCKET_ID_ANY, 0); + if (mz == NULL) { + PDUMP_LOG_LINE(ERR, "cannot allocate pdump statistics"); + rte_mp_action_unregister(PDUMP_MP); + rte_errno = ENOMEM; + return -1; + } + } else { + ret = rte_mp_action_register(PDUMP_MP, pdump_handle_primary_request); + if (ret && rte_errno != ENOTSUP) + return -1; + + mz = rte_memzone_lookup(MZ_RTE_PDUMP_STATS); + if (mz == NULL) { + PDUMP_LOG_LINE(ERR, "cannot find pdump statistics"); + rte_mp_action_unregister(PDUMP_MP); + rte_errno = ENOENT; + return -1; + } } + pdump_stats = mz->addr; pdump_stats->mz = mz; - ret = rte_mp_action_register(PDUMP_MP, pdump_server); - if (ret && rte_errno != ENOTSUP) - return -1; return 0; } @@ -491,7 +647,7 @@ rte_pdump_uninit(void) { rte_mp_action_unregister(PDUMP_MP); - if (pdump_stats != NULL) { + if (rte_eal_process_type() == RTE_PROC_PRIMARY && pdump_stats != NULL) { rte_memzone_free(pdump_stats->mz); pdump_stats = NULL; } @@ -580,11 +736,12 @@ pdump_prepare_client_request(const char *device, uint16_t queue, int ret = -1; struct rte_mp_msg mp_req, *mp_rep; struct rte_mp_reply mp_reply; - struct timespec ts = {.tv_sec = 5, .tv_nsec = 0}; + struct timespec ts = {.tv_sec = MP_TIMEOUT_S, .tv_nsec = 0}; struct pdump_request *req = (struct pdump_request *)mp_req.param; struct pdump_response *resp; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + /* FIXME */ PDUMP_LOG_LINE(ERR, "pdump enable/disable not allowed in primary process"); return -EINVAL; From patchwork Tue Nov 4 18:07:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 158440 X-Patchwork-Delegate: thomas@monjalon.net 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 E209048AB2; Tue, 4 Nov 2025 19:10:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C0C2140A77; Tue, 4 Nov 2025 19:09:41 +0100 (CET) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by mails.dpdk.org (Postfix) with ESMTP id EDEE3406B8 for ; Tue, 4 Nov 2025 19:09:39 +0100 (CET) Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-b6ce6d1d3dcso4054222a12.3 for ; Tue, 04 Nov 2025 10:09:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1762279779; x=1762884579; 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=MXogDDOvmK+qm2LPMaadzZxaHZp7cU7catOjpOE0zJg=; b=CrJUk2pSu27Iy16BdlLEdNOLZsPpN2kICFaBCvIk0plaMB1eQYEpQRi6BDLCv+TJck nekjwb+KDyjZmAY80Fkh7yo0ynpf4LrGN5mIQutOsD+hc8bWlbcNVntI2oqQYb2vd94Z pMRQHzLst3eiBK2vzT6U4tcQmSDi5S9z+gFgKIRaKerV9MeYYKz/Enp0rKnDXjg9JUA9 oHYin//l8eBUjAKKD1PiBvLlGv50+mnZ+7o2w9kfziACG4lhTuz5yNqqbS+cFEGTU/O8 MuEwMWBg/LWF7UGG2TN/MloTiRpSlBKrVZ+Ir6BdBH1umTjFfGjgFjghu9MQh7fFVBa0 dzcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762279779; x=1762884579; 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=MXogDDOvmK+qm2LPMaadzZxaHZp7cU7catOjpOE0zJg=; b=OLvdstqaQu27vjN7me3aFeajav8jZUi24vUDGUOFQbiTh+d8y4k8KDf9otVN2oK33A XF6DR8oY6dCpN9E1UdEEHpfDMpguWCmnKaX4DHApJ5zUA4oTaZGYk2etdXDWgwlfgCOW Sjs1MZ2I/Z4Asy18VP6VZo1BUj6tl4dw8Ow7J6YJyoL3vp1Mh0uCnOeDm/85MjiaryY7 OMz+JwsaIRHH1MINqF01vLL7obnWV77v6TZoSGx923DQn9dzEb26uJ2HkLm+mahPCrG2 n0cnr9QK8sksuIY3rEzOQmvE5I6AKLHLekfH9Rmt7/fCfARvuApiI8l8LqR8eJTCF7oc 9WnA== X-Gm-Message-State: AOJu0YwQtBHNLtGeos66crrTdotx6DV/bmju8gzReVvQ7zWAFq3WzB6E 29tF0H5zB7SsrwVhPYE5jx8rsUR0om+oG4rjzNd29CDpwPnqHVTI54GMjTjHuXKrPLoaE90exSe bMjhy X-Gm-Gg: ASbGnctrhdlJs4CmeQ2W4nChu/x7gJ0tSCO8WabP4JcmP0icOasarVuCk5RTTNyzbX1 kpbcaDCtH2brrn/wCXhidBrQvG6FVlgVFi+slJJc1qKxuQo7ZO8qpkv3qsfTUtAr7GeU8y3QOSA JhjSH5J96+Yhh0wr1qcN5bsiCpuWrF5FUHHaBtuzXaVAAOcql/9KBn9okMmUO42roEwSjbWKEos +x5M9vSDG3+wZcN/yfgO634Vrt2p6r7DIaXeYzAN+k9Chcc49BncUIXeB6Wjj/athadq7qlCg76 sQHPrWiQR8/SmS2GPKoUAp8q7wQzJvIWVfLN9WOT4LJw/g5HQVGg7FwEnmVkw4d2MQDD5WvTMcQ Q4384/uExfFz0sZk4cv7rth5q0aVzFgMoERYbWO2islDtCG7l9RASFXFjKJHA9rYJDaU5djzgQF daFqm7ZpNsCgB1Kie3xLncdAGvmDyQXOiF9t1SNAw= X-Google-Smtp-Source: AGHT+IEbrZctFLQrUsHgz7yj0H2NDIy2LbcciJLjvFYzhe/2DQoZxg/1eX4dw/MZfR4Z6RkuVYOfxw== X-Received: by 2002:a05:6a21:6d82:b0:342:a261:e2c3 with SMTP id adf61e73a8af0-34f836ef191mr271069637.6.1762279778920; Tue, 04 Nov 2025 10:09:38 -0800 (PST) Received: from phoenix.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba1f86b0688sm3035988a12.28.2025.11.04.10.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Nov 2025 10:09:38 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>, Reshma Pattan Subject: [PATCH v6 7/8] pdump: remove use of VLA Date: Tue, 4 Nov 2025 10:07:11 -0800 Message-ID: <20251104180927.403355-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251104180927.403355-1-stephen@networkplumber.org> References: <20250811213632.16023-1-stephen@networkplumber.org> <20251104180927.403355-1-stephen@networkplumber.org> MIME-Version: 1.0 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 variable length array with refactored loop so that packets are processed in bursts of up to 32. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson Acked-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> --- lib/pdump/meson.build | 2 -- lib/pdump/rte_pdump.c | 42 +++++++++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/lib/pdump/meson.build b/lib/pdump/meson.build index 553dfdd5e6..da8d51b616 100644 --- a/lib/pdump/meson.build +++ b/lib/pdump/meson.build @@ -7,8 +7,6 @@ if is_windows subdir_done() endif -cflags += no_wvla_cflag - sources = files('rte_pdump.c') headers = files('rte_pdump.h') deps += ['ethdev', 'bpf', 'pcapng'] diff --git a/lib/pdump/rte_pdump.c b/lib/pdump/rte_pdump.c index 305325847c..039a4013dd 100644 --- a/lib/pdump/rte_pdump.c +++ b/lib/pdump/rte_pdump.c @@ -27,6 +27,8 @@ RTE_LOG_REGISTER_DEFAULT(pdump_logtype, NOTICE); /* Used for the multi-process communication */ #define PDUMP_MP "mp_pdump" +#define PDUMP_BURST_SIZE 32 + /* Overly generous timeout for secondary to respond */ #define MP_TIMEOUT_S 5 @@ -135,20 +137,22 @@ pdump_cb_release(struct pdump_rxtx_cbs *cbs) /* Create a clone of mbuf to be placed into ring. */ static void -pdump_copy(uint16_t port_id, uint16_t queue, - enum rte_pcapng_direction direction, - struct rte_mbuf **pkts, uint16_t nb_pkts, - const struct pdump_rxtx_cbs *cbs, - struct rte_pdump_stats *stats) +pdump_copy_burst(uint16_t port_id, uint16_t queue_id, + enum rte_pcapng_direction direction, + struct rte_mbuf **pkts, uint16_t nb_pkts, + const struct pdump_rxtx_cbs *cbs, + struct rte_pdump_stats *stats) { unsigned int i; int ring_enq; uint16_t d_pkts = 0; - struct rte_mbuf *dup_bufs[nb_pkts]; + struct rte_mbuf *dup_bufs[PDUMP_BURST_SIZE]; /* duplicated packets */ struct rte_ring *ring; struct rte_mempool *mp; struct rte_mbuf *p; - uint64_t rcs[nb_pkts]; + uint64_t rcs[PDUMP_BURST_SIZE]; /* filter result */ + + RTE_ASSERT(nb_pkts <= PDUMP_BURST_SIZE); if (cbs->filter) rte_bpf_exec_burst(cbs->filter, (void **)pkts, rcs, nb_pkts); @@ -173,8 +177,7 @@ pdump_copy(uint16_t port_id, uint16_t queue, * otherwise a simple copy. */ if (cbs->ver == V2) - p = rte_pcapng_copy(port_id, queue, - pkts[i], mp, cbs->snaplen, + p = rte_pcapng_copy(port_id, queue_id, pkts[i], mp, cbs->snaplen, direction, NULL); else p = rte_pktmbuf_copy(pkts[i], mp, 0, cbs->snaplen); @@ -185,6 +188,9 @@ pdump_copy(uint16_t port_id, uint16_t queue, dup_bufs[d_pkts++] = p; } + if (unlikely(d_pkts == 0)) + return; + rte_atomic_fetch_add_explicit(&stats->accepted, d_pkts, rte_memory_order_relaxed); ring_enq = rte_ring_enqueue_burst(ring, (void *)&dup_bufs[0], d_pkts, NULL); @@ -196,6 +202,24 @@ pdump_copy(uint16_t port_id, uint16_t queue, } } +/* Create a clone of mbuf to be placed into ring. */ +static void +pdump_copy(uint16_t port_id, uint16_t queue_id, + enum rte_pcapng_direction direction, + struct rte_mbuf **pkts, uint16_t nb_pkts, + const struct pdump_rxtx_cbs *cbs, + struct rte_pdump_stats *stats) +{ + uint16_t offs = 0; + + do { + uint16_t n = RTE_MIN(nb_pkts - offs, PDUMP_BURST_SIZE); + + pdump_copy_burst(port_id, queue_id, direction, &pkts[offs], n, cbs, stats); + offs += n; + } while (offs < nb_pkts); +} + static uint16_t pdump_rx(uint16_t port, uint16_t queue, struct rte_mbuf **pkts, uint16_t nb_pkts, From patchwork Tue Nov 4 18:07:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 158441 X-Patchwork-Delegate: thomas@monjalon.net 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 2936B48AB2; Tue, 4 Nov 2025 19:10:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D61ED40A72; Tue, 4 Nov 2025 19:09:42 +0100 (CET) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id 21C0F40A6F for ; Tue, 4 Nov 2025 19:09:41 +0100 (CET) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2955805b7acso693335ad.1 for ; Tue, 04 Nov 2025 10:09:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1762279780; x=1762884580; 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=bzX2+4zwc/W4SYw5qrvZgh1SeceNBqkHGO3r7por6/E=; b=HfN2QoO31EyRfAaH14myM8v3sZSA/gouGfmjUplyZQgrxcaLnJ2rrawiVARH83pvJb r6iVu07WWokOyR+Jhv4LZvaJWzi3xoniS5kjG66YM0xg/mQ0p0u6mRqaRl53k2c9KlXl axnsZT0yhZPJPW6+7jPIRH265J8JvHPrd1AonrEgfwGmbRi+1WcToc6IKyXySMw4EHDJ bXq5Am1P6gutSYQBwdh/CS7d6PC4Ef+zMpD5Afd8x3yjHIx2sPVK2L8IPsvTnxXQZQnH /h7Lamq8o8jSy8gVBNT2apXH9R/qW4w6f5Yg1TNle9Q1EV9Oue3wHPpMZv+O2z3G8qTu 1k9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762279780; x=1762884580; 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=bzX2+4zwc/W4SYw5qrvZgh1SeceNBqkHGO3r7por6/E=; b=wwMAkSpyyIuIEF+234QGshltr9AlPon1M9fw8sLwEOmXr2TL9KOZSRCIcckv9fKgSo ZPhVkB/qWqtdpR/wy7x4Td4HQcrY6eQ1p0hVa9DLkpl87sWbD8HyZtmdpw00i/0jRcnX 02+q2pWaj5NdIujuHx5QfzYpkVDjhGMW6AoEew9PkHdb+m45DQXDuB50nNdXD94mdgGW f4Y3Qm2DGeh7H5N/G6nYCGrTj5YiSzkvjozy8f8T1OjQDPqLZ/EEL6ut8/FcJerTeBDe HmYS6kRdELvygNDP3ZrR7wVXFD1hhGZ0M+22dTAlchQAUE54OdShUvp87gD/AabKd6Q6 55oA== X-Gm-Message-State: AOJu0YzCk0fRm73KU5hM1TvxERhCJXHk44pCy/SP26J7y5LDd1ttDyEr TJEFuVQRCGGP4AeUJHdVVRsK4cvUi9YfXuGhCiE55KxedTejr1w0vqOywQURqmHL7wkQz1we0DG of+uf X-Gm-Gg: ASbGncvFm396xoFCrTx0dZHNWGwTUHEjaiAwSB0OryDhy7WSYqPVL+3vn5RFaNH0lX3 WeZ/ZyykbDULy9YcWcbNu8dARODn71xNI/9PxvoVvZ394hxBFHo/2f9SybUZfucYFv3ZDTR6Pws wb8So6Dw2RGNugCufERaXEaY7YekRHXv5VqdJuYdRGC2p9JWI81pR2rSFTu8OMrsKVbCKH3eHZC FiweIe1gXG9Wuxrpp6JE2VNTzv+0j87aGQrm1u49zpJYb/Cz9vx6XIHSvddqeacY/frNKoiWZ+b b6v8jelamDxYx//0AQJYr0+UzvNPpO386iW1g5he9Nsn3VLC9gHpl0Z5bn0L+w9vCUP6GmR/Jik tv56PW8Fv/+N14KgqHl0tQU7y1kAymml7Dpn1r0HzTvyOuoxKfrQSS7w2/RqS0TMGi6d4FNerkx ZNJNl3mC33XyvnXYbqxrG+F/FxJ9J92Jfq1ywlHLU= X-Google-Smtp-Source: AGHT+IFs7JnwCZF3NlkjAe5AZMOsJEqpWtZWi4do689DUW1CWT4x6RCJVCXfNTgLWCAIqTz1hys/pg== X-Received: by 2002:a17:903:2c04:b0:295:50f5:c0e3 with SMTP id d9443c01a7336-2962ada2f5emr7023675ad.14.1762279780173; Tue, 04 Nov 2025 10:09:40 -0800 (PST) Received: from phoenix.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba1f86b0688sm3035988a12.28.2025.11.04.10.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Nov 2025 10:09:39 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>, Reshma Pattan Subject: [PATCH v6 8/8] doc: update documentation on pdump library Date: Tue, 4 Nov 2025 10:07:12 -0800 Message-ID: <20251104180927.403355-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251104180927.403355-1-stephen@networkplumber.org> References: <20250811213632.16023-1-stephen@networkplumber.org> <20251104180927.403355-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The documentation was missing some of the API, and had some awkward wording. With the help of ChatGPT, update it and make it more concise. Add a release note Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson Acked-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> --- doc/guides/prog_guide/img/pdump_overview.svg | 135 ++++++++++++++ doc/guides/prog_guide/pdump_lib.rst | 183 ++++++++++++------- doc/guides/rel_notes/release_25_11.rst | 5 + 3 files changed, 255 insertions(+), 68 deletions(-) create mode 100644 doc/guides/prog_guide/img/pdump_overview.svg diff --git a/doc/guides/prog_guide/img/pdump_overview.svg b/doc/guides/prog_guide/img/pdump_overview.svg new file mode 100644 index 0000000000..537de49669 --- /dev/null +++ b/doc/guides/prog_guide/img/pdump_overview.svg @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + Capture Process + + Primary Process + + Secondary Processes + + + + + + + + + + rte_eal_init() + + rte_pdump_init() + + + + rte_eal_init() + + rte_pdump_init() + + + + rte_eal_init() + + rte_pdump_init() + + + + + rte_pdump_enable() + + uses rte_mp_request() to message primary + + + + pdump_server() + • enable RX/TX callbacks + • send ACK to capture + • forward request to all secondaries + + + ACK + + forward enable request + + + + pdump_server() + • register RX/TX callbacks + • send response + + + response + + + + collect responses + from secondary processes + + + + + + Packet capture in progress... + + + + + rte_pdump_disable() + + + + pdump_server() + • remove RX/TX callbacks + • forward disable to secondaries + + + + forward disable request + + + + pdump_server() + • remove RX/TX callbacks + + + + response + + + + collect disable responses + + diff --git a/doc/guides/prog_guide/pdump_lib.rst b/doc/guides/prog_guide/pdump_lib.rst index 07b9f39d09..5183756d9e 100644 --- a/doc/guides/prog_guide/pdump_lib.rst +++ b/doc/guides/prog_guide/pdump_lib.rst @@ -4,90 +4,137 @@ Packet Capture Library ====================== -The DPDK ``pdump`` library provides a framework for packet capturing in DPDK. -The library does the complete copy of the Rx and Tx mbufs to a new mempool and -hence it slows down the performance of the applications, so it is recommended -to use this library for debugging purposes. +The DPDK ``pdump`` library provides a framework for capturing packets within DPDK applications. +It enables a **secondary process** to monitor packets being processed by both +**primary** or **secondary** processes. -The library uses a generic multi process channel to facilitate communication -between primary and secondary process for enabling/disabling packet capture on -ports. +Overview +-------- -The library provides the following APIs to initialize the packet capture framework, to enable -or disable the packet capture, and to uninitialize it. +The library uses a multi-process channel to facilitate communication +between the primary and secondary processes. This mechanism allows enabling +or disabling packet capture on specific ports or queues. -* ``rte_pdump_init()``: - This API initializes the packet capture framework. +.. _figure_pdump_overview: -* ``rte_pdump_enable()``: - This API enables the packet capture on a given port and queue. +.. figure:: img/pdump_overview.* -* ``rte_pdump_enable_bpf()`` - This API enables the packet capture on a given port and queue. - It also allows setting an optional filter using DPDK BPF interpreter - and setting the captured packet length. + Packet Capture enable and disable sequence -* ``rte_pdump_enable_by_deviceid()``: - This API enables the packet capture on a given device id (``vdev name or pci address``) and queue. +API Reference +------------- -* ``rte_pdump_enable_bpf_by_deviceid()`` - This API enables the packet capture on a given device id (``vdev name or pci address``) and queue. - It also allows setting an optional filter using DPDK BPF interpreter - and setting the captured packet length. +The library exposes APIs for: -* ``rte_pdump_disable()``: - This API disables the packet capture on a given port and queue. +* Initializing and uninitializing the packet capture framework. +* Enabling and disabling packet capture. +* Applying optional filters and limiting captured packet length. -* ``rte_pdump_disable_by_deviceid()``: - This API disables the packet capture on a given device id (``vdev name or pci address``) and queue. -* ``rte_pdump_uninit()``: - This API uninitializes the packet capture framework. +.. function:: int rte_pdump_init(void) + Initialize the packet capture framework. + +.. function:: int rte_pdump_enable(uint16_t port_id, uint16_t queue, uint32_t flags) + + Enable packet capture on the specified port and queue. + +.. function:: int rte_pdump_enable_bpf(uint16_t port_id, uint16_t queue, const struct rte_bpf_program *bpf, uint32_t snaplen) + + Enable packet capture on the specified port and queue with an optional + BPF packet filter and a limit on the captured packet length. + +.. function:: int rte_pdump_enable_by_deviceid(const char *device_id, uint16_t queue, uint32_t flags) + + Enable packet capture on the specified device ID (``vdev`` name or PCI address) + and queue. + +.. function:: int rte_pdump_enable_bpf_by_deviceid(const char *device_id, uint16_t queue, const struct rte_bpf_program *bpf, uint32_t snaplen) + + Enable packet capture on the specified device ID (``vdev`` name or PCI address) + and queue, with optional filtering and captured packet length limit. + +.. function:: int rte_pdump_disable(uint16_t port_id, uint16_t queue) + + Disable packet capture on the specified port and queue. + This applies to the current process and all other processes. + +.. function:: int rte_pdump_disable_by_deviceid(const char *device_id, uint16_t queue) + + Disable packet capture on the specified device ID (``vdev`` name or PCI address) + and queue. + +.. function:: int rte_pdump_uninit(void) + + Uninitialize the packet capture framework for this process. + +.. function:: int rte_pdump_stats(uint16_t port_id, struct rte_dump_stats *stats) + + Reports the number of packets captured, filtered, and missed. + Packets maybe missed due to mbuf pool being exhausted or the ring being full. Operation --------- -The primary process using ``librte_pdump`` is responsible for initializing the packet -capture framework. The packet capture framework, as part of its initialization, creates the -multi process channel to facilitate communication with secondary process, so the -secondary process ``app/pdump`` tool is responsible for enabling and disabling the packet capture on ports. +All processes using ``librte_pdump`` must initialize the packet capture framework +before use. This initialization is required in both the primary and secondary processes. + +DPDK provides the following utilities that use this library: + +* ``app/dpdk-dumpcap`` +* ``app/pdump`` Implementation Details ---------------------- -The library API ``rte_pdump_init()``, initializes the packet capture framework by creating the multi process -channel using ``rte_mp_action_register()`` API. The primary process will listen to secondary process requests -to enable or disable the packet capture over the multi process channel. - -The library APIs ``rte_pdump_enable()`` and ``rte_pdump_enable_by_deviceid()`` enables the packet capture. -For the calls to these APIs from secondary process, the library creates the "pdump enable" request and sends -the request to the primary process over the multi process channel. The primary process takes this request -and enables the packet capture by registering the Ethernet RX and TX callbacks for the given port or device_id -and queue combinations. Then the primary process will mirror the packets to the new mempool and enqueue them to -the rte_ring that secondary process have passed to these APIs. - -The packet ring supports one of two formats. -The default format enqueues copies of the original packets into the rte_ring. -If the ``RTE_PDUMP_FLAG_PCAPNG`` is set, the mbuf data is extended -with header and trailer to match the format of Pcapng enhanced packet block. -The enhanced packet block has meta-data such as the timestamp, port and queue -the packet was captured on. -It is up to the application consuming the packets from the ring -to select the format desired. - -The library APIs ``rte_pdump_disable()`` and ``rte_pdump_disable_by_deviceid()`` disables the packet capture. -For the calls to these APIs from secondary process, the library creates the "pdump disable" request and sends -the request to the primary process over the multi process channel. The primary process takes this request and -disables the packet capture by removing the Ethernet RX and TX callbacks for the given port or device_id and -queue combinations. - -The library API ``rte_pdump_uninit()``, uninitializes the packet capture framework by calling ``rte_mp_action_unregister()`` -function. - - -Use Case: Packet Capturing --------------------------- - -The DPDK ``app/dpdk-dumpcap`` utility uses this library -to capture packets in DPDK. +``rte_pdump_init()`` creates the multi-process channel by calling +``rte_mp_action_register()``. + +The primary process listens for requests from secondary processes to +enable or disable packet capture over the multi-process channel. + +When a secondary process calls ``rte_pdump_enable()`` or +``rte_pdump_enable_by_deviceid()``, the library sends a "pdump enable" request +to the primary process. The primary process then: + +1. Receives the request over the multi-process channel. +2. Registers Ethernet Rx and Tx callbacks for the specified port. +3. Forwards the request to other secondary processes (if any) + + +FAQ +--- + +* What is the performance impact of pdump? + +Setting up pdump with ``rte_pdump_init`` has no impact, +there are no changes in the fast path. +When pdump is enabled, the Tx and Rx fast path functions +callbacks make a copy of the mbufs and enqueue them. This will impact +performance. The effect can be reduced by filtering to only +see the packets of interest and using the snaplen parameter +to only copy the needed headers. + +* What happens if process does not call pdump init? + +If application does not call ``rte_pdump_init`` then the request +to enable (in the capture command) will timeout and an error is returned. + +* Where do packets go? + +Packets captured are placed in the ring passed in ``rte_pdump_enable``. +The capture application must dequeue these mbuf's and free them. + +* Why is copy required? + +A copy is used instead of incrementing the reference count because +on transmit the device maybe using fast free which does not use refcounts; +and on receive the application may modify the incoming packet. + +* What about offloads? + +The offload flags of the original mbuf are copied to the ring. +It is up to the capture application to handle flags like VLAN stripping +as necessary. Packets are captured before passing to driver and hardware +so the actual packet on the wire maybe segmented or encapsulated based +on the offload flags. diff --git a/doc/guides/rel_notes/release_25_11.rst b/doc/guides/rel_notes/release_25_11.rst index c5ba335cfc..5dfdb5ff1e 100644 --- a/doc/guides/rel_notes/release_25_11.rst +++ b/doc/guides/rel_notes/release_25_11.rst @@ -167,6 +167,11 @@ New Features The built-in help text function is available as a public function which can be reused by custom functions, if so desired. +* **Added packet capture (pdump) for secondary process.** + + Added multi-process support to allow packets sent and received by secondary + process to be visible in packet capture. + Removed Items -------------