• Jesper Dangaard Brouer's avatar
    samples/bpf: add cpumap sample program xdp_redirect_cpu · fad3917e
    Jesper Dangaard Brouer authored
    
    
    This sample program show how to use cpumap and the associated
    tracepoints.
    
    It provides command line stats, which shows how the XDP-RX process,
    cpumap-enqueue and cpumap kthread dequeue is cooperating on a per CPU
    basis.  It also utilize the xdp_exception and xdp_redirect_err
    transpoints to allow users quickly to identify setup issues.
    
    One issue with ixgbe driver is that the driver reset the link when
    loading XDP.  This reset the procfs smp_affinity settings.  Thus,
    after loading the program, these must be reconfigured.  The easiest
    workaround it to reduce the RX-queue to e.g. two via:
    
     # ethtool --set-channels ixgbe1 combined 2
    
    And then add CPUs above 0 and 1, like:
    
     # xdp_redirect_cpu --dev ixgbe1 --prog 2 --cpu 2 --cpu 3 --cpu 4
    
    Another issue with ixgbe is that the page recycle mechanism is tied to
    the RX-ring size.  And the default setting of 512 elements is too
    small.  This is the same issue with regular devmap XDP_REDIRECT.
    To overcome this I've been using 1024 rx-ring size:
    
     # ethtool -G ixgbe1 rx 1024 tx 1024
    
    V3:
     - whitespace cleanups
     - bpf tracepoint cannot access top part of struct
    
    V4:
     - report on kthread sched events, according to tracepoint change
     - report average bulk enqueue size
    
    V5:
     - bpf_map_lookup_elem on cpumap not allowed from bpf_prog
       use separate map to mark CPUs not available
    
    V6:
     - correct kthread sched summary output
    
    V7:
     - Added a --stress-mode for concurrently changing underlying cpumap
    
    Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    fad3917e