Lines Matching +full:smi +full:- +full:mdio
1 // SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-3-Clause)
3 * Copyright (c) 2014-2025, Advanced Micro Devices, Inc.
20 #include "xgbe-common.h"
67 for (i = 0; i < ARRAY_SIZE(pdata->channel); i++) { in xgbe_free_channels()
68 if (!pdata->channel[i]) in xgbe_free_channels()
71 kfree(pdata->channel[i]->rx_ring); in xgbe_free_channels()
72 kfree(pdata->channel[i]->tx_ring); in xgbe_free_channels()
73 kfree(pdata->channel[i]); in xgbe_free_channels()
75 pdata->channel[i] = NULL; in xgbe_free_channels()
78 pdata->channel_count = 0; in xgbe_free_channels()
89 count = max_t(unsigned int, pdata->tx_ring_count, pdata->rx_ring_count); in xgbe_alloc_channels()
92 cpu = cpumask_local_spread(i, dev_to_node(pdata->dev)); in xgbe_alloc_channels()
100 pdata->channel[i] = channel; in xgbe_alloc_channels()
102 snprintf(channel->name, sizeof(channel->name), "channel-%u", i); in xgbe_alloc_channels()
103 channel->pdata = pdata; in xgbe_alloc_channels()
104 channel->queue_index = i; in xgbe_alloc_channels()
105 channel->dma_regs = pdata->xgmac_regs + DMA_CH_BASE + in xgbe_alloc_channels()
107 channel->node = node; in xgbe_alloc_channels()
108 cpumask_set_cpu(cpu, &channel->affinity_mask); in xgbe_alloc_channels()
110 if (pdata->per_channel_irq) in xgbe_alloc_channels()
111 channel->dma_irq = pdata->channel_irq[i]; in xgbe_alloc_channels()
113 if (i < pdata->tx_ring_count) { in xgbe_alloc_channels()
118 spin_lock_init(&ring->lock); in xgbe_alloc_channels()
119 ring->node = node; in xgbe_alloc_channels()
121 channel->tx_ring = ring; in xgbe_alloc_channels()
124 if (i < pdata->rx_ring_count) { in xgbe_alloc_channels()
129 spin_lock_init(&ring->lock); in xgbe_alloc_channels()
130 ring->node = node; in xgbe_alloc_channels()
132 channel->rx_ring = ring; in xgbe_alloc_channels()
135 netif_dbg(pdata, drv, pdata->netdev, in xgbe_alloc_channels()
136 "%s: cpu=%u, node=%d\n", channel->name, cpu, node); in xgbe_alloc_channels()
138 netif_dbg(pdata, drv, pdata->netdev, in xgbe_alloc_channels()
140 channel->name, channel->dma_regs, channel->dma_irq, in xgbe_alloc_channels()
141 channel->tx_ring, channel->rx_ring); in xgbe_alloc_channels()
144 pdata->channel_count = count; in xgbe_alloc_channels()
151 return -ENOMEM; in xgbe_alloc_channels()
156 return (ring->rdesc_count - (ring->cur - ring->dirty)); in xgbe_tx_avail_desc()
161 return (ring->cur - ring->dirty); in xgbe_rx_dirty_desc()
167 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_maybe_stop_tx_queue()
170 netif_info(pdata, drv, pdata->netdev, in xgbe_maybe_stop_tx_queue()
172 netif_stop_subqueue(pdata->netdev, channel->queue_index); in xgbe_maybe_stop_tx_queue()
173 ring->tx.queue_stopped = 1; in xgbe_maybe_stop_tx_queue()
178 if (ring->tx.xmit_more) in xgbe_maybe_stop_tx_queue()
179 pdata->hw_if.tx_start_xmit(channel, ring); in xgbe_maybe_stop_tx_queue()
194 rx_buf_size = (rx_buf_size + XGBE_RX_BUF_ALIGN - 1) & in xgbe_calc_rx_buf_size()
195 ~(XGBE_RX_BUF_ALIGN - 1); in xgbe_calc_rx_buf_size()
203 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_enable_rx_tx_int()
206 if (channel->tx_ring && channel->rx_ring) in xgbe_enable_rx_tx_int()
208 else if (channel->tx_ring) in xgbe_enable_rx_tx_int()
210 else if (channel->rx_ring) in xgbe_enable_rx_tx_int()
215 hw_if->enable_int(channel, int_id); in xgbe_enable_rx_tx_int()
222 for (i = 0; i < pdata->channel_count; i++) in xgbe_enable_rx_tx_ints()
223 xgbe_enable_rx_tx_int(pdata, pdata->channel[i]); in xgbe_enable_rx_tx_ints()
229 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_disable_rx_tx_int()
232 if (channel->tx_ring && channel->rx_ring) in xgbe_disable_rx_tx_int()
234 else if (channel->tx_ring) in xgbe_disable_rx_tx_int()
236 else if (channel->rx_ring) in xgbe_disable_rx_tx_int()
241 hw_if->disable_int(channel, int_id); in xgbe_disable_rx_tx_int()
248 for (i = 0; i < pdata->channel_count; i++) in xgbe_disable_rx_tx_ints()
249 xgbe_disable_rx_tx_int(pdata, pdata->channel[i]); in xgbe_disable_rx_tx_ints()
263 dev_warn_once(pdata->dev, in xgbe_ecc_sec()
268 dev_warn_once(pdata->dev, in xgbe_ecc_sec()
288 netdev_alert(pdata->netdev, in xgbe_ecc_ded()
306 netif_dbg(pdata, intr, pdata->netdev, "ECC_ISR=%#010x\n", ecc_isr); in xgbe_ecc_isr_bh_work()
309 stop |= xgbe_ecc_ded(pdata, &pdata->tx_ded_period, in xgbe_ecc_isr_bh_work()
310 &pdata->tx_ded_count, "TX fifo"); in xgbe_ecc_isr_bh_work()
314 stop |= xgbe_ecc_ded(pdata, &pdata->rx_ded_period, in xgbe_ecc_isr_bh_work()
315 &pdata->rx_ded_count, "RX fifo"); in xgbe_ecc_isr_bh_work()
319 stop |= xgbe_ecc_ded(pdata, &pdata->desc_ded_period, in xgbe_ecc_isr_bh_work()
320 &pdata->desc_ded_count, in xgbe_ecc_isr_bh_work()
325 pdata->hw_if.disable_ecc_ded(pdata); in xgbe_ecc_isr_bh_work()
326 schedule_work(&pdata->stopdev_work); in xgbe_ecc_isr_bh_work()
331 if (xgbe_ecc_sec(pdata, &pdata->tx_sec_period, in xgbe_ecc_isr_bh_work()
332 &pdata->tx_sec_count, "TX fifo")) in xgbe_ecc_isr_bh_work()
333 pdata->hw_if.disable_ecc_sec(pdata, XGBE_ECC_SEC_TX); in xgbe_ecc_isr_bh_work()
337 if (xgbe_ecc_sec(pdata, &pdata->rx_sec_period, in xgbe_ecc_isr_bh_work()
338 &pdata->rx_sec_count, "RX fifo")) in xgbe_ecc_isr_bh_work()
339 pdata->hw_if.disable_ecc_sec(pdata, XGBE_ECC_SEC_RX); in xgbe_ecc_isr_bh_work()
342 if (xgbe_ecc_sec(pdata, &pdata->desc_sec_period, in xgbe_ecc_isr_bh_work()
343 &pdata->desc_sec_count, "descriptor cache")) in xgbe_ecc_isr_bh_work()
344 pdata->hw_if.disable_ecc_sec(pdata, XGBE_ECC_SEC_DESC); in xgbe_ecc_isr_bh_work()
351 if (pdata->vdata->irq_reissue_support) in xgbe_ecc_isr_bh_work()
359 if (pdata->isr_as_bh_work) in xgbe_ecc_isr()
360 queue_work(system_bh_wq, &pdata->ecc_bh_work); in xgbe_ecc_isr()
362 xgbe_ecc_isr_bh_work(&pdata->ecc_bh_work); in xgbe_ecc_isr()
371 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_isr_bh_work()
379 * this register to be non-zero in xgbe_isr_bh_work()
385 netif_dbg(pdata, intr, pdata->netdev, "DMA_ISR=%#010x\n", dma_isr); in xgbe_isr_bh_work()
387 for (i = 0; i < pdata->channel_count; i++) { in xgbe_isr_bh_work()
394 channel = pdata->channel[i]; in xgbe_isr_bh_work()
404 netif_dbg(pdata, intr, pdata->netdev, "DMA_CH%u_ISR=%#010x\n", in xgbe_isr_bh_work()
407 per_ch_irq = pdata->per_channel_irq; in xgbe_isr_bh_work()
411 * - When not using per-channel IRQs: schedule on global NAPI in xgbe_isr_bh_work()
413 * - RBU should also trigger NAPI (either per-channel or global) in xgbe_isr_bh_work()
421 pdata->ext_stats.rx_buffer_unavailable++; in xgbe_isr_bh_work()
424 napi = per_ch_irq ? &channel->napi : &pdata->napi; in xgbe_isr_bh_work()
429 if (pdata->channel_irq_mode) in xgbe_isr_bh_work()
432 disable_irq_nosync(channel->dma_irq); in xgbe_isr_bh_work()
441 * Don't clear Rx/Tx status if doing per-channel DMA in xgbe_isr_bh_work()
443 * the per-channel ISR/NAPI. In non-per-channel mode in xgbe_isr_bh_work()
446 * local copy so that the eventual write-back does not in xgbe_isr_bh_work()
455 schedule_work(&pdata->restart_work); in xgbe_isr_bh_work()
464 netif_dbg(pdata, intr, pdata->netdev, "MAC_ISR=%#010x\n", in xgbe_isr_bh_work()
468 hw_if->tx_mmc_int(pdata); in xgbe_isr_bh_work()
471 hw_if->rx_mmc_int(pdata); in xgbe_isr_bh_work()
476 netif_dbg(pdata, intr, pdata->netdev, in xgbe_isr_bh_work()
481 pdata->tx_tstamp = in xgbe_isr_bh_work()
483 queue_work(pdata->dev_workqueue, in xgbe_isr_bh_work()
484 &pdata->tx_tstamp_work); in xgbe_isr_bh_work()
488 if (XGMAC_GET_BITS(mac_isr, MAC_ISR, SMI)) { in xgbe_isr_bh_work()
491 netif_dbg(pdata, intr, pdata->netdev, in xgbe_isr_bh_work()
496 complete(&pdata->mdio_complete); in xgbe_isr_bh_work()
502 if (pdata->dev_irq == pdata->an_irq) in xgbe_isr_bh_work()
503 pdata->phy_if.an_isr(pdata); in xgbe_isr_bh_work()
506 if (pdata->vdata->ecc_support && (pdata->dev_irq == pdata->ecc_irq)) in xgbe_isr_bh_work()
507 xgbe_ecc_isr_bh_work(&pdata->ecc_bh_work); in xgbe_isr_bh_work()
510 if (pdata->vdata->i2c_support && (pdata->dev_irq == pdata->i2c_irq)) in xgbe_isr_bh_work()
511 pdata->i2c_if.i2c_isr(pdata); in xgbe_isr_bh_work()
514 if (pdata->vdata->irq_reissue_support) { in xgbe_isr_bh_work()
518 if (!pdata->per_channel_irq) in xgbe_isr_bh_work()
529 if (pdata->isr_as_bh_work) in xgbe_isr()
530 queue_work(system_bh_wq, &pdata->dev_bh_work); in xgbe_isr()
532 xgbe_isr_bh_work(&pdata->dev_bh_work); in xgbe_isr()
540 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_dma_isr()
546 if (napi_schedule_prep(&channel->napi)) { in xgbe_dma_isr()
548 if (pdata->channel_irq_mode) in xgbe_dma_isr()
551 disable_irq_nosync(channel->dma_irq); in xgbe_dma_isr()
554 __napi_schedule_irqoff(&channel->napi); in xgbe_dma_isr()
570 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_tx_timer()
573 DBGPR("-->xgbe_tx_timer\n"); in xgbe_tx_timer()
575 napi = (pdata->per_channel_irq) ? &channel->napi : &pdata->napi; in xgbe_tx_timer()
579 if (pdata->per_channel_irq) in xgbe_tx_timer()
580 if (pdata->channel_irq_mode) in xgbe_tx_timer()
583 disable_irq_nosync(channel->dma_irq); in xgbe_tx_timer()
591 channel->tx_timer_active = 0; in xgbe_tx_timer()
593 DBGPR("<--xgbe_tx_timer\n"); in xgbe_tx_timer()
602 pdata->phy_if.phy_status(pdata); in xgbe_service()
612 queue_work(pdata->dev_workqueue, &pdata->service_work); in xgbe_service_timer()
614 mod_timer(&pdata->service_timer, jiffies + HZ); in xgbe_service_timer()
616 if (!pdata->tx_usecs) in xgbe_service_timer()
619 for (i = 0; i < pdata->channel_count; i++) { in xgbe_service_timer()
620 channel = pdata->channel[i]; in xgbe_service_timer()
621 if (!channel->tx_ring || channel->tx_timer_active) in xgbe_service_timer()
623 channel->tx_timer_active = 1; in xgbe_service_timer()
624 mod_timer(&channel->tx_timer, in xgbe_service_timer()
625 jiffies + usecs_to_jiffies(pdata->tx_usecs)); in xgbe_service_timer()
634 timer_setup(&pdata->service_timer, xgbe_service_timer, 0); in xgbe_init_timers()
636 for (i = 0; i < pdata->channel_count; i++) { in xgbe_init_timers()
637 channel = pdata->channel[i]; in xgbe_init_timers()
638 if (!channel->tx_ring) in xgbe_init_timers()
641 timer_setup(&channel->tx_timer, xgbe_tx_timer, 0); in xgbe_init_timers()
647 mod_timer(&pdata->service_timer, jiffies + HZ); in xgbe_start_timers()
655 timer_delete_sync(&pdata->service_timer); in xgbe_stop_timers()
657 for (i = 0; i < pdata->channel_count; i++) { in xgbe_stop_timers()
658 channel = pdata->channel[i]; in xgbe_stop_timers()
659 if (!channel->tx_ring) in xgbe_stop_timers()
663 timer_delete_sync(&channel->tx_timer); in xgbe_stop_timers()
664 channel->tx_timer_active = 0; in xgbe_stop_timers()
671 struct xgbe_hw_features *hw_feat = &pdata->hw_feat; in xgbe_get_all_hw_features()
679 hw_feat->version = XGMAC_IOREAD(pdata, MAC_VR); in xgbe_get_all_hw_features()
682 hw_feat->gmii = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, GMIISEL); in xgbe_get_all_hw_features()
683 hw_feat->vlhash = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, VLHASH); in xgbe_get_all_hw_features()
684 hw_feat->sma = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, SMASEL); in xgbe_get_all_hw_features()
685 hw_feat->rwk = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, RWKSEL); in xgbe_get_all_hw_features()
686 hw_feat->mgk = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, MGKSEL); in xgbe_get_all_hw_features()
687 hw_feat->mmc = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, MMCSEL); in xgbe_get_all_hw_features()
688 hw_feat->aoe = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, ARPOFFSEL); in xgbe_get_all_hw_features()
689 hw_feat->ts = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TSSEL); in xgbe_get_all_hw_features()
690 hw_feat->eee = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, EEESEL); in xgbe_get_all_hw_features()
691 hw_feat->tx_coe = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TXCOESEL); in xgbe_get_all_hw_features()
692 hw_feat->rx_coe = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, RXCOESEL); in xgbe_get_all_hw_features()
693 hw_feat->addn_mac = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, in xgbe_get_all_hw_features()
695 hw_feat->ts_src = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TSSTSSEL); in xgbe_get_all_hw_features()
696 hw_feat->sa_vlan_ins = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, SAVLANINS); in xgbe_get_all_hw_features()
697 hw_feat->vxn = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, VXN); in xgbe_get_all_hw_features()
700 hw_feat->rx_fifo_size = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, in xgbe_get_all_hw_features()
702 hw_feat->tx_fifo_size = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, in xgbe_get_all_hw_features()
704 hw_feat->adv_ts_hi = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, ADVTHWORD); in xgbe_get_all_hw_features()
705 hw_feat->dma_width = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, ADDR64); in xgbe_get_all_hw_features()
706 hw_feat->dcb = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, DCBEN); in xgbe_get_all_hw_features()
707 hw_feat->sph = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, SPHEN); in xgbe_get_all_hw_features()
708 hw_feat->tso = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, TSOEN); in xgbe_get_all_hw_features()
709 hw_feat->dma_debug = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, DBGMEMA); in xgbe_get_all_hw_features()
710 hw_feat->rss = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, RSSEN); in xgbe_get_all_hw_features()
711 hw_feat->tc_cnt = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, NUMTC); in xgbe_get_all_hw_features()
712 hw_feat->hash_table_size = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, in xgbe_get_all_hw_features()
714 hw_feat->l3l4_filter_num = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, in xgbe_get_all_hw_features()
718 hw_feat->rx_q_cnt = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, RXQCNT); in xgbe_get_all_hw_features()
719 hw_feat->tx_q_cnt = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, TXQCNT); in xgbe_get_all_hw_features()
720 hw_feat->rx_ch_cnt = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, RXCHCNT); in xgbe_get_all_hw_features()
721 hw_feat->tx_ch_cnt = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, TXCHCNT); in xgbe_get_all_hw_features()
722 hw_feat->pps_out_num = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, PPSOUTNUM); in xgbe_get_all_hw_features()
723 hw_feat->aux_snap_num = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, AUXSNAPNUM); in xgbe_get_all_hw_features()
726 if (hw_feat->pps_out_num > XGBE_MAX_PPS_OUT) { in xgbe_get_all_hw_features()
727 dev_warn(pdata->dev, in xgbe_get_all_hw_features()
729 hw_feat->pps_out_num, XGBE_MAX_PPS_OUT); in xgbe_get_all_hw_features()
730 hw_feat->pps_out_num = XGBE_MAX_PPS_OUT; in xgbe_get_all_hw_features()
733 if (hw_feat->aux_snap_num > XGBE_MAX_AUX_SNAP) { in xgbe_get_all_hw_features()
734 dev_warn(pdata->dev, in xgbe_get_all_hw_features()
736 hw_feat->aux_snap_num, XGBE_MAX_AUX_SNAP); in xgbe_get_all_hw_features()
737 hw_feat->aux_snap_num = XGBE_MAX_AUX_SNAP; in xgbe_get_all_hw_features()
741 switch (hw_feat->hash_table_size) { in xgbe_get_all_hw_features()
745 hw_feat->hash_table_size = 64; in xgbe_get_all_hw_features()
748 hw_feat->hash_table_size = 128; in xgbe_get_all_hw_features()
751 hw_feat->hash_table_size = 256; in xgbe_get_all_hw_features()
756 switch (hw_feat->dma_width) { in xgbe_get_all_hw_features()
758 hw_feat->dma_width = 32; in xgbe_get_all_hw_features()
761 hw_feat->dma_width = 40; in xgbe_get_all_hw_features()
764 hw_feat->dma_width = 48; in xgbe_get_all_hw_features()
767 hw_feat->dma_width = 32; in xgbe_get_all_hw_features()
773 hw_feat->rx_q_cnt++; in xgbe_get_all_hw_features()
774 hw_feat->tx_q_cnt++; in xgbe_get_all_hw_features()
775 hw_feat->rx_ch_cnt++; in xgbe_get_all_hw_features()
776 hw_feat->tx_ch_cnt++; in xgbe_get_all_hw_features()
777 hw_feat->tc_cnt++; in xgbe_get_all_hw_features()
780 hw_feat->rx_fifo_size = 1 << (hw_feat->rx_fifo_size + 7); in xgbe_get_all_hw_features()
781 hw_feat->tx_fifo_size = 1 << (hw_feat->tx_fifo_size + 7); in xgbe_get_all_hw_features()
784 dev_dbg(pdata->dev, "Hardware features:\n"); in xgbe_get_all_hw_features()
787 dev_dbg(pdata->dev, " 1GbE support : %s\n", in xgbe_get_all_hw_features()
788 hw_feat->gmii ? "yes" : "no"); in xgbe_get_all_hw_features()
789 dev_dbg(pdata->dev, " VLAN hash filter : %s\n", in xgbe_get_all_hw_features()
790 hw_feat->vlhash ? "yes" : "no"); in xgbe_get_all_hw_features()
791 dev_dbg(pdata->dev, " MDIO interface : %s\n", in xgbe_get_all_hw_features()
792 hw_feat->sma ? "yes" : "no"); in xgbe_get_all_hw_features()
793 dev_dbg(pdata->dev, " Wake-up packet support : %s\n", in xgbe_get_all_hw_features()
794 hw_feat->rwk ? "yes" : "no"); in xgbe_get_all_hw_features()
795 dev_dbg(pdata->dev, " Magic packet support : %s\n", in xgbe_get_all_hw_features()
796 hw_feat->mgk ? "yes" : "no"); in xgbe_get_all_hw_features()
797 dev_dbg(pdata->dev, " Management counters : %s\n", in xgbe_get_all_hw_features()
798 hw_feat->mmc ? "yes" : "no"); in xgbe_get_all_hw_features()
799 dev_dbg(pdata->dev, " ARP offload : %s\n", in xgbe_get_all_hw_features()
800 hw_feat->aoe ? "yes" : "no"); in xgbe_get_all_hw_features()
801 dev_dbg(pdata->dev, " IEEE 1588-2008 Timestamp : %s\n", in xgbe_get_all_hw_features()
802 hw_feat->ts ? "yes" : "no"); in xgbe_get_all_hw_features()
803 dev_dbg(pdata->dev, " Energy Efficient Ethernet : %s\n", in xgbe_get_all_hw_features()
804 hw_feat->eee ? "yes" : "no"); in xgbe_get_all_hw_features()
805 dev_dbg(pdata->dev, " TX checksum offload : %s\n", in xgbe_get_all_hw_features()
806 hw_feat->tx_coe ? "yes" : "no"); in xgbe_get_all_hw_features()
807 dev_dbg(pdata->dev, " RX checksum offload : %s\n", in xgbe_get_all_hw_features()
808 hw_feat->rx_coe ? "yes" : "no"); in xgbe_get_all_hw_features()
809 dev_dbg(pdata->dev, " Additional MAC addresses : %u\n", in xgbe_get_all_hw_features()
810 hw_feat->addn_mac); in xgbe_get_all_hw_features()
811 dev_dbg(pdata->dev, " Timestamp source : %s\n", in xgbe_get_all_hw_features()
812 (hw_feat->ts_src == 1) ? "internal" : in xgbe_get_all_hw_features()
813 (hw_feat->ts_src == 2) ? "external" : in xgbe_get_all_hw_features()
814 (hw_feat->ts_src == 3) ? "internal/external" : "n/a"); in xgbe_get_all_hw_features()
815 dev_dbg(pdata->dev, " SA/VLAN insertion : %s\n", in xgbe_get_all_hw_features()
816 hw_feat->sa_vlan_ins ? "yes" : "no"); in xgbe_get_all_hw_features()
817 dev_dbg(pdata->dev, " VXLAN/NVGRE support : %s\n", in xgbe_get_all_hw_features()
818 hw_feat->vxn ? "yes" : "no"); in xgbe_get_all_hw_features()
821 dev_dbg(pdata->dev, " RX fifo size : %u\n", in xgbe_get_all_hw_features()
822 hw_feat->rx_fifo_size); in xgbe_get_all_hw_features()
823 dev_dbg(pdata->dev, " TX fifo size : %u\n", in xgbe_get_all_hw_features()
824 hw_feat->tx_fifo_size); in xgbe_get_all_hw_features()
825 dev_dbg(pdata->dev, " IEEE 1588 high word : %s\n", in xgbe_get_all_hw_features()
826 hw_feat->adv_ts_hi ? "yes" : "no"); in xgbe_get_all_hw_features()
827 dev_dbg(pdata->dev, " DMA width : %u\n", in xgbe_get_all_hw_features()
828 hw_feat->dma_width); in xgbe_get_all_hw_features()
829 dev_dbg(pdata->dev, " Data Center Bridging : %s\n", in xgbe_get_all_hw_features()
830 hw_feat->dcb ? "yes" : "no"); in xgbe_get_all_hw_features()
831 dev_dbg(pdata->dev, " Split header : %s\n", in xgbe_get_all_hw_features()
832 hw_feat->sph ? "yes" : "no"); in xgbe_get_all_hw_features()
833 dev_dbg(pdata->dev, " TCP Segmentation Offload : %s\n", in xgbe_get_all_hw_features()
834 hw_feat->tso ? "yes" : "no"); in xgbe_get_all_hw_features()
835 dev_dbg(pdata->dev, " Debug memory interface : %s\n", in xgbe_get_all_hw_features()
836 hw_feat->dma_debug ? "yes" : "no"); in xgbe_get_all_hw_features()
837 dev_dbg(pdata->dev, " Receive Side Scaling : %s\n", in xgbe_get_all_hw_features()
838 hw_feat->rss ? "yes" : "no"); in xgbe_get_all_hw_features()
839 dev_dbg(pdata->dev, " Traffic Class count : %u\n", in xgbe_get_all_hw_features()
840 hw_feat->tc_cnt); in xgbe_get_all_hw_features()
841 dev_dbg(pdata->dev, " Hash table size : %u\n", in xgbe_get_all_hw_features()
842 hw_feat->hash_table_size); in xgbe_get_all_hw_features()
843 dev_dbg(pdata->dev, " L3/L4 Filters : %u\n", in xgbe_get_all_hw_features()
844 hw_feat->l3l4_filter_num); in xgbe_get_all_hw_features()
847 dev_dbg(pdata->dev, " RX queue count : %u\n", in xgbe_get_all_hw_features()
848 hw_feat->rx_q_cnt); in xgbe_get_all_hw_features()
849 dev_dbg(pdata->dev, " TX queue count : %u\n", in xgbe_get_all_hw_features()
850 hw_feat->tx_q_cnt); in xgbe_get_all_hw_features()
851 dev_dbg(pdata->dev, " RX DMA channel count : %u\n", in xgbe_get_all_hw_features()
852 hw_feat->rx_ch_cnt); in xgbe_get_all_hw_features()
853 dev_dbg(pdata->dev, " TX DMA channel count : %u\n", in xgbe_get_all_hw_features()
854 hw_feat->rx_ch_cnt); in xgbe_get_all_hw_features()
855 dev_dbg(pdata->dev, " PPS outputs : %u\n", in xgbe_get_all_hw_features()
856 hw_feat->pps_out_num); in xgbe_get_all_hw_features()
857 dev_dbg(pdata->dev, " Auxiliary snapshot inputs : %u\n", in xgbe_get_all_hw_features()
858 hw_feat->aux_snap_num); in xgbe_get_all_hw_features()
867 pdata->vxlan_port = be16_to_cpu(ti->port); in xgbe_vxlan_set_port()
868 pdata->hw_if.enable_vxlan(pdata); in xgbe_vxlan_set_port()
878 pdata->hw_if.disable_vxlan(pdata); in xgbe_vxlan_unset_port()
879 pdata->vxlan_port = 0; in xgbe_vxlan_unset_port()
903 if (pdata->per_channel_irq) { in xgbe_napi_enable()
904 for (i = 0; i < pdata->channel_count; i++) { in xgbe_napi_enable()
905 channel = pdata->channel[i]; in xgbe_napi_enable()
907 netif_napi_add(pdata->netdev, &channel->napi, in xgbe_napi_enable()
910 napi_enable(&channel->napi); in xgbe_napi_enable()
914 netif_napi_add(pdata->netdev, &pdata->napi, in xgbe_napi_enable()
917 napi_enable(&pdata->napi); in xgbe_napi_enable()
926 if (pdata->per_channel_irq) { in xgbe_napi_disable()
927 for (i = 0; i < pdata->channel_count; i++) { in xgbe_napi_disable()
928 channel = pdata->channel[i]; in xgbe_napi_disable()
929 napi_disable(&channel->napi); in xgbe_napi_disable()
932 netif_napi_del(&channel->napi); in xgbe_napi_disable()
935 napi_disable(&pdata->napi); in xgbe_napi_disable()
938 netif_napi_del(&pdata->napi); in xgbe_napi_disable()
945 struct net_device *netdev = pdata->netdev; in xgbe_request_irqs()
949 INIT_WORK(&pdata->dev_bh_work, xgbe_isr_bh_work); in xgbe_request_irqs()
950 INIT_WORK(&pdata->ecc_bh_work, xgbe_ecc_isr_bh_work); in xgbe_request_irqs()
952 ret = devm_request_irq(pdata->dev, pdata->dev_irq, xgbe_isr, 0, in xgbe_request_irqs()
956 pdata->dev_irq); in xgbe_request_irqs()
960 if (pdata->vdata->ecc_support && (pdata->dev_irq != pdata->ecc_irq)) { in xgbe_request_irqs()
961 ret = devm_request_irq(pdata->dev, pdata->ecc_irq, xgbe_ecc_isr, in xgbe_request_irqs()
962 0, pdata->ecc_name, pdata); in xgbe_request_irqs()
965 pdata->ecc_irq); in xgbe_request_irqs()
970 if (!pdata->per_channel_irq) in xgbe_request_irqs()
973 for (i = 0; i < pdata->channel_count; i++) { in xgbe_request_irqs()
974 channel = pdata->channel[i]; in xgbe_request_irqs()
975 snprintf(channel->dma_irq_name, in xgbe_request_irqs()
976 sizeof(channel->dma_irq_name) - 1, in xgbe_request_irqs()
977 "%s-TxRx-%u", netdev_name(netdev), in xgbe_request_irqs()
978 channel->queue_index); in xgbe_request_irqs()
980 ret = devm_request_irq(pdata->dev, channel->dma_irq, in xgbe_request_irqs()
982 channel->dma_irq_name, channel); in xgbe_request_irqs()
985 channel->dma_irq); in xgbe_request_irqs()
989 irq_set_affinity_hint(channel->dma_irq, in xgbe_request_irqs()
990 &channel->affinity_mask); in xgbe_request_irqs()
997 for (i--; i < pdata->channel_count; i--) { in xgbe_request_irqs()
998 channel = pdata->channel[i]; in xgbe_request_irqs()
1000 irq_set_affinity_hint(channel->dma_irq, NULL); in xgbe_request_irqs()
1001 devm_free_irq(pdata->dev, channel->dma_irq, channel); in xgbe_request_irqs()
1004 if (pdata->vdata->ecc_support && (pdata->dev_irq != pdata->ecc_irq)) in xgbe_request_irqs()
1005 devm_free_irq(pdata->dev, pdata->ecc_irq, pdata); in xgbe_request_irqs()
1008 devm_free_irq(pdata->dev, pdata->dev_irq, pdata); in xgbe_request_irqs()
1018 devm_free_irq(pdata->dev, pdata->dev_irq, pdata); in xgbe_free_irqs()
1020 cancel_work_sync(&pdata->dev_bh_work); in xgbe_free_irqs()
1021 cancel_work_sync(&pdata->ecc_bh_work); in xgbe_free_irqs()
1023 if (pdata->vdata->ecc_support && (pdata->dev_irq != pdata->ecc_irq)) in xgbe_free_irqs()
1024 devm_free_irq(pdata->dev, pdata->ecc_irq, pdata); in xgbe_free_irqs()
1026 if (!pdata->per_channel_irq) in xgbe_free_irqs()
1029 for (i = 0; i < pdata->channel_count; i++) { in xgbe_free_irqs()
1030 channel = pdata->channel[i]; in xgbe_free_irqs()
1032 irq_set_affinity_hint(channel->dma_irq, NULL); in xgbe_free_irqs()
1033 devm_free_irq(pdata->dev, channel->dma_irq, channel); in xgbe_free_irqs()
1039 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_init_tx_coalesce()
1041 DBGPR("-->xgbe_init_tx_coalesce\n"); in xgbe_init_tx_coalesce()
1043 pdata->tx_usecs = XGMAC_INIT_DMA_TX_USECS; in xgbe_init_tx_coalesce()
1044 pdata->tx_frames = XGMAC_INIT_DMA_TX_FRAMES; in xgbe_init_tx_coalesce()
1046 hw_if->config_tx_coalesce(pdata); in xgbe_init_tx_coalesce()
1048 DBGPR("<--xgbe_init_tx_coalesce\n"); in xgbe_init_tx_coalesce()
1053 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_init_rx_coalesce()
1055 DBGPR("-->xgbe_init_rx_coalesce\n"); in xgbe_init_rx_coalesce()
1057 pdata->rx_riwt = hw_if->usec_to_riwt(pdata, XGMAC_INIT_DMA_RX_USECS); in xgbe_init_rx_coalesce()
1058 pdata->rx_usecs = XGMAC_INIT_DMA_RX_USECS; in xgbe_init_rx_coalesce()
1059 pdata->rx_frames = XGMAC_INIT_DMA_RX_FRAMES; in xgbe_init_rx_coalesce()
1061 hw_if->config_rx_coalesce(pdata); in xgbe_init_rx_coalesce()
1063 DBGPR("<--xgbe_init_rx_coalesce\n"); in xgbe_init_rx_coalesce()
1068 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_free_tx_data()
1073 DBGPR("-->xgbe_free_tx_data\n"); in xgbe_free_tx_data()
1075 for (i = 0; i < pdata->channel_count; i++) { in xgbe_free_tx_data()
1076 ring = pdata->channel[i]->tx_ring; in xgbe_free_tx_data()
1080 for (j = 0; j < ring->rdesc_count; j++) { in xgbe_free_tx_data()
1082 desc_if->unmap_rdata(pdata, rdata); in xgbe_free_tx_data()
1086 DBGPR("<--xgbe_free_tx_data\n"); in xgbe_free_tx_data()
1091 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_free_rx_data()
1096 DBGPR("-->xgbe_free_rx_data\n"); in xgbe_free_rx_data()
1098 for (i = 0; i < pdata->channel_count; i++) { in xgbe_free_rx_data()
1099 ring = pdata->channel[i]->rx_ring; in xgbe_free_rx_data()
1103 for (j = 0; j < ring->rdesc_count; j++) { in xgbe_free_rx_data()
1105 desc_if->unmap_rdata(pdata, rdata); in xgbe_free_rx_data()
1109 DBGPR("<--xgbe_free_rx_data\n"); in xgbe_free_rx_data()
1114 pdata->phy_speed = SPEED_UNKNOWN; in xgbe_phy_reset()
1116 return pdata->phy_if.phy_reset(pdata); in xgbe_phy_reset()
1122 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_powerdown()
1125 DBGPR("-->xgbe_powerdown\n"); in xgbe_powerdown()
1128 (caller == XGMAC_IOCTL_CONTEXT && pdata->power_down)) { in xgbe_powerdown()
1130 DBGPR("<--xgbe_powerdown\n"); in xgbe_powerdown()
1131 return -EINVAL; in xgbe_powerdown()
1134 spin_lock_irqsave(&pdata->lock, flags); in xgbe_powerdown()
1142 flush_workqueue(pdata->dev_workqueue); in xgbe_powerdown()
1144 hw_if->powerdown_tx(pdata); in xgbe_powerdown()
1145 hw_if->powerdown_rx(pdata); in xgbe_powerdown()
1149 pdata->power_down = 1; in xgbe_powerdown()
1151 spin_unlock_irqrestore(&pdata->lock, flags); in xgbe_powerdown()
1153 DBGPR("<--xgbe_powerdown\n"); in xgbe_powerdown()
1161 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_powerup()
1164 DBGPR("-->xgbe_powerup\n"); in xgbe_powerup()
1167 (caller == XGMAC_IOCTL_CONTEXT && !pdata->power_down)) { in xgbe_powerup()
1169 DBGPR("<--xgbe_powerup\n"); in xgbe_powerup()
1170 return -EINVAL; in xgbe_powerup()
1173 spin_lock_irqsave(&pdata->lock, flags); in xgbe_powerup()
1175 pdata->power_down = 0; in xgbe_powerup()
1179 hw_if->powerup_tx(pdata); in xgbe_powerup()
1180 hw_if->powerup_rx(pdata); in xgbe_powerup()
1189 spin_unlock_irqrestore(&pdata->lock, flags); in xgbe_powerup()
1191 DBGPR("<--xgbe_powerup\n"); in xgbe_powerup()
1198 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_free_memory()
1201 desc_if->free_ring_resources(pdata); in xgbe_free_memory()
1209 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_alloc_memory()
1210 struct net_device *netdev = pdata->netdev; in xgbe_alloc_memory()
1213 if (pdata->new_tx_ring_count) { in xgbe_alloc_memory()
1214 pdata->tx_ring_count = pdata->new_tx_ring_count; in xgbe_alloc_memory()
1215 pdata->tx_q_count = pdata->tx_ring_count; in xgbe_alloc_memory()
1216 pdata->new_tx_ring_count = 0; in xgbe_alloc_memory()
1219 if (pdata->new_rx_ring_count) { in xgbe_alloc_memory()
1220 pdata->rx_ring_count = pdata->new_rx_ring_count; in xgbe_alloc_memory()
1221 pdata->new_rx_ring_count = 0; in xgbe_alloc_memory()
1225 pdata->rx_buf_size = xgbe_calc_rx_buf_size(netdev, netdev->mtu); in xgbe_alloc_memory()
1233 ret = desc_if->alloc_ring_resources(pdata); in xgbe_alloc_memory()
1250 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_start()
1251 struct xgbe_phy_if *phy_if = &pdata->phy_if; in xgbe_start()
1252 struct net_device *netdev = pdata->netdev; in xgbe_start()
1257 ret = netif_set_real_num_tx_queues(netdev, pdata->tx_ring_count); in xgbe_start()
1263 ret = netif_set_real_num_rx_queues(netdev, pdata->rx_ring_count); in xgbe_start()
1271 XGMAC_SET_BITS(pdata->rss_table[i], MAC_RSSDR, DMCH, in xgbe_start()
1272 i % pdata->rx_ring_count); in xgbe_start()
1274 ret = hw_if->init(pdata); in xgbe_start()
1284 ret = phy_if->phy_start(pdata); in xgbe_start()
1288 hw_if->enable_tx(pdata); in xgbe_start()
1289 hw_if->enable_rx(pdata); in xgbe_start()
1301 queue_work(pdata->dev_workqueue, &pdata->service_work); in xgbe_start()
1303 clear_bit(XGBE_STOPPED, &pdata->dev_state); in xgbe_start()
1308 hw_if->disable_rx(pdata); in xgbe_start()
1309 hw_if->disable_tx(pdata); in xgbe_start()
1317 hw_if->exit(pdata); in xgbe_start()
1324 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_stop()
1325 struct xgbe_phy_if *phy_if = &pdata->phy_if; in xgbe_stop()
1327 struct net_device *netdev = pdata->netdev; in xgbe_stop()
1331 DBGPR("-->xgbe_stop\n"); in xgbe_stop()
1333 if (test_bit(XGBE_STOPPED, &pdata->dev_state)) in xgbe_stop()
1337 netif_carrier_off(pdata->netdev); in xgbe_stop()
1340 flush_workqueue(pdata->dev_workqueue); in xgbe_stop()
1344 hw_if->disable_tx(pdata); in xgbe_stop()
1345 hw_if->disable_rx(pdata); in xgbe_stop()
1347 phy_if->phy_stop(pdata); in xgbe_stop()
1353 hw_if->exit(pdata); in xgbe_stop()
1355 for (i = 0; i < pdata->channel_count; i++) { in xgbe_stop()
1356 channel = pdata->channel[i]; in xgbe_stop()
1357 if (!channel->tx_ring) in xgbe_stop()
1360 txq = netdev_get_tx_queue(netdev, channel->queue_index); in xgbe_stop()
1364 set_bit(XGBE_STOPPED, &pdata->dev_state); in xgbe_stop()
1366 DBGPR("<--xgbe_stop\n"); in xgbe_stop()
1384 netdev_alert(pdata->netdev, "device stopped\n"); in xgbe_stopdev()
1390 if (!netif_running(pdata->netdev)) in xgbe_full_restart_dev()
1404 if (!netif_running(pdata->netdev)) in xgbe_restart_dev()
1431 packet->vlan_ctag = skb_vlan_tag_get(skb); in xgbe_prep_vlan()
1438 if (!XGMAC_GET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_prep_tso()
1446 if (XGMAC_GET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, VXLAN)) { in xgbe_prep_tso()
1447 packet->header_len = skb_inner_tcp_all_headers(skb); in xgbe_prep_tso()
1448 packet->tcp_header_len = inner_tcp_hdrlen(skb); in xgbe_prep_tso()
1450 packet->header_len = skb_tcp_all_headers(skb); in xgbe_prep_tso()
1451 packet->tcp_header_len = tcp_hdrlen(skb); in xgbe_prep_tso()
1453 packet->tcp_payload_len = skb->len - packet->header_len; in xgbe_prep_tso()
1454 packet->mss = skb_shinfo(skb)->gso_size; in xgbe_prep_tso()
1456 DBGPR(" packet->header_len=%u\n", packet->header_len); in xgbe_prep_tso()
1457 DBGPR(" packet->tcp_header_len=%u, packet->tcp_payload_len=%u\n", in xgbe_prep_tso()
1458 packet->tcp_header_len, packet->tcp_payload_len); in xgbe_prep_tso()
1459 DBGPR(" packet->mss=%u\n", packet->mss); in xgbe_prep_tso()
1464 packet->tx_packets = skb_shinfo(skb)->gso_segs; in xgbe_prep_tso()
1465 packet->tx_bytes += (packet->tx_packets - 1) * packet->header_len; in xgbe_prep_tso()
1472 if (!skb->encapsulation) in xgbe_is_vxlan()
1475 if (skb->ip_summed != CHECKSUM_PARTIAL) in xgbe_is_vxlan()
1478 switch (skb->protocol) { in xgbe_is_vxlan()
1480 if (ip_hdr(skb)->protocol != IPPROTO_UDP) in xgbe_is_vxlan()
1485 if (ipv6_hdr(skb)->nexthdr != IPPROTO_UDP) in xgbe_is_vxlan()
1493 if (skb->inner_protocol_type != ENCAP_TYPE_ETHER || in xgbe_is_vxlan()
1494 skb->inner_protocol != htons(ETH_P_TEB) || in xgbe_is_vxlan()
1495 (skb_inner_mac_header(skb) - skb_transport_header(skb) != in xgbe_is_vxlan()
1504 if (skb->ip_summed != CHECKSUM_PARTIAL) in xgbe_is_tso()
1524 packet->skb = skb; in xgbe_packet_info()
1527 packet->rdesc_count = 0; in xgbe_packet_info()
1529 packet->tx_packets = 1; in xgbe_packet_info()
1530 packet->tx_bytes = skb->len; in xgbe_packet_info()
1534 if (skb_shinfo(skb)->gso_size != ring->tx.cur_mss) { in xgbe_packet_info()
1536 packet->rdesc_count++; in xgbe_packet_info()
1540 packet->rdesc_count++; in xgbe_packet_info()
1542 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1544 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1546 } else if (skb->ip_summed == CHECKSUM_PARTIAL) in xgbe_packet_info()
1547 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1551 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1556 if (skb_vlan_tag_get(skb) != ring->tx.cur_vlan_ctag) in xgbe_packet_info()
1560 packet->rdesc_count++; in xgbe_packet_info()
1563 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1567 if ((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && in xgbe_packet_info()
1568 (pdata->tstamp_config.tx_type == HWTSTAMP_TX_ON)) in xgbe_packet_info()
1569 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1573 packet->rdesc_count++; in xgbe_packet_info()
1574 len -= min_t(unsigned int, len, XGBE_TX_MAX_BUF_SIZE); in xgbe_packet_info()
1577 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { in xgbe_packet_info()
1578 frag = &skb_shinfo(skb)->frags[i]; in xgbe_packet_info()
1580 packet->rdesc_count++; in xgbe_packet_info()
1581 len -= min_t(unsigned int, len, XGBE_TX_MAX_BUF_SIZE); in xgbe_packet_info()
1592 snprintf(pdata->an_name, sizeof(pdata->an_name) - 1, "%s-pcs", in xgbe_open()
1595 snprintf(pdata->ecc_name, sizeof(pdata->ecc_name) - 1, "%s-ecc", in xgbe_open()
1598 snprintf(pdata->i2c_name, sizeof(pdata->i2c_name) - 1, "%s-i2c", in xgbe_open()
1602 pdata->dev_workqueue = in xgbe_open()
1604 if (!pdata->dev_workqueue) { in xgbe_open()
1606 return -ENOMEM; in xgbe_open()
1609 pdata->an_workqueue = in xgbe_open()
1610 create_singlethread_workqueue(pdata->an_name); in xgbe_open()
1611 if (!pdata->an_workqueue) { in xgbe_open()
1613 ret = -ENOMEM; in xgbe_open()
1618 ret = clk_prepare_enable(pdata->sysclk); in xgbe_open()
1624 ret = clk_prepare_enable(pdata->ptpclk); in xgbe_open()
1630 INIT_WORK(&pdata->service_work, xgbe_service); in xgbe_open()
1631 INIT_WORK(&pdata->restart_work, xgbe_restart); in xgbe_open()
1632 INIT_WORK(&pdata->stopdev_work, xgbe_stopdev); in xgbe_open()
1633 INIT_WORK(&pdata->tx_tstamp_work, xgbe_tx_tstamp); in xgbe_open()
1646 clear_bit(XGBE_DOWN, &pdata->dev_state); in xgbe_open()
1654 clk_disable_unprepare(pdata->ptpclk); in xgbe_open()
1657 clk_disable_unprepare(pdata->sysclk); in xgbe_open()
1660 destroy_workqueue(pdata->an_workqueue); in xgbe_open()
1663 destroy_workqueue(pdata->dev_workqueue); in xgbe_open()
1678 clk_disable_unprepare(pdata->ptpclk); in xgbe_close()
1679 clk_disable_unprepare(pdata->sysclk); in xgbe_close()
1681 destroy_workqueue(pdata->an_workqueue); in xgbe_close()
1683 destroy_workqueue(pdata->dev_workqueue); in xgbe_close()
1685 set_bit(XGBE_DOWN, &pdata->dev_state); in xgbe_close()
1693 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_xmit()
1694 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_xmit()
1701 DBGPR("-->xgbe_xmit: skb->len = %d\n", skb->len); in xgbe_xmit()
1703 channel = pdata->channel[skb->queue_mapping]; in xgbe_xmit()
1704 txq = netdev_get_tx_queue(netdev, channel->queue_index); in xgbe_xmit()
1705 ring = channel->tx_ring; in xgbe_xmit()
1706 packet = &ring->packet_data; in xgbe_xmit()
1710 if (skb->len == 0) { in xgbe_xmit()
1722 ret = xgbe_maybe_stop_tx_queue(channel, ring, packet->rdesc_count); in xgbe_xmit()
1735 if (!desc_if->map_tx_skb(channel, skb)) { in xgbe_xmit()
1743 netdev_tx_sent_queue(txq, packet->tx_bytes); in xgbe_xmit()
1746 hw_if->dev_xmit(channel); in xgbe_xmit()
1763 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_set_rx_mode()
1765 DBGPR("-->xgbe_set_rx_mode\n"); in xgbe_set_rx_mode()
1767 hw_if->config_rx_mode(pdata); in xgbe_set_rx_mode()
1769 DBGPR("<--xgbe_set_rx_mode\n"); in xgbe_set_rx_mode()
1775 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_set_mac_address()
1778 DBGPR("-->xgbe_set_mac_address\n"); in xgbe_set_mac_address()
1780 if (!is_valid_ether_addr(saddr->sa_data)) in xgbe_set_mac_address()
1781 return -EADDRNOTAVAIL; in xgbe_set_mac_address()
1783 eth_hw_addr_set(netdev, saddr->sa_data); in xgbe_set_mac_address()
1785 hw_if->set_mac_address(pdata, netdev->dev_addr); in xgbe_set_mac_address()
1787 DBGPR("<--xgbe_set_mac_address\n"); in xgbe_set_mac_address()
1797 DBGPR("-->xgbe_change_mtu\n"); in xgbe_change_mtu()
1803 pdata->rx_buf_size = ret; in xgbe_change_mtu()
1804 WRITE_ONCE(netdev->mtu, mtu); in xgbe_change_mtu()
1808 DBGPR("<--xgbe_change_mtu\n"); in xgbe_change_mtu()
1818 schedule_work(&pdata->restart_work); in xgbe_tx_timeout()
1825 struct xgbe_mmc_stats *pstats = &pdata->mmc_stats; in xgbe_get_stats64()
1827 DBGPR("-->%s\n", __func__); in xgbe_get_stats64()
1829 pdata->hw_if.read_mmc_stats(pdata); in xgbe_get_stats64()
1831 s->rx_packets = pstats->rxframecount_gb; in xgbe_get_stats64()
1832 s->rx_bytes = pstats->rxoctetcount_gb; in xgbe_get_stats64()
1833 s->rx_errors = pstats->rxframecount_gb - in xgbe_get_stats64()
1834 pstats->rxbroadcastframes_g - in xgbe_get_stats64()
1835 pstats->rxmulticastframes_g - in xgbe_get_stats64()
1836 pstats->rxunicastframes_g; in xgbe_get_stats64()
1837 s->multicast = pstats->rxmulticastframes_g; in xgbe_get_stats64()
1838 s->rx_length_errors = pstats->rxlengtherror; in xgbe_get_stats64()
1839 s->rx_crc_errors = pstats->rxcrcerror; in xgbe_get_stats64()
1840 s->rx_fifo_errors = pstats->rxfifooverflow; in xgbe_get_stats64()
1842 s->tx_packets = pstats->txframecount_gb; in xgbe_get_stats64()
1843 s->tx_bytes = pstats->txoctetcount_gb; in xgbe_get_stats64()
1844 s->tx_errors = pstats->txframecount_gb - pstats->txframecount_g; in xgbe_get_stats64()
1845 s->tx_dropped = netdev->stats.tx_dropped; in xgbe_get_stats64()
1847 DBGPR("<--%s\n", __func__); in xgbe_get_stats64()
1854 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_vlan_rx_add_vid()
1856 DBGPR("-->%s\n", __func__); in xgbe_vlan_rx_add_vid()
1858 set_bit(vid, pdata->active_vlans); in xgbe_vlan_rx_add_vid()
1859 hw_if->update_vlan_hash_table(pdata); in xgbe_vlan_rx_add_vid()
1861 DBGPR("<--%s\n", __func__); in xgbe_vlan_rx_add_vid()
1870 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_vlan_rx_kill_vid()
1872 DBGPR("-->%s\n", __func__); in xgbe_vlan_rx_kill_vid()
1874 clear_bit(vid, pdata->active_vlans); in xgbe_vlan_rx_kill_vid()
1875 hw_if->update_vlan_hash_table(pdata); in xgbe_vlan_rx_kill_vid()
1877 DBGPR("<--%s\n", __func__); in xgbe_vlan_rx_kill_vid()
1889 DBGPR("-->xgbe_poll_controller\n"); in xgbe_poll_controller()
1891 if (pdata->per_channel_irq) { in xgbe_poll_controller()
1892 for (i = 0; i < pdata->channel_count; i++) { in xgbe_poll_controller()
1893 channel = pdata->channel[i]; in xgbe_poll_controller()
1894 xgbe_dma_isr(channel->dma_irq, channel); in xgbe_poll_controller()
1897 disable_irq(pdata->dev_irq); in xgbe_poll_controller()
1898 xgbe_isr(pdata->dev_irq, pdata); in xgbe_poll_controller()
1899 enable_irq(pdata->dev_irq); in xgbe_poll_controller()
1902 DBGPR("<--xgbe_poll_controller\n"); in xgbe_poll_controller()
1914 return -EOPNOTSUPP; in xgbe_setup_tc()
1916 mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS; in xgbe_setup_tc()
1917 tc = mqprio->num_tc; in xgbe_setup_tc()
1919 if (tc > pdata->hw_feat.tc_cnt) in xgbe_setup_tc()
1920 return -EINVAL; in xgbe_setup_tc()
1922 pdata->num_tcs = tc; in xgbe_setup_tc()
1923 pdata->hw_if.config_tc(pdata); in xgbe_setup_tc()
1936 if (!pdata->hw_feat.vxn) in xgbe_fix_features()
1975 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_set_features()
1979 rxhash = pdata->netdev_features & NETIF_F_RXHASH; in xgbe_set_features()
1980 rxcsum = pdata->netdev_features & NETIF_F_RXCSUM; in xgbe_set_features()
1981 rxvlan = pdata->netdev_features & NETIF_F_HW_VLAN_CTAG_RX; in xgbe_set_features()
1982 rxvlan_filter = pdata->netdev_features & NETIF_F_HW_VLAN_CTAG_FILTER; in xgbe_set_features()
1985 ret = hw_if->enable_rss(pdata); in xgbe_set_features()
1987 ret = hw_if->disable_rss(pdata); in xgbe_set_features()
1992 hw_if->enable_sph(pdata); in xgbe_set_features()
1993 hw_if->enable_vxlan(pdata); in xgbe_set_features()
1994 hw_if->enable_rx_csum(pdata); in xgbe_set_features()
1995 schedule_work(&pdata->restart_work); in xgbe_set_features()
1997 hw_if->disable_sph(pdata); in xgbe_set_features()
1998 hw_if->disable_vxlan(pdata); in xgbe_set_features()
1999 hw_if->disable_rx_csum(pdata); in xgbe_set_features()
2000 schedule_work(&pdata->restart_work); in xgbe_set_features()
2004 hw_if->enable_rx_vlan_stripping(pdata); in xgbe_set_features()
2006 hw_if->disable_rx_vlan_stripping(pdata); in xgbe_set_features()
2009 hw_if->enable_rx_vlan_filtering(pdata); in xgbe_set_features()
2011 hw_if->disable_rx_vlan_filtering(pdata); in xgbe_set_features()
2013 pdata->netdev_features = features; in xgbe_set_features()
2015 DBGPR("<--xgbe_set_features\n"); in xgbe_set_features()
2060 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_rx_refresh()
2061 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_rx_refresh()
2062 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_rx_refresh()
2063 struct xgbe_ring *ring = channel->rx_ring; in xgbe_rx_refresh()
2066 while (ring->dirty != ring->cur) { in xgbe_rx_refresh()
2067 rdata = XGBE_GET_DESC_DATA(ring, ring->dirty); in xgbe_rx_refresh()
2070 desc_if->unmap_rdata(pdata, rdata); in xgbe_rx_refresh()
2072 if (desc_if->map_rx_buffer(pdata, ring, rdata)) in xgbe_rx_refresh()
2075 hw_if->rx_desc_reset(pdata, rdata, ring->dirty); in xgbe_rx_refresh()
2077 ring->dirty++; in xgbe_rx_refresh()
2085 rdata = XGBE_GET_DESC_DATA(ring, ring->dirty - 1); in xgbe_rx_refresh()
2087 lower_32_bits(rdata->rdesc_dma)); in xgbe_rx_refresh()
2098 skb = napi_alloc_skb(napi, rdata->rx.hdr.dma_len); in xgbe_create_skb()
2105 dma_sync_single_range_for_cpu(pdata->dev, rdata->rx.hdr.dma_base, in xgbe_create_skb()
2106 rdata->rx.hdr.dma_off, in xgbe_create_skb()
2107 rdata->rx.hdr.dma_len, DMA_FROM_DEVICE); in xgbe_create_skb()
2109 packet = page_address(rdata->rx.hdr.pa.pages) + in xgbe_create_skb()
2110 rdata->rx.hdr.pa.pages_offset; in xgbe_create_skb()
2121 if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, FIRST)) in xgbe_rx_buf1_len()
2125 if (rdata->rx.hdr_len) in xgbe_rx_buf1_len()
2126 return rdata->rx.hdr_len; in xgbe_rx_buf1_len()
2131 if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, LAST)) in xgbe_rx_buf1_len()
2132 return rdata->rx.hdr.dma_len; in xgbe_rx_buf1_len()
2137 return min_t(unsigned int, rdata->rx.hdr.dma_len, rdata->rx.len); in xgbe_rx_buf1_len()
2145 if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, LAST)) in xgbe_rx_buf2_len()
2146 return rdata->rx.buf.dma_len; in xgbe_rx_buf2_len()
2151 return rdata->rx.len - len; in xgbe_rx_buf2_len()
2156 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_tx_poll()
2157 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_tx_poll()
2158 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_tx_poll()
2159 struct xgbe_ring *ring = channel->tx_ring; in xgbe_tx_poll()
2162 struct net_device *netdev = pdata->netdev; in xgbe_tx_poll()
2168 DBGPR("-->xgbe_tx_poll\n"); in xgbe_tx_poll()
2174 cur = ring->cur; in xgbe_tx_poll()
2176 /* Be sure we get ring->cur before accessing descriptor data */ in xgbe_tx_poll()
2179 txq = netdev_get_tx_queue(netdev, channel->queue_index); in xgbe_tx_poll()
2182 (ring->dirty != cur)) { in xgbe_tx_poll()
2183 rdata = XGBE_GET_DESC_DATA(ring, ring->dirty); in xgbe_tx_poll()
2184 rdesc = rdata->rdesc; in xgbe_tx_poll()
2186 if (!hw_if->tx_complete(rdesc)) in xgbe_tx_poll()
2194 xgbe_dump_tx_desc(pdata, ring, ring->dirty, 1, 0); in xgbe_tx_poll()
2196 if (hw_if->is_last_desc(rdesc)) { in xgbe_tx_poll()
2197 tx_packets += rdata->tx.packets; in xgbe_tx_poll()
2198 tx_bytes += rdata->tx.bytes; in xgbe_tx_poll()
2201 /* Free the SKB and reset the descriptor for re-use */ in xgbe_tx_poll()
2202 desc_if->unmap_rdata(pdata, rdata); in xgbe_tx_poll()
2203 hw_if->tx_desc_reset(rdata); in xgbe_tx_poll()
2206 ring->dirty++; in xgbe_tx_poll()
2214 if ((ring->tx.queue_stopped == 1) && in xgbe_tx_poll()
2216 ring->tx.queue_stopped = 0; in xgbe_tx_poll()
2220 DBGPR("<--xgbe_tx_poll: processed=%d\n", processed); in xgbe_tx_poll()
2227 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_rx_poll()
2228 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_rx_poll()
2229 struct xgbe_ring *ring = channel->rx_ring; in xgbe_rx_poll()
2232 struct net_device *netdev = pdata->netdev; in xgbe_rx_poll()
2241 DBGPR("-->xgbe_rx_poll: budget=%d\n", budget); in xgbe_rx_poll()
2250 napi = (pdata->per_channel_irq) ? &channel->napi : &pdata->napi; in xgbe_rx_poll()
2252 rdata = XGBE_GET_DESC_DATA(ring, ring->cur); in xgbe_rx_poll()
2253 packet = &ring->packet_data; in xgbe_rx_poll()
2255 DBGPR(" cur = %d\n", ring->cur); in xgbe_rx_poll()
2258 if (!received && rdata->state_saved) { in xgbe_rx_poll()
2259 skb = rdata->state.skb; in xgbe_rx_poll()
2260 error = rdata->state.error; in xgbe_rx_poll()
2261 len = rdata->state.len; in xgbe_rx_poll()
2270 rdata = XGBE_GET_DESC_DATA(ring, ring->cur); in xgbe_rx_poll()
2275 if (hw_if->dev_read(channel)) in xgbe_rx_poll()
2279 ring->cur++; in xgbe_rx_poll()
2281 last = XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, in xgbe_rx_poll()
2283 context_next = XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2286 context = XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2294 if (error || packet->errors) { in xgbe_rx_poll()
2295 if (packet->errors) in xgbe_rx_poll()
2309 if (buf2_len > rdata->rx.buf.dma_len) { in xgbe_rx_poll()
2327 dma_sync_single_range_for_cpu(pdata->dev, in xgbe_rx_poll()
2328 rdata->rx.buf.dma_base, in xgbe_rx_poll()
2329 rdata->rx.buf.dma_off, in xgbe_rx_poll()
2330 rdata->rx.buf.dma_len, in xgbe_rx_poll()
2333 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, in xgbe_rx_poll()
2334 rdata->rx.buf.pa.pages, in xgbe_rx_poll()
2335 rdata->rx.buf.pa.pages_offset, in xgbe_rx_poll()
2337 rdata->rx.buf.dma_len); in xgbe_rx_poll()
2338 rdata->rx.buf.pa.pages = NULL; in xgbe_rx_poll()
2352 max_len = netdev->mtu + ETH_HLEN; in xgbe_rx_poll()
2353 if (!(netdev->features & NETIF_F_HW_VLAN_CTAG_RX) && in xgbe_rx_poll()
2354 (skb->protocol == htons(ETH_P_8021Q))) in xgbe_rx_poll()
2357 if (skb->len > max_len) { in xgbe_rx_poll()
2368 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2370 skb->ip_summed = CHECKSUM_UNNECESSARY; in xgbe_rx_poll()
2372 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2374 skb->encapsulation = 1; in xgbe_rx_poll()
2376 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2378 skb->csum_level = 1; in xgbe_rx_poll()
2381 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2384 packet->vlan_ctag); in xgbe_rx_poll()
2386 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2389 hwtstamps->hwtstamp = ns_to_ktime(packet->rx_tstamp); in xgbe_rx_poll()
2392 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2394 skb_set_hash(skb, packet->rss_hash, in xgbe_rx_poll()
2395 packet->rss_hash_type); in xgbe_rx_poll()
2397 skb->dev = netdev; in xgbe_rx_poll()
2398 skb->protocol = eth_type_trans(skb, netdev); in xgbe_rx_poll()
2399 skb_record_rx_queue(skb, channel->queue_index); in xgbe_rx_poll()
2409 rdata = XGBE_GET_DESC_DATA(ring, ring->cur); in xgbe_rx_poll()
2410 rdata->state_saved = 1; in xgbe_rx_poll()
2411 rdata->state.skb = skb; in xgbe_rx_poll()
2412 rdata->state.len = len; in xgbe_rx_poll()
2413 rdata->state.error = error; in xgbe_rx_poll()
2416 DBGPR("<--xgbe_rx_poll: packet_count = %d\n", packet_count); in xgbe_rx_poll()
2425 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_one_poll()
2428 DBGPR("-->xgbe_one_poll: budget=%d\n", budget); in xgbe_one_poll()
2439 if (pdata->channel_irq_mode) in xgbe_one_poll()
2442 enable_irq(channel->dma_irq); in xgbe_one_poll()
2445 DBGPR("<--xgbe_one_poll: received = %d\n", processed); in xgbe_one_poll()
2459 DBGPR("-->xgbe_all_poll: budget=%d\n", budget); in xgbe_all_poll()
2462 ring_budget = budget / pdata->rx_ring_count; in xgbe_all_poll()
2466 for (i = 0; i < pdata->channel_count; i++) { in xgbe_all_poll()
2467 channel = pdata->channel[i]; in xgbe_all_poll()
2473 if (ring_budget > (budget - processed)) in xgbe_all_poll()
2474 ring_budget = budget - processed; in xgbe_all_poll()
2485 DBGPR("<--xgbe_all_poll: received = %d\n", processed); in xgbe_all_poll()
2496 while (count--) { in xgbe_dump_tx_desc()
2498 rdesc = rdata->rdesc; in xgbe_dump_tx_desc()
2499 netdev_dbg(pdata->netdev, in xgbe_dump_tx_desc()
2502 le32_to_cpu(rdesc->desc0), in xgbe_dump_tx_desc()
2503 le32_to_cpu(rdesc->desc1), in xgbe_dump_tx_desc()
2504 le32_to_cpu(rdesc->desc2), in xgbe_dump_tx_desc()
2505 le32_to_cpu(rdesc->desc3)); in xgbe_dump_tx_desc()
2517 rdesc = rdata->rdesc; in xgbe_dump_rx_desc()
2518 netdev_dbg(pdata->netdev, in xgbe_dump_rx_desc()
2520 idx, le32_to_cpu(rdesc->desc0), le32_to_cpu(rdesc->desc1), in xgbe_dump_rx_desc()
2521 le32_to_cpu(rdesc->desc2), le32_to_cpu(rdesc->desc3)); in xgbe_dump_rx_desc()
2526 struct ethhdr *eth = (struct ethhdr *)skb->data; in xgbe_print_pkt()
2533 (tx_rx ? "TX" : "RX"), skb->len); in xgbe_print_pkt()
2535 netdev_dbg(netdev, "Dst MAC addr: %pM\n", eth->h_dest); in xgbe_print_pkt()
2536 netdev_dbg(netdev, "Src MAC addr: %pM\n", eth->h_source); in xgbe_print_pkt()
2537 netdev_dbg(netdev, "Protocol: %#06x\n", ntohs(eth->h_proto)); in xgbe_print_pkt()
2539 for (i = 0; i < skb->len; i += 32) { in xgbe_print_pkt()
2540 unsigned int len = min(skb->len - i, 32U); in xgbe_print_pkt()
2542 hex_dump_to_buffer(&skb->data[i], len, 32, 1, in xgbe_print_pkt()