Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

samples/pktgen: Add some helper functions

1. given a device, get its NUMA belongings
2. given a device, get its queues' irq numbers.
3. given a NUMA node, get its cpu id list.

Signed-off-by: Robert Hoo <robert.hu@intel.com>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Robert Hoo and committed by
David S. Miller
22ac5ad4 de218073

+43
+43
samples/pktgen/functions.sh
··· 119 119 err 4 "cannot perform sudo run of $0" 120 120 fi 121 121 } 122 + 123 + # Exact input device's NUMA node info 124 + function get_iface_node() 125 + { 126 + local node=$(</sys/class/net/$1/device/numa_node) 127 + if [[ $node == -1 ]]; then 128 + echo 0 129 + else 130 + echo $node 131 + fi 132 + } 133 + 134 + # Given an Dev/iface, get its queues' irq numbers 135 + function get_iface_irqs() 136 + { 137 + local IFACE=$1 138 + local queues="${IFACE}-.*TxRx" 139 + 140 + irqs=$(grep "$queues" /proc/interrupts | cut -f1 -d:) 141 + [ -z "$irqs" ] && irqs=$(grep $IFACE /proc/interrupts | cut -f1 -d:) 142 + [ -z "$irqs" ] && irqs=$(for i in `ls -Ux /sys/class/net/$IFACE/device/msi_irqs` ;\ 143 + do grep "$i:.*TxRx" /proc/interrupts | grep -v fdir | cut -f 1 -d : ;\ 144 + done) 145 + [ -z "$irqs" ] && err 3 "Could not find interrupts for $IFACE" 146 + 147 + echo $irqs 148 + } 149 + 150 + # Given a NUMA node, return cpu ids belonging to it. 151 + function get_node_cpus() 152 + { 153 + local node=$1 154 + local node_cpu_list 155 + local node_cpu_range_list=`cut -f1- -d, --output-delimiter=" " \ 156 + /sys/devices/system/node/node$node/cpulist` 157 + 158 + for cpu_range in $node_cpu_range_list 159 + do 160 + node_cpu_list="$node_cpu_list "`seq -s " " ${cpu_range//-/ }` 161 + done 162 + 163 + echo $node_cpu_list 164 + }