Skip to content

Commit

Permalink
af_xdp: move rx timestamp read to support WODA
Browse files Browse the repository at this point in the history
Move AF_XDP rx timestamp read into vi->ops.receive_get_timestamp.

The original implementation added a branch in device independent
get_rx_timestamp. This is not needed, and it breaks WODA, because
record_rx_timestamp is skipped.

Fix this, and as a side-effect better isolate the AF_XDP from the
device independent code.

WODA also needs the EF_VI_SYNC flags passed. XDP offers no way to
query the device for these currently. Similar to ef10_mcdi_event,
assume clock is always in sync.

With this change, src/tests/onload/wire_order succeeds.

Signed-off-by: Willem de Bruijn <[email protected]>
  • Loading branch information
wdebruij committed Oct 31, 2024
1 parent 272c4d8 commit 623ae39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
20 changes: 19 additions & 1 deletion src/lib/ciul/efxdp_vi.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,25 @@ static void efxdp_ef_vi_receive_push(ef_vi* vi)
static int efxdp_ef_vi_receive_get_timestamp(struct ef_vi* vi, const void* pkt,
ef_precisetime* ts_out)
{
return -EOPNOTSUPP;
const uint64_t ns_to_sec = 1000UL * 1000 * 1000;
struct onload_xdp_rx_meta {
#define ONLOAD_XDP_RX_META_TSTAMP 0x1
uint64_t flags;
uint64_t tstamp;
} *meta = pkt;

/* pkt points to start of packet data. meta precedes that */
meta--;
if (!(meta->flags & ONLOAD_XDP_RX_META_TSTAMP)) {
*ts_out = (ef_precisetime) { 0 };
return -ENODATA;
}

ts_out->tv_sec = meta->tstamp / ns_to_sec;
ts_out->tv_nsec = meta->tstamp % ns_to_sec;
ts_out->tv_nsec_frac = 0;
ts_out->tv_flags = EF_VI_SYNC_FLAG_CLOCK_SET | EF_VI_SYNC_FLAG_CLOCK_IN_SYNC;
return 0;
}

static void efxdp_ef_eventq_prime(ef_vi* vi)
Expand Down
20 changes: 0 additions & 20 deletions src/lib/transport/ip/netif_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,26 +221,6 @@ static void get_rx_timestamp(ci_netif* netif, ci_ip_pkt_fmt* pkt)
ci_netif_state_nic_t* nsn = &netif->state->nic[pkt->intf_i];
ef_vi* vi = ci_netif_vi(netif, pkt->intf_i);

/* AF_XDP timestamps are read in ci_netif_poll_evq
* TODO: probably move here. we have all necessary data: vi and pkt */
if( vi->nic_type.arch == EF_VI_ARCH_AF_XDP ) {
struct onload_xdp_rx_meta {
#define ONLOAD_XDP_RX_META_TSTAMP 0x1
uint64_t flags;
uint64_t tstamp;
} *meta;
const uint64_t ns_to_sec = 1000UL * 1000 * 1000;

meta = ((struct onload_xdp_rx_meta *)(pkt->dma_start + pkt->pkt_start_off)) - 1;
if (meta->flags & ONLOAD_XDP_RX_META_TSTAMP) {
pkt->hw_stamp.tv_sec = meta->tstamp / ns_to_sec;
pkt->hw_stamp.tv_nsec = meta->tstamp % ns_to_sec;
pkt->hw_stamp.tv_nsec_frac = 0;
pkt->hw_stamp.tv_flags = 0;
}
return;
}

if( (vi->nic_type.arch != EF_VI_ARCH_EFCT) &&
(nsn->oo_vi_flags & OO_VI_FLAGS_RX_HW_TS_EN) ) {
ef_precisetime stamp;
Expand Down

0 comments on commit 623ae39

Please sign in to comment.