DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Subject: Re: [PATCH v2 0/9] pcap: cleanup pcap PMD and add test
Date: Sun, 11 Jan 2026 16:50:18 -0800	[thread overview]
Message-ID: <20260111165018.1f4ced3d@phoenix.local> (raw)
In-Reply-To: <20260109011755.362857-1-stephen@networkplumber.org>

On Thu,  8 Jan 2026 17:16:17 -0800
Stephen Hemminger <stephen@networkplumber.org> wrote:

> This is a set of enhancements and tests to the PCAP PMD.
> It started out when looking at the handling of timestamps
> then realized lots of other cleanups were needed here.
> 
> v2 - review feedback
>    - consolidate patches
> 
> Stephen Hemminger (9):
>   net/pcap: avoid using rte_malloc and rte_memcpy
>   net/pcap: support MTU set
>   net/pcap: use bool for flags
>   net/pcap: support Tx offloads
>   net/pcap: support nanosecond timestamp precision
>   net/pcap: remove global variables
>   net/pcap: avoid use of volatile
>   net/pcap: support MAC address set
>   test: add test for pcap PMD
> 
>  app/test/meson.build                  |    2 +
>  app/test/test_pmd_pcap.c              | 1846 +++++++++++++++++++++++++
>  drivers/net/pcap/pcap_ethdev.c        |  353 +++--
>  drivers/net/pcap/pcap_osdep.h         |    2 +
>  drivers/net/pcap/pcap_osdep_freebsd.c |   60 +-
>  drivers/net/pcap/pcap_osdep_linux.c   |   51 +-
>  drivers/net/pcap/pcap_osdep_windows.c |    5 +
>  7 files changed, 2184 insertions(+), 135 deletions(-)
>  create mode 100644 app/test/test_pmd_pcap.c
> 

Results of AI review with AGENTS.md are:


I'll start by reading the AGENTS.md file to understand the review criteria, then examine the patch bundle.Let me view the middle sections of the patch bundle to see all patches:Now I have a comprehensive view of the patch series. Let me provide the review based on the AGENTS.md criteria:

---

## DPDK Patch Review: net/pcap Driver Changes (v2, 9 patches)

### Patch Series Overview

| # | Subject | Status |
|---|---------|--------|
| 1/9 | net/pcap: avoid using rte_malloc and rte_memcpy | ✅ Clean |
| 2/9 | net/pcap: support MTU set | ⚠️ Minor issues |
| 3/9 | net/pcap: use bool for flags | ✅ Clean |
| 4/9 | net/pcap: add VLAN insert offload | ✅ Clean |
| 5/9 | net/pcap: support nanosecond timestamp precision | ✅ Clean |
| 6/9 | net/pcap: localize variables | ✅ Clean |
| 7/9 | net/pcap: avoid use of volatile | ✅ Clean |
| 8/9 | net/pcap: support MAC address set | ⚠️ Minor issues |
| 9/9 | test: add test for pcap PMD | ⚠️ Warnings |

---

### Detailed Review

#### **Patch 1/9: net/pcap: avoid using rte_malloc and rte_memcpy**

**Commit Message**: ✅ Pass
- Subject line: 49 chars (≤60 ✓)
- Correct component prefix `net/pcap:`
- Imperative mood, lowercase, no trailing period
- Signed-off-by present

**Code Changes**: ✅ Pass
- Simple, correct replacement of `rte_malloc`/`rte_free` with standard `malloc`/`free`
- Removes unnecessary includes `<rte_malloc.h>` and `<rte_memcpy.h>`
- Appropriate for FreeBSD osdep code that doesn't need hugepage allocations

---

#### **Patch 2/9: net/pcap: support MTU set**

**Commit Message**: ✅ Pass

**Code Review**: ⚠️ Warnings

1. **FreeBSD duplicate check** (line 489-491):
   ```c
   int s = socket(AF_INET, SOCK_DGRAM, 0);
   if (s < 0)
       return -errno;

   struct ifreq ifr = { 0 };
   if (s < 0)     // <-- Dead code: already checked above
       return -EINVAL;
   ```
   This is dead code - `s < 0` was already handled above. Remove the second check.

2. **Double blank line** (lines 1009-1010): Style issue - extra blank line before `static const struct eth_dev_ops ops`.

3. **Warning (should fix)**: The FreeBSD `osdep_iface_mtu_set` function does not close the socket on all error paths before the duplicate check.

---

#### **Patch 3/9: net/pcap: use bool for flags**

**Commit Message**: ✅ Pass

**Code Changes**: ✅ Pass
- Good cleanup converting `unsigned int` and `int` flags to `bool`
- Adds `<stdbool.h>` header appropriately
- Consolidates `select_phy_mac` and `get_infinite_rx_arg` into unified `process_bool_flag`
- Using `bool` for flags follows DPDK guidelines

---

#### **Patch 4/9: net/pcap: add VLAN insert offload**

**Commit Message**: ✅ Pass

**Code Changes**: ✅ Pass
- Adds `<rte_vlan.h>` header
- Correctly adds VLAN insert capability to both TX paths
- Reports capability in `dev_info->tx_offload_capa`

---

#### **Patch 5/9: net/pcap: support nanosecond timestamp precision**

**Commit Message**: ✅ Pass

**Code Changes**: ✅ Pass
- Good use of `rte_reciprocal_u64` for efficient division
- Replaces `pcap_open_live` with `pcap_create`/`pcap_activate` pattern for more control
- Uses `pcap_open_offline_with_tstamp_precision` for nanosecond precision
- Adds `read_clock` op for timestamp synchronization
- Makes timestamp offloading configurable via `rxmode.offloads`

**Info**: Nice optimization using `rte_reciprocal_divide_u64` to avoid expensive division operations in the fast path.

---

#### **Patch 6/9: net/pcap: localize variables**

**Commit Message**: ✅ Pass
- Has `Acked-by:` from reviewer ✓

**Code Changes**: ✅ Pass
- Moves `errbuf` to function-local scope
- Makes `iface_idx` static within function scope
- Good practice to reduce global state

---

#### **Patch 7/9: net/pcap: avoid use of volatile**

**Commit Message**: ✅ Pass

**Code Changes**: ✅ Pass
- Removes `volatile` keyword from statistics structures
- Changes `unsigned long` to `uint64_t` for consistency
- Rationale is sound: only one thread operates on a queue at a time in DPDK

---

#### **Patch 8/9: net/pcap: support MAC address set**

**Commit Message**: ✅ Pass

**Code Review**: ⚠️ Warnings

1. **Double blank line** (lines 1709-1711): Extra blank line after `eth_dev_macaddr_set` function.

2. **Linux code changes** (line 1803-1809): The header reordering is correct:
   ```c
   #include <string.h>
   #include <stdint.h>
   #include <unistd.h>
   #include <errno.h>
   #include <net/if.h>
   #include <net/if_arp.h>
   ```
   This follows proper include ordering (system headers first).

---

#### **Patch 9/9: test: add test for pcap PMD**

**Commit Message**: ✅ Pass
- Subject `test:` prefix is correct for app/test

**Code Review**: ⚠️ Warnings

1. **SPDX/Copyright**: ✅ Correct format:
   ```c
   /* SPDX-License-Identifier: BSD-3-Clause
    * Copyright(c) 2026 Stephen Hemminger
    */
   ```

2. **Include order issue** (lines 1977-1997): The `"test.h"` and `"packet_burst_generator.h"` should come **after** system and DPDK includes, not before. The correct order per AGENTS.md is:
   - System/libc includes
   - DPDK EAL includes
   - DPDK misc library includes
   - Application-specific includes

   **Should be:**
   ```c
   #include <stdio.h>
   #include <stdlib.h>
   ...
   #include <rte_ethdev.h>
   ...
   #include "test.h"
   #include "packet_burst_generator.h"
   ```

3. **Meson.build style** (line 1955):
   ```python
   'test_pmd_pcap.c': ['net_pcap', 'ethdev',  'bus_vdev']  + packet_burst_generator_deps,
   ```
   Double space after `'ethdev',` - should be single space.

4. **Test registration** (line 3818): Uses `REGISTER_FAST_TEST` which is correct for the test framework.

5. **Line length**: All checked lines are within the 100-char limit ✓

---

### Summary

| Severity | Count | Issues |
|----------|-------|--------|
| **Error** | 0 | None |
| **Warning** | 4 | Dead code in FreeBSD MTU (2/9), double blank lines (2/9, 8/9), include order in test (9/9), meson spacing (9/9) |
| **Info** | 1 | Good use of reciprocal divide optimization (5/9) |

### Recommendations

1. **Patch 2/9**: Remove the dead code check `if (s < 0)` on line 490 of `pcap_osdep_freebsd.c`

2. **Patch 2/9, 8/9**: Remove extra blank lines to maintain single blank line between functions

3. **Patch 9/9**: Reorder includes in `test_pmd_pcap.c` to place `"test.h"` and `"packet_burst_generator.h"` after DPDK includes

4. **Patch 9/9**: Fix double space in `meson.build`

Overall, this is a well-structured patch series with good separation of concerns. The issues are minor style/cleanup items that don't affect functionality.

      parent reply	other threads:[~2026-01-12  0:50 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-06 18:26 [PATCH 00/12] net/pcap: cleanups and test Stephen Hemminger
2026-01-06 18:26 ` [PATCH 01/12] net/pcap: avoid using rte_malloc and rte_memcpy Stephen Hemminger
2026-01-06 18:26 ` [PATCH 02/12] net/pcap: support MTU set Stephen Hemminger
2026-01-06 18:26 ` [PATCH 03/12] net/pcap: use bool for flags Stephen Hemminger
2026-01-07 10:28   ` Marat Khalili
2026-01-09  0:23     ` Stephen Hemminger
2026-01-06 18:26 ` [PATCH 04/12] net/pcap: support Tx offloads Stephen Hemminger
2026-01-06 18:26 ` [PATCH 05/12] net/pcap: support nanosecond timestamp precision Stephen Hemminger
2026-01-06 18:26 ` [PATCH 06/12] net/pcap: remove global variables Stephen Hemminger
2026-01-07  9:48   ` Marat Khalili
2026-01-06 18:26 ` [PATCH 07/12] net/pcap: avoid use of volatile Stephen Hemminger
2026-01-07 10:31   ` Marat Khalili
2026-01-06 18:26 ` [PATCH 08/12] net/pcap: optimize calculation of receive timestamp Stephen Hemminger
2026-01-07 10:58   ` Marat Khalili
2026-01-06 18:26 ` [PATCH 09/12] net/pcap: report receive clock Stephen Hemminger
2026-01-06 18:26 ` [PATCH 10/12] net/pcap: cleanup MAC address handling Stephen Hemminger
2026-01-06 18:26 ` [PATCH 11/12] net/pcap: support MAC address set Stephen Hemminger
2026-01-06 18:26 ` [PATCH 12/12] test: add test for pcap PMD Stephen Hemminger
2026-01-09  1:16 ` [PATCH v2 0/9] pcap: cleanup pcap PMD and add test Stephen Hemminger
2026-01-09  1:16   ` [PATCH v2 1/9] net/pcap: avoid using rte_malloc and rte_memcpy Stephen Hemminger
2026-01-09  1:16   ` [PATCH v2 2/9] net/pcap: support MTU set Stephen Hemminger
2026-01-09  1:16   ` [PATCH v2 3/9] net/pcap: use bool for flags Stephen Hemminger
2026-01-09  1:16   ` [PATCH v2 4/9] net/pcap: support Tx offloads Stephen Hemminger
2026-01-09  1:16   ` [PATCH v2 5/9] net/pcap: support nanosecond timestamp precision Stephen Hemminger
2026-01-09  1:16   ` [PATCH v2 6/9] net/pcap: remove global variables Stephen Hemminger
2026-01-09  1:16   ` [PATCH v2 7/9] net/pcap: avoid use of volatile Stephen Hemminger
2026-01-09  1:16   ` [PATCH v2 8/9] net/pcap: support MAC address set Stephen Hemminger
2026-01-09  1:16   ` [PATCH v2 9/9] test: add test for pcap PMD Stephen Hemminger
2026-01-12  0:50   ` Stephen Hemminger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260111165018.1f4ced3d@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).