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
4041static 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+
433446static 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
548585recycle :
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
0 commit comments