Path: blob/master/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh
26292 views
#!/bin/bash1# SPDX-License-Identifier: GPL-2.02#3# Benchmark script:4# - developed for benchmarking egress qdisc path, derived (more5# like cut'n'pasted) from ingress benchmark script.6#7# Script for injecting packets into egress qdisc path of the stack8# with pktgen "xmit_mode queue_xmit".9#10basedir=`dirname $0`11source ${basedir}/functions.sh12root_check_run_with_sudo "$@"1314# Parameter parsing via include15source ${basedir}/parameters.sh1617# Trap EXIT first18trap_exit1920if [ -z "$DEST_IP" ]; then21[ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"22fi23[ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"2425# Burst greater than 1 are invalid for queue_xmit mode26if [[ -n "$BURST" ]]; then27err 1 "Bursting not supported for this mode"28fi29[ -z "$COUNT" ] && COUNT="10000000" # Zero means indefinitely30if [ -n "$DEST_IP" ]; then31validate_addr${IP6} $DEST_IP32read -r DST_MIN DST_MAX <<< $(parse_addr${IP6} $DEST_IP)33fi34if [ -n "$DST_PORT" ]; then35read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)36validate_ports $UDP_DST_MIN $UDP_DST_MAX37fi3839# General cleanup everything since last run40pg_ctrl "reset"4142# Threads are specified with parameter -t value in $THREADS43for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do44# The device name is extended with @name, using thread number to45# make then unique, but any name will do.46dev=${DEV}@${thread}4748# Add remove all other devices and add_device $dev to thread49pg_thread $thread "rem_device_all"50pg_thread $thread "add_device" $dev5152# Base config of dev53pg_set $dev "flag QUEUE_MAP_CPU"54pg_set $dev "count $COUNT"55pg_set $dev "pkt_size $PKT_SIZE"56pg_set $dev "delay $DELAY"57pg_set $dev "flag NO_TIMESTAMP"5859# Destination60pg_set $dev "dst_mac $DST_MAC"61pg_set $dev "dst${IP6}_min $DST_MIN"62pg_set $dev "dst${IP6}_max $DST_MAX"6364if [ -n "$DST_PORT" ]; then65# Single destination port or random port range66pg_set $dev "flag UDPDST_RND"67pg_set $dev "udp_dst_min $UDP_DST_MIN"68pg_set $dev "udp_dst_max $UDP_DST_MAX"69fi7071# Inject packet into TX qdisc egress path of stack72pg_set $dev "xmit_mode queue_xmit"73done7475# Run if user hits control-c76function print_result {77# Print results78for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do79dev=${DEV}@${thread}80echo "Device: $dev"81cat /proc/net/pktgen/$dev | grep -A2 "Result:"82done83}84# trap keyboard interrupt (Ctrl-C)85trap true SIGINT8687# start_run88echo "Running... ctrl^C to stop" >&289pg_ctrl "start"90echo "Done" >&29192print_result939495