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_write(bgx, lmacid, BGX_CMRX_CFG, cfg); in bgx_lmac_rx_tx_enable()
419 if (bgx->is_rgx) in bgx_lmac_rx_tx_enable()
427 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_config_timestamping() local
431 if (!bgx) in bgx_config_timestamping()
434 lmac = &bgx->lmac[lmacid]; in bgx_config_timestamping()
443 cfg = bgx_reg_read(bgx, lmacid, csr_offset); in bgx_config_timestamping()
449 bgx_reg_write(bgx, lmacid, csr_offset, cfg); in bgx_config_timestamping()
456 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_lmac_get_pfc() local
460 if (!bgx) in bgx_lmac_get_pfc()
462 lmac = &bgx->lmac[lmacid]; in bgx_lmac_get_pfc()
466 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_CBFC_CTL); in bgx_lmac_get_pfc()
476 struct bgx *bgx = get_bgx(node, bgx_idx); in bgx_lmac_set_pfc() local
480 if (!bgx) in bgx_lmac_set_pfc()
482 lmac = &bgx->lmac[lmacid]; in bgx_lmac_set_pfc()
486 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_CBFC_CTL); in bgx_lmac_set_pfc()
490 bgx_reg_write(bgx, lmacid, BGX_SMUX_CBFC_CTL, cfg); in bgx_lmac_set_pfc()
496 struct bgx *bgx = lmac->bgx; in bgx_sgmii_change_link_state() local
502 cmr_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_CMRX_CFG); in bgx_sgmii_change_link_state()
506 bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg); in bgx_sgmii_change_link_state()
509 if (bgx_poll_reg(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG, in bgx_sgmii_change_link_state()
511 dev_err(&bgx->pdev->dev, "BGX%d LMAC%d GMI RX not idle\n", in bgx_sgmii_change_link_state()
512 bgx->bgx_id, lmac->lmacid); in bgx_sgmii_change_link_state()
517 if (bgx_poll_reg(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG, in bgx_sgmii_change_link_state()
519 dev_err(&bgx->pdev->dev, "BGX%d LMAC%d GMI TX not idle\n", in bgx_sgmii_change_link_state()
520 bgx->bgx_id, lmac->lmacid); in bgx_sgmii_change_link_state()
524 port_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG); in bgx_sgmii_change_link_state()
525 misc_ctl = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_PCS_MISCX_CTL); in bgx_sgmii_change_link_state()
542 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_TXX_SLOT, 64); in bgx_sgmii_change_link_state()
543 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_TXX_BURST, 0); 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, 512); in bgx_sgmii_change_link_state()
562 bgx_reg_write(bgx, lmac->lmacid, in bgx_sgmii_change_link_state()
565 bgx_reg_write(bgx, lmac->lmacid, in bgx_sgmii_change_link_state()
571 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_PCS_MISCX_CTL, misc_ctl); in bgx_sgmii_change_link_state()
572 bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG, port_cfg); in bgx_sgmii_change_link_state()
576 bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg); in bgx_sgmii_change_link_state()
578 if (bgx->is_rgx && (cmr_cfg & (CMR_PKT_RX_EN | CMR_PKT_TX_EN))) in bgx_sgmii_change_link_state()
623 struct bgx *bgx; in bgx_get_rx_stats() local
625 bgx = get_bgx(node, bgx_idx); in bgx_get_rx_stats()
626 if (!bgx) in bgx_get_rx_stats()
631 return bgx_reg_read(bgx, lmac, BGX_CMRX_RX_STAT0 + (idx * 8)); in bgx_get_rx_stats()
637 struct bgx *bgx; in bgx_get_tx_stats() local
639 bgx = get_bgx(node, bgx_idx); in bgx_get_tx_stats()
640 if (!bgx) in bgx_get_tx_stats()
643 return bgx_reg_read(bgx, lmac, BGX_CMRX_TX_STAT0 + (idx * 8)); in bgx_get_tx_stats()
651 struct bgx *bgx; in bgx_lmac_internal_loopback() local
655 bgx = get_bgx(node, bgx_idx); in bgx_lmac_internal_loopback()
656 if (!bgx) in bgx_lmac_internal_loopback()
659 lmac = &bgx->lmac[lmac_idx]; in bgx_lmac_internal_loopback()
661 cfg = bgx_reg_read(bgx, lmac_idx, BGX_GMP_PCS_MRX_CTL); in bgx_lmac_internal_loopback()
666 bgx_reg_write(bgx, lmac_idx, BGX_GMP_PCS_MRX_CTL, cfg); in bgx_lmac_internal_loopback()
668 cfg = bgx_reg_read(bgx, lmac_idx, BGX_SPUX_CONTROL1); in bgx_lmac_internal_loopback()
673 bgx_reg_write(bgx, lmac_idx, BGX_SPUX_CONTROL1, cfg); in bgx_lmac_internal_loopback()
678 static int bgx_lmac_sgmii_init(struct bgx *bgx, struct lmac *lmac) in bgx_lmac_sgmii_init() argument
683 bgx_reg_modify(bgx, lmacid, BGX_GMP_GMI_TXX_THRESH, 0x30); in bgx_lmac_sgmii_init()
685 bgx_reg_modify(bgx, lmacid, BGX_GMP_GMI_RXX_JABBER, MAX_FRAME_SIZE); in bgx_lmac_sgmii_init()
688 cfg = bgx_reg_read(bgx, lmacid, BGX_GMP_GMI_TXX_APPEND); in bgx_lmac_sgmii_init()
690 bgx_reg_write(bgx, lmacid, BGX_GMP_GMI_TXX_SGMII_CTL, 0); in bgx_lmac_sgmii_init()
693 bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN); in bgx_lmac_sgmii_init()
696 bgx_reg_modify(bgx, lmacid, BGX_GMP_PCS_MRX_CTL, PCS_MRX_CTL_RESET); in bgx_lmac_sgmii_init()
697 if (bgx_poll_reg(bgx, lmacid, BGX_GMP_PCS_MRX_CTL, in bgx_lmac_sgmii_init()
699 dev_err(&bgx->pdev->dev, "BGX PCS reset not completed\n"); in bgx_lmac_sgmii_init()
704 cfg = bgx_reg_read(bgx, lmacid, BGX_GMP_PCS_MRX_CTL); in bgx_lmac_sgmii_init()
717 bgx_reg_write(bgx, lmacid, BGX_GMP_PCS_MRX_CTL, cfg); in bgx_lmac_sgmii_init()
721 cfg = bgx_reg_read(bgx, lmacid, BGX_GMP_PCS_MISCX_CTL); in bgx_lmac_sgmii_init()
723 bgx_reg_write(bgx, lmacid, BGX_GMP_PCS_MISCX_CTL, cfg); in bgx_lmac_sgmii_init()
728 if (bgx_poll_reg(bgx, lmacid, BGX_GMP_PCS_MRX_STATUS, in bgx_lmac_sgmii_init()
730 dev_err(&bgx->pdev->dev, "BGX AN_CPT not completed\n"); in bgx_lmac_sgmii_init()
738 static int bgx_lmac_xaui_init(struct bgx *bgx, struct lmac *lmac) in bgx_lmac_xaui_init() argument
744 bgx_reg_modify(bgx, lmacid, BGX_SPUX_CONTROL1, SPU_CTL_RESET); in bgx_lmac_xaui_init()
745 if (bgx_poll_reg(bgx, lmacid, BGX_SPUX_CONTROL1, SPU_CTL_RESET, true)) { in bgx_lmac_xaui_init()
746 dev_err(&bgx->pdev->dev, "BGX SPU reset not completed\n"); in bgx_lmac_xaui_init()
751 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); in bgx_lmac_xaui_init()
753 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); in bgx_lmac_xaui_init()
755 bgx_reg_modify(bgx, lmacid, BGX_SPUX_CONTROL1, SPU_CTL_LOW_POWER); in bgx_lmac_xaui_init()
758 bgx_reg_modify(bgx, lmacid, BGX_SPUX_MISC_CONTROL, in bgx_lmac_xaui_init()
762 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_MISC_CONTROL); in bgx_lmac_xaui_init()
764 bgx_reg_write(bgx, lmacid, BGX_SPUX_MISC_CONTROL, cfg); in bgx_lmac_xaui_init()
767 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_RX_INT); in bgx_lmac_xaui_init()
768 bgx_reg_write(bgx, lmacid, BGX_SMUX_RX_INT, cfg); in bgx_lmac_xaui_init()
769 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_TX_INT); in bgx_lmac_xaui_init()
770 bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_INT, cfg); in bgx_lmac_xaui_init()
771 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_INT); in bgx_lmac_xaui_init()
772 bgx_reg_write(bgx, lmacid, BGX_SPUX_INT, cfg); in bgx_lmac_xaui_init()
775 bgx_reg_write(bgx, lmacid, BGX_SPUX_BR_PMD_LP_CUP, 0x00); in bgx_lmac_xaui_init()
776 bgx_reg_write(bgx, lmacid, BGX_SPUX_BR_PMD_LD_CUP, 0x00); in bgx_lmac_xaui_init()
777 bgx_reg_write(bgx, lmacid, BGX_SPUX_BR_PMD_LD_REP, 0x00); in bgx_lmac_xaui_init()
779 bgx_reg_modify(bgx, lmacid, in bgx_lmac_xaui_init()
784 bgx_reg_modify(bgx, lmacid, BGX_SMUX_TX_APPEND, SMU_TX_APPEND_FCS_D); in bgx_lmac_xaui_init()
787 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_FEC_CONTROL); in bgx_lmac_xaui_init()
789 bgx_reg_write(bgx, lmacid, BGX_SPUX_FEC_CONTROL, cfg); in bgx_lmac_xaui_init()
792 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_AN_CONTROL); in bgx_lmac_xaui_init()
794 bgx_reg_write(bgx, lmacid, BGX_SPUX_AN_CONTROL, cfg); in bgx_lmac_xaui_init()
796 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_AN_ADV); in bgx_lmac_xaui_init()
804 bgx_reg_write(bgx, lmacid, BGX_SPUX_AN_ADV, cfg); in bgx_lmac_xaui_init()
806 cfg = bgx_reg_read(bgx, 0, BGX_SPU_DBG_CONTROL); in bgx_lmac_xaui_init()
808 bgx_reg_write(bgx, 0, BGX_SPU_DBG_CONTROL, cfg); in bgx_lmac_xaui_init()
811 bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN); in bgx_lmac_xaui_init()
813 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_CONTROL1); in bgx_lmac_xaui_init()
815 bgx_reg_write(bgx, lmacid, BGX_SPUX_CONTROL1, cfg); in bgx_lmac_xaui_init()
817 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_TX_CTL); in bgx_lmac_xaui_init()
820 bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_CTL, cfg); in bgx_lmac_xaui_init()
823 bgx_reg_write(bgx, lmacid, BGX_SMUX_CBFC_CTL, ((0xffffULL << 32) | in bgx_lmac_xaui_init()
826 bgx_reg_write(bgx, lmacid, in bgx_lmac_xaui_init()
828 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_TX_PAUSE_PKT_INTERVAL); in bgx_lmac_xaui_init()
830 bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_PAUSE_PKT_INTERVAL, in bgx_lmac_xaui_init()
832 bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_PAUSE_ZERO, 0x01); in bgx_lmac_xaui_init()
835 bgx_reg_modify(bgx, lmacid, BGX_SMUX_TX_THRESH, (0x100 - 1)); in bgx_lmac_xaui_init()
837 bgx_reg_modify(bgx, lmacid, BGX_SMUX_RX_JABBER, MAX_FRAME_SIZE); in bgx_lmac_xaui_init()
844 struct bgx *bgx = lmac->bgx; in bgx_xaui_check_link() local
850 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_INT); in bgx_xaui_check_link()
853 bgx_reg_write(bgx, lmacid, BGX_SPUX_INT, cfg); in bgx_xaui_check_link()
854 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_BR_PMD_CRTL); in bgx_xaui_check_link()
856 bgx_reg_write(bgx, lmacid, BGX_SPUX_BR_PMD_CRTL, cfg); in bgx_xaui_check_link()
862 if (bgx_poll_reg(bgx, lmacid, BGX_SPUX_CONTROL1, SPU_CTL_RESET, true)) { in bgx_xaui_check_link()
863 dev_err(&bgx->pdev->dev, "BGX SPU reset not completed\n"); in bgx_xaui_check_link()
869 if (bgx_poll_reg(bgx, lmacid, BGX_SPUX_BR_STATUS1, in bgx_xaui_check_link()
871 dev_err(&bgx->pdev->dev, in bgx_xaui_check_link()
876 if (bgx_poll_reg(bgx, lmacid, BGX_SPUX_BX_STATUS, in bgx_xaui_check_link()
878 dev_err(&bgx->pdev->dev, in bgx_xaui_check_link()
885 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) in bgx_xaui_check_link()
886 bgx_reg_modify(bgx, lmacid, in bgx_xaui_check_link()
888 if (bgx_reg_read(bgx, lmacid, BGX_SPUX_STATUS2) & SPU_STATUS2_RCVFLT) { in bgx_xaui_check_link()
889 dev_err(&bgx->pdev->dev, "Receive fault, retry training\n"); in bgx_xaui_check_link()
891 cfg = bgx_reg_read(bgx, lmacid, BGX_SPUX_INT); in bgx_xaui_check_link()
894 bgx_reg_write(bgx, lmacid, BGX_SPUX_INT, cfg); in bgx_xaui_check_link()
895 cfg = bgx_reg_read(bgx, lmacid, in bgx_xaui_check_link()
898 bgx_reg_write(bgx, lmacid, in bgx_xaui_check_link()
907 if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_CTL, SMU_CTL_RX_IDLE, false)) { in bgx_xaui_check_link()
908 dev_err(&bgx->pdev->dev, "SMU RX not idle\n"); in bgx_xaui_check_link()
913 if (bgx_poll_reg(bgx, lmacid, BGX_SMUX_CTL, SMU_CTL_TX_IDLE, false)) { in bgx_xaui_check_link()
914 dev_err(&bgx->pdev->dev, "SMU TX not idle\n"); in bgx_xaui_check_link()
919 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_RX_CTL); in bgx_xaui_check_link()
928 bgx_lmac_xaui_init(bgx, lmac); in bgx_xaui_check_link()
938 pcs_link = bgx_reg_read(lmac->bgx, lmac->lmacid, in bgx_poll_for_sgmii_link()
943 pcs_link = bgx_reg_read(lmac->bgx, lmac->lmacid, in bgx_poll_for_sgmii_link()
946 if (bgx_poll_reg(lmac->bgx, lmac->lmacid, BGX_GMP_PCS_MRX_STATUS, in bgx_poll_for_sgmii_link()
955 an_result = bgx_reg_read(lmac->bgx, lmac->lmacid, in bgx_poll_for_sgmii_link()
1000 bgx_reg_modify(lmac->bgx, lmac->lmacid, in bgx_poll_for_link()
1002 bgx_poll_reg(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1, in bgx_poll_for_link()
1005 spu_link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SPUX_STATUS1); in bgx_poll_for_link()
1006 smu_link = bgx_reg_read(lmac->bgx, lmac->lmacid, BGX_SMUX_RX_CTL); in bgx_poll_for_link()
1047 static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid) in bgx_lmac_enable() argument
1052 lmac = &bgx->lmac[lmacid]; in bgx_lmac_enable()
1053 lmac->bgx = bgx; in bgx_lmac_enable()
1059 if (bgx_lmac_sgmii_init(bgx, lmac)) in bgx_lmac_enable()
1063 if (bgx_lmac_xaui_init(bgx, lmac)) in bgx_lmac_enable()
1068 cfg = bgx_reg_read(bgx, lmacid, BGX_GMP_GMI_TXX_APPEND); in bgx_lmac_enable()
1070 bgx_reg_modify(bgx, lmacid, BGX_GMP_GMI_TXX_APPEND, cfg); in bgx_lmac_enable()
1071 bgx_reg_write(bgx, lmacid, BGX_GMP_GMI_TXX_MIN_PKT, 60 - 1); in bgx_lmac_enable()
1073 cfg = bgx_reg_read(bgx, lmacid, BGX_SMUX_TX_APPEND); in bgx_lmac_enable()
1075 bgx_reg_modify(bgx, lmacid, BGX_SMUX_TX_APPEND, cfg); in bgx_lmac_enable()
1076 bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_MIN_PKT, 60 + 4); in bgx_lmac_enable()
1080 lmac->dmacs_count = (RX_DMAC_COUNT / bgx->lmac_count); in bgx_lmac_enable()
1087 bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN); in bgx_lmac_enable()
1090 bgx_reg_write(bgx, lmacid, BGX_CMRX_RX_DMAC_CTL, 0x03); in bgx_lmac_enable()
1098 bgx_reg_write(bgx, lmacid, in bgx_lmac_enable()
1133 static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid) in bgx_lmac_disable() argument
1138 lmac = &bgx->lmac[lmacid]; in bgx_lmac_disable()
1146 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); in bgx_lmac_disable()
1148 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); in bgx_lmac_disable()
1151 bgx_poll_reg(bgx, lmacid, BGX_CMRX_RX_FIFO_LEN, (u64)0x1FFF, true); in bgx_lmac_disable()
1152 bgx_poll_reg(bgx, lmacid, BGX_CMRX_TX_FIFO_LEN, (u64)0x3FFF, true); 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()
1161 bgx_reg_modify(bgx, lmacid, in bgx_lmac_disable()
1164 bgx_reg_modify(bgx, lmacid, in bgx_lmac_disable()
1168 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); in bgx_lmac_disable()
1170 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); in bgx_lmac_disable()
1172 bgx_flush_dmac_cam_filter(bgx, lmacid); in bgx_lmac_disable()
1184 static void bgx_init_hw(struct bgx *bgx) in bgx_init_hw() argument
1189 bgx_reg_modify(bgx, 0, BGX_CMR_GLOBAL_CFG, CMR_GLOBAL_CFG_FCS_STRIP); in bgx_init_hw()
1190 if (bgx_reg_read(bgx, 0, BGX_CMR_BIST_STATUS)) in bgx_init_hw()
1191 dev_err(&bgx->pdev->dev, "BGX%d BIST failed\n", bgx->bgx_id); in bgx_init_hw()
1194 for (i = 0; i < bgx->lmac_count; i++) { in bgx_init_hw()
1195 lmac = &bgx->lmac[i]; in bgx_init_hw()
1196 bgx_reg_write(bgx, i, BGX_CMRX_CFG, in bgx_init_hw()
1198 bgx->lmac[i].lmacid_bd = lmac_count; in bgx_init_hw()
1202 bgx_reg_write(bgx, 0, BGX_CMR_TX_LMACS, bgx->lmac_count); in bgx_init_hw()
1203 bgx_reg_write(bgx, 0, BGX_CMR_RX_LMACS, bgx->lmac_count); in bgx_init_hw()
1206 for (i = 0; i < bgx->lmac_count; i++) in bgx_init_hw()
1207 bgx_reg_modify(bgx, 0, BGX_CMR_CHAN_MSK_AND, in bgx_init_hw()
1213 bgx_reg_write(bgx, 0, BGX_CMR_RX_DMACX_CAM + (i * 8), 0x00); in bgx_init_hw()
1217 bgx_reg_write(bgx, 0, BGX_CMR_RX_STEERING + (i * 8), 0x00); in bgx_init_hw()
1220 static u8 bgx_get_lane2sds_cfg(struct bgx *bgx, struct lmac *lmac) in bgx_get_lane2sds_cfg() argument
1222 return (u8)(bgx_reg_read(bgx, lmac->lmacid, BGX_CMRX_CFG) & 0xFF); in bgx_get_lane2sds_cfg()
1225 static void bgx_print_qlm_mode(struct bgx *bgx, u8 lmacid) in bgx_print_qlm_mode() argument
1227 struct device *dev = &bgx->pdev->dev; in bgx_print_qlm_mode()
1231 if (!bgx->is_dlm && lmacid) in bgx_print_qlm_mode()
1234 lmac = &bgx->lmac[lmacid]; in bgx_print_qlm_mode()
1235 if (!bgx->is_dlm) in bgx_print_qlm_mode()
1236 sprintf(str, "BGX%d QLM mode", bgx->bgx_id); in bgx_print_qlm_mode()
1238 sprintf(str, "BGX%d LMAC%d mode", bgx->bgx_id, lmacid); in bgx_print_qlm_mode()
1274 static void lmac_set_lane2sds(struct bgx *bgx, struct lmac *lmac) in lmac_set_lane2sds() argument
1295 lmac->lane_to_sds = bgx_get_lane2sds_cfg(bgx, lmac); in lmac_set_lane2sds()
1303 static void lmac_set_training(struct bgx *bgx, struct lmac *lmac, int lmacid) in lmac_set_training() argument
1311 lmac->use_training = bgx_reg_read(bgx, lmacid, BGX_SPUX_BR_PMD_CRTL) & in lmac_set_training()
1315 static void bgx_set_lmac_config(struct bgx *bgx, u8 idx) in bgx_set_lmac_config() argument
1322 lmac = &bgx->lmac[idx]; in bgx_set_lmac_config()
1324 if (!bgx->is_dlm || bgx->is_rgx) { in bgx_set_lmac_config()
1328 cmr_cfg = bgx_reg_read(bgx, 0, BGX_CMRX_CFG); in bgx_set_lmac_config()
1330 if (bgx->is_rgx) in bgx_set_lmac_config()
1332 lmac_set_training(bgx, lmac, 0); in bgx_set_lmac_config()
1333 lmac_set_lane2sds(bgx, lmac); in bgx_set_lmac_config()
1342 cmr_cfg = bgx_reg_read(bgx, idx, BGX_CMRX_CFG); in bgx_set_lmac_config()
1351 lmac_set_training(bgx, lmac, lmac->lmacid); in bgx_set_lmac_config()
1354 static void bgx_get_qlm_mode(struct bgx *bgx) in bgx_get_qlm_mode() argument
1360 for (idx = 0; idx < bgx->max_lmac; idx++) { in bgx_get_qlm_mode()
1361 lmac = &bgx->lmac[idx]; in bgx_get_qlm_mode()
1368 bgx->lmac_count = bgx_reg_read(bgx, 0, BGX_CMR_RX_LMACS) & 0x7; in bgx_get_qlm_mode()
1369 if (bgx->lmac_count > bgx->max_lmac) in bgx_get_qlm_mode()
1370 bgx->lmac_count = bgx->max_lmac; in bgx_get_qlm_mode()
1372 for (idx = 0; idx < bgx->lmac_count; idx++) { in bgx_get_qlm_mode()
1373 bgx_set_lmac_config(bgx, idx); in bgx_get_qlm_mode()
1374 bgx_print_qlm_mode(bgx, idx); in bgx_get_qlm_mode()
1402 struct bgx *bgx = context; in bgx_acpi_register_phy() local
1403 struct device *dev = &bgx->pdev->dev; in bgx_acpi_register_phy()
1409 acpi_get_mac_address(dev, adev, bgx->lmac[bgx->acpi_lmac_idx].mac); in bgx_acpi_register_phy()
1411 SET_NETDEV_DEV(&bgx->lmac[bgx->acpi_lmac_idx].netdev, dev); in bgx_acpi_register_phy()
1413 bgx->lmac[bgx->acpi_lmac_idx].lmacid = bgx->acpi_lmac_idx; in bgx_acpi_register_phy()
1414 bgx->acpi_lmac_idx++; /* move to next LMAC */ in bgx_acpi_register_phy()
1423 struct bgx *bgx = context; in bgx_acpi_match_id() local
1426 snprintf(bgx_sel, 5, "BGX%d", bgx->bgx_id); in bgx_acpi_match_id()
1436 bgx_acpi_register_phy, NULL, bgx, NULL); in bgx_acpi_match_id()
1442 static int bgx_init_acpi_phy(struct bgx *bgx) in bgx_init_acpi_phy() argument
1444 acpi_get_devices(NULL, bgx_acpi_match_id, bgx, (void **)NULL); in bgx_init_acpi_phy()
1450 static int bgx_init_acpi_phy(struct bgx *bgx) in bgx_init_acpi_phy() argument
1459 static int bgx_init_of_phy(struct bgx *bgx) in bgx_init_of_phy() argument
1465 device_for_each_child_node(&bgx->pdev->dev, fwn) { in bgx_init_of_phy()
1479 ether_addr_copy(bgx->lmac[lmac].mac, mac); in bgx_init_of_phy()
1481 SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev); in bgx_init_of_phy()
1482 bgx->lmac[lmac].lmacid = lmac; in bgx_init_of_phy()
1495 bgx->lmac[lmac].phydev = pd; in bgx_init_of_phy()
1499 if (lmac == bgx->max_lmac) { in bgx_init_of_phy()
1511 if (bgx->lmac[lmac].phydev) { in bgx_init_of_phy()
1512 put_device(&bgx->lmac[lmac].phydev->mdio.dev); in bgx_init_of_phy()
1513 bgx->lmac[lmac].phydev = NULL; in bgx_init_of_phy()
1523 static int bgx_init_of_phy(struct bgx *bgx) in bgx_init_of_phy() argument
1530 static int bgx_init_phy(struct bgx *bgx) in bgx_init_phy() argument
1533 return bgx_init_acpi_phy(bgx); in bgx_init_phy()
1535 return bgx_init_of_phy(bgx); in bgx_init_phy()
1542 struct bgx *bgx = NULL; in bgx_probe() local
1546 bgx = devm_kzalloc(dev, sizeof(*bgx), GFP_KERNEL); in bgx_probe()
1547 if (!bgx) in bgx_probe()
1549 bgx->pdev = pdev; in bgx_probe()
1551 pci_set_drvdata(pdev, bgx); in bgx_probe()
1567 bgx->reg_base = pcim_iomap(pdev, PCI_CFG_REG_BAR_NUM, 0); in bgx_probe()
1568 if (!bgx->reg_base) { in bgx_probe()
1578 bgx->bgx_id = (pci_resource_start(pdev, in bgx_probe()
1580 bgx->bgx_id += nic_get_node_id(pdev) * max_bgx_per_node; in bgx_probe()
1581 bgx->max_lmac = MAX_LMAC_PER_BGX; in bgx_probe()
1582 bgx_vnic[bgx->bgx_id] = bgx; in bgx_probe()
1584 bgx->is_rgx = true; in bgx_probe()
1585 bgx->max_lmac = 1; in bgx_probe()
1586 bgx->bgx_id = MAX_BGX_PER_CN81XX - 1; in bgx_probe()
1587 bgx_vnic[bgx->bgx_id] = bgx; in bgx_probe()
1596 ((sdevid == PCI_SUBSYS_DEVID_83XX_BGX) && (bgx->bgx_id == 2))) in bgx_probe()
1597 bgx->is_dlm = true; in bgx_probe()
1599 bgx_get_qlm_mode(bgx); in bgx_probe()
1601 err = bgx_init_phy(bgx); in bgx_probe()
1605 bgx_init_hw(bgx); in bgx_probe()
1608 for (lmac = 0; lmac < bgx->lmac_count; lmac++) { in bgx_probe()
1609 err = bgx_lmac_enable(bgx, lmac); in bgx_probe()
1612 bgx->bgx_id, lmac); in bgx_probe()
1614 bgx_lmac_disable(bgx, --lmac); in bgx_probe()
1622 bgx_vnic[bgx->bgx_id] = NULL; in bgx_probe()
1633 struct bgx *bgx = pci_get_drvdata(pdev); in bgx_remove() local
1637 for (lmac = 0; lmac < bgx->lmac_count; lmac++) in bgx_remove()
1638 bgx_lmac_disable(bgx, lmac); in bgx_remove()
1640 bgx_vnic[bgx->bgx_id] = NULL; in bgx_remove()