From: Michael Tremer Date: Wed, 7 Jun 2017 18:10:16 +0000 (+0200) Subject: device: Show queue status X-Git-Tag: 009~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6529dfaa1da69782553848f60242ac43679ca357;p=network.git device: Show queue status Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.cli b/src/functions/functions.cli index b5b164d7..a4690b23 100644 --- a/src/functions/functions.cli +++ b/src/functions/functions.cli @@ -242,6 +242,33 @@ cli_device_bonding() { cli_space } +cli_device_show_queues() { + assert [ $# -eq 2 ] + + local level=${1} + local device=${2} + + cli_headline ${level} "Queues" + cli_print_fmt1 ${level} "Queue" "Processors" + + local processors=$(system_get_processors) + + local queue + for queue in $(device_get_queues ${device}); do + local smp_affinity=$(device_queue_get_smp_affinity ${device} ${queue}) + + local processor s="" + for (( processor = 0; processor < ${processors}; processor++ )); do + if ! isset smp_affinity || list_match ${processor} ${smp_affinity}; then + list_append s ${processor} + fi + done + + cli_print_fmt1 ${level} "${queue}" "$(list_join s ", ")" + done + cli_space +} + cli_headline() { local level=${1} local format=${2} diff --git a/src/functions/functions.device b/src/functions/functions.device index 98bdc71a..32108bb0 100644 --- a/src/functions/functions.device +++ b/src/functions/functions.device @@ -989,6 +989,56 @@ device_get_queues() { done } +device_supports_multiqueue() { + local device=${1} + + local num_queues=$(device_num_queues ${device}) + + if isset num_queues && [ ${num_queues} -gt 2 ]; then + return ${EXIT_TRUE} + fi + + return ${EXIT_FALSE} +} + +device_num_queues() { + local device=${1} + local type=${2} + + assert isoneof type "" rx tx + + local i=0 + + local q + for q in $(device_get_queues ${device}); do + case "${type},${q}" in + rx,rx-*) + (( i++ )) + ;; + tx,tx-*) + (( i++ )) + ;; + *,*) + (( i++ )) + ;; + esac + done + + print ${i} +} + +device_queue_get_smp_affinity() { + assert [ $# -eq 2 ] + + local device=${1} + local queue=${2} + + local path="${SYS_CLASS_NET}/${device}/queues/${queue}/rps_cpus" + assert [ -r "${path}" ] + + __bitmap_to_processor_ids $(<${path}) +} + device_queue_set_smp_affinity() { assert [ $# -eq 3 ] diff --git a/src/network b/src/network index e1934b85..e0d57a04 100644 --- a/src/network +++ b/src/network @@ -175,8 +175,15 @@ cli_device_status() { device_is_promisc ${device} &>/dev/null cli_print_fmt1 1 "Promisc" "$(cli_print_bool $?)" + + # Supports multiqueue? + if device_supports_multiqueue ${device}; then + cli_print_fmt 1 "Multiqueue" "Supported" + fi cli_space + cli_device_show_queues 2 ${device} + # Print all vlan devices. local vlans=$(device_get_vlans ${device}) if [ -n "${vlans}" ]; then