Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mellanox] Use a service to clear eeprom cache #77

Closed
wants to merge 1 commit into from
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
1 change: 1 addition & 0 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ start() {
-v mlnx_sdk_ready:/tmp \
-e SX_API_SOCKET_FILE=/var/run/sx_sdk/sx_api.sock \
-v /dev/shm:/dev/shm:rw \
-v /var/cache/sonic/decode-syseeprom:/var/cache/sonic/decode-syseeprom:rw \
{%- else %}
{%- if mount_default_tmpfs|default("n") == "y" %}
--tmpfs /tmp \
Expand Down
6 changes: 6 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,12 @@ sudo cp $IMAGE_CONFIGS/pcie-check/pcie-check.service $FILESYSTEM_ROOT_USR_LIB_SY
echo "pcie-check.service" | sudo tee -a $GENERATED_SERVICE_FILE
sudo cp $IMAGE_CONFIGS/pcie-check/pcie-check.sh $FILESYSTEM_ROOT/usr/bin/

{% if sonic_asic_platform == "mellanox" %}
sudo cp $IMAGE_CONFIGS/eeprom-cache-clear/eeprom-cache-clear.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
echo "eeprom-cache-clear.service" | sudo tee -a $GENERATED_SERVICE_FILE
sudo cp $IMAGE_CONFIGS/eeprom-cache-clear/eeprom-cache-clear.sh $FILESYSTEM_ROOT/usr/bin/
{% endif %}

## Install package without starting service
## ref: https://wiki.debian.org/chroot
sudo tee -a $FILESYSTEM_ROOT/usr/sbin/policy-rc.d > /dev/null <<EOF
Expand Down
11 changes: 11 additions & 0 deletions files/image_config/eeprom-cache-clear/eeprom-cache-clear.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Clear EEPROM cache file
After=rc.local.service database.service
Before=pmon.service

[Service]
Type=simple
ExecStart=/usr/bin/eeprom-cache-clear.sh

[Install]
WantedBy=multi-user.target
8 changes: 8 additions & 0 deletions files/image_config/eeprom-cache-clear/eeprom-cache-clear.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /bin/bash
## Clear EEPROM cache

CACHE_ROOT="/var/cache/sonic/decode-syseeprom"
CACHE_FILE="syseeprom_cache"

mkdir -p ${CACHE_ROOT}
rm -f ${CACHE_ROOT}/${CACHE_FILE}
14 changes: 1 addition & 13 deletions platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self):

if not (os.path.exists(EEPROM_SYMLINK) \
or os.path.isfile(os.path.join(CACHE_ROOT, CACHE_FILE))):
log_error("Nowhere to read syseeprom from! No symlink or cache file found")
logger.log_error("Nowhere to read syseeprom from! No symlink or cache file found")
raise RuntimeError("No syseeprom symlink or cache file found")

self.eeprom_path = EEPROM_SYMLINK
Expand All @@ -66,18 +66,6 @@ def __init__(self):

def _load_eeprom(self):
cache_file = os.path.join(CACHE_ROOT, CACHE_FILE)
if not os.path.exists(CACHE_ROOT):
try:
os.makedirs(CACHE_ROOT)
except:
pass
else:
try:
# Make sure first time always read eeprom data from hardware
if os.path.exists(cache_file):
os.remove(cache_file)
except Exception as e:
logger.log_error('Failed to remove cache file {} - {}'.format(cache_file, repr(e)))

try:
self.set_cache_name(cache_file)
Expand Down