• Alexei Starovoitov's avatar
    pktgen: introduce xmit_mode '<start_xmit|netif_receive>' · 62f64aed
    Alexei Starovoitov authored
    Introduce xmit_mode 'netif_receive' for pktgen which generates the
    packets using familiar pktgen commands, but feeds them into
    netif_receive_skb() instead of ndo_start_xmit().
    
    Default mode is called 'start_xmit'.
    
    It is designed to test netif_receive_skb and ingress qdisc
    performace only. Make sure to understand how it works before
    using it for other rx benchmarking.
    
    Sample script 'pktgen.sh':
    \#!/bin/bash
    function pgset() {
      local result
    
      echo $1 > $PGDEV
    
      result=`cat $PGDEV | fgrep "Result: OK:"`
      if [ "$result" = "" ]; then
        cat $PGDEV | fgrep Result:
      fi
    }
    
    [ -z "$1" ] && echo "Usage: $0 DEV" && exit 1
    ETH=$1
    
    PGDEV=/proc/net/pktgen/kpktgend_0
    pgset "rem_device_all"
    pgset "add_device $ETH"
    
    PGDEV=/proc/net/pktgen/$ETH
    pgset "xmit_mode netif_receive"
    pgset "pkt_size 60"
    pgset "dst 198.18.0.1"
    pgset "dst_mac 90:e2:ba:ff:ff:ff"
    pgset "count 10000000"
    pgset "burst 32"
    
    PGDEV=/proc/net/pktgen/pgctrl
    echo "Running... ctrl^C to stop"
    pgset "start"
    echo "Done"
    cat /proc/net/pktgen/$ETH
    
    Usage:
    $ sudo ./pktgen.sh eth2
    ...
    Result: OK: 232376(c232372+d3) usec, 10000000 (60byte,0frags)
      43033682pps 20656Mb/sec (20656167360bps) errors: 10000000
    
    Raw netif_receive_skb speed should be ~43 million packet
    per second on 3.7Ghz x86 and 'perf report' should look like:
      37.69%  kpktgend_0   [kernel.vmlinux]  [k] __netif_receive_skb_core
      25.81%  kpktgend_0   [kernel.vmlinux]  [k] kfree_skb
       7.22%  kpktgend_0   [kernel.vmlinux]  [k] ip_rcv
       5.68%  kpktgend_0   [pktgen]          [k] pktgen_thread_worker
    
    If fib_table_lookup is seen on top, it means skb was processed
    by the stack. To benchmark netif_receive_skb only make sure
    that 'dst_mac' of your pktgen script is different from
    receiving device mac and it will be dropped by ip_rcv
    Signed-off-by: default avatarAlexei Starovoitov <ast@plumgrid.com>
    Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    62f64aed
pktgen.c 96.7 KB