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

temp commit for independent modules code #8

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4b85757
temp commit for independent modules code
dbarashinvd Aug 17, 2023
90aa94e
update modules mgmt to have new state db table
dbarashinvd Sep 20, 2023
c19187d
Fix issues and separate to static module detection
dbarashinvd Sep 26, 2023
b71e69e
fix issues and change waiting list to Set
dbarashinvd Oct 1, 2023
f105501
added fixes and retries to power on and hw reset
dbarashinvd Oct 8, 2023
87fe6e8
added mci max freq. write commmented out due to bug in SDK
dbarashinvd Oct 11, 2023
e222cf0
change all logger from warning to info
dbarashinvd Oct 11, 2023
0b2bea5
fix comments of internal CR part 1
dbarashinvd Oct 11, 2023
97f9f47
fix CR comments part 2
dbarashinvd Oct 12, 2023
9fbcbe3
remove workaround using hw_reset for xcvr_api returned None
dbarashinvd Oct 16, 2023
fa65a6a
fix CR comments part 3 and add critical fixes
dbarashinvd Oct 17, 2023
c29d578
fix test_change_event test and align code to it
Junchao-Mellanox Oct 19, 2023
fc3912a
Add copyright header and try except for fds poller
dbarashinvd Oct 25, 2023
6824551
fix DPB bug of port not exists
dbarashinvd Oct 26, 2023
21586c2
fix get_sfp returns None
dbarashinvd Oct 29, 2023
f966b80
Junchao: Fix issues found in module detection flow
Junchao-Mellanox Nov 2, 2023
ca7d986
Junchao: Fix issue: wrong FD is used for dynamic detection
Junchao-Mellanox Nov 3, 2023
e555c06
Junchao: Fix issue: dummy read flow should use poll
Junchao-Mellanox Nov 6, 2023
f1ce61a
Junchao: fix typo in modules_mgmt
Junchao-Mellanox Nov 7, 2023
100fd69
Junchao: workaround for dummy read issue
Junchao-Mellanox Nov 7, 2023
875e73e
fix log typo and dynamic issue, remove old dummy
dbarashinvd Nov 13, 2023
d43b683
add hw_present fd registration to poll for shutdown port
dbarashinvd Nov 15, 2023
a52f918
fix plug out-in not detected when independent mode disabled
dbarashinvd Nov 22, 2023
b926a3f
fix dynamic detection not resetting states upon cable plug out
dbarashinvd Nov 26, 2023
40a3c68
Merge branch 'master' of github.com:Azure/sonic-buildimage into dbara…
dbarashinvd Nov 27, 2023
ccec845
fix dynamic detection cable plug in flow
dbarashinvd Nov 27, 2023
4210b1b
Update modules_mgmt thread to be a daemon and deleted the use of the …
dbarashinvd Dec 4, 2023
95eefa9
Merge branch 'sonic-net:master' into dbarashi_indep_mode_temp
dbarashinvd Dec 5, 2023
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
66 changes: 40 additions & 26 deletions platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
from . import utils
from .device_data import DeviceDataManager
import re
import queue
import threading
import time
from sonic_platform import modules_mgmt
except ImportError as e:
raise ImportError (str(e) + "- required module not found")

Expand Down Expand Up @@ -123,6 +126,12 @@ def __init__(self):
self._RJ45_port_inited = False
self._RJ45_port_list = None

self.threads = []
dbarashinvd marked this conversation as resolved.
Show resolved Hide resolved
self.modules_mgmt_thread = threading.Thread()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.modules_mgmt_thread = None

self.modules_changes_queue = queue.Queue()
self.modules_queue_lock = threading.Lock()
dbarashinvd marked this conversation as resolved.
Show resolved Hide resolved
self.modules_mgmt_task_stopping_event = threading.Event()

logger.log_info("Chassis loaded successfully")

def __del__(self):
Expand All @@ -133,6 +142,11 @@ def __del__(self):
if self.sfp_module.SFP.shared_sdk_handle:
self.sfp_module.deinitialize_sdk_handle(self.sfp_module.SFP.shared_sdk_handle)

#self.modules_mgmt_task_stopping_event.set()
dbarashinvd marked this conversation as resolved.
Show resolved Hide resolved
#logger.log_info('set modules_mgmt_task_stopping_event {self.modules_mgmt_task_stopping_event}')
#self.modules_mgmt_thread.join(timeout=10)
#logger.log_info('joined modules_mgmt_thread thread')

@property
def RJ45_port_list(self):
if not self._RJ45_port_inited:
Expand Down Expand Up @@ -366,11 +380,11 @@ def get_change_event(self, timeout=0):

Args:
timeout: Timeout in milliseconds (optional). If timeout == 0,
this method will block until a change is detected.
this method will block until a change is detected. - Deprecated
dbarashinvd marked this conversation as resolved.
Show resolved Hide resolved

Returns:
(bool, dict):
- True if call successful, False if not;
- True if call successful, False if not; - Deprecated, will always return True
- A nested dictionary where key is a device type,
value is a dictionary with key:value pairs in the format of
{'device_id':'device_event'},
Expand All @@ -382,38 +396,38 @@ def get_change_event(self, timeout=0):
indicates that fan 0 has been removed, fan 2
has been inserted and sfp 11 has been removed.
"""
if not self.modules_mgmt_thread.is_alive():
# open new SFP change events thread
self.modules_mgmt_thread = modules_mgmt.ModulesMgmtTask(q=self.modules_changes_queue
, l=self.modules_queue_lock
, main_thread_stop_event = self.modules_mgmt_task_stopping_event)
self.modules_mgmt_thread.start()
self.threads.append(self.modules_mgmt_thread)
self.initialize_sfp()
# Initialize SFP event first
if not self.sfp_event:
from .sfp_event import sfp_event
self.sfp_event = sfp_event(self.RJ45_port_list)
self.sfp_event.initialize()

wait_for_ever = (timeout == 0)
# select timeout should be no more than 1000ms to ensure fast shutdown flow
select_timeout = 1000.0 if timeout >= 1000 else float(timeout)
port_dict = {}
error_dict = {}
begin = time.time()
i = 0
while True:
status = self.sfp_event.check_sfp_status(port_dict, error_dict, select_timeout)
if bool(port_dict):
break
logger.log_info('get_change_event() acquiring queue lock iteration {}'.format(i))
self.modules_queue_lock.acquire()
if self.modules_changes_queue.qsize() > 0:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need this check

if True:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove it

try:
logger.log_info('get_change_event() trying to get changes from queue')
port_dict = self.modules_changes_queue.get(timeout=1)
logger.log_info ('get_change_event() port_dict: {}'.format(port_dict))
except queue.Empty:
logger.log_info("failed to get item from modules changes queue")
logger.log_info('get_change_event() releasing queue lock iteration {}'.format(i))
self.modules_queue_lock.release()

if not wait_for_ever:
elapse = time.time() - begin
if elapse * 1000 > timeout:
break

if status:
if port_dict:
self.reinit_sfps(port_dict)
result_dict = {'sfp': port_dict}
if error_dict:
result_dict = {'sfp': port_dict}
result_dict['sfp_error'] = error_dict
return True, result_dict
else:
return True, {'sfp': {}}
return True, result_dict
time.sleep(1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove it

i += 1

def reinit_sfps(self, port_dict):
"""
Expand Down
Loading