From d821bc0b137264daa01c347700c7c14677cf3370 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Fri, 16 Apr 2021 09:00:00 +0300 Subject: [PATCH] [Mellanox] Add SAI template config support (#803) Allow SAI xml dynamic config override when template is defined Signed-off-by: Nazarii Hnydyn --- syncd/scripts/syncd_init_common.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index 0bc4df40aaf7..bff1dc1646ed 100755 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -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') @@ -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 }