From 864906c888eeb83dfc4063033d44801114a45426 Mon Sep 17 00:00:00 2001 From: Bob Gilligan Date: Wed, 20 May 2009 16:13:34 -0700 Subject: Bugfix 4427: Handle multiqueue NICs. Added code to deal with NICs that utilize more than one IRQ. The "set" sub-command of this script will now assign the requested affinity mask to all IRQs that are associated with the NIC. --- scripts/vyatta-irqaffin | 59 ++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-irqaffin b/scripts/vyatta-irqaffin index 1959a30..bdbc541 100755 --- a/scripts/vyatta-irqaffin +++ b/scripts/vyatta-irqaffin @@ -21,14 +21,18 @@ # Provides sub-commands to: # - Check the validity of an interface name and affinity mask value -# - Set the affinity mask to the IRQ being used by an interface -# - Reset the affinity mask of the IRQ being used by an interface to the +# - Set the affinity mask to the IRQs being used by an interface +# - Reset the affinity mask of the IRQs being used by an interface to the # system default value of all-ones. -# - Print the affinity mask of the IRQ being used by an interface +# - Print the affinity mask of the IRQs being used by an interface +# +# If the NIC in question supports multiple IRQs, the "set" sub-command +# sets all IRQs to the same mask. The "print" sub-command displays +# the mask of each IRQ individually. # -# Max number of hex characters in an IRQ affinity mask. Support up to 16 CPUs. -MAX_MASK=4 +# Max number of hex characters in an IRQ affinity mask. Support up to 64 CPUs. +MAX_MASK=16 # Set up some global values... numcpus=`grep -c -e "^processor" /proc/cpuinfo` @@ -45,10 +49,10 @@ print_usage() echo -e "\t$0 print " } -get_irqnum() +get_irqnums() { - irqnum=`cat /sys/class/net/$1/device/irq` - if [ -z "$irqnum" ]; then + irqnums=`grep $1 /proc/interrupts | awk -F ': ' '{ print $1 }'` + if [ -z "$irqnums" ]; then echo "Invalid interface name: $1" return 1 fi @@ -118,7 +122,7 @@ case "$1" in exit 1 fi - if ! get_irqnum $2 ; then + if ! get_irqnums $2 ; then exit 1 fi @@ -138,7 +142,7 @@ case "$1" in exit 1 fi - if ! get_irqnum $2 ; then + if ! get_irqnums $2 ; then exit 1 fi @@ -146,7 +150,9 @@ case "$1" in exit 1 fi - echo $mask > /proc/irq/$irqnum/smp_affinity + for irqnum in $irqnums ; do + echo $mask > /proc/irq/$irqnum/smp_affinity + done if [ $? -ne 0 ]; then echo "Couldn't assign smp_affinity. Exit status: $?" @@ -159,15 +165,17 @@ case "$1" in print_usage exit 1 fi - if ! get_irqnum $2 ; then + if ! get_irqnums $2 ; then exit 1 fi - echo $maxmaskhex > /proc/irq/$irqnum/smp_affinity - if [ $? -ne 0 ]; then - echo "Couldn't assign smp_affinity. Exit status: $?" - exit 1 - fi + for irqnum in $irqnums ; do + echo $maxmaskhex > /proc/irq/$irqnum/smp_affinity + if [ $? -ne 0 ]; then + echo "Couldn't assign smp_affinity for IRQ $irqnum. Exit status: $?" + exit 1 + fi + done ;; @@ -176,19 +184,20 @@ case "$1" in print_usage exit 1 fi - if ! get_irqnum $2 ; then + if ! get_irqnums $2 ; then exit 1 fi - mask=`cat /proc/irq/$irqnum/smp_affinity` + for irqnum in $irqnums ; do + mask=`cat /proc/irq/$irqnum/smp_affinity` - if [ -z $mask ]; then - echo "Couldn't get smp_affinity for interface $2, irq $irqnum" - exit 1 - fi + if [ -z $mask ]; then + echo "Couldn't get smp_affinity for interface $2, irq $irqnum" + exit 1 + fi - echo "Interface $2 is using IRQ: $irqnum" - echo "SMP affinity mask for IRQ $irqnum is: $mask" + echo "Interface: $2 IRQ: $irqnum Mask: $mask" + done ;; *) -- cgit v1.2.3 From c6277542e164fbb9b5618f8351f3aafc0c031f99 Mon Sep 17 00:00:00 2001 From: Bob Gilligan Date: Wed, 20 May 2009 16:40:28 -0700 Subject: Use the default_smp_affinity /proc file if it is available. --- scripts/vyatta-irqaffin | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyatta-irqaffin b/scripts/vyatta-irqaffin index bdbc541..1286130 100755 --- a/scripts/vyatta-irqaffin +++ b/scripts/vyatta-irqaffin @@ -169,8 +169,14 @@ case "$1" in exit 1 fi + if [ -e /proc/irq/default_smp_affinity ]; then + defmask=`cat /proc/irq/default_smp_affinity` + else + defmask=$maxmaskhex + fi + for irqnum in $irqnums ; do - echo $maxmaskhex > /proc/irq/$irqnum/smp_affinity + echo $defmask > /proc/irq/$irqnum/smp_affinity if [ $? -ne 0 ]; then echo "Couldn't assign smp_affinity for IRQ $irqnum. Exit status: $?" exit 1 -- cgit v1.2.3 From 6ece71ecf691431006ae1389f9ab575a1a39683e Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 21 May 2009 10:36:47 -0700 Subject: Add script option to check if interface is up Better than reading sysfs directly. --- scripts/vyatta-interfaces.pl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index d0d8fa1..3e5beaa 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -48,7 +48,8 @@ use warnings; my $dhcp_daemon = '/sbin/dhclient'; my ($eth_update, $eth_delete, $addr, $dev, $mac, $mac_update, $op_dhclient); -my ($check_name, $show_names, $intf_cli_path, $vif_name, $warn_name, $show_path); +my ($check_name, $show_names, $intf_cli_path, $vif_name, $warn_name); +my ($check_up, $show_path); sub usage { print "Usage: $0 --dev= --check=\n"; @@ -58,6 +59,7 @@ sub usage { print " $0 --dev= --eth-addr-delete=\n"; print " $0 --dev= --valid-addr={|dhcp}\n"; print " $0 --dev= --path\n"; + print " $0 --dev= --isup\n"; print " $0 --show=\n"; exit 1; } @@ -74,6 +76,7 @@ GetOptions("eth-addr-update=s" => \$eth_update, "vif=s" => \$vif_name, "warn" => \$warn_name, "path" => \$show_path, + "isup" => \$check_up, ) or usage(); update_eth_addrs($eth_update, $dev) if ($eth_update); @@ -86,6 +89,7 @@ is_valid_name($check_name, $dev) if ($check_name); exists_name($dev) if ($warn_name); show_interfaces($show_names) if ($show_names); show_config_path($dev) if ($show_path); +is_up($dev) if ($check_up); exit 0; sub is_ip_configured { @@ -106,6 +110,16 @@ sub is_ip_duplicate { return is_ip_configured($intf, $ip); } +sub is_up { + my $name = shift; + my $intf = new Vyatta::Interface($name); + + die "Unknown interface type for $name" unless $intf; + + exit 0 if ($intf->up()); + exit 1; +} + sub touch { my $file = shift; my $t = time; -- cgit v1.2.3 From 613b7e3b36684e92cb7765b03bb4706a6caed98b Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Thu, 21 May 2009 14:07:43 -0700 Subject: add "discard" command to cmd wrapper --- scripts/vyatta-cfg-cmd-wrapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyatta-cfg-cmd-wrapper b/scripts/vyatta-cfg-cmd-wrapper index cf10fc5..d1b70d5 100755 --- a/scripts/vyatta-cfg-cmd-wrapper +++ b/scripts/vyatta-cfg-cmd-wrapper @@ -66,7 +66,7 @@ case "$1" in rm -rf ${VYATTA_CONFIG_TMP} rm -rf ${VYATTA_TEMP_CONFIG_DIR} ;; - cleanup) + cleanup|discard) sudo umount ${VYATTA_TEMP_CONFIG_DIR} rm -rf $VYATTA_CHANGES_ONLY_DIR/* $VYATTA_CHANGES_ONLY_DIR/.modified sudo mount -t $UNIONFS -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:${VYATTA_ACTIVE_CONFIGURATION_DIR}=ro $UNIONFS ${VYATTA_TEMP_CONFIG_DIR} -- cgit v1.2.3