Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 39 additions & 10 deletions device/mellanox/x86_64-mlnx_msn2700-r0/platform_wait
Original file line number Diff line number Diff line change
@@ -1,24 +1,52 @@
#!/bin/bash

declare -r SYSLOG_LOGGER="/usr/bin/logger"
declare -r SYSLOG_IDENTIFIER="platform_wait"
declare -r SYSLOG_ERROR="error"
declare -r SYSLOG_NOTICE="notice"
declare -r SYSLOG_INFO="info"

declare -r HW_MGMT_CONFIG="/var/run/hw-management/config"

declare -r MODULE_COUNTER="${HW_MGMT_CONFIG}/module_counter"
declare -r SFP_COUNTER="${HW_MGMT_CONFIG}/sfp_counter"

declare -r EXIT_SUCCESS="0"
declare -r EXIT_TIMEOUT="1"

declare -r QSFP_PATH="/var/run/hw-management/qsfp"
function log_error() {
eval "${SYSLOG_LOGGER} -t ${SYSLOG_IDENTIFIER} -p ${SYSLOG_ERROR} $@"
}

function WaitForQsfpReady() {
local -r _QSFP_PATH="${1}"
function log_notice() {
eval "${SYSLOG_LOGGER} -t ${SYSLOG_IDENTIFIER} -p ${SYSLOG_NOTICE} $@"
}

function log_info() {
eval "${SYSLOG_LOGGER} -t ${SYSLOG_IDENTIFIER} -p ${SYSLOG_INFO} $@"
}

function wait_for_sfp() {
local -r _NUM_MATCH="^[0-9]+$"
local -r _NUM_ZERO="0"

local _MODULE_CNT="0"
local _SFP_CNT="0"

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
_MODULE_CNT="$(cat ${MODULE_COUNTER} 2>&1)"
_SFP_CNT="$(cat ${SFP_COUNTER} 2>&1)"

if [[ "${_MODULE_CNT}" =~ ${_NUM_MATCH} && "${_SFP_CNT}" =~ ${_NUM_MATCH} ]]; then
if [[ "${_SFP_CNT}" -gt "${_NUM_ZERO}" && "${_MODULE_CNT}" -eq "${_SFP_CNT}" ]]; then
return "${EXIT_SUCCESS}"
fi
done
fi

let "_WDOG_CNT++"
sleep "${_TIMEOUT}"
Expand All @@ -27,14 +55,15 @@ function WaitForQsfpReady() {
return "${EXIT_TIMEOUT}"
}

echo "Wait for QSFP I2C interface is ready"
log_info "Wait for SFP interfaces to be ready"

WaitForQsfpReady "${QSFP_PATH}"
wait_for_sfp
EXIT_CODE="$?"
if [[ "${EXIT_CODE}" != "${EXIT_SUCCESS}" ]]; then
echo "QSFP I2C interface is not ready: timeout"
log_error "SFP interfaces are not ready: timeout"
exit "${EXIT_CODE}"
fi

echo "QSFP I2C interface is ready: mlxsw_minimal has finished initialization"
log_info "SFP interfaces are ready"

exit "${EXIT_SUCCESS}"
24 changes: 11 additions & 13 deletions files/build_templates/syncd.service.j2
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
[Unit]
Description=syncd service
Requires=database.service updategraph.service
{% if sonic_asic_platform == 'broadcom' %}
Before=ntp-config.service
After=database.service updategraph.service interfaces-config.service swss.service
{%- if sonic_asic_platform == 'mellanox' %}
Wants=mlnx-asic-syncd.service
After=mlnx-asic-syncd.service
{%- elif sonic_asic_platform == 'broadcom' %}
Requires=opennsl-modules.service
{% elif sonic_asic_platform == 'nephos' %}
Requires=nps-modules-4.9.0-9-2-amd64.service
{% endif %}
After=database.service updategraph.service
After=interfaces-config.service
{% if sonic_asic_platform == 'broadcom' %}
After=opennsl-modules.service
{% elif sonic_asic_platform == 'nephos' %}
{%- elif sonic_asic_platform == 'nephos' %}
Requires=nps-modules-4.9.0-9-2-amd64.service
After=nps-modules-4.9.0-9-2-amd64.service
{% endif %}
After=swss.service
Before=ntp-config.service
{%- endif %}

[Service]
User=root
Environment=sonic_asic_platform={{ sonic_asic_platform }}
ExecStartPre=/usr/local/bin/syncd.sh start
ExecStart=/usr/local/bin/syncd.sh wait
ExecStop=/usr/local/bin/syncd.sh stop
{% if sonic_asic_platform == 'mellanox' %}
{%- if sonic_asic_platform == 'mellanox' %}
TimeoutStartSec=150
{% endif %}
{%- endif %}

[Install]
WantedBy=multi-user.target
14 changes: 0 additions & 14 deletions files/scripts/syncd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,6 @@ start() {
export FAST_BOOT=1
fi

if [[ x"$WARM_BOOT" != x"true" ]]; then
if [[ x"$(/bin/systemctl is-active pmon)" == x"active" ]]; then
/bin/systemctl stop pmon
/usr/bin/hw-management.sh chipdown
/bin/systemctl restart pmon
else
/usr/bin/hw-management.sh chipdown
fi
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
Expand Down
2 changes: 1 addition & 1 deletion platform/mellanox/hw-management.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mellanox HW Management

MLNX_HW_MANAGEMENT_VERSION = 2.0.0183
MLNX_HW_MANAGEMENT_VERSION = 2.0.0188

export MLNX_HW_MANAGEMENT_VERSION

Expand Down
11 changes: 11 additions & 0 deletions platform/mellanox/mlnx-asic-syncd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Mellanox ASIC syncd

MLNX_ASIC_SYNCD_VERSION = 1.0.0000

export MLNX_ASIC_SYNCD_VERSION

MLNX_ASIC_SYNCD = mlnx-asic-syncd_1.mlnx.$(MLNX_ASIC_SYNCD_VERSION)_amd64.deb
$(MLNX_ASIC_SYNCD)_SRC_PATH = $(PLATFORM_PATH)/mlnx-asic-syncd
SONIC_MAKE_DEBS += $(MLNX_ASIC_SYNCD)

SONIC_STRETCH_DEBS += $(MLNX_ASIC_SYNCD)
12 changes: 12 additions & 0 deletions platform/mellanox/mlnx-asic-syncd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.ONESHELL:
SHELL = /bin/bash

MAIN_TARGET = mlnx-asic-syncd_1.mlnx.$(MLNX_ASIC_SYNCD_VERSION)_amd64.deb

$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
pushd asic-syncd
chmod +x ./debian/rules
sudo ./debian/rules binary
popd

mv $* $(DEST)/
4 changes: 4 additions & 0 deletions platform/mellanox/mlnx-asic-syncd/asic-syncd/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mlnx-asic-syncd (1.mlnx.1.0.0000) unstable; urgency=low
[ MLNX ]

-- MellanoxBSP <[email protected]> Tue, 4 Jun 2019 10:54:17 +0300
1 change: 1 addition & 0 deletions platform/mellanox/mlnx-asic-syncd/asic-syncd/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
12 changes: 12 additions & 0 deletions platform/mellanox/mlnx-asic-syncd/asic-syncd/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Source: mlnx-asic-syncd
Maintainer: MellanoxBSP <[email protected]>
Section: utils
Priority: optional
Build-Depends: debhelper, dh-systemd
Standards-Version:
Homepage: http://www.mellanox.com

Package:mlnx-asic-syncd
Architecture: any
Depends: systemd, ${shlibs:Depends}, ${misc:Depends}
Description: ASIC syncd for Mellanox platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts/* usr/bin/
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=ASIC syncd for Mellanox platforms
Requires=syncd.service
Wants=hw-management.service database.service
Before=syncd.service
After=hw-management.service database.service

[Service]
Type=simple
RemainAfterExit=true
ExecStartPre=/bin/sh -c "/usr/bin/mlnx-asic-syncd.sh prestart"
ExecStart=/bin/sh -c "/usr/bin/mlnx-asic-syncd.sh start"
ExecStop=/bin/sh -c "/usr/bin/mlnx-asic-syncd.sh stop"
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=mlnx-asic-syncd
SyslogFacility=daemon
SyslogLevel=err

[Install]
WantedBy=multi-user.target
4 changes: 4 additions & 0 deletions platform/mellanox/mlnx-asic-syncd/asic-syncd/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/make -f

%:
dh $@ --with=systemd
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

declare -r SYSLOG_LOGGER="/usr/bin/logger"
declare -r SYSLOG_IDENTIFIER="mlnx-asic-syncd"
declare -r SYSLOG_ERROR="error"
declare -r SYSLOG_NOTICE="notice"
declare -r SYSLOG_INFO="info"

declare -r SYSTEMCTL_PMON_IS_ACTIVE="/bin/systemctl is-active pmon"
declare -r SYSTEMCTL_PMON_ACTIVE="active"
declare -r SYSTEMCTL_PMON_STOP="/bin/systemctl stop pmon"
declare -r SYSTEMCTL_PMON_RESTART="/bin/systemctl restart pmon"

declare -r HW_MGMT_CHIPUP="/usr/bin/hw-management.sh chipup"
declare -r HW_MGMT_CHIPDOWN="/usr/bin/hw-management.sh chipdown"

declare -r APPL_DB_ID="0"
declare -r APPL_DB_KEY="PORT_TABLE:PortInitDone"
declare -r APPL_DB_KEYS_QUERY="redis-cli -n ${APPL_DB_ID} keys '*'"
declare -r APPL_DB_QUERY_TIMEOUT="1s"

declare -r EXIT_SUCCESS="0"
declare -r EXIT_FAILURE="1"

function log_error() {
eval "${SYSLOG_LOGGER} -t ${SYSLOG_IDENTIFIER} -p ${SYSLOG_ERROR} $@"
}

function log_notice() {
eval "${SYSLOG_LOGGER} -t ${SYSLOG_IDENTIFIER} -p ${SYSLOG_NOTICE} $@"
}

function log_info() {
eval "${SYSLOG_LOGGER} -t ${SYSLOG_IDENTIFIER} -p ${SYSLOG_INFO} $@"
}

function run_cmd() {
local _EXIT_CODE="${EXIT_SUCCESS}"

eval "$@" > /dev/null
_EXIT_CODE="$?"

if [[ "${_EXIT_CODE}" != "${EXIT_SUCCESS}" ]]; then
log_error "command failed: $@"
fi
}

function prestart() {
if [[ "$(eval ${SYSTEMCTL_PMON_IS_ACTIVE})" = "${SYSTEMCTL_PMON_ACTIVE}" ]]; then
log_info "Stop pmon service"
run_cmd "${SYSTEMCTL_PMON_STOP}"

log_info "Disconnect ASIC from I2C"
run_cmd "${HW_MGMT_CHIPDOWN}"

log_info "Restart pmon service"
run_cmd "${SYSTEMCTL_PMON_RESTART}"
else
log_info "Disconnect ASIC from I2C"
run_cmd "${HW_MGMT_CHIPDOWN}"
fi
}

function start() {
log_notice "Starting ${SYSLOG_IDENTIFIER} service..."

while [[ "$(eval ${APPL_DB_KEYS_QUERY} | grep ${APPL_DB_KEY})" != "${APPL_DB_KEY}" ]]; do
sleep "${APPL_DB_QUERY_TIMEOUT}"
done

log_info "Connect ASIC to I2C"
run_cmd "${HW_MGMT_CHIPUP}"
}

function stop() {
log_notice "Stopping ${SYSLOG_IDENTIFIER} service..."
}

case "$1" in
prestart|start|stop)
eval "$1"
;;
*)
echo "Usage: $0 {prestart|start|stop}"
exit "${EXIT_SUCCESS}"
;;
esac
2 changes: 1 addition & 1 deletion platform/mellanox/one-image.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SONIC_ONE_IMAGE = sonic-mellanox.bin
$(SONIC_ONE_IMAGE)_MACHINE = mellanox
$(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie
$(SONIC_ONE_IMAGE)_INSTALLS += $(SX_KERNEL) $(KERNEL_MFT) $(MFT_OEM) $(MFT) $(MLNX_HW_MANAGEMENT)
$(SONIC_ONE_IMAGE)_INSTALLS += $(SX_KERNEL) $(KERNEL_MFT) $(MFT_OEM) $(MFT) $(MLNX_HW_MANAGEMENT) $(MLNX_ASIC_SYNCD)
ifeq ($(INSTALL_DEBUG_TOOLS),y)
$(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_DBG_IMAGES)
$(SONIC_ONE_IMAGE)_DOCKERS += $(filter-out $(patsubst %-$(DBG_IMAGE_MARK).gz,%.gz, $(SONIC_INSTALL_DOCKER_DBG_IMAGES)), $(SONIC_INSTALL_DOCKER_IMAGES))
Expand Down
1 change: 1 addition & 0 deletions platform/mellanox/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include $(PLATFORM_PATH)/one-image.mk
include $(PLATFORM_PATH)/libsaithrift-dev.mk
include $(PLATFORM_PATH)/docker-ptf-mlnx.mk
include $(PLATFORM_PATH)/mlnx-sfpd.mk
include $(PLATFORM_PATH)/mlnx-asic-syncd.mk
include $(PLATFORM_PATH)/mlnx-ffb.mk
include $(PLATFORM_PATH)/issu-version.mk

Expand Down