znet: Move functionality from znetcontrolunits to lsznet

lsznet sources znetcontrolunits to use search_cu() and set the variable
cu_idx. lsznet's own function search_cu_tcpip() is doing the same thing
as search_cu() without setting cu_idx.

Declare and move cu_idx to the global variable CU_IDX and consolidate
the functions by letting search_cu_tcpip() set CU_IDX. Call
search_cu_tcpip() instead of search_cu() and replace cu_idx with CU_IDX
accordingly. search_cu() is removed and the CU_DEVDRV array is moved to
lsznet.

Reviewed-by: Aswin Karuvally <aswin@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Jan Höppner
2026-02-25 18:38:24 +01:00
parent c81ca8f01b
commit d41d968792
2 changed files with 18 additions and 30 deletions

View File

@@ -55,6 +55,17 @@ readonly -a CU_DEVNAME=(
eth
)
readonly -a CU_DEVDRV=(
qeth
qeth
ctcm
ctcm
ctcm
lcs
qeth
qeth
)
readonly -a CU_GROUPCHANNELS=(
3
3
@@ -93,6 +104,7 @@ readonly SSIDFORMAT=[0-3]
readonly BUSIDFORMAT=[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]
readonly IDFORMAT=$PREFIXFORMAT.$SSIDFORMAT.$BUSIDFORMAT
readonly SUBCHANNEL_TYPE_IO=0
declare CU_IDX
function debug() {
level=$1
@@ -100,13 +112,15 @@ function debug() {
[ $DEBUG -ge $level ] && echo "$*" 1>&2
}
# Searches for a match of argument 1 on the array $CU_TCPIP.
# Searches for a match of argument 1 on the array $CU_TCPIP and sets $CU_IDX to
# the matched array index on success.
# Returns 0 on success, 1 on failure.
function search_cu_tcpip() {
local scu=$1
local i
for ((i = 0; i < ${#CU_TCPIP[@]}; i++)); do
if [ "$scu" == "${CU_TCPIP[i]}" ]; then
CU_IDX=$i
return 0
fi
done
@@ -220,14 +234,14 @@ function build_list() {
if [ -z "$all" ] && ! search_cu_tcpip $cutype; then
continue
fi
if search_cu $cutype; then
if [ "${CU_DEVDRV[$cu_idx]}" == "ctcm" ]; then
if search_cu_tcpip $cutype; then
if [ "${CU_DEVDRV[$CU_IDX]}" == "ctcm" ]; then
# assume CTC are mostly virtual and ignore chpid from sysfs
chpidtype_symbolic="-"
else
search_chpt $chptype
fi
echo $pimchpids $devbusid $cutype $chpidtype_symbolic ${CU_DEVDRV[$cu_idx]} ${CU_DEVNAME[$cu_idx]} ${CU_GROUPCHANNELS[$cu_idx]} ${CU_CARDTYPE[$cu_idx]}
echo $pimchpids $devbusid $cutype $chpidtype_symbolic ${CU_DEVDRV[$CU_IDX]} ${CU_DEVNAME[$cu_idx]} ${CU_GROUPCHANNELS[$cu_idx]} ${CU_CARDTYPE[$cu_idx]}
else
debug 5 " skip non-network device $devbusid CU $cutype"
fi

View File

@@ -26,29 +26,3 @@ readonly -a CU=(
1731/02
)
# 1731/06 (OSN) is no longer supported
readonly -a CU_DEVDRV=(
qeth
qeth
ctcm
ctcm
ctcm
lcs
qeth
qeth
)
# Searches for a match of argument 1 on the array $CU and sets $cu_idx
# to the matched array index on success.
# Returns 0 on success, 1 on failure.
function search_cu() {
local scu=$1
local i
for ((i=0; i < ${#CU[@]}; i++)); do
if [ "$scu" == "${CU[i]}" ]; then
cu_idx=$i
return 0
fi
done
return 1
}