@@ -68,6 +68,8 @@ def update_table_mux_status_for_response_tbl(table_name, status, logical_port_na
68
68
fvs = swsscommon .FieldValuePairs ([('response' , status )])
69
69
table_name .set (logical_port_name , fvs )
70
70
71
+ helper_logger .log_debug ("Y_CABLE_DEBUG: Successful in returning probe port status {}" .format (logical_port_name ))
72
+
71
73
72
74
def update_table_mux_status_for_statedb_port_tbl (table_name , status , read_side , active_side , logical_port_name ):
73
75
fvs = swsscommon .FieldValuePairs ([('state' , status ),
@@ -78,6 +80,8 @@ def update_table_mux_status_for_statedb_port_tbl(table_name, status, read_side,
78
80
79
81
def y_cable_toggle_mux_torA (physical_port ):
80
82
update_status = y_cable .toggle_mux_to_torA (physical_port )
83
+
84
+ helper_logger .log_debug ("Y_CABLE_DEBUG: Status of toggling mux to ToR A for port {} {}" .format (physical_port , update_status ))
81
85
if update_status is True :
82
86
return 1
83
87
else :
@@ -88,6 +92,8 @@ def y_cable_toggle_mux_torA(physical_port):
88
92
89
93
def y_cable_toggle_mux_torB (physical_port ):
90
94
update_status = y_cable .toggle_mux_to_torB (physical_port )
95
+
96
+ helper_logger .log_debug ("Y_CABLE_DEBUG: Status of toggling mux to ToR B for port {} {}" .format (physical_port , update_status ))
91
97
if update_status is True :
92
98
return 2
93
99
else :
@@ -173,6 +179,8 @@ def update_appdb_port_mux_cable_response_table(logical_port_name, asic_index, ap
173
179
helper_logger .log_warning (
174
180
"Error: Could not get state for mux cable port probe command logical port {} and physical port {}" .format (logical_port_name , physical_port ))
175
181
182
+ helper_logger .log_debug ("Y_CABLE_DEBUG: notifying a probe for port status {} {}" .format (logical_port_name , status ))
183
+
176
184
update_table_mux_status_for_response_tbl (y_cable_response_tbl [asic_index ], status , logical_port_name )
177
185
178
186
else :
@@ -347,17 +355,21 @@ def init_ports_status_for_y_cable(platform_sfp, platform_chassis, y_cable_presen
347
355
config_db , state_db , port_tbl , y_cable_tbl = {}, {}, {}, {}
348
356
static_tbl , mux_tbl = {}, {}
349
357
port_table_keys = {}
358
+ xcvrd_log_tbl = {}
350
359
351
360
y_cable_platform_sfputil = platform_sfp
352
361
y_cable_platform_chassis = platform_chassis
353
362
363
+ fvs_updated = swsscommon .FieldValuePairs ([('enable_log' , 'false' )])
354
364
# Get the namespaces in the platform
355
365
namespaces = multi_asic .get_front_end_namespaces ()
356
366
for namespace in namespaces :
357
367
asic_id = multi_asic .get_asic_index_from_namespace (namespace )
358
368
config_db [asic_id ] = daemon_base .db_connect ("CONFIG_DB" , namespace )
359
369
port_tbl [asic_id ] = swsscommon .Table (config_db [asic_id ], "MUX_CABLE" )
360
370
port_table_keys [asic_id ] = port_tbl [asic_id ].getKeys ()
371
+ xcvrd_log_tbl [asic_id ] = swsscommon .Table (config_db [asic_id ], "XCVRD_LOG" )
372
+ xcvrd_log_tbl [asic_id ].set ("Y_CABLE" , fvs_updated )
361
373
362
374
# Init PORT_STATUS table if ports are on Y cable
363
375
logical_port_list = y_cable_platform_sfputil .logical
@@ -996,10 +1008,11 @@ def __init__(self):
996
1008
def task_worker (self ):
997
1009
998
1010
# Connect to STATE_DB and APPL_DB and get both the HW_MUX_STATUS_TABLE info
999
- appl_db , state_db , status_tbl , y_cable_tbl = {}, {}, {}, {}
1011
+ appl_db , state_db , config_db , status_tbl , y_cable_tbl = {}, {}, {}, {}, {}
1000
1012
y_cable_tbl_keys = {}
1001
1013
mux_cable_command_tbl , y_cable_command_tbl = {}, {}
1002
1014
mux_metrics_tbl = {}
1015
+ xcvrd_log_tbl = {}
1003
1016
1004
1017
sel = swsscommon .Select ()
1005
1018
@@ -1009,6 +1022,7 @@ def task_worker(self):
1009
1022
# Open a handle to the Application database, in all namespaces
1010
1023
asic_id = multi_asic .get_asic_index_from_namespace (namespace )
1011
1024
appl_db [asic_id ] = daemon_base .db_connect ("APPL_DB" , namespace )
1025
+ config_db [asic_id ] = daemon_base .db_connect ("CONFIG_DB" , namespace )
1012
1026
status_tbl [asic_id ] = swsscommon .SubscriberStateTable (
1013
1027
appl_db [asic_id ], swsscommon .APP_HW_MUX_CABLE_TABLE_NAME )
1014
1028
mux_cable_command_tbl [asic_id ] = swsscommon .SubscriberStateTable (
@@ -1020,9 +1034,12 @@ def task_worker(self):
1020
1034
state_db [asic_id ], swsscommon .STATE_HW_MUX_CABLE_TABLE_NAME )
1021
1035
mux_metrics_tbl [asic_id ] = swsscommon .Table (
1022
1036
state_db [asic_id ], swsscommon .STATE_MUX_METRICS_TABLE_NAME )
1037
+ xcvrd_log_tbl [asic_id ] = swsscommon .SubscriberStateTable (
1038
+ config_db [asic_id ], "XCVRD_LOG" )
1023
1039
y_cable_tbl_keys [asic_id ] = y_cable_tbl [asic_id ].getKeys ()
1024
1040
sel .addSelectable (status_tbl [asic_id ])
1025
1041
sel .addSelectable (mux_cable_command_tbl [asic_id ])
1042
+ sel .addSelectable (xcvrd_log_tbl [asic_id ])
1026
1043
1027
1044
# Listen indefinitely for changes to the HW_MUX_CABLE_TABLE in the Application DB's
1028
1045
while True :
@@ -1048,9 +1065,12 @@ def task_worker(self):
1048
1065
1049
1066
while True :
1050
1067
(port , op , fvp ) = status_tbl [asic_index ].pop ()
1068
+
1051
1069
if not port :
1052
1070
break
1053
1071
1072
+ helper_logger .log_debug ("Y_CABLE_DEBUG: received an event for port transition {}" .format (port ))
1073
+
1054
1074
# entering this section signifies a start for xcvrd state
1055
1075
# change request from swss so initiate recording in mux_metrics table
1056
1076
time_start = datetime .datetime .utcnow ().strftime ("%Y-%b-%d %H:%M:%S.%f" )
@@ -1075,6 +1095,7 @@ def task_worker(self):
1075
1095
old_status = mux_port_dict .get ("state" )
1076
1096
read_side = mux_port_dict .get ("read_side" )
1077
1097
# Now whatever is the state requested, toggle the mux appropriately
1098
+ helper_logger .log_debug ("Y_CABLE_DEBUG: xcvrd trying to transition port {} from {} to {}" .format (port , old_status , new_status ))
1078
1099
active_side = update_tor_active_side (read_side , new_status , port )
1079
1100
if active_side == - 1 :
1080
1101
helper_logger .log_warning ("ERR: Got a change event for toggle but could not toggle the mux-direction for port {} state from {} to {}, writing unknown" .format (
@@ -1085,6 +1106,7 @@ def task_worker(self):
1085
1106
('read_side' , read_side ),
1086
1107
('active_side' , str (active_side ))])
1087
1108
y_cable_tbl [asic_index ].set (port , fvs_updated )
1109
+ helper_logger .log_debug ("Y_CABLE_DEBUG: xcvrd successful to transition port {} from {} to {} and write back to the DB" .format (port , old_status , new_status ))
1088
1110
helper_logger .log_info ("Got a change event for toggle the mux-direction active side for port {} state from {} to {}" .format (
1089
1111
port , old_status , new_status ))
1090
1112
time_end = datetime .datetime .utcnow ().strftime ("%Y-%b-%d %H:%M:%S.%f" )
@@ -1097,8 +1119,11 @@ def task_worker(self):
1097
1119
1098
1120
while True :
1099
1121
(port_m , op_m , fvp_m ) = mux_cable_command_tbl [asic_index ].pop ()
1122
+
1100
1123
if not port_m :
1101
1124
break
1125
+ helper_logger .log_debug ("Y_CABLE_DEBUG: received a probe for port status {}" .format (port_m ))
1126
+
1102
1127
if fvp_m :
1103
1128
1104
1129
if port_m not in y_cable_tbl_keys [asic_index ]:
@@ -1120,6 +1145,30 @@ def task_worker(self):
1120
1145
read_side = mux_port_dict .get ("read_side" )
1121
1146
update_appdb_port_mux_cable_response_table (port_m , asic_index , appl_db , int (read_side ))
1122
1147
1148
+ while True :
1149
+ (key , op_m , fvp_m ) = xcvrd_log_tbl [asic_index ].pop ()
1150
+
1151
+ if not key :
1152
+ break
1153
+
1154
+ helper_logger .log_notice ("Y_CABLE_DEBUG: trying to enable/disable debug logs" )
1155
+ if fvp_m :
1156
+
1157
+ if key is "Y_CABLE" :
1158
+ continue
1159
+
1160
+ fvp_dict = dict (fvp_m )
1161
+ if "log_verbosity" in fvp_dict :
1162
+ # check if xcvrd got a probe command
1163
+ probe_identifier = fvp_dict ["log_verbosity" ]
1164
+
1165
+ if probe_identifier == "debug" :
1166
+ helper_logger .set_min_log_priority_debug ()
1167
+
1168
+ elif probe_identifier == "notice" :
1169
+ helper_logger .set_min_log_priority_notice ()
1170
+
1171
+
1123
1172
def task_run (self ):
1124
1173
self .task_thread = threading .Thread (target = self .task_worker )
1125
1174
self .task_thread .start ()
0 commit comments