Skip to content

Commit faeee50

Browse files
committed
Add timestamp to netmap_slot
1 parent 81d0e5a commit faeee50

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

LINUX/mlx5_netmap_linux.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ int mlx5e_netmap_txsync(struct netmap_kring *kring, int flags) {
324324

325325
/* unpack slot number from skb pointer */
326326
nm_i_done = (u32)((uintptr_t)skb & 0x00FFFFFF);
327+
slot->flags |= NS_TIMESTAMP;
328+
slot->ts = mlx5_timecounter_cyc2time(sq->clock, get_cqe_ts(cqe));
327329

328330
sqcc += num_wqebbs;
329331
kring->nr_hwtail = nm_prev(nm_i_done, lim);
@@ -491,6 +493,9 @@ int mlx5e_netmap_rxsync(struct netmap_kring *kring, int flags) {
491493

492494
ring->slot[nm_i].len = bytes_recv;
493495
ring->slot[nm_i].flags = slot_flags;
496+
ring->slot[nm_i].flags |= NS_TIMESTAMP;
497+
ring->slot[nm_i].ts = mlx5_timecounter_cyc2time(rq->clock, get_cqe_ts(cqe));
498+
494499
nm_i = nm_next(nm_i, lim);
495500

496501
wq_cyc_pop:

sys/net/netmap.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ struct netmap_slot {
165165
uint16_t len; /* length for this slot */
166166
uint16_t flags; /* buf changed, etc. */
167167
uint64_t ptr; /* pointer for indirect buffers */
168+
uint64_t ts; /* timestamp of buffer */
168169
};
169170

170171
/*
@@ -224,6 +225,12 @@ struct netmap_slot {
224225
* ring of the monitored port
225226
*/
226227

228+
#define NS_TIMESTAMP 0x0080
229+
/* the packet has a receive or transmit timestamp
230+
Note: this is using the NIC hardware clock and
231+
not the PC clock
232+
*/
233+
227234
#define NS_PORT_SHIFT 8
228235
#define NS_PORT_MASK (0xff << NS_PORT_SHIFT)
229236
/*

0 commit comments

Comments
 (0)