Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BFN] Provide unified approach to select P4 profile based on chip family #1089

Merged
merged 2 commits into from
Jul 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions syncd/scripts/syncd_init_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
taras-keryk marked this conversation as resolved.
Show resolved Hide resolved
# 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/
Expand Down