]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blame - samples/pktgen/pktgen_sample04_many_flows.sh
Merge tag 'dax-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
[mirror_ubuntu-focal-kernel.git] / samples / pktgen / pktgen_sample04_many_flows.sh
CommitLineData
15f2cbbd 1#!/bin/bash
b2441318 2# SPDX-License-Identifier: GPL-2.0
15f2cbbd
JDB
3#
4# Script example for many flows testing
5#
6# Number of simultaneous flows limited by variable $FLOWS
7# and number of packets per flow controlled by variable $FLOWLEN
8#
9basedir=`dirname $0`
10source ${basedir}/functions.sh
11root_check_run_with_sudo "$@"
12
13# Parameter parsing via include
14source ${basedir}/parameters.sh
15# Set some default params, if they didn't get set
16[ -z "$DEST_IP" ] && DEST_IP="198.18.0.42"
17[ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
18[ -z "$CLONE_SKB" ] && CLONE_SKB="0"
69137ea6 19[ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely
6e32a74a
DL
20if [ -n "$DST_PORT" ]; then
21 read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT)
22 validate_ports $DST_MIN $DST_MAX
23fi
15f2cbbd
JDB
24
25# NOTICE: Script specific settings
26# =======
27# Limiting the number of concurrent flows ($FLOWS)
28# and also set how many packets each flow contains ($FLOWLEN)
29#
30[ -z "$FLOWS" ] && FLOWS="8000"
31[ -z "$FLOWLEN" ] && FLOWLEN="10"
32
33# Base Config
34DELAY="0" # Zero means max speed
15f2cbbd
JDB
35
36if [[ -n "$BURST" ]]; then
37 err 1 "Bursting not supported for this mode"
38fi
39
40# General cleanup everything since last run
41pg_ctrl "reset"
42
43# Threads are specified with parameter -t value in $THREADS
e0e16672 44for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
15f2cbbd
JDB
45 dev=${DEV}@${thread}
46
47 # Add remove all other devices and add_device $dev to thread
48 pg_thread $thread "rem_device_all"
49 pg_thread $thread "add_device" $dev
50
51 # Base config
52 pg_set $dev "flag QUEUE_MAP_CPU"
53 pg_set $dev "count $COUNT"
54 pg_set $dev "clone_skb $CLONE_SKB"
55 pg_set $dev "pkt_size $PKT_SIZE"
56 pg_set $dev "delay $DELAY"
57 pg_set $dev "flag NO_TIMESTAMP"
58
59 # Single destination
60 pg_set $dev "dst_mac $DST_MAC"
61 pg_set $dev "dst $DEST_IP"
62
6e32a74a
DL
63 if [ -n "$DST_PORT" ]; then
64 # Single destination port or random port range
65 pg_set $dev "flag UDPDST_RND"
66 pg_set $dev "udp_dst_min $DST_MIN"
67 pg_set $dev "udp_dst_max $DST_MAX"
68 fi
69
15f2cbbd
JDB
70 # Randomize source IP-addresses
71 pg_set $dev "flag IPSRC_RND"
72 pg_set $dev "src_min 198.18.0.0"
73 pg_set $dev "src_max 198.19.255.255"
74
75 # Limit number of flows (max 65535)
76 pg_set $dev "flows $FLOWS"
77 #
78 # How many packets a flow will send, before flow "entry" is
79 # re-generated/setup.
80 pg_set $dev "flowlen $FLOWLEN"
81 #
82 # Flag FLOW_SEQ will cause $FLOWLEN packets from the same flow
83 # being send back-to-back, before next flow is selected
84 # incrementally. This helps lookup caches, and is more realistic.
85 #
86 pg_set $dev "flag FLOW_SEQ"
87
88done
89
90# Run if user hits control-c
91function print_result() {
92 # Print results
e0e16672 93 for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
15f2cbbd
JDB
94 dev=${DEV}@${thread}
95 echo "Device: $dev"
96 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
97 done
98}
99# trap keyboard interrupt (Ctrl-C)
100trap true SIGINT
101
102echo "Running... ctrl^C to stop" >&2
103pg_ctrl "start"
104
105print_result