Skip to content

Commit

Permalink
[ycable][credo] Fix the is_link_active API for Credo Ycable (#260)
Browse files Browse the repository at this point in the history
Signed-off-by: vaibhav-dahiya vdahiya@microsoft.com

Description
Currently is_link_active API was broken because it was not using the target param in the routine to give back the correct link_status of ecah side. With this change it gives the correct result.

Motivation and Context
Required for MUX_CABLE_INFO table in streaming telemetry if the cable is disconnected or the link is down.

redis-cli -n 6 hgetall "MUX_CABLE_INFO|Ethernet16"
"
 9) "link_status_self"
10) "down"
11) "link_status_peer"
12) "up"
13) "link_status_nic"
14) "up"
How Has This Been Tested?
Tested on actual Arista7050cx3 testbed.
  • Loading branch information
vdahiya12 authored Feb 15, 2022
1 parent 931c6ea commit 5da31e1
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions sonic_y_cable/credo/y_cable_credo.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,15 +787,24 @@ def is_link_active(self, target):

regval_read = struct.unpack(">B", result)

if (regval_read[0] & 0x01):
self.log_info("NIC link is up")
return True
elif ((regval_read[0] >> 2) & 0x01):
self.log_info("TOR A link is up")
return True
elif ((regval_read[0] >> 1) & 0x01):
self.log_info("TOR B link is up")
return True
if target == YCableBase.TARGET_NIC:
if (regval_read[0] & 0x01):
self.log_info("NIC link is up")
return True
else:
return False
elif target == YCableBase.TARGET_TOR_A:
if ((regval_read[0] >> 2) & 0x01):
self.log_info("TOR A link is up")
return True
else:
return False
elif target == YCableBase.TARGET_TOR_B:
if ((regval_read[0] >> 1) & 0x01):
self.log_info("TOR B link is up")
return True
else:
return False
else:
return YCableBase.TARGET_UNKNOWN

Expand Down

0 comments on commit 5da31e1

Please sign in to comment.