Commit fbfe2b63 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

minic: improve error reporting

parent bd93a61a
......@@ -40,6 +40,7 @@
struct wr_minic minic;
int ver_supported;
static inline void minic_writel(uint32_t reg, uint32_t data)
{
*(volatile uint32_t *)(BASE_MINIC + reg) = data;
......@@ -122,6 +123,7 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
uint64_t sec;
uint32_t counter_r, counter_f, counter_ppsg;
int cntr_diff;
int got_rx_error = 0;
/* check if there is something in the Rx FIFO to be retrieved */
......@@ -162,21 +164,20 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
* beginning of next frame. We check hdr_size > 0 to
* make sure it's not the first received word, i.e. our
* own initial status.*/
pp_printf("Rxstat %x\n", rx_data);
//pp_printf("Rxstat %x\n", rx_data);
if (RX_STATUS_ERROR(rx_data))
{
pp_printf("Warning: Minic received erroneous "
"frame\n");
got_rx_error = 1;
}
break;
} else if ( rx_type == WRF_OOB) {
pp_printf("rxoob\n");
//pp_printf("rxoob\n");
if (oob_cnt == 0)
oob_hdr = rx_data;
else if (oob_cnt == 1)
......@@ -224,11 +225,21 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
}
/* Increment Rx counter for statistics */
minic.rx_count++;
if( got_rx_error )
{
minic.rx_errors++;
} else {
minic.rx_count++;
return -1;
}
if (minic_readl(MINIC_REG_MCR) & MINIC_MCR_RX_FULL)
pp_printf("Warning: Minic Rx fifo full, expect wrong frames\n");
/* return number of bytes written to the *payload buffer */
return (buf_size < payload_size ? buf_size : payload_size);
}
......@@ -348,8 +359,10 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size,
return size;
}
void minic_get_stats(int *tx_frames, int *rx_frames)
void minic_get_stats(int *tx_frames, int *rx_frames, int *rx_errors)
{
*tx_frames = minic.tx_count;
*rx_frames = minic.rx_count;
if(rx_errors)
*rx_errors = minic.rx_errors;
}
......@@ -24,7 +24,7 @@
void minic_init(void);
void minic_disable(void);
int minic_poll_rx(void);
void minic_get_stats(int *tx_frames, int *rx_frames);
void minic_get_stats(int *tx_frames, int *rx_frames, int*rx_errors);
struct wr_ethhdr {
uint8_t dstmac[6];
......@@ -41,7 +41,7 @@ struct wr_ethhdr_vlan {
};
struct wr_minic {
int tx_count, rx_count;
int tx_count, rx_count, rx_errors;
};
extern struct wr_minic minic;
......
......@@ -95,6 +95,7 @@ static int wrc_mon_status(void)
return 1;
}
int wrc_mon_gui(void)
{
static uint32_t last_jiffies;
......@@ -146,8 +147,9 @@ int wrc_mon_gui(void)
if( i == 0 ) // fixme: independent rx/tx stats for each interface
{
minic_get_stats(&tx, &rx);
cprintf(C_GREY, "(RX: %d, TX: %d)", rx, tx);
int rx_er;
minic_get_stats(&tx, &rx, &rx_er);
cprintf(C_GREY, "(RX: %d, TX: %d, RX errors: %d)", rx, tx, rx_er);
}
}
......@@ -286,7 +288,7 @@ int wrc_mon_gui(void)
cprintf(C_WHITE, "%27d\n", (int32_t) (s->update_count));
cprintf(C_GREY, "Extra stats: ");
cprintf(C_WHITE, "Sync packet errors: %d followup errors: %d servo restarts: %d\n", ppi->stats.sync_errors, ppi->stats.followup_errors, ppi->stats.servo_restarts);
cprintf(C_WHITE, " Sync packet errors: %d followup errors: %d servo restarts: %d\n", ppi->stats.sync_errors, ppi->stats.followup_errors, ppi->stats.servo_restarts);
return 0;
}
......@@ -368,7 +370,7 @@ int wrc_log_stats(void)
shw_pps_gen_get_time(&sec, &nsec);
wrpc_get_port_state(&state, NULL);
minic_get_stats(&tx, &rx);
minic_get_stats(&tx, &rx, NULL);
pp_printf("lnk:%d rx:%d tx:%d ", state.state, rx, tx);
pp_printf("lock:%d ", state.locked ? 1 : 0);
pp_printf("ptp:%s ", wrc_ptp_state());
......@@ -463,7 +465,7 @@ int wrc_wr_diags(void)
wdiag_set_valid(0);
/* frame statistics */
minic_get_stats(&tx, &rx);
minic_get_stats(&tx, &rx, NULL);
wdiags_write_cnts(tx,rx);
/* local time */
......@@ -560,7 +562,7 @@ int wrc_diags_dump(struct WRC_DIAGS_WB *buf)
buf->VER = 0x12345678;
buf->CTRL = 0xcafebabe;
/* frame statistics */
minic_get_stats(&tx, &rx);
minic_get_stats(&tx, &rx, NULL);
buf->WDIAG_TXFCNT = tx;
buf->WDIAG_RXFCNT = rx;
......
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