Lines Matching +full:i2c +full:- +full:tunnel
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()
370 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_isr_bh_work()
378 * this register to be non-zero in xgbe_isr_bh_work()
384 netif_dbg(pdata, intr, pdata->netdev, "DMA_ISR=%#010x\n", dma_isr); in xgbe_isr_bh_work()
386 for (i = 0; i < pdata->channel_count; i++) { in xgbe_isr_bh_work()
390 channel = pdata->channel[i]; in xgbe_isr_bh_work()
393 netif_dbg(pdata, intr, pdata->netdev, "DMA_CH%u_ISR=%#010x\n", in xgbe_isr_bh_work()
400 if (!pdata->per_channel_irq && in xgbe_isr_bh_work()
403 if (napi_schedule_prep(&pdata->napi)) { in xgbe_isr_bh_work()
408 __napi_schedule(&pdata->napi); in xgbe_isr_bh_work()
420 pdata->ext_stats.rx_buffer_unavailable++; in xgbe_isr_bh_work()
424 schedule_work(&pdata->restart_work); in xgbe_isr_bh_work()
433 netif_dbg(pdata, intr, pdata->netdev, "MAC_ISR=%#010x\n", in xgbe_isr_bh_work()
437 hw_if->tx_mmc_int(pdata); in xgbe_isr_bh_work()
440 hw_if->rx_mmc_int(pdata); in xgbe_isr_bh_work()
445 netif_dbg(pdata, intr, pdata->netdev, in xgbe_isr_bh_work()
450 pdata->tx_tstamp = in xgbe_isr_bh_work()
452 queue_work(pdata->dev_workqueue, in xgbe_isr_bh_work()
453 &pdata->tx_tstamp_work); in xgbe_isr_bh_work()
460 netif_dbg(pdata, intr, pdata->netdev, in xgbe_isr_bh_work()
465 complete(&pdata->mdio_complete); in xgbe_isr_bh_work()
471 if (pdata->dev_irq == pdata->an_irq) in xgbe_isr_bh_work()
472 pdata->phy_if.an_isr(pdata); in xgbe_isr_bh_work()
475 if (pdata->vdata->ecc_support && (pdata->dev_irq == pdata->ecc_irq)) in xgbe_isr_bh_work()
476 xgbe_ecc_isr_bh_work(&pdata->ecc_bh_work); in xgbe_isr_bh_work()
478 /* If there is not a separate I2C irq, handle it here */ in xgbe_isr_bh_work()
479 if (pdata->vdata->i2c_support && (pdata->dev_irq == pdata->i2c_irq)) in xgbe_isr_bh_work()
480 pdata->i2c_if.i2c_isr(pdata); in xgbe_isr_bh_work()
483 if (pdata->vdata->irq_reissue_support) { in xgbe_isr_bh_work()
487 if (!pdata->per_channel_irq) in xgbe_isr_bh_work()
498 if (pdata->isr_as_bh_work) in xgbe_isr()
499 queue_work(system_bh_wq, &pdata->dev_bh_work); in xgbe_isr()
501 xgbe_isr_bh_work(&pdata->dev_bh_work); in xgbe_isr()
509 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_dma_isr()
515 if (napi_schedule_prep(&channel->napi)) { in xgbe_dma_isr()
517 if (pdata->channel_irq_mode) in xgbe_dma_isr()
520 disable_irq_nosync(channel->dma_irq); in xgbe_dma_isr()
523 __napi_schedule_irqoff(&channel->napi); in xgbe_dma_isr()
539 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_tx_timer()
542 DBGPR("-->xgbe_tx_timer\n"); in xgbe_tx_timer()
544 napi = (pdata->per_channel_irq) ? &channel->napi : &pdata->napi; in xgbe_tx_timer()
548 if (pdata->per_channel_irq) in xgbe_tx_timer()
549 if (pdata->channel_irq_mode) in xgbe_tx_timer()
552 disable_irq_nosync(channel->dma_irq); in xgbe_tx_timer()
560 channel->tx_timer_active = 0; in xgbe_tx_timer()
562 DBGPR("<--xgbe_tx_timer\n"); in xgbe_tx_timer()
571 pdata->phy_if.phy_status(pdata); in xgbe_service()
581 queue_work(pdata->dev_workqueue, &pdata->service_work); in xgbe_service_timer()
583 mod_timer(&pdata->service_timer, jiffies + HZ); in xgbe_service_timer()
585 if (!pdata->tx_usecs) in xgbe_service_timer()
588 for (i = 0; i < pdata->channel_count; i++) { in xgbe_service_timer()
589 channel = pdata->channel[i]; in xgbe_service_timer()
590 if (!channel->tx_ring || channel->tx_timer_active) in xgbe_service_timer()
592 channel->tx_timer_active = 1; in xgbe_service_timer()
593 mod_timer(&channel->tx_timer, in xgbe_service_timer()
594 jiffies + usecs_to_jiffies(pdata->tx_usecs)); in xgbe_service_timer()
603 timer_setup(&pdata->service_timer, xgbe_service_timer, 0); in xgbe_init_timers()
605 for (i = 0; i < pdata->channel_count; i++) { in xgbe_init_timers()
606 channel = pdata->channel[i]; in xgbe_init_timers()
607 if (!channel->tx_ring) in xgbe_init_timers()
610 timer_setup(&channel->tx_timer, xgbe_tx_timer, 0); in xgbe_init_timers()
616 mod_timer(&pdata->service_timer, jiffies + HZ); in xgbe_start_timers()
624 timer_delete_sync(&pdata->service_timer); in xgbe_stop_timers()
626 for (i = 0; i < pdata->channel_count; i++) { in xgbe_stop_timers()
627 channel = pdata->channel[i]; in xgbe_stop_timers()
628 if (!channel->tx_ring) in xgbe_stop_timers()
632 timer_delete_sync(&channel->tx_timer); in xgbe_stop_timers()
633 channel->tx_timer_active = 0; in xgbe_stop_timers()
640 struct xgbe_hw_features *hw_feat = &pdata->hw_feat; in xgbe_get_all_hw_features()
648 hw_feat->version = XGMAC_IOREAD(pdata, MAC_VR); in xgbe_get_all_hw_features()
651 hw_feat->gmii = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, GMIISEL); in xgbe_get_all_hw_features()
652 hw_feat->vlhash = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, VLHASH); in xgbe_get_all_hw_features()
653 hw_feat->sma = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, SMASEL); in xgbe_get_all_hw_features()
654 hw_feat->rwk = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, RWKSEL); in xgbe_get_all_hw_features()
655 hw_feat->mgk = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, MGKSEL); in xgbe_get_all_hw_features()
656 hw_feat->mmc = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, MMCSEL); in xgbe_get_all_hw_features()
657 hw_feat->aoe = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, ARPOFFSEL); in xgbe_get_all_hw_features()
658 hw_feat->ts = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TSSEL); in xgbe_get_all_hw_features()
659 hw_feat->eee = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, EEESEL); in xgbe_get_all_hw_features()
660 hw_feat->tx_coe = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TXCOESEL); in xgbe_get_all_hw_features()
661 hw_feat->rx_coe = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, RXCOESEL); in xgbe_get_all_hw_features()
662 hw_feat->addn_mac = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, in xgbe_get_all_hw_features()
664 hw_feat->ts_src = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TSSTSSEL); in xgbe_get_all_hw_features()
665 hw_feat->sa_vlan_ins = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, SAVLANINS); in xgbe_get_all_hw_features()
666 hw_feat->vxn = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, VXN); in xgbe_get_all_hw_features()
669 hw_feat->rx_fifo_size = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, in xgbe_get_all_hw_features()
671 hw_feat->tx_fifo_size = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, in xgbe_get_all_hw_features()
673 hw_feat->adv_ts_hi = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, ADVTHWORD); in xgbe_get_all_hw_features()
674 hw_feat->dma_width = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, ADDR64); in xgbe_get_all_hw_features()
675 hw_feat->dcb = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, DCBEN); in xgbe_get_all_hw_features()
676 hw_feat->sph = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, SPHEN); in xgbe_get_all_hw_features()
677 hw_feat->tso = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, TSOEN); in xgbe_get_all_hw_features()
678 hw_feat->dma_debug = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, DBGMEMA); in xgbe_get_all_hw_features()
679 hw_feat->rss = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, RSSEN); in xgbe_get_all_hw_features()
680 hw_feat->tc_cnt = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, NUMTC); in xgbe_get_all_hw_features()
681 hw_feat->hash_table_size = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, in xgbe_get_all_hw_features()
683 hw_feat->l3l4_filter_num = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, in xgbe_get_all_hw_features()
687 hw_feat->rx_q_cnt = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, RXQCNT); in xgbe_get_all_hw_features()
688 hw_feat->tx_q_cnt = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, TXQCNT); in xgbe_get_all_hw_features()
689 hw_feat->rx_ch_cnt = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, RXCHCNT); in xgbe_get_all_hw_features()
690 hw_feat->tx_ch_cnt = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, TXCHCNT); in xgbe_get_all_hw_features()
691 hw_feat->pps_out_num = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, PPSOUTNUM); in xgbe_get_all_hw_features()
692 hw_feat->aux_snap_num = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, AUXSNAPNUM); in xgbe_get_all_hw_features()
695 switch (hw_feat->hash_table_size) { in xgbe_get_all_hw_features()
699 hw_feat->hash_table_size = 64; in xgbe_get_all_hw_features()
702 hw_feat->hash_table_size = 128; in xgbe_get_all_hw_features()
705 hw_feat->hash_table_size = 256; in xgbe_get_all_hw_features()
710 switch (hw_feat->dma_width) { in xgbe_get_all_hw_features()
712 hw_feat->dma_width = 32; in xgbe_get_all_hw_features()
715 hw_feat->dma_width = 40; in xgbe_get_all_hw_features()
718 hw_feat->dma_width = 48; in xgbe_get_all_hw_features()
721 hw_feat->dma_width = 32; in xgbe_get_all_hw_features()
727 hw_feat->rx_q_cnt++; in xgbe_get_all_hw_features()
728 hw_feat->tx_q_cnt++; in xgbe_get_all_hw_features()
729 hw_feat->rx_ch_cnt++; in xgbe_get_all_hw_features()
730 hw_feat->tx_ch_cnt++; in xgbe_get_all_hw_features()
731 hw_feat->tc_cnt++; in xgbe_get_all_hw_features()
734 hw_feat->rx_fifo_size = 1 << (hw_feat->rx_fifo_size + 7); in xgbe_get_all_hw_features()
735 hw_feat->tx_fifo_size = 1 << (hw_feat->tx_fifo_size + 7); in xgbe_get_all_hw_features()
738 dev_dbg(pdata->dev, "Hardware features:\n"); in xgbe_get_all_hw_features()
741 dev_dbg(pdata->dev, " 1GbE support : %s\n", in xgbe_get_all_hw_features()
742 hw_feat->gmii ? "yes" : "no"); in xgbe_get_all_hw_features()
743 dev_dbg(pdata->dev, " VLAN hash filter : %s\n", in xgbe_get_all_hw_features()
744 hw_feat->vlhash ? "yes" : "no"); in xgbe_get_all_hw_features()
745 dev_dbg(pdata->dev, " MDIO interface : %s\n", in xgbe_get_all_hw_features()
746 hw_feat->sma ? "yes" : "no"); in xgbe_get_all_hw_features()
747 dev_dbg(pdata->dev, " Wake-up packet support : %s\n", in xgbe_get_all_hw_features()
748 hw_feat->rwk ? "yes" : "no"); in xgbe_get_all_hw_features()
749 dev_dbg(pdata->dev, " Magic packet support : %s\n", in xgbe_get_all_hw_features()
750 hw_feat->mgk ? "yes" : "no"); in xgbe_get_all_hw_features()
751 dev_dbg(pdata->dev, " Management counters : %s\n", in xgbe_get_all_hw_features()
752 hw_feat->mmc ? "yes" : "no"); in xgbe_get_all_hw_features()
753 dev_dbg(pdata->dev, " ARP offload : %s\n", in xgbe_get_all_hw_features()
754 hw_feat->aoe ? "yes" : "no"); in xgbe_get_all_hw_features()
755 dev_dbg(pdata->dev, " IEEE 1588-2008 Timestamp : %s\n", in xgbe_get_all_hw_features()
756 hw_feat->ts ? "yes" : "no"); in xgbe_get_all_hw_features()
757 dev_dbg(pdata->dev, " Energy Efficient Ethernet : %s\n", in xgbe_get_all_hw_features()
758 hw_feat->eee ? "yes" : "no"); in xgbe_get_all_hw_features()
759 dev_dbg(pdata->dev, " TX checksum offload : %s\n", in xgbe_get_all_hw_features()
760 hw_feat->tx_coe ? "yes" : "no"); in xgbe_get_all_hw_features()
761 dev_dbg(pdata->dev, " RX checksum offload : %s\n", in xgbe_get_all_hw_features()
762 hw_feat->rx_coe ? "yes" : "no"); in xgbe_get_all_hw_features()
763 dev_dbg(pdata->dev, " Additional MAC addresses : %u\n", in xgbe_get_all_hw_features()
764 hw_feat->addn_mac); in xgbe_get_all_hw_features()
765 dev_dbg(pdata->dev, " Timestamp source : %s\n", in xgbe_get_all_hw_features()
766 (hw_feat->ts_src == 1) ? "internal" : in xgbe_get_all_hw_features()
767 (hw_feat->ts_src == 2) ? "external" : in xgbe_get_all_hw_features()
768 (hw_feat->ts_src == 3) ? "internal/external" : "n/a"); in xgbe_get_all_hw_features()
769 dev_dbg(pdata->dev, " SA/VLAN insertion : %s\n", in xgbe_get_all_hw_features()
770 hw_feat->sa_vlan_ins ? "yes" : "no"); in xgbe_get_all_hw_features()
771 dev_dbg(pdata->dev, " VXLAN/NVGRE support : %s\n", in xgbe_get_all_hw_features()
772 hw_feat->vxn ? "yes" : "no"); in xgbe_get_all_hw_features()
775 dev_dbg(pdata->dev, " RX fifo size : %u\n", in xgbe_get_all_hw_features()
776 hw_feat->rx_fifo_size); in xgbe_get_all_hw_features()
777 dev_dbg(pdata->dev, " TX fifo size : %u\n", in xgbe_get_all_hw_features()
778 hw_feat->tx_fifo_size); in xgbe_get_all_hw_features()
779 dev_dbg(pdata->dev, " IEEE 1588 high word : %s\n", in xgbe_get_all_hw_features()
780 hw_feat->adv_ts_hi ? "yes" : "no"); in xgbe_get_all_hw_features()
781 dev_dbg(pdata->dev, " DMA width : %u\n", in xgbe_get_all_hw_features()
782 hw_feat->dma_width); in xgbe_get_all_hw_features()
783 dev_dbg(pdata->dev, " Data Center Bridging : %s\n", in xgbe_get_all_hw_features()
784 hw_feat->dcb ? "yes" : "no"); in xgbe_get_all_hw_features()
785 dev_dbg(pdata->dev, " Split header : %s\n", in xgbe_get_all_hw_features()
786 hw_feat->sph ? "yes" : "no"); in xgbe_get_all_hw_features()
787 dev_dbg(pdata->dev, " TCP Segmentation Offload : %s\n", in xgbe_get_all_hw_features()
788 hw_feat->tso ? "yes" : "no"); in xgbe_get_all_hw_features()
789 dev_dbg(pdata->dev, " Debug memory interface : %s\n", in xgbe_get_all_hw_features()
790 hw_feat->dma_debug ? "yes" : "no"); in xgbe_get_all_hw_features()
791 dev_dbg(pdata->dev, " Receive Side Scaling : %s\n", in xgbe_get_all_hw_features()
792 hw_feat->rss ? "yes" : "no"); in xgbe_get_all_hw_features()
793 dev_dbg(pdata->dev, " Traffic Class count : %u\n", in xgbe_get_all_hw_features()
794 hw_feat->tc_cnt); in xgbe_get_all_hw_features()
795 dev_dbg(pdata->dev, " Hash table size : %u\n", in xgbe_get_all_hw_features()
796 hw_feat->hash_table_size); in xgbe_get_all_hw_features()
797 dev_dbg(pdata->dev, " L3/L4 Filters : %u\n", in xgbe_get_all_hw_features()
798 hw_feat->l3l4_filter_num); in xgbe_get_all_hw_features()
801 dev_dbg(pdata->dev, " RX queue count : %u\n", in xgbe_get_all_hw_features()
802 hw_feat->rx_q_cnt); in xgbe_get_all_hw_features()
803 dev_dbg(pdata->dev, " TX queue count : %u\n", in xgbe_get_all_hw_features()
804 hw_feat->tx_q_cnt); in xgbe_get_all_hw_features()
805 dev_dbg(pdata->dev, " RX DMA channel count : %u\n", in xgbe_get_all_hw_features()
806 hw_feat->rx_ch_cnt); in xgbe_get_all_hw_features()
807 dev_dbg(pdata->dev, " TX DMA channel count : %u\n", in xgbe_get_all_hw_features()
808 hw_feat->rx_ch_cnt); in xgbe_get_all_hw_features()
809 dev_dbg(pdata->dev, " PPS outputs : %u\n", in xgbe_get_all_hw_features()
810 hw_feat->pps_out_num); in xgbe_get_all_hw_features()
811 dev_dbg(pdata->dev, " Auxiliary snapshot inputs : %u\n", in xgbe_get_all_hw_features()
812 hw_feat->aux_snap_num); in xgbe_get_all_hw_features()
821 pdata->vxlan_port = be16_to_cpu(ti->port); in xgbe_vxlan_set_port()
822 pdata->hw_if.enable_vxlan(pdata); in xgbe_vxlan_set_port()
832 pdata->hw_if.disable_vxlan(pdata); in xgbe_vxlan_unset_port()
833 pdata->vxlan_port = 0; in xgbe_vxlan_unset_port()
857 if (pdata->per_channel_irq) { in xgbe_napi_enable()
858 for (i = 0; i < pdata->channel_count; i++) { in xgbe_napi_enable()
859 channel = pdata->channel[i]; in xgbe_napi_enable()
861 netif_napi_add(pdata->netdev, &channel->napi, in xgbe_napi_enable()
864 napi_enable(&channel->napi); in xgbe_napi_enable()
868 netif_napi_add(pdata->netdev, &pdata->napi, in xgbe_napi_enable()
871 napi_enable(&pdata->napi); in xgbe_napi_enable()
880 if (pdata->per_channel_irq) { in xgbe_napi_disable()
881 for (i = 0; i < pdata->channel_count; i++) { in xgbe_napi_disable()
882 channel = pdata->channel[i]; in xgbe_napi_disable()
883 napi_disable(&channel->napi); in xgbe_napi_disable()
886 netif_napi_del(&channel->napi); in xgbe_napi_disable()
889 napi_disable(&pdata->napi); in xgbe_napi_disable()
892 netif_napi_del(&pdata->napi); in xgbe_napi_disable()
899 struct net_device *netdev = pdata->netdev; in xgbe_request_irqs()
903 INIT_WORK(&pdata->dev_bh_work, xgbe_isr_bh_work); in xgbe_request_irqs()
904 INIT_WORK(&pdata->ecc_bh_work, xgbe_ecc_isr_bh_work); in xgbe_request_irqs()
906 ret = devm_request_irq(pdata->dev, pdata->dev_irq, xgbe_isr, 0, in xgbe_request_irqs()
910 pdata->dev_irq); in xgbe_request_irqs()
914 if (pdata->vdata->ecc_support && (pdata->dev_irq != pdata->ecc_irq)) { in xgbe_request_irqs()
915 ret = devm_request_irq(pdata->dev, pdata->ecc_irq, xgbe_ecc_isr, in xgbe_request_irqs()
916 0, pdata->ecc_name, pdata); in xgbe_request_irqs()
919 pdata->ecc_irq); in xgbe_request_irqs()
924 if (!pdata->per_channel_irq) in xgbe_request_irqs()
927 for (i = 0; i < pdata->channel_count; i++) { in xgbe_request_irqs()
928 channel = pdata->channel[i]; in xgbe_request_irqs()
929 snprintf(channel->dma_irq_name, in xgbe_request_irqs()
930 sizeof(channel->dma_irq_name) - 1, in xgbe_request_irqs()
931 "%s-TxRx-%u", netdev_name(netdev), in xgbe_request_irqs()
932 channel->queue_index); in xgbe_request_irqs()
934 ret = devm_request_irq(pdata->dev, channel->dma_irq, in xgbe_request_irqs()
936 channel->dma_irq_name, channel); in xgbe_request_irqs()
939 channel->dma_irq); in xgbe_request_irqs()
943 irq_set_affinity_hint(channel->dma_irq, in xgbe_request_irqs()
944 &channel->affinity_mask); in xgbe_request_irqs()
951 for (i--; i < pdata->channel_count; i--) { in xgbe_request_irqs()
952 channel = pdata->channel[i]; in xgbe_request_irqs()
954 irq_set_affinity_hint(channel->dma_irq, NULL); in xgbe_request_irqs()
955 devm_free_irq(pdata->dev, channel->dma_irq, channel); in xgbe_request_irqs()
958 if (pdata->vdata->ecc_support && (pdata->dev_irq != pdata->ecc_irq)) in xgbe_request_irqs()
959 devm_free_irq(pdata->dev, pdata->ecc_irq, pdata); in xgbe_request_irqs()
962 devm_free_irq(pdata->dev, pdata->dev_irq, pdata); in xgbe_request_irqs()
972 devm_free_irq(pdata->dev, pdata->dev_irq, pdata); in xgbe_free_irqs()
974 cancel_work_sync(&pdata->dev_bh_work); in xgbe_free_irqs()
975 cancel_work_sync(&pdata->ecc_bh_work); in xgbe_free_irqs()
977 if (pdata->vdata->ecc_support && (pdata->dev_irq != pdata->ecc_irq)) in xgbe_free_irqs()
978 devm_free_irq(pdata->dev, pdata->ecc_irq, pdata); in xgbe_free_irqs()
980 if (!pdata->per_channel_irq) in xgbe_free_irqs()
983 for (i = 0; i < pdata->channel_count; i++) { in xgbe_free_irqs()
984 channel = pdata->channel[i]; in xgbe_free_irqs()
986 irq_set_affinity_hint(channel->dma_irq, NULL); in xgbe_free_irqs()
987 devm_free_irq(pdata->dev, channel->dma_irq, channel); in xgbe_free_irqs()
993 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_init_tx_coalesce()
995 DBGPR("-->xgbe_init_tx_coalesce\n"); in xgbe_init_tx_coalesce()
997 pdata->tx_usecs = XGMAC_INIT_DMA_TX_USECS; in xgbe_init_tx_coalesce()
998 pdata->tx_frames = XGMAC_INIT_DMA_TX_FRAMES; in xgbe_init_tx_coalesce()
1000 hw_if->config_tx_coalesce(pdata); in xgbe_init_tx_coalesce()
1002 DBGPR("<--xgbe_init_tx_coalesce\n"); in xgbe_init_tx_coalesce()
1007 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_init_rx_coalesce()
1009 DBGPR("-->xgbe_init_rx_coalesce\n"); in xgbe_init_rx_coalesce()
1011 pdata->rx_riwt = hw_if->usec_to_riwt(pdata, XGMAC_INIT_DMA_RX_USECS); in xgbe_init_rx_coalesce()
1012 pdata->rx_usecs = XGMAC_INIT_DMA_RX_USECS; in xgbe_init_rx_coalesce()
1013 pdata->rx_frames = XGMAC_INIT_DMA_RX_FRAMES; in xgbe_init_rx_coalesce()
1015 hw_if->config_rx_coalesce(pdata); in xgbe_init_rx_coalesce()
1017 DBGPR("<--xgbe_init_rx_coalesce\n"); in xgbe_init_rx_coalesce()
1022 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_free_tx_data()
1027 DBGPR("-->xgbe_free_tx_data\n"); in xgbe_free_tx_data()
1029 for (i = 0; i < pdata->channel_count; i++) { in xgbe_free_tx_data()
1030 ring = pdata->channel[i]->tx_ring; in xgbe_free_tx_data()
1034 for (j = 0; j < ring->rdesc_count; j++) { in xgbe_free_tx_data()
1036 desc_if->unmap_rdata(pdata, rdata); in xgbe_free_tx_data()
1040 DBGPR("<--xgbe_free_tx_data\n"); in xgbe_free_tx_data()
1045 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_free_rx_data()
1050 DBGPR("-->xgbe_free_rx_data\n"); in xgbe_free_rx_data()
1052 for (i = 0; i < pdata->channel_count; i++) { in xgbe_free_rx_data()
1053 ring = pdata->channel[i]->rx_ring; in xgbe_free_rx_data()
1057 for (j = 0; j < ring->rdesc_count; j++) { in xgbe_free_rx_data()
1059 desc_if->unmap_rdata(pdata, rdata); in xgbe_free_rx_data()
1063 DBGPR("<--xgbe_free_rx_data\n"); in xgbe_free_rx_data()
1068 pdata->phy_link = -1; in xgbe_phy_reset()
1069 pdata->phy_speed = SPEED_UNKNOWN; in xgbe_phy_reset()
1071 return pdata->phy_if.phy_reset(pdata); in xgbe_phy_reset()
1077 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_powerdown()
1080 DBGPR("-->xgbe_powerdown\n"); in xgbe_powerdown()
1083 (caller == XGMAC_IOCTL_CONTEXT && pdata->power_down)) { in xgbe_powerdown()
1085 DBGPR("<--xgbe_powerdown\n"); in xgbe_powerdown()
1086 return -EINVAL; in xgbe_powerdown()
1089 spin_lock_irqsave(&pdata->lock, flags); in xgbe_powerdown()
1097 flush_workqueue(pdata->dev_workqueue); in xgbe_powerdown()
1099 hw_if->powerdown_tx(pdata); in xgbe_powerdown()
1100 hw_if->powerdown_rx(pdata); in xgbe_powerdown()
1104 pdata->power_down = 1; in xgbe_powerdown()
1106 spin_unlock_irqrestore(&pdata->lock, flags); in xgbe_powerdown()
1108 DBGPR("<--xgbe_powerdown\n"); in xgbe_powerdown()
1116 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_powerup()
1119 DBGPR("-->xgbe_powerup\n"); in xgbe_powerup()
1122 (caller == XGMAC_IOCTL_CONTEXT && !pdata->power_down)) { in xgbe_powerup()
1124 DBGPR("<--xgbe_powerup\n"); in xgbe_powerup()
1125 return -EINVAL; in xgbe_powerup()
1128 spin_lock_irqsave(&pdata->lock, flags); in xgbe_powerup()
1130 pdata->power_down = 0; in xgbe_powerup()
1134 hw_if->powerup_tx(pdata); in xgbe_powerup()
1135 hw_if->powerup_rx(pdata); in xgbe_powerup()
1144 spin_unlock_irqrestore(&pdata->lock, flags); in xgbe_powerup()
1146 DBGPR("<--xgbe_powerup\n"); in xgbe_powerup()
1153 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_free_memory()
1156 desc_if->free_ring_resources(pdata); in xgbe_free_memory()
1164 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_alloc_memory()
1165 struct net_device *netdev = pdata->netdev; in xgbe_alloc_memory()
1168 if (pdata->new_tx_ring_count) { in xgbe_alloc_memory()
1169 pdata->tx_ring_count = pdata->new_tx_ring_count; in xgbe_alloc_memory()
1170 pdata->tx_q_count = pdata->tx_ring_count; in xgbe_alloc_memory()
1171 pdata->new_tx_ring_count = 0; in xgbe_alloc_memory()
1174 if (pdata->new_rx_ring_count) { in xgbe_alloc_memory()
1175 pdata->rx_ring_count = pdata->new_rx_ring_count; in xgbe_alloc_memory()
1176 pdata->new_rx_ring_count = 0; in xgbe_alloc_memory()
1180 pdata->rx_buf_size = xgbe_calc_rx_buf_size(netdev, netdev->mtu); in xgbe_alloc_memory()
1188 ret = desc_if->alloc_ring_resources(pdata); in xgbe_alloc_memory()
1205 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_start()
1206 struct xgbe_phy_if *phy_if = &pdata->phy_if; in xgbe_start()
1207 struct net_device *netdev = pdata->netdev; in xgbe_start()
1212 ret = netif_set_real_num_tx_queues(netdev, pdata->tx_ring_count); in xgbe_start()
1218 ret = netif_set_real_num_rx_queues(netdev, pdata->rx_ring_count); in xgbe_start()
1226 XGMAC_SET_BITS(pdata->rss_table[i], MAC_RSSDR, DMCH, in xgbe_start()
1227 i % pdata->rx_ring_count); in xgbe_start()
1229 ret = hw_if->init(pdata); in xgbe_start()
1239 ret = phy_if->phy_start(pdata); in xgbe_start()
1243 hw_if->enable_tx(pdata); in xgbe_start()
1244 hw_if->enable_rx(pdata); in xgbe_start()
1251 queue_work(pdata->dev_workqueue, &pdata->service_work); in xgbe_start()
1253 clear_bit(XGBE_STOPPED, &pdata->dev_state); in xgbe_start()
1263 hw_if->exit(pdata); in xgbe_start()
1270 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_stop()
1271 struct xgbe_phy_if *phy_if = &pdata->phy_if; in xgbe_stop()
1273 struct net_device *netdev = pdata->netdev; in xgbe_stop()
1277 DBGPR("-->xgbe_stop\n"); in xgbe_stop()
1279 if (test_bit(XGBE_STOPPED, &pdata->dev_state)) in xgbe_stop()
1283 netif_carrier_off(pdata->netdev); in xgbe_stop()
1286 flush_workqueue(pdata->dev_workqueue); in xgbe_stop()
1290 hw_if->disable_tx(pdata); in xgbe_stop()
1291 hw_if->disable_rx(pdata); in xgbe_stop()
1293 phy_if->phy_stop(pdata); in xgbe_stop()
1299 hw_if->exit(pdata); in xgbe_stop()
1301 for (i = 0; i < pdata->channel_count; i++) { in xgbe_stop()
1302 channel = pdata->channel[i]; in xgbe_stop()
1303 if (!channel->tx_ring) in xgbe_stop()
1306 txq = netdev_get_tx_queue(netdev, channel->queue_index); in xgbe_stop()
1310 set_bit(XGBE_STOPPED, &pdata->dev_state); in xgbe_stop()
1312 DBGPR("<--xgbe_stop\n"); in xgbe_stop()
1330 netdev_alert(pdata->netdev, "device stopped\n"); in xgbe_stopdev()
1336 if (!netif_running(pdata->netdev)) in xgbe_full_restart_dev()
1350 if (!netif_running(pdata->netdev)) in xgbe_restart_dev()
1377 packet->vlan_ctag = skb_vlan_tag_get(skb); in xgbe_prep_vlan()
1384 if (!XGMAC_GET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_prep_tso()
1392 if (XGMAC_GET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, VXLAN)) { in xgbe_prep_tso()
1393 packet->header_len = skb_inner_tcp_all_headers(skb); in xgbe_prep_tso()
1394 packet->tcp_header_len = inner_tcp_hdrlen(skb); in xgbe_prep_tso()
1396 packet->header_len = skb_tcp_all_headers(skb); in xgbe_prep_tso()
1397 packet->tcp_header_len = tcp_hdrlen(skb); in xgbe_prep_tso()
1399 packet->tcp_payload_len = skb->len - packet->header_len; in xgbe_prep_tso()
1400 packet->mss = skb_shinfo(skb)->gso_size; in xgbe_prep_tso()
1402 DBGPR(" packet->header_len=%u\n", packet->header_len); in xgbe_prep_tso()
1403 DBGPR(" packet->tcp_header_len=%u, packet->tcp_payload_len=%u\n", in xgbe_prep_tso()
1404 packet->tcp_header_len, packet->tcp_payload_len); in xgbe_prep_tso()
1405 DBGPR(" packet->mss=%u\n", packet->mss); in xgbe_prep_tso()
1410 packet->tx_packets = skb_shinfo(skb)->gso_segs; in xgbe_prep_tso()
1411 packet->tx_bytes += (packet->tx_packets - 1) * packet->header_len; in xgbe_prep_tso()
1418 if (!skb->encapsulation) in xgbe_is_vxlan()
1421 if (skb->ip_summed != CHECKSUM_PARTIAL) in xgbe_is_vxlan()
1424 switch (skb->protocol) { in xgbe_is_vxlan()
1426 if (ip_hdr(skb)->protocol != IPPROTO_UDP) in xgbe_is_vxlan()
1431 if (ipv6_hdr(skb)->nexthdr != IPPROTO_UDP) in xgbe_is_vxlan()
1439 if (skb->inner_protocol_type != ENCAP_TYPE_ETHER || in xgbe_is_vxlan()
1440 skb->inner_protocol != htons(ETH_P_TEB) || in xgbe_is_vxlan()
1441 (skb_inner_mac_header(skb) - skb_transport_header(skb) != in xgbe_is_vxlan()
1450 if (skb->ip_summed != CHECKSUM_PARTIAL) in xgbe_is_tso()
1470 packet->skb = skb; in xgbe_packet_info()
1473 packet->rdesc_count = 0; in xgbe_packet_info()
1475 packet->tx_packets = 1; in xgbe_packet_info()
1476 packet->tx_bytes = skb->len; in xgbe_packet_info()
1480 if (skb_shinfo(skb)->gso_size != ring->tx.cur_mss) { in xgbe_packet_info()
1482 packet->rdesc_count++; in xgbe_packet_info()
1486 packet->rdesc_count++; in xgbe_packet_info()
1488 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1490 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1492 } else if (skb->ip_summed == CHECKSUM_PARTIAL) in xgbe_packet_info()
1493 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1497 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1502 if (skb_vlan_tag_get(skb) != ring->tx.cur_vlan_ctag) in xgbe_packet_info()
1506 packet->rdesc_count++; in xgbe_packet_info()
1509 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1513 if ((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && in xgbe_packet_info()
1514 (pdata->tstamp_config.tx_type == HWTSTAMP_TX_ON)) in xgbe_packet_info()
1515 XGMAC_SET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, in xgbe_packet_info()
1519 packet->rdesc_count++; in xgbe_packet_info()
1520 len -= min_t(unsigned int, len, XGBE_TX_MAX_BUF_SIZE); in xgbe_packet_info()
1523 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { in xgbe_packet_info()
1524 frag = &skb_shinfo(skb)->frags[i]; in xgbe_packet_info()
1526 packet->rdesc_count++; in xgbe_packet_info()
1527 len -= min_t(unsigned int, len, XGBE_TX_MAX_BUF_SIZE); in xgbe_packet_info()
1538 snprintf(pdata->an_name, sizeof(pdata->an_name) - 1, "%s-pcs", in xgbe_open()
1541 snprintf(pdata->ecc_name, sizeof(pdata->ecc_name) - 1, "%s-ecc", in xgbe_open()
1544 snprintf(pdata->i2c_name, sizeof(pdata->i2c_name) - 1, "%s-i2c", in xgbe_open()
1548 pdata->dev_workqueue = in xgbe_open()
1550 if (!pdata->dev_workqueue) { in xgbe_open()
1552 return -ENOMEM; in xgbe_open()
1555 pdata->an_workqueue = in xgbe_open()
1556 create_singlethread_workqueue(pdata->an_name); in xgbe_open()
1557 if (!pdata->an_workqueue) { in xgbe_open()
1559 ret = -ENOMEM; in xgbe_open()
1569 ret = clk_prepare_enable(pdata->sysclk); in xgbe_open()
1575 ret = clk_prepare_enable(pdata->ptpclk); in xgbe_open()
1581 INIT_WORK(&pdata->service_work, xgbe_service); in xgbe_open()
1582 INIT_WORK(&pdata->restart_work, xgbe_restart); in xgbe_open()
1583 INIT_WORK(&pdata->stopdev_work, xgbe_stopdev); in xgbe_open()
1584 INIT_WORK(&pdata->tx_tstamp_work, xgbe_tx_tstamp); in xgbe_open()
1597 clear_bit(XGBE_DOWN, &pdata->dev_state); in xgbe_open()
1605 clk_disable_unprepare(pdata->ptpclk); in xgbe_open()
1608 clk_disable_unprepare(pdata->sysclk); in xgbe_open()
1611 destroy_workqueue(pdata->an_workqueue); in xgbe_open()
1614 destroy_workqueue(pdata->dev_workqueue); in xgbe_open()
1629 clk_disable_unprepare(pdata->ptpclk); in xgbe_close()
1630 clk_disable_unprepare(pdata->sysclk); in xgbe_close()
1632 destroy_workqueue(pdata->an_workqueue); in xgbe_close()
1634 destroy_workqueue(pdata->dev_workqueue); in xgbe_close()
1636 set_bit(XGBE_DOWN, &pdata->dev_state); in xgbe_close()
1644 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_xmit()
1645 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_xmit()
1652 DBGPR("-->xgbe_xmit: skb->len = %d\n", skb->len); in xgbe_xmit()
1654 channel = pdata->channel[skb->queue_mapping]; in xgbe_xmit()
1655 txq = netdev_get_tx_queue(netdev, channel->queue_index); in xgbe_xmit()
1656 ring = channel->tx_ring; in xgbe_xmit()
1657 packet = &ring->packet_data; in xgbe_xmit()
1661 if (skb->len == 0) { in xgbe_xmit()
1673 ret = xgbe_maybe_stop_tx_queue(channel, ring, packet->rdesc_count); in xgbe_xmit()
1686 if (!desc_if->map_tx_skb(channel, skb)) { in xgbe_xmit()
1694 netdev_tx_sent_queue(txq, packet->tx_bytes); in xgbe_xmit()
1697 hw_if->dev_xmit(channel); in xgbe_xmit()
1714 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_set_rx_mode()
1716 DBGPR("-->xgbe_set_rx_mode\n"); in xgbe_set_rx_mode()
1718 hw_if->config_rx_mode(pdata); in xgbe_set_rx_mode()
1720 DBGPR("<--xgbe_set_rx_mode\n"); in xgbe_set_rx_mode()
1726 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_set_mac_address()
1729 DBGPR("-->xgbe_set_mac_address\n"); in xgbe_set_mac_address()
1731 if (!is_valid_ether_addr(saddr->sa_data)) in xgbe_set_mac_address()
1732 return -EADDRNOTAVAIL; in xgbe_set_mac_address()
1734 eth_hw_addr_set(netdev, saddr->sa_data); in xgbe_set_mac_address()
1736 hw_if->set_mac_address(pdata, netdev->dev_addr); in xgbe_set_mac_address()
1738 DBGPR("<--xgbe_set_mac_address\n"); in xgbe_set_mac_address()
1758 ret = -EOPNOTSUPP; in xgbe_ioctl()
1769 DBGPR("-->xgbe_change_mtu\n"); in xgbe_change_mtu()
1775 pdata->rx_buf_size = ret; in xgbe_change_mtu()
1776 WRITE_ONCE(netdev->mtu, mtu); in xgbe_change_mtu()
1780 DBGPR("<--xgbe_change_mtu\n"); in xgbe_change_mtu()
1790 schedule_work(&pdata->restart_work); in xgbe_tx_timeout()
1797 struct xgbe_mmc_stats *pstats = &pdata->mmc_stats; in xgbe_get_stats64()
1799 DBGPR("-->%s\n", __func__); in xgbe_get_stats64()
1801 pdata->hw_if.read_mmc_stats(pdata); in xgbe_get_stats64()
1803 s->rx_packets = pstats->rxframecount_gb; in xgbe_get_stats64()
1804 s->rx_bytes = pstats->rxoctetcount_gb; in xgbe_get_stats64()
1805 s->rx_errors = pstats->rxframecount_gb - in xgbe_get_stats64()
1806 pstats->rxbroadcastframes_g - in xgbe_get_stats64()
1807 pstats->rxmulticastframes_g - in xgbe_get_stats64()
1808 pstats->rxunicastframes_g; in xgbe_get_stats64()
1809 s->multicast = pstats->rxmulticastframes_g; in xgbe_get_stats64()
1810 s->rx_length_errors = pstats->rxlengtherror; in xgbe_get_stats64()
1811 s->rx_crc_errors = pstats->rxcrcerror; in xgbe_get_stats64()
1812 s->rx_fifo_errors = pstats->rxfifooverflow; in xgbe_get_stats64()
1814 s->tx_packets = pstats->txframecount_gb; in xgbe_get_stats64()
1815 s->tx_bytes = pstats->txoctetcount_gb; in xgbe_get_stats64()
1816 s->tx_errors = pstats->txframecount_gb - pstats->txframecount_g; in xgbe_get_stats64()
1817 s->tx_dropped = netdev->stats.tx_dropped; in xgbe_get_stats64()
1819 DBGPR("<--%s\n", __func__); in xgbe_get_stats64()
1826 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_vlan_rx_add_vid()
1828 DBGPR("-->%s\n", __func__); in xgbe_vlan_rx_add_vid()
1830 set_bit(vid, pdata->active_vlans); in xgbe_vlan_rx_add_vid()
1831 hw_if->update_vlan_hash_table(pdata); in xgbe_vlan_rx_add_vid()
1833 DBGPR("<--%s\n", __func__); in xgbe_vlan_rx_add_vid()
1842 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_vlan_rx_kill_vid()
1844 DBGPR("-->%s\n", __func__); in xgbe_vlan_rx_kill_vid()
1846 clear_bit(vid, pdata->active_vlans); in xgbe_vlan_rx_kill_vid()
1847 hw_if->update_vlan_hash_table(pdata); in xgbe_vlan_rx_kill_vid()
1849 DBGPR("<--%s\n", __func__); in xgbe_vlan_rx_kill_vid()
1861 DBGPR("-->xgbe_poll_controller\n"); in xgbe_poll_controller()
1863 if (pdata->per_channel_irq) { in xgbe_poll_controller()
1864 for (i = 0; i < pdata->channel_count; i++) { in xgbe_poll_controller()
1865 channel = pdata->channel[i]; in xgbe_poll_controller()
1866 xgbe_dma_isr(channel->dma_irq, channel); in xgbe_poll_controller()
1869 disable_irq(pdata->dev_irq); in xgbe_poll_controller()
1870 xgbe_isr(pdata->dev_irq, pdata); in xgbe_poll_controller()
1871 enable_irq(pdata->dev_irq); in xgbe_poll_controller()
1874 DBGPR("<--xgbe_poll_controller\n"); in xgbe_poll_controller()
1886 return -EOPNOTSUPP; in xgbe_setup_tc()
1888 mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS; in xgbe_setup_tc()
1889 tc = mqprio->num_tc; in xgbe_setup_tc()
1891 if (tc > pdata->hw_feat.tc_cnt) in xgbe_setup_tc()
1892 return -EINVAL; in xgbe_setup_tc()
1894 pdata->num_tcs = tc; in xgbe_setup_tc()
1895 pdata->hw_if.config_tc(pdata); in xgbe_setup_tc()
1908 if (!pdata->hw_feat.vxn) in xgbe_fix_features()
1915 "forcing tx udp tunnel support\n"); in xgbe_fix_features()
1922 "forcing both tx and rx udp tunnel support\n"); in xgbe_fix_features()
1929 "forcing tx udp tunnel checksumming on\n"); in xgbe_fix_features()
1935 "forcing tx udp tunnel checksumming off\n"); in xgbe_fix_features()
1947 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_set_features()
1951 rxhash = pdata->netdev_features & NETIF_F_RXHASH; in xgbe_set_features()
1952 rxcsum = pdata->netdev_features & NETIF_F_RXCSUM; in xgbe_set_features()
1953 rxvlan = pdata->netdev_features & NETIF_F_HW_VLAN_CTAG_RX; in xgbe_set_features()
1954 rxvlan_filter = pdata->netdev_features & NETIF_F_HW_VLAN_CTAG_FILTER; in xgbe_set_features()
1957 ret = hw_if->enable_rss(pdata); in xgbe_set_features()
1959 ret = hw_if->disable_rss(pdata); in xgbe_set_features()
1964 hw_if->enable_sph(pdata); in xgbe_set_features()
1965 hw_if->enable_vxlan(pdata); in xgbe_set_features()
1966 hw_if->enable_rx_csum(pdata); in xgbe_set_features()
1967 schedule_work(&pdata->restart_work); in xgbe_set_features()
1969 hw_if->disable_sph(pdata); in xgbe_set_features()
1970 hw_if->disable_vxlan(pdata); in xgbe_set_features()
1971 hw_if->disable_rx_csum(pdata); in xgbe_set_features()
1972 schedule_work(&pdata->restart_work); in xgbe_set_features()
1976 hw_if->enable_rx_vlan_stripping(pdata); in xgbe_set_features()
1978 hw_if->disable_rx_vlan_stripping(pdata); in xgbe_set_features()
1981 hw_if->enable_rx_vlan_filtering(pdata); in xgbe_set_features()
1983 hw_if->disable_rx_vlan_filtering(pdata); in xgbe_set_features()
1985 pdata->netdev_features = features; in xgbe_set_features()
1987 DBGPR("<--xgbe_set_features\n"); in xgbe_set_features()
2031 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_rx_refresh()
2032 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_rx_refresh()
2033 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_rx_refresh()
2034 struct xgbe_ring *ring = channel->rx_ring; in xgbe_rx_refresh()
2037 while (ring->dirty != ring->cur) { in xgbe_rx_refresh()
2038 rdata = XGBE_GET_DESC_DATA(ring, ring->dirty); in xgbe_rx_refresh()
2041 desc_if->unmap_rdata(pdata, rdata); in xgbe_rx_refresh()
2043 if (desc_if->map_rx_buffer(pdata, ring, rdata)) in xgbe_rx_refresh()
2046 hw_if->rx_desc_reset(pdata, rdata, ring->dirty); in xgbe_rx_refresh()
2048 ring->dirty++; in xgbe_rx_refresh()
2056 rdata = XGBE_GET_DESC_DATA(ring, ring->dirty - 1); in xgbe_rx_refresh()
2058 lower_32_bits(rdata->rdesc_dma)); in xgbe_rx_refresh()
2069 skb = napi_alloc_skb(napi, rdata->rx.hdr.dma_len); in xgbe_create_skb()
2076 dma_sync_single_range_for_cpu(pdata->dev, rdata->rx.hdr.dma_base, in xgbe_create_skb()
2077 rdata->rx.hdr.dma_off, in xgbe_create_skb()
2078 rdata->rx.hdr.dma_len, DMA_FROM_DEVICE); in xgbe_create_skb()
2080 packet = page_address(rdata->rx.hdr.pa.pages) + in xgbe_create_skb()
2081 rdata->rx.hdr.pa.pages_offset; in xgbe_create_skb()
2092 if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, FIRST)) in xgbe_rx_buf1_len()
2096 if (rdata->rx.hdr_len) in xgbe_rx_buf1_len()
2097 return rdata->rx.hdr_len; in xgbe_rx_buf1_len()
2102 if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, LAST)) in xgbe_rx_buf1_len()
2103 return rdata->rx.hdr.dma_len; in xgbe_rx_buf1_len()
2108 return min_t(unsigned int, rdata->rx.hdr.dma_len, rdata->rx.len); in xgbe_rx_buf1_len()
2116 if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, LAST)) in xgbe_rx_buf2_len()
2117 return rdata->rx.buf.dma_len; in xgbe_rx_buf2_len()
2122 return rdata->rx.len - len; in xgbe_rx_buf2_len()
2127 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_tx_poll()
2128 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_tx_poll()
2129 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_tx_poll()
2130 struct xgbe_ring *ring = channel->tx_ring; in xgbe_tx_poll()
2133 struct net_device *netdev = pdata->netdev; in xgbe_tx_poll()
2139 DBGPR("-->xgbe_tx_poll\n"); in xgbe_tx_poll()
2145 cur = ring->cur; in xgbe_tx_poll()
2147 /* Be sure we get ring->cur before accessing descriptor data */ in xgbe_tx_poll()
2150 txq = netdev_get_tx_queue(netdev, channel->queue_index); in xgbe_tx_poll()
2153 (ring->dirty != cur)) { in xgbe_tx_poll()
2154 rdata = XGBE_GET_DESC_DATA(ring, ring->dirty); in xgbe_tx_poll()
2155 rdesc = rdata->rdesc; in xgbe_tx_poll()
2157 if (!hw_if->tx_complete(rdesc)) in xgbe_tx_poll()
2165 xgbe_dump_tx_desc(pdata, ring, ring->dirty, 1, 0); in xgbe_tx_poll()
2167 if (hw_if->is_last_desc(rdesc)) { in xgbe_tx_poll()
2168 tx_packets += rdata->tx.packets; in xgbe_tx_poll()
2169 tx_bytes += rdata->tx.bytes; in xgbe_tx_poll()
2172 /* Free the SKB and reset the descriptor for re-use */ in xgbe_tx_poll()
2173 desc_if->unmap_rdata(pdata, rdata); in xgbe_tx_poll()
2174 hw_if->tx_desc_reset(rdata); in xgbe_tx_poll()
2177 ring->dirty++; in xgbe_tx_poll()
2185 if ((ring->tx.queue_stopped == 1) && in xgbe_tx_poll()
2187 ring->tx.queue_stopped = 0; in xgbe_tx_poll()
2191 DBGPR("<--xgbe_tx_poll: processed=%d\n", processed); in xgbe_tx_poll()
2198 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_rx_poll()
2199 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_rx_poll()
2200 struct xgbe_ring *ring = channel->rx_ring; in xgbe_rx_poll()
2203 struct net_device *netdev = pdata->netdev; in xgbe_rx_poll()
2212 DBGPR("-->xgbe_rx_poll: budget=%d\n", budget); in xgbe_rx_poll()
2221 napi = (pdata->per_channel_irq) ? &channel->napi : &pdata->napi; in xgbe_rx_poll()
2223 rdata = XGBE_GET_DESC_DATA(ring, ring->cur); in xgbe_rx_poll()
2224 packet = &ring->packet_data; in xgbe_rx_poll()
2226 DBGPR(" cur = %d\n", ring->cur); in xgbe_rx_poll()
2229 if (!received && rdata->state_saved) { in xgbe_rx_poll()
2230 skb = rdata->state.skb; in xgbe_rx_poll()
2231 error = rdata->state.error; in xgbe_rx_poll()
2232 len = rdata->state.len; in xgbe_rx_poll()
2241 rdata = XGBE_GET_DESC_DATA(ring, ring->cur); in xgbe_rx_poll()
2246 if (hw_if->dev_read(channel)) in xgbe_rx_poll()
2250 ring->cur++; in xgbe_rx_poll()
2252 last = XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, in xgbe_rx_poll()
2254 context_next = XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2257 context = XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2265 if (error || packet->errors) { in xgbe_rx_poll()
2266 if (packet->errors) in xgbe_rx_poll()
2280 if (buf2_len > rdata->rx.buf.dma_len) { in xgbe_rx_poll()
2298 dma_sync_single_range_for_cpu(pdata->dev, in xgbe_rx_poll()
2299 rdata->rx.buf.dma_base, in xgbe_rx_poll()
2300 rdata->rx.buf.dma_off, in xgbe_rx_poll()
2301 rdata->rx.buf.dma_len, in xgbe_rx_poll()
2304 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, in xgbe_rx_poll()
2305 rdata->rx.buf.pa.pages, in xgbe_rx_poll()
2306 rdata->rx.buf.pa.pages_offset, in xgbe_rx_poll()
2308 rdata->rx.buf.dma_len); in xgbe_rx_poll()
2309 rdata->rx.buf.pa.pages = NULL; in xgbe_rx_poll()
2323 max_len = netdev->mtu + ETH_HLEN; in xgbe_rx_poll()
2324 if (!(netdev->features & NETIF_F_HW_VLAN_CTAG_RX) && in xgbe_rx_poll()
2325 (skb->protocol == htons(ETH_P_8021Q))) in xgbe_rx_poll()
2328 if (skb->len > max_len) { in xgbe_rx_poll()
2339 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2341 skb->ip_summed = CHECKSUM_UNNECESSARY; in xgbe_rx_poll()
2343 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2345 skb->encapsulation = 1; in xgbe_rx_poll()
2347 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2349 skb->csum_level = 1; in xgbe_rx_poll()
2352 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2355 packet->vlan_ctag); in xgbe_rx_poll()
2357 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2360 hwtstamps->hwtstamp = ns_to_ktime(packet->rx_tstamp); in xgbe_rx_poll()
2363 if (XGMAC_GET_BITS(packet->attributes, in xgbe_rx_poll()
2365 skb_set_hash(skb, packet->rss_hash, in xgbe_rx_poll()
2366 packet->rss_hash_type); in xgbe_rx_poll()
2368 skb->dev = netdev; in xgbe_rx_poll()
2369 skb->protocol = eth_type_trans(skb, netdev); in xgbe_rx_poll()
2370 skb_record_rx_queue(skb, channel->queue_index); in xgbe_rx_poll()
2380 rdata = XGBE_GET_DESC_DATA(ring, ring->cur); in xgbe_rx_poll()
2381 rdata->state_saved = 1; in xgbe_rx_poll()
2382 rdata->state.skb = skb; in xgbe_rx_poll()
2383 rdata->state.len = len; in xgbe_rx_poll()
2384 rdata->state.error = error; in xgbe_rx_poll()
2387 DBGPR("<--xgbe_rx_poll: packet_count = %d\n", packet_count); in xgbe_rx_poll()
2396 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_one_poll()
2399 DBGPR("-->xgbe_one_poll: budget=%d\n", budget); in xgbe_one_poll()
2410 if (pdata->channel_irq_mode) in xgbe_one_poll()
2413 enable_irq(channel->dma_irq); in xgbe_one_poll()
2416 DBGPR("<--xgbe_one_poll: received = %d\n", processed); in xgbe_one_poll()
2430 DBGPR("-->xgbe_all_poll: budget=%d\n", budget); in xgbe_all_poll()
2433 ring_budget = budget / pdata->rx_ring_count; in xgbe_all_poll()
2437 for (i = 0; i < pdata->channel_count; i++) { in xgbe_all_poll()
2438 channel = pdata->channel[i]; in xgbe_all_poll()
2444 if (ring_budget > (budget - processed)) in xgbe_all_poll()
2445 ring_budget = budget - processed; in xgbe_all_poll()
2456 DBGPR("<--xgbe_all_poll: received = %d\n", processed); in xgbe_all_poll()
2467 while (count--) { in xgbe_dump_tx_desc()
2469 rdesc = rdata->rdesc; in xgbe_dump_tx_desc()
2470 netdev_dbg(pdata->netdev, in xgbe_dump_tx_desc()
2473 le32_to_cpu(rdesc->desc0), in xgbe_dump_tx_desc()
2474 le32_to_cpu(rdesc->desc1), in xgbe_dump_tx_desc()
2475 le32_to_cpu(rdesc->desc2), in xgbe_dump_tx_desc()
2476 le32_to_cpu(rdesc->desc3)); in xgbe_dump_tx_desc()
2488 rdesc = rdata->rdesc; in xgbe_dump_rx_desc()
2489 netdev_dbg(pdata->netdev, in xgbe_dump_rx_desc()
2491 idx, le32_to_cpu(rdesc->desc0), le32_to_cpu(rdesc->desc1), in xgbe_dump_rx_desc()
2492 le32_to_cpu(rdesc->desc2), le32_to_cpu(rdesc->desc3)); in xgbe_dump_rx_desc()
2497 struct ethhdr *eth = (struct ethhdr *)skb->data; in xgbe_print_pkt()
2504 (tx_rx ? "TX" : "RX"), skb->len); in xgbe_print_pkt()
2506 netdev_dbg(netdev, "Dst MAC addr: %pM\n", eth->h_dest); in xgbe_print_pkt()
2507 netdev_dbg(netdev, "Src MAC addr: %pM\n", eth->h_source); in xgbe_print_pkt()
2508 netdev_dbg(netdev, "Protocol: %#06x\n", ntohs(eth->h_proto)); in xgbe_print_pkt()
2510 for (i = 0; i < skb->len; i += 32) { in xgbe_print_pkt()
2511 unsigned int len = min(skb->len - i, 32U); in xgbe_print_pkt()
2513 hex_dump_to_buffer(&skb->data[i], len, 32, 1, in xgbe_print_pkt()