smc-tools: smc_rnics is not listing the NetH/NetD cards inside the guest

Resolves: RHEL-159089

Signed-off-by: Čestmír Kalina <ckalina@redhat.com>
This commit is contained in:
Čestmír Kalina 2026-06-23 18:21:35 +02:00
parent f0b7392ecd
commit 3fae52deba
6 changed files with 455 additions and 1 deletions

88
1-0b965ae9b5ad.patch Normal file
View File

@ -0,0 +1,88 @@
commit 0b965ae9b5ad1725c8a86073a594d62925031a0e
Author: Sidraya Jayagond <sidraya@linux.ibm.com>
Date: Fri Jun 27 07:39:26 2025 +0200
smc_rnics: Add support for Network Express RNIC in smc_rnics
Add support for the Network Express RDMA-capable NIC in smc_rnics,
identified by its PCI Function Type (PFT).
Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com>
Signed-off-by: Sidraya Jayagond <sidraya@linux.ibm.com>
diff --git a/smc_rnics b/smc_rnics
index db9fde7..c5d086e 100755
--- a/smc_rnics
+++ b/smc_rnics
@@ -23,9 +23,9 @@ function usage() {
function print_header() {
if [ $IBdev -eq 0 ]; then
- printf " FID Power PCI_ID PCHID Type PPrt PNET_ID Net-Dev\n";
+ printf " FID Power PCI_ID PCHID Type PPrt PNET_ID Net-Dev\n";
else
- printf " FID Power PCI_ID PCHID Type IPrt PNET_ID IB-Dev\n";
+ printf " FID Power PCI_ID PCHID Type IPrt PNET_ID IB-Dev\n";
fi
echo '------------------------------------------------------------------------------------------';
}
@@ -78,7 +78,7 @@ function get_pnet_from_port() {
}
function print_rnic() {
- printf "%8x %-5s %-12s %-4s %-14s %-4s %-17s %s\n" "$((16#$fid))" "$power" "$addr" "$pchid" "$dev_type" "$port" "`get_pnet_from_port`" "$int";
+ printf "%8x %-5s %-12s %-4s %-15s %-4s %-17s %s\n" "$((16#$fid))" "$power" "$addr" "$pchid" "$dev_type" "$port" "`get_pnet_from_port`" "$int";
(( printed++ ));
}
@@ -103,13 +103,14 @@ function set_by_firmware_lvl() {
local name;
local lvl;
- name="Mlx_$id";
which ethtool >/dev/null 2>&1;
if [ $? -eq 0 ] && [ "$int" != "n/a" ] && [ -d "net" ]; then
iface="`ls -1 net | head -1`";
lvl="`ethtool -i $iface | grep -e "^firmware-version:" | awk '{print($2)}'`";
if [ "${lvl%%.*}" == "22" ]; then
name="RoCE_Express3";
+ elif [ "${lvl%%.*}" == "14" ]; then
+ name="RoCE_Express2";
fi
fi
set_RoCE_dev_and_port $name;
@@ -155,25 +156,17 @@ function print_rnics() {
id=`cat device`;
vend=`cat vendor`;
dev_type="${vend#0x}:${id#0x}";
+ pft=`cat pft`;
if [ $rawIDs -eq 0 ]; then
- case "$vend" in
- "0x1014" ) # IBM
- case "$id" in
- "0x04ed") dev_type="ISM";
- int="n/a";;
- *)
- continue;
- esac;;
- "0x15b3" ) # Mellanox
- case "$id" in
- "0x1003" | \
- "0x1004") dev_type="RoCE_Express";;
- "0x1016") set_RoCE_dev_and_port "RoCE_Express2";;
- "0x101e") set_by_firmware_lvl;;
- *) set_RoCE_dev_and_port "Mlx_$id";;
- esac;;
+ case "$pft" in
+ "0x05") dev_type="ISM";
+ int="n/a";;
+ "0x02") dev_type="RoCE_Express";;
+ "0x0a") set_by_firmware_lvl;;
+ "0x0c" | \
+ "0x0f") set_RoCE_dev_and_port "Network_Express";;
*) [ $all -eq 0 ] && continue
- esac
+ esac
fi
pchid="`cat pchid | sed 's/^0x//'`";
pnetids="`cat util_string | sed 's/\x0/\x40/g' | iconv -f IBM-1047 -t ASCII`";

123
2-61129ccb308b.patch Normal file
View File

@ -0,0 +1,123 @@
commit 61129ccb308b260f2138e0610a1f4fe4919dfb43
Author: Sidraya Jayagond <sidraya@linux.ibm.com>
Date: Mon Jul 7 12:43:03 2025 +0200
smc_rnics: Add PFT and VF columns to smc_rnics output
Introduce new columns for PCI Function Type (PFT) and Virtual
Function (VF) in the smc_rnics device table output to improve RNIC
identification and diagnostics.
Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com>
Signed-off-by: Sidraya Jayagond <sidraya@linux.ibm.com>
diff --git a/smc_rnics b/smc_rnics
index c5d086e..4677bc1 100755
--- a/smc_rnics
+++ b/smc_rnics
@@ -22,12 +22,19 @@ function usage() {
}
function print_header() {
- if [ $IBdev -eq 0 ]; then
- printf " FID Power PCI_ID PCHID Type PPrt PNET_ID Net-Dev\n";
+ if [ $IBdev -eq 1 ] && [ $rawIDs -eq 1 ]; then
+ printf "FID Power PCI_ID PCHID Type PFT VFN IPrt PNET_ID IB-Dev\n";
+ echo '----------------------------------------------------------------------------------------------------';
+ elif [ $IBdev -eq 1 ]; then
+ printf "FID Power PCI_ID PCHID Type PFT VF IPrt PNET_ID IB-Dev\n";
+ echo '----------------------------------------------------------------------------------------------------';
+ elif [ $rawIDs -eq 1 ]; then
+ printf "FID Power PCI_ID PCHID Type PFT VFN PPrt PNET_ID Net-Dev\n";
+ echo '----------------------------------------------------------------------------------------------------'
else
- printf " FID Power PCI_ID PCHID Type IPrt PNET_ID IB-Dev\n";
+ printf "FID Power PCI_ID PCHID Type PFT VF PPrt PNET_ID Net-Dev\n";
+ echo '----------------------------------------------------------------------------------------------------';
fi
- echo '------------------------------------------------------------------------------------------';
}
function get_softset_pnet_id() {
@@ -78,10 +85,35 @@ function get_pnet_from_port() {
}
function print_rnic() {
- printf "%8x %-5s %-12s %-4s %-15s %-4s %-17s %s\n" "$((16#$fid))" "$power" "$addr" "$pchid" "$dev_type" "$port" "`get_pnet_from_port`" "$int";
+ if [ $rawIDs -eq 1 ]; then
+ printf "%4x %-5s %-12s %-4s %-15s %-4s %-3s %-4s %-17s %s\n" \
+ "$((16#$fid))" "$power" "$addr" "$pchid" "$dev_type" "$pft" "${vfn:+$((16#${vfn#0x}))}" "$port" "`get_pnet_from_port`" "$int";
+ else
+ printf "%4x %-5s %-12s %-4s %-15s %-4s %-3s %-4s %-17s %s\n" \
+ "$((16#$fid))" "$power" "$addr" "$pchid" "$dev_type" "$pft" "$vfn" "$port" "`get_pnet_from_port`" "$int";
+ fi
(( printed++ ));
}
+function set_RoCE_pft_and_vfn() {
+ local lpft=$1;
+ local lvfn=$((16#${2#0x}));
+
+ case "$lpft" in
+ "0x02") pft="ROC"; vfn="y";;
+ "0x05") pft="ISM"; vfn="y";;
+ "0x0a") pft="ROC2"; vfn="y";;
+ "0x0c") pft="NETH"; vfn="y";;
+ "0x0f") pft="NETD";
+ if (( $lvfn != 0 )); then
+ vfn="y";
+ else
+ vfn="n";
+ fi;;
+ *)
+ vfn="$lvfn";;
+ esac
+}
function set_RoCE_dev_and_port() {
dev_type="$1";
if [ -e port ]; then
@@ -134,8 +166,10 @@ function print_rnics() {
if [ $all -ne 0 ]; then
dev_type="";
pchid="";
+ pft="";
pnet="";
port="";
+ vfn="";
print_rnic;
fi
continue;
@@ -157,15 +191,28 @@ function print_rnics() {
vend=`cat vendor`;
dev_type="${vend#0x}:${id#0x}";
pft=`cat pft`;
+ vfn=`cat vfn`;
if [ $rawIDs -eq 0 ]; then
case "$pft" in
"0x05") dev_type="ISM";
- int="n/a";;
- "0x02") dev_type="RoCE_Express";;
- "0x0a") set_by_firmware_lvl;;
+ int="n/a";
+ set_RoCE_pft_and_vfn "$pft" "$vfn";;
+ "0x02") dev_type="RoCE_Express";
+ set_RoCE_pft_and_vfn "$pft" "$vfn";;
+ "0x0a") set_by_firmware_lvl;
+ set_RoCE_pft_and_vfn "$pft" "$vfn";;
"0x0c" | \
- "0x0f") set_RoCE_dev_and_port "Network_Express";;
- *) [ $all -eq 0 ] && continue
+ "0x0f") set_RoCE_dev_and_port "Network_Express";
+ set_RoCE_pft_and_vfn "$pft" "$vfn";;
+ *)
+ # For unknown PCI vendors, determine VF flag based on VFN value.
+ # This ensures consistent handling even for unrecognized vendor devices
+ [ $all -eq 0 ] && continue
+ if (( 16#${vfn#0x} != 0 )); then
+ vfn="y";
+ else
+ vfn="n";
+ fi;;
esac
fi
pchid="`cat pchid | sed 's/^0x//'`";

46
3-3cb6fbb2afac.patch Normal file
View File

@ -0,0 +1,46 @@
commit 3cb6fbb2afac79f0f097fccf3f6cc440784b3d00
Author: Sidraya Jayagond <sidraya@linux.ibm.com>
Date: Fri Jun 27 20:04:07 2025 +0200
smc_rnics: update smc_chk to extract PNetID from column 9
Adapt the smc_chk script to extract PNetID from
column 9 of the updated smc_rnics output, which now
includes two new columns: PCI Function Type (PFT)
and Virtual Function (VF).
The column index shift is handled to maintain correct PNET_ID parsing.
Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com>
Signed-off-by: Sidraya Jayagond <sidraya@linux.ibm.com>
diff --git a/smc_chk b/smc_chk
index c43e605..61c61c4 100755
--- a/smc_chk
+++ b/smc_chk
@@ -255,7 +255,7 @@ function set_pnetid() {
if [ $? -eq 0 ]; then
# PCI device - use smc_rnics for easy PNET_ID access
debug "PCI device, retrieve PNET ID via smc_rnics";
- pnetid="`smc_rnics | grep -e "$1\$" | awk '{print($7)}'`";
+ pnetid="`smc_rnics | grep -e "$1\$" | awk '{print($9)}'`";
[ "$pnetid" != "" ] && return;
fi
if [ -e /sys/class/net/$1/device/portno ] && [ -e /sys/class/net/$1/device/chpid ]; then
@@ -290,7 +290,7 @@ function is_smcd_available() {
function set_ism() {
is_smcd_available "v1";
[ $? -ne 0 ] && return;
- ism="`smc_rnics | awk -v pn="$1" '$5 == "ISM" && $7 == pn {print($1)}' | sed 's/ $//'`";
+ ism="`smc_rnics | awk -v pn="$1" '$5 == "ISM" && $9 == pn {print($1)}' | sed 's/ $//'`";
}
# Returns all ISMv2-eligible devices (PNET ID not set or same as *some* NIC)
@@ -317,7 +317,7 @@ function set_ismv2() {
[ $? -ne 0 ] && continue;
fi
ismv2="$ismv2 `echo $line | awk '{print($1)}'`";
- done <<< $(smc_rnics | awk '$5 == "ISM" {print($1" "$7)}')
+ done <<< $(smc_rnics | awk '$5 == "ISM" {print($1" "$9)}')
ismv2="`echo $ismv2`"; # strip leading blank
}

43
4-108d5124b837.patch Normal file
View File

@ -0,0 +1,43 @@
commit 108d5124b8377587aa2ae73cf432901f008ff47b
Author: Sidraya Jayagond <sidraya@linux.ibm.com>
Date: Fri Jun 27 20:46:48 2025 +0200
man pages: Update man page for --rawids option and PFT and VF columns
Update the smc_rnics man page to clarify that --rawids options outputs
raw PCI, PFT and VFN codes, and add descriptions for the new PFT, VF
and VFN columns.
Reviewed-by: Alexandra Winter <wintera@linux.ibm.com>
Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com>
Signed-off-by: Sidraya Jayagond <sidraya@linux.ibm.com>
diff --git a/smc_rnics.8 b/smc_rnics.8
index d4f4f1d..789dff4 100644
--- a/smc_rnics.8
+++ b/smc_rnics.8
@@ -60,7 +60,7 @@ usage information.
Display IB device information.
.TP
.BR "\-r, \-\-rawids"
-Display raw PCI vendor and device codes in column. Note that this will
+Display raw PCI vendor/device, PFT, and VFN codes in columns. Note that this will
also include unknown devices.
.TP
.BR "\-v, \-\-version"
@@ -87,6 +87,15 @@ Device type in human readable form. See option
.B -r
to switch to display of PCI vendor and device instead.
+.SS "PFT"
+PCI Function Type. Display hexadecimal value with option -r or mapped name with option -a.
+
+.SS "VF"
+Virtual Function. Indicates if the FID is a virtual function within the adapter.
+
+.SS "VFN"
+Virtual Function number. Indicates the virtual function within the adapter.
+
.SS "PPrt"
Corresponding physical port of an RNIC, if applicable. Starts counting at 0.

140
5-a60b96821be3.patch Normal file
View File

@ -0,0 +1,140 @@
commit a60b96821be3fadaf89d643072488e4762b28d10
Author: Halil Pasic <pasic@linux.ibm.com>
Date: Tue Dec 2 15:25:40 2025 +0100
smc_rnics: fix regression when PFT not available
Before commit 0b965ae ("smc_rnics: Add support for Network Express RNIC
in smc_rnics") the device type detection was based on PCI vendor and
device ID. The aforementioned commit switched smc_rnics to doing
the device type detection primarily on PCI function type (PFT), which
is in general a sound thing to do.
In certain virtualized environments however (most notably QEMU+KVM) PFT
is generally not available, and even for passed through devices, as of
now PFT 0 is reported regardless of the actual PFT as seen by G1 (i.e.
LPAR). And that leads to not detecting passed through rnics as such, and
generally displaying an empty list when smc_rnics is called with no
parameters, even in a presence of rnics to display.
The patch also degraded the ability of the script to handle unknown
vendor id 0x15b3 devices gracefully. This can be relevant if a not
enlightened version of the script is used on new hardware.
Adding a warning about the surprise PFT 0 does not seem to be a good
idea, because there are PCI devices which are readily available on
s390x and for which PFT 0 is just expected: most notably virtio-pci, and
frankly it isn't all that helpful either.
On the other hand, using the PFT, when available and suitable, is still
considered superior.
Use the old PCI vendor and device ID based logic as a fall back when PFT
is not available or not known.
With this the regressions introduced by commit 0b965ae ("smc_rnics: Add
support for Network Express RNIC in smc_rnics") shall be gone.
While at it fix the handling of ports too. The call to
set_RoCE_dev_and_port in the loop that iterates over network interfaces
does not make sense; and 'RoCE Express' needs special handling as a
device that has multiple ports and interfaces per PCI function
regardless of the value the variable 'rawIDs'.
I don't quite understand why grabbing port from the interface's dev_port
attribute is a bad idea. That precedence was established by 05d1c7e
("smc_rnics: Fix RoCE Express2 port display"). My best guess is that
dev_port is only valid if a PCI function can interact with multiple
physical ports, which is not the case with RoCE Express2 and higher. So
I am leaving that as is.
Fixes: commit 0b965ae ("smc_rnics: Add support for Network Express RNIC in smc_rnics")
Reviewed-by: Sidraya Jayagond <sidraya@linux.ibm.com>
Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
diff --git a/smc_rnics b/smc_rnics
index 70b6f69..279da22 100755
--- a/smc_rnics
+++ b/smc_rnics
@@ -144,6 +144,26 @@ function set_by_firmware_lvl() {
set_RoCE_dev_and_port $name;
}
+function set_by_pciid(){
+
+ case "$vend" in
+ "0x1014" ) # IBM
+ case "$id" in
+ "0x04ed") dev_type="ISM";
+ int="n/a";;
+ esac;;
+ "0x15b3" ) # Mellanox
+ case "$id" in
+ "0x1003" | \
+ "0x1004") dev_type="RoCE_Express";
+ multiport_f=1;;
+ "0x1016") set_RoCE_dev_and_port "RoCE_Express2";;
+ "0x101e") set_by_firmware_lvl;;
+ *) set_RoCE_dev_and_port "Mlx_$id";;
+ esac;;
+ esac
+}
+
function print_rnics() {
# iterate over slots, as powered-off devices won't show elsewhere
for fid in `ls -1 /sys/bus/pci/slots`; do
@@ -188,12 +208,15 @@ function print_rnics() {
dev_type="${vend#0x}:${id#0x}";
pft=`cat pft`;
vfn=`cat vfn`;
+ multiport_f=0;
if [ $rawIDs -eq 0 ]; then
+ # prefer PFT for disamgibuating devices
case "$pft" in
"0x05") dev_type="ISM";
int="n/a";
set_RoCE_pft_and_vfn "$pft" "$vfn";;
"0x02") dev_type="RoCE_Express";
+ multiport_f=1;
set_RoCE_pft_and_vfn "$pft" "$vfn";;
"0x0a") set_by_firmware_lvl;
set_RoCE_pft_and_vfn "$pft" "$vfn";;
@@ -201,15 +224,20 @@ function print_rnics() {
"0x0f") set_RoCE_dev_and_port "Network_Express";
set_RoCE_pft_and_vfn "$pft" "$vfn";;
*)
+ # but if that fails go via the pci IDs
+ set_by_pciid
# For unknown PCI vendors, determine VF flag based on VFN value.
# This ensures consistent handling even for unrecognized vendor devices
- [ $all -eq 0 ] && continue
+ [ "$dev_type" = "${vend#0x}:${id#0x}" ] && [ $all -eq 0 ] && continue
if (( 16#${vfn#0x} != 0 )); then
vfn="y";
else
vfn="n";
fi;;
- esac
+ esac
+ else
+ set_RoCE_dev_and_port "$dev_type";
+ [ "0x15b3" = "$vend" ] && [ "0x1004" = "$id" ] && multiport_f=1;
fi
pchid="`cat pchid | sed 's/^0x//'`";
pnetids="`cat util_string | sed 's/\x0/\x40/g' | iconv -f IBM-1047 -t ASCII`";
@@ -221,10 +249,10 @@ function print_rnics() {
print_rnic;
continue;
fi
- # one device can have multiple interfaces (one per port)
for int in $interfaces; do
+ # one device can have multiple interfaces (one per port)
cd /sys/bus/pci/devices/$addr/net/$int;
- if [ "$dev_type" == "RoCE_Express" ] && [ -e dev_port ]; then
+ if [ $multiport_f -eq 1 ] && [ -e dev_port ]; then
port=`cat dev_port`;
fi
print_rnic;
--
2.54.0

View File

@ -2,7 +2,7 @@
Name: smc-tools
Version: 1.8.3
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Shared Memory Communication Tools
License: EPL
@ -16,6 +16,11 @@ BuildRequires: bash-completion
Source0: https://github.com/ibm-s390-linux/%{name}/archive/refs/tags/%{version}.tar.gz
Patch0: smc-tools-1.6.0-smc_chk-py3.patch
Patch1: 1-0b965ae9b5ad.patch
Patch2: 2-61129ccb308b.patch
Patch3: 3-3cb6fbb2afac.patch
Patch4: 4-108d5124b837.patch
Patch5: 5-a60b96821be3.patch
%description
The Shared Memory Communication Tools (smc-tools) package enables usage of SMC
@ -24,6 +29,11 @@ sockets in Linux.
%prep
%forgesetup
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%build
%make_build CFLAGS="%{build_cflags} -I%{_includedir}/libnl3" LDFLAGS="%{build_ldflags}" V=1
@ -51,6 +61,10 @@ sockets in Linux.
%{_libdir}/libsmc-preload.so*
%changelog
* Tue Jun 23 2026 Čestmír Kalina <ckalina@redhat.com> - 1.8.3-2
- Resolves: RHEL-159089
- smc-tools: smc_rnics is not listing the NetH/NetD cards inside the guest
* Mon Oct 09 2023 Čestmír Kalina <ckalina@redhat.com> - 1.8.3-1
- Resolves: RHEL-11417 Upgrade smc-tools to latest version
- smc_stats: Fix man page name