Lines Matching refs:bgx
43 struct bgx *bgx; member
67 struct bgx { struct
79 static struct bgx *bgx_vnic[MAX_BGX_THUNDER]; argument
107 static u64 bgx_reg_read(struct bgx *bgx, u8 lmac, u64 offset) in bgx_reg_read() argument
109 void __iomem *addr = bgx->reg_base + ((u32)lmac << 20) + offset; in bgx_reg_read()
114 static void bgx_reg_write(struct bgx *bgx, u8 lmac, u64 offset, u64 val) in bgx_reg_write() argument
116 void __iomem *addr = bgx->reg_base + ((u32)lmac << 20) + offset; in bgx_reg_write()
121 static void bgx_reg_modify(struct bgx *bgx, u8 lmac, u64 offset, u64 val) in bgx_reg_modify() argument
123 void __iomem *addr = bgx->reg_base + ((u32)lmac << 20) + offset; in bgx_reg_modify()
128 static int bgx_poll_reg(struct bgx *bgx, u8 lmac, u64 reg, u64 mask, bool zero) in bgx_poll_reg() argument
134 reg_val = bgx_reg_read(bgx, lmac, reg); in bgx_poll_reg()
169 static struct bgx *get_bgx(int node, int bgx_idx) in get_bgx()
194 struct bgx *bgx; in bgx_get_lmac_count() local
196 bgx = get_bgx(node, bgx_idx); in bgx_get_lmac_count()
197 if (bgx) in bgx_get_lmac_count()
198 return bgx->lmac_count; in bgx_get_lmac_count()
208 struct bgx *bgx; in bgx_get_lmac_link_state() local
211 bgx = get_bgx(node, bgx_idx); in bgx_get_lmac_link_state()
212 if (!bgx) in bgx_get_lmac_link_state()
215 lmac = &bgx->lmac[lmacid]; in bgx_get_lmac_link_state()
225 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_get_lmac_mac() local
227 if (bgx) in bgx_get_lmac_mac()
228 return bgx->lmac[lmacid].mac; in bgx_get_lmac_mac()
236 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_set_lmac_mac() local
238 if (!bgx) in bgx_set_lmac_mac()
241 ether_addr_copy(bgx->lmac[lmacid].mac, mac); in bgx_set_lmac_mac()
245 static void bgx_flush_dmac_cam_filter(struct bgx *bgx, int lmacid) in bgx_flush_dmac_cam_filter() argument
250 lmac = &bgx->lmac[lmacid]; in bgx_flush_dmac_cam_filter()
253 bgx_reg_write(bgx, 0, BGX_CMR_RX_DMACX_CAM + in bgx_flush_dmac_cam_filter()
311 static int bgx_set_dmac_cam_filter_mac(struct bgx *bgx, int lmacid, in bgx_set_dmac_cam_filter_mac() argument
318 if (!cam_dmac || !bgx) in bgx_set_dmac_cam_filter_mac()
321 lmac = &bgx->lmac[lmacid]; in bgx_set_dmac_cam_filter_mac()
326 bgx_reg_write(bgx, 0, BGX_CMR_RX_DMACX_CAM + in bgx_set_dmac_cam_filter_mac()
334 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_set_dmac_cam_filter() local
337 if (!bgx) in bgx_set_dmac_cam_filter()
340 lmac = &bgx->lmac[lmacid]; in bgx_set_dmac_cam_filter()
356 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_set_xcast_mode() local
361 if (!bgx) in bgx_set_xcast_mode()
364 lmac = &bgx->lmac[lmacid]; in bgx_set_xcast_mode()
366 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_RX_DMAC_CTL); in bgx_set_xcast_mode()
381 bgx_set_dmac_cam_filter_mac(bgx, lmacid, in bgx_set_xcast_mode()
384 bgx_reg_write(bgx, lmacid, BGX_CMRX_RX_DMAC_CTL, cfg); in bgx_set_xcast_mode()
390 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_reset_xcast_mode() local
392 if (!bgx) in bgx_reset_xcast_mode()
395 bgx_lmac_remove_filters(&bgx->lmac[lmacid], vf_id); in bgx_reset_xcast_mode()
396 bgx_flush_dmac_cam_filter(bgx, lmacid); in bgx_reset_xcast_mode()
404 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_lmac_rx_tx_enable() local
408 if (!bgx) in bgx_lmac_rx_tx_enable()
410 lmac = &bgx->lmac[lmacid]; in bgx_lmac_rx_tx_enable()
412 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); in bgx_lmac_rx_tx_enable()
417 bgx_reg_modify(bgx, lmacid, BGX_GMP_GMI_TXX_INT_ENA_W1S, in bgx_lmac_rx_tx_enable()
423 bgx_reg_modify(bgx, lmacid, BGX_GMP_GMI_TXX_INT_ENA_W1C, in bgx_lmac_rx_tx_enable()
426 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); in bgx_lmac_rx_tx_enable()
428 if (bgx->is_rgx) in bgx_lmac_rx_tx_enable()
436 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_config_timestamping() local
440 if (!bgx) in bgx_config_timestamping()
443 lmac = &bgx->lmac[lmacid]; in bgx_config_timestamping()
452 cfg = bgx_reg_read(bgx, lmacid, csr_offset); in bgx_config_timestamping()
458 bgx_reg_write(bgx, lmacid, csr_offset, cfg); in bgx_config_timestamping()
465 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_lmac_get_pfc() local
469 if (!bgx) in bgx_lmac_get_pfc()
471 lmac = &bgx->lmac[lmacid]; in bgx_lmac_get_pfc()
475 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_CBFC_CTL); in bgx_lmac_get_pfc()
485 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_lmac_set_pfc() local
489 if (!bgx) in bgx_lmac_set_pfc()
491 lmac = &bgx->lmac[lmacid]; in bgx_lmac_set_pfc()
495 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_CBFC_CTL); in bgx_lmac_set_pfc()
499 bgx_reg_write(bgx, lmacid, BGX_SMUX_CBFC_CTL, cfg); in bgx_lmac_set_pfc()
505 struct bgx *bgx = lmac->bgx; in bgx_sgmii_change_link_state() local
511 cmr_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_CMRX_CFG); in bgx_sgmii_change_link_state()
515 bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg); in bgx_sgmii_change_link_state()
518 if (bgx_poll_reg(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG, in bgx_sgmii_change_link_state()
520 dev_err(&bgx->pdev->dev, "BGX%d LMAC%d GMI RX not idle\n", in bgx_sgmii_change_link_state()
521 bgx->bgx_id, lmac->lmacid); in bgx_sgmii_change_link_state()
526 if (bgx_poll_reg(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG, in bgx_sgmii_change_link_state()
528 dev_err(&bgx->pdev->dev, "BGX%d LMAC%d GMI TX not idle\n", in bgx_sgmii_change_link_state()
529 bgx->bgx_id, lmac->lmacid); in bgx_sgmii_change_link_state()
533 port_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG); in bgx_sgmii_change_link_state()
534 misc_ctl = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_PCS_MISCX_CTL); in bgx_sgmii_change_link_state()
551 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_TXX_SLOT, 64); in bgx_sgmii_change_link_state()
552 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_TXX_BURST, 0); in bgx_sgmii_change_link_state()
560 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_TXX_SLOT, 64); in bgx_sgmii_change_link_state()
561 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_TXX_BURST, 0); in bgx_sgmii_change_link_state()
569 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_TXX_SLOT, 512); in bgx_sgmii_change_link_state()
571 bgx_reg_write(bgx, lmac->lmacid, in bgx_sgmii_change_link_state()
574 bgx_reg_write(bgx, lmac->lmacid, in bgx_sgmii_change_link_state()
580 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_PCS_MISCX_CTL, misc_ctl); in bgx_sgmii_change_link_state()
581 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG, port_cfg); in bgx_sgmii_change_link_state()
585 bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg); in bgx_sgmii_change_link_state()
587 if (bgx->is_rgx && (cmr_cfg & (CMR_PKT_RX_EN | CMR_PKT_TX_EN))) in bgx_sgmii_change_link_state()
632 struct bgx *bgx; in bgx_get_rx_stats() local
634 bgx = get_bgx(node, bgx_idx); in bgx_get_rx_stats()
635 if (!bgx) in bgx_get_rx_stats()
640 return bgx_reg_read(bgx, lmac, BGX_CMRX_RX_STAT0 + (idx * 8)); in bgx_get_rx_stats()
646 struct bgx *bgx; in bgx_get_tx_stats() local
648 bgx = get_bgx(node, bgx_idx); in bgx_get_tx_stats()
649 if (!bgx) in bgx_get_tx_stats()
652 return bgx_reg_read(bgx, lmac, BGX_CMRX_TX_STAT0 + (idx * 8)); in bgx_get_tx_stats()
660 struct bgx *bgx; in bgx_lmac_internal_loopback() local
664 bgx = get_bgx(node, bgx_idx); in bgx_lmac_internal_loopback()
665 if (!bgx) in bgx_lmac_internal_loopback()
668 lmac = &bgx->lmac[lmac_idx]; in bgx_lmac_internal_loopback()
670 cfg = bgx_reg_read(bgx, lmac_idx, BGX_GMP_PCS_MRX_CTL); in bgx_lmac_internal_loopback()
675 bgx_reg_write(bgx, lmac_idx, BGX_GMP_PCS_MRX_CTL, cfg); in bgx_lmac_internal_loopback()
677 cfg = bgx_reg_read(bgx, lmac_idx, BGX_SPUX_CONTROL1); in bgx_lmac_internal_loopback()
682 bgx_reg_write(bgx, lmac_idx, BGX_SPUX_CONTROL1, cfg); in bgx_lmac_internal_loopback()
687 static int bgx_lmac_sgmii_init(struct bgx *bgx, struct lmac *lmac) in bgx_lmac_sgmii_init() argument
692 bgx_reg_modify(bgx, lmacid, BGX_GMP_GMI_TXX_THRESH, 0x30); in bgx_lmac_sgmii_init()
694 bgx_reg_modify(bgx, lmacid, BGX_GMP_GMI_RXX_JABBER, MAX_FRAME_SIZE); in bgx_lmac_sgmii_init()
697 cfg = bgx_reg_read(bgx, lmacid, BGX_GMP_GMI_TXX_APPEND); in bgx_lmac_sgmii_init()
699 bgx_reg_write(bgx, lmacid, BGX_GMP_GMI_TXX_SGMII_CTL, 0); in bgx_lmac_sgmii_init()
702 bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN); in bgx_lmac_sgmii_init()
705 bgx_reg_modify(bgx, lmacid, BGX_GMP_PCS_MRX_CTL, PCS_MRX_CTL_RESET); in bgx_lmac_sgmii_init()
706 if (bgx_poll_reg(bgx, lmacid, BGX_GMP_PCS_MRX_CTL, in bgx_lmac_sgmii_init()
708 dev_err(&bgx->pdev->dev, "BGX PCS reset not completed\n"); in bgx_lmac_sgmii_init()
713 cfg = bgx_reg_read(bgx, lmacid, BGX_GMP_PCS_MRX_CTL); in bgx_lmac_sgmii_init()
726 bgx_reg_write(bgx, lmacid, BGX_GMP_PCS_MRX_CTL, cfg); in bgx_lmac_sgmii_init()
730 cfg = bgx_reg_read(bgx, lmacid, BGX_GMP_PCS_MISCX_CTL); in bgx_lmac_sgmii_init()
732 bgx_reg_write(bgx, lmacid, BGX_GMP_PCS_MISCX_CTL, cfg); in bgx_lmac_sgmii_init()
737 if (bgx_poll_reg(bgx, lmacid, BGX_GMP_PCS_MRX_STATUS, in bgx_lmac_sgmii_init()
739 dev_err(&bgx->pdev->dev, "BGX AN_CPT not completed\n"); in bgx_lmac_sgmii_init()
747 static int bgx_lmac_xaui_init(struct bgx *bgx, struct lmac *lmac) in bgx_lmac_xaui_init() argument
753 bgx_reg_modify(bgx, lmacid, BGX_SPUX_CONTROL1, SPU_CTL_RESET); in bgx_lmac_xaui_init()
754 if (bgx_poll_reg(bgx, lmacid, BGX_SPUX_CONTROL1, SPU_CTL_RESET, true)) { in bgx_lmac_xaui_init()
755 dev_err(&bgx->pdev->dev, "BGX SPU reset not completed\n"); in bgx_lmac_xaui_init()
760 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); in bgx_lmac_xaui_init()
762 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); in bgx_lmac_xaui_init()
764 bgx_reg_modify(bgx, lmacid, BGX_SPUX_CONTROL1, SPU_CTL_LOW_POWER); in bgx_lmac_xaui_init()
767 bgx_reg_modify(bgx, lmacid, BGX_SPUX_MISC_CONTROL, in bgx_lmac_xaui_init()
771 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_MISC_CONTROL); in bgx_lmac_xaui_init()
773 bgx_reg_write(bgx, lmacid, BGX_SPUX_MISC_CONTROL, cfg); in bgx_lmac_xaui_init()
776 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_RX_INT); in bgx_lmac_xaui_init()
777 bgx_reg_write(bgx, lmacid, BGX_SMUX_RX_INT, cfg); in bgx_lmac_xaui_init()
778 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_TX_INT); in bgx_lmac_xaui_init()
779 bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_INT, cfg); in bgx_lmac_xaui_init()
780 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_INT); in bgx_lmac_xaui_init()
781 bgx_reg_write(bgx, lmacid, BGX_SPUX_INT, cfg); in bgx_lmac_xaui_init()
784 bgx_reg_write(bgx, lmacid, BGX_SPUX_BR_PMD_LP_CUP, 0x00); in bgx_lmac_xaui_init()
785 bgx_reg_write(bgx, lmacid, BGX_SPUX_BR_PMD_LD_CUP, 0x00); in bgx_lmac_xaui_init()
786 bgx_reg_write(bgx, lmacid, BGX_SPUX_BR_PMD_LD_REP, 0x00); in bgx_lmac_xaui_init()
788 bgx_reg_modify(bgx, lmacid, in bgx_lmac_xaui_init()
793 bgx_reg_modify(bgx, lmacid, BGX_SMUX_TX_APPEND, SMU_TX_APPEND_FCS_D); in bgx_lmac_xaui_init()
796 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_FEC_CONTROL); in bgx_lmac_xaui_init()
798 bgx_reg_write(bgx, lmacid, BGX_SPUX_FEC_CONTROL, cfg); in bgx_lmac_xaui_init()
801 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_AN_CONTROL); in bgx_lmac_xaui_init()
803 bgx_reg_write(bgx, lmacid, BGX_SPUX_AN_CONTROL, cfg); in bgx_lmac_xaui_init()
805 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_AN_ADV); in bgx_lmac_xaui_init()
813 bgx_reg_write(bgx, lmacid, BGX_SPUX_AN_ADV, cfg); in bgx_lmac_xaui_init()
815 cfg = bgx_reg_read(bgx, 0, BGX_SPU_DBG_CONTROL); in bgx_lmac_xaui_init()
817 bgx_reg_write(bgx, 0, BGX_SPU_DBG_CONTROL, cfg); in bgx_lmac_xaui_init()
820 bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN); in bgx_lmac_xaui_init()
822 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_CONTROL1); in bgx_lmac_xaui_init()
824 bgx_reg_write(bgx, lmacid, BGX_SPUX_CONTROL1, cfg); in bgx_lmac_xaui_init()
826 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_TX_CTL); in bgx_lmac_xaui_init()
829 bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_CTL, cfg); in bgx_lmac_xaui_init()
832 bgx_reg_write(bgx, lmacid, BGX_SMUX_CBFC_CTL, ((0xffffULL << 32) | in bgx_lmac_xaui_init()
835 bgx_reg_write(bgx, lmacid, in bgx_lmac_xaui_init()
837 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_TX_PAUSE_PKT_INTERVAL); in bgx_lmac_xaui_init()
839 bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_PAUSE_PKT_INTERVAL, in bgx_lmac_xaui_init()
841 bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_PAUSE_ZERO, 0x01); in bgx_lmac_xaui_init()
844 bgx_reg_modify(bgx, lmacid, BGX_SMUX_TX_THRESH, (0x100 - 1)); in bgx_lmac_xaui_init()
846 bgx_reg_modify(bgx, lmacid, BGX_SMUX_RX_JABBER, MAX_FRAME_SIZE); in bgx_lmac_xaui_init()
853 struct bgx *bgx = lmac->bgx; in bgx_xaui_check_link() local
859 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_INT); in bgx_xaui_check_link()
862 bgx_reg_write(bgx, lmacid, BGX_SPUX_INT, cfg); in bgx_xaui_check_link()
863 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_BR_PMD_CRTL); in bgx_xaui_check_link()
865 bgx_reg_write(bgx, lmacid, BGX_SPUX_BR_PMD_CRTL, cfg); in bgx_xaui_check_link()
871 if (bgx_poll_reg(bgx, lmacid, BGX_SPUX_CONTROL1, SPU_CTL_RESET, true)) { in bgx_xaui_check_link()
872 dev_err(&bgx->pdev->dev, "BGX SPU reset not completed\n"); in bgx_xaui_check_link()
878 if (bgx_poll_reg(bgx, lmacid, BGX_SPUX_BR_STATUS1, in bgx_xaui_check_link()
880 dev_err(&bgx->pdev->dev, in bgx_xaui_check_link()
885 if (bgx_poll_reg(bgx, lmacid, BGX_SPUX_BX_STATUS, in bgx_xaui_check_link()
887 dev_err(&bgx->pdev->dev, in bgx_xaui_check_link()
894 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) in bgx_xaui_check_link()
895 bgx_reg_modify(bgx, lmacid, in bgx_xaui_check_link()
897 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) { in bgx_xaui_check_link()
898 dev_err(&bgx->pdev->dev, "Receive fault, retry training\n"); in bgx_xaui_check_link()
900 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_INT); in bgx_xaui_check_link()
903 bgx_reg_write(bgx, lmacid, BGX_SPUX_INT, cfg); in bgx_xaui_check_link()
904 cfg = bgx_reg_read(bgx, lmacid, in bgx_xaui_check_link()
907 bgx_reg_write(bgx, lmacid, in bgx_xaui_check_link()
916 if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_CTL, SMU_CTL_RX_IDLE, false)) { in bgx_xaui_check_link()
917 dev_err(&bgx->pdev->dev, "SMU RX not idle\n"); in bgx_xaui_check_link()
922 if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_CTL, SMU_CTL_TX_IDLE, false)) { in bgx_xaui_check_link()
923 dev_err(&bgx->pdev->dev, "SMU TX not idle\n"); in bgx_xaui_check_link()
928 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_RX_CTL); in bgx_xaui_check_link()
937 bgx_lmac_xaui_init(bgx, lmac); in bgx_xaui_check_link()
947 pcs_link = bgx_reg_read(lmac->bgx, lmac->lmacid, in bgx_poll_for_sgmii_link()
952 pcs_link = bgx_reg_read(lmac->bgx, lmac->lmacid, in bgx_poll_for_sgmii_link()
955 if (bgx_poll_reg(lmac->bgx, lmac->lmacid, BGX_GMP_PCS_MRX_STATUS, in bgx_poll_for_sgmii_link()
964 an_result = bgx_reg_read(lmac->bgx, lmac->lmacid, in bgx_poll_for_sgmii_link()
1009 bgx_reg_modify(lmac->bgx, lmac->lmacid, in bgx_poll_for_link()
1011 bgx_poll_reg(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1, in bgx_poll_for_link()
1014 spu_link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1); in bgx_poll_for_link()
1015 smu_link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SMUX_RX_CTL); in bgx_poll_for_link()
1056 static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid) in bgx_lmac_enable() argument
1061 lmac = &bgx->lmac[lmacid]; in bgx_lmac_enable()
1062 lmac->bgx = bgx; in bgx_lmac_enable()
1068 if (bgx_lmac_sgmii_init(bgx, lmac)) in bgx_lmac_enable()
1072 if (bgx_lmac_xaui_init(bgx, lmac)) in bgx_lmac_enable()
1077 cfg = bgx_reg_read(bgx, lmacid, BGX_GMP_GMI_TXX_APPEND); in bgx_lmac_enable()
1079 bgx_reg_modify(bgx, lmacid, BGX_GMP_GMI_TXX_APPEND, cfg); in bgx_lmac_enable()
1080 bgx_reg_write(bgx, lmacid, BGX_GMP_GMI_TXX_MIN_PKT, 60 - 1); in bgx_lmac_enable()
1082 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_TX_APPEND); in bgx_lmac_enable()
1084 bgx_reg_modify(bgx, lmacid, BGX_SMUX_TX_APPEND, cfg); in bgx_lmac_enable()
1085 bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_MIN_PKT, 60 + 4); in bgx_lmac_enable()
1089 lmac->dmacs_count = (RX_DMAC_COUNT / bgx->lmac_count); in bgx_lmac_enable()
1096 bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN); in bgx_lmac_enable()
1099 bgx_reg_write(bgx, lmacid, BGX_CMRX_RX_DMAC_CTL, 0x03); in bgx_lmac_enable()
1107 bgx_reg_write(bgx, lmacid, in bgx_lmac_enable()
1142 static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid) in bgx_lmac_disable() argument
1147 lmac = &bgx->lmac[lmacid]; in bgx_lmac_disable()
1155 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); in bgx_lmac_disable()
1157 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); in bgx_lmac_disable()
1160 bgx_poll_reg(bgx, lmacid, BGX_CMRX_RX_FIFO_LEN, (u64)0x1FFF, true); in bgx_lmac_disable()
1161 bgx_poll_reg(bgx, lmacid, BGX_CMRX_TX_FIFO_LEN, (u64)0x3FFF, true); in bgx_lmac_disable()
1164 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); in bgx_lmac_disable()
1166 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); in bgx_lmac_disable()
1170 bgx_reg_modify(bgx, lmacid, in bgx_lmac_disable()
1173 bgx_reg_modify(bgx, lmacid, in bgx_lmac_disable()
1177 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); in bgx_lmac_disable()
1179 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); in bgx_lmac_disable()
1181 bgx_flush_dmac_cam_filter(bgx, lmacid); in bgx_lmac_disable()
1193 static void bgx_init_hw(struct bgx *bgx) in bgx_init_hw() argument
1198 bgx_reg_modify(bgx, 0, BGX_CMR_GLOBAL_CFG, CMR_GLOBAL_CFG_FCS_STRIP); in bgx_init_hw()
1199 if (bgx_reg_read(bgx, 0, BGX_CMR_BIST_STATUS)) in bgx_init_hw()
1200 dev_err(&bgx->pdev->dev, "BGX%d BIST failed\n", bgx->bgx_id); in bgx_init_hw()
1203 for (i = 0; i < bgx->lmac_count; i++) { in bgx_init_hw()
1204 lmac = &bgx->lmac[i]; in bgx_init_hw()
1205 bgx_reg_write(bgx, i, BGX_CMRX_CFG, in bgx_init_hw()
1207 bgx->lmac[i].lmacid_bd = lmac_count; in bgx_init_hw()
1211 bgx_reg_write(bgx, 0, BGX_CMR_TX_LMACS, bgx->lmac_count); in bgx_init_hw()
1212 bgx_reg_write(bgx, 0, BGX_CMR_RX_LMACS, bgx->lmac_count); in bgx_init_hw()
1215 for (i = 0; i < bgx->lmac_count; i++) in bgx_init_hw()
1216 bgx_reg_modify(bgx, 0, BGX_CMR_CHAN_MSK_AND, in bgx_init_hw()
1222 bgx_reg_write(bgx, 0, BGX_CMR_RX_DMACX_CAM + (i * 8), 0x00); in bgx_init_hw()
1226 bgx_reg_write(bgx, 0, BGX_CMR_RX_STEERING + (i * 8), 0x00); in bgx_init_hw()
1229 static u8 bgx_get_lane2sds_cfg(struct bgx *bgx, struct lmac *lmac) in bgx_get_lane2sds_cfg() argument
1231 return (u8)(bgx_reg_read(bgx, lmac->lmacid, BGX_CMRX_CFG) & 0xFF); in bgx_get_lane2sds_cfg()
1234 static void bgx_print_qlm_mode(struct bgx *bgx, u8 lmacid) in bgx_print_qlm_mode() argument
1236 struct device *dev = &bgx->pdev->dev; in bgx_print_qlm_mode()
1240 if (!bgx->is_dlm && lmacid) in bgx_print_qlm_mode()
1243 lmac = &bgx->lmac[lmacid]; in bgx_print_qlm_mode()
1244 if (!bgx->is_dlm) in bgx_print_qlm_mode()
1245 sprintf(str, "BGX%d QLM mode", bgx->bgx_id); in bgx_print_qlm_mode()
1247 sprintf(str, "BGX%d LMAC%d mode", bgx->bgx_id, lmacid); in bgx_print_qlm_mode()
1283 static void lmac_set_lane2sds(struct bgx *bgx, struct lmac *lmac) in lmac_set_lane2sds() argument
1304 lmac->lane_to_sds = bgx_get_lane2sds_cfg(bgx, lmac); in lmac_set_lane2sds()
1312 static void lmac_set_training(struct bgx *bgx, struct lmac *lmac, int lmacid) in lmac_set_training() argument
1320 lmac->use_training = bgx_reg_read(bgx, lmacid, BGX_SPUX_BR_PMD_CRTL) & in lmac_set_training()
1324 static void bgx_set_lmac_config(struct bgx *bgx, u8 idx) in bgx_set_lmac_config() argument
1331 lmac = &bgx->lmac[idx]; in bgx_set_lmac_config()
1333 if (!bgx->is_dlm || bgx->is_rgx) { in bgx_set_lmac_config()
1337 cmr_cfg = bgx_reg_read(bgx, 0, BGX_CMRX_CFG); in bgx_set_lmac_config()
1339 if (bgx->is_rgx) in bgx_set_lmac_config()
1341 lmac_set_training(bgx, lmac, 0); in bgx_set_lmac_config()
1342 lmac_set_lane2sds(bgx, lmac); in bgx_set_lmac_config()
1351 cmr_cfg = bgx_reg_read(bgx, idx, BGX_CMRX_CFG); in bgx_set_lmac_config()
1360 lmac_set_training(bgx, lmac, lmac->lmacid); in bgx_set_lmac_config()
1363 static void bgx_get_qlm_mode(struct bgx *bgx) in bgx_get_qlm_mode() argument
1369 for (idx = 0; idx < bgx->max_lmac; idx++) { in bgx_get_qlm_mode()
1370 lmac = &bgx->lmac[idx]; in bgx_get_qlm_mode()
1377 bgx->lmac_count = bgx_reg_read(bgx, 0, BGX_CMR_RX_LMACS) & 0x7; in bgx_get_qlm_mode()
1378 if (bgx->lmac_count > bgx->max_lmac) in bgx_get_qlm_mode()
1379 bgx->lmac_count = bgx->max_lmac; in bgx_get_qlm_mode()
1381 for (idx = 0; idx < bgx->lmac_count; idx++) { in bgx_get_qlm_mode()
1382 bgx_set_lmac_config(bgx, idx); in bgx_get_qlm_mode()
1383 bgx_print_qlm_mode(bgx, idx); in bgx_get_qlm_mode()
1411 struct bgx *bgx = context; in bgx_acpi_register_phy() local
1412 struct device *dev = &bgx->pdev->dev; in bgx_acpi_register_phy()
1418 acpi_get_mac_address(dev, adev, bgx->lmac[bgx->acpi_lmac_idx].mac); in bgx_acpi_register_phy()
1420 SET_NETDEV_DEV(&bgx->lmac[bgx->acpi_lmac_idx].netdev, dev); in bgx_acpi_register_phy()
1422 bgx->lmac[bgx->acpi_lmac_idx].lmacid = bgx->acpi_lmac_idx; in bgx_acpi_register_phy()
1423 bgx->acpi_lmac_idx++; /* move to next LMAC */ in bgx_acpi_register_phy()
1432 struct bgx *bgx = context; in bgx_acpi_match_id() local
1435 snprintf(bgx_sel, 5, "BGX%d", bgx->bgx_id); in bgx_acpi_match_id()
1445 bgx_acpi_register_phy, NULL, bgx, NULL); in bgx_acpi_match_id()
1451 static int bgx_init_acpi_phy(struct bgx *bgx) in bgx_init_acpi_phy() argument
1453 acpi_get_devices(NULL, bgx_acpi_match_id, bgx, (void **)NULL); in bgx_init_acpi_phy()
1459 static int bgx_init_acpi_phy(struct bgx *bgx) in bgx_init_acpi_phy() argument
1468 static int bgx_init_of_phy(struct bgx *bgx) in bgx_init_of_phy() argument
1474 device_for_each_child_node(&bgx->pdev->dev, fwn) { in bgx_init_of_phy()
1488 ether_addr_copy(bgx->lmac[lmac].mac, mac); in bgx_init_of_phy()
1490 SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev); in bgx_init_of_phy()
1491 bgx->lmac[lmac].lmacid = lmac; in bgx_init_of_phy()
1504 bgx->lmac[lmac].phydev = pd; in bgx_init_of_phy()
1508 if (lmac == bgx->max_lmac) { in bgx_init_of_phy()
1520 if (bgx->lmac[lmac].phydev) { in bgx_init_of_phy()
1521 put_device(&bgx->lmac[lmac].phydev->mdio.dev); in bgx_init_of_phy()
1522 bgx->lmac[lmac].phydev = NULL; in bgx_init_of_phy()
1532 static int bgx_init_of_phy(struct bgx *bgx) in bgx_init_of_phy() argument
1539 static int bgx_init_phy(struct bgx *bgx) in bgx_init_phy() argument
1542 return bgx_init_acpi_phy(bgx); in bgx_init_phy()
1544 return bgx_init_of_phy(bgx); in bgx_init_phy()
1549 struct bgx *bgx = (struct bgx *)data; in bgx_intr_handler() local
1553 for (lmac = 0; lmac < bgx->lmac_count; lmac++) { in bgx_intr_handler()
1554 status = bgx_reg_read(bgx, lmac, BGX_GMP_GMI_TXX_INT); in bgx_intr_handler()
1556 pci_err(bgx->pdev, "BGX%d lmac%d UNDFLW\n", in bgx_intr_handler()
1557 bgx->bgx_id, lmac); in bgx_intr_handler()
1558 val = bgx_reg_read(bgx, lmac, BGX_CMRX_CFG); in bgx_intr_handler()
1560 bgx_reg_write(bgx, lmac, BGX_CMRX_CFG, val); in bgx_intr_handler()
1562 bgx_reg_write(bgx, lmac, BGX_CMRX_CFG, val); in bgx_intr_handler()
1565 bgx_reg_write(bgx, lmac, BGX_GMP_GMI_TXX_INT, status); in bgx_intr_handler()
1573 struct bgx *bgx = pci_get_drvdata(pdev); in bgx_register_intr() local
1584 bgx, "BGX%d", bgx->bgx_id); in bgx_register_intr()
1586 pci_free_irq(pdev, GMPX_GMI_TX_INT, bgx); in bgx_register_intr()
1593 struct bgx *bgx = NULL; in bgx_probe() local
1597 bgx = devm_kzalloc(dev, sizeof(*bgx), GFP_KERNEL); in bgx_probe()
1598 if (!bgx) in bgx_probe()
1600 bgx->pdev = pdev; in bgx_probe()
1602 pci_set_drvdata(pdev, bgx); in bgx_probe()
1618 bgx->reg_base = pcim_iomap(pdev, PCI_CFG_REG_BAR_NUM, 0); in bgx_probe()
1619 if (!bgx->reg_base) { in bgx_probe()
1629 bgx->bgx_id = (pci_resource_start(pdev, in bgx_probe()
1631 bgx->bgx_id += nic_get_node_id(pdev) * max_bgx_per_node; in bgx_probe()
1632 bgx->max_lmac = MAX_LMAC_PER_BGX; in bgx_probe()
1633 bgx_vnic[bgx->bgx_id] = bgx; in bgx_probe()
1635 bgx->is_rgx = true; in bgx_probe()
1636 bgx->max_lmac = 1; in bgx_probe()
1637 bgx->bgx_id = MAX_BGX_PER_CN81XX - 1; in bgx_probe()
1638 bgx_vnic[bgx->bgx_id] = bgx; in bgx_probe()
1647 ((sdevid == PCI_SUBSYS_DEVID_83XX_BGX) && (bgx->bgx_id == 2))) in bgx_probe()
1648 bgx->is_dlm = true; in bgx_probe()
1650 bgx_get_qlm_mode(bgx); in bgx_probe()
1652 err = bgx_init_phy(bgx); in bgx_probe()
1656 bgx_init_hw(bgx); in bgx_probe()
1661 for (lmac = 0; lmac < bgx->lmac_count; lmac++) { in bgx_probe()
1662 err = bgx_lmac_enable(bgx, lmac); in bgx_probe()
1665 bgx->bgx_id, lmac); in bgx_probe()
1667 bgx_lmac_disable(bgx, --lmac); in bgx_probe()
1675 bgx_vnic[bgx->bgx_id] = NULL; in bgx_probe()
1676 pci_free_irq(pdev, GMPX_GMI_TX_INT, bgx); in bgx_probe()
1687 struct bgx *bgx = pci_get_drvdata(pdev); in bgx_remove() local
1691 for (lmac = 0; lmac < bgx->lmac_count; lmac++) in bgx_remove()
1692 bgx_lmac_disable(bgx, lmac); in bgx_remove()
1694 pci_free_irq(pdev, GMPX_GMI_TX_INT, bgx); in bgx_remove()
1696 bgx_vnic[bgx->bgx_id] = NULL; in bgx_remove()