From 78aa9559d9b293478dca6d4c1ea06fe39ab0a0c8 Mon Sep 17 00:00:00 2001 From: Adam Wujek <adam.wujek@cern.ch> Date: Wed, 19 Jun 2019 16:30:00 +0200 Subject: [PATCH] [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 <adam.wujek@cern.ch> --- userspace/wrsw_hal/hal_ports.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/userspace/wrsw_hal/hal_ports.c b/userspace/wrsw_hal/hal_ports.c index 361b99e91..e7d71109a 100644 --- a/userspace/wrsw_hal/hal_ports.c +++ b/userspace/wrsw_hal/hal_ports.c @@ -644,6 +644,7 @@ static void hal_port_poll_sfp(void) void hal_port_update_all() { int i; + struct shw_sfp_dom sfp_dom_raw[HAL_MAX_PORTS]; /* poll_rts_state does not write to shmem */ if (libwr_tmo_expired(&hal_port_tmo_rts)) @@ -659,22 +660,43 @@ void hal_port_update_all() 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 && libwr_tmo_expired(&update_sfp_dom_tmo)) { + /* get the DOM data to local memory */ 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 */ if (ports[i].in_use && ports[i].state != HAL_PORT_STATE_DISABLED && (ports[i].has_sfp_diag)) { 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)) { /* update color of the link LEDs */ -- GitLab