From e99cfdb6c95f71a3cc2791cefc88e641f1329b9c Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Mon, 22 Mar 2021 12:59:05 +0100 Subject: [PATCH] scripts/rxe_cfg: Split collect_devices() collect_devices() is split into two functions: - collect_net_devices(): Collect ethernet net devs from the net class. - collect_rxe_devices(): Collect all rxe devices from the infiniband class. This is done in order to make handling of some conditions easier. Case and point, in newer kernels, device/net link is not anymore created for the soft roce devices, instead only ./parent attribute is available. collect_rxe_devices() is adjusted to handle such a condition. Signed-off-by: Michal Berger Change-Id: Idefa39c4a62c9e650a03e237f49940461e9782a6 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6992 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Karol Latecki Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki --- scripts/rxe_cfg_small.sh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/scripts/rxe_cfg_small.sh b/scripts/rxe_cfg_small.sh index 0b4d5760f..facb927a6 100755 --- a/scripts/rxe_cfg_small.sh +++ b/scripts/rxe_cfg_small.sh @@ -251,23 +251,38 @@ link_up() { echo $(($(< "$net/$1/flags") | 0x1)) > "$net/$1/flags" } -collect_devices() { - local net_dev rxe_dev +collect_net_devices() { + local net_dev for net_dev in "$net/"!(bonding_masters); do (($(< "$net_dev/type") != 1)) && continue net_devices["${net_dev##*/}"]=$net_dev - for rxe_dev in "$infiniband/"*; do - if [[ -e $rxe_dev/device/net/${net_dev##*/} ]]; then - net_to_rxe["${net_dev##*/}"]=${rxe_dev##*/} - rxe_to_net["${rxe_dev##*/}"]=${net_dev##*/} - continue 2 - fi - done done } -collect_devices +collect_rxe_devices() { + local rxe_dev net_dev + + for rxe_dev in "$infiniband/"*; do + if [[ -e $rxe_dev/parent ]]; then + # Soft + net_dev=$(< "$rxe_dev/parent") + elif [[ -e $rxe_dev/device/net ]]; then + # HW + net_dev=$(readlink -f "$rxe_dev/device/net/"*) + net_dev=${net_dev##*/} + else + continue + fi 2> /dev/null + + [[ -n ${net_devices["$net_dev"]} ]] || continue + net_to_rxe["$net_dev"]=${rxe_dev##*/} + rxe_to_net["${rxe_dev##*/}"]=$net_dev + done +} + +collect_net_devices +collect_rxe_devices case "${1:-status}" in start)