|
1 |
| -#!/bin/bash |
2 |
| - |
3 |
| -declare -r SYSLOG_LOGGER="/usr/bin/logger" |
4 |
| -declare -r SYSLOG_IDENTIFIER="platform_wait" |
5 |
| -declare -r SYSLOG_ERROR="error" |
6 |
| -declare -r SYSLOG_NOTICE="notice" |
7 |
| -declare -r SYSLOG_INFO="info" |
8 |
| - |
9 |
| -declare -r HW_MGMT_CONFIG="/var/run/hw-management/config" |
10 |
| - |
11 |
| -declare -r ASIC_INIT_DONE="${HW_MGMT_CONFIG}/asics_init_done" |
12 |
| -declare -r NUM_ASICS="${HW_MGMT_CONFIG}/asic_num" |
13 |
| -declare -r ASIC_CHIPUP_COMPLETED="${HW_MGMT_CONFIG}/asic_chipup_completed" |
14 |
| - |
15 |
| -declare -r EXIT_SUCCESS="0" |
16 |
| -declare -r EXIT_TIMEOUT="1" |
17 |
| - |
18 |
| -function log_error() { |
19 |
| - eval "${SYSLOG_LOGGER} -t ${SYSLOG_IDENTIFIER} -p ${SYSLOG_ERROR} $@" |
20 |
| -} |
21 |
| - |
22 |
| -function log_notice() { |
23 |
| - eval "${SYSLOG_LOGGER} -t ${SYSLOG_IDENTIFIER} -p ${SYSLOG_NOTICE} $@" |
24 |
| -} |
25 |
| - |
26 |
| -function log_info() { |
27 |
| - eval "${SYSLOG_LOGGER} -t ${SYSLOG_IDENTIFIER} -p ${SYSLOG_INFO} $@" |
28 |
| -} |
29 |
| - |
30 |
| -function wait_for_asic_chipup() { |
31 |
| - |
32 |
| - local _ASIC_INIT="0" |
33 |
| - local _ASIC_COUNT="0" |
34 |
| - local _ASICS_CHIPUP="0" |
35 |
| - |
36 |
| - local -i _WDOG_CNT="1" |
37 |
| - local -ir _WDOG_MAX="300" |
38 |
| - |
39 |
| - local -r _TIMEOUT="1s" |
40 |
| - |
41 |
| - while [[ "${_WDOG_CNT}" -le "${_WDOG_MAX}" ]]; do |
42 |
| - _ASIC_INIT="$(cat ${ASIC_INIT_DONE} 2>&1)" |
43 |
| - _ASIC_COUNT="$(cat ${NUM_ASICS} 2>&1)" |
44 |
| - _ASICS_CHIPUP="$(cat ${ASIC_CHIPUP_COMPLETED} 2>&1)" |
45 |
| - |
46 |
| - if [[ "${_ASIC_INIT}" -eq 1 && "${_ASIC_COUNT}" -eq "${_ASICS_CHIPUP}" ]]; then |
47 |
| - return "${EXIT_SUCCESS}" |
48 |
| - fi |
49 |
| - |
50 |
| - let "_WDOG_CNT++" |
51 |
| - sleep "${_TIMEOUT}" |
52 |
| - done |
53 |
| - |
54 |
| - log_error "Mellanox ASIC is not ready: INIT: ${_ASIC_INIT}, NUM_ASIC: ${_ASIC_COUNT}, CHIPUP: ${_ASICS_CHIPUP} timeout...." |
55 |
| - return "${EXIT_TIMEOUT}" |
56 |
| -} |
57 |
| - |
58 |
| -log_info "Wait for Mellanox ASIC to be ready" |
59 |
| - |
60 |
| -wait_for_asic_chipup |
61 |
| -EXIT_CODE="$?" |
62 |
| -if [[ "${EXIT_CODE}" != "${EXIT_SUCCESS}" ]]; then |
63 |
| - exit "${EXIT_CODE}" |
64 |
| -fi |
65 |
| - |
66 |
| -log_notice "Mellanox ASIC is ready" |
67 |
| - |
68 |
| -exit "${EXIT_SUCCESS}" |
| 1 | +#!/usr/bin/python3 |
| 2 | + |
| 3 | +# |
| 4 | +# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. |
| 5 | +# Apache-2.0 |
| 6 | +# |
| 7 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +# you may not use this file except in compliance with the License. |
| 9 | +# You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +# See the License for the specific language governing permissions and |
| 17 | +# limitations under the License. |
| 18 | +# |
| 19 | + |
| 20 | +import sys |
| 21 | +from sonic_platform.device_data import DeviceDataManager |
| 22 | +from sonic_py_common.logger import Logger |
| 23 | + |
| 24 | + |
| 25 | +logger = Logger(log_identifier='platform_wait') |
| 26 | +logger.log_notice('Nvidia: Wait for PMON dependencies to be ready') |
| 27 | +if DeviceDataManager.wait_platform_ready(): |
| 28 | + logger.log_notice('Nvidia: PMON dependencies are ready') |
| 29 | + sys.exit(0) |
| 30 | +else: |
| 31 | + logger.log_error('Nvidia: PMON dependencies are not ready: timeout') |
| 32 | + sys.exit(-1) |
0 commit comments