diff --git a/userspace/libwr/i2c_sfp.c b/userspace/libwr/i2c_sfp.c index dc750e4154fac9adb43e7a698c200688b467b5ce..2b20a82d2fd8e58adffe1f928decba6b7caee0be 100644 --- a/userspace/libwr/i2c_sfp.c +++ b/userspace/libwr/i2c_sfp.c @@ -8,6 +8,7 @@ #include <string.h> #include <unistd.h> #include <errno.h> +#include <stddef.h> #include <libwr/pio.h> #include <libwr/wrs-msg.h> @@ -659,6 +660,38 @@ int shw_sfp_read_dom(int num, struct shw_sfp_dom *dom) return 0; } +/* read only values that are updated in real-time */ +int shw_sfp_read_dom_rt(int num, struct shw_sfp_dom *dom) +{ + int ret; + int rt_size; + size_t offset_temp; + + if (shw_sfp_id(num) < 0) { + pr_error("shw_sfp_read_header: wrong SFP num %d\n", num + 1); + return -1; + } + + ret = shw_sfp_module_scan(); + if (!(ret & (1 << num))) { + pr_error("shw_sfp_read_header: SFP not present %d\n", num + 1); + return -2; + } + + offset_temp = offsetof(struct shw_sfp_dom, temp); + rt_size = offsetof(struct shw_sfp_dom, alw) - offset_temp; + + ret = shw_sfp_read(num, I2C_SFP_DOM_ADDRESS, offset_temp, rt_size, + (uint8_t *) dom + offset_temp); + if (ret == I2C_DEV_NOT_FOUND) { + pr_error("shw_sfp_read_header: I2C_DEV_NOT_FOUND\n"); + return -ENODEV; + } + + return 0; +} + + /* Function to update SFP's Diagnostic Monitoring data from SFP's eeprom */ int shw_sfp_update_dom(int num, struct shw_sfp_dom *dom) { @@ -666,6 +699,15 @@ int shw_sfp_update_dom(int num, struct shw_sfp_dom *dom) return shw_sfp_read_dom(num, dom); } +/* Update the SFP diagnostics page, only real-time values */ +int shw_sfp_update_dom_rt(int num, struct shw_sfp_dom *dom) +{ + /* Copy only fields updated in real-time */ + return shw_sfp_read_dom_rt(num, dom); +} + + + int shw_sfp_read_verify_header(int num, struct shw_sfp_header *head) { int ret; diff --git a/userspace/libwr/include/libwr/sfp_lib.h b/userspace/libwr/include/libwr/sfp_lib.h index 1b492ae560b266c353d856e51ea713bce70f29fa..17ec2759543e1e51e0c9e601e92e1cfd5fc6487f 100644 --- a/userspace/libwr/include/libwr/sfp_lib.h +++ b/userspace/libwr/include/libwr/sfp_lib.h @@ -189,6 +189,9 @@ int shw_sfp_read_dom(int num, struct shw_sfp_dom *dom); /* Update the SFP diagnostics page */ int shw_sfp_update_dom(int num, struct shw_sfp_dom *dom); +/* Update the SFP diagnostics page, only real-time values */ +int shw_sfp_update_dom_rt(int num, struct shw_sfp_dom *dom); + /* Decode and print the SFP real time diagnostics */ void shw_sfp_print_dom(struct shw_sfp_dom * dom); diff --git a/userspace/wrsw_hal/hal_ports.c b/userspace/wrsw_hal/hal_ports.c index 445ce49b858b83ff2f7c28c8a2de0f1a1916ab2d..9834a4519f994860542d3abc417616d058128824 100644 --- a/userspace/wrsw_hal/hal_ports.c +++ b/userspace/wrsw_hal/hal_ports.c @@ -592,8 +592,8 @@ static void _cb_port_poll_sfp_dom(int timerId){ if (ps->in_use && ps->sfpPresent && ps->has_sfp_diag) { - shw_sfp_update_dom(ps->hw_index, - &sfp_dom_raw[i]); + shw_sfp_update_dom_rt(ps->hw_index, + &sfp_dom_raw[i]); } ps++; }