Skip to content

Commit 4853881

Browse files
author
Taras Keryk
authored
[BFN] Provide unified approach to select P4 profile based on chip family (sonic-net#1089)
* Added check if SDE profile configured * put $PROFILE_DEFAULT into quotes, removed one extra space before $PROFILE_DEFAULT
1 parent 854d54e commit 4853881

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

syncd/scripts/syncd_init_common.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,25 @@ config_syncd_barefoot()
248248
echo "SAI_KEY_WARM_BOOT_READ_FILE=/var/warmboot/sai-warmboot.bin" >> $PROFILE_FILE
249249
fi
250250
CMD_ARGS+=" -l -p $PROFILE_FILE"
251-
252-
# Check and load SDE profile
251+
# Check if SDE profile is configured
253252
P4_PROFILE=$(sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["p4_profile"]')
254253
if [[ -n "$P4_PROFILE" ]]; then
255254
if [[ ( -d /opt/bfn/install_${P4_PROFILE} ) && ( -L /opt/bfn/install || ! -e /opt/bfn/install ) ]]; then
256255
ln -srfn /opt/bfn/install_${P4_PROFILE} /opt/bfn/install
257256
fi
257+
else
258+
CHIP_FAMILY_INFO="$(cat $HWSKU_DIR/switch-tna-sai.conf | grep chip_family | awk -F : '{print $2}' | cut -d '"' -f 2)"
259+
CHIP_FAMILY=${CHIP_FAMILY_INFO,,}
260+
[[ "$CHIP_FAMILY" == "tofino" ]] && P4_PTYPE="x" || P4_PTYPE="y"
261+
# Check if the current profile fits the ASIC family
262+
PROFILE_DEFAULT=$(readlink /opt/bfn/install)
263+
if [[ "$PROFILE_DEFAULT" != "install_$P4_PTYPE"*"_profile" && "$PROFILE_DEFAULT" != *"_$CHIP_FAMILY" ]]; then
264+
# Find suitable profile
265+
PROFILE=$(ls -d /opt/bfn/install_$P4_PTYPE*_profile -d /opt/bfn/install_*_$CHIP_FAMILY 2> /dev/null | head -1)
266+
if [[ ! -z $PROFILE ]]; then
267+
ln -srfn $PROFILE /opt/bfn/install
268+
fi
269+
fi
258270
fi
259271
export PYTHONHOME=/opt/bfn/install/
260272
export PYTHONPATH=/opt/bfn/install/

0 commit comments

Comments
 (0)