Skip to content

Commit 3862d37

Browse files
author
Stefan Raspl
committed
Release: Prepare v1.3.0
Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
1 parent 910717c commit 3862d37

9 files changed

Lines changed: 424 additions & 102 deletions

File tree

Makefile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# http://www.eclipse.org/legal/epl-v10.html
1111
#
1212

13-
SMC_TOOLS_RELEASE = 1.2.2
13+
SMC_TOOLS_RELEASE = 1.3.0
1414
VER_MAJOR = $(shell echo $(SMC_TOOLS_RELEASE) | cut -d '.' -f 1)
1515

1616
ARCHTYPE = $(shell uname -m)
@@ -102,7 +102,7 @@ SMC_PNET_CFLAGS = -I /usr/include/libnl3
102102
SMC_PNET_LFLAGS = -lnl-genl-3 -lnl-3
103103
endif
104104

105-
smc_pnet: smc_pnet.c smc.h smctools_common.h
105+
smc_pnet: smc_pnet.c smctools_common.h
106106
@if [ ! -e /usr/include/libnl3/netlink/netlink.h ]; then \
107107
printf "**************************************************************\n" >&2; \
108108
printf "* Missing build requirement for: %-45s\n" $@ >&2; \
@@ -115,7 +115,7 @@ smc_pnet: smc_pnet.c smc.h smctools_common.h
115115
fi
116116
${CCC} ${ALL_CFLAGS} ${SMC_PNET_CFLAGS} ${LDFLAGS} -o $@ $< ${SMC_PNET_LFLAGS}
117117

118-
smcss: smcss.c smc_diag.h smctools_common.h
118+
smcss: smcss.c smctools_common.h
119119
${CCC} ${ALL_CFLAGS} ${LDFLAGS} $< -o $@
120120

121121
install: all
@@ -147,6 +147,22 @@ ifneq ($(BASH_AUTODIR),)
147147
ln -sfr $(DESTDIR)$(BASH_AUTODIR)/smc-tools $(DESTDIR)$(BASH_AUTODIR)/smc_pnet
148148
endif
149149

150+
check:
151+
if which cppcheck >/dev/null; then \
152+
echo "Running cppcheck"; \
153+
cppcheck . 2>&1; \
154+
else \
155+
echo "cppcheck not available"; \
156+
fi
157+
@echo;
158+
if which valgrind >/dev/null; then \
159+
echo "Running valgrind"; \
160+
valgrind --leak-check=full --show-leak-kinds=all ./smcss 2>&1; \
161+
valgrind --leak-check=full --show-leak-kinds=all ./smc_pnet 2>&1; \
162+
else \
163+
echo "valgrind not available"; \
164+
fi
165+
@echo;
150166
clean:
151167
echo " CLEAN"
152168
rm -f *.o *.so smcss smc_pnet

README.smctools

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,25 @@ For enhancements, please describe the proposed change and its benefits.
4646
Release History:
4747
================
4848

49+
1.3.0 (2020-06-16)
50+
Changes:
51+
- smcss: Add description of Linux error codes to man page
52+
- smc_rnics:
53+
* Sort output by PCHID
54+
* Replace spaces in output by underscores for easier parsing
55+
* Add new option --IB-dev to display IB-specific attributes
56+
57+
Bug fixes:
58+
- smc_rnics:
59+
* FIDs can have up to 4 digits and are planned to be extended
60+
to a total of 8 digits - adjusting output format accordingly
61+
* Do not display port attribute for RoCE Express2 devices
62+
unless we have an accurate value
63+
4964
1.2.2 (2019-10-24)
5065
Changes:
5166
- Add bash autocompletion support
67+
- Makefile: Drop 31 Bit install due to rpmbuild conflict
5268

5369
Bug fixes:
5470
- smcss: Do not show connection mode for already closed sockets
@@ -105,8 +121,6 @@ smc_run SMC preload library environment setup script
105121
smc_pnet.c PNET Table handling source code
106122
smcss.c SMC socket display source code
107123
smctools_common.h common definitions for smctools
108-
smc.h include file from kernel include/uapi/linux/smc.h
109-
smc_diag.h include file from kernel include/uapi/linux/smc_diag.h
110124
af_smc.7 manpage for AF_SMC sockets
111125
smc_pnet.8 manpage for smc_pnet
112126
smcss.8 manpage for smcss

smc_dbg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ while [ $# -gt 0 ]; do
3636
"-t" | "--tgz" )
3737
tgz="on";;
3838
"-v" | "--version" )
39-
echo "smc_dbg utility, smc-tools-1.2.2 (4335826)";
39+
echo "smc_dbg utility, smc-tools-1.3.0 (eb56148)";
4040
exit 0;;
4141
* )
4242
esac

smc_pnet.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <netlink/genl/ctrl.h>
3434

3535
#include "smctools_common.h"
36-
#include "smc.h"
3736

3837
static char *progname;
3938

smc_rnics

Lines changed: 132 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,140 @@ function usage() {
1212
echo " -d, --disable <FID> disable the specified FID";
1313
echo " -e, --enable <FID> enable the specified FID";
1414
echo " -h, --help display this message";
15+
echo " -I, --IB-dev display IB-dev instead of netdev attributes";
1516
echo " -r, --rawids display 'type' as raw vendor/device IDs";
1617
echo " -v, --version display version info";
1718
echo;
1819
}
1920

20-
function print_rnic() {
21-
if [ $header -eq 0 ]; then
22-
printf "FID Power PCI ID PCHID Type Port PNET ID Interface\n";
23-
echo '------------------------------------------------------------------------------------';
24-
header=1;
21+
function print_header() {
22+
if [ $IBdev -eq 0 ]; then
23+
printf " FID Power PCI_ID PCHID Type PPrt PNET_ID Net-Dev\n";
24+
else
25+
printf " FID Power PCI_ID PCHID Type IPrt PNET_ID IB-Dev\n";
2526
fi
26-
printf "%3x %-5s %-12s %-4s %-14s %-4s %-16s %s\n" "$((16#$fid))" "$power" "$addr" "$pchid" "$dev_type" "$port" "$pnet" "$int";
27+
echo '-----------------------------------------------------------------------------------------';
28+
}
29+
30+
function get_pnet_from_port() {
31+
local idx;
32+
local end;
33+
local lport=$port;
34+
35+
if [ "$lport" == "n/a" ] || [ "$dev_type" == "RoCE_Express2" ]; then
36+
if [ $IBdev -eq 0 ]; then
37+
lport=0;
38+
else
39+
lport=1;
40+
fi
41+
fi
42+
[ $IBdev -ne 0 ] && let lport=$lport-1;
43+
(( idx=16*$lport+1 ))
44+
(( end=$idx+15 ))
45+
echo "$pnetids" | cut -c $idx-$end;
46+
}
47+
48+
function print_rnic() {
49+
printf "%8x %-5s %-12s %-4s %-14s %-4s %-16s %s\n" "$((16#$fid))" "$power" "$addr" "$pchid" "$dev_type" "$port" "`get_pnet_from_port`" "$int";
2750
(( printed++ ));
2851
}
2952

53+
function print_rnics() {
54+
# iterate over slots, as powered-off devices won't show elsewhere
55+
for fid in `ls -1 /sys/bus/pci/slots`; do
56+
cd /sys/bus/pci/slots/$fid;
57+
fid="$fid";
58+
if [ "$target" != "" ] && [ "$fid" != "$target" ]; then
59+
continue;
60+
fi
61+
power=`cat power`;
62+
interfaces="";
63+
port="n/a";
64+
addr="";
65+
int="";
66+
if [ $power -eq 0 ]; then
67+
# device not yet hotplugged
68+
dev_type="";
69+
pchid="";
70+
pnet="";
71+
print_rnic;
72+
continue;
73+
fi
74+
# device is hotplugged - locate it
75+
for dev in `ls -1 /sys/bus/pci/devices`; do
76+
cd /sys/bus/pci/devices/$dev;
77+
if [ "`cat function_id`" == "0x$fid" ]; then
78+
addr=$dev;
79+
break;
80+
fi
81+
done
82+
if [ "$addr" == "" ]; then
83+
echo "Error: No matching device found for FID $fid" >&2;
84+
continue;
85+
fi
86+
cd /sys/bus/pci/devices/$addr;
87+
id=`cat device`;
88+
vend=`cat vendor`;
89+
dev_type="${vend#0x}:${id#0x}";
90+
if [ $rawIDs -eq 0 ]; then
91+
case "$vend" in
92+
"0x1014" ) # IBM
93+
case "$id" in
94+
"0x04ed") dev_type="ISM";
95+
int="n/a";;
96+
"0x044b") continue;; # zEDC
97+
esac;;
98+
"0x15b3" ) # Mellanox
99+
case "$id" in
100+
"0x1003" | \
101+
"0x1004") dev_type="RoCE_Express";;
102+
"0x1016") dev_type="RoCE_Express2";
103+
if [ -e port ]; then
104+
port=`cat port`;
105+
if [ $IBdev -eq 0 ]; then
106+
let port=$port-1;
107+
else
108+
port=1;
109+
fi
110+
fi;;
111+
esac;;
112+
esac
113+
fi
114+
pchid="`cat pchid | sed 's/^0x//'`";
115+
pnetids="`cat util_string | tr -d '\000' | iconv -f IBM-1047 -t ASCII`";
116+
if [ $IBdev -eq 0 ]; then
117+
if [ -d "net" ]; then
118+
interfaces="`ls -1 net`";
119+
else
120+
int="n/a";
121+
print_rnic;
122+
continue;
123+
fi
124+
# one device can have multiple interfaces (one per port)
125+
for int in $interfaces; do
126+
cd /sys/bus/pci/devices/$addr/net/$int;
127+
if [ "$dev_type" == "RoCE_Express" ] && [ -e dev_port ]; then
128+
port=`cat dev_port`;
129+
fi
130+
print_rnic;
131+
done
132+
else
133+
if [ -d "infiniband" ]; then
134+
int="`ls -1 infiniband`";
135+
else
136+
int="n/a";
137+
print_rnic;
138+
continue;
139+
fi
140+
# only one IB interface per card
141+
cd /sys/bus/pci/devices/$addr/infiniband/$int
142+
for port in `ls -1 ports`; do
143+
print_rnic;
144+
done
145+
fi
146+
done
147+
}
148+
30149
function format_fid() {
31150
res="${1#0x}";
32151

@@ -43,12 +162,13 @@ if [ "`uname -m`" != "s390x" ] && [ "`uname -m`" != "s390" ]; then
43162
exit 1;
44163
fi
45164

46-
args=`getopt -u -o hrve:d: -l enable:,disable:,help,rawids,version -- $*`;
165+
args=`getopt -u -o hIrve:d: -l enable:,disable:,help,IB-dev,rawids,version -- $*`;
47166
[ $? -ne 0 ] && exit 2;
48167
set -- $args;
49168
action="print";
50169
rawIDs=0;
51170
target="";
171+
IBdev=0;
52172
printed=0;
53173
while [ $# -gt 0 ]; do
54174
case $1 in
@@ -63,10 +183,12 @@ while [ $# -gt 0 ]; do
63183
"-h" | "--help" )
64184
usage;
65185
exit 0;;
186+
"-I" | "--IB-dev" )
187+
IBdev=1;;
66188
"-r" | "--rawids" )
67189
rawIDs=1;;
68190
"-v" | "--version" )
69-
echo "smc_rnics utility, smc-tools-1.2.2 (4335826)";
191+
echo "smc_rnics utility, smc-tools-1.3.0 (eb56148)";
70192
exit 0;;
71193
"--" ) ;;
72194
* ) format_fid "$1";
@@ -102,82 +224,8 @@ if [ "$action" != "print" ]; then
102224
exit 0;
103225
fi
104226

105-
header=0;
106-
# iterate over slots, as powered-off devices won't show elsewhere
107-
for fid in `ls -1 /sys/bus/pci/slots`; do
108-
cd /sys/bus/pci/slots/$fid;
109-
fid="$fid";
110-
if [ "$target" != "" ] && [ "$fid" != "$target" ]; then
111-
continue;
112-
fi
113-
power=`cat power`;
114-
interfaces="";
115-
port="";
116-
addr="";
117-
int="";
118-
if [ $power -eq 0 ]; then
119-
# device not yet hotplugged
120-
dev_type="";
121-
pchid="";
122-
pnet="";
123-
print_rnic;
124-
continue;
125-
fi
126-
# device is hotplugged - locate it
127-
for dev in `ls -1 /sys/bus/pci/devices`; do
128-
cd /sys/bus/pci/devices/$dev;
129-
if [ "`cat function_id`" == "0x$fid" ]; then
130-
addr=$dev;
131-
break;
132-
fi
133-
done
134-
if [ "$addr" == "" ]; then
135-
echo "Error: No matching device found for FID $fid" >&2;
136-
continue;
137-
fi
138-
cd /sys/bus/pci/devices/$addr;
139-
id=`cat device`;
140-
vend=`cat vendor`;
141-
dev_type="${vend#0x}:${id#0x}";
142-
if [ $rawIDs -eq 0 ]; then
143-
case "$vend" in
144-
"0x1014" ) # IBM
145-
case "$id" in
146-
"0x04ed") dev_type="ISM";
147-
port="n/a";
148-
int="n/a";;
149-
"0x044b") continue;; # zEDC
150-
esac;;
151-
"0x15b3" ) # Mellanox
152-
case "$id" in
153-
"0x1003" | \
154-
"0x1004") dev_type="RoCE Express";;
155-
"0x1016") dev_type="RoCE Express2";;
156-
esac;;
157-
esac
158-
fi
159-
pchid="`cat pchid | sed 's/^0x//'`";
160-
pnet="`cat util_string | tr -d '\000' | iconv -f IBM-1047 -t ASCII`";
161-
if [ -d net ]; then
162-
interfaces="`ls -1 net`";
163-
fi
164-
# one device can have multiple interfaces (one per port)
165-
if [ "$interfaces" != "" ]; then
166-
pnetids="$pnet";
167-
for int in $interfaces; do
168-
cd /sys/bus/pci/devices/$addr/net/$int;
169-
if [ -e dev_port ]; then
170-
port=`cat dev_port`;
171-
(( idx=16*$port+1 ))
172-
(( end=$idx+15 ))
173-
pnet=`echo "$pnetids" | cut -c $idx-$end`;
174-
fi
175-
print_rnic;
176-
done
177-
continue;
178-
fi
179-
print_rnic;
180-
done
227+
print_header;
228+
print_rnics | sort -k 4;
181229

182230
if [ "$target" != "" ] && [ $printed -eq 0 ]; then
183231
exit 8;

0 commit comments

Comments
 (0)