pktgen_bench_xmit_mode_netif_receive.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/bash
  2. #
  3. # Benchmark script:
  4. # - developed for benchmarking ingress qdisc path
  5. #
  6. # Script for injecting packets into RX path of the stack with pktgen
  7. # "xmit_mode netif_receive". With an invalid dst_mac this will only
  8. # measure the ingress code path as packets gets dropped in ip_rcv().
  9. #
  10. # This script don't really need any hardware. It benchmarks software
  11. # RX path just after NIC driver level. With bursting is also
  12. # "removes" the SKB alloc/free overhead.
  13. #
  14. # Setup scenarios for measuring ingress qdisc (with invalid dst_mac):
  15. # ------------------------------------------------------------------
  16. # (1) no ingress (uses static_key_false(&ingress_needed))
  17. #
  18. # (2) ingress on other dev (change ingress_needed and calls
  19. # handle_ing() but exit early)
  20. #
  21. # config: tc qdisc add dev $SOMEDEV handle ffff: ingress
  22. #
  23. # (3) ingress on this dev, handle_ing() -> tc_classify()
  24. #
  25. # config: tc qdisc add dev $DEV handle ffff: ingress
  26. #
  27. # (4) ingress on this dev + drop at u32 classifier/action.
  28. #
  29. basedir=`dirname $0`
  30. source ${basedir}/functions.sh
  31. root_check_run_with_sudo "$@"
  32. # Parameter parsing via include
  33. source ${basedir}/parameters.sh
  34. # Using invalid DST_MAC will cause the packets to get dropped in
  35. # ip_rcv() which is part of the test
  36. if [ -z "$DEST_IP" ]; then
  37. [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
  38. fi
  39. [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
  40. [ -z "$BURST" ] && BURST=1024
  41. # Base Config
  42. DELAY="0" # Zero means max speed
  43. COUNT="10000000" # Zero means indefinitely
  44. # General cleanup everything since last run
  45. pg_ctrl "reset"
  46. # Threads are specified with parameter -t value in $THREADS
  47. for ((thread = 0; thread < $THREADS; thread++)); do
  48. # The device name is extended with @name, using thread number to
  49. # make then unique, but any name will do.
  50. dev=${DEV}@${thread}
  51. # Add remove all other devices and add_device $dev to thread
  52. pg_thread $thread "rem_device_all"
  53. pg_thread $thread "add_device" $dev
  54. # Base config of dev
  55. pg_set $dev "flag QUEUE_MAP_CPU"
  56. pg_set $dev "count $COUNT"
  57. pg_set $dev "pkt_size $PKT_SIZE"
  58. pg_set $dev "delay $DELAY"
  59. pg_set $dev "flag NO_TIMESTAMP"
  60. # Destination
  61. pg_set $dev "dst_mac $DST_MAC"
  62. pg_set $dev "dst$IP6 $DEST_IP"
  63. # Inject packet into RX path of stack
  64. pg_set $dev "xmit_mode netif_receive"
  65. # Burst allow us to avoid measuring SKB alloc/free overhead
  66. pg_set $dev "burst $BURST"
  67. done
  68. # start_run
  69. echo "Running... ctrl^C to stop" >&2
  70. pg_ctrl "start"
  71. echo "Done" >&2
  72. # Print results
  73. for ((thread = 0; thread < $THREADS; thread++)); do
  74. dev=${DEV}@${thread}
  75. echo "Device: $dev"
  76. cat /proc/net/pktgen/$dev | grep -A2 "Result:"
  77. done