Skip to content

Commit 5a49a0f

Browse files
[multi-asic][vs]: Update topology script to retrieve hwsku from minigraph (#6219)
Update topology script to retrieve hwsku from minigraph if hwsku information is not available in config_db. Fix clean up of interfaces in msft_multi_asic_vs hwsku topology script. - Why I did it When bringing up multi-asic VS switch, topology service is started during boot up. Topology service starts a shell script which runs the topology script present in /usr/share/sonic/device// directory. To invoke hwsku specific script, the topology script tries to retrieve hwsku information from config_db. During initial boot up config_db might not be populated. In order to start topology service before config_db is updated, update topology script to get hwsku information from minigraph.xml if it is available. This will be helpful to bring up multi-asic VS testbed by loading minigraph and starting topology service. - How I did it Update topology.sh script to retrieve hwsku information from minigraph.xml. Fix clean up function on msft_multi_asic_vs toplogy script. - How to verify it single-asic VS - no change; topology service is only enabled for multi-asic VS. multi-asic VS - Bring up multi-asic VS image, copy minigraph to vs image, start topology service. Topology service should be successful. to test clean up function fix, start topology service - make sure interfaces are created and moved to the right namespaces. stop topology service - make sure namespace do not have any interface and all front end interfaces are present in default namespace.
1 parent 2fc37dd commit 5a49a0f

2 files changed

Lines changed: 45 additions & 14 deletions

File tree

device/virtual/x86_64-kvm_x86_64-r0/msft_multi_asic_vs/topology.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ NUM_INTERFACES_PER_ASIC=32
88

99
start () {
1010
# Move external links into assigned frontend namespaces
11-
# eth0 - eth15: asic2
12-
# eth16 - eth31: asic3
13-
# eth32 - eth47: asic4
14-
# eth48 - eth63: asic5
11+
# eth1 - eth16: asic0
12+
# eth17 - eth32: asic1
13+
# eth33 - eth48: asic2
14+
# eth49 - eth64: asic3
1515
for ASIC in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do
1616
for NUM in `seq 1 16`; do
1717
ORIG="eth$((16 * $ASIC + $NUM))"
@@ -22,6 +22,7 @@ start () {
2222
ip link set dev $ORIG name $TEMP # rename to prevent conflicts before renaming in new namespace
2323
ip link set dev $TEMP netns asic$ASIC
2424
sudo ip netns exec asic$ASIC ip link set $TEMP name $NEW # rename to final interface name
25+
sudo ip netns exec asic$ASIC ip link set dev $NEW mtu 9100
2526
sudo ip netns exec asic$ASIC ip link set $NEW up
2627
done
2728
done
@@ -43,7 +44,9 @@ start () {
4344
sudo ip netns exec asic$BACKEND ip link set $TEMP_BACK name $BACK_NAME
4445
sudo ip netns exec asic$FRONTEND ip link set $TEMP_FRONT name $FRONT_NAME
4546

47+
sudo ip netns exec asic$BACKEND ip link set dev $BACK_NAME mtu 9100
4648
sudo ip netns exec asic$BACKEND ip link set $BACK_NAME up
49+
sudo ip netns exec asic$FRONTEND ip link set dev $FRONT_NAME mtu 9100
4750
sudo ip netns exec asic$FRONTEND ip link set $FRONT_NAME up
4851
done
4952
done
@@ -54,8 +57,8 @@ stop() {
5457
for ASIC in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do
5558
for NUM in `seq 1 16`; do
5659
TEMP="eth999"
57-
OLD="eth$((16 * $ASIC + $NUM))"
58-
NAME="eth$((16 * $ASIC + $NUM - 1))"
60+
OLD="eth$(($NUM))"
61+
NAME="eth$((16 * $ASIC + $NUM))"
5962
sudo ip netns exec asic$ASIC ip link set dev $OLD down
6063
sudo ip netns exec asic$ASIC ip link set dev $OLD name $TEMP
6164
sudo ip netns exec asic$ASIC ip link set dev $TEMP netns 1

files/image_config/topology/topology.sh

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,49 @@
11
#!/bin/bash
22
# This script is invoked by topology.service only
3-
# for multi-asic virtual platform. For multi-asic platform
4-
# multiple Database instances are present
3+
# for multi-asic virtual platform. For multi-asic platform
4+
# multiple Database instances are present
55
# and HWKSU information is retrieved from first database instance.
66
#
77

8+
get_hwsku() {
9+
# Get HWSKU from config_db. If HWSKU is not available in config_db
10+
# get HWSKU from minigraph.xml if minigraph file exists.
11+
HWSKU=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]' 2>&1`
12+
if [[ $? -ne 0 || $HWSKU == "" ]]; then
13+
if [[ -f "/etc/sonic/minigraph.xml" ]]; then
14+
HWSKU=`sonic-cfggen -m /etc/sonic/minigraph.xml -v "DEVICE_METADATA['localhost']['hwsku']" 2>&1`
15+
if [[ $? -ne 0 || $HWSKU == "" ]]; then
16+
HWSKU=""
17+
fi
18+
else
19+
HWSKU=""
20+
fi
21+
fi
22+
echo "${HWSKU}"
23+
}
24+
825
start() {
926
TOPOLOGY_SCRIPT="topology.sh"
10-
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
11-
HWSKU=${HWSKU:-`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`}
12-
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT start
27+
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
28+
HWSKU=`get_hwsku`
29+
if [[ $HWSKU != "" ]]; then
30+
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT start
31+
else
32+
echo "Failed to get HWSKU"
33+
exit 1
34+
fi
1335
}
36+
1437
stop() {
1538
TOPOLOGY_SCRIPT="topology.sh"
16-
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
17-
HWSKU=${HWSKU:-`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`}
18-
usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT stop
39+
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
40+
HWSKU=`get_hwsku`
41+
if [[ $HWSKU != "" ]]; then
42+
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT stop
43+
else
44+
echo "Failed to get HWSKU"
45+
exit 1
46+
fi
1947
}
2048

2149
# read SONiC immutable variables

0 commit comments

Comments
 (0)