Commit e99cfdb6 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

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: default avatarMichal Berger <michalx.berger@intel.com>
Change-Id: Idefa39c4a62c9e650a03e237f49940461e9782a6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6992


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 132d80be
Loading
Loading
Loading
Loading
+25 −10
Original line number Diff line number Diff line
@@ -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
}

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_devices
collect_net_devices
collect_rxe_devices

case "${1:-status}" in
	start)