• Home
  • Raw
  • Download

Lines Matching refs:pdata

127 static inline unsigned int xgbe_get_max_frame(struct xgbe_prv_data *pdata)  in xgbe_get_max_frame()  argument
129 return pdata->netdev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN; in xgbe_get_max_frame()
132 static unsigned int xgbe_usec_to_riwt(struct xgbe_prv_data *pdata, in xgbe_usec_to_riwt() argument
140 rate = pdata->sysclk_rate; in xgbe_usec_to_riwt()
155 static unsigned int xgbe_riwt_to_usec(struct xgbe_prv_data *pdata, in xgbe_riwt_to_usec() argument
163 rate = pdata->sysclk_rate; in xgbe_riwt_to_usec()
178 static int xgbe_config_pbl_val(struct xgbe_prv_data *pdata) in xgbe_config_pbl_val() argument
184 pbl = pdata->pbl; in xgbe_config_pbl_val()
186 if (pdata->pbl > 32) { in xgbe_config_pbl_val()
191 for (i = 0; i < pdata->channel_count; i++) { in xgbe_config_pbl_val()
192 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_CR, PBLX8, in xgbe_config_pbl_val()
195 if (pdata->channel[i]->tx_ring) in xgbe_config_pbl_val()
196 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_TCR, in xgbe_config_pbl_val()
199 if (pdata->channel[i]->rx_ring) in xgbe_config_pbl_val()
200 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_RCR, in xgbe_config_pbl_val()
207 static int xgbe_config_osp_mode(struct xgbe_prv_data *pdata) in xgbe_config_osp_mode() argument
211 for (i = 0; i < pdata->channel_count; i++) { in xgbe_config_osp_mode()
212 if (!pdata->channel[i]->tx_ring) in xgbe_config_osp_mode()
215 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_TCR, OSP, in xgbe_config_osp_mode()
216 pdata->tx_osp_mode); in xgbe_config_osp_mode()
222 static int xgbe_config_rsf_mode(struct xgbe_prv_data *pdata, unsigned int val) in xgbe_config_rsf_mode() argument
226 for (i = 0; i < pdata->rx_q_count; i++) in xgbe_config_rsf_mode()
227 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, RSF, val); in xgbe_config_rsf_mode()
232 static int xgbe_config_tsf_mode(struct xgbe_prv_data *pdata, unsigned int val) in xgbe_config_tsf_mode() argument
236 for (i = 0; i < pdata->tx_q_count; i++) in xgbe_config_tsf_mode()
237 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TSF, val); in xgbe_config_tsf_mode()
242 static int xgbe_config_rx_threshold(struct xgbe_prv_data *pdata, in xgbe_config_rx_threshold() argument
247 for (i = 0; i < pdata->rx_q_count; i++) in xgbe_config_rx_threshold()
248 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, RTC, val); in xgbe_config_rx_threshold()
253 static int xgbe_config_tx_threshold(struct xgbe_prv_data *pdata, in xgbe_config_tx_threshold() argument
258 for (i = 0; i < pdata->tx_q_count; i++) in xgbe_config_tx_threshold()
259 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TTC, val); in xgbe_config_tx_threshold()
264 static int xgbe_config_rx_coalesce(struct xgbe_prv_data *pdata) in xgbe_config_rx_coalesce() argument
268 for (i = 0; i < pdata->channel_count; i++) { in xgbe_config_rx_coalesce()
269 if (!pdata->channel[i]->rx_ring) in xgbe_config_rx_coalesce()
272 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_RIWT, RWT, in xgbe_config_rx_coalesce()
273 pdata->rx_riwt); in xgbe_config_rx_coalesce()
279 static int xgbe_config_tx_coalesce(struct xgbe_prv_data *pdata) in xgbe_config_tx_coalesce() argument
284 static void xgbe_config_rx_buffer_size(struct xgbe_prv_data *pdata) in xgbe_config_rx_buffer_size() argument
288 for (i = 0; i < pdata->channel_count; i++) { in xgbe_config_rx_buffer_size()
289 if (!pdata->channel[i]->rx_ring) in xgbe_config_rx_buffer_size()
292 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_RCR, RBSZ, in xgbe_config_rx_buffer_size()
293 pdata->rx_buf_size); in xgbe_config_rx_buffer_size()
297 static void xgbe_config_tso_mode(struct xgbe_prv_data *pdata) in xgbe_config_tso_mode() argument
301 for (i = 0; i < pdata->channel_count; i++) { in xgbe_config_tso_mode()
302 if (!pdata->channel[i]->tx_ring) in xgbe_config_tso_mode()
305 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_TCR, TSE, 1); in xgbe_config_tso_mode()
309 static void xgbe_config_sph_mode(struct xgbe_prv_data *pdata) in xgbe_config_sph_mode() argument
313 for (i = 0; i < pdata->channel_count; i++) { in xgbe_config_sph_mode()
314 if (!pdata->channel[i]->rx_ring) in xgbe_config_sph_mode()
317 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_CR, SPH, 1); in xgbe_config_sph_mode()
320 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, HDSMS, XGBE_SPH_HDSMS_SIZE); in xgbe_config_sph_mode()
323 static int xgbe_write_rss_reg(struct xgbe_prv_data *pdata, unsigned int type, in xgbe_write_rss_reg() argument
329 mutex_lock(&pdata->rss_mutex); in xgbe_write_rss_reg()
331 if (XGMAC_IOREAD_BITS(pdata, MAC_RSSAR, OB)) { in xgbe_write_rss_reg()
336 XGMAC_IOWRITE(pdata, MAC_RSSDR, val); in xgbe_write_rss_reg()
338 XGMAC_IOWRITE_BITS(pdata, MAC_RSSAR, RSSIA, index); in xgbe_write_rss_reg()
339 XGMAC_IOWRITE_BITS(pdata, MAC_RSSAR, ADDRT, type); in xgbe_write_rss_reg()
340 XGMAC_IOWRITE_BITS(pdata, MAC_RSSAR, CT, 0); in xgbe_write_rss_reg()
341 XGMAC_IOWRITE_BITS(pdata, MAC_RSSAR, OB, 1); in xgbe_write_rss_reg()
345 if (!XGMAC_IOREAD_BITS(pdata, MAC_RSSAR, OB)) in xgbe_write_rss_reg()
354 mutex_unlock(&pdata->rss_mutex); in xgbe_write_rss_reg()
359 static int xgbe_write_rss_hash_key(struct xgbe_prv_data *pdata) in xgbe_write_rss_hash_key() argument
361 unsigned int key_regs = sizeof(pdata->rss_key) / sizeof(u32); in xgbe_write_rss_hash_key()
362 unsigned int *key = (unsigned int *)&pdata->rss_key; in xgbe_write_rss_hash_key()
366 ret = xgbe_write_rss_reg(pdata, XGBE_RSS_HASH_KEY_TYPE, in xgbe_write_rss_hash_key()
375 static int xgbe_write_rss_lookup_table(struct xgbe_prv_data *pdata) in xgbe_write_rss_lookup_table() argument
380 for (i = 0; i < ARRAY_SIZE(pdata->rss_table); i++) { in xgbe_write_rss_lookup_table()
381 ret = xgbe_write_rss_reg(pdata, in xgbe_write_rss_lookup_table()
383 pdata->rss_table[i]); in xgbe_write_rss_lookup_table()
391 static int xgbe_set_rss_hash_key(struct xgbe_prv_data *pdata, const u8 *key) in xgbe_set_rss_hash_key() argument
393 memcpy(pdata->rss_key, key, sizeof(pdata->rss_key)); in xgbe_set_rss_hash_key()
395 return xgbe_write_rss_hash_key(pdata); in xgbe_set_rss_hash_key()
398 static int xgbe_set_rss_lookup_table(struct xgbe_prv_data *pdata, in xgbe_set_rss_lookup_table() argument
403 for (i = 0; i < ARRAY_SIZE(pdata->rss_table); i++) in xgbe_set_rss_lookup_table()
404 XGMAC_SET_BITS(pdata->rss_table[i], MAC_RSSDR, DMCH, table[i]); in xgbe_set_rss_lookup_table()
406 return xgbe_write_rss_lookup_table(pdata); in xgbe_set_rss_lookup_table()
409 static int xgbe_enable_rss(struct xgbe_prv_data *pdata) in xgbe_enable_rss() argument
413 if (!pdata->hw_feat.rss) in xgbe_enable_rss()
417 ret = xgbe_write_rss_hash_key(pdata); in xgbe_enable_rss()
422 ret = xgbe_write_rss_lookup_table(pdata); in xgbe_enable_rss()
427 XGMAC_IOWRITE(pdata, MAC_RSSCR, pdata->rss_options); in xgbe_enable_rss()
430 XGMAC_IOWRITE_BITS(pdata, MAC_RSSCR, RSSE, 1); in xgbe_enable_rss()
435 static int xgbe_disable_rss(struct xgbe_prv_data *pdata) in xgbe_disable_rss() argument
437 if (!pdata->hw_feat.rss) in xgbe_disable_rss()
440 XGMAC_IOWRITE_BITS(pdata, MAC_RSSCR, RSSE, 0); in xgbe_disable_rss()
445 static void xgbe_config_rss(struct xgbe_prv_data *pdata) in xgbe_config_rss() argument
449 if (!pdata->hw_feat.rss) in xgbe_config_rss()
452 if (pdata->netdev->features & NETIF_F_RXHASH) in xgbe_config_rss()
453 ret = xgbe_enable_rss(pdata); in xgbe_config_rss()
455 ret = xgbe_disable_rss(pdata); in xgbe_config_rss()
458 netdev_err(pdata->netdev, in xgbe_config_rss()
462 static bool xgbe_is_pfc_queue(struct xgbe_prv_data *pdata, in xgbe_is_pfc_queue() argument
469 if (pdata->prio2q_map[prio] != queue) in xgbe_is_pfc_queue()
473 tc = pdata->ets->prio_tc[prio]; in xgbe_is_pfc_queue()
476 if (pdata->pfc->pfc_en & (1 << tc)) in xgbe_is_pfc_queue()
483 static void xgbe_set_vxlan_id(struct xgbe_prv_data *pdata) in xgbe_set_vxlan_id() argument
486 XGMAC_IOWRITE_BITS(pdata, MAC_TIR, TNID, pdata->vxlan_port); in xgbe_set_vxlan_id()
488 netif_dbg(pdata, drv, pdata->netdev, "VXLAN tunnel id set to %hx\n", in xgbe_set_vxlan_id()
489 pdata->vxlan_port); in xgbe_set_vxlan_id()
492 static void xgbe_enable_vxlan(struct xgbe_prv_data *pdata) in xgbe_enable_vxlan() argument
494 if (!pdata->hw_feat.vxn) in xgbe_enable_vxlan()
498 xgbe_set_vxlan_id(pdata); in xgbe_enable_vxlan()
501 XGMAC_IOWRITE_BITS(pdata, MAC_PFR, VUCC, 1); in xgbe_enable_vxlan()
504 XGMAC_IOWRITE_BITS(pdata, MAC_TCR, VNM, 0); in xgbe_enable_vxlan()
505 XGMAC_IOWRITE_BITS(pdata, MAC_TCR, VNE, 1); in xgbe_enable_vxlan()
507 netif_dbg(pdata, drv, pdata->netdev, "VXLAN acceleration enabled\n"); in xgbe_enable_vxlan()
510 static void xgbe_disable_vxlan(struct xgbe_prv_data *pdata) in xgbe_disable_vxlan() argument
512 if (!pdata->hw_feat.vxn) in xgbe_disable_vxlan()
516 XGMAC_IOWRITE_BITS(pdata, MAC_TCR, VNE, 0); in xgbe_disable_vxlan()
519 XGMAC_IOWRITE_BITS(pdata, MAC_PFR, VUCC, 0); in xgbe_disable_vxlan()
522 XGMAC_IOWRITE_BITS(pdata, MAC_TIR, TNID, 0); in xgbe_disable_vxlan()
524 netif_dbg(pdata, drv, pdata->netdev, "VXLAN acceleration disabled\n"); in xgbe_disable_vxlan()
527 static unsigned int xgbe_get_fc_queue_count(struct xgbe_prv_data *pdata) in xgbe_get_fc_queue_count() argument
532 if (XGMAC_GET_BITS(pdata->hw_feat.version, MAC_VR, SNPSVER) >= 0x30) in xgbe_get_fc_queue_count()
535 return min_t(unsigned int, pdata->tx_q_count, max_q_count); in xgbe_get_fc_queue_count()
538 static int xgbe_disable_tx_flow_control(struct xgbe_prv_data *pdata) in xgbe_disable_tx_flow_control() argument
544 for (i = 0; i < pdata->rx_q_count; i++) in xgbe_disable_tx_flow_control()
545 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, EHFC, 0); in xgbe_disable_tx_flow_control()
548 q_count = xgbe_get_fc_queue_count(pdata); in xgbe_disable_tx_flow_control()
551 reg_val = XGMAC_IOREAD(pdata, reg); in xgbe_disable_tx_flow_control()
553 XGMAC_IOWRITE(pdata, reg, reg_val); in xgbe_disable_tx_flow_control()
561 static int xgbe_enable_tx_flow_control(struct xgbe_prv_data *pdata) in xgbe_enable_tx_flow_control() argument
563 struct ieee_pfc *pfc = pdata->pfc; in xgbe_enable_tx_flow_control()
564 struct ieee_ets *ets = pdata->ets; in xgbe_enable_tx_flow_control()
569 for (i = 0; i < pdata->rx_q_count; i++) { in xgbe_enable_tx_flow_control()
572 if (pdata->rx_rfd[i]) { in xgbe_enable_tx_flow_control()
575 if (xgbe_is_pfc_queue(pdata, i)) in xgbe_enable_tx_flow_control()
582 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, EHFC, ehfc); in xgbe_enable_tx_flow_control()
584 netif_dbg(pdata, drv, pdata->netdev, in xgbe_enable_tx_flow_control()
590 q_count = xgbe_get_fc_queue_count(pdata); in xgbe_enable_tx_flow_control()
593 reg_val = XGMAC_IOREAD(pdata, reg); in xgbe_enable_tx_flow_control()
600 XGMAC_IOWRITE(pdata, reg, reg_val); in xgbe_enable_tx_flow_control()
608 static int xgbe_disable_rx_flow_control(struct xgbe_prv_data *pdata) in xgbe_disable_rx_flow_control() argument
610 XGMAC_IOWRITE_BITS(pdata, MAC_RFCR, RFE, 0); in xgbe_disable_rx_flow_control()
615 static int xgbe_enable_rx_flow_control(struct xgbe_prv_data *pdata) in xgbe_enable_rx_flow_control() argument
617 XGMAC_IOWRITE_BITS(pdata, MAC_RFCR, RFE, 1); in xgbe_enable_rx_flow_control()
622 static int xgbe_config_tx_flow_control(struct xgbe_prv_data *pdata) in xgbe_config_tx_flow_control() argument
624 struct ieee_pfc *pfc = pdata->pfc; in xgbe_config_tx_flow_control()
626 if (pdata->tx_pause || (pfc && pfc->pfc_en)) in xgbe_config_tx_flow_control()
627 xgbe_enable_tx_flow_control(pdata); in xgbe_config_tx_flow_control()
629 xgbe_disable_tx_flow_control(pdata); in xgbe_config_tx_flow_control()
634 static int xgbe_config_rx_flow_control(struct xgbe_prv_data *pdata) in xgbe_config_rx_flow_control() argument
636 struct ieee_pfc *pfc = pdata->pfc; in xgbe_config_rx_flow_control()
638 if (pdata->rx_pause || (pfc && pfc->pfc_en)) in xgbe_config_rx_flow_control()
639 xgbe_enable_rx_flow_control(pdata); in xgbe_config_rx_flow_control()
641 xgbe_disable_rx_flow_control(pdata); in xgbe_config_rx_flow_control()
646 static void xgbe_config_flow_control(struct xgbe_prv_data *pdata) in xgbe_config_flow_control() argument
648 struct ieee_pfc *pfc = pdata->pfc; in xgbe_config_flow_control()
650 xgbe_config_tx_flow_control(pdata); in xgbe_config_flow_control()
651 xgbe_config_rx_flow_control(pdata); in xgbe_config_flow_control()
653 XGMAC_IOWRITE_BITS(pdata, MAC_RFCR, PFCE, in xgbe_config_flow_control()
657 static void xgbe_enable_dma_interrupts(struct xgbe_prv_data *pdata) in xgbe_enable_dma_interrupts() argument
663 if (pdata->channel_irq_mode) in xgbe_enable_dma_interrupts()
664 XGMAC_IOWRITE_BITS(pdata, DMA_MR, INTM, in xgbe_enable_dma_interrupts()
665 pdata->channel_irq_mode); in xgbe_enable_dma_interrupts()
667 ver = XGMAC_GET_BITS(pdata->hw_feat.version, MAC_VR, SNPSVER); in xgbe_enable_dma_interrupts()
669 for (i = 0; i < pdata->channel_count; i++) { in xgbe_enable_dma_interrupts()
670 channel = pdata->channel[i]; in xgbe_enable_dma_interrupts()
699 if (!pdata->per_channel_irq || pdata->channel_irq_mode) in xgbe_enable_dma_interrupts()
711 if (!pdata->per_channel_irq || pdata->channel_irq_mode) in xgbe_enable_dma_interrupts()
720 static void xgbe_enable_mtl_interrupts(struct xgbe_prv_data *pdata) in xgbe_enable_mtl_interrupts() argument
725 q_count = max(pdata->hw_feat.tx_q_cnt, pdata->hw_feat.rx_q_cnt); in xgbe_enable_mtl_interrupts()
728 mtl_q_isr = XGMAC_MTL_IOREAD(pdata, i, MTL_Q_ISR); in xgbe_enable_mtl_interrupts()
729 XGMAC_MTL_IOWRITE(pdata, i, MTL_Q_ISR, mtl_q_isr); in xgbe_enable_mtl_interrupts()
732 XGMAC_MTL_IOWRITE(pdata, i, MTL_Q_IER, 0); in xgbe_enable_mtl_interrupts()
736 static void xgbe_enable_mac_interrupts(struct xgbe_prv_data *pdata) in xgbe_enable_mac_interrupts() argument
743 XGMAC_IOWRITE(pdata, MAC_IER, mac_ier); in xgbe_enable_mac_interrupts()
746 XGMAC_IOWRITE_BITS(pdata, MMC_RIER, ALL_INTERRUPTS, 0xffffffff); in xgbe_enable_mac_interrupts()
747 XGMAC_IOWRITE_BITS(pdata, MMC_TIER, ALL_INTERRUPTS, 0xffffffff); in xgbe_enable_mac_interrupts()
750 XGMAC_IOWRITE_BITS(pdata, MAC_MDIOIER, SNGLCOMPIE, 1); in xgbe_enable_mac_interrupts()
753 static void xgbe_enable_ecc_interrupts(struct xgbe_prv_data *pdata) in xgbe_enable_ecc_interrupts() argument
757 if (!pdata->vdata->ecc_support) in xgbe_enable_ecc_interrupts()
761 ecc_isr = XP_IOREAD(pdata, XP_ECC_ISR); in xgbe_enable_ecc_interrupts()
762 XP_IOWRITE(pdata, XP_ECC_ISR, ecc_isr); in xgbe_enable_ecc_interrupts()
772 XP_IOWRITE(pdata, XP_ECC_IER, ecc_ier); in xgbe_enable_ecc_interrupts()
775 static void xgbe_disable_ecc_ded(struct xgbe_prv_data *pdata) in xgbe_disable_ecc_ded() argument
779 ecc_ier = XP_IOREAD(pdata, XP_ECC_IER); in xgbe_disable_ecc_ded()
786 XP_IOWRITE(pdata, XP_ECC_IER, ecc_ier); in xgbe_disable_ecc_ded()
789 static void xgbe_disable_ecc_sec(struct xgbe_prv_data *pdata, in xgbe_disable_ecc_sec() argument
794 ecc_ier = XP_IOREAD(pdata, XP_ECC_IER); in xgbe_disable_ecc_sec()
809 XP_IOWRITE(pdata, XP_ECC_IER, ecc_ier); in xgbe_disable_ecc_sec()
812 static int xgbe_set_speed(struct xgbe_prv_data *pdata, int speed) in xgbe_set_speed() argument
830 if (XGMAC_IOREAD_BITS(pdata, MAC_TCR, SS) != ss) in xgbe_set_speed()
831 XGMAC_IOWRITE_BITS(pdata, MAC_TCR, SS, ss); in xgbe_set_speed()
836 static int xgbe_enable_rx_vlan_stripping(struct xgbe_prv_data *pdata) in xgbe_enable_rx_vlan_stripping() argument
839 XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, EVLRXS, 1); in xgbe_enable_rx_vlan_stripping()
842 XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, DOVLTC, 1); in xgbe_enable_rx_vlan_stripping()
845 XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, ERSVLM, 0); in xgbe_enable_rx_vlan_stripping()
848 XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, ESVL, 0); in xgbe_enable_rx_vlan_stripping()
851 XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, EVLS, 0x3); in xgbe_enable_rx_vlan_stripping()
856 static int xgbe_disable_rx_vlan_stripping(struct xgbe_prv_data *pdata) in xgbe_disable_rx_vlan_stripping() argument
858 XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, EVLS, 0); in xgbe_disable_rx_vlan_stripping()
863 static int xgbe_enable_rx_vlan_filtering(struct xgbe_prv_data *pdata) in xgbe_enable_rx_vlan_filtering() argument
866 XGMAC_IOWRITE_BITS(pdata, MAC_PFR, VTFE, 1); in xgbe_enable_rx_vlan_filtering()
869 XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, VTHM, 1); in xgbe_enable_rx_vlan_filtering()
872 XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, VTIM, 0); in xgbe_enable_rx_vlan_filtering()
875 XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, ETV, 1); in xgbe_enable_rx_vlan_filtering()
883 XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, VL, 1); in xgbe_enable_rx_vlan_filtering()
888 static int xgbe_disable_rx_vlan_filtering(struct xgbe_prv_data *pdata) in xgbe_disable_rx_vlan_filtering() argument
891 XGMAC_IOWRITE_BITS(pdata, MAC_PFR, VTFE, 0); in xgbe_disable_rx_vlan_filtering()
920 static int xgbe_update_vlan_hash_table(struct xgbe_prv_data *pdata) in xgbe_update_vlan_hash_table() argument
928 for_each_set_bit(vid, pdata->active_vlans, VLAN_N_VID) { in xgbe_update_vlan_hash_table()
937 XGMAC_IOWRITE_BITS(pdata, MAC_VLANHTR, VLHT, vlan_hash_table); in xgbe_update_vlan_hash_table()
942 static int xgbe_set_promiscuous_mode(struct xgbe_prv_data *pdata, in xgbe_set_promiscuous_mode() argument
947 if (XGMAC_IOREAD_BITS(pdata, MAC_PFR, PR) == val) in xgbe_set_promiscuous_mode()
950 netif_dbg(pdata, drv, pdata->netdev, "%s promiscuous mode\n", in xgbe_set_promiscuous_mode()
952 XGMAC_IOWRITE_BITS(pdata, MAC_PFR, PR, val); in xgbe_set_promiscuous_mode()
956 xgbe_disable_rx_vlan_filtering(pdata); in xgbe_set_promiscuous_mode()
958 if (pdata->netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER) in xgbe_set_promiscuous_mode()
959 xgbe_enable_rx_vlan_filtering(pdata); in xgbe_set_promiscuous_mode()
965 static int xgbe_set_all_multicast_mode(struct xgbe_prv_data *pdata, in xgbe_set_all_multicast_mode() argument
970 if (XGMAC_IOREAD_BITS(pdata, MAC_PFR, PM) == val) in xgbe_set_all_multicast_mode()
973 netif_dbg(pdata, drv, pdata->netdev, "%s allmulti mode\n", in xgbe_set_all_multicast_mode()
975 XGMAC_IOWRITE_BITS(pdata, MAC_PFR, PM, val); in xgbe_set_all_multicast_mode()
980 static void xgbe_set_mac_reg(struct xgbe_prv_data *pdata, in xgbe_set_mac_reg() argument
999 netif_dbg(pdata, drv, pdata->netdev, in xgbe_set_mac_reg()
1006 XGMAC_IOWRITE(pdata, *mac_reg, mac_addr_hi); in xgbe_set_mac_reg()
1008 XGMAC_IOWRITE(pdata, *mac_reg, mac_addr_lo); in xgbe_set_mac_reg()
1012 static void xgbe_set_mac_addn_addrs(struct xgbe_prv_data *pdata) in xgbe_set_mac_addn_addrs() argument
1014 struct net_device *netdev = pdata->netdev; in xgbe_set_mac_addn_addrs()
1020 addn_macs = pdata->hw_feat.addn_mac; in xgbe_set_mac_addn_addrs()
1023 xgbe_set_promiscuous_mode(pdata, 1); in xgbe_set_mac_addn_addrs()
1026 xgbe_set_mac_reg(pdata, ha, &mac_reg); in xgbe_set_mac_addn_addrs()
1031 xgbe_set_all_multicast_mode(pdata, 1); in xgbe_set_mac_addn_addrs()
1034 xgbe_set_mac_reg(pdata, ha, &mac_reg); in xgbe_set_mac_addn_addrs()
1042 xgbe_set_mac_reg(pdata, NULL, &mac_reg); in xgbe_set_mac_addn_addrs()
1045 static void xgbe_set_mac_hash_table(struct xgbe_prv_data *pdata) in xgbe_set_mac_hash_table() argument
1047 struct net_device *netdev = pdata->netdev; in xgbe_set_mac_hash_table()
1055 hash_table_shift = 26 - (pdata->hw_feat.hash_table_size >> 7); in xgbe_set_mac_hash_table()
1056 hash_table_count = pdata->hw_feat.hash_table_size / 32; in xgbe_set_mac_hash_table()
1075 XGMAC_IOWRITE(pdata, hash_reg, hash_table[i]); in xgbe_set_mac_hash_table()
1080 static int xgbe_add_mac_addresses(struct xgbe_prv_data *pdata) in xgbe_add_mac_addresses() argument
1082 if (pdata->hw_feat.hash_table_size) in xgbe_add_mac_addresses()
1083 xgbe_set_mac_hash_table(pdata); in xgbe_add_mac_addresses()
1085 xgbe_set_mac_addn_addrs(pdata); in xgbe_add_mac_addresses()
1090 static int xgbe_set_mac_address(struct xgbe_prv_data *pdata, u8 *addr) in xgbe_set_mac_address() argument
1098 XGMAC_IOWRITE(pdata, MAC_MACA0HR, mac_addr_hi); in xgbe_set_mac_address()
1099 XGMAC_IOWRITE(pdata, MAC_MACA0LR, mac_addr_lo); in xgbe_set_mac_address()
1104 static int xgbe_config_rx_mode(struct xgbe_prv_data *pdata) in xgbe_config_rx_mode() argument
1106 struct net_device *netdev = pdata->netdev; in xgbe_config_rx_mode()
1112 xgbe_set_promiscuous_mode(pdata, pr_mode); in xgbe_config_rx_mode()
1113 xgbe_set_all_multicast_mode(pdata, am_mode); in xgbe_config_rx_mode()
1115 xgbe_add_mac_addresses(pdata); in xgbe_config_rx_mode()
1120 static int xgbe_clr_gpio(struct xgbe_prv_data *pdata, unsigned int gpio) in xgbe_clr_gpio() argument
1127 reg = XGMAC_IOREAD(pdata, MAC_GPIOSR); in xgbe_clr_gpio()
1130 XGMAC_IOWRITE(pdata, MAC_GPIOSR, reg); in xgbe_clr_gpio()
1135 static int xgbe_set_gpio(struct xgbe_prv_data *pdata, unsigned int gpio) in xgbe_set_gpio() argument
1142 reg = XGMAC_IOREAD(pdata, MAC_GPIOSR); in xgbe_set_gpio()
1145 XGMAC_IOWRITE(pdata, MAC_GPIOSR, reg); in xgbe_set_gpio()
1150 static int xgbe_read_mmd_regs_v2(struct xgbe_prv_data *pdata, int prtad, in xgbe_read_mmd_regs_v2() argument
1160 mmd_address = (pdata->mdio_mmd << 16) | (mmd_reg & 0xffff); in xgbe_read_mmd_regs_v2()
1172 index = mmd_address & ~pdata->xpcs_window_mask; in xgbe_read_mmd_regs_v2()
1173 offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask); in xgbe_read_mmd_regs_v2()
1175 spin_lock_irqsave(&pdata->xpcs_lock, flags); in xgbe_read_mmd_regs_v2()
1176 XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index); in xgbe_read_mmd_regs_v2()
1177 mmd_data = XPCS16_IOREAD(pdata, offset); in xgbe_read_mmd_regs_v2()
1178 spin_unlock_irqrestore(&pdata->xpcs_lock, flags); in xgbe_read_mmd_regs_v2()
1183 static void xgbe_write_mmd_regs_v2(struct xgbe_prv_data *pdata, int prtad, in xgbe_write_mmd_regs_v2() argument
1192 mmd_address = (pdata->mdio_mmd << 16) | (mmd_reg & 0xffff); in xgbe_write_mmd_regs_v2()
1204 index = mmd_address & ~pdata->xpcs_window_mask; in xgbe_write_mmd_regs_v2()
1205 offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask); in xgbe_write_mmd_regs_v2()
1207 spin_lock_irqsave(&pdata->xpcs_lock, flags); in xgbe_write_mmd_regs_v2()
1208 XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index); in xgbe_write_mmd_regs_v2()
1209 XPCS16_IOWRITE(pdata, offset, mmd_data); in xgbe_write_mmd_regs_v2()
1210 spin_unlock_irqrestore(&pdata->xpcs_lock, flags); in xgbe_write_mmd_regs_v2()
1213 static int xgbe_read_mmd_regs_v1(struct xgbe_prv_data *pdata, int prtad, in xgbe_read_mmd_regs_v1() argument
1223 mmd_address = (pdata->mdio_mmd << 16) | (mmd_reg & 0xffff); in xgbe_read_mmd_regs_v1()
1234 spin_lock_irqsave(&pdata->xpcs_lock, flags); in xgbe_read_mmd_regs_v1()
1235 XPCS32_IOWRITE(pdata, PCS_V1_WINDOW_SELECT, mmd_address >> 8); in xgbe_read_mmd_regs_v1()
1236 mmd_data = XPCS32_IOREAD(pdata, (mmd_address & 0xff) << 2); in xgbe_read_mmd_regs_v1()
1237 spin_unlock_irqrestore(&pdata->xpcs_lock, flags); in xgbe_read_mmd_regs_v1()
1242 static void xgbe_write_mmd_regs_v1(struct xgbe_prv_data *pdata, int prtad, in xgbe_write_mmd_regs_v1() argument
1251 mmd_address = (pdata->mdio_mmd << 16) | (mmd_reg & 0xffff); in xgbe_write_mmd_regs_v1()
1262 spin_lock_irqsave(&pdata->xpcs_lock, flags); in xgbe_write_mmd_regs_v1()
1263 XPCS32_IOWRITE(pdata, PCS_V1_WINDOW_SELECT, mmd_address >> 8); in xgbe_write_mmd_regs_v1()
1264 XPCS32_IOWRITE(pdata, (mmd_address & 0xff) << 2, mmd_data); in xgbe_write_mmd_regs_v1()
1265 spin_unlock_irqrestore(&pdata->xpcs_lock, flags); in xgbe_write_mmd_regs_v1()
1268 static int xgbe_read_mmd_regs(struct xgbe_prv_data *pdata, int prtad, in xgbe_read_mmd_regs() argument
1271 switch (pdata->vdata->xpcs_access) { in xgbe_read_mmd_regs()
1273 return xgbe_read_mmd_regs_v1(pdata, prtad, mmd_reg); in xgbe_read_mmd_regs()
1277 return xgbe_read_mmd_regs_v2(pdata, prtad, mmd_reg); in xgbe_read_mmd_regs()
1281 static void xgbe_write_mmd_regs(struct xgbe_prv_data *pdata, int prtad, in xgbe_write_mmd_regs() argument
1284 switch (pdata->vdata->xpcs_access) { in xgbe_write_mmd_regs()
1286 return xgbe_write_mmd_regs_v1(pdata, prtad, mmd_reg, mmd_data); in xgbe_write_mmd_regs()
1290 return xgbe_write_mmd_regs_v2(pdata, prtad, mmd_reg, mmd_data); in xgbe_write_mmd_regs()
1308 static int xgbe_write_ext_mii_regs(struct xgbe_prv_data *pdata, int addr, in xgbe_write_ext_mii_regs() argument
1313 reinit_completion(&pdata->mdio_complete); in xgbe_write_ext_mii_regs()
1316 XGMAC_IOWRITE(pdata, MAC_MDIOSCAR, mdio_sca); in xgbe_write_ext_mii_regs()
1322 XGMAC_IOWRITE(pdata, MAC_MDIOSCCDR, mdio_sccd); in xgbe_write_ext_mii_regs()
1324 if (!wait_for_completion_timeout(&pdata->mdio_complete, HZ)) { in xgbe_write_ext_mii_regs()
1325 netdev_err(pdata->netdev, "mdio write operation timed out\n"); in xgbe_write_ext_mii_regs()
1332 static int xgbe_read_ext_mii_regs(struct xgbe_prv_data *pdata, int addr, in xgbe_read_ext_mii_regs() argument
1337 reinit_completion(&pdata->mdio_complete); in xgbe_read_ext_mii_regs()
1340 XGMAC_IOWRITE(pdata, MAC_MDIOSCAR, mdio_sca); in xgbe_read_ext_mii_regs()
1345 XGMAC_IOWRITE(pdata, MAC_MDIOSCCDR, mdio_sccd); in xgbe_read_ext_mii_regs()
1347 if (!wait_for_completion_timeout(&pdata->mdio_complete, HZ)) { in xgbe_read_ext_mii_regs()
1348 netdev_err(pdata->netdev, "mdio read operation timed out\n"); in xgbe_read_ext_mii_regs()
1352 return XGMAC_IOREAD_BITS(pdata, MAC_MDIOSCCDR, DATA); in xgbe_read_ext_mii_regs()
1355 static int xgbe_set_ext_mii_mode(struct xgbe_prv_data *pdata, unsigned int port, in xgbe_set_ext_mii_mode() argument
1358 unsigned int reg_val = XGMAC_IOREAD(pdata, MAC_MDIOCL22R); in xgbe_set_ext_mii_mode()
1372 XGMAC_IOWRITE(pdata, MAC_MDIOCL22R, reg_val); in xgbe_set_ext_mii_mode()
1382 static int xgbe_disable_rx_csum(struct xgbe_prv_data *pdata) in xgbe_disable_rx_csum() argument
1384 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, IPC, 0); in xgbe_disable_rx_csum()
1389 static int xgbe_enable_rx_csum(struct xgbe_prv_data *pdata) in xgbe_enable_rx_csum() argument
1391 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, IPC, 1); in xgbe_enable_rx_csum()
1445 static void xgbe_rx_desc_reset(struct xgbe_prv_data *pdata, in xgbe_rx_desc_reset() argument
1449 unsigned int rx_usecs = pdata->rx_usecs; in xgbe_rx_desc_reset()
1450 unsigned int rx_frames = pdata->rx_frames; in xgbe_rx_desc_reset()
1495 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_rx_desc_init() local
1508 xgbe_rx_desc_reset(pdata, rdata, i); in xgbe_rx_desc_init()
1529 static void xgbe_update_tstamp_addend(struct xgbe_prv_data *pdata, in xgbe_update_tstamp_addend() argument
1535 XGMAC_IOWRITE(pdata, MAC_TSAR, addend); in xgbe_update_tstamp_addend()
1536 XGMAC_IOWRITE_BITS(pdata, MAC_TSCR, TSADDREG, 1); in xgbe_update_tstamp_addend()
1539 while (--count && XGMAC_IOREAD_BITS(pdata, MAC_TSCR, TSADDREG)) in xgbe_update_tstamp_addend()
1543 netdev_err(pdata->netdev, in xgbe_update_tstamp_addend()
1547 static void xgbe_set_tstamp_time(struct xgbe_prv_data *pdata, unsigned int sec, in xgbe_set_tstamp_time() argument
1553 XGMAC_IOWRITE(pdata, MAC_STSUR, sec); in xgbe_set_tstamp_time()
1554 XGMAC_IOWRITE(pdata, MAC_STNUR, nsec); in xgbe_set_tstamp_time()
1555 XGMAC_IOWRITE_BITS(pdata, MAC_TSCR, TSINIT, 1); in xgbe_set_tstamp_time()
1558 while (--count && XGMAC_IOREAD_BITS(pdata, MAC_TSCR, TSINIT)) in xgbe_set_tstamp_time()
1562 netdev_err(pdata->netdev, "timed out initializing timestamp\n"); in xgbe_set_tstamp_time()
1565 static u64 xgbe_get_tstamp_time(struct xgbe_prv_data *pdata) in xgbe_get_tstamp_time() argument
1569 nsec = XGMAC_IOREAD(pdata, MAC_STSR); in xgbe_get_tstamp_time()
1571 nsec += XGMAC_IOREAD(pdata, MAC_STNR); in xgbe_get_tstamp_time()
1576 static u64 xgbe_get_tx_tstamp(struct xgbe_prv_data *pdata) in xgbe_get_tx_tstamp() argument
1581 if (pdata->vdata->tx_tstamp_workaround) { in xgbe_get_tx_tstamp()
1582 tx_snr = XGMAC_IOREAD(pdata, MAC_TXSNR); in xgbe_get_tx_tstamp()
1583 tx_ssr = XGMAC_IOREAD(pdata, MAC_TXSSR); in xgbe_get_tx_tstamp()
1585 tx_ssr = XGMAC_IOREAD(pdata, MAC_TXSSR); in xgbe_get_tx_tstamp()
1586 tx_snr = XGMAC_IOREAD(pdata, MAC_TXSNR); in xgbe_get_tx_tstamp()
1617 static int xgbe_config_tstamp(struct xgbe_prv_data *pdata, in xgbe_config_tstamp() argument
1629 XGMAC_IOWRITE(pdata, MAC_TSCR, mac_tscr); in xgbe_config_tstamp()
1636 XGMAC_IOWRITE_BITS(pdata, MAC_SSIR, SSINC, XGBE_TSTAMP_SSINC); in xgbe_config_tstamp()
1637 XGMAC_IOWRITE_BITS(pdata, MAC_SSIR, SNSINC, XGBE_TSTAMP_SNSINC); in xgbe_config_tstamp()
1638 xgbe_update_tstamp_addend(pdata, pdata->tstamp_addend); in xgbe_config_tstamp()
1639 xgbe_set_tstamp_time(pdata, 0, 0); in xgbe_config_tstamp()
1642 timecounter_init(&pdata->tstamp_tc, &pdata->tstamp_cc, in xgbe_config_tstamp()
1651 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_tx_start_xmit() local
1664 if (pdata->tx_usecs && !channel->tx_timer_active) { in xgbe_tx_start_xmit()
1667 jiffies + usecs_to_jiffies(pdata->tx_usecs)); in xgbe_tx_start_xmit()
1675 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_dev_xmit() local
1723 if (!pdata->tx_frames) in xgbe_dev_xmit()
1725 else if (tx_packets > pdata->tx_frames) in xgbe_dev_xmit()
1727 else if ((ring->coalesce_count % pdata->tx_frames) < tx_packets) in xgbe_dev_xmit()
1738 netif_dbg(pdata, tx_queued, pdata->netdev, in xgbe_dev_xmit()
1758 netif_dbg(pdata, tx_queued, pdata->netdev, in xgbe_dev_xmit()
1817 pdata->ext_stats.tx_tso_packets += tx_packets; in xgbe_dev_xmit()
1836 pdata->ext_stats.tx_vxlan_packets += packet->tx_packets; in xgbe_dev_xmit()
1875 pdata->ext_stats.txq_packets[channel->queue_index] += tx_packets; in xgbe_dev_xmit()
1876 pdata->ext_stats.txq_bytes[channel->queue_index] += tx_bytes; in xgbe_dev_xmit()
1889 if (netif_msg_tx_queued(pdata)) in xgbe_dev_xmit()
1890 xgbe_dump_tx_desc(pdata, ring, start_index, in xgbe_dev_xmit()
1898 netif_xmit_stopped(netdev_get_tx_queue(pdata->netdev, in xgbe_dev_xmit()
1913 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_dev_read() local
1918 struct net_device *netdev = pdata->netdev; in xgbe_dev_read()
1933 if (netif_msg_rx_status(pdata)) in xgbe_dev_read()
1934 xgbe_dump_rx_desc(pdata, ring, ring->cur); in xgbe_dev_read()
1962 pdata->ext_stats.rx_split_header_packets++; in xgbe_dev_read()
2011 pdata->ext_stats.rx_vxlan_packets++; in xgbe_dev_read()
2026 netif_dbg(pdata, rx_status, netdev, "err=%u, etlt=%#x\n", err, etlt); in xgbe_dev_read()
2037 netif_dbg(pdata, rx_status, netdev, "vlan-ctag=%#06x\n", in xgbe_dev_read()
2049 pdata->ext_stats.rx_csum_errors++; in xgbe_dev_read()
2055 pdata->ext_stats.rx_vxlan_csum_errors++; in xgbe_dev_read()
2062 pdata->ext_stats.rxq_packets[channel->queue_index]++; in xgbe_dev_read()
2063 pdata->ext_stats.rxq_bytes[channel->queue_index] += rdata->rx.len; in xgbe_dev_read()
2166 static int __xgbe_exit(struct xgbe_prv_data *pdata) in __xgbe_exit() argument
2173 XGMAC_IOWRITE_BITS(pdata, DMA_MR, SWR, 1); in __xgbe_exit()
2177 while (--count && XGMAC_IOREAD_BITS(pdata, DMA_MR, SWR)) in __xgbe_exit()
2188 static int xgbe_exit(struct xgbe_prv_data *pdata) in xgbe_exit() argument
2195 ret = __xgbe_exit(pdata); in xgbe_exit()
2199 return __xgbe_exit(pdata); in xgbe_exit()
2202 static int xgbe_flush_tx_queues(struct xgbe_prv_data *pdata) in xgbe_flush_tx_queues() argument
2206 if (XGMAC_GET_BITS(pdata->hw_feat.version, MAC_VR, SNPSVER) < 0x21) in xgbe_flush_tx_queues()
2209 for (i = 0; i < pdata->tx_q_count; i++) in xgbe_flush_tx_queues()
2210 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, FTQ, 1); in xgbe_flush_tx_queues()
2213 for (i = 0; i < pdata->tx_q_count; i++) { in xgbe_flush_tx_queues()
2215 while (--count && XGMAC_MTL_IOREAD_BITS(pdata, i, in xgbe_flush_tx_queues()
2226 static void xgbe_config_dma_bus(struct xgbe_prv_data *pdata) in xgbe_config_dma_bus() argument
2230 sbmr = XGMAC_IOREAD(pdata, DMA_SBMR); in xgbe_config_dma_bus()
2237 XGMAC_SET_BITS(sbmr, DMA_SBMR, BLEN, pdata->blen >> 2); in xgbe_config_dma_bus()
2238 XGMAC_SET_BITS(sbmr, DMA_SBMR, AAL, pdata->aal); in xgbe_config_dma_bus()
2239 XGMAC_SET_BITS(sbmr, DMA_SBMR, RD_OSR_LMT, pdata->rd_osr_limit - 1); in xgbe_config_dma_bus()
2240 XGMAC_SET_BITS(sbmr, DMA_SBMR, WR_OSR_LMT, pdata->wr_osr_limit - 1); in xgbe_config_dma_bus()
2242 XGMAC_IOWRITE(pdata, DMA_SBMR, sbmr); in xgbe_config_dma_bus()
2245 if (pdata->vdata->tx_desc_prefetch) in xgbe_config_dma_bus()
2246 XGMAC_IOWRITE_BITS(pdata, DMA_TXEDMACR, TDPS, in xgbe_config_dma_bus()
2247 pdata->vdata->tx_desc_prefetch); in xgbe_config_dma_bus()
2249 if (pdata->vdata->rx_desc_prefetch) in xgbe_config_dma_bus()
2250 XGMAC_IOWRITE_BITS(pdata, DMA_RXEDMACR, RDPS, in xgbe_config_dma_bus()
2251 pdata->vdata->rx_desc_prefetch); in xgbe_config_dma_bus()
2254 static void xgbe_config_dma_cache(struct xgbe_prv_data *pdata) in xgbe_config_dma_cache() argument
2256 XGMAC_IOWRITE(pdata, DMA_AXIARCR, pdata->arcr); in xgbe_config_dma_cache()
2257 XGMAC_IOWRITE(pdata, DMA_AXIAWCR, pdata->awcr); in xgbe_config_dma_cache()
2258 if (pdata->awarcr) in xgbe_config_dma_cache()
2259 XGMAC_IOWRITE(pdata, DMA_AXIAWARCR, pdata->awarcr); in xgbe_config_dma_cache()
2262 static void xgbe_config_mtl_mode(struct xgbe_prv_data *pdata) in xgbe_config_mtl_mode() argument
2267 XGMAC_IOWRITE_BITS(pdata, MTL_OMR, ETSALG, MTL_ETSALG_WRR); in xgbe_config_mtl_mode()
2270 for (i = 0; i < pdata->hw_feat.tc_cnt; i++) { in xgbe_config_mtl_mode()
2271 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_TC_ETSCR, TSA, in xgbe_config_mtl_mode()
2273 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_TC_QWR, QW, 1); in xgbe_config_mtl_mode()
2277 XGMAC_IOWRITE_BITS(pdata, MTL_OMR, RAA, MTL_RAA_SP); in xgbe_config_mtl_mode()
2280 static void xgbe_queue_flow_control_threshold(struct xgbe_prv_data *pdata, in xgbe_queue_flow_control_threshold() argument
2287 frame_fifo_size = XGMAC_FLOW_CONTROL_ALIGN(xgbe_get_max_frame(pdata)); in xgbe_queue_flow_control_threshold()
2289 if (pdata->pfcq[queue] && (q_fifo_size > pdata->pfc_rfa)) { in xgbe_queue_flow_control_threshold()
2291 rfa = pdata->pfc_rfa; in xgbe_queue_flow_control_threshold()
2305 pdata->rx_rfa[queue] = 0; in xgbe_queue_flow_control_threshold()
2306 pdata->rx_rfd[queue] = 0; in xgbe_queue_flow_control_threshold()
2312 pdata->rx_rfa[queue] = 0; /* Full - 1024 bytes */ in xgbe_queue_flow_control_threshold()
2313 pdata->rx_rfd[queue] = 1; /* Full - 1536 bytes */ in xgbe_queue_flow_control_threshold()
2319 pdata->rx_rfa[queue] = 2; /* Full - 2048 bytes */ in xgbe_queue_flow_control_threshold()
2320 pdata->rx_rfd[queue] = 5; /* Full - 3584 bytes */ in xgbe_queue_flow_control_threshold()
2341 pdata->rx_rfa[queue] = XGMAC_FLOW_CONTROL_VALUE(rfa); in xgbe_queue_flow_control_threshold()
2342 pdata->rx_rfd[queue] = XGMAC_FLOW_CONTROL_VALUE(rfd); in xgbe_queue_flow_control_threshold()
2345 static void xgbe_calculate_flow_control_threshold(struct xgbe_prv_data *pdata, in xgbe_calculate_flow_control_threshold() argument
2351 for (i = 0; i < pdata->rx_q_count; i++) { in xgbe_calculate_flow_control_threshold()
2354 xgbe_queue_flow_control_threshold(pdata, i, q_fifo_size); in xgbe_calculate_flow_control_threshold()
2358 static void xgbe_config_flow_control_threshold(struct xgbe_prv_data *pdata) in xgbe_config_flow_control_threshold() argument
2362 for (i = 0; i < pdata->rx_q_count; i++) { in xgbe_config_flow_control_threshold()
2363 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQFCR, RFA, in xgbe_config_flow_control_threshold()
2364 pdata->rx_rfa[i]); in xgbe_config_flow_control_threshold()
2365 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQFCR, RFD, in xgbe_config_flow_control_threshold()
2366 pdata->rx_rfd[i]); in xgbe_config_flow_control_threshold()
2370 static unsigned int xgbe_get_tx_fifo_size(struct xgbe_prv_data *pdata) in xgbe_get_tx_fifo_size() argument
2373 return min_t(unsigned int, pdata->tx_max_fifo_size, in xgbe_get_tx_fifo_size()
2374 pdata->hw_feat.tx_fifo_size); in xgbe_get_tx_fifo_size()
2377 static unsigned int xgbe_get_rx_fifo_size(struct xgbe_prv_data *pdata) in xgbe_get_rx_fifo_size() argument
2380 return min_t(unsigned int, pdata->rx_max_fifo_size, in xgbe_get_rx_fifo_size()
2381 pdata->hw_feat.rx_fifo_size); in xgbe_get_rx_fifo_size()
2430 static unsigned int xgbe_get_pfc_delay(struct xgbe_prv_data *pdata) in xgbe_get_pfc_delay() argument
2435 if (pdata->pfc->delay) in xgbe_get_pfc_delay()
2436 return pdata->pfc->delay / 8; in xgbe_get_pfc_delay()
2439 delay = xgbe_get_max_frame(pdata); in xgbe_get_pfc_delay()
2454 static unsigned int xgbe_get_pfc_queues(struct xgbe_prv_data *pdata) in xgbe_get_pfc_queues() argument
2459 if (!pdata->pfc->pfc_en) in xgbe_get_pfc_queues()
2463 prio_queues = XGMAC_PRIO_QUEUES(pdata->rx_q_count); in xgbe_get_pfc_queues()
2465 if (!xgbe_is_pfc_queue(pdata, i)) in xgbe_get_pfc_queues()
2468 pdata->pfcq[i] = 1; in xgbe_get_pfc_queues()
2475 static void xgbe_calculate_dcb_fifo(struct xgbe_prv_data *pdata, in xgbe_calculate_dcb_fifo() argument
2484 q_fifo_size = XGMAC_FIFO_ALIGN(xgbe_get_max_frame(pdata)); in xgbe_calculate_dcb_fifo()
2485 prio_queues = XGMAC_PRIO_QUEUES(pdata->rx_q_count); in xgbe_calculate_dcb_fifo()
2486 pfc_count = xgbe_get_pfc_queues(pdata); in xgbe_calculate_dcb_fifo()
2500 pdata->pfc_rfa = xgbe_get_pfc_delay(pdata); in xgbe_calculate_dcb_fifo()
2501 pdata->pfc_rfa = XGMAC_FLOW_CONTROL_ALIGN(pdata->pfc_rfa); in xgbe_calculate_dcb_fifo()
2503 if (pdata->pfc_rfa > q_fifo_size) { in xgbe_calculate_dcb_fifo()
2504 addn_fifo = pdata->pfc_rfa - q_fifo_size; in xgbe_calculate_dcb_fifo()
2521 if (!pdata->pfcq[i] || !addn_fifo) in xgbe_calculate_dcb_fifo()
2525 netdev_warn(pdata->netdev, in xgbe_calculate_dcb_fifo()
2546 static void xgbe_config_tx_fifo_size(struct xgbe_prv_data *pdata) in xgbe_config_tx_fifo_size() argument
2552 fifo_size = xgbe_get_tx_fifo_size(pdata); in xgbe_config_tx_fifo_size()
2554 xgbe_calculate_equal_fifo(fifo_size, pdata->tx_q_count, fifo); in xgbe_config_tx_fifo_size()
2556 for (i = 0; i < pdata->tx_q_count; i++) in xgbe_config_tx_fifo_size()
2557 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TQS, fifo[i]); in xgbe_config_tx_fifo_size()
2559 netif_info(pdata, drv, pdata->netdev, in xgbe_config_tx_fifo_size()
2561 pdata->tx_q_count, ((fifo[0] + 1) * XGMAC_FIFO_UNIT)); in xgbe_config_tx_fifo_size()
2564 static void xgbe_config_rx_fifo_size(struct xgbe_prv_data *pdata) in xgbe_config_rx_fifo_size() argument
2572 memset(pdata->pfcq, 0, sizeof(pdata->pfcq)); in xgbe_config_rx_fifo_size()
2573 pdata->pfc_rfa = 0; in xgbe_config_rx_fifo_size()
2575 fifo_size = xgbe_get_rx_fifo_size(pdata); in xgbe_config_rx_fifo_size()
2576 prio_queues = XGMAC_PRIO_QUEUES(pdata->rx_q_count); in xgbe_config_rx_fifo_size()
2579 fifo_size = xgbe_set_nonprio_fifos(fifo_size, pdata->rx_q_count, fifo); in xgbe_config_rx_fifo_size()
2581 if (pdata->pfc && pdata->ets) in xgbe_config_rx_fifo_size()
2582 xgbe_calculate_dcb_fifo(pdata, fifo_size, fifo); in xgbe_config_rx_fifo_size()
2586 for (i = 0; i < pdata->rx_q_count; i++) in xgbe_config_rx_fifo_size()
2587 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, RQS, fifo[i]); in xgbe_config_rx_fifo_size()
2589 xgbe_calculate_flow_control_threshold(pdata, fifo); in xgbe_config_rx_fifo_size()
2590 xgbe_config_flow_control_threshold(pdata); in xgbe_config_rx_fifo_size()
2592 if (pdata->pfc && pdata->ets && pdata->pfc->pfc_en) { in xgbe_config_rx_fifo_size()
2593 netif_info(pdata, drv, pdata->netdev, in xgbe_config_rx_fifo_size()
2594 "%u Rx hardware queues\n", pdata->rx_q_count); in xgbe_config_rx_fifo_size()
2595 for (i = 0; i < pdata->rx_q_count; i++) in xgbe_config_rx_fifo_size()
2596 netif_info(pdata, drv, pdata->netdev, in xgbe_config_rx_fifo_size()
2600 netif_info(pdata, drv, pdata->netdev, in xgbe_config_rx_fifo_size()
2602 pdata->rx_q_count, in xgbe_config_rx_fifo_size()
2607 static void xgbe_config_queue_mapping(struct xgbe_prv_data *pdata) in xgbe_config_queue_mapping() argument
2618 qptc = pdata->tx_q_count / pdata->hw_feat.tc_cnt; in xgbe_config_queue_mapping()
2619 qptc_extra = pdata->tx_q_count % pdata->hw_feat.tc_cnt; in xgbe_config_queue_mapping()
2621 for (i = 0, queue = 0; i < pdata->hw_feat.tc_cnt; i++) { in xgbe_config_queue_mapping()
2623 netif_dbg(pdata, drv, pdata->netdev, in xgbe_config_queue_mapping()
2625 XGMAC_MTL_IOWRITE_BITS(pdata, queue, MTL_Q_TQOMR, in xgbe_config_queue_mapping()
2627 pdata->q2tc_map[queue++] = i; in xgbe_config_queue_mapping()
2631 netif_dbg(pdata, drv, pdata->netdev, in xgbe_config_queue_mapping()
2633 XGMAC_MTL_IOWRITE_BITS(pdata, queue, MTL_Q_TQOMR, in xgbe_config_queue_mapping()
2635 pdata->q2tc_map[queue++] = i; in xgbe_config_queue_mapping()
2640 prio_queues = XGMAC_PRIO_QUEUES(pdata->rx_q_count); in xgbe_config_queue_mapping()
2649 netif_dbg(pdata, drv, pdata->netdev, in xgbe_config_queue_mapping()
2652 pdata->prio2q_map[prio++] = i; in xgbe_config_queue_mapping()
2656 netif_dbg(pdata, drv, pdata->netdev, in xgbe_config_queue_mapping()
2659 pdata->prio2q_map[prio++] = i; in xgbe_config_queue_mapping()
2667 XGMAC_IOWRITE(pdata, reg, reg_val); in xgbe_config_queue_mapping()
2675 for (i = 0; i < pdata->rx_q_count;) { in xgbe_config_queue_mapping()
2678 if ((i % MTL_RQDCM_Q_PER_REG) && (i != pdata->rx_q_count)) in xgbe_config_queue_mapping()
2681 XGMAC_IOWRITE(pdata, reg, reg_val); in xgbe_config_queue_mapping()
2688 static void xgbe_config_tc(struct xgbe_prv_data *pdata) in xgbe_config_tc() argument
2693 netdev_reset_tc(pdata->netdev); in xgbe_config_tc()
2694 if (!pdata->num_tcs) in xgbe_config_tc()
2697 netdev_set_num_tc(pdata->netdev, pdata->num_tcs); in xgbe_config_tc()
2699 for (i = 0, queue = 0, offset = 0; i < pdata->num_tcs; i++) { in xgbe_config_tc()
2700 while ((queue < pdata->tx_q_count) && in xgbe_config_tc()
2701 (pdata->q2tc_map[queue] == i)) in xgbe_config_tc()
2704 netif_dbg(pdata, drv, pdata->netdev, "TC%u using TXq%u-%u\n", in xgbe_config_tc()
2706 netdev_set_tc_queue(pdata->netdev, i, queue - offset, offset); in xgbe_config_tc()
2710 if (!pdata->ets) in xgbe_config_tc()
2714 netdev_set_prio_tc_map(pdata->netdev, prio, in xgbe_config_tc()
2715 pdata->ets->prio_tc[prio]); in xgbe_config_tc()
2718 static void xgbe_config_dcb_tc(struct xgbe_prv_data *pdata) in xgbe_config_dcb_tc() argument
2720 struct ieee_ets *ets = pdata->ets; in xgbe_config_dcb_tc()
2731 XGMAC_IOWRITE_BITS(pdata, MTL_OMR, ETSALG, MTL_ETSALG_DWRR); in xgbe_config_dcb_tc()
2734 total_weight = pdata->netdev->mtu * pdata->hw_feat.tc_cnt; in xgbe_config_dcb_tc()
2739 for (i = 0; i < pdata->hw_feat.tc_cnt; i++) { in xgbe_config_dcb_tc()
2748 netif_dbg(pdata, drv, pdata->netdev, "TC%u PRIO mask=%#x\n", in xgbe_config_dcb_tc()
2751 reg_val = XGMAC_IOREAD(pdata, reg); in xgbe_config_dcb_tc()
2756 XGMAC_IOWRITE(pdata, reg, reg_val); in xgbe_config_dcb_tc()
2761 netif_dbg(pdata, drv, pdata->netdev, in xgbe_config_dcb_tc()
2763 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_TC_ETSCR, TSA, in xgbe_config_dcb_tc()
2770 netif_dbg(pdata, drv, pdata->netdev, in xgbe_config_dcb_tc()
2772 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_TC_ETSCR, TSA, in xgbe_config_dcb_tc()
2774 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_TC_QWR, QW, in xgbe_config_dcb_tc()
2780 xgbe_config_tc(pdata); in xgbe_config_dcb_tc()
2783 static void xgbe_config_dcb_pfc(struct xgbe_prv_data *pdata) in xgbe_config_dcb_pfc() argument
2785 if (!test_bit(XGBE_DOWN, &pdata->dev_state)) { in xgbe_config_dcb_pfc()
2787 netif_tx_stop_all_queues(pdata->netdev); in xgbe_config_dcb_pfc()
2790 pdata->hw_if.disable_rx(pdata); in xgbe_config_dcb_pfc()
2793 xgbe_config_rx_fifo_size(pdata); in xgbe_config_dcb_pfc()
2794 xgbe_config_flow_control(pdata); in xgbe_config_dcb_pfc()
2796 if (!test_bit(XGBE_DOWN, &pdata->dev_state)) { in xgbe_config_dcb_pfc()
2798 pdata->hw_if.enable_rx(pdata); in xgbe_config_dcb_pfc()
2801 netif_tx_start_all_queues(pdata->netdev); in xgbe_config_dcb_pfc()
2805 static void xgbe_config_mac_address(struct xgbe_prv_data *pdata) in xgbe_config_mac_address() argument
2807 xgbe_set_mac_address(pdata, pdata->netdev->dev_addr); in xgbe_config_mac_address()
2810 if (pdata->hw_feat.hash_table_size) { in xgbe_config_mac_address()
2811 XGMAC_IOWRITE_BITS(pdata, MAC_PFR, HPF, 1); in xgbe_config_mac_address()
2812 XGMAC_IOWRITE_BITS(pdata, MAC_PFR, HUC, 1); in xgbe_config_mac_address()
2813 XGMAC_IOWRITE_BITS(pdata, MAC_PFR, HMC, 1); in xgbe_config_mac_address()
2817 static void xgbe_config_jumbo_enable(struct xgbe_prv_data *pdata) in xgbe_config_jumbo_enable() argument
2821 val = (pdata->netdev->mtu > XGMAC_STD_PACKET_MTU) ? 1 : 0; in xgbe_config_jumbo_enable()
2823 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, JE, val); in xgbe_config_jumbo_enable()
2826 static void xgbe_config_mac_speed(struct xgbe_prv_data *pdata) in xgbe_config_mac_speed() argument
2828 xgbe_set_speed(pdata, pdata->phy_speed); in xgbe_config_mac_speed()
2831 static void xgbe_config_checksum_offload(struct xgbe_prv_data *pdata) in xgbe_config_checksum_offload() argument
2833 if (pdata->netdev->features & NETIF_F_RXCSUM) in xgbe_config_checksum_offload()
2834 xgbe_enable_rx_csum(pdata); in xgbe_config_checksum_offload()
2836 xgbe_disable_rx_csum(pdata); in xgbe_config_checksum_offload()
2839 static void xgbe_config_vlan_support(struct xgbe_prv_data *pdata) in xgbe_config_vlan_support() argument
2842 XGMAC_IOWRITE_BITS(pdata, MAC_VLANIR, CSVL, 0); in xgbe_config_vlan_support()
2843 XGMAC_IOWRITE_BITS(pdata, MAC_VLANIR, VLTI, 1); in xgbe_config_vlan_support()
2846 xgbe_update_vlan_hash_table(pdata); in xgbe_config_vlan_support()
2848 if (pdata->netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER) in xgbe_config_vlan_support()
2849 xgbe_enable_rx_vlan_filtering(pdata); in xgbe_config_vlan_support()
2851 xgbe_disable_rx_vlan_filtering(pdata); in xgbe_config_vlan_support()
2853 if (pdata->netdev->features & NETIF_F_HW_VLAN_CTAG_RX) in xgbe_config_vlan_support()
2854 xgbe_enable_rx_vlan_stripping(pdata); in xgbe_config_vlan_support()
2856 xgbe_disable_rx_vlan_stripping(pdata); in xgbe_config_vlan_support()
2859 static u64 xgbe_mmc_read(struct xgbe_prv_data *pdata, unsigned int reg_lo) in xgbe_mmc_read() argument
2864 if (pdata->vdata->mmc_64bit) { in xgbe_mmc_read()
2893 val = XGMAC_IOREAD(pdata, reg_lo); in xgbe_mmc_read()
2896 val |= ((u64)XGMAC_IOREAD(pdata, reg_lo + 4) << 32); in xgbe_mmc_read()
2901 static void xgbe_tx_mmc_int(struct xgbe_prv_data *pdata) in xgbe_tx_mmc_int() argument
2903 struct xgbe_mmc_stats *stats = &pdata->mmc_stats; in xgbe_tx_mmc_int()
2904 unsigned int mmc_isr = XGMAC_IOREAD(pdata, MMC_TISR); in xgbe_tx_mmc_int()
2908 xgbe_mmc_read(pdata, MMC_TXOCTETCOUNT_GB_LO); in xgbe_tx_mmc_int()
2912 xgbe_mmc_read(pdata, MMC_TXFRAMECOUNT_GB_LO); in xgbe_tx_mmc_int()
2916 xgbe_mmc_read(pdata, MMC_TXBROADCASTFRAMES_G_LO); in xgbe_tx_mmc_int()
2920 xgbe_mmc_read(pdata, MMC_TXMULTICASTFRAMES_G_LO); in xgbe_tx_mmc_int()
2924 xgbe_mmc_read(pdata, MMC_TX64OCTETS_GB_LO); in xgbe_tx_mmc_int()
2928 xgbe_mmc_read(pdata, MMC_TX65TO127OCTETS_GB_LO); in xgbe_tx_mmc_int()
2932 xgbe_mmc_read(pdata, MMC_TX128TO255OCTETS_GB_LO); in xgbe_tx_mmc_int()
2936 xgbe_mmc_read(pdata, MMC_TX256TO511OCTETS_GB_LO); in xgbe_tx_mmc_int()
2940 xgbe_mmc_read(pdata, MMC_TX512TO1023OCTETS_GB_LO); in xgbe_tx_mmc_int()
2944 xgbe_mmc_read(pdata, MMC_TX1024TOMAXOCTETS_GB_LO); in xgbe_tx_mmc_int()
2948 xgbe_mmc_read(pdata, MMC_TXUNICASTFRAMES_GB_LO); in xgbe_tx_mmc_int()
2952 xgbe_mmc_read(pdata, MMC_TXMULTICASTFRAMES_GB_LO); in xgbe_tx_mmc_int()
2956 xgbe_mmc_read(pdata, MMC_TXBROADCASTFRAMES_GB_LO); in xgbe_tx_mmc_int()
2960 xgbe_mmc_read(pdata, MMC_TXUNDERFLOWERROR_LO); in xgbe_tx_mmc_int()
2964 xgbe_mmc_read(pdata, MMC_TXOCTETCOUNT_G_LO); in xgbe_tx_mmc_int()
2968 xgbe_mmc_read(pdata, MMC_TXFRAMECOUNT_G_LO); in xgbe_tx_mmc_int()
2972 xgbe_mmc_read(pdata, MMC_TXPAUSEFRAMES_LO); in xgbe_tx_mmc_int()
2976 xgbe_mmc_read(pdata, MMC_TXVLANFRAMES_G_LO); in xgbe_tx_mmc_int()
2979 static void xgbe_rx_mmc_int(struct xgbe_prv_data *pdata) in xgbe_rx_mmc_int() argument
2981 struct xgbe_mmc_stats *stats = &pdata->mmc_stats; in xgbe_rx_mmc_int()
2982 unsigned int mmc_isr = XGMAC_IOREAD(pdata, MMC_RISR); in xgbe_rx_mmc_int()
2986 xgbe_mmc_read(pdata, MMC_RXFRAMECOUNT_GB_LO); in xgbe_rx_mmc_int()
2990 xgbe_mmc_read(pdata, MMC_RXOCTETCOUNT_GB_LO); in xgbe_rx_mmc_int()
2994 xgbe_mmc_read(pdata, MMC_RXOCTETCOUNT_G_LO); in xgbe_rx_mmc_int()
2998 xgbe_mmc_read(pdata, MMC_RXBROADCASTFRAMES_G_LO); in xgbe_rx_mmc_int()
3002 xgbe_mmc_read(pdata, MMC_RXMULTICASTFRAMES_G_LO); in xgbe_rx_mmc_int()
3006 xgbe_mmc_read(pdata, MMC_RXCRCERROR_LO); in xgbe_rx_mmc_int()
3010 xgbe_mmc_read(pdata, MMC_RXRUNTERROR); in xgbe_rx_mmc_int()
3014 xgbe_mmc_read(pdata, MMC_RXJABBERERROR); in xgbe_rx_mmc_int()
3018 xgbe_mmc_read(pdata, MMC_RXUNDERSIZE_G); in xgbe_rx_mmc_int()
3022 xgbe_mmc_read(pdata, MMC_RXOVERSIZE_G); in xgbe_rx_mmc_int()
3026 xgbe_mmc_read(pdata, MMC_RX64OCTETS_GB_LO); in xgbe_rx_mmc_int()
3030 xgbe_mmc_read(pdata, MMC_RX65TO127OCTETS_GB_LO); in xgbe_rx_mmc_int()
3034 xgbe_mmc_read(pdata, MMC_RX128TO255OCTETS_GB_LO); in xgbe_rx_mmc_int()
3038 xgbe_mmc_read(pdata, MMC_RX256TO511OCTETS_GB_LO); in xgbe_rx_mmc_int()
3042 xgbe_mmc_read(pdata, MMC_RX512TO1023OCTETS_GB_LO); in xgbe_rx_mmc_int()
3046 xgbe_mmc_read(pdata, MMC_RX1024TOMAXOCTETS_GB_LO); in xgbe_rx_mmc_int()
3050 xgbe_mmc_read(pdata, MMC_RXUNICASTFRAMES_G_LO); in xgbe_rx_mmc_int()
3054 xgbe_mmc_read(pdata, MMC_RXLENGTHERROR_LO); in xgbe_rx_mmc_int()
3058 xgbe_mmc_read(pdata, MMC_RXOUTOFRANGETYPE_LO); in xgbe_rx_mmc_int()
3062 xgbe_mmc_read(pdata, MMC_RXPAUSEFRAMES_LO); in xgbe_rx_mmc_int()
3066 xgbe_mmc_read(pdata, MMC_RXFIFOOVERFLOW_LO); in xgbe_rx_mmc_int()
3070 xgbe_mmc_read(pdata, MMC_RXVLANFRAMES_GB_LO); in xgbe_rx_mmc_int()
3074 xgbe_mmc_read(pdata, MMC_RXWATCHDOGERROR); in xgbe_rx_mmc_int()
3077 static void xgbe_read_mmc_stats(struct xgbe_prv_data *pdata) in xgbe_read_mmc_stats() argument
3079 struct xgbe_mmc_stats *stats = &pdata->mmc_stats; in xgbe_read_mmc_stats()
3082 XGMAC_IOWRITE_BITS(pdata, MMC_CR, MCF, 1); in xgbe_read_mmc_stats()
3085 xgbe_mmc_read(pdata, MMC_TXOCTETCOUNT_GB_LO); in xgbe_read_mmc_stats()
3088 xgbe_mmc_read(pdata, MMC_TXFRAMECOUNT_GB_LO); in xgbe_read_mmc_stats()
3091 xgbe_mmc_read(pdata, MMC_TXBROADCASTFRAMES_G_LO); in xgbe_read_mmc_stats()
3094 xgbe_mmc_read(pdata, MMC_TXMULTICASTFRAMES_G_LO); in xgbe_read_mmc_stats()
3097 xgbe_mmc_read(pdata, MMC_TX64OCTETS_GB_LO); in xgbe_read_mmc_stats()
3100 xgbe_mmc_read(pdata, MMC_TX65TO127OCTETS_GB_LO); in xgbe_read_mmc_stats()
3103 xgbe_mmc_read(pdata, MMC_TX128TO255OCTETS_GB_LO); in xgbe_read_mmc_stats()
3106 xgbe_mmc_read(pdata, MMC_TX256TO511OCTETS_GB_LO); in xgbe_read_mmc_stats()
3109 xgbe_mmc_read(pdata, MMC_TX512TO1023OCTETS_GB_LO); in xgbe_read_mmc_stats()
3112 xgbe_mmc_read(pdata, MMC_TX1024TOMAXOCTETS_GB_LO); in xgbe_read_mmc_stats()
3115 xgbe_mmc_read(pdata, MMC_TXUNICASTFRAMES_GB_LO); in xgbe_read_mmc_stats()
3118 xgbe_mmc_read(pdata, MMC_TXMULTICASTFRAMES_GB_LO); in xgbe_read_mmc_stats()
3121 xgbe_mmc_read(pdata, MMC_TXBROADCASTFRAMES_GB_LO); in xgbe_read_mmc_stats()
3124 xgbe_mmc_read(pdata, MMC_TXUNDERFLOWERROR_LO); in xgbe_read_mmc_stats()
3127 xgbe_mmc_read(pdata, MMC_TXOCTETCOUNT_G_LO); in xgbe_read_mmc_stats()
3130 xgbe_mmc_read(pdata, MMC_TXFRAMECOUNT_G_LO); in xgbe_read_mmc_stats()
3133 xgbe_mmc_read(pdata, MMC_TXPAUSEFRAMES_LO); in xgbe_read_mmc_stats()
3136 xgbe_mmc_read(pdata, MMC_TXVLANFRAMES_G_LO); in xgbe_read_mmc_stats()
3139 xgbe_mmc_read(pdata, MMC_RXFRAMECOUNT_GB_LO); in xgbe_read_mmc_stats()
3142 xgbe_mmc_read(pdata, MMC_RXOCTETCOUNT_GB_LO); in xgbe_read_mmc_stats()
3145 xgbe_mmc_read(pdata, MMC_RXOCTETCOUNT_G_LO); in xgbe_read_mmc_stats()
3148 xgbe_mmc_read(pdata, MMC_RXBROADCASTFRAMES_G_LO); in xgbe_read_mmc_stats()
3151 xgbe_mmc_read(pdata, MMC_RXMULTICASTFRAMES_G_LO); in xgbe_read_mmc_stats()
3154 xgbe_mmc_read(pdata, MMC_RXCRCERROR_LO); in xgbe_read_mmc_stats()
3157 xgbe_mmc_read(pdata, MMC_RXRUNTERROR); in xgbe_read_mmc_stats()
3160 xgbe_mmc_read(pdata, MMC_RXJABBERERROR); in xgbe_read_mmc_stats()
3163 xgbe_mmc_read(pdata, MMC_RXUNDERSIZE_G); in xgbe_read_mmc_stats()
3166 xgbe_mmc_read(pdata, MMC_RXOVERSIZE_G); in xgbe_read_mmc_stats()
3169 xgbe_mmc_read(pdata, MMC_RX64OCTETS_GB_LO); in xgbe_read_mmc_stats()
3172 xgbe_mmc_read(pdata, MMC_RX65TO127OCTETS_GB_LO); in xgbe_read_mmc_stats()
3175 xgbe_mmc_read(pdata, MMC_RX128TO255OCTETS_GB_LO); in xgbe_read_mmc_stats()
3178 xgbe_mmc_read(pdata, MMC_RX256TO511OCTETS_GB_LO); in xgbe_read_mmc_stats()
3181 xgbe_mmc_read(pdata, MMC_RX512TO1023OCTETS_GB_LO); in xgbe_read_mmc_stats()
3184 xgbe_mmc_read(pdata, MMC_RX1024TOMAXOCTETS_GB_LO); in xgbe_read_mmc_stats()
3187 xgbe_mmc_read(pdata, MMC_RXUNICASTFRAMES_G_LO); in xgbe_read_mmc_stats()
3190 xgbe_mmc_read(pdata, MMC_RXLENGTHERROR_LO); in xgbe_read_mmc_stats()
3193 xgbe_mmc_read(pdata, MMC_RXOUTOFRANGETYPE_LO); in xgbe_read_mmc_stats()
3196 xgbe_mmc_read(pdata, MMC_RXPAUSEFRAMES_LO); in xgbe_read_mmc_stats()
3199 xgbe_mmc_read(pdata, MMC_RXFIFOOVERFLOW_LO); in xgbe_read_mmc_stats()
3202 xgbe_mmc_read(pdata, MMC_RXVLANFRAMES_GB_LO); in xgbe_read_mmc_stats()
3205 xgbe_mmc_read(pdata, MMC_RXWATCHDOGERROR); in xgbe_read_mmc_stats()
3208 XGMAC_IOWRITE_BITS(pdata, MMC_CR, MCF, 0); in xgbe_read_mmc_stats()
3211 static void xgbe_config_mmc(struct xgbe_prv_data *pdata) in xgbe_config_mmc() argument
3214 XGMAC_IOWRITE_BITS(pdata, MMC_CR, ROR, 1); in xgbe_config_mmc()
3217 XGMAC_IOWRITE_BITS(pdata, MMC_CR, CR, 1); in xgbe_config_mmc()
3220 static void xgbe_txq_prepare_tx_stop(struct xgbe_prv_data *pdata, in xgbe_txq_prepare_tx_stop() argument
3232 tx_status = XGMAC_MTL_IOREAD(pdata, queue, MTL_Q_TQDR); in xgbe_txq_prepare_tx_stop()
3241 netdev_info(pdata->netdev, in xgbe_txq_prepare_tx_stop()
3246 static void xgbe_prepare_tx_stop(struct xgbe_prv_data *pdata, in xgbe_prepare_tx_stop() argument
3253 if (XGMAC_GET_BITS(pdata->hw_feat.version, MAC_VR, SNPSVER) > 0x20) in xgbe_prepare_tx_stop()
3254 return xgbe_txq_prepare_tx_stop(pdata, queue); in xgbe_prepare_tx_stop()
3274 tx_status = XGMAC_IOREAD(pdata, tx_dsr); in xgbe_prepare_tx_stop()
3284 netdev_info(pdata->netdev, in xgbe_prepare_tx_stop()
3289 static void xgbe_enable_tx(struct xgbe_prv_data *pdata) in xgbe_enable_tx() argument
3294 for (i = 0; i < pdata->channel_count; i++) { in xgbe_enable_tx()
3295 if (!pdata->channel[i]->tx_ring) in xgbe_enable_tx()
3298 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_TCR, ST, 1); in xgbe_enable_tx()
3302 for (i = 0; i < pdata->tx_q_count; i++) in xgbe_enable_tx()
3303 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TXQEN, in xgbe_enable_tx()
3307 XGMAC_IOWRITE_BITS(pdata, MAC_TCR, TE, 1); in xgbe_enable_tx()
3310 static void xgbe_disable_tx(struct xgbe_prv_data *pdata) in xgbe_disable_tx() argument
3315 for (i = 0; i < pdata->tx_q_count; i++) in xgbe_disable_tx()
3316 xgbe_prepare_tx_stop(pdata, i); in xgbe_disable_tx()
3319 XGMAC_IOWRITE_BITS(pdata, MAC_TCR, TE, 0); in xgbe_disable_tx()
3322 for (i = 0; i < pdata->tx_q_count; i++) in xgbe_disable_tx()
3323 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TXQEN, 0); in xgbe_disable_tx()
3326 for (i = 0; i < pdata->channel_count; i++) { in xgbe_disable_tx()
3327 if (!pdata->channel[i]->tx_ring) in xgbe_disable_tx()
3330 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_TCR, ST, 0); in xgbe_disable_tx()
3334 static void xgbe_prepare_rx_stop(struct xgbe_prv_data *pdata, in xgbe_prepare_rx_stop() argument
3346 rx_status = XGMAC_MTL_IOREAD(pdata, queue, MTL_Q_RQDR); in xgbe_prepare_rx_stop()
3355 netdev_info(pdata->netdev, in xgbe_prepare_rx_stop()
3360 static void xgbe_enable_rx(struct xgbe_prv_data *pdata) in xgbe_enable_rx() argument
3365 for (i = 0; i < pdata->channel_count; i++) { in xgbe_enable_rx()
3366 if (!pdata->channel[i]->rx_ring) in xgbe_enable_rx()
3369 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_RCR, SR, 1); in xgbe_enable_rx()
3374 for (i = 0; i < pdata->rx_q_count; i++) in xgbe_enable_rx()
3376 XGMAC_IOWRITE(pdata, MAC_RQC0R, reg_val); in xgbe_enable_rx()
3379 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, DCRCC, 1); in xgbe_enable_rx()
3380 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, CST, 1); in xgbe_enable_rx()
3381 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, ACS, 1); in xgbe_enable_rx()
3382 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, RE, 1); in xgbe_enable_rx()
3385 static void xgbe_disable_rx(struct xgbe_prv_data *pdata) in xgbe_disable_rx() argument
3390 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, DCRCC, 0); in xgbe_disable_rx()
3391 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, CST, 0); in xgbe_disable_rx()
3392 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, ACS, 0); in xgbe_disable_rx()
3393 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, RE, 0); in xgbe_disable_rx()
3396 for (i = 0; i < pdata->rx_q_count; i++) in xgbe_disable_rx()
3397 xgbe_prepare_rx_stop(pdata, i); in xgbe_disable_rx()
3400 XGMAC_IOWRITE(pdata, MAC_RQC0R, 0); in xgbe_disable_rx()
3403 for (i = 0; i < pdata->channel_count; i++) { in xgbe_disable_rx()
3404 if (!pdata->channel[i]->rx_ring) in xgbe_disable_rx()
3407 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_RCR, SR, 0); in xgbe_disable_rx()
3411 static void xgbe_powerup_tx(struct xgbe_prv_data *pdata) in xgbe_powerup_tx() argument
3416 for (i = 0; i < pdata->channel_count; i++) { in xgbe_powerup_tx()
3417 if (!pdata->channel[i]->tx_ring) in xgbe_powerup_tx()
3420 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_TCR, ST, 1); in xgbe_powerup_tx()
3424 XGMAC_IOWRITE_BITS(pdata, MAC_TCR, TE, 1); in xgbe_powerup_tx()
3427 static void xgbe_powerdown_tx(struct xgbe_prv_data *pdata) in xgbe_powerdown_tx() argument
3432 for (i = 0; i < pdata->tx_q_count; i++) in xgbe_powerdown_tx()
3433 xgbe_prepare_tx_stop(pdata, i); in xgbe_powerdown_tx()
3436 XGMAC_IOWRITE_BITS(pdata, MAC_TCR, TE, 0); in xgbe_powerdown_tx()
3439 for (i = 0; i < pdata->channel_count; i++) { in xgbe_powerdown_tx()
3440 if (!pdata->channel[i]->tx_ring) in xgbe_powerdown_tx()
3443 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_TCR, ST, 0); in xgbe_powerdown_tx()
3447 static void xgbe_powerup_rx(struct xgbe_prv_data *pdata) in xgbe_powerup_rx() argument
3452 for (i = 0; i < pdata->channel_count; i++) { in xgbe_powerup_rx()
3453 if (!pdata->channel[i]->rx_ring) in xgbe_powerup_rx()
3456 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_RCR, SR, 1); in xgbe_powerup_rx()
3460 static void xgbe_powerdown_rx(struct xgbe_prv_data *pdata) in xgbe_powerdown_rx() argument
3465 for (i = 0; i < pdata->channel_count; i++) { in xgbe_powerdown_rx()
3466 if (!pdata->channel[i]->rx_ring) in xgbe_powerdown_rx()
3469 XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_RCR, SR, 0); in xgbe_powerdown_rx()
3473 static int xgbe_init(struct xgbe_prv_data *pdata) in xgbe_init() argument
3475 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_init()
3481 ret = xgbe_flush_tx_queues(pdata); in xgbe_init()
3483 netdev_err(pdata->netdev, "error flushing TX queues\n"); in xgbe_init()
3490 xgbe_config_dma_bus(pdata); in xgbe_init()
3491 xgbe_config_dma_cache(pdata); in xgbe_init()
3492 xgbe_config_osp_mode(pdata); in xgbe_init()
3493 xgbe_config_pbl_val(pdata); in xgbe_init()
3494 xgbe_config_rx_coalesce(pdata); in xgbe_init()
3495 xgbe_config_tx_coalesce(pdata); in xgbe_init()
3496 xgbe_config_rx_buffer_size(pdata); in xgbe_init()
3497 xgbe_config_tso_mode(pdata); in xgbe_init()
3498 xgbe_config_sph_mode(pdata); in xgbe_init()
3499 xgbe_config_rss(pdata); in xgbe_init()
3500 desc_if->wrapper_tx_desc_init(pdata); in xgbe_init()
3501 desc_if->wrapper_rx_desc_init(pdata); in xgbe_init()
3502 xgbe_enable_dma_interrupts(pdata); in xgbe_init()
3507 xgbe_config_mtl_mode(pdata); in xgbe_init()
3508 xgbe_config_queue_mapping(pdata); in xgbe_init()
3509 xgbe_config_tsf_mode(pdata, pdata->tx_sf_mode); in xgbe_init()
3510 xgbe_config_rsf_mode(pdata, pdata->rx_sf_mode); in xgbe_init()
3511 xgbe_config_tx_threshold(pdata, pdata->tx_threshold); in xgbe_init()
3512 xgbe_config_rx_threshold(pdata, pdata->rx_threshold); in xgbe_init()
3513 xgbe_config_tx_fifo_size(pdata); in xgbe_init()
3514 xgbe_config_rx_fifo_size(pdata); in xgbe_init()
3518 xgbe_config_dcb_tc(pdata); in xgbe_init()
3519 xgbe_enable_mtl_interrupts(pdata); in xgbe_init()
3524 xgbe_config_mac_address(pdata); in xgbe_init()
3525 xgbe_config_rx_mode(pdata); in xgbe_init()
3526 xgbe_config_jumbo_enable(pdata); in xgbe_init()
3527 xgbe_config_flow_control(pdata); in xgbe_init()
3528 xgbe_config_mac_speed(pdata); in xgbe_init()
3529 xgbe_config_checksum_offload(pdata); in xgbe_init()
3530 xgbe_config_vlan_support(pdata); in xgbe_init()
3531 xgbe_config_mmc(pdata); in xgbe_init()
3532 xgbe_enable_mac_interrupts(pdata); in xgbe_init()
3537 xgbe_enable_ecc_interrupts(pdata); in xgbe_init()