Skip to content

Commit 068bccc

Browse files
authored
[xcvrd] Store mux_cable telemetry data in State DB (#148)
* [xcvrd] adding mux_cable data for sonic-telemetry inside state db Summary: This PR provides the necessary infrastructure to initialize the mux_cable info and static tables and post them within state db as part of xcvrd. The data is posted every 60 secs and streaming telemetry can utilize this info. Approach Added changes in the sonic_xcvrd directory of sonic-platform-daemons What is the motivation for this PR? To add the necessary infrastructure for Credo Y cable support for posting streaming telemetry data inside state-db Signed-off-by: vaibhav-dahiya <[email protected]>
1 parent 93cac0a commit 068bccc

File tree

3 files changed

+681
-22
lines changed

3 files changed

+681
-22
lines changed

sonic-xcvrd/tests/test_xcvrd.py

+105-5
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ def test_xcvrd_helper_class_run(self):
6969
def test_post_port_dom_info_to_db(self):
7070
logical_port_name = "Ethernet0"
7171
stop_event = threading.Event()
72-
dom_tbl = Table("state_db", "dom_info_tbl")
72+
dom_tbl = Table("STATE_DB", TRANSCEIVER_DOM_SENSOR_TABLE)
7373
post_port_dom_info_to_db(logical_port_name, dom_tbl, stop_event)
7474

7575
@patch('xcvrd.xcvrd.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
7676
@patch('xcvrd.xcvrd._wrapper_get_presence', MagicMock(return_value=True))
7777
def test_del_port_sfp_dom_info_from_db(self):
7878
logical_port_name = "Ethernet0"
7979
stop_event = threading.Event()
80-
dom_tbl = Table("state_db", "dom_info_tbl")
81-
init_tbl = Table("state_db", "init_info_tbl")
80+
dom_tbl = Table("STATE_DB", TRANSCEIVER_DOM_SENSOR_TABLE)
81+
init_tbl = Table("STATE_DB", TRANSCEIVER_INFO_TABLE)
8282
del_port_sfp_dom_info_from_db(logical_port_name, init_tbl, dom_tbl)
8383

8484
@patch('xcvrd.xcvrd.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
@@ -106,7 +106,7 @@ def test_del_port_sfp_dom_info_from_db(self):
106106
def test_post_port_dom_threshold_info_to_db(self):
107107
logical_port_name = "Ethernet0"
108108
stop_event = threading.Event()
109-
dom_tbl = Table("state_db", "dom_info_tbl")
109+
dom_tbl = Table("STATE_DB", TRANSCEIVER_DOM_SENSOR_TABLE)
110110
post_port_dom_threshold_info_to_db(logical_port_name, dom_tbl, stop_event)
111111

112112
@patch('xcvrd.xcvrd.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
@@ -132,7 +132,7 @@ def test_post_port_dom_threshold_info_to_db(self):
132132
def test_post_port_sfp_info_to_db(self):
133133
logical_port_name = "Ethernet0"
134134
stop_event = threading.Event()
135-
dom_tbl = Table("state_db", "dom_info_tbl")
135+
dom_tbl = Table("STATE_DB", TRANSCEIVER_DOM_SENSOR_TABLE)
136136
transceiver_dict = {}
137137
post_port_sfp_info_to_db(logical_port_name, dom_tbl, transceiver_dict, stop_event)
138138

@@ -215,3 +215,103 @@ def test_post_port_sfp_dom_info_to_db(self):
215215
def test_init_port_sfp_status_tbl(self):
216216
stop_event = threading.Event()
217217
init_port_sfp_status_tbl(stop_event)
218+
219+
@patch('xcvrd.xcvrd_utilities.y_cable_helper.y_cable_platform_sfputil', MagicMock(return_value=[0]))
220+
@patch('y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
221+
@patch('y_cable_helper._wrapper_get_presence', MagicMock(return_value=True))
222+
@patch('y_cable_helper.get_muxcable_info', MagicMock(return_value={'tor_active': 'self',
223+
'mux_direction': 'self',
224+
'manual_switch_count': '7',
225+
'auto_switch_count': '71',
226+
'link_status_self': 'up',
227+
'link_status_peer': 'up',
228+
'link_status_nic': 'up',
229+
'nic_lane1_active': 'True',
230+
'nic_lane2_active': 'True',
231+
'nic_lane3_active': 'True',
232+
'nic_lane4_active': 'True',
233+
'self_eye_height_lane1': '500',
234+
'self_eye_height_lane2': '510',
235+
'peer_eye_height_lane1': '520',
236+
'peer_eye_height_lane2': '530',
237+
'nic_eye_height_lane1': '742',
238+
'nic_eye_height_lane2': '750',
239+
'internal_temperature': '28',
240+
'internal_voltage': '3.3',
241+
'nic_temperature': '20',
242+
'nic_voltage': '2.7',
243+
'build_slot1_nic': 'MS',
244+
'build_slot2_nic': 'MS',
245+
'version_slot1_nic': '1.7',
246+
'version_slot2_nic': '1.7',
247+
'run_slot1_nic': 'True',
248+
'run_slot2_nic': 'False',
249+
'commit_slot1_nic': 'True',
250+
'commit_slot2_nic': 'False',
251+
'empty_slot1_nic': 'True',
252+
'empty_slot2_nic': 'False',
253+
'build_slot1_tor1': 'MS',
254+
'build_slot2_tor1': 'MS',
255+
'version_slot1_tor1': '1.7',
256+
'version_slot2_tor1': '1.7',
257+
'run_slot1_tor1': 'True',
258+
'run_slot2_tor1': 'False',
259+
'commit_slot1_tor1': 'True',
260+
'commit_slot2_tor1': 'False',
261+
'empty_slot1_tor1': 'True',
262+
'empty_slot2_tor1': 'False',
263+
'build_slot1_tor2': 'MS',
264+
'build_slot2_tor2': 'MS',
265+
'version_slot1_tor2': '1.7',
266+
'version_slot2_tor2': '1.7',
267+
'run_slot1_tor2': 'True',
268+
'run_slot2_tor2': 'False',
269+
'commit_slot1_tor2': 'True',
270+
'commit_slot2_tor2': 'False',
271+
'empty_slot1_tor2': 'True',
272+
'empty_slot2_tor2': 'False'}))
273+
def test_post_port_mux_info_to_db(self):
274+
logical_port_name = "Ethernet0"
275+
mux_tbl = Table("STATE_DB", y_cable_helper.MUX_CABLE_INFO_TABLE)
276+
rc = post_port_mux_info_to_db(logical_port_name, mux_tbl)
277+
assert(rc != -1)
278+
279+
@patch('xcvrd.xcvrd_utilities.y_cable_helper.y_cable_platform_sfputil', MagicMock(return_value=[0]))
280+
@patch('y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
281+
@patch('y_cable_helper._wrapper_get_presence', MagicMock(return_value=True))
282+
@patch('y_cable_helper.get_muxcable_static_info', MagicMock(return_value={'read_side': 'self',
283+
'nic_lane1_precursor1': '1',
284+
'nic_lane1_precursor2': '-7',
285+
'nic_lane1_maincursor': '-1',
286+
'nic_lane1_postcursor1': '11',
287+
'nic_lane1_postcursor2': '11',
288+
'nic_lane2_precursor1': '12',
289+
'nic_lane2_precursor2': '7',
290+
'nic_lane2_maincursor': '7',
291+
'nic_lane2_postcursor1': '7',
292+
'nic_lane2_postcursor2': '7',
293+
'tor_self_lane1_precursor1': '17',
294+
'tor_self_lane1_precursor2': '17',
295+
'tor_self_lane1_maincursor': '17',
296+
'tor_self_lane1_postcursor1': '17',
297+
'tor_self_lane1_postcursor2': '17',
298+
'tor_self_lane2_precursor1': '7',
299+
'tor_self_lane2_precursor2': '7',
300+
'tor_self_lane2_maincursor': '7',
301+
'tor_self_lane2_postcursor1': '7',
302+
'tor_self_lane2_postcursor2': '7',
303+
'tor_peer_lane1_precursor1': '7',
304+
'tor_peer_lane1_precursor2': '7',
305+
'tor_peer_lane1_maincursor': '17',
306+
'tor_peer_lane1_postcursor1': '7',
307+
'tor_peer_lane1_postcursor2': '17',
308+
'tor_peer_lane2_precursor1': '7',
309+
'tor_peer_lane2_precursor2': '7',
310+
'tor_peer_lane2_maincursor': '17',
311+
'tor_peer_lane2_postcursor1': '7',
312+
'tor_peer_lane2_postcursor2': '17'}))
313+
def test_post_port_mux_static_info_to_db(self):
314+
logical_port_name = "Ethernet0"
315+
mux_tbl = Table("STATE_DB", y_cable_helper.MUX_CABLE_STATIC_INFO_TABLE)
316+
rc = post_port_mux_static_info_to_db(logical_port_name, mux_tbl)
317+
assert(rc != -1)

sonic-xcvrd/xcvrd/xcvrd.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -832,11 +832,12 @@ def __init__(self):
832832
self.task_thread = None
833833
self.task_stopping_event = threading.Event()
834834

835-
def task_worker(self):
835+
def task_worker(self, y_cable_presence):
836836
helper_logger.log_info("Start DOM monitoring loop")
837837

838838
# Connect to STATE_DB and create transceiver dom info table
839839
state_db, dom_tbl, status_tbl = {}, {}, {}
840+
mux_tbl = {}
840841

841842
# Get the namespaces in the platform
842843
namespaces = multi_asic.get_front_end_namespaces()
@@ -859,14 +860,16 @@ def task_worker(self):
859860
if not detect_port_in_error_status(logical_port_name, status_tbl[asic_index]):
860861
post_port_dom_info_to_db(logical_port_name, dom_tbl[asic_index], self.task_stopping_event)
861862
post_port_dom_threshold_info_to_db(logical_port_name, dom_tbl[asic_index], self.task_stopping_event)
863+
if y_cable_presence[0] is True:
864+
y_cable_helper.check_identifier_presence_and_update_mux_info_entry(state_db, mux_tbl, asic_index, logical_port_name)
862865

863866
helper_logger.log_info("Stop DOM monitoring loop")
864867

865-
def task_run(self):
868+
def task_run(self, y_cable_presence):
866869
if self.task_stopping_event.is_set():
867870
return
868871

869-
self.task_thread = threading.Thread(target=self.task_worker)
872+
self.task_thread = threading.Thread(target=self.task_worker, args=(y_cable_presence,))
870873
self.task_thread.start()
871874

872875
def task_stop(self):
@@ -1325,7 +1328,7 @@ def run(self):
13251328

13261329
# Start the dom sensor info update thread
13271330
dom_info_update = DomInfoUpdateTask()
1328-
dom_info_update.task_run()
1331+
dom_info_update.task_run(self.y_cable_presence)
13291332

13301333
# Start the sfp state info update process
13311334
sfp_state_update = SfpStateUpdateTask()

0 commit comments

Comments
 (0)