Re: [PATCH v2 0/9] pcap: cleanup pcap PMD and add test

Stephen Hemminger
2026-01-12T00:50:27Z

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.