aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunil Goutham <sgoutham@cavium.com>2016-06-27 06:00:02 -0400
committerDavid S. Miller <davem@davemloft.net>2016-06-29 05:14:13 -0400
commit3f4c68cfde30caa1f6d8368fd19590671411ade2 (patch)
tree66970b40777a89fb709b8b173f63829c57e64669
parentf5074d0ce2f8b45b3d5998a280edd2066c0cfcda (diff)
net: thunderx: Fix link status reporting
Check for SMU RX local/remote faults along with SPU LINK status. Otherwise at times link is UP at our end but DOWN at link partner's side. Also due to an issue in BGX it's rarely seen that initialization doesn't happen properly and SMU RX reports faults with everything fine at SPU. This patch tries to reinitialize LMAC to fix it. Also fixed LMAC disable sequence to properly bring down link. Signed-off-by: Sunil Goutham <sgoutham@cavium.com> Signed-off-by: Tao Wang <tao.wang@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.c91
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.h2
2 files changed, 62 insertions, 31 deletions
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 3ed21988626b..63a39ac97d53 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -551,7 +551,9 @@ static int bgx_xaui_check_link(struct lmac *lmac)
551 } 551 }
552 552
553 /* Clear rcvflt bit (latching high) and read it back */ 553 /* Clear rcvflt bit (latching high) and read it back */
554 bgx_reg_modify(bgx, lmacid, BGX_SPUX_STATUS2, SPU_STATUS2_RCVFLT); 554 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT)
555 bgx_reg_modify(bgx, lmacid,
556 BGX_SPUX_STATUS2, SPU_STATUS2_RCVFLT);
555 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) { 557 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) {
556 dev_err(&bgx->pdev->dev, "Receive fault, retry training\n"); 558 dev_err(&bgx->pdev->dev, "Receive fault, retry training\n");
557 if (bgx->use_training) { 559 if (bgx->use_training) {
@@ -570,13 +572,6 @@ static int bgx_xaui_check_link(struct lmac *lmac)
570 return -1; 572 return -1;
571 } 573 }
572 574
573 /* Wait for MAC RX to be ready */
574 if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_RX_CTL,
575 SMU_RX_CTL_STATUS, true)) {
576 dev_err(&bgx->pdev->dev, "SMU RX link not okay\n");
577 return -1;
578 }
579
580 /* Wait for BGX RX to be idle */ 575 /* Wait for BGX RX to be idle */
581 if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_CTL, SMU_CTL_RX_IDLE, false)) { 576 if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_CTL, SMU_CTL_RX_IDLE, false)) {
582 dev_err(&bgx->pdev->dev, "SMU RX not idle\n"); 577 dev_err(&bgx->pdev->dev, "SMU RX not idle\n");
@@ -589,29 +584,30 @@ static int bgx_xaui_check_link(struct lmac *lmac)
589 return -1; 584 return -1;
590 } 585 }
591 586
592 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) { 587 /* Clear receive packet disable */
593 dev_err(&bgx->pdev->dev, "Receive fault\n");
594 return -1;
595 }
596
597 /* Receive link is latching low. Force it high and verify it */
598 bgx_reg_modify(bgx, lmacid, BGX_SPUX_STATUS1, SPU_STATUS1_RCV_LNK);
599 if (bgx_poll_reg(bgx, lmacid, BGX_SPUX_STATUS1,
600 SPU_STATUS1_RCV_LNK, false)) {
601 dev_err(&bgx->pdev->dev, "SPU receive link down\n");
602 return -1;
603 }
604
605 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_MISC_CONTROL); 588 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_MISC_CONTROL);
606 cfg &= ~SPU_MISC_CTL_RX_DIS; 589 cfg &= ~SPU_MISC_CTL_RX_DIS;
607 bgx_reg_write(bgx, lmacid, BGX_SPUX_MISC_CONTROL, cfg); 590 bgx_reg_write(bgx, lmacid, BGX_SPUX_MISC_CONTROL, cfg);
608 return 0; 591
592 /* Check for MAC RX faults */
593 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_RX_CTL);
594 /* 0 - Link is okay, 1 - Local fault, 2 - Remote fault */
595 cfg &= SMU_RX_CTL_STATUS;
596 if (!cfg)
597 return 0;
598
599 /* Rx local/remote fault seen.
600 * Do lmac reinit to see if condition recovers
601 */
602 bgx_lmac_xaui_init(bgx, lmacid, bgx->lmac_type);
603
604 return -1;
609} 605}
610 606
611static void bgx_poll_for_link(struct work_struct *work) 607static void bgx_poll_for_link(struct work_struct *work)
612{ 608{
613 struct lmac *lmac; 609 struct lmac *lmac;
614 u64 link; 610 u64 spu_link, smu_link;
615 611
616 lmac = container_of(work, struct lmac, dwork.work); 612 lmac = container_of(work, struct lmac, dwork.work);
617 613
@@ -621,8 +617,11 @@ static void bgx_poll_for_link(struct work_struct *work)
621 bgx_poll_reg(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1, 617 bgx_poll_reg(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1,
622 SPU_STATUS1_RCV_LNK, false); 618 SPU_STATUS1_RCV_LNK, false);
623 619
624 link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1); 620 spu_link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1);
625 if (link & SPU_STATUS1_RCV_LNK) { 621 smu_link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SMUX_RX_CTL);
622
623 if ((spu_link & SPU_STATUS1_RCV_LNK) &&
624 !(smu_link & SMU_RX_CTL_STATUS)) {
626 lmac->link_up = 1; 625 lmac->link_up = 1;
627 if (lmac->bgx->lmac_type == BGX_MODE_XLAUI) 626 if (lmac->bgx->lmac_type == BGX_MODE_XLAUI)
628 lmac->last_speed = 40000; 627 lmac->last_speed = 40000;
@@ -636,9 +635,15 @@ static void bgx_poll_for_link(struct work_struct *work)
636 } 635 }
637 636
638 if (lmac->last_link != lmac->link_up) { 637 if (lmac->last_link != lmac->link_up) {
638 if (lmac->link_up) {
639 if (bgx_xaui_check_link(lmac)) {
640 /* Errors, clear link_up state */
641 lmac->link_up = 0;
642 lmac->last_speed = SPEED_UNKNOWN;
643 lmac->last_duplex = DUPLEX_UNKNOWN;
644 }
645 }
639 lmac->last_link = lmac->link_up; 646 lmac->last_link = lmac->link_up;
640 if (lmac->link_up)
641 bgx_xaui_check_link(lmac);
642 } 647 }
643 648
644 queue_delayed_work(lmac->check_link, &lmac->dwork, HZ * 2); 649 queue_delayed_work(lmac->check_link, &lmac->dwork, HZ * 2);
@@ -710,7 +715,7 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
710static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid) 715static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid)
711{ 716{
712 struct lmac *lmac; 717 struct lmac *lmac;
713 u64 cmrx_cfg; 718 u64 cfg;
714 719
715 lmac = &bgx->lmac[lmacid]; 720 lmac = &bgx->lmac[lmacid];
716 if (lmac->check_link) { 721 if (lmac->check_link) {
@@ -719,9 +724,33 @@ static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid)
719 destroy_workqueue(lmac->check_link); 724 destroy_workqueue(lmac->check_link);
720 } 725 }
721 726
722 cmrx_cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); 727 /* Disable packet reception */
723 cmrx_cfg &= ~(1 << 15); 728 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG);
724 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cmrx_cfg); 729 cfg &= ~CMR_PKT_RX_EN;
730 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);
731
732 /* Give chance for Rx/Tx FIFO to get drained */
733 bgx_poll_reg(bgx, lmacid, BGX_CMRX_RX_FIFO_LEN, (u64)0x1FFF, true);
734 bgx_poll_reg(bgx, lmacid, BGX_CMRX_TX_FIFO_LEN, (u64)0x3FFF, true);
735
736 /* Disable packet transmission */
737 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG);
738 cfg &= ~CMR_PKT_TX_EN;
739 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);
740
741 /* Disable serdes lanes */
742 if (!lmac->is_sgmii)
743 bgx_reg_modify(bgx, lmacid,
744 BGX_SPUX_CONTROL1, SPU_CTL_LOW_POWER);
745 else
746 bgx_reg_modify(bgx, lmacid,
747 BGX_GMP_PCS_MRX_CTL, PCS_MRX_CTL_PWR_DN);
748
749 /* Disable LMAC */
750 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG);
751 cfg &= ~CMR_EN;
752 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);
753
725 bgx_flush_dmac_addrs(bgx, lmacid); 754 bgx_flush_dmac_addrs(bgx, lmacid);
726 755
727 if ((bgx->lmac_type != BGX_MODE_XFI) && 756 if ((bgx->lmac_type != BGX_MODE_XFI) &&
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
index 149e179363a1..42010d2e5ddf 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
@@ -41,6 +41,7 @@
41#define BGX_CMRX_RX_STAT10 0xC0 41#define BGX_CMRX_RX_STAT10 0xC0
42#define BGX_CMRX_RX_BP_DROP 0xC8 42#define BGX_CMRX_RX_BP_DROP 0xC8
43#define BGX_CMRX_RX_DMAC_CTL 0x0E8 43#define BGX_CMRX_RX_DMAC_CTL 0x0E8
44#define BGX_CMRX_RX_FIFO_LEN 0x108
44#define BGX_CMR_RX_DMACX_CAM 0x200 45#define BGX_CMR_RX_DMACX_CAM 0x200
45#define RX_DMACX_CAM_EN BIT_ULL(48) 46#define RX_DMACX_CAM_EN BIT_ULL(48)
46#define RX_DMACX_CAM_LMACID(x) (x << 49) 47#define RX_DMACX_CAM_LMACID(x) (x << 49)
@@ -50,6 +51,7 @@
50#define BGX_CMR_CHAN_MSK_AND 0x450 51#define BGX_CMR_CHAN_MSK_AND 0x450
51#define BGX_CMR_BIST_STATUS 0x460 52#define BGX_CMR_BIST_STATUS 0x460
52#define BGX_CMR_RX_LMACS 0x468 53#define BGX_CMR_RX_LMACS 0x468
54#define BGX_CMRX_TX_FIFO_LEN 0x518
53#define BGX_CMRX_TX_STAT0 0x600 55#define BGX_CMRX_TX_STAT0 0x600
54#define BGX_CMRX_TX_STAT1 0x608 56#define BGX_CMRX_TX_STAT1 0x608
55#define BGX_CMRX_TX_STAT2 0x610 57#define BGX_CMRX_TX_STAT2 0x610