Skip to content

Commit 09cd7f6

Browse files
authoredFeb 26, 2024
Add new functionality to syncd_init_common.sh, to use common sai.profile (#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.
1 parent a91d51d commit 09cd7f6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
 

‎syncd/scripts/syncd_init_common.sh

+12-3
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,23 @@ config_syncd_mlnx()
211211
DUAL_TOR="$(echo $SYNCD_VARS | jq -r '.dual_tor')"
212212
DSCP_REMAPPING="$(echo $SYNCD_VARS | jq -r '.dscp_remapping')"
213213

214-
# Make default sai.profile
214+
SAI_COMMON_FILE_PATH=/etc/mlnx/sai-common.profile
215+
215216
if [[ -f $HWSKU_DIR/sai.profile.j2 ]]; then
216217
export RESOURCE_TYPE="$(echo $SYNCD_VARS | jq -r '.resource_type')"
217-
j2 -e RESOURCE_TYPE $HWSKU_DIR/sai.profile.j2 -o /tmp/sai.profile
218+
j2 -e RESOURCE_TYPE $HWSKU_DIR/sai.profile.j2 -o /tmp/sai-temp.profile
218219
else
219-
cat $HWSKU_DIR/sai.profile > /tmp/sai.profile
220+
cat $HWSKU_DIR/sai.profile > /tmp/sai-temp.profile
221+
fi
222+
223+
if [[ -f $SAI_COMMON_FILE_PATH ]]; then
224+
cat $SAI_COMMON_FILE_PATH >> /tmp/sai-temp.profile
220225
fi
221226

227+
# keep only the first occurence of each prefix with '=' sign, and remove the others.
228+
awk -F= '!seen[$1]++' /tmp/sai-temp.profile > /tmp/sai.profile
229+
rm -f /tmp/sai-temp.profile
230+
222231
# Update sai.profile with MAC_ADDRESS and WARM_BOOT settings
223232
echo "DEVICE_MAC_ADDRESS=$MAC_ADDRESS" >> /tmp/sai.profile
224233
echo "SAI_WARM_BOOT_WRITE_FILE=/var/warmboot/" >> /tmp/sai.profile

0 commit comments

Comments
 (0)