Skip to content

Commit

Permalink
kamel: Cherry-pick mW/dBm fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecmd committed Oct 13, 2024
1 parent 05cf5c1 commit 6c84f07
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions sonic_platform_base/sonic_xcvr/api/public/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def get_transceiver_bulk_status(self):

for i in range(1, self.NUM_CHANNELS + 1):
bulk_status["tx%dbias" % i] = tx_bias[i - 1]
bulk_status["rx%dpower" % i] = rx_power[i - 1]
bulk_status["tx%dpower" % i] = tx_power[i - 1]
bulk_status["rx%dpower" % i] = self.mw_to_dbm(rx_power[i - 1]) if rx_power[i - 1] != 'N/A' else 'N/A'
bulk_status["tx%dpower" % i] = self.mw_to_dbm(tx_power[i - 1]) if tx_power[i - 1] != 'N/A' else 'N/A'

return bulk_status

Expand Down
4 changes: 2 additions & 2 deletions sonic_platform_base/sonic_xcvr/api/public/sff8472.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def get_transceiver_bulk_status(self):

for i in range(1, self.NUM_CHANNELS + 1):
bulk_status["tx%dbias" % i] = tx_bias[i - 1]
bulk_status["rx%dpower" % i] = rx_power[i - 1]
bulk_status["tx%dpower" % i] = tx_power[i - 1]
bulk_status["rx%dpower" % i] = self.mw_to_dbm(rx_power[i - 1]) if rx_power[i - 1] != 'N/A' else 'N/A'
bulk_status["tx%dpower" % i] = self.mw_to_dbm(tx_power[i - 1]) if tx_power[i - 1] != 'N/A' else 'N/A'

# Added to avoid failing xcvrd. Ideally xcvrd should be fixed so that this is not necessary
for i in range(2, 5):
Expand Down
4 changes: 2 additions & 2 deletions sonic_platform_base/sonic_xcvr/api/public/sff8636.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def get_transceiver_bulk_status(self):

for i in range(1, self.NUM_CHANNELS + 1):
bulk_status["tx%dbias" % i] = tx_bias[i - 1]
bulk_status["rx%dpower" % i] = rx_power[i - 1]
bulk_status["tx%dpower" % i] = tx_power[i - 1]
bulk_status["rx%dpower" % i] = self.mw_to_dbm(rx_power[i - 1]) if rx_power[i - 1] != 'N/A' else 'N/A'
bulk_status["tx%dpower" % i] = self.mw_to_dbm(tx_power[i - 1]) if tx_power[i - 1] != 'N/A' else 'N/A'

return bulk_status

Expand Down
2 changes: 1 addition & 1 deletion sonic_platform_base/sonic_xcvr/api/xcvr_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def mw_to_dbm(mW):
return float("-inf")
elif mW < 0:
return float("NaN")
return 10. * log10(mW)
return round(10. * log10(mW), 3)

def get_model(self):
"""
Expand Down

0 comments on commit 6c84f07

Please sign in to comment.