From 47df89dbb741f1f29050bfce10d292b244be0e9c Mon Sep 17 00:00:00 2001 From: Taras Keryk Date: Fri, 22 Jul 2022 19:34:22 +0000 Subject: [PATCH 1/2] Added check if SDE profile configured --- syncd/scripts/syncd_init_common.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index 3ea08029a..f840a2de1 100644 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -247,13 +247,25 @@ config_syncd_barefoot() echo "SAI_KEY_WARM_BOOT_READ_FILE=/var/warmboot/sai-warmboot.bin" >> $PROFILE_FILE fi CMD_ARGS+=" -l -p $PROFILE_FILE" - - # Check and load SDE profile + # Check if SDE profile configured P4_PROFILE=$(sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["p4_profile"]') if [[ -n "$P4_PROFILE" ]]; then if [[ ( -d /opt/bfn/install_${P4_PROFILE} ) && ( -L /opt/bfn/install || ! -e /opt/bfn/install ) ]]; then ln -srfn /opt/bfn/install_${P4_PROFILE} /opt/bfn/install fi + else + CHIP_FAMILY_INFO="$(cat $HWSKU_DIR/switch-tna-sai.conf | grep chip_family | awk -F : '{print $2}' | cut -d '"' -f 2)" + CHIP_FAMILY=${CHIP_FAMILY_INFO,,} + [[ "$CHIP_FAMILY" == "tofino" ]] && P4_PTYPE="x" || P4_PTYPE="y" + # Check if the current profile fits the ASIC family + PROFILE_DEFAULT=$(readlink /opt/bfn/install) + if [[ "$PROFILE_DEFAULT" != "install_$P4_PTYPE"*"_profile" && $PROFILE_DEFAULT != *"_$CHIP_FAMILY" ]]; then + # Find suitable profile + PROFILE=$(ls -d /opt/bfn/install_$P4_PTYPE*_profile -d /opt/bfn/install_*_$CHIP_FAMILY 2> /dev/null | head -1) + if [[ ! -z $PROFILE ]]; then + ln -srfn $PROFILE /opt/bfn/install + fi + fi fi export PYTHONHOME=/opt/bfn/install/ export PYTHONPATH=/opt/bfn/install/ From a345dad7bfb2ce4764bb626211d4d1d8b0394ba3 Mon Sep 17 00:00:00 2001 From: Taras Keryk Date: Mon, 25 Jul 2022 06:13:17 +0000 Subject: [PATCH 2/2] put $PROFILE_DEFAULT into quotes, removed one extra space before $PROFILE_DEFAULT --- syncd/scripts/syncd_init_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index f840a2de1..5759cba17 100644 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -247,7 +247,7 @@ config_syncd_barefoot() echo "SAI_KEY_WARM_BOOT_READ_FILE=/var/warmboot/sai-warmboot.bin" >> $PROFILE_FILE fi CMD_ARGS+=" -l -p $PROFILE_FILE" - # Check if SDE profile configured + # Check if SDE profile is configured P4_PROFILE=$(sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["p4_profile"]') if [[ -n "$P4_PROFILE" ]]; then if [[ ( -d /opt/bfn/install_${P4_PROFILE} ) && ( -L /opt/bfn/install || ! -e /opt/bfn/install ) ]]; then @@ -259,7 +259,7 @@ config_syncd_barefoot() [[ "$CHIP_FAMILY" == "tofino" ]] && P4_PTYPE="x" || P4_PTYPE="y" # Check if the current profile fits the ASIC family PROFILE_DEFAULT=$(readlink /opt/bfn/install) - if [[ "$PROFILE_DEFAULT" != "install_$P4_PTYPE"*"_profile" && $PROFILE_DEFAULT != *"_$CHIP_FAMILY" ]]; then + if [[ "$PROFILE_DEFAULT" != "install_$P4_PTYPE"*"_profile" && "$PROFILE_DEFAULT" != *"_$CHIP_FAMILY" ]]; then # Find suitable profile PROFILE=$(ls -d /opt/bfn/install_$P4_PTYPE*_profile -d /opt/bfn/install_*_$CHIP_FAMILY 2> /dev/null | head -1) if [[ ! -z $PROFILE ]]; then