aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/usrp3/n230/n230_eth_handlers.c35
-rw-r--r--firmware/usrp3/n230/n230_eth_handlers.h2
-rw-r--r--firmware/usrp3/n230/n230_fw_defs.h2
-rw-r--r--firmware/usrp3/n230/n230_main.c2
4 files changed, 30 insertions, 11 deletions
diff --git a/firmware/usrp3/n230/n230_eth_handlers.c b/firmware/usrp3/n230/n230_eth_handlers.c
index aebae4161..98b8bc326 100644
--- a/firmware/usrp3/n230/n230_eth_handlers.c
+++ b/firmware/usrp3/n230/n230_eth_handlers.c
@@ -249,12 +249,11 @@ void n230_register_flash_comms_handler()
#define SFPP_STATUS_TXFAULT (1 << 1) // TXFAULT state
#define SFPP_STATUS_RXLOS (1 << 0) // RXLOS state
-static bool links_up[N230_MAX_NUM_ETH_PORTS] = {};
+static bool links_up[N230_MAX_NUM_ETH_PORTS] = {};
+static uint32_t packet_count[N230_MAX_NUM_ETH_PORTS] = {};
-void n230_poll_sfp_status(const uint32_t eth)
+void n230_poll_sfp_status(const uint32_t eth, bool force)
{
- static bool first_poll = 1;
-
// Has MODDET/MODAbS changed since we last looked?
uint32_t rb = wb_peek32(SR_ADDR(WB_SBRB_BASE, (eth==0) ? RB_ZPU_SFP_STATUS0 : RB_ZPU_SFP_STATUS1));
@@ -266,7 +265,7 @@ void n230_poll_sfp_status(const uint32_t eth)
UHD_FW_TRACE_FSTR(DEBUG, "eth%1d MODABS changed state: %d", eth, ((rb & SFPP_STATUS_MODABS) >> 2));
//update the link up status
- if ((rb & SFPP_STATUS_RXLOS_CHG) || (rb & SFPP_STATUS_TXFAULT_CHG) || (rb & SFPP_STATUS_MODABS_CHG) || first_poll)
+ if ((rb & SFPP_STATUS_RXLOS_CHG) || (rb & SFPP_STATUS_TXFAULT_CHG) || (rb & SFPP_STATUS_MODABS_CHG) || force)
{
const bool old_link_up = links_up[eth];
const uint32_t status_reg_addr = (eth==0) ? RB_ZPU_SFP_STATUS0 : RB_ZPU_SFP_STATUS1;
@@ -298,18 +297,36 @@ void n230_poll_sfp_status(const uint32_t eth)
}
}
}
-
- first_poll = 0;
}
-void n230_handle_sfp_updates(soft_reg_t* led_reg)
+void n230_update_link_act_state(soft_reg_t* led_reg)
{
+ static bool first_poll = 1;
+ static uint32_t poll_cnt;
+
+ bool activity[N230_MAX_NUM_ETH_PORTS] = {};
for (uint32_t i = 0; i < N230_NUM_ETH_PORTS; i++) {
- n230_poll_sfp_status(i);
+ if (first_poll) {
+ links_up[i] = 0;
+ packet_count[i] = 0;
+ poll_cnt = 0;
+ }
+
+ //Check SFP status
+ n230_poll_sfp_status(i, first_poll);
+
+ //Check packet counters less frequently to keep the LED on for a visible duration
+ uint32_t cnt = wb_peek32(SR_ADDR(WB_SBRB_BASE, (i==0)?RB_ZPU_ETH0_PKT_CNT:RB_ZPU_ETH1_PKT_CNT));
+ activity[i] = (cnt != packet_count[i]);
+ packet_count[i] = cnt;
}
//TODO: Swap this when Ethernet port swap issues is fixed
soft_reg_write(led_reg, LED_REG_FIELD_ETH_LINK2, links_up[0]?1:0);
soft_reg_write(led_reg, LED_REG_FIELD_ETH_LINK1, links_up[1]?1:0);
+ soft_reg_write(led_reg, LED_REG_FIELD_ETH_ACT2, activity[0]?1:0);
+ soft_reg_write(led_reg, LED_REG_FIELD_ETH_ACT1, activity[1]?1:0);
+
+ first_poll = 0;
}
diff --git a/firmware/usrp3/n230/n230_eth_handlers.h b/firmware/usrp3/n230/n230_eth_handlers.h
index 9b9be7b78..86130e361 100644
--- a/firmware/usrp3/n230/n230_eth_handlers.h
+++ b/firmware/usrp3/n230/n230_eth_handlers.h
@@ -43,6 +43,6 @@ void n230_register_flash_comms_handler();
/*!
* Handle SFP updates.
*/
-void n230_handle_sfp_updates(soft_reg_t* led_reg);
+void n230_update_link_act_state(soft_reg_t* led_reg);
#endif /* INCLUDED_N230_ETH_HANDLERS_H */
diff --git a/firmware/usrp3/n230/n230_fw_defs.h b/firmware/usrp3/n230/n230_fw_defs.h
index 8b66b03ad..fbdc67ebb 100644
--- a/firmware/usrp3/n230/n230_fw_defs.h
+++ b/firmware/usrp3/n230/n230_fw_defs.h
@@ -82,6 +82,8 @@ static const uint32_t RB_ZPU_COMPAT = 0;
static const uint32_t RB_ZPU_COUNTER = 1;
static const uint32_t RB_ZPU_SFP_STATUS0 = 2;
static const uint32_t RB_ZPU_SFP_STATUS1 = 3;
+static const uint32_t RB_ZPU_ETH0_PKT_CNT = 6;
+static const uint32_t RB_ZPU_ETH1_PKT_CNT = 7;
/*******************************************************************
* Ethernet
diff --git a/firmware/usrp3/n230/n230_main.c b/firmware/usrp3/n230/n230_main.c
index f9d93bf4a..ceb896514 100644
--- a/firmware/usrp3/n230/n230_main.c
+++ b/firmware/usrp3/n230/n230_main.c
@@ -75,7 +75,7 @@ int main(void)
if (cron_job_run_due(PER_MILLISEC_CRON_JOBID)) {
//Everything in this block runs approx once per millisecond
n230_handle_claim();
- n230_handle_sfp_updates(&g_led_register);
+ n230_update_link_act_state(&g_led_register);
}
//run the network stack - poll and handle