2

Why is setting SO_TIMESTAMP not supported for an AF_XDP socket? The user manual of my driver (mlnx 5.0) states that

Incoming packets are time-stamped before they are distributed on the PCI depending on the congestion in the PCI buffers.

To my knowledge, before distributed on the PCI means that there is no Linux Kernel involved (yet) - right?

I tried setting it like this:

int timestamp = SOF_TIMESTAMPING_RX_HARDWARE;
if(setsockopt(xsk_socket__fd(xsk_socket->xsk), SOL_XDP, SO_TIMESTAMP, (int*)&timestamp, sizeof(int)) < 0) {
    fprintf(stderr, "Failed to set `SO_TIMESTAMP`: %s\n", strerror(errno));
    return;
}

And get:

Failed to set SO_TIMESTAMP: Protocol not available

I copied the definition of SO_XDP from xsk.c (https://github.com/libbpf/libbpf/blob/master/src/xsk.c):

#ifndef SOL_XDP
 #define SOL_XDP 283
#endif

I don't understand, why it is not supported...

binaryBigInt
  • 1,526
  • 2
  • 18
  • 44

1 Answers1

1

There is no technical reason on why it is not implemented.

Indeed, it looks like it is on the To-Do list of the xdp development team.

Cite from here:

Important medium-term tasks

...

Metadata from hardware

There are various hardware metadata items that would be useful for XDP programs to access, to reduce the amount of processing that needs to happen in eBPF. These include:

  • Checksum
  • Hash value
  • Flow designator
  • Higher-level protocol header offsets
  • Timestamps

It looks like this is on the To-Do since June 2019, so it probably doesn't have top priority, otherwise it would already be implemented.

Ctx
  • 18,090
  • 24
  • 36
  • 51