Commit 78aa9559 authored by Adam Wujek's avatar Adam Wujek 💬

[Issue: #195] userspace/wrsw_hal: unlock shmem before reading DOM from SFPs

Otherwise most of the time is spent with the HAL's shmem locked.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 8ec67be0
...@@ -644,6 +644,7 @@ static void hal_port_poll_sfp(void) ...@@ -644,6 +644,7 @@ static void hal_port_poll_sfp(void)
void hal_port_update_all() void hal_port_update_all()
{ {
int i; int i;
struct shw_sfp_dom sfp_dom_raw[HAL_MAX_PORTS];
/* poll_rts_state does not write to shmem */ /* poll_rts_state does not write to shmem */
if (libwr_tmo_expired(&hal_port_tmo_rts)) if (libwr_tmo_expired(&hal_port_tmo_rts))
...@@ -659,22 +660,43 @@ void hal_port_update_all() ...@@ -659,22 +660,43 @@ void hal_port_update_all()
hal_port_fsm(&ports[i]); hal_port_fsm(&ports[i]);
} }
/* unlock shmem */
wrs_shm_write(hal_shmem_hdr, WRS_SHM_WRITE_END);
if (hal_shmem->read_sfp_diag == READ_SFP_DIAG_ENABLE if (hal_shmem->read_sfp_diag == READ_SFP_DIAG_ENABLE
&& libwr_tmo_expired(&update_sfp_dom_tmo)) { && libwr_tmo_expired(&update_sfp_dom_tmo)) {
/* get the DOM data to local memory */
for (i = 0; i < HAL_MAX_PORTS; i++) { for (i = 0; i < HAL_MAX_PORTS; i++) {
/* update DOM only for plugged ports with DOM /* read DOM only for plugged ports with DOM
* capabilities */ * capabilities */
if (ports[i].in_use if (ports[i].in_use
&& ports[i].state != HAL_PORT_STATE_DISABLED && ports[i].state != HAL_PORT_STATE_DISABLED
&& (ports[i].has_sfp_diag)) { && (ports[i].has_sfp_diag)) {
shw_sfp_update_dom(ports[i].hw_index, shw_sfp_update_dom(ports[i].hw_index,
&ports[i].calib.sfp_dom_raw); &sfp_dom_raw[i]);
}
}
/* lock shmem */
wrs_shm_write(hal_shmem_hdr, WRS_SHM_WRITE_BEGIN);
/* copy the DOM from local memory to shmem */
for (i = 0; i < HAL_MAX_PORTS; i++) {
/* update DOM only for plugged ports with DOM
* capabilities */
if (ports[i].in_use
&& ports[i].state != HAL_PORT_STATE_DISABLED
&& (ports[i].has_sfp_diag)) {
memcpy(&ports[i].calib.sfp_dom_raw,
&sfp_dom_raw[i],
sizeof(struct shw_sfp_dom));
} }
} }
/* unlock shmem */
wrs_shm_write(hal_shmem_hdr, WRS_SHM_WRITE_END);
} }
/* unlock shmem */
wrs_shm_write(hal_shmem_hdr, WRS_SHM_WRITE_END);
if (libwr_tmo_expired(&update_link_leds_tmo)) { if (libwr_tmo_expired(&update_link_leds_tmo)) {
/* update color of the link LEDs */ /* update color of the link LEDs */
......
Markdown is supported
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