brintos

brintos / linux-shallow public Read only

0
0
Text · 2.5 KiB · f2beb51 Raw
94 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03#4# Benchmark script:5#  - developed for benchmarking egress qdisc path, derived (more6#    like cut'n'pasted) from ingress benchmark script.7#8# Script for injecting packets into egress qdisc path of the stack9# with pktgen "xmit_mode queue_xmit".10#11basedir=`dirname $0`12source ${basedir}/functions.sh13root_check_run_with_sudo "$@"14 15# Parameter parsing via include16source ${basedir}/parameters.sh17 18# Trap EXIT first19trap_exit20 21if [ -z "$DEST_IP" ]; then22    [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"23fi24[ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"25 26# Burst greater than 1 are invalid for queue_xmit mode27if [[ -n "$BURST" ]]; then28    err 1 "Bursting not supported for this mode"29fi30[ -z "$COUNT" ] && COUNT="10000000" # Zero means indefinitely31if [ -n "$DEST_IP" ]; then32    validate_addr${IP6} $DEST_IP33    read -r DST_MIN DST_MAX <<< $(parse_addr${IP6} $DEST_IP)34fi35if [ -n "$DST_PORT" ]; then36    read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)37    validate_ports $UDP_DST_MIN $UDP_DST_MAX38fi39 40# General cleanup everything since last run41pg_ctrl "reset"42 43# Threads are specified with parameter -t value in $THREADS44for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do45    # The device name is extended with @name, using thread number to46    # make then unique, but any name will do.47    dev=${DEV}@${thread}48 49    # Add remove all other devices and add_device $dev to thread50    pg_thread $thread "rem_device_all"51    pg_thread $thread "add_device" $dev52 53    # Base config of dev54    pg_set $dev "flag QUEUE_MAP_CPU"55    pg_set $dev "count $COUNT"56    pg_set $dev "pkt_size $PKT_SIZE"57    pg_set $dev "delay $DELAY"58    pg_set $dev "flag NO_TIMESTAMP"59 60    # Destination61    pg_set $dev "dst_mac $DST_MAC"62    pg_set $dev "dst${IP6}_min $DST_MIN"63    pg_set $dev "dst${IP6}_max $DST_MAX"64 65    if [ -n "$DST_PORT" ]; then66	# Single destination port or random port range67	pg_set $dev "flag UDPDST_RND"68	pg_set $dev "udp_dst_min $UDP_DST_MIN"69	pg_set $dev "udp_dst_max $UDP_DST_MAX"70    fi71 72    # Inject packet into TX qdisc egress path of stack73    pg_set $dev "xmit_mode queue_xmit"74done75 76# Run if user hits control-c77function print_result {78    # Print results79    for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do80        dev=${DEV}@${thread}81        echo "Device: $dev"82        cat /proc/net/pktgen/$dev | grep -A2 "Result:"83    done84}85# trap keyboard interrupt (Ctrl-C)86trap true SIGINT87 88# start_run89echo "Running... ctrl^C to stop" >&290pg_ctrl "start"91echo "Done" >&292 93print_result94