diff --git a/.gitignore b/.gitignore index e75c54cd428d..37ee9e6216f6 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,12 @@ src/sonic-device-data/src/debian/ src/supervisor/* !src/supervisor/Makefile !src/supervisor/patch/ +src/telemetry/debian/* +!src/telemetry/debian/changelog +!src/telemetry/debian/compat +!src/telemetry/debian/control +!src/telemetry/debian/rules +!src/telemetry/debian/telemetry.init.d src/thrift/* !src/thrift/Makefile diff --git a/device/arista/x86_64-arista_7170_64c/Arista-7170-Q59S20/port_config.ini b/device/arista/x86_64-arista_7170_64c/Arista-7170-Q59S20/port_config.ini index c12c9c5b83b2..cf01e339b810 100644 --- a/device/arista/x86_64-arista_7170_64c/Arista-7170-Q59S20/port_config.ini +++ b/device/arista/x86_64-arista_7170_64c/Arista-7170-Q59S20/port_config.ini @@ -1,80 +1,80 @@ -# name lanes alias speed index -Ethernet0 0,1,2,3 Ethernet1/1 40000 1 -Ethernet4 4,5,6,7 Ethernet2/1 40000 2 -Ethernet8 8,9,10,11 Ethernet3/1 40000 3 -Ethernet12 12,13,14,15 Ethernet4/1 40000 4 -Ethernet16 16,17,18,19 Ethernet5/1 40000 5 -Ethernet20 20,21,22,23 Ethernet6/1 40000 6 -Ethernet24 24,25,26,27 Ethernet7/1 40000 7 -Ethernet28 28,29,30,31 Ethernet8/1 40000 8 -Ethernet32 32,33,34,35 Ethernet9/1 40000 9 -Ethernet36 36,37,38,39 Ethernet10/1 40000 10 -Ethernet40 40,41,42,43 Ethernet11/1 40000 11 -Ethernet44 44,45,46,47 Ethernet12/1 40000 12 -Ethernet48 48,49,50,51 Ethernet13/1 40000 13 -Ethernet52 52,53,54,55 Ethernet14/1 40000 14 -Ethernet56 56,57,58,59 Ethernet15/1 40000 15 -Ethernet60 60,61,62,63 Ethernet16/1 40000 16 -Ethernet64 64,65,66,67 Ethernet17/1 40000 17 -Ethernet68 68,69,70,71 Ethernet18/1 40000 18 -Ethernet72 72,73,74,75 Ethernet19/1 40000 19 -Ethernet76 76,77,78,79 Ethernet20/1 40000 20 -Ethernet80 80 Ethernet21/1 10000 21 -Ethernet80 81 Ethernet21/2 10000 22 -Ethernet80 82 Ethernet21/3 10000 23 -Ethernet80 83 Ethernet21/4 10000 24 -Ethernet84 84 Ethernet22/1 10000 25 -Ethernet84 85 Ethernet22/2 10000 26 -Ethernet84 86 Ethernet22/3 10000 27 -Ethernet84 87 Ethernet22/4 10000 28 -Ethernet88 88,89,90,91 Ethernet23/1 40000 29 -Ethernet92 92,93,94,95 Ethernet24/1 40000 30 -Ethernet96 96,97,98,99 Ethernet25/1 40000 31 -Ethernet100 100,101,102,103 Ethernet26/1 40000 32 -Ethernet104 104,105,106,107 Ethernet27/1 40000 33 -Ethernet108 108,109,110,111 Ethernet28/1 40000 34 -Ethernet112 112,113,114,115 Ethernet29/1 40000 35 -Ethernet116 116,117,118,119 Ethernet30/1 40000 36 -Ethernet120 120,121,122,123 Ethernet31/1 40000 37 -Ethernet124 124,125,126,127 Ethernet32/1 40000 38 -Ethernet128 128 Ethernet33/1 10000 39 -Ethernet129 129 Ethernet33/2 10000 40 -Ethernet130 130 Ethernet33/3 10000 41 -Ethernet131 131 Ethernet33/4 10000 42 -Ethernet132 132 Ethernet34/1 10000 43 -Ethernet133 133 Ethernet34/2 10000 44 -Ethernet134 134 Ethernet34/3 10000 45 -Ethernet135 135 Ethernet34/4 10000 46 -Ethernet136 136 Ethernet35/1 10000 47 -Ethernet137 137 Ethernet35/2 10000 48 -Ethernet138 138 Ethernet35/3 10000 49 -Ethernet139 139 Ethernet35/4 10000 50 -Ethernet140 140,141,142,143 Ethernet36/1 40000 51 -Ethernet144 144,145,146,147 Ethernet37/1 40000 52 -Ethernet148 148,149,150,151 Ethernet38/1 40000 53 -Ethernet152 152,153,154,155 Ethernet39/1 40000 54 -Ethernet156 156,157,158,159 Ethernet40/1 40000 55 -Ethernet160 160,161,162,163 Ethernet41/1 40000 56 -Ethernet164 164,165,166,167 Ethernet42/1 40000 57 -Ethernet168 168,169,170,171 Ethernet43/1 40000 58 -Ethernet172 172,173,174,175 Ethernet44/1 40000 59 -Ethernet176 176,177,178,179 Ethernet45/1 40000 60 -Ethernet180 180,181,182,183 Ethernet46/1 40000 61 -Ethernet184 184,185,186,187 Ethernet47/1 40000 62 -Ethernet188 188,189,190,191 Ethernet48/1 40000 63 -Ethernet192 192,193,194,195 Ethernet49/1 40000 64 -Ethernet196 196,197,198,199 Ethernet50/1 40000 65 -Ethernet200 200,201,202,203 Ethernet51/1 40000 66 -Ethernet204 204,205,206,207 Ethernet52/1 40000 67 -Ethernet208 208,209,210,211 Ethernet53/1 40000 68 -Ethernet212 212,213,214,215 Ethernet54/1 40000 69 -Ethernet216 216,217,218,219 Ethernet55/1 40000 70 -Ethernet220 220,221,222,223 Ethernet56/1 40000 71 -Ethernet224 224,225,226,227 Ethernet57/1 40000 72 -Ethernet228 228,229,230,231 Ethernet58/1 40000 73 -Ethernet232 232,233,234,235 Ethernet59/1 40000 74 -Ethernet236 236,237,238,239 Ethernet60/1 40000 75 -Ethernet240 240,241,242,243 Ethernet61/1 40000 76 -Ethernet244 244,245,246,247 Ethernet62/1 40000 77 -Ethernet248 248,249,250,251 Ethernet63/1 40000 78 -Ethernet252 252,253,254,255 Ethernet64/1 40000 79 +# name lanes alias speed index autoneg +Ethernet0 0,1,2,3 Ethernet1/1 40000 1 0 +Ethernet4 4,5,6,7 Ethernet2/1 40000 2 0 +Ethernet8 8,9,10,11 Ethernet3/1 40000 3 0 +Ethernet12 12,13,14,15 Ethernet4/1 40000 4 0 +Ethernet16 16,17,18,19 Ethernet5/1 40000 5 0 +Ethernet20 20,21,22,23 Ethernet6/1 40000 6 0 +Ethernet24 24,25,26,27 Ethernet7/1 40000 7 0 +Ethernet28 28,29,30,31 Ethernet8/1 40000 8 0 +Ethernet32 32,33,34,35 Ethernet9/1 40000 9 1 +Ethernet36 36,37,38,39 Ethernet10/1 40000 10 1 +Ethernet40 40,41,42,43 Ethernet11/1 40000 11 1 +Ethernet44 44,45,46,47 Ethernet12/1 40000 12 1 +Ethernet48 48,49,50,51 Ethernet13/1 40000 13 1 +Ethernet52 52,53,54,55 Ethernet14/1 40000 14 1 +Ethernet56 56,57,58,59 Ethernet15/1 40000 15 1 +Ethernet60 60,61,62,63 Ethernet16/1 40000 16 1 +Ethernet64 64,65,66,67 Ethernet17/1 40000 17 1 +Ethernet68 68,69,70,71 Ethernet18/1 40000 18 1 +Ethernet72 72,73,74,75 Ethernet19/1 40000 19 1 +Ethernet76 76,77,78,79 Ethernet20/1 40000 20 1 +Ethernet80 80 Ethernet21/1 10000 21 0 +Ethernet81 81 Ethernet21/2 10000 21 0 +Ethernet82 82 Ethernet21/3 10000 21 0 +Ethernet83 83 Ethernet21/4 10000 21 0 +Ethernet84 84 Ethernet22/1 10000 22 0 +Ethernet85 85 Ethernet22/2 10000 22 0 +Ethernet86 86 Ethernet22/3 10000 22 0 +Ethernet87 87 Ethernet22/4 10000 22 0 +Ethernet88 88,89,90,91 Ethernet23/1 40000 23 0 +Ethernet92 92,93,94,95 Ethernet24/1 40000 24 0 +Ethernet96 96,97,98,99 Ethernet25/1 40000 25 0 +Ethernet100 100,101,102,103 Ethernet26/1 40000 26 0 +Ethernet104 104,105,106,107 Ethernet27/1 40000 27 0 +Ethernet108 108,109,110,111 Ethernet28/1 40000 28 0 +Ethernet112 112,113,114,115 Ethernet29/1 40000 29 0 +Ethernet116 116,117,118,119 Ethernet30/1 40000 30 0 +Ethernet120 120,121,122,123 Ethernet31/1 40000 31 0 +Ethernet124 124,125,126,127 Ethernet32/1 40000 32 0 +Ethernet128 128 Ethernet33/1 10000 33 0 +Ethernet129 129 Ethernet33/2 10000 33 0 +Ethernet130 130 Ethernet33/3 10000 33 0 +Ethernet131 131 Ethernet33/4 10000 33 0 +Ethernet132 132 Ethernet34/1 10000 34 0 +Ethernet133 133 Ethernet34/2 10000 34 0 +Ethernet134 134 Ethernet34/3 10000 34 0 +Ethernet135 135 Ethernet34/4 10000 34 0 +Ethernet136 136 Ethernet35/1 10000 35 0 +Ethernet137 137 Ethernet35/2 10000 35 0 +Ethernet138 138 Ethernet35/3 10000 35 0 +Ethernet139 139 Ethernet35/4 10000 35 0 +Ethernet140 140,141,142,143 Ethernet36/1 40000 36 0 +Ethernet144 144,145,146,147 Ethernet37/1 40000 37 0 +Ethernet148 148,149,150,151 Ethernet38/1 40000 38 0 +Ethernet152 152,153,154,155 Ethernet39/1 40000 39 0 +Ethernet156 156,157,158,159 Ethernet40/1 40000 40 0 +Ethernet160 160,161,162,163 Ethernet41/1 40000 41 1 +Ethernet164 164,165,166,167 Ethernet42/1 40000 42 1 +Ethernet168 168,169,170,171 Ethernet43/1 40000 43 1 +Ethernet172 172,173,174,175 Ethernet44/1 40000 44 1 +Ethernet176 176,177,178,179 Ethernet45/1 40000 45 1 +Ethernet180 180,181,182,183 Ethernet46/1 40000 46 1 +Ethernet184 184,185,186,187 Ethernet47/1 40000 47 1 +Ethernet188 188,189,190,191 Ethernet48/1 40000 48 1 +Ethernet192 192,193,194,195 Ethernet49/1 40000 49 1 +Ethernet196 196,197,198,199 Ethernet50/1 40000 50 1 +Ethernet200 200,201,202,203 Ethernet51/1 40000 51 1 +Ethernet204 204,205,206,207 Ethernet52/1 40000 52 1 +Ethernet208 208,209,210,211 Ethernet53/1 40000 53 1 +Ethernet212 212,213,214,215 Ethernet54/1 40000 54 1 +Ethernet216 216,217,218,219 Ethernet55/1 40000 55 1 +Ethernet220 220,221,222,223 Ethernet56/1 40000 56 1 +Ethernet224 224,225,226,227 Ethernet57/1 40000 57 1 +Ethernet228 228,229,230,231 Ethernet58/1 40000 58 1 +Ethernet232 232,233,234,235 Ethernet59/1 40000 59 1 +Ethernet236 236,237,238,239 Ethernet60/1 40000 60 1 +Ethernet240 240,241,242,243 Ethernet61/1 40000 61 1 +Ethernet244 244,245,246,247 Ethernet62/1 40000 62 1 +Ethernet248 248,249,250,251 Ethernet63/1 40000 63 1 +Ethernet252 252,253,254,255 Ethernet64/1 40000 64 1 diff --git a/device/mellanox/x86_64-mlnx_lssn2700-r0/platform_wait b/device/mellanox/x86_64-mlnx_lssn2700-r0/platform_wait new file mode 120000 index 000000000000..4b30bd429854 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_lssn2700-r0/platform_wait @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/platform_wait \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_lssn2700-r0/pmon_daemon_control.json b/device/mellanox/x86_64-mlnx_lssn2700-r0/pmon_daemon_control.json new file mode 120000 index 000000000000..435a2ce7c0ba --- /dev/null +++ b/device/mellanox/x86_64-mlnx_lssn2700-r0/pmon_daemon_control.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/pmon_daemon_control.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2010-r0/platform_wait b/device/mellanox/x86_64-mlnx_msn2010-r0/platform_wait new file mode 120000 index 000000000000..4b30bd429854 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2010-r0/platform_wait @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/platform_wait \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py index 914ef050d2c7..a51a9b07292c 100644 --- a/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py @@ -20,14 +20,10 @@ class PsuUtil(PsuBase): def __init__(self): PsuBase.__init__(self) - self.psu_path = "" - for index in range(0, 100): - hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index) - if os.path.exists(hwmon_path): - self.psu_path = hwmon_path - break - self.psu_presence = "pwr{}" - self.psu_oper_status = "pwr{}" + + self.psu_path = "/var/run/hw-management/thermal/" + self.psu_presence = "psu{}_pwr_status" + self.psu_oper_status = "psu{}_pwr_status" def get_num_psus(self): """ diff --git a/device/mellanox/x86_64-mlnx_msn2010-r0/pmon_daemon_control.json b/device/mellanox/x86_64-mlnx_msn2010-r0/pmon_daemon_control.json new file mode 120000 index 000000000000..435a2ce7c0ba --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2010-r0/pmon_daemon_control.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/pmon_daemon_control.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2010-r0/sensors.conf b/device/mellanox/x86_64-mlnx_msn2010-r0/sensors.conf index 170b0371fb0d..3b68f775df2d 100644 --- a/device/mellanox/x86_64-mlnx_msn2010-r0/sensors.conf +++ b/device/mellanox/x86_64-mlnx_msn2010-r0/sensors.conf @@ -17,3 +17,76 @@ chip "tps53679-*" label pout2 "TPS pout2" label iout1 "TPS iout1" label iout2 "TPS iout2" + +chip "mlxsw-*" + ignore temp2 + ignore temp3 + ignore temp4 + ignore temp5 + ignore temp6 + ignore temp7 + ignore temp8 + ignore temp9 + ignore temp10 + ignore temp11 + ignore temp12 + ignore temp13 + ignore temp14 + ignore temp15 + ignore temp16 + ignore temp17 + ignore temp18 + ignore temp19 + ignore temp20 + ignore temp21 + ignore temp22 + ignore temp23 + ignore temp24 + ignore temp25 + ignore temp26 + ignore temp27 + ignore temp28 + ignore temp29 + ignore temp30 + ignore temp31 + ignore temp32 + ignore temp33 + ignore temp34 + ignore temp35 + ignore temp36 + ignore temp37 + ignore temp38 + ignore temp39 + ignore temp40 + ignore temp41 + ignore temp42 + ignore temp43 + ignore temp44 + ignore temp45 + ignore temp46 + ignore temp47 + ignore temp48 + ignore temp49 + ignore temp50 + ignore temp51 + ignore temp52 + ignore temp53 + ignore temp54 + ignore temp55 + ignore temp56 + ignore temp57 + ignore temp58 + ignore temp59 + ignore temp60 + ignore temp61 + ignore temp62 + ignore temp63 + ignore temp64 + +chip "*-virtual-*" + ignore temp1 + ignore temp2 + +chip "dps460-*" + ignore fan2 + ignore fan3 diff --git a/device/mellanox/x86_64-mlnx_msn2100-r0/platform_wait b/device/mellanox/x86_64-mlnx_msn2100-r0/platform_wait new file mode 120000 index 000000000000..4b30bd429854 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2100-r0/platform_wait @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/platform_wait \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py index b9bb580d7c57..b14b1d9dac4d 100644 --- a/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py @@ -21,14 +21,9 @@ class PsuUtil(PsuBase): def __init__(self): PsuBase.__init__(self) - self.psu_path = "" - for index in range(0, 100): - hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index) - if os.path.exists(hwmon_path): - self.psu_path = hwmon_path - break - self.psu_presence = "pwr{}" - self.psu_oper_status = "pwr{}" + self.psu_path = "/var/run/hw-management/thermal/" + self.psu_presence = "psu{}_status" + self.psu_oper_status = "psu{}_pwr_status" def get_num_psus(self): """ diff --git a/device/mellanox/x86_64-mlnx_msn2100-r0/pmon_daemon_control.json b/device/mellanox/x86_64-mlnx_msn2100-r0/pmon_daemon_control.json new file mode 120000 index 000000000000..435a2ce7c0ba --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2100-r0/pmon_daemon_control.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/pmon_daemon_control.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2410-r0/platform_wait b/device/mellanox/x86_64-mlnx_msn2410-r0/platform_wait new file mode 120000 index 000000000000..4b30bd429854 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2410-r0/platform_wait @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/platform_wait \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2410-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2410-r0/plugins/psuutil.py index 954045dde59c..f3cce52b12aa 100644 --- a/device/mellanox/x86_64-mlnx_msn2410-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2410-r0/plugins/psuutil.py @@ -21,14 +21,9 @@ class PsuUtil(PsuBase): def __init__(self): PsuBase.__init__(self) - self.psu_path = "" - for index in range(0, 100): - hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index) - if os.path.exists(hwmon_path): - self.psu_path = hwmon_path - break - self.psu_presence = "psu{}" - self.psu_oper_status = "pwr{}" + self.psu_path = "/var/run/hw-management/thermal/" + self.psu_presence = "psu{}_status" + self.psu_oper_status = "psu{}_pwr_status" def get_num_psus(self): """ diff --git a/device/mellanox/x86_64-mlnx_msn2410-r0/pmon_daemon_control.json b/device/mellanox/x86_64-mlnx_msn2410-r0/pmon_daemon_control.json new file mode 120000 index 000000000000..435a2ce7c0ba --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2410-r0/pmon_daemon_control.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/pmon_daemon_control.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/platform_wait b/device/mellanox/x86_64-mlnx_msn2700-r0/platform_wait new file mode 100755 index 000000000000..44321184dccc --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/platform_wait @@ -0,0 +1,40 @@ +#!/bin/bash + +declare -r EXIT_SUCCESS="0" +declare -r EXIT_TIMEOUT="1" + +declare -r QSFP_PATH="/var/run/hw-management/qsfp" + +function WaitForQsfpReady() { + local -r _QSFP_PATH="${1}" + + local -i _WDOG_CNT="1" + local -ir _WDOG_MAX="300" + + local -r _TIMEOUT="1s" + + while [[ "${_WDOG_CNT}" -le "${_WDOG_MAX}" ]]; do + for _QSFP in ${_QSFP_PATH}/qsfp*; do + if [[ -e "${_QSFP}" ]]; then + return "${EXIT_SUCCESS}" + fi + done + + let "_WDOG_CNT++" + sleep "${_TIMEOUT}" + done + + return "${EXIT_TIMEOUT}" +} + +echo "Wait for QSFP I2C interface is ready" + +WaitForQsfpReady "${QSFP_PATH}" +EXIT_CODE="$?" +if [[ "${EXIT_CODE}" != "${EXIT_SUCCESS}" ]]; then + echo "QSFP I2C interface is not ready: timeout" + exit "${EXIT_CODE}" +fi + +echo "QSFP I2C interface is ready: mlxsw_minimal has finished initialization" +exit "${EXIT_SUCCESS}" diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/eeprom.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/eeprom.py index 3d7e8d0556d5..63303c13a244 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/eeprom.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/eeprom.py @@ -26,7 +26,7 @@ raise ImportError (str(e) + "- required module not found") SYSLOG_IDENTIFIER = "eeprom.py" -EEPROM_SYMLINK = "/bsp/eeprom/vpd_info" +EEPROM_SYMLINK = "/var/run/hw-management/eeprom/vpd_info" CACHE_FILE = "/var/cache/sonic/decode-syseeprom/syseeprom_cache" def log_error(msg): diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py index 954045dde59c..f3cce52b12aa 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py @@ -21,14 +21,9 @@ class PsuUtil(PsuBase): def __init__(self): PsuBase.__init__(self) - self.psu_path = "" - for index in range(0, 100): - hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index) - if os.path.exists(hwmon_path): - self.psu_path = hwmon_path - break - self.psu_presence = "psu{}" - self.psu_oper_status = "pwr{}" + self.psu_path = "/var/run/hw-management/thermal/" + self.psu_presence = "psu{}_status" + self.psu_oper_status = "psu{}_pwr_status" def get_num_psus(self): """ diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py index 34f285bf7c63..2a69cb63a709 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py @@ -22,7 +22,7 @@ # magic code defnition for port number, qsfp port position of each hwsku # port_position_tuple = (PORT_START, QSFP_PORT_START, PORT_END, PORT_IN_BLOCK, EEPROM_OFFSET) -hwsku_dict = {'ACS-MSN2700': 0, "LS-SN2700":0, 'ACS-MSN2740': 0, 'ACS-MSN2100': 1, 'ACS-MSN2410': 2, 'ACS-MSN2010': 3, 'ACS-MSN3700': 0, 'ACS-MSN3700C': 0} +hwsku_dict = {'ACS-MSN2700': 0, "LS-SN2700":0, 'ACS-MSN2740': 0, 'ACS-MSN2100': 1, 'ACS-MSN2410': 2, 'ACS-MSN2010': 3, 'ACS-MSN3700': 0, 'ACS-MSN3700C': 0, 'Mellanox-SN2700': 0, 'Mellanox-SN2700-D48C8': 0} port_position_tuple_list = [(0, 0, 31, 32, 1), (0, 0, 15, 16, 1), (0, 48, 55, 56, 1),(0, 18, 21, 22, 1)] class SfpUtil(SfpUtilBase): @@ -41,7 +41,7 @@ class SfpUtil(SfpUtilBase): db_sel_tbl = None state_db = None sfpd_status_tbl = None - qsfp_sysfs_path = "/sys/devices/platform/i2c_mlxcpld.1/i2c-1/i2c-2/2-0048/" + qsfp_sysfs_path = "/var/run/hw-management/qsfp/" @property def port_start(self): diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/pmon_daemon_control.json b/device/mellanox/x86_64-mlnx_msn2700-r0/pmon_daemon_control.json new file mode 100644 index 000000000000..6092a26f30f8 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/pmon_daemon_control.json @@ -0,0 +1,4 @@ +{ + "skip_ledd": true +} + diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/sensors.conf b/device/mellanox/x86_64-mlnx_msn2700-r0/sensors.conf index a3e30391863e..247db54f99d8 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/sensors.conf +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/sensors.conf @@ -19,3 +19,77 @@ chip "ucd9200-i2c-5-41" bus "i2c-17" "i2c-1-mux (chan_id 7)" chip "lm75-i2c-17-49" label temp1 "Ambient Board Temp" + +chip "mlxsw-*" + ignore temp2 + ignore temp3 + ignore temp4 + ignore temp5 + ignore temp6 + ignore temp7 + ignore temp8 + ignore temp9 + ignore temp10 + ignore temp11 + ignore temp12 + ignore temp13 + ignore temp14 + ignore temp15 + ignore temp16 + ignore temp17 + ignore temp18 + ignore temp19 + ignore temp20 + ignore temp21 + ignore temp22 + ignore temp23 + ignore temp24 + ignore temp25 + ignore temp26 + ignore temp27 + ignore temp28 + ignore temp29 + ignore temp30 + ignore temp31 + ignore temp32 + ignore temp33 + ignore temp34 + ignore temp35 + ignore temp36 + ignore temp37 + ignore temp38 + ignore temp39 + ignore temp40 + ignore temp41 + ignore temp42 + ignore temp43 + ignore temp44 + ignore temp45 + ignore temp46 + ignore temp47 + ignore temp48 + ignore temp49 + ignore temp50 + ignore temp51 + ignore temp52 + ignore temp53 + ignore temp54 + ignore temp55 + ignore temp56 + ignore temp57 + ignore temp58 + ignore temp59 + ignore temp60 + ignore temp61 + ignore temp62 + ignore temp63 + ignore temp64 + +chip "*-virtual-*" + ignore temp1 + ignore temp2 + +chip "dps460-*" + ignore fan2 + ignore fan3 + diff --git a/device/mellanox/x86_64-mlnx_msn2740-r0/platform_wait b/device/mellanox/x86_64-mlnx_msn2740-r0/platform_wait new file mode 120000 index 000000000000..4b30bd429854 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2740-r0/platform_wait @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/platform_wait \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2740-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2740-r0/plugins/psuutil.py index 8c47a0083249..f3cce52b12aa 100644 --- a/device/mellanox/x86_64-mlnx_msn2740-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2740-r0/plugins/psuutil.py @@ -20,14 +20,10 @@ class PsuUtil(PsuBase): def __init__(self): PsuBase.__init__(self) - self.psu_path = "" - for index in range(0, 100): - hwmon_path = "/sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon/hwmon{}/".format(index) - if os.path.exists(hwmon_path): - self.psu_path = hwmon_path - break - self.psu_presence = "psu{}" - self.psu_oper_status = "pwr{}" + + self.psu_path = "/var/run/hw-management/thermal/" + self.psu_presence = "psu{}_status" + self.psu_oper_status = "psu{}_pwr_status" def get_num_psus(self): """ diff --git a/device/mellanox/x86_64-mlnx_msn2740-r0/pmon_daemon_control.json b/device/mellanox/x86_64-mlnx_msn2740-r0/pmon_daemon_control.json new file mode 120000 index 000000000000..435a2ce7c0ba --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2740-r0/pmon_daemon_control.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/pmon_daemon_control.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn3700-r0/platform_wait b/device/mellanox/x86_64-mlnx_msn3700-r0/platform_wait new file mode 120000 index 000000000000..4b30bd429854 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn3700-r0/platform_wait @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/platform_wait \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn3700-r0/pmon_daemon_control.json b/device/mellanox/x86_64-mlnx_msn3700-r0/pmon_daemon_control.json new file mode 120000 index 000000000000..435a2ce7c0ba --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn3700-r0/pmon_daemon_control.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/pmon_daemon_control.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn3700-r0/sensors.conf b/device/mellanox/x86_64-mlnx_msn3700-r0/sensors.conf index 592964d75c52..376d079390a6 100644 --- a/device/mellanox/x86_64-mlnx_msn3700-r0/sensors.conf +++ b/device/mellanox/x86_64-mlnx_msn3700-r0/sensors.conf @@ -1,7 +1,7 @@ ################################################################################ # Copyright (c) 2019 Mellanox Technologies # -# Platform specific sensors config for MSN3700 +# Platform specific sensors config for SN3700 ################################################################################ # Temperature sensors @@ -15,6 +15,10 @@ bus "i2c-7" "i2c-1-mux (chan_id 6)" chip "tmp102-i2c-*-4a" label temp1 "Ambient Port Side Temp (air exhaust)" +bus "i2c-15" "i2c-1-mux (chan_id 6)" + chip "tmp102-i2c-15-49" + label temp1 "Ambient COMEX Temp" + # Power controllers bus "i2c-5" "i2c-1-mux (chan_id 4)" chip "tps53679-i2c-*-70" @@ -30,6 +34,7 @@ bus "i2c-5" "i2c-1-mux (chan_id 4)" chip "tps53679-i2c-*-71" label in1 "PMIC-2 PSU 12V Rail (in)" label in2 "PMIC-2 ASIC 3.3V Rail (out)" + compute in2 (1.5)*@, @/(1.5) label in3 "PMIC-2 ASIC 1.8V Rail (out)" label temp1 "PMIC-2 Temp 1" label temp2 "PMIC-2 Temp 2" @@ -38,6 +43,28 @@ bus "i2c-5" "i2c-1-mux (chan_id 4)" label curr1 "PMIC-2 ASIC 3.3V Rail Curr (out)" label curr2 "PMIC-2 ASIC 1.8V Rail Curr (out)" +bus "i2c-15" "i2c-1-mux (chan_id 6)" + chip "tps53679-i2c-*-58" + label in1 "PMIC-3 PSU 12V Rail (in)" + label in2 "PMIC-3 COMEX 1.8V Rail (out)" + label in3 "PMIC-3 COMEX 1.05V Rail (out)" + label temp1 "PMIC-3 Temp 1" + label temp2 "PMIC-3 Temp 2" + label power1 "PMIC-3 COMEX 1.8V Rail Pwr (out)" + label power2 "PMIC-3 COMEX 1.05V Rail Pwr (out)" + label curr1 "PMIC-3 COMEX 1.8V Rail Curr (out)" + label curr2 "PMIC-3 COMEX 1.05V Rail Curr (out)" + chip "tps53679-i2c-*-61" + label in1 "PMIC-4 PSU 12V Rail (in)" + label in2 "PMIC-4 COMEX 1.2V Rail (out)" + ignore in3 + label temp1 "PMIC-4 Temp 1" + label temp2 "PMIC-4 Temp 2" + label power1 "PMIC-4 COMEX 1.2V Rail Pwr (out)" + ignore power2 + label curr1 "PMIC-4 COMEX 1.2V Rail Curr (out)" + ignore curr2 + # Power supplies bus "i2c-4" "i2c-1-mux (chan_id 3)" chip "dps460-i2c-*-58" diff --git a/device/mellanox/x86_64-mlnx_msn3700c-r0/platform_wait b/device/mellanox/x86_64-mlnx_msn3700c-r0/platform_wait new file mode 120000 index 000000000000..4b30bd429854 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn3700c-r0/platform_wait @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/platform_wait \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn3700c-r0/pmon_daemon_control.json b/device/mellanox/x86_64-mlnx_msn3700c-r0/pmon_daemon_control.json new file mode 120000 index 000000000000..435a2ce7c0ba --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn3700c-r0/pmon_daemon_control.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/pmon_daemon_control.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn3700c-r0/sensors.conf b/device/mellanox/x86_64-mlnx_msn3700c-r0/sensors.conf index 1570ac30b68f..7efcefc5f740 100644 --- a/device/mellanox/x86_64-mlnx_msn3700c-r0/sensors.conf +++ b/device/mellanox/x86_64-mlnx_msn3700c-r0/sensors.conf @@ -1,7 +1,7 @@ ################################################################################ # Copyright (c) 2019 Mellanox Technologies # -# Platform specific sensors config for MSN3700C +# Platform specific sensors config for SN3700C ################################################################################ # Temperature sensors @@ -15,6 +15,10 @@ bus "i2c-7" "i2c-1-mux (chan_id 6)" chip "tmp102-i2c-*-4a" label temp1 "Ambient Port Side Temp (air exhaust)" +bus "i2c-15" "i2c-1-mux (chan_id 6)" + chip "tmp102-i2c-15-49" + label temp1 "Ambient COMEX Temp" + # Power controllers bus "i2c-5" "i2c-1-mux (chan_id 4)" chip "tps53679-i2c-*-70" @@ -30,6 +34,7 @@ bus "i2c-5" "i2c-1-mux (chan_id 4)" chip "tps53679-i2c-*-71" label in1 "PMIC-2 PSU 12V Rail (in)" label in2 "PMIC-2 ASIC 3.3V Rail (out)" + compute in2 (1.5)*@, @/(1.5) label in3 "PMIC-2 ASIC 1.8V Rail (out)" label temp1 "PMIC-2 Temp 1" label temp2 "PMIC-2 Temp 2" @@ -38,6 +43,28 @@ bus "i2c-5" "i2c-1-mux (chan_id 4)" label curr1 "PMIC-2 ASIC 3.3V Rail Curr (out)" label curr2 "PMIC-2 ASIC 1.8V Rail Curr (out)" +bus "i2c-15" "i2c-1-mux (chan_id 6)" + chip "tps53679-i2c-*-58" + label in1 "PMIC-3 PSU 12V Rail (in)" + label in2 "PMIC-3 COMEX 1.8V Rail (out)" + label in3 "PMIC-3 COMEX 1.05V Rail (out)" + label temp1 "PMIC-3 Temp 1" + label temp2 "PMIC-3 Temp 2" + label power1 "PMIC-3 COMEX 1.8V Rail Pwr (out)" + label power2 "PMIC-3 COMEX 1.05V Rail Pwr (out)" + label curr1 "PMIC-3 COMEX 1.8V Rail Curr (out)" + label curr2 "PMIC-3 COMEX 1.05V Rail Curr (out)" + chip "tps53679-i2c-*-61" + label in1 "PMIC-4 PSU 12V Rail (in)" + label in2 "PMIC-4 COMEX 1.2V Rail (out)" + ignore in3 + label temp1 "PMIC-4 Temp 1" + label temp2 "PMIC-4 Temp 2" + label power1 "PMIC-4 COMEX 1.2V Rail Pwr (out)" + ignore power2 + label curr1 "PMIC-4 COMEX 1.2V Rail Curr (out)" + ignore curr2 + # Power supplies bus "i2c-4" "i2c-1-mux (chan_id 3)" chip "dps460-i2c-*-58" @@ -79,10 +106,6 @@ chip "mlxreg_fan-isa-*" label fan6 "Chassis Fan Drawer-3 Tach 2" label fan7 "Chassis Fan Drawer-4 Tach 1" label fan8 "Chassis Fan Drawer-4 Tach 2" - ignore fan9 - ignore fan10 - ignore fan11 - ignore fan12 # Miscellaneous chip "*-virtual-*" diff --git a/device/mellanox/x86_64-mlnx_x86-r5.0.1400/pmon_daemon_control.json b/device/mellanox/x86_64-mlnx_x86-r5.0.1400/pmon_daemon_control.json new file mode 120000 index 000000000000..435a2ce7c0ba --- /dev/null +++ b/device/mellanox/x86_64-mlnx_x86-r5.0.1400/pmon_daemon_control.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/pmon_daemon_control.json \ No newline at end of file diff --git a/dockers/docker-base-stretch/etc/rsyslog.conf b/dockers/docker-base-stretch/etc/rsyslog.conf index 40c7463afa2d..ef249229ab1e 100644 --- a/dockers/docker-base-stretch/etc/rsyslog.conf +++ b/dockers/docker-base-stretch/etc/rsyslog.conf @@ -10,6 +10,13 @@ ################# $ModLoad imuxsock # provides support for local system logging + +# +# Set a rate limit on messages from the container +# +$SystemLogRateLimitInterval 300 +$SystemLogRateLimitBurst 20000 + #$ModLoad imklog # provides kernel logging support #$ModLoad immark # provides --MARK-- message capability diff --git a/dockers/docker-base/etc/rsyslog.conf b/dockers/docker-base/etc/rsyslog.conf index 863c11d8c17a..4851ac784475 100644 --- a/dockers/docker-base/etc/rsyslog.conf +++ b/dockers/docker-base/etc/rsyslog.conf @@ -14,6 +14,13 @@ ################# $ModLoad imuxsock # provides support for local system logging + +# +# Set a rate limit on messages from the container +# +$SystemLogRateLimitInterval 300 +$SystemLogRateLimitBurst 20000 + #$ModLoad imklog # provides kernel logging support #$ModLoad immark # provides --MARK-- message capability diff --git a/dockers/docker-orchagent/Dockerfile.j2 b/dockers/docker-orchagent/Dockerfile.j2 index 4fcbe08ab7ac..f3108a9d1778 100755 --- a/dockers/docker-orchagent/Dockerfile.j2 +++ b/dockers/docker-orchagent/Dockerfile.j2 @@ -15,7 +15,7 @@ RUN apt-get install -f -y ndisc6 tcpdump python-scapy ## TODO: implicitly install dependencies RUN apt-get -y install libjemalloc1 -RUN apt-get install -y libelf1 libmnl0 +RUN apt-get install -y libelf1 libmnl0 bridge-utils RUN pip install setuptools RUN pip install pyroute2==0.5.3 netifaces==0.10.7 diff --git a/dockers/docker-platform-monitor/Dockerfile.j2 b/dockers/docker-platform-monitor/Dockerfile.j2 index c887e2297e49..4528cd17d327 100755 --- a/dockers/docker-platform-monitor/Dockerfile.j2 +++ b/dockers/docker-platform-monitor/Dockerfile.j2 @@ -55,7 +55,7 @@ RUN apt-get autoclean -y RUN apt-get autoremove -y RUN rm -rf /debs /python-wheels ~/.cache -COPY ["start.sh", "lm-sensors.sh", "/usr/bin/"] -COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] +COPY ["docker_init.sh", "lm-sensors.sh", "/usr/bin/"] +COPY ["docker-pmon.supervisord.conf.j2", "start.sh.j2", "/usr/share/sonic/templates/"] -ENTRYPOINT ["/usr/bin/supervisord"] +ENTRYPOINT ["/usr/bin/docker_init.sh"] diff --git a/dockers/docker-platform-monitor/supervisord.conf b/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 similarity index 90% rename from dockers/docker-platform-monitor/supervisord.conf rename to dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 index 2854d0510f93..a10b94c25e92 100644 --- a/dockers/docker-platform-monitor/supervisord.conf +++ b/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 @@ -37,6 +37,7 @@ autorestart=false stdout_logfile=syslog stderr_logfile=syslog +{% if not skip_ledd %} [program:ledd] command=/usr/bin/ledd priority=5 @@ -45,7 +46,9 @@ autorestart=false stdout_logfile=syslog stderr_logfile=syslog startsecs=0 +{% endif %} +{% if not skip_xcvrd %} [program:xcvrd] command=/usr/bin/xcvrd priority=6 @@ -54,7 +57,9 @@ autorestart=false stdout_logfile=syslog stderr_logfile=syslog startsecs=0 +{% endif %} +{% if not skip_psud %} [program:psud] command=/usr/bin/psud priority=7 @@ -63,4 +68,4 @@ autorestart=false stdout_logfile=syslog stderr_logfile=syslog startsecs=0 - +{% endif %} diff --git a/dockers/docker-platform-monitor/docker_init.sh b/dockers/docker-platform-monitor/docker_init.sh new file mode 100755 index 000000000000..6d04de694feb --- /dev/null +++ b/dockers/docker-platform-monitor/docker_init.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Generate supervisord config file and the start.sh scripts +mkdir -p /etc/supervisor/conf.d/ + +if [ -e /usr/share/sonic/platform/pmon_daemon_control.json ]; then +sonic-cfggen -j /usr/share/sonic/platform/pmon_daemon_control.json -t /usr/share/sonic/templates/docker-pmon.supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf +sonic-cfggen -j /usr/share/sonic/platform/pmon_daemon_control.json -t /usr/share/sonic/templates/start.sh.j2 > /usr/bin/start.sh +chmod +x /usr/bin/start.sh +else +sonic-cfggen -t /usr/share/sonic/templates/docker-pmon.supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf +sonic-cfggen -t /usr/share/sonic/templates/start.sh.j2 > /usr/bin/start.sh +chmod +x /usr/bin/start.sh +fi + +exec /usr/bin/supervisord diff --git a/dockers/docker-platform-monitor/start.sh b/dockers/docker-platform-monitor/start.sh.j2 old mode 100755 new mode 100644 similarity index 67% rename from dockers/docker-platform-monitor/start.sh rename to dockers/docker-platform-monitor/start.sh.j2 index 18541b80fe18..e9f0ebf6cd83 --- a/dockers/docker-platform-monitor/start.sh +++ b/dockers/docker-platform-monitor/start.sh.j2 @@ -1,5 +1,7 @@ #!/usr/bin/env bash +declare -r EXIT_SUCCESS="0" + mkdir -p /var/sonic echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status @@ -7,6 +9,16 @@ rm -f /var/run/rsyslogd.pid supervisorctl start rsyslogd +# If this platform has synchronization script, run it +if [ -e /usr/share/sonic/platform/platform_wait ]; then + /usr/share/sonic/platform/platform_wait + EXIT_CODE="$?" + if [ "${EXIT_CODE}" != "${EXIT_SUCCESS}" ]; then + supervisorctl shutdown + exit "${EXIT_CODE}" + fi +fi + # If this platform has an lm-sensors config file, copy it to it's proper place # and start lm-sensors if [ -e /usr/share/sonic/platform/sensors.conf ]; then @@ -25,8 +37,14 @@ if [ -e /usr/share/sonic/platform/fancontrol ]; then supervisorctl start fancontrol fi +{% if not skip_ledd %} supervisorctl start ledd +{% endif %} +{% if not skip_xcvrd %} supervisorctl start xcvrd +{% endif %} +{% if not skip_psud %} supervisorctl start psud +{% endif %} diff --git a/dockers/docker-router-advertiser/Dockerfile.j2 b/dockers/docker-router-advertiser/Dockerfile.j2 index 40589f2e6e43..9034724abef0 100644 --- a/dockers/docker-router-advertiser/Dockerfile.j2 +++ b/dockers/docker-router-advertiser/Dockerfile.j2 @@ -30,6 +30,6 @@ RUN rm -rf /debs COPY ["start.sh", "/usr/bin/"] COPY ["docker-router-advertiser.supervisord.conf", "/etc/supervisor/conf.d/"] -COPY ["radvd.conf.j2", "/usr/share/sonic/templates/"] +COPY ["radvd.conf.j2", "wait_for_intf.sh.j2", "/usr/share/sonic/templates/"] ENTRYPOINT ["/usr/bin/supervisord"] diff --git a/dockers/docker-router-advertiser/start.sh b/dockers/docker-router-advertiser/start.sh index 159006a176bd..8d5f73a8bcb0 100755 --- a/dockers/docker-router-advertiser/start.sh +++ b/dockers/docker-router-advertiser/start.sh @@ -21,5 +21,12 @@ if [ $NUM_IFACES -eq 0 ]; then exit 0 fi +# Generate the script that waits for pertinent interfaces to come up and make it executable +sonic-cfggen -d -t /usr/share/sonic/templates/wait_for_intf.sh.j2 > /usr/bin/wait_for_intf.sh +chmod +x /usr/bin/wait_for_intf.sh + +# Wait for pertinent interfaces to come up +/usr/bin/wait_for_intf.sh + # Start the router advertiser supervisorctl start radvd diff --git a/dockers/docker-router-advertiser/wait_for_intf.sh.j2 b/dockers/docker-router-advertiser/wait_for_intf.sh.j2 new file mode 100644 index 000000000000..856c47678f23 --- /dev/null +++ b/dockers/docker-router-advertiser/wait_for_intf.sh.j2 @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +STATE_DB_IDX="6" + +VLAN_TABLE_PREFIX="VLAN_TABLE" + +function wait_until_iface_ready +{ + TABLE_PREFIX=$1 + IFACE=$2 + + echo "Waiting until interface $IFACE is ready..." + + # Wait for the interface to come up + # (i.e., interface is present in STATE_DB and state is "ok") + while true; do + RESULT=$(redis-cli -n ${STATE_DB_IDX} HGET "${TABLE_PREFIX}|${IFACE}" "state" 2> /dev/null) + if [ x"$RESULT" == x"ok" ]; then + break + fi + + sleep 1 + done + + echo "Interface ${IFACE} is ready!" +} + + +# Wait for all interfaces to be up and ready +{% for (name, prefix) in VLAN_INTERFACE %} +wait_until_iface_ready ${VLAN_TABLE_PREFIX} {{ name }} +{% endfor %} diff --git a/files/build_templates/buffers_config.j2 b/files/build_templates/buffers_config.j2 index 44b5a340fab8..8c6d27c26536 100644 --- a/files/build_templates/buffers_config.j2 +++ b/files/build_templates/buffers_config.j2 @@ -29,12 +29,16 @@ def {# Port configuration to cable length look-up table #} {# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #} {# Roles described in the minigraph #} -{%- set ports2cable = { - 'torrouter_server' : '5m', - 'leafrouter_torrouter' : '40m', - 'spinerouter_leafrouter' : '300m' - } --%} +{%- if defs.ports2cable is defined %} + {%- set ports2cable = defs.ports2cable %} +{%- else %} + {%- set ports2cable = { + 'torrouter_server' : '5m', + 'leafrouter_torrouter' : '40m', + 'spinerouter_leafrouter' : '300m' + } + -%} +{%- endif %} {%- macro cable_length(port_name) %} {%- set cable_len = [] %} diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index a3cbf5adbae7..76f55e2234df 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -126,12 +126,17 @@ start() { {%- if '--log-driver=json-file' in docker_image_run_opt or '--log-driver' not in docker_image_run_opt %} --log-opt max-size=2M --log-opt max-file=5 \ {%- endif %} -{%- if docker_container_name == "syncd" and sonic_asic_platform == "mellanox" %} +{%- if sonic_asic_platform == "mellanox" %} +{%- if docker_container_name == "syncd" %} -e SX_SNIFFER_ENABLE \ -e SX_SNIFFER_TARGET \ -e PRM_SNIFFER \ -e PRM_SNIFFER_FILE_PATH \ -v /var/log/mellanox/sniffer:/var/log/mellanox/sniffer:rw \ +{%- endif %} +{%- if docker_container_name == "pmon" %} + -v /var/run/hw-management:/var/run/hw-management:rw \ +{%- endif %} {%- endif %} -v /var/run/redis:/var/run/redis:rw \ -v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \ diff --git a/files/build_templates/swss.service.j2 b/files/build_templates/swss.service.j2 index 43e513439afe..8bbdc8f32997 100644 --- a/files/build_templates/swss.service.j2 +++ b/files/build_templates/swss.service.j2 @@ -13,7 +13,8 @@ Before=ntp-config.service [Service] User=root Environment=sonic_asic_platform={{ sonic_asic_platform }} -ExecStart=/usr/local/bin/swss.sh start +ExecStartPre=/usr/local/bin/swss.sh start +ExecStart=/usr/local/bin/swss.sh attach ExecStop=/usr/local/bin/swss.sh stop [Install] diff --git a/files/build_templates/syncd.service.j2 b/files/build_templates/syncd.service.j2 index 2c073ced92e7..6fdbed07f819 100644 --- a/files/build_templates/syncd.service.j2 +++ b/files/build_templates/syncd.service.j2 @@ -13,12 +13,14 @@ After=opennsl-modules.service {% elif sonic_asic_platform == 'nephos' %} After=nps-modules-4.9.0-8-2-amd64.service {% endif %} +After=swss.service Before=ntp-config.service [Service] User=root Environment=sonic_asic_platform={{ sonic_asic_platform }} -ExecStart=/usr/local/bin/syncd.sh start +ExecStartPre=/usr/local/bin/syncd.sh start +ExecStart=/usr/local/bin/syncd.sh attach ExecStop=/usr/local/bin/syncd.sh stop [Install] diff --git a/files/build_templates/updategraph.service.j2 b/files/build_templates/updategraph.service.j2 index e01fd0146f98..8039f42531cd 100644 --- a/files/build_templates/updategraph.service.j2 +++ b/files/build_templates/updategraph.service.j2 @@ -4,7 +4,7 @@ After=rc-local.service After=database.service Requires=database.service {% if sonic_asic_platform == 'mellanox' -%} -Requires=msn-chassis.service +Requires=hw-management.service {% endif -%} diff --git a/files/image_config/hostcfgd/common-auth-sonic.j2 b/files/image_config/hostcfgd/common-auth-sonic.j2 index 288d19f714df..e609296d4e05 100644 --- a/files/image_config/hostcfgd/common-auth-sonic.j2 +++ b/files/image_config/hostcfgd/common-auth-sonic.j2 @@ -19,7 +19,7 @@ auth [success=done new_authtok_reqd=done default=ignore{{ ' auth_err=die' if not {% endfor %} {% if servers | count %} {% set last_server = servers | last %} -auth [success=1 default=ignore] pam_tacplus.so server={{ last_server.ip }}:{{ last_server.tcp_port }} secret={{ last_server.passkey }} login={{ last_server.auth_type }} timeout={{ last_server.timeout }} {% if server.vrf %} vrf={{ last_server.vrf }} {% endif %} try_first_pass +auth [success=1 default=ignore] pam_tacplus.so server={{ last_server.ip }}:{{ last_server.tcp_port }} secret={{ last_server.passkey }} login={{ last_server.auth_type }} timeout={{ last_server.timeout }} {% if last_server.vrf %} vrf={{ last_server.vrf }} {% endif %} try_first_pass {% endif %} {% elif auth['login'] == 'tacacs+' or auth['login'] == 'tacacs+,local' %} diff --git a/files/scripts/swss.sh b/files/scripts/swss.sh index f7f2e53608f4..107a2e81b4b2 100755 --- a/files/scripts/swss.sh +++ b/files/scripts/swss.sh @@ -78,6 +78,14 @@ function clean_up_tables() end" 0 } +startPeerService() { + check_warm_boot + + if [[ x"$WARM_BOOT" != x"true" ]]; then + /bin/systemctl start ${PEER} + fi +} + start() { debug "Starting ${SERVICE} service..." @@ -105,10 +113,10 @@ start() { # Unlock has to happen before reaching out to peer service unlock_service_state_change +} - if [[ x"$WARM_BOOT" != x"true" ]]; then - /bin/systemctl start ${PEER} - fi +attach() { + startPeerService /usr/bin/${SERVICE}.sh attach } @@ -134,11 +142,11 @@ stop() { } case "$1" in - start|stop) + start|attach|stop) $1 ;; *) - echo "Usage: $0 {start|stop}" + echo "Usage: $0 {start|attach|stop}" exit 1 ;; esac diff --git a/files/scripts/syncd.sh b/files/scripts/syncd.sh index 545879b2f7f4..0d43f7840fbe 100755 --- a/files/scripts/syncd.sh +++ b/files/scripts/syncd.sh @@ -94,15 +94,28 @@ start() { # start mellanox drivers regardless of # boot type - if [ x"$sonic_asic_platform" == x"mellanox" ]; then + if [[ x"$sonic_asic_platform" == x"mellanox" ]]; then BOOT_TYPE=`getBootType` if [[ x"$WARM_BOOT" == x"true" || x"$BOOT_TYPE" == x"fast" ]]; then export FAST_BOOT=1 fi + + if [[ x"$WARM_BOOT" != x"true" ]]; then + /bin/systemctl stop pmon + /usr/bin/hw-management.sh chipdown + fi + + if [[ x"$BOOT_TYPE" == x"fast" ]]; then + /usr/bin/hw-management.sh chipupdis + fi + /usr/bin/mst start /usr/bin/mlnx-fw-upgrade.sh /etc/init.d/sxdkernel start - /sbin/modprobe i2c-dev + + if [[ x"$WARM_BOOT" != x"true" ]]; then + /bin/systemctl start pmon + fi fi if [[ x"$WARM_BOOT" != x"true" ]]; then @@ -111,12 +124,18 @@ start() { fi fi - # start service docker /usr/bin/${SERVICE}.sh start debug "Started ${SERVICE} service..." + if [[ x"$sonic_asic_platform" == x"mellanox" && x"$BOOT_TYPE" == x"fast" ]]; then + /usr/bin/hw-management.sh chipupen + fi + unlock_service_state_change +} + +attach() { /usr/bin/${SERVICE}.sh attach } @@ -165,11 +184,11 @@ stop() { } case "$1" in - start|stop) + start|attach|stop) $1 ;; *) - echo "Usage: $0 {start|stop}" + echo "Usage: $0 {start|attach|stop}" exit 1 ;; esac diff --git a/platform/barefoot/bfn-platform.mk b/platform/barefoot/bfn-platform.mk index 211b4886c78c..ca33fb9fa301 100644 --- a/platform/barefoot/bfn-platform.mk +++ b/platform/barefoot/bfn-platform.mk @@ -1,5 +1,5 @@ -BFN_PLATFORM = bfnplatform_8.5.x.59217b4.deb -$(BFN_PLATFORM)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/rel_8_5/bfnplatform_8.5.x.59217b4.deb" +BFN_PLATFORM = bfnplatform_master.df38274.deb +$(BFN_PLATFORM)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/vxlan_poc/bfnplatform_master.df38274.deb" SONIC_ONLINE_DEBS += $(BFN_PLATFORM) # $(BFN_SAI_DEV) $(BFN_SAI_DEV)_DEPENDS += $(BFN_PLATFORM) diff --git a/platform/barefoot/bfn-sai.mk b/platform/barefoot/bfn-sai.mk index a735ea777b62..6b2cee9082e1 100644 --- a/platform/barefoot/bfn-sai.mk +++ b/platform/barefoot/bfn-sai.mk @@ -1,5 +1,5 @@ -BFN_SAI = bfnsdk_8.5.x.59217b4.deb -$(BFN_SAI)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/rel_8_5/bfnsdk_8.5.x.59217b4.deb" +BFN_SAI = bfnsdk_master.df38274.deb +$(BFN_SAI)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/vxlan_poc/bfnsdk_master.df38274.deb" SONIC_ONLINE_DEBS += $(BFN_SAI) # $(BFN_SAI_DEV) $(BFN_SAI_DEV)_DEPENDS += $(BFN_SAI) diff --git a/platform/mellanox/hw-management.mk b/platform/mellanox/hw-management.mk index 10e6bcd76652..4f6df401758a 100644 --- a/platform/mellanox/hw-management.mk +++ b/platform/mellanox/hw-management.mk @@ -1,6 +1,6 @@ # Mellanox HW Management -MLNX_HW_MANAGEMENT_VERSION = 27.09.2018 +MLNX_HW_MANAGEMENT_VERSION = 18.01.2019 export MLNX_HW_MANAGEMENT_VERSION diff --git a/platform/mellanox/hw-management/0001-Suspend-thermal-control-by-default.patch b/platform/mellanox/hw-management/0001-Suspend-thermal-control-by-default.patch new file mode 100644 index 000000000000..c8db79889610 --- /dev/null +++ b/platform/mellanox/hw-management/0001-Suspend-thermal-control-by-default.patch @@ -0,0 +1,51 @@ +From 45587a19ab4b69e5d1ed84d9910a6b89d0fc5520 Mon Sep 17 00:00:00 2001 +From: Kevin Wang +Date: Thu, 10 Jan 2019 07:22:31 +0200 +Subject: [PATCH] Suspend thermal control by default + +Suspend thermal control and set the default fan speed to 60% + +Signed-off-by: Kevin Wang +--- + usr/usr/bin/hw-management-thermal-control.sh | 5 +++-- + usr/usr/bin/hw-management.sh | 1 + + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/usr/usr/bin/hw-management-thermal-control.sh b/usr/usr/bin/hw-management-thermal-control.sh +index c7274a6..4c5438f 100755 +--- a/usr/usr/bin/hw-management-thermal-control.sh ++++ b/usr/usr/bin/hw-management-thermal-control.sh +@@ -116,6 +116,7 @@ max_ports=${5:-$max_ports_def} + # Local constants + pwm_noact=0 + pwm_max=1 ++pwm_def_rpm=153 + pwm_max_rpm=255 + max_amb=120000 + untrusted_sensor=0 +@@ -893,8 +894,8 @@ disable_zones_max_pwm() { + fi + fi + done +- echo $pwm_max_rpm > $pwm +- log_action_msg "Set fan speed to maximum" ++ echo $pwm_def_rpm > $pwm ++ log_action_msg "Set fan speed to 60% percent" + } + + trip_points_num=4 +diff --git a/usr/usr/bin/hw-management.sh b/usr/usr/bin/hw-management.sh +index 9214a9f..c8261a3 100755 +--- a/usr/usr/bin/hw-management.sh ++++ b/usr/usr/bin/hw-management.sh +@@ -565,6 +565,7 @@ do_start() + echo $asic_bus > $config_path/asic_bus + connect_platform + ++ echo 1 > $config_path/suspend + $THERMAL_CONTROL $thermal_type $max_tachos $max_psus& + } + +-- +1.9.1 + diff --git a/platform/mellanox/hw-management/hw-mgmt b/platform/mellanox/hw-management/hw-mgmt index 498002ba528e..ea86fcb7dfab 160000 --- a/platform/mellanox/hw-management/hw-mgmt +++ b/platform/mellanox/hw-management/hw-mgmt @@ -1 +1 @@ -Subproject commit 498002ba528e5633bf1e9b8e488979ed731ca0f6 +Subproject commit ea86fcb7dfab5373cd982a500ac7d0b7db51d318 diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform_api/chassis.py b/platform/mellanox/mlnx-platform-api/sonic_platform_api/chassis.py index 398a3a553762..e521007a1fa4 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform_api/chassis.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform_api/chassis.py @@ -13,6 +13,7 @@ try: from sonic_platform_base.chassis_base import ChassisBase from sonic_platform_api.psu import Psu + from sonic_platform_api.watchdog import get_watchdog except ImportError as e: raise ImportError (str(e) + "- required module not found") @@ -20,9 +21,15 @@ class Chassis(ChassisBase): """Platform-specific Chassis class""" + def __init__(self): ChassisBase.__init__(self) + + # Initialize PSU list for index in range(MLNX_NUM_PSU): psu = Psu(index) self._psu_list.append(psu) + # Initialize watchdog + self._watchdog = get_watchdog() + diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform_api/watchdog.py b/platform/mellanox/mlnx-platform-api/sonic_platform_api/watchdog.py new file mode 100644 index 000000000000..e9694f1b2a59 --- /dev/null +++ b/platform/mellanox/mlnx-platform-api/sonic_platform_api/watchdog.py @@ -0,0 +1,288 @@ +#!/usr/bin/env python + +""" +Mellanox + +Module contains an implementation of SONiC Platform Base API and +provides access to hardware watchdog on Mellanox platforms +""" + +import os +import fcntl +import array +import time + +from sonic_platform_base.watchdog_base import WatchdogBase + +""" ioctl constants """ +IO_WRITE = 0x40000000 +IO_READ = 0x80000000 +IO_READ_WRITE = 0xC0000000 +IO_SIZE_INT = 0x00040000 +IO_SIZE_40 = 0x00280000 +IO_TYPE_WATCHDOG = ord('W') << 8 + +WDR_INT = IO_READ | IO_SIZE_INT | IO_TYPE_WATCHDOG +WDR_40 = IO_READ | IO_SIZE_40 | IO_TYPE_WATCHDOG +WDWR_INT = IO_READ_WRITE | IO_SIZE_INT | IO_TYPE_WATCHDOG + +""" Watchdog ioctl commands """ +WDIOC_GETSUPPORT = 0 | WDR_40 +WDIOC_GETSTATUS = 1 | WDR_INT +WDIOC_GETBOOTSTATUS = 2 | WDR_INT +WDIOC_GETTEMP = 3 | WDR_INT +WDIOC_SETOPTIONS = 4 | WDR_INT +WDIOC_KEEPALIVE = 5 | WDR_INT +WDIOC_SETTIMEOUT = 6 | WDWR_INT +WDIOC_GETTIMEOUT = 7 | WDR_INT +WDIOC_SETPRETIMEOUT = 8 | WDWR_INT +WDIOC_GETPRETIMEOUT = 9 | WDR_INT +WDIOC_GETTIMELEFT = 10 | WDR_INT + +""" Watchdog status constants """ +WDIOS_DISABLECARD = 0x0001 +WDIOS_ENABLECARD = 0x0002 + +""" Mellanox main watchdog identity string """ +WD_MLNX_MAIN_IDENTITY = "mlx-wdt-main" +""" watchdog sysfs """ +WD_SYSFS_PATH = "/sys/class/watchdog/" + + +WD_COMMON_ERROR = -1 + + +class WatchdogImplBase(WatchdogBase): + """ + Base class that implements common logic for interacting + with watchdog using ioctl commands + """ + + def __init__(self, wd_device_path): + """ + Open a watchdog handle + @param wd_device_path Path to watchdog device + """ + + self.watchdog_path = wd_device_path + self.watchdog = os.open(self.watchdog_path, os.O_WRONLY) + + # Opening a watchdog descriptor starts + # watchdog timer; + # by default it should be stopped + self._disablecard() + self.armed = False + + self.timeout = self._gettimeout() + + def _enablecard(self): + """ + Turn on the watchdog timer + """ + + req = array.array('h', [WDIOS_ENABLECARD]) + fcntl.ioctl(self.watchdog, WDIOC_SETOPTIONS, req, False) + + def _disablecard(self): + """ + Turn off the watchdog timer + """ + + req = array.array('h', [WDIOS_DISABLECARD]) + fcntl.ioctl(self.watchdog, WDIOC_SETOPTIONS, req, False) + + def _keepalive(self): + """ + Keep alive watchdog timer + """ + + fcntl.ioctl(self.watchdog, WDIOC_KEEPALIVE) + + def _settimeout(self, seconds): + """ + Set watchdog timer timeout + @param seconds - timeout in seconds + @return is the actual set timeout + """ + + req = array.array('I', [seconds]) + fcntl.ioctl(self.watchdog, WDIOC_SETTIMEOUT, req, True) + + return int(req[0]) + + def _gettimeout(self): + """ + Get watchdog timeout + @return watchdog timeout + """ + + req = array.array('I', [0]) + fcntl.ioctl(self.watchdog, WDIOC_GETTIMEOUT, req, True) + + return int(req[0]) + + def _gettimeleft(self): + """ + Get time left before watchdog timer expires + @return time left in seconds + """ + + req = array.array('I', [0]) + fcntl.ioctl(self.watchdog, WDIOC_GETTIMELEFT, req, True) + + return int(req[0]) + + def arm(self, seconds): + """ + Implements arm WatchdogBase API + """ + + ret = WD_COMMON_ERROR + if seconds < 0: + return ret + + try: + if self.timeout != seconds: + self.timeout = self._settimeout(seconds) + if self.armed: + self._keepalive() + else: + self._enablecard() + self.armed = True + ret = self.timeout + except IOError: + pass + + return ret + + def disarm(self): + """ + Implements disarm WatchdogBase API + """ + + disarmed = False + if self.armed: + try: + self._disablecard() + self.armed = False + disarmed = True + except IOError: + pass + + return disarmed + + def is_armed(self): + """ + Implements is_armed WatchdogBase API + """ + + return self.armed + + def get_remaining_time(self): + """ + Implements get_remaining_time WatchdogBase API + """ + + timeleft = WD_COMMON_ERROR + + if self.armed: + try: + timeleft = self._gettimeleft() + except IOError: + pass + + return timeleft + + def __del__(self): + """ + Close watchdog + """ + + os.close(self.watchdog) + + +class WatchdogType1(WatchdogImplBase): + """ + Watchdog type 1 + """ + + def arm(self, seconds): + """ + Call arm from WatchdgoImplBase and save the timestamp + when the watchdog was armed + """ + + ret = WatchdogImplBase.arm(self, seconds) + # Save the watchdog arm timestamp + # requiered for get_remaining_time() + self.arm_timestamp = time.time() + + return ret + + def get_remaining_time(self): + """ + Watchdog Type 1 does not support timeleft + operation, we will calculate timeleft based + on timeout and arm timestamp + """ + + timeleft = WD_COMMON_ERROR + + if self.armed: + timeleft = int(self.timeout - (time.time() - self.arm_timestamp)) + + return timeleft + +class WatchdogType2(WatchdogImplBase): + """ + Watchdog type 2 + """ + + pass + + +def is_mlnx_wd_main(dev): + """ + Checks if dev is Mellanox main watchdog + """ + + try: + with open("{}/{}/identity".format(WD_SYSFS_PATH, dev)) as identity_file: + identity = identity_file.read().strip() + if identity == WD_MLNX_MAIN_IDENTITY: + return True + except IOError: + pass + + return False + + +def is_wd_type2(dev): + """ + Checks if dev is Mellanox type 2 watchdog + """ + + return os.path.exists("{}/{}/timeleft".format(WD_SYSFS_PATH, dev)) + + +def get_watchdog(): + """ + Return WatchdogType1 or WatchdogType2 based on system + """ + + watchdog_main_device_name = None + + for device in os.listdir("/dev/"): + if device.startswith("watchdog") and is_mlnx_wd_main(device): + watchdog_main_device_name = device + + watchdog_device_path = "/dev/{}".format(watchdog_main_device_name) + + watchdog = None + + if is_wd_type2(watchdog_main_device_name): + watchdog = WatchdogType2(watchdog_device_path) + else: + watchdog = WatchdogType1(watchdog_device_path) + + return watchdog diff --git a/platform/vs/docker-sonic-vs/orchagent.sh b/platform/vs/docker-sonic-vs/orchagent.sh index 26dae28a6e15..d9bebf117346 100755 --- a/platform/vs/docker-sonic-vs/orchagent.sh +++ b/platform/vs/docker-sonic-vs/orchagent.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash -export platform=vs +if [[ -z "$fake_platform" ]]; then + export platform=vs +else + export platform=$fake_platform +fi MAC_ADDRESS=`ip link show eth0 | grep ether | awk '{print $2}'` diff --git a/rules/config b/rules/config index f672bd3722d4..5fa19928e0a9 100644 --- a/rules/config +++ b/rules/config @@ -69,7 +69,7 @@ ENABLE_ORGANIZATION_EXTENSIONS = y #SONIC_PROFILING_ON = y # ENABLE_SYSTEM_TELEMETRY - build docker-sonic-telemetry for system telemetry support -# ENABLE_SYSTEM_TELEMETRY = y +ENABLE_SYSTEM_TELEMETRY = y # DEFAULT_KERNEL_PROCURE_METHOD - default method for obtaining kernel # build: build kernel from source diff --git a/rules/docker-platform-monitor.mk b/rules/docker-platform-monitor.mk index 317bc9b46c5c..a1000849bc76 100644 --- a/rules/docker-platform-monitor.mk +++ b/rules/docker-platform-monitor.mk @@ -7,6 +7,7 @@ $(DOCKER_PLATFORM_MONITOR)_PYTHON_DEBS += $(SONIC_LEDD) $(SONIC_XCVRD) $(SONIC_P $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY2) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SWSSSDK_PY2) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_API_PY2) +$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_DAEMON_BASE_PY2) $(DOCKER_PLATFORM_MONITOR)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE) SONIC_DOCKER_IMAGES += $(DOCKER_PLATFORM_MONITOR) diff --git a/rules/docker-router-advertiser.mk b/rules/docker-router-advertiser.mk index 90c7b6fa89ea..b4b20b768db0 100644 --- a/rules/docker-router-advertiser.mk +++ b/rules/docker-router-advertiser.mk @@ -2,6 +2,7 @@ DOCKER_ROUTER_ADVERTISER = docker-router-advertiser.gz $(DOCKER_ROUTER_ADVERTISER)_PATH = $(DOCKERS_PATH)/docker-router-advertiser +$(DOCKER_ROUTER_ADVERTISER)_DEPENDS += $(REDIS_TOOLS) $(DOCKER_ROUTER_ADVERTISER)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_STRETCH) SONIC_DOCKER_IMAGES += $(DOCKER_ROUTER_ADVERTISER) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ROUTER_ADVERTISER) diff --git a/rules/sonic-daemon-base.mk b/rules/sonic-daemon-base.mk new file mode 100644 index 000000000000..dad0900e75ca --- /dev/null +++ b/rules/sonic-daemon-base.mk @@ -0,0 +1,7 @@ +# SONIC_DAEMON_BASE_PY2 package + +SONIC_DAEMON_BASE_PY2 = sonic_daemon_base-1.0-py2-none-any.whl +$(SONIC_DAEMON_BASE_PY2)_SRC_PATH = $(SRC_PATH)/sonic-daemon-base +$(SONIC_DAEMON_BASE_PY2)_PYTHON_VERSION = 2 +SONIC_PYTHON_WHEELS += $(SONIC_DAEMON_BASE_PY2) + diff --git a/src/sonic-config-engine/sonic_platform.py b/src/sonic-config-engine/sonic_platform.py index 20890d765cab..370f6e3a42ee 100644 --- a/src/sonic-config-engine/sonic_platform.py +++ b/src/sonic-config-engine/sonic_platform.py @@ -56,7 +56,7 @@ def get_system_mac(): mac = mac.strip() # Align last byte of MAC if necessary - if version_info and (version_info['asic_type'] == 'mellanox' or version_info['asic_type'] == 'centec'): + if version_info and version_info['asic_type'] == 'centec': last_byte = mac[-2:] aligned_last_byte = format(int(int(last_byte, 16) & 0b11000000), '02x') mac = mac[:-2] + aligned_last_byte diff --git a/src/sonic-daemon-base/setup.py b/src/sonic-daemon-base/setup.py new file mode 100644 index 000000000000..397af04b87dc --- /dev/null +++ b/src/sonic-daemon-base/setup.py @@ -0,0 +1,30 @@ +from setuptools import setup + +setup( + name='sonic-daemon-base', + version='1.0', + description='Sonic daemon base package', + license='Apache 2.0', + author='SONiC Team', + author_email='linuxnetdev@microsoft.com', + url='https://github.com/Azure/sonic-platform-daemons', + maintainer='Kevin Wang', + maintainer_email='kevinw@mellanox.com', + packages=[ + 'sonic_daemon_base', + ], + classifiers=[ + 'Development Status :: 4 - Beta', + 'Environment :: No Input/Output (Daemon)', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Natural Language :: English', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 2.7', + 'Topic :: System :: Hardware', + ], + keywords='SONiC sonic PLATFORM platform DAEMON daemon', +) + diff --git a/src/sonic-daemon-base/sonic_daemon_base/__init__.py b/src/sonic-daemon-base/sonic_daemon_base/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/sonic-daemon-base/sonic_daemon_base/daemon_base.py b/src/sonic-daemon-base/sonic_daemon_base/daemon_base.py new file mode 100644 index 000000000000..7fc14bf55c1f --- /dev/null +++ b/src/sonic-daemon-base/sonic_daemon_base/daemon_base.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python2 + +try: + import imp + import signal + import subprocess + import sys + import syslog + from swsscommon import swsscommon +except ImportError, e: + raise ImportError (str(e) + " - required module not found") + +#============================= Constants ============================= + +# Platform root directory inside docker +PLATFORM_ROOT_DOCKER = "/usr/share/sonic/platform" +SONIC_CFGGEN_PATH = '/usr/local/bin/sonic-cfggen' +HWSKU_KEY = 'DEVICE_METADATA.localhost.hwsku' +PLATFORM_KEY = 'DEVICE_METADATA.localhost.platform' + +class DaemonBase(object): + # Redis DB information + redis_hostname = "localhost" + redis_port = 6379 + redis_timeout_msecs = 0 + + def __init__(self): + self.log_info("Starting up...") + # Register our signal handlers + signal.signal(signal.SIGHUP, self.signal_handler) + signal.signal(signal.SIGINT, self.signal_handler) + signal.signal(signal.SIGTERM, self.signal_handler) + + def __del__(self): + self.log_error("Return from daemon, exiting...") + + def run(self): + raise NotImplementedError() + + # ========================== Connect to DB ============================ + def db_connect(self, db): + return swsscommon.DBConnector(db, + self.redis_hostname, + self.redis_port, + self.redis_timeout_msecs) + + # ========================== Syslog wrappers ========================== + def log_info(self, msg): + syslog.openlog() + syslog.syslog(syslog.LOG_INFO, msg) + syslog.closelog() + + def log_warning(self, msg): + syslog.openlog() + syslog.syslog(syslog.LOG_WARNING, msg) + syslog.closelog() + + def log_error(self, msg): + syslog.openlog() + syslog.syslog(syslog.LOG_ERR, msg) + syslog.closelog() + + #========================== Signal Handling ========================== + def signal_handler(self, sig, frame): + if sig == signal.SIGHUP: + self.log_info("Caught SIGHUP - ignoring...") + return + elif sig == signal.SIGINT: + self.log_info("Caught SIGINT - exiting...") + sys.exit(128 + sig) + elif sig == signal.SIGTERM: + self.log_info("Caught SIGTERM - exiting...") + sys.exit(128 + sig) + else: + self.log_warning("Caught unhandled signal '" + sig + "'") + return + + #============ Functions to load platform-specific classes ============ + # Returns platform and HW SKU + def get_platform_and_hwsku(self): + try: + proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY], + stdout=subprocess.PIPE, + shell=False, + stderr=subprocess.STDOUT) + stdout = proc.communicate()[0] + proc.wait() + platform = stdout.rstrip('\n') + + proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY], + stdout=subprocess.PIPE, + shell=False, + stderr=subprocess.STDOUT) + stdout = proc.communicate()[0] + proc.wait() + hwsku = stdout.rstrip('\n') + except OSError, e: + self.log_error("Cannot to detect platform") + raise OSError("Cannot detect platform") + + return (platform, hwsku) + + # Returns path to hwsku + def get_path_to_platform_and_hwsku(self): + # Get platform and hwsku + (platform, hwsku) = self.get_platform_and_hwsku() + + # Load platform module from source + platform_path = PLATFORM_ROOT_DOCKER + hwsku_path = "/".join([platform_path, hwsku]) + + return (platform_path, hwsku_path) + + # Loads platform specific psuutil module from source + def load_platform_util(self, module_name, class_name): + platform_util = None + + # Get path to platform and hwsku + (platform_path, hwsku_path) = self.get_path_to_platform_and_hwsku() + + try: + module_file = "/".join([platform_path, "plugins", module_name + ".py"]) + module = imp.load_source(module_name, module_file) + except IOError, e: + self.log_error("Failed to load platform module '%s': %s" % (module_name, str(e))) + return None + + try: + platform_util_class = getattr(module, class_name) + platform_util = platform_util_class() + except AttributeError, e: + self.log_error("Failed to instantiate '%s' class: %s" % (class_name, str(e))) + return None + + return platform_util + diff --git a/src/sonic-linux-kernel b/src/sonic-linux-kernel index 4cb2f2817c93..69ba0c13f6b9 160000 --- a/src/sonic-linux-kernel +++ b/src/sonic-linux-kernel @@ -1 +1 @@ -Subproject commit 4cb2f2817c9307eb1ed73c11459c409414075230 +Subproject commit 69ba0c13f6b984b554dd83fadfaace4e856239ae diff --git a/src/sonic-sairedis b/src/sonic-sairedis index 9609d46f4c16..501d16477a8e 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit 9609d46f4c161b1ad9bc6fdca9287b3c13399ded +Subproject commit 501d16477a8ebd840f83867ad0d876b44188989c diff --git a/src/supervisor/patch/0002-Add-unit-test-cases-to-ensure-state-transitions-work.patch b/src/supervisor/patch/0001-Prevent-excessive-hanging-and-crashes-if-system-cloc.patch similarity index 54% rename from src/supervisor/patch/0002-Add-unit-test-cases-to-ensure-state-transitions-work.patch rename to src/supervisor/patch/0001-Prevent-excessive-hanging-and-crashes-if-system-cloc.patch index cb01665ba80b..6c4a6b7c2a4c 100644 --- a/src/supervisor/patch/0002-Add-unit-test-cases-to-ensure-state-transitions-work.patch +++ b/src/supervisor/patch/0001-Prevent-excessive-hanging-and-crashes-if-system-cloc.patch @@ -1,15 +1,91 @@ -From 43b6f3ee93593f666af2c6a7af897bf3b5ee762d Mon Sep 17 00:00:00 2001 +From 5b56519e68e866662d9fd9a6681b6b47d6b5fcdb Mon Sep 17 00:00:00 2001 From: Joe LeVeque -Date: Wed, 17 Jan 2018 22:27:56 +0000 -Subject: [PATCH 2/2] Add unit test cases to ensure state transitions work if - system time has rolled backward +Date: Thu, 28 Feb 2019 01:43:54 +0000 +Subject: [PATCH] Prevent excessive hanging and crashes if system clock rolls + backward --- - supervisor/tests/test_process.py | 146 +++++++++++++++++++++++++++++++++++++++ - 1 file changed, 146 insertions(+) + supervisor/process.py | 36 ++++++ + supervisor/tests/test_process.py | 183 +++++++++++++++++++++++++++++++ + 2 files changed, 219 insertions(+) +diff --git a/supervisor/process.py b/supervisor/process.py +index f9ddcd9..5f73e6b 100644 +--- a/supervisor/process.py ++++ b/supervisor/process.py +@@ -347,6 +347,28 @@ class Subprocess: + options.write(2, "supervisor: child process was not spawned\n") + options._exit(127) # exit process with code for spawn failure + ++ def _check_and_adjust_for_system_clock_rollback(self, test_time): ++ """ ++ Check if system clock has rolled backward beyond test_time. If so, set ++ affected timestamps to test_time. ++ """ ++ if self.state == ProcessStates.STARTING: ++ if test_time < self.laststart: ++ self.laststart = test_time; ++ if self.delay > 0 and test_time < (self.delay - self.config.startsecs): ++ self.delay = test_time + self.config.startsecs ++ elif self.state == ProcessStates.RUNNING: ++ if test_time > self.laststart and test_time < (self.laststart + self.config.startsecs): ++ self.laststart = test_time - self.config.startsecs ++ elif self.state == ProcessStates.STOPPING: ++ if test_time < self.laststopreport: ++ self.laststopreport = test_time; ++ if self.delay > 0 and test_time < (self.delay - self.config.stopwaitsecs): ++ self.delay = test_time + self.config.stopwaitsecs ++ elif self.state == ProcessStates.BACKOFF: ++ if self.delay > 0 and test_time < (self.delay - self.backoff): ++ self.delay = test_time + self.backoff ++ + def stop(self): + """ Administrative stop """ + self.administrative_stop = True +@@ -357,6 +379,9 @@ class Subprocess: + """ Log a 'waiting for x to stop' message with throttling. """ + if self.state == ProcessStates.STOPPING: + now = time.time() ++ ++ self._check_and_adjust_for_system_clock_rollback(now) ++ + if now > (self.laststopreport + 2): # every 2 seconds + self.config.options.logger.info( + 'waiting for %s to stop' % self.config.name) +@@ -487,6 +512,9 @@ class Subprocess: + es, msg = decode_wait_status(sts) + + now = time.time() ++ ++ self._check_and_adjust_for_system_clock_rollback(now) ++ + self.laststop = now + processname = self.config.name + +@@ -586,6 +614,8 @@ class Subprocess: + now = time.time() + state = self.state + ++ self._check_and_adjust_for_system_clock_rollback(now) ++ + logger = self.config.options.logger + + if self.config.options.mood > SupervisorStates.RESTARTING: +@@ -805,6 +835,12 @@ class EventListenerPool(ProcessGroupBase): + if dispatch_capable: + if self.dispatch_throttle: + now = time.time() ++ ++ if now < self.last_dispatch: ++ # The system clock appears to have moved backward ++ # Reset self.last_dispatch accordingly ++ self.last_dispatch = now; ++ + if now - self.last_dispatch < self.dispatch_throttle: + return + self.dispatch() diff --git a/supervisor/tests/test_process.py b/supervisor/tests/test_process.py -index 7f9bab2..ea16315 100644 +index 7f9bab2..6808f60 100644 --- a/supervisor/tests/test_process.py +++ b/supervisor/tests/test_process.py @@ -736,6 +736,40 @@ class SubprocessTests(unittest.TestCase): @@ -53,7 +129,51 @@ index 7f9bab2..ea16315 100644 def test_give_up(self): options = DummyOptions() config = DummyPConfig(options, 'test', '/test') -@@ -1402,6 +1436,92 @@ class SubprocessTests(unittest.TestCase): +@@ -1105,6 +1139,43 @@ class SubprocessTests(unittest.TestCase): + self.assertEqual(event.__class__, events.ProcessStateBackoffEvent) + self.assertEqual(event.from_state, ProcessStates.STARTING) + ++ # This tests the case where the process has stayed alive longer than ++ # startsecs (i.e., long enough to enter the RUNNING state), however the ++ # system clock has since rolled backward such that the current time is ++ # greater than laststart but less than startsecs. ++ def test_finish_running_state_exited_too_quickly_due_to_clock_rollback(self): ++ options = DummyOptions() ++ config = DummyPConfig(options, 'notthere', '/notthere', ++ stdout_logfile='/tmp/foo', startsecs=10) ++ instance = self._makeOne(config) ++ instance.config.options.pidhistory[123] = instance ++ pipes = {'stdout':'','stderr':''} ++ instance.pipes = pipes ++ instance.config.exitcodes =[-1] ++ instance.laststart = time.time() ++ from supervisor.states import ProcessStates ++ from supervisor import events ++ instance.state = ProcessStates.RUNNING ++ L = [] ++ events.subscribe(events.ProcessStateEvent, lambda x: L.append(x)) ++ instance.pid = 123 ++ instance.finish(123, 1) ++ self.assertFalse(instance.killing) ++ self.assertEqual(instance.pid, 0) ++ self.assertEqual(options.parent_pipes_closed, pipes) ++ self.assertEqual(instance.pipes, {}) ++ self.assertEqual(instance.dispatchers, {}) ++ self.assertEqual(options.logger.data[0], ++ 'exited: notthere (terminated by SIGHUP; expected)') ++ self.assertEqual(instance.exitstatus, -1) ++ self.assertEqual(len(L), 1) ++ event = L[0] ++ self.assertEqual(event.__class__, ++ events.ProcessStateExitedEvent) ++ self.assertEqual(event.expected, True) ++ self.assertEqual(event.extra_values, [('expected', True), ('pid', 123)]) ++ self.assertEqual(event.from_state, ProcessStates.RUNNING) ++ + def test_finish_running_state_laststart_in_future(self): + options = DummyOptions() + config = DummyPConfig(options, 'notthere', '/notthere', +@@ -1402,6 +1473,92 @@ class SubprocessTests(unittest.TestCase): event = L[0] self.assertEqual(event.__class__, events.ProcessStateRunningEvent) @@ -146,7 +266,7 @@ index 7f9bab2..ea16315 100644 def test_transition_backoff_to_fatal(self): from supervisor import events L = [] -@@ -2033,6 +2153,32 @@ class EventListenerPoolTests(ProcessGroupBaseTests): +@@ -2033,6 +2190,32 @@ class EventListenerPoolTests(ProcessGroupBaseTests): self.assertEqual(process1.listener_state, EventListenerStates.BUSY) self.assertEqual(process1.event, event) @@ -180,5 +300,5 @@ index 7f9bab2..ea16315 100644 options = DummyOptions() from supervisor.states import ProcessStates -- -2.1.4 +2.17.1 diff --git a/src/supervisor/patch/0001-Prevent-excessive-hanging-delays-in-process-state-tr.patch b/src/supervisor/patch/0001-Prevent-excessive-hanging-delays-in-process-state-tr.patch deleted file mode 100644 index c0263e9baf10..000000000000 --- a/src/supervisor/patch/0001-Prevent-excessive-hanging-delays-in-process-state-tr.patch +++ /dev/null @@ -1,83 +0,0 @@ -From bac496af4c2051b3c15038e06533f9094b1c3604 Mon Sep 17 00:00:00 2001 -From: Joe LeVeque -Date: Tue, 16 Jan 2018 20:42:13 +0000 -Subject: [PATCH 1/2] Prevent excessive hanging/delays in process state - transitions if the system time rolls backward - ---- - supervisor/process.py | 32 ++++++++++++++++++++++++++++++++ - 1 file changed, 32 insertions(+) - -diff --git a/supervisor/process.py b/supervisor/process.py -index f9ddcd9..216372f 100644 ---- a/supervisor/process.py -+++ b/supervisor/process.py -@@ -357,6 +357,12 @@ class Subprocess: - """ Log a 'waiting for x to stop' message with throttling. """ - if self.state == ProcessStates.STOPPING: - now = time.time() -+ -+ # If the system clock has moved backward, reset -+ # self.laststopreport to current system time -+ if now < self.laststopreport: -+ self.laststopreport = now; -+ - if now > (self.laststopreport + 2): # every 2 seconds - self.config.options.logger.info( - 'waiting for %s to stop' % self.config.name) -@@ -604,12 +610,27 @@ class Subprocess: - # STOPPED -> STARTING - self.spawn() - elif state == ProcessStates.BACKOFF: -+ if self.delay > 0 and now < self.delay - self.backoff: -+ # The system clock appears to have moved backward -+ # Reset self.delay accordingly -+ self.delay = now + self.backoff -+ - if self.backoff <= self.config.startretries: - if now > self.delay: - # BACKOFF -> STARTING - self.spawn() - - if state == ProcessStates.STARTING: -+ if now < self.laststart: -+ # The system clock appears to have moved backward -+ # Reset self.laststart to current system time -+ self.laststart = now; -+ -+ if self.delay > 0 and now < self.delay - self.config.startsecs: -+ # The system clock appears to have moved backward -+ # Reset self.delay accordingly -+ self.delay = now + self.config.startsecs -+ - if now - self.laststart > self.config.startsecs: - # STARTING -> RUNNING if the proc has started - # successfully and it has stayed up for at least -@@ -633,6 +654,11 @@ class Subprocess: - logger.info('gave up: %s %s' % (self.config.name, msg)) - - elif state == ProcessStates.STOPPING: -+ if self.delay > 0 and now < self.delay - self.config.stopwaitsecs: -+ # The system clock appears to have moved backward -+ # Reset self.delay accordingly -+ self.delay = now + self.config.stopwaitsecs -+ - time_left = self.delay - now - if time_left <= 0: - # kill processes which are taking too long to stop with a final -@@ -805,6 +831,12 @@ class EventListenerPool(ProcessGroupBase): - if dispatch_capable: - if self.dispatch_throttle: - now = time.time() -+ -+ # If the system clock has moved backward, reset -+ # self.last_dispatch to current system time -+ if now < self.last_dispatch: -+ self.last_dispatch = now; -+ - if now - self.last_dispatch < self.dispatch_throttle: - return - self.dispatch() --- -2.1.4 - diff --git a/src/supervisor/patch/series b/src/supervisor/patch/series index d141fddf3301..9d87dccfa780 100644 --- a/src/supervisor/patch/series +++ b/src/supervisor/patch/series @@ -1,2 +1,2 @@ -0001-Prevent-excessive-hanging-delays-in-process-state-tr.patch -0002-Add-unit-test-cases-to-ensure-state-transitions-work.patch +# This series applies on GIT commit 34b690aea8cf7572d73765c95c54a83261d69aad +0001-Prevent-excessive-hanging-and-crashes-if-system-cloc.patch diff --git a/src/telemetry/debian/rules b/src/telemetry/debian/rules old mode 100644 new mode 100755