Skip to content

Commit

Permalink
[Mellanox] Add SAI template config support (#803)
Browse files Browse the repository at this point in the history
Allow SAI xml dynamic config override when template is defined

Signed-off-by: Nazarii Hnydyn <[email protected]>
  • Loading branch information
nazariig authored Apr 16, 2021
1 parent bb341e9 commit d821bc0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions syncd/scripts/syncd_init_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ CMD_DSSERVE_ARGS="$CMD_SYNCD --diag"

ENABLE_SAITHRIFT=0

TEMPLATES_DIR=/usr/share/sonic/templates
PLATFORM_DIR=/usr/share/sonic/platform
HWSKU_DIR=/usr/share/sonic/hwsku

VARS_FILE=/usr/share/sonic/templates/swss_vars.j2
VARS_FILE=$TEMPLATES_DIR/swss_vars.j2

# Retrieve vars from sonic-cfggen
SYNCD_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $VARS_FILE) || exit 1
SONIC_ASIC_TYPE=$(echo $SYNCD_VARS | jq -r '.asic_type')
Expand Down Expand Up @@ -105,10 +107,17 @@ config_syncd_mlnx()
[ -e /dev/sxdevs/sxcdev ] || ( mkdir -p /dev/sxdevs && mknod /dev/sxdevs/sxcdev c 231 193 )

# Read MAC address
MAC_ADDRESS="$(sonic-cfggen -d -v DEVICE_METADATA.localhost.mac)"
MAC_ADDRESS="$(echo $SYNCD_VARS | jq -r '.mac')"

# Make default sai.profile
if [[ -f $HWSKU_DIR/sai.profile.j2 ]]; then
export RESOURCE_TYPE="$(echo $SYNCD_VARS | jq -r '.resource_type')"
j2 -e RESOURCE_TYPE $HWSKU_DIR/sai.profile.j2 -o /tmp/sai.profile
else
cat $HWSKU_DIR/sai.profile > /tmp/sai.profile
fi

# Write MAC address into /tmp/profile file.
cat $HWSKU_DIR/sai.profile > /tmp/sai.profile
# Update sai.profile with MAC_ADDRESS and WARM_BOOT settings
echo "DEVICE_MAC_ADDRESS=$MAC_ADDRESS" >> /tmp/sai.profile
echo "SAI_WARM_BOOT_WRITE_FILE=/var/warmboot/" >> /tmp/sai.profile
}
Expand Down

0 comments on commit d821bc0

Please sign in to comment.