Skip to content

Commit

Permalink
Add new functionality to syncd_init_common.sh, to use common sai.prof…
Browse files Browse the repository at this point in the history
…ile (#1352)

Changed config_mlnx_syncd() functionality to use common sai.profile for all SKUs, then apply the specific SKU sai.profile on top of it, and remove duplications.

Why I did it
To have the ability to add common parameters to only 1 file instead of all SKUs.
  • Loading branch information
noaOrMlnx authored and mssonicbld committed Feb 27, 2024
1 parent 5c05e23 commit edb2b17
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions syncd/scripts/syncd_init_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,23 @@ config_syncd_mlnx()
DUAL_TOR="$(echo $SYNCD_VARS | jq -r '.dual_tor')"
DSCP_REMAPPING="$(echo $SYNCD_VARS | jq -r '.dscp_remapping')"

# Make default sai.profile
SAI_COMMON_FILE_PATH=/etc/mlnx/sai-common.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
j2 -e RESOURCE_TYPE $HWSKU_DIR/sai.profile.j2 -o /tmp/sai-temp.profile
else
cat $HWSKU_DIR/sai.profile > /tmp/sai.profile
cat $HWSKU_DIR/sai.profile > /tmp/sai-temp.profile
fi

if [[ -f $SAI_COMMON_FILE_PATH ]]; then
cat $SAI_COMMON_FILE_PATH >> /tmp/sai-temp.profile
fi

# keep only the first occurence of each prefix with '=' sign, and remove the others.
awk -F= '!seen[$1]++' /tmp/sai-temp.profile > /tmp/sai.profile
rm -f /tmp/sai-temp.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 edb2b17

Please sign in to comment.