• Stanislav Fomichev's avatar
    selftests/bpf: Simple program to dump XDP RX metadata · 297a3f12
    Stanislav Fomichev authored
    To be used for verification of driver implementations. Note that
    the skb path is gone from the series, but I'm still keeping the
    implementation for any possible future work.
    
    $ xdp_hw_metadata <ifname>
    
    On the other machine:
    
    $ echo -n xdp | nc -u -q1 <target> 9091 # for AF_XDP
    $ echo -n skb | nc -u -q1 <target> 9092 # for skb
    
    Sample output:
    
      # xdp
      xsk_ring_cons__peek: 1
      0x19f9090: rx_desc[0]->addr=100000000008000 addr=8100 comp_addr=8000
      rx_timestamp_supported: 1
      rx_timestamp: 1667850075063948829
      0x19f9090: complete idx=8 addr=8000
    
      # skb
      found skb hwtstamp = 1668314052.854274681
    
    Decoding:
      # xdp
      rx_timestamp=1667850075.063948829
    
      $ date -d @1667850075
      Mon Nov  7 11:41:15 AM PST 2022
      $ date
      Mon Nov  7 11:42:05 AM PST 2022
    
      # skb
      $ date -d @1668314052
      Sat Nov 12 08:34:12 PM PST 2022
      $ date
      Sat Nov 12 08:37:06 PM PST 2022
    
    Cc: John Fastabend <john.fastabend@gmail.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Martin KaFai Lau <martin.lau@linux.dev>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Willem de Bruijn <willemb@google.com>
    Cc: Jesper Dangaard Brouer <brouer@redhat.com>
    Cc: Anatoly Burakov <anatoly.burakov@intel.com>
    Cc: Alexander Lobakin <alexandr.lobakin@intel.com>
    Cc: Magnus Karlsson <magnus.karlsson@gmail.com>
    Cc: Maryam Tahhan <mtahhan@redhat.com>
    Cc: xdp-hints@xdp-project.net
    Cc: netdev@vger.kernel.org
    Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
    Link: https://lore.kernel.org/r/20230119221536.3349901-18-sdf@google.comSigned-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
    297a3f12
xdp_hw_metadata.c 1.99 KB