|WARNING| [v3,1/1] pcapng: add user-supplied timestamp support
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Thu Jun 18 23:08:32 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/165676
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-06-18
# DPDK Patch Review: pcapng user-supplied timestamp support
## Summary
This patch adds support for user-supplied timestamps in the pcapng library, allowing applications to provide hardware PTP timestamps. The implementation uses a sentinel bit (bit 63) to distinguish between TSC-based and user-supplied timestamps.
---
## Errors
None found. The patch correctly implements the timestamp handling logic and all resource management is sound.
---
## Warnings
### 1. Missing `__rte_experimental` annotation on new API function
**Issue:** The new public function `rte_pcapng_copy_ts()` is not marked as experimental, but it is a new API addition that should be marked `__rte_experimental` per DPDK policy.
**Why it matters:** New API functions must go through an experimental period before becoming stable. This allows for API changes based on user feedback without breaking ABI compatibility.
**Suggested fix:**
```c
__rte_experimental
struct rte_mbuf *
rte_pcapng_copy_ts(uint16_t port_id, uint32_t queue,
const struct rte_mbuf *m, struct rte_mempool *mp,
uint32_t length,
enum rte_pcapng_direction direction, const char *comment, uint64_t ts);
```
Additionally, the `RTE_EXPORT_SYMBOL` line should use `RTE_EXPORT_EXPERIMENTAL_SYMBOL`:
```c
RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pcapng_copy_ts, 26.11) /* adjust version */
```
### 2. Missing release notes update
**Issue:** The patch adds a new public API function but does not include a corresponding update to `doc/guides/rel_notes/release_26_11.rst` (or the current release version).
**Why it matters:** API changes and new features must be documented in release notes so users are aware of new functionality.
**Suggested fix:** Add an entry to the "New Features" section of the current release notes file documenting the new `rte_pcapng_copy_ts()` function and its use case for hardware PTP timestamps.
### 3. Missing testpmd hook or functional test
**Issue:** The new API function `rte_pcapng_copy_ts()` does not appear to have an accompanying test in `app/test/` or usage example in `app/testpmd/`.
**Why it matters:** New API functions should be tested to verify correct behavior and provide usage examples for developers.
**Suggested fix:** Add a test case to `app/test/test_pcapng.c` (if it exists) that exercises the timestamp path with both zero and non-zero `ts` values, or add usage in testpmd's packet capture path.
---
## Info
### 1. API design consideration: Timestamp in nanoseconds
The chosen timestamp format (nanoseconds since Unix epoch) is reasonable and matches common practice. However, the API might benefit from explicit documentation about:
- The valid range for the timestamp (0 for TSC-based, or any positive value representing epoch ns)
- The behavior when the timestamp exceeds the year 2554 threshold mentioned in the commit message (bit 63 collision)
- Whether sub-nanosecond precision from hardware timestamps is lost or how it should be rounded
Consider adding a note in the Doxygen comment about the expected timestamp precision and range limitations.
### 2. Sentinel bit mechanism is clever but undocumented in header
The sentinel bit mechanism using bit 63 is a reasonable approach, but the header file documentation does not explain this internal detail. While implementation details don't always need to be in the public header, it might be worth a comment in the header explaining that "when ts==0, the function captures the current time internally" to clarify the special meaning of zero.
---
## Positive Observations
1. **Good backward compatibility:** Making `rte_pcapng_copy()` a static inline wrapper preserves the existing API completely.
2. **Sound timestamp handling logic:** The sentinel bit approach is safe given the constraints (TSC and epoch ns both stay below bit 63 in the relevant timeframes).
3. **Clean code style:** The patch follows DPDK coding conventions for indentation, bracing, and comments.
4. **Correct resource management:** No leaks or use-after-free issues detected. The timestamp modification happens in-place on an already-allocated mbuf.
5. **Proper .mailmap updates:** Both authors are correctly added.
---
## Required Actions
1. **Add `__rte_experimental` to `rte_pcapng_copy_ts()` declaration** (Warning - must fix for merge)
2. **Update `RTE_EXPORT_SYMBOL` to `RTE_EXPORT_EXPERIMENTAL_SYMBOL`** with appropriate version (Warning - must fix for merge)
3. **Add release notes entry** for the new API (Warning - required)
4. **Add test coverage** for the new function (Warning - required before stabilization)
Once these items are addressed, the patch will be ready for merge.
More information about the test-report
mailing list