From 3daf6989af3f4cb9dac53be7cff72cba8a82aea8 Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Tue, 3 Nov 2020 23:37:07 -0800 Subject: [PATCH 1/2] Per-switching silicon Common config for Broadcom Supported Platforms --- syncd/scripts/syncd_init_common.sh | 51 +++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) mode change 100755 => 100644 syncd/scripts/syncd_init_common.sh diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh old mode 100755 new mode 100644 index 0bc4df40a..917131922 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -87,7 +87,56 @@ function set_start_type() config_syncd_bcm() { - if [ -f "/etc/sai.d/sai.profile" ]; then + PLATFORM_COMMON_DIR=/usr/share/sonic/device/x86_64-broadcom_common + + cp -f $HWSKU_DIR/*.config.bcm /tmp + cp -f /etc/sai.d/sai.profile /tmp + CONFIG_BCM=$(find /tmp -name '*.bcm') + PLT_CONFIG_BCM=$(find $HWSKU_DIR -name '*.bcm') + SAI_PROFILE=$(find /tmp -name 'sai.profile') + sed -i 's+/usr/share/sonic/hwsku+/tmp+g' $SAI_PROFILE + + #Get first three characters of chip id + readline=$(grep '0x14e4' /proc/linux-kernel-bde) + chip_id=${readline#*0x14e4:0x} + chip_id=${chip_id::3} + COMMON_CONFIG_BCM=$(find $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id} -name '*.bcm') + + if [ -f $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id}/*.bcm ]; then + for file in $CONFIG_BCM; do + echo "" >> $file + echo "# Start of chip common properties" >> $file + while read line + do + line=$( echo $line | xargs ) + if [ ! -z "$line" ];then + if [ "${line::1}" == '#' ];then + echo $line >> $file + else + sedline=${line%=*} + if grep -q $sedline $file ;then + echo "Keep the config $(grep $sedline $file) in $file" + else + echo $line >> $file + fi + fi + fi + done < $COMMON_CONFIG_BCM + echo "# End of chip common properties" >> $file + done + echo "Merging $PLT_CONFIG_BCM with $COMMON_CONFIG_BCM, merge files stored in $CONFIG_BCM" + fi + + #sync the file system + sync + + # copy the final config.bcm and sai.profile to the shared folder for 'show tech' + cp -f /tmp/sai.profile /var/run/sswsyncd/ + cp -f /tmp/*.bcm /var/run/sswsyncd/ + + if [ -f "/tmp/sai.profile" ]; then + CMD_ARGS+=" -p /tmp/sai.profile" + elif [ -f "/etc/sai.d/sai.profile" ]; then CMD_ARGS+=" -p /etc/sai.d/sai.profile" else CMD_ARGS+=" -p $HWSKU_DIR/sai.profile" From 6fe9f43acb9f0cc0a69c6e86814356b5df6ac16c Mon Sep 17 00:00:00 2001 From: Geans Pin Date: Mon, 9 Nov 2020 00:16:29 -0800 Subject: [PATCH 2/2] Fix review comment --- syncd/scripts/syncd_init_common.sh | 112 ++++++++++++++++------------- 1 file changed, 63 insertions(+), 49 deletions(-) diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index 917131922..f08a460cb 100644 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -87,64 +87,78 @@ function set_start_type() config_syncd_bcm() { - PLATFORM_COMMON_DIR=/usr/share/sonic/device/x86_64-broadcom_common - - cp -f $HWSKU_DIR/*.config.bcm /tmp - cp -f /etc/sai.d/sai.profile /tmp - CONFIG_BCM=$(find /tmp -name '*.bcm') - PLT_CONFIG_BCM=$(find $HWSKU_DIR -name '*.bcm') - SAI_PROFILE=$(find /tmp -name 'sai.profile') - sed -i 's+/usr/share/sonic/hwsku+/tmp+g' $SAI_PROFILE - - #Get first three characters of chip id - readline=$(grep '0x14e4' /proc/linux-kernel-bde) - chip_id=${readline#*0x14e4:0x} - chip_id=${chip_id::3} - COMMON_CONFIG_BCM=$(find $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id} -name '*.bcm') - - if [ -f $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id}/*.bcm ]; then - for file in $CONFIG_BCM; do - echo "" >> $file - echo "# Start of chip common properties" >> $file - while read line - do - line=$( echo $line | xargs ) - if [ ! -z "$line" ];then - if [ "${line::1}" == '#' ];then - echo $line >> $file - else - sedline=${line%=*} - if grep -q $sedline $file ;then - echo "Keep the config $(grep $sedline $file) in $file" - else - echo $line >> $file - fi - fi - fi - done < $COMMON_CONFIG_BCM - echo "# End of chip common properties" >> $file - done - echo "Merging $PLT_CONFIG_BCM with $COMMON_CONFIG_BCM, merge files stored in $CONFIG_BCM" - fi - #sync the file system - sync + if [ -f $PLATFORM_DIR/common_config_support ];then + + PLATFORM_COMMON_DIR=/usr/share/sonic/device/x86_64-broadcom_common + + cp -f $HWSKU_DIR/*.config.bcm /tmp + cp -f /etc/sai.d/sai.profile /tmp + CONFIG_BCM=$(find /tmp -name '*.bcm') + PLT_CONFIG_BCM=$(find $HWSKU_DIR -name '*.bcm') + SAI_PROFILE=$(find /tmp -name 'sai.profile') + sed -i 's+/usr/share/sonic/hwsku+/tmp+g' $SAI_PROFILE - # copy the final config.bcm and sai.profile to the shared folder for 'show tech' - cp -f /tmp/sai.profile /var/run/sswsyncd/ - cp -f /tmp/*.bcm /var/run/sswsyncd/ + #Get first three characters of chip id + readline=$(grep '0x14e4' /proc/linux-kernel-bde) + chip_id=${readline#*0x14e4:0x} + chip_id=${chip_id::3} + COMMON_CONFIG_BCM=$(find $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id} -name '*.bcm') + + if [ -f $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id}/*.bcm ]; then + for file in $CONFIG_BCM; do + echo "" >> $file + echo "# Start of chip common properties" >> $file + while read line + do + line=$( echo $line | xargs ) + if [ ! -z "$line" ];then + if [ "${line::1}" == '#' ];then + echo $line >> $file + else + sedline=${line%=*} + if grep -q $sedline $file ;then + echo "Keep the config $(grep $sedline $file) in $file" + else + echo $line >> $file + fi + fi + fi + done < $COMMON_CONFIG_BCM + echo "# End of chip common properties" >> $file + done + echo "Merging $PLT_CONFIG_BCM with $COMMON_CONFIG_BCM, merge files stored in $CONFIG_BCM" + fi + + #sync the file system + sync + + # copy the final config.bcm and sai.profile to the shared folder for 'show tech' + cp -f /tmp/sai.profile /var/run/sswsyncd/ + cp -f /tmp/*.bcm /var/run/sswsyncd/ + + if [ -f "/tmp/sai.profile" ]; then + CMD_ARGS+=" -p /tmp/sai.profile" + elif [ -f "/etc/sai.d/sai.profile" ]; then + CMD_ARGS+=" -p /etc/sai.d/sai.profile" + else + CMD_ARGS+=" -p $HWSKU_DIR/sai.profile" + fi - if [ -f "/tmp/sai.profile" ]; then - CMD_ARGS+=" -p /tmp/sai.profile" - elif [ -f "/etc/sai.d/sai.profile" ]; then - CMD_ARGS+=" -p /etc/sai.d/sai.profile" else - CMD_ARGS+=" -p $HWSKU_DIR/sai.profile" + + if [ -f "/etc/sai.d/sai.profile" ]; then + CMD_ARGS+=" -p /etc/sai.d/sai.profile" + else + CMD_ARGS+=" -p $HWSKU_DIR/sai.profile" + fi + fi [ -e /dev/linux-bcm-knet ] || mknod /dev/linux-bcm-knet c 122 0 [ -e /dev/linux-user-bde ] || mknod /dev/linux-user-bde c 126 0 [ -e /dev/linux-kernel-bde ] || mknod /dev/linux-kernel-bde c 127 0 + } config_syncd_mlnx()