Skip to content
Snippets Groups Projects
Commit 66e7623c authored by Fabian Mauchle's avatar Fabian Mauchle Committed by Adam Wujek
Browse files

[FEATURE: #313] userspace/libwr: fix sfp dom datatypes


Signed-off-by: default avatarAdam Wujek <dev_public@wujek.eu>
parent f9d846d9
Branches
Tags
No related merge requests found
......@@ -10,6 +10,7 @@
#include <errno.h>
#include <stddef.h>
#include <math.h>
#include <arpa/inet.h>
#include <libwr/pio.h>
#include <libwr/wrs-msg.h>
......@@ -351,11 +352,11 @@ void shw_sfp_print_header(struct shw_sfp_header *head)
void shw_sfp_print_dom(struct shw_sfp_dom * dom)
{
float tx_pow = (dom->tx_pow[0]*256 + dom->tx_pow[1])/(float)10000;
float rx_pow = (dom->rx_pow[0]*256 + dom->rx_pow[1])/(float)10000;
printf("Temperature: %.3f C\n", (int8_t)dom->temp[0] + dom->temp[1]/(float)256);
printf("Voltage: %.3f V\n", (dom->vcc[0]*256 + dom->vcc[1])/(float)10000);
printf("Bias Current: %.3f mA\n", (dom->tx_bias[0]*256+dom->tx_bias[1])/(float)500);
float tx_pow = (ntohs(dom->tx_pow))/(float)10000;
float rx_pow = (ntohs(dom->rx_pow))/(float)10000;
printf("Temperature: %.3f C\n", (int16_t)ntohs(dom->temp)/(float)256);
printf("Voltage: %.3f V\n", ntohs(dom->vcc)/(float)10000);
printf("Bias Current: %.3f mA\n", ntohs(dom->tx_bias)/(float)500);
printf("TX power: %.4f mW (%.1f dBm)\n", tx_pow, 10 * log10(tx_pow));
printf("RX power: %.4f mW (%.1f dBm)\n", rx_pow, 10 * log10(rx_pow));
}
......
......@@ -134,11 +134,12 @@ struct shw_sfp_dom {
uint8_t cal_unalloc[3];
uint8_t CC_DMI;
/* Real Time Diagnostics, 96-111 */
uint8_t temp[2];
uint8_t vcc[2];
uint8_t tx_bias[2];
uint8_t tx_pow[2];
uint8_t rx_pow[2];
int16_t temp; /* signed 16bit twos complement int, units if
* 1/256 C */
uint16_t vcc; /* unsigned 16bit int, units of 0.1mV */
uint16_t tx_bias; /* unsigned 16bit int, units of 2uA */
uint16_t tx_pow; /* unsigned 16bit int, units of 0.1uW */
uint16_t rx_pow; /* unsigned 16bit int, units of 0.1uW */
uint8_t rtd_unalloc0[4];
uint8_t OSCB;
uint8_t rtd_unalloc1;
......
......@@ -2546,7 +2546,7 @@ wrsPortStatusSfpTemp OBJECT-TYPE
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Temperature reported by SFP. According to SFF-8472, accuracy of
"Temperature in 0.1 C reported by SFP. According to SFF-8472, accuracy of
this value must be better than 3 degrees Celsius"
::= { wrsPortStatusEntry 17 }
......@@ -2555,7 +2555,7 @@ wrsPortStatusSfpVcc OBJECT-TYPE
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Internally measured transceiver supply voltage reported by SFP.
"Internally measured transceiver supply voltage in 0.1 mV reported by SFP.
According to SFF-8472, accuracy of this value must be better than 3%"
::= { wrsPortStatusEntry 18 }
......@@ -2573,7 +2573,7 @@ wrsPortStatusSfpTxPower OBJECT-TYPE
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Measured TX output power in uW reported by SFP.
"Measured TX output power in 0.1 uW reported by SFP.
According to SFF-8472, accuracy of this value must be better than 3dB%"
::= { wrsPortStatusEntry 20 }
......@@ -2582,7 +2582,7 @@ wrsPortStatusSfpRxPower OBJECT-TYPE
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Measured RX output power in uW reported by SFP.
"Measured RX output power in 0.1 uW reported by SFP.
According to SFF-8472, accuracy of this value must be better than 3dB%"
::= { wrsPortStatusEntry 21 }
......
......@@ -148,15 +148,15 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
if (port_state->has_sfp_diag) {
wrsPortStatusTable->wrsPortStatusSfpDom = WRS_PORT_STATUS_SFP_DOM_ENABLE;
/* temp in C */
wrsPortStatusTable->wrsPortStatusSfpTemp = ntohs(*port_state->calib.sfp_dom_raw.temp)/256;
wrsPortStatusTable->wrsPortStatusSfpTemp = ntohs(port_state->calib.sfp_dom_raw.temp)/25.6;
/* vcc in mV */
wrsPortStatusTable->wrsPortStatusSfpVcc = ntohs(*port_state->calib.sfp_dom_raw.vcc)/10;
wrsPortStatusTable->wrsPortStatusSfpVcc = ntohs(port_state->calib.sfp_dom_raw.vcc);
/* tx_bias in uA */
wrsPortStatusTable->wrsPortStatusSfpTxBias = ntohs(*port_state->calib.sfp_dom_raw.tx_bias)*2;
wrsPortStatusTable->wrsPortStatusSfpTxBias = ntohs(port_state->calib.sfp_dom_raw.tx_bias)*2;
/* tx_pow in uW */
wrsPortStatusTable->wrsPortStatusSfpTxPower = ntohs(*port_state->calib.sfp_dom_raw.tx_pow)/10;
wrsPortStatusTable->wrsPortStatusSfpTxPower = ntohs(port_state->calib.sfp_dom_raw.tx_pow);
/* rx_pow in uW */
wrsPortStatusTable->wrsPortStatusSfpRxPower = ntohs(*port_state->calib.sfp_dom_raw.rx_pow)/10;
wrsPortStatusTable->wrsPortStatusSfpRxPower = ntohs(port_state->calib.sfp_dom_raw.rx_pow);
} else {
wrsPortStatusTable->wrsPortStatusSfpDom = WRS_PORT_STATUS_SFP_DOM_NOT_SUPPORTED;
}
......
......@@ -246,17 +246,17 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
printf("\n");
break;
case dump_type_sfp_dom_temp:
printf("%.3f C\n", ntohs(*(short *)p)/(float)256);
printf("%.3f C\n", (int16_t)ntohs(*(uint16_t *)p)/(float)256);
break;
case dump_type_sfp_dom_voltage:
printf("%.3f V\n", ntohs(*(short *)p)/(float)10000);
printf("%.3f V\n", ntohs(*(uint16_t *)p)/(float)10000);
break;
case dump_type_sfp_dom_bias_curr:
printf("%.3f mA\n", ntohs(*(short *)p)/(float)500);
printf("%.3f mA\n", ntohs(*(uint16_t *)p)/(float)500);
break;
case dump_type_sfp_dom_tx_power:
case dump_type_sfp_dom_rx_power:
printf("%.3f mW\n", ntohs(*(short *)p)/(float)10000);
printf("%.3f mW\n", ntohs(*(uint16_t *)p)/(float)10000);
break;
case dump_type_port_mode:
i = *(uint32_t *)p;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment