Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
9 changes: 9 additions & 0 deletions files/build_templates/pcie-chk.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Start the pcie-chk.service in 10 seconds after boot

[Timer]
OnBootSec=10sec
Unit=pcie-chk.service

[Install]
WantedBy=timers.target
9 changes: 9 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,15 @@ sudo cp $IMAGE_CONFIGS/procdockerstatsd/procdockerstatsd.service $FILESYSTEM_ROO
echo "procdockerstatsd.service" | sudo tee -a $GENERATED_SERVICE_FILE
sudo cp $IMAGE_CONFIGS/procdockerstatsd/procdockerstatsd $FILESYSTEM_ROOT/usr/bin/

# Copy systemd timer configuration
sudo cp $BUILD_TEMPLATES/pcie-chk.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable pcie-chk.timer

# Copy pcie-chk service files
sudo cp $IMAGE_CONFIGS/pcie-chk/pcie-chk.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
echo "pcie-chk.service" | sudo tee -a $GENERATED_SERVICE_FILE
sudo cp $IMAGE_CONFIGS/pcie-chk.sh $FILESYSTEM_ROOT/usr/bin/

# Copy systemd timer configuration
# It implements delayed start of services
sudo cp $BUILD_TEMPLATES/process-reboot-cause.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
Expand Down
8 changes: 8 additions & 0 deletions files/image_config/pcie-chk/pcie-chk.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Check the PCIe device presence and status
After=rc.local.service

[Service]
Type=simple
ExecStart=/usr/bin/pcie-chk.sh

33 changes: 33 additions & 0 deletions files/image_config/pcie-chk/pcie-chk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! /bin/bash
## Check the platform PCIe device presence and status

VERBOSE="no"
RESULTS="PCIe Device Checking All Test"
PCIE_CHK_CMD=`sudo pcieutil pcie-check |grep "$RESULTS"`
EXPECTED="PCIe Device Checking All Test ----------->>> PASSED"
MAX_RESCAN=15

function debug()
{
/usr/bin/logger "$0 : $1"
if [[ x"${VERBOSE}" == x"yes" ]]; then
echo "$(date) $0: $1"
fi
}

function check_and_rescan_pcie_devices()
{
for i in $(seq 1 1 $MAX_RESCAN)
do
if [ "$PCIE_CHK_CMD" = "$EXPECTED" ]; then
debug "PCIe check passed"
exit
else
debug "PCIe check failed, try pci bus rescan"
echo 1 > /sys/bus/pci/rescan
fi
sleep 1
done
}

check_and_rescan_pcie_devices