1. 06 Jan, 2022 10 commits
    • Alexei Starovoitov's avatar
      Merge branch 'samples/bpf: xdpsock app enhancements' · 640a171c
      Alexei Starovoitov authored
      Ong Boon says:
      
      ====================
      
      First of all, sorry for taking more time to get back to this series and
      thanks to all valuble feedback in series-1 at [1] from Jesper and Song
      Liu.
      
      Since then I have looked into what Jesper suggested in [2] and worked on
      revising the patch series into several patches for ease of review:
      
      v1->v2:
      1/7: [No change]. Add VLAN tag (ID & Priority) to the generated Tx-Only
           frames.
      
      2/7: [No change]. Add DMAC and SMAC setting to the generated Tx-Only
           frames. If parameters are not set, previous DMAC and SMAC are used.
      
      3/7: [New]. Add support for selecting different CLOCK for clock_gettime()
           used in get_nsecs.
      
      4/7: [New]. This is a total rework from series-1 3/4-patch [3]. It uses
           clock_nanosleep() suggested by Jesper. In addition, added statistic
           for Tx schedule variance under application stat (-a|--app-stats).
           Make the cyclic Tx operation and --poll mode to be mutually-
           exclusive. Still, the ability to specify TX cycle time and used
           together with batch size and packet count remain the same.
      
      5/7: [New]. Add the support for TX process schedule policy and priority
           setting. By default, SCHED_OTHER policy is used. This too is matching
           the schedule policy setting in [2].
      
      6/7: [Change]. This is update from series-1 4/4-patch [4]. Added TX clean
           process time-out in 1s granularity with configurable retries count
           (-O|--retries).
      
      7/7: [New]. Added timestamp for TX packet following pktgen_hdr format
           matching the implementation in [2]. However, the sequence ID remains
           the same as it is instead of process schedule diff in [2].
      
      To summarize on what program options have been added with v2 series
      using an example below:-
      
       DMAC (-G)                 = fa:8d:f1:e2:0b:e8
       SMAC (-H)                 = ce:17:07:17:3e:3a
      
       VLAN tagged (-V)
       VLAN ID (-J)              = 12
       VLAN Pri (-K)             = 3
      
       Tx Queue (-q)             = 3
       Cycle Time in us (-T)     = 1000
       Batch (-b)                = 2
       Packet Count              = 6
       Tx schedule policy (-W)   = FIFO
       Tx schedule priority (-U) = 50
       Clock selection (-w)      = REALTIME
      
       Tx timeout retries(-O)    = 5
       Tx timestamp (-y)
       Cyclic Tx schedule stat (-a)
      
      Note: xdpsock sets UDP dest-port and src-port to 0x1000 as default.
      
       Sending Board
       =============
       $ xdpsock -i eth0 -t -N -z -H ce:17:07:17:3e:3a -G fa:8d:f1:e2:0b:e8 \
         -V -J 12 -K 3 -q 3 \
         -T 1000 -b 2 -C 6 -W FIFO -U 50 -w REALTIME \
         -O 5 -y -a
      
        sock0@eth0:3 txonly xdp-drv
                          pps            pkts           0.00
       rx                 0              0
       tx                 0              6
      
                          calls/s        count
       rx empty polls     0              0
       fill fail polls    0              0
       copy tx sendtos    0              0
       tx wakeup sendtos  0              5
       opt polls          0              0
      
                          period     min        ave        max        cycle
       Cyclic TX          1000000    31033      32009      33397      3
      
       Receiving Board
       ===============
       $ tcpdump -nei eth0 udp port 0x1000 -vv -Q in -X \
          --time-stamp-precision nano
      tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
      03:46:40.520111580 ce:17:07:17:3e:3a > fa:8d:f1:e2:0b:e8, ethertype 802.1Q (0x8100), length 62: vlan 12, p 3, ethertype IPv4, (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 44)
          10.10.10.16.4096 > 10.10.10.32.4096: [udp sum ok] UDP, length 16
              0x0000:  4500 002c 0000 0000 4011 527e 0a0a 0a10  E..,....@.R~....
              0x0010:  0a0a 0a20 1000 1000 0018 e997 be9b e955  ...............U
              0x0020:  0000 0000 61cd 2ba1 0006 987c            ....a.+....|
      03:46:40.520112163 ce:17:07:17:3e:3a > fa:8d:f1:e2:0b:e8, ethertype 802.1Q (0x8100), length 62: vlan 12, p 3, ethertype IPv4, (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 44)
          10.10.10.16.4096 > 10.10.10.32.4096: [udp sum ok] UDP, length 16
              0x0000:  4500 002c 0000 0000 4011 527e 0a0a 0a10  E..,....@.R~....
              0x0010:  0a0a 0a20 1000 1000 0018 e996 be9b e955  ...............U
              0x0020:  0000 0001 61cd 2ba1 0006 987c            ....a.+....|
      03:46:40.521066860 ce:17:07:17:3e:3a > fa:8d:f1:e2:0b:e8, ethertype 802.1Q (0x8100), length 62: vlan 12, p 3, ethertype IPv4, (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 44)
          10.10.10.16.4096 > 10.10.10.32.4096: [udp sum ok] UDP, length 16
              0x0000:  4500 002c 0000 0000 4011 527e 0a0a 0a10  E..,....@.R~....
              0x0010:  0a0a 0a20 1000 1000 0018 e5af be9b e955  ...............U
              0x0020:  0000 0002 61cd 2ba1 0006 9c62            ....a.+....b
      03:46:40.521067012 ce:17:07:17:3e:3a > fa:8d:f1:e2:0b:e8, ethertype 802.1Q (0x8100), length 62: vlan 12, p 3, ethertype IPv4, (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 44)
          10.10.10.16.4096 > 10.10.10.32.4096: [udp sum ok] UDP, length 16
              0x0000:  4500 002c 0000 0000 4011 527e 0a0a 0a10  E..,....@.R~....
              0x0010:  0a0a 0a20 1000 1000 0018 e5ae be9b e955  ...............U
              0x0020:  0000 0003 61cd 2ba1 0006 9c62            ....a.+....b
      03:46:40.522061935 ce:17:07:17:3e:3a > fa:8d:f1:e2:0b:e8, ethertype 802.1Q (0x8100), length 62: vlan 12, p 3, ethertype IPv4, (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 44)
          10.10.10.16.4096 > 10.10.10.32.4096: [udp sum ok] UDP, length 16
              0x0000:  4500 002c 0000 0000 4011 527e 0a0a 0a10  E..,....@.R~....
              0x0010:  0a0a 0a20 1000 1000 0018 e1c5 be9b e955  ...............U
              0x0020:  0000 0004 61cd 2ba1 0006 a04a            ....a.+....J
      03:46:40.522062173 ce:17:07:17:3e:3a > fa:8d:f1:e2:0b:e8, ethertype 802.1Q (0x8100), length 62: vlan 12, p 3, ethertype IPv4, (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 44)
          10.10.10.16.4096 > 10.10.10.32.4096: [udp sum ok] UDP, length 16
              0x0000:  4500 002c 0000 0000 4011 527e 0a0a 0a10  E..,....@.R~....
              0x0010:  0a0a 0a20 1000 1000 0018 e1c4 be9b e955  ...............U
              0x0020:  0000 0005 61cd 2ba1 0006 a04a            ....a.+....J
      
      I have tested the above with both tagged and untagged packet format and
      based on the timestamp in tcpdump found that the timing of the batch
      cyclic transmission is correct.
      
      Appreciate if community can give the patch series v2 a try and point out
      any gap.
      
      Thanks
      Boon Leong
      
      [1] https://patchwork.kernel.org/project/netdevbpf/cover/20211124091821.3916046-1-boon.leong.ong@intel.com/
      [2] https://github.com/netoptimizer/network-testing/blob/master/src/udp_pacer.c
      [3] https://patchwork.kernel.org/project/netdevbpf/patch/20211124091821.3916046-4-boon.leong.ong@intel.com/
      [4] https://patchwork.kernel.org/project/netdevbpf/patch/20211124091821.3916046-5-boon.leong.ong@intel.com/
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      640a171c
    • Ong Boon Leong's avatar
      samples/bpf: xdpsock: Add timestamp for Tx-only operation · eb68db45
      Ong Boon Leong authored
      It may be useful to add timestamp for Tx packets for continuous or cyclic
      transmit operation. The timestamp and sequence ID of a Tx packet are
      stored according to pktgen header format. To enable per-packet timestamp,
      use -y|--tstamp option. If timestamp is off, pktgen header is not
      included in the UDP payload. This means receiving side can use the magic
      number for pktgen for differentiation.
      
      The implementation supports both VLAN tagged and untagged option. By
      default, the minimum packet size is set at 64B. However, if VLAN tagged
      is on (-V), the minimum packet size is increased to 66B just so to fit
      the pktgen_hdr size.
      
      Added hex_dump() into the code path just for future cross-checking.
      As before, simply change to "#define DEBUG_HEXDUMP 1" to inspect the
      accuracy of TX packet.
      Signed-off-by: default avatarOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20211230035447.523177-8-boon.leong.ong@intel.com
      eb68db45
    • Ong Boon Leong's avatar
      samples/bpf: xdpsock: Add time-out for cleaning Tx · 8121e789
      Ong Boon Leong authored
      When user sets tx-pkt-count and in case where there are invalid Tx frame,
      the complete_tx_only_all() process polls indefinitely. So, this patch
      adds a time-out mechanism into the process so that the application
      can terminate automatically after it retries 3*polling interval duration.
      
      v1->v2:
       Thanks to Jesper's and Song Liu's suggestion.
       - clean-up git message to remove polling log
       - make the Tx time-out retries configurable with 1s granularity
      Signed-off-by: default avatarOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20211230035447.523177-7-boon.leong.ong@intel.com
      8121e789
    • Ong Boon Leong's avatar
      samples/bpf: xdpsock: Add sched policy and priority support · fa24d0b1
      Ong Boon Leong authored
      By default, TX schedule policy is SCHED_OTHER (round-robin time-sharing).
      To improve TX cyclic scheduling, we add SCHED_FIFO policy and its priority
      by using -W FIFO or --policy=FIFO and -U <PRIO> or --schpri=<PRIO>.
      
      A) From xdpsock --app-stats, for SCHED_OTHER policy:
         $ xdpsock -i eth0 -t -N -z -T 1000 -b 16 -C 100000 -a
      
                            period     min        ave        max        cycle
         Cyclic TX          1000000    53507      75334      712642     6250
      
      B) For SCHED_FIFO policy and schpri=50:
         $ xdpsock -i eth0 -t -N -z -T 1000 -b 16 -C 100000 -a -W FIFO -U 50
      
                            period     min        ave        max        cycle
         Cyclic TX          1000000    3699       24859      54397      6250
      Signed-off-by: default avatarOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20211230035447.523177-6-boon.leong.ong@intel.com
      fa24d0b1
    • Ong Boon Leong's avatar
      samples/bpf: xdpsock: Add cyclic TX operation capability · fa0d27a1
      Ong Boon Leong authored
      Tx cycle time is in micro-seconds unit. By combining the batch size (-b M)
      and Tx cycle time (-T|--tx-cycle N), xdpsock now can transmit batch-size of
      packets every N-us periodically. Cyclic TX operation is not applicable if
      --poll mode is used.
      
      To transmit 16 packets every 1ms cycle time for total of 100000 packets
      silently:
       $ xdpsock -i eth0 -T -N -z -T 1000 -b 16 -C 100000
      
      To print cyclic TX schedule variance stats, use --app-stats|-a:
       $ xdpsock -i eth0 -T -N -z -T 1000 -b 16 -C 100000 -a
      
       sock0@eth0:0 txonly xdp-drv
                         pps            pkts           0.00
      rx                 0              0
      tx                 0              100000
      
                         calls/s        count
      rx empty polls     0              0
      fill fail polls    0              0
      copy tx sendtos    0              0
      tx wakeup sendtos  0              6254
      opt polls          0              0
      
                         period     min        ave        max        cycle
      Cyclic TX          1000000    53507      75334      712642     6250
      Signed-off-by: default avatarOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20211230035447.523177-5-boon.leong.ong@intel.com
      fa0d27a1
    • Ong Boon Leong's avatar
      samples/bpf: xdpsock: Add clockid selection support · 5a388254
      Ong Boon Leong authored
      User specifies the clock selection by using -w CLOCK or --clock=CLOCK
      where CLOCK=[REALTIME, TAI, BOOTTIME, MONOTONIC].
      
      The default CLOCK selection is MONOTONIC.
      
      The implementation of clock selection parsing is borrowed from
      iproute2/tc/q_taprio.c
      Signed-off-by: default avatarOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20211230035447.523177-4-boon.leong.ong@intel.com
      5a388254
    • Ong Boon Leong's avatar
      samples/bpf: xdpsock: Add Dest and Src MAC setting for Tx-only operation · 6440a6c2
      Ong Boon Leong authored
      To set Dest MAC address (-G|--tx-dmac) only:
       $ xdpsock -i eth0 -t -N -z -G aa:bb:cc:dd:ee:ff
      
      To set Source MAC address (-H|--tx-smac) only:
       $ xdpsock -i eth0 -t -N -z -H 11:22:33:44:55:66
      
      To set both Dest and Source MAC address:
       $ xdpsock -i eth0 -t -N -z -G aa:bb:cc:dd:ee:ff \
         -H 11:22:33:44:55:66
      
      The default Dest and Source MAC address remain the same as before.
      Signed-off-by: default avatarOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Acked-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Link: https://lore.kernel.org/bpf/20211230035447.523177-3-boon.leong.ong@intel.com
      6440a6c2
    • Ong Boon Leong's avatar
      samples/bpf: xdpsock: Add VLAN support for Tx-only operation · 2741a049
      Ong Boon Leong authored
      In multi-queue environment testing, the support for VLAN-tag based
      steering is useful. So, this patch adds the capability to add
      VLAN tag (VLAN ID and Priority) to the generated Tx frame.
      
      To set the VLAN ID=10 and Priority=2 for Tx only through TxQ=3:
       $ xdpsock -i eth0 -t -N -z -q 3 -V -J 10 -K 2
      
      If VLAN ID (-J) and Priority (-K) is set, it default to
        VLAN ID = 1
        VLAN Priority = 0.
      
      For example, VLAN-tagged Tx only, xdp copy mode through TxQ=1:
       $ xdpsock -i eth0 -t -N -c -q 1 -V
      Signed-off-by: default avatarOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20211230035447.523177-2-boon.leong.ong@intel.com
      2741a049
    • Christy Lee's avatar
      libbpf 1.0: Deprecate bpf_object__find_map_by_offset() API · 5f608264
      Christy Lee authored
      API created with simplistic assumptions about BPF map definitions.
      It hasn’t worked for a while, deprecate it in preparation for
      libbpf 1.0.
      
        [0] Closes: https://github.com/libbpf/libbpf/issues/302Signed-off-by: default avatarChristy Lee <christylee@fb.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20220105003120.2222673-1-christylee@fb.com
      5f608264
    • Christy Lee's avatar
      libbpf 1.0: Deprecate bpf_map__is_offload_neutral() · 9855c131
      Christy Lee authored
      Deprecate bpf_map__is_offload_neutral(). It’s most probably broken
      already. PERF_EVENT_ARRAY isn’t the only map that’s not suitable
      for hardware offloading. Applications can directly check map type
      instead.
      
        [0] Closes: https://github.com/libbpf/libbpf/issues/306Signed-off-by: default avatarChristy Lee <christylee@fb.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20220105000601.2090044-1-christylee@fb.com
      9855c131
  2. 05 Jan, 2022 30 commits