Skip to content

Commit ba59d57

Browse files
Mathias Thoredavem330
authored andcommitted
net/wan/fsl_ucc_hdlc: error counters
Extract error information from rx and tx buffer descriptors, and update error counters. Signed-off-by: Mathias Thore <mathias.thore@infinera.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2af1ccd commit ba59d57

2 files changed

Lines changed: 51 additions & 8 deletions

File tree

‎drivers/net/wan/fsl_ucc_hdlc.c‎

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#define DRV_NAME "ucc_hdlc"
3737

3838
#define TDM_PPPOHT_SLIC_MAXIN
39+
#define RX_BD_ERRORS (R_CD_S | R_OV_S | R_CR_S | R_AB_S | R_NO_S | R_LG_S)
3940

4041
static struct ucc_tdm_info utdm_primary_info = {
4142
.uf_info = {
@@ -430,12 +431,25 @@ static netdev_tx_t ucc_hdlc_tx(struct sk_buff *skb, struct net_device *dev)
430431
return NETDEV_TX_OK;
431432
}
432433

434+
static int hdlc_tx_restart(struct ucc_hdlc_private *priv)
435+
{
436+
u32 cecr_subblock;
437+
438+
cecr_subblock =
439+
ucc_fast_get_qe_cr_subblock(priv->ut_info->uf_info.ucc_num);
440+
441+
qe_issue_cmd(QE_RESTART_TX, cecr_subblock,
442+
QE_CR_PROTOCOL_UNSPECIFIED, 0);
443+
return 0;
444+
}
445+
433446
static int hdlc_tx_done(struct ucc_hdlc_private *priv)
434447
{
435448
/* Start from the next BD that should be filled */
436449
struct net_device *dev = priv->ndev;
437450
struct qe_bd *bd; /* BD pointer */
438451
u16 bd_status;
452+
int tx_restart = 0;
439453

440454
bd = priv->dirty_tx;
441455
bd_status = ioread16be(&bd->status);
@@ -444,6 +458,15 @@ static int hdlc_tx_done(struct ucc_hdlc_private *priv)
444458
while ((bd_status & T_R_S) == 0) {
445459
struct sk_buff *skb;
446460

461+
if (bd_status & T_UN_S) { /* Underrun */
462+
dev->stats.tx_fifo_errors++;
463+
tx_restart = 1;
464+
}
465+
if (bd_status & T_CT_S) { /* Carrier lost */
466+
dev->stats.tx_carrier_errors++;
467+
tx_restart = 1;
468+
}
469+
447470
/* BD contains already transmitted buffer. */
448471
/* Handle the transmitted buffer and release */
449472
/* the BD to be used with the current frame */
@@ -475,6 +498,9 @@ static int hdlc_tx_done(struct ucc_hdlc_private *priv)
475498
}
476499
priv->dirty_tx = bd;
477500

501+
if (tx_restart)
502+
hdlc_tx_restart(priv);
503+
478504
return 0;
479505
}
480506

@@ -493,11 +519,22 @@ static int hdlc_rx_done(struct ucc_hdlc_private *priv, int rx_work_limit)
493519

494520
/* while there are received buffers and BD is full (~R_E) */
495521
while (!((bd_status & (R_E_S)) || (--rx_work_limit < 0))) {
496-
if (bd_status & R_OV_S)
497-
dev->stats.rx_over_errors++;
498-
if (bd_status & R_CR_S) {
499-
dev->stats.rx_crc_errors++;
500-
dev->stats.rx_dropped++;
522+
if (bd_status & (RX_BD_ERRORS)) {
523+
dev->stats.rx_errors++;
524+
525+
if (bd_status & R_CD_S)
526+
dev->stats.collisions++;
527+
if (bd_status & R_OV_S)
528+
dev->stats.rx_fifo_errors++;
529+
if (bd_status & R_CR_S)
530+
dev->stats.rx_crc_errors++;
531+
if (bd_status & R_AB_S)
532+
dev->stats.rx_over_errors++;
533+
if (bd_status & R_NO_S)
534+
dev->stats.rx_frame_errors++;
535+
if (bd_status & R_LG_S)
536+
dev->stats.rx_length_errors++;
537+
501538
goto recycle;
502539
}
503540
bdbuffer = priv->rx_buffer +
@@ -546,7 +583,7 @@ static int hdlc_rx_done(struct ucc_hdlc_private *priv, int rx_work_limit)
546583
netif_receive_skb(skb);
547584

548585
recycle:
549-
iowrite16be(bd_status | R_E_S | R_I_S, &bd->status);
586+
iowrite16be((bd_status & R_W_S) | R_E_S | R_I_S, &bd->status);
550587

551588
/* update to point at the next bd */
552589
if (bd_status & R_W_S) {
@@ -622,7 +659,7 @@ static irqreturn_t ucc_hdlc_irq_handler(int irq, void *dev_id)
622659

623660
/* Errors and other events */
624661
if (ucce >> 16 & UCC_HDLC_UCCE_BSY)
625-
dev->stats.rx_errors++;
662+
dev->stats.rx_missed_errors++;
626663
if (ucce >> 16 & UCC_HDLC_UCCE_TXE)
627664
dev->stats.tx_errors++;
628665

‎include/soc/fsl/qe/ucc_fast.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@
4141
#define R_L_S 0x0800 /* last */
4242
#define R_F_S 0x0400 /* first */
4343
#define R_CM_S 0x0200 /* continuous mode */
44+
#define R_LG_S 0x0020 /* frame length */
45+
#define R_NO_S 0x0010 /* nonoctet */
46+
#define R_AB_S 0x0008 /* abort */
4447
#define R_CR_S 0x0004 /* crc */
45-
#define R_OV_S 0x0002 /* crc */
48+
#define R_OV_S 0x0002 /* overrun */
49+
#define R_CD_S 0x0001 /* carrier detect */
4650

4751
/* transmit BD's status */
4852
#define T_R_S 0x8000 /* ready bit */
@@ -51,6 +55,8 @@
5155
#define T_L_S 0x0800 /* last */
5256
#define T_TC_S 0x0400 /* crc */
5357
#define T_TM_S 0x0200 /* continuous mode */
58+
#define T_UN_S 0x0002 /* hdlc underrun */
59+
#define T_CT_S 0x0001 /* hdlc carrier lost */
5460

5561
/* Rx Data buffer must be 4 bytes aligned in most cases */
5662
#define UCC_FAST_RX_ALIGN 4

0 commit comments

Comments
 (0)