Lines Matching refs:pdata
63 static void xgbe_free_channels(struct xgbe_prv_data *pdata) in xgbe_free_channels() argument
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()
81 static int xgbe_alloc_channels(struct xgbe_prv_data *pdata) in xgbe_alloc_channels() argument
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()
103 channel->pdata = pdata; in xgbe_alloc_channels()
105 channel->dma_regs = pdata->xgmac_regs + DMA_CH_BASE + 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()
124 if (i < pdata->rx_ring_count) { in xgbe_alloc_channels()
135 netif_dbg(pdata, drv, pdata->netdev, in xgbe_alloc_channels()
138 netif_dbg(pdata, drv, pdata->netdev, in xgbe_alloc_channels()
144 pdata->channel_count = count; in xgbe_alloc_channels()
149 xgbe_free_channels(pdata); in xgbe_alloc_channels()
167 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_maybe_stop_tx_queue() local
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()
179 pdata->hw_if.tx_start_xmit(channel, ring); in xgbe_maybe_stop_tx_queue()
200 static void xgbe_enable_rx_tx_int(struct xgbe_prv_data *pdata, in xgbe_enable_rx_tx_int() argument
203 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_enable_rx_tx_int()
218 static void xgbe_enable_rx_tx_ints(struct xgbe_prv_data *pdata) in xgbe_enable_rx_tx_ints() argument
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()
226 static void xgbe_disable_rx_tx_int(struct xgbe_prv_data *pdata, in xgbe_disable_rx_tx_int() argument
229 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_disable_rx_tx_int()
244 static void xgbe_disable_rx_tx_ints(struct xgbe_prv_data *pdata) in xgbe_disable_rx_tx_ints() argument
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()
252 static bool xgbe_ecc_sec(struct xgbe_prv_data *pdata, unsigned long *period, in xgbe_ecc_sec() argument
263 dev_warn_once(pdata->dev, in xgbe_ecc_sec()
268 dev_warn_once(pdata->dev, in xgbe_ecc_sec()
277 static bool xgbe_ecc_ded(struct xgbe_prv_data *pdata, unsigned long *period, in xgbe_ecc_ded() argument
288 netdev_alert(pdata->netdev, in xgbe_ecc_ded()
299 struct xgbe_prv_data *pdata = from_work(pdata, work, ecc_bh_work); in xgbe_ecc_isr_bh_work() local
304 ecc_isr = XP_IOREAD(pdata, XP_ECC_ISR); in xgbe_ecc_isr_bh_work()
305 ecc_isr &= XP_IOREAD(pdata, XP_ECC_IER); in xgbe_ecc_isr_bh_work()
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()
348 XP_IOWRITE(pdata, XP_ECC_ISR, ecc_isr); in xgbe_ecc_isr_bh_work()
351 if (pdata->vdata->irq_reissue_support) in xgbe_ecc_isr_bh_work()
352 XP_IOWRITE(pdata, XP_INT_REISSUE_EN, 1 << 1); in xgbe_ecc_isr_bh_work()
357 struct xgbe_prv_data *pdata = data; in xgbe_ecc_isr() local
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()
369 struct xgbe_prv_data *pdata = from_work(pdata, work, dev_bh_work); in xgbe_isr_bh_work() local
370 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_isr_bh_work()
380 dma_isr = XGMAC_IOREAD(pdata, DMA_ISR); 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()
405 xgbe_disable_rx_tx_ints(pdata); 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()
431 mac_isr = XGMAC_IOREAD(pdata, MAC_ISR); 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()
443 mac_tssr = XGMAC_IOREAD(pdata, MAC_TSSR); 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()
451 xgbe_get_tx_tstamp(pdata); 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()
458 mac_mdioisr = XGMAC_IOREAD(pdata, MAC_MDIOISR); 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()
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()
490 XP_IOWRITE(pdata, XP_INT_REISSUE_EN, reissue_mask); in xgbe_isr_bh_work()
496 struct xgbe_prv_data *pdata = data; in xgbe_isr() local
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() local
517 if (pdata->channel_irq_mode) in xgbe_dma_isr()
518 xgbe_disable_rx_tx_int(pdata, channel); in xgbe_dma_isr()
539 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_tx_timer() local
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()
550 xgbe_disable_rx_tx_int(pdata, channel); in xgbe_tx_timer()
554 xgbe_disable_rx_tx_ints(pdata); in xgbe_tx_timer()
567 struct xgbe_prv_data *pdata = container_of(work, in xgbe_service() local
571 pdata->phy_if.phy_status(pdata); in xgbe_service()
576 struct xgbe_prv_data *pdata = timer_container_of(pdata, t, in xgbe_service_timer() local
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()
594 jiffies + usecs_to_jiffies(pdata->tx_usecs)); in xgbe_service_timer()
598 static void xgbe_init_timers(struct xgbe_prv_data *pdata) in xgbe_init_timers() argument
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()
614 static void xgbe_start_timers(struct xgbe_prv_data *pdata) in xgbe_start_timers() argument
616 mod_timer(&pdata->service_timer, jiffies + HZ); in xgbe_start_timers()
619 static void xgbe_stop_timers(struct xgbe_prv_data *pdata) in xgbe_stop_timers() argument
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()
637 void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) in xgbe_get_all_hw_features() argument
640 struct xgbe_hw_features *hw_feat = &pdata->hw_feat; in xgbe_get_all_hw_features()
642 mac_hfr0 = XGMAC_IOREAD(pdata, MAC_HWF0R); in xgbe_get_all_hw_features()
643 mac_hfr1 = XGMAC_IOREAD(pdata, MAC_HWF1R); in xgbe_get_all_hw_features()
644 mac_hfr2 = XGMAC_IOREAD(pdata, MAC_HWF2R); in xgbe_get_all_hw_features()
648 hw_feat->version = XGMAC_IOREAD(pdata, MAC_VR); in xgbe_get_all_hw_features()
737 if (netif_msg_probe(pdata)) { 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()
743 dev_dbg(pdata->dev, " VLAN hash filter : %s\n", in xgbe_get_all_hw_features()
745 dev_dbg(pdata->dev, " MDIO interface : %s\n", in xgbe_get_all_hw_features()
747 dev_dbg(pdata->dev, " Wake-up packet support : %s\n", in xgbe_get_all_hw_features()
749 dev_dbg(pdata->dev, " Magic packet support : %s\n", in xgbe_get_all_hw_features()
751 dev_dbg(pdata->dev, " Management counters : %s\n", in xgbe_get_all_hw_features()
753 dev_dbg(pdata->dev, " ARP offload : %s\n", in xgbe_get_all_hw_features()
755 dev_dbg(pdata->dev, " IEEE 1588-2008 Timestamp : %s\n", in xgbe_get_all_hw_features()
757 dev_dbg(pdata->dev, " Energy Efficient Ethernet : %s\n", in xgbe_get_all_hw_features()
759 dev_dbg(pdata->dev, " TX checksum offload : %s\n", in xgbe_get_all_hw_features()
761 dev_dbg(pdata->dev, " RX checksum offload : %s\n", in xgbe_get_all_hw_features()
763 dev_dbg(pdata->dev, " Additional MAC addresses : %u\n", in xgbe_get_all_hw_features()
765 dev_dbg(pdata->dev, " Timestamp source : %s\n", in xgbe_get_all_hw_features()
769 dev_dbg(pdata->dev, " SA/VLAN insertion : %s\n", in xgbe_get_all_hw_features()
771 dev_dbg(pdata->dev, " VXLAN/NVGRE support : %s\n", in xgbe_get_all_hw_features()
775 dev_dbg(pdata->dev, " RX fifo size : %u\n", in xgbe_get_all_hw_features()
777 dev_dbg(pdata->dev, " TX fifo size : %u\n", in xgbe_get_all_hw_features()
779 dev_dbg(pdata->dev, " IEEE 1588 high word : %s\n", in xgbe_get_all_hw_features()
781 dev_dbg(pdata->dev, " DMA width : %u\n", in xgbe_get_all_hw_features()
783 dev_dbg(pdata->dev, " Data Center Bridging : %s\n", in xgbe_get_all_hw_features()
785 dev_dbg(pdata->dev, " Split header : %s\n", in xgbe_get_all_hw_features()
787 dev_dbg(pdata->dev, " TCP Segmentation Offload : %s\n", in xgbe_get_all_hw_features()
789 dev_dbg(pdata->dev, " Debug memory interface : %s\n", in xgbe_get_all_hw_features()
791 dev_dbg(pdata->dev, " Receive Side Scaling : %s\n", in xgbe_get_all_hw_features()
793 dev_dbg(pdata->dev, " Traffic Class count : %u\n", in xgbe_get_all_hw_features()
795 dev_dbg(pdata->dev, " Hash table size : %u\n", in xgbe_get_all_hw_features()
797 dev_dbg(pdata->dev, " L3/L4 Filters : %u\n", in xgbe_get_all_hw_features()
801 dev_dbg(pdata->dev, " RX queue count : %u\n", in xgbe_get_all_hw_features()
803 dev_dbg(pdata->dev, " TX queue count : %u\n", in xgbe_get_all_hw_features()
805 dev_dbg(pdata->dev, " RX DMA channel count : %u\n", in xgbe_get_all_hw_features()
807 dev_dbg(pdata->dev, " TX DMA channel count : %u\n", in xgbe_get_all_hw_features()
809 dev_dbg(pdata->dev, " PPS outputs : %u\n", in xgbe_get_all_hw_features()
811 dev_dbg(pdata->dev, " Auxiliary snapshot inputs : %u\n", in xgbe_get_all_hw_features()
819 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_vxlan_set_port() local
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()
830 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_vxlan_unset_port() local
832 pdata->hw_if.disable_vxlan(pdata); in xgbe_vxlan_unset_port()
833 pdata->vxlan_port = 0; in xgbe_vxlan_unset_port()
852 static void xgbe_napi_enable(struct xgbe_prv_data *pdata, unsigned int add) in xgbe_napi_enable() argument
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()
868 netif_napi_add(pdata->netdev, &pdata->napi, in xgbe_napi_enable()
871 napi_enable(&pdata->napi); in xgbe_napi_enable()
875 static void xgbe_napi_disable(struct xgbe_prv_data *pdata, unsigned int del) in xgbe_napi_disable() argument
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()
889 napi_disable(&pdata->napi); in xgbe_napi_disable()
892 netif_napi_del(&pdata->napi); in xgbe_napi_disable()
896 static int xgbe_request_irqs(struct xgbe_prv_data *pdata) in xgbe_request_irqs() argument
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()
907 netdev_name(netdev), pdata); 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()
934 ret = devm_request_irq(pdata->dev, channel->dma_irq, 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()
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()
967 static void xgbe_free_irqs(struct xgbe_prv_data *pdata) in xgbe_free_irqs() argument
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()
987 devm_free_irq(pdata->dev, channel->dma_irq, channel); in xgbe_free_irqs()
991 void xgbe_init_tx_coalesce(struct xgbe_prv_data *pdata) in xgbe_init_tx_coalesce() argument
993 struct xgbe_hw_if *hw_if = &pdata->hw_if; 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()
1005 void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata) in xgbe_init_rx_coalesce() argument
1007 struct xgbe_hw_if *hw_if = &pdata->hw_if; 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()
1020 static void xgbe_free_tx_data(struct xgbe_prv_data *pdata) in xgbe_free_tx_data() argument
1022 struct xgbe_desc_if *desc_if = &pdata->desc_if; 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()
1036 desc_if->unmap_rdata(pdata, rdata); in xgbe_free_tx_data()
1043 static void xgbe_free_rx_data(struct xgbe_prv_data *pdata) in xgbe_free_rx_data() argument
1045 struct xgbe_desc_if *desc_if = &pdata->desc_if; 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()
1059 desc_if->unmap_rdata(pdata, rdata); in xgbe_free_rx_data()
1066 static int xgbe_phy_reset(struct xgbe_prv_data *pdata) in xgbe_phy_reset() argument
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()
1076 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_powerdown() local
1077 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_powerdown()
1083 (caller == XGMAC_IOCTL_CONTEXT && pdata->power_down)) { in xgbe_powerdown()
1089 spin_lock_irqsave(&pdata->lock, flags); in xgbe_powerdown()
1096 xgbe_stop_timers(pdata); 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()
1102 xgbe_napi_disable(pdata, 0); in xgbe_powerdown()
1104 pdata->power_down = 1; in xgbe_powerdown()
1106 spin_unlock_irqrestore(&pdata->lock, flags); in xgbe_powerdown()
1115 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_powerup() local
1116 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_powerup()
1122 (caller == XGMAC_IOCTL_CONTEXT && !pdata->power_down)) { in xgbe_powerup()
1128 spin_lock_irqsave(&pdata->lock, flags); in xgbe_powerup()
1130 pdata->power_down = 0; in xgbe_powerup()
1132 xgbe_napi_enable(pdata, 0); in xgbe_powerup()
1134 hw_if->powerup_tx(pdata); in xgbe_powerup()
1135 hw_if->powerup_rx(pdata); in xgbe_powerup()
1142 xgbe_start_timers(pdata); in xgbe_powerup()
1144 spin_unlock_irqrestore(&pdata->lock, flags); in xgbe_powerup()
1151 static void xgbe_free_memory(struct xgbe_prv_data *pdata) in xgbe_free_memory() argument
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()
1159 xgbe_free_channels(pdata); in xgbe_free_memory()
1162 static int xgbe_alloc_memory(struct xgbe_prv_data *pdata) in xgbe_alloc_memory() argument
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()
1183 ret = xgbe_alloc_channels(pdata); in xgbe_alloc_memory()
1188 ret = desc_if->alloc_ring_resources(pdata); in xgbe_alloc_memory()
1193 xgbe_init_timers(pdata); in xgbe_alloc_memory()
1198 xgbe_free_memory(pdata); in xgbe_alloc_memory()
1203 static int xgbe_start(struct xgbe_prv_data *pdata) in xgbe_start() argument
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()
1233 xgbe_napi_enable(pdata, 1); in xgbe_start()
1235 ret = xgbe_request_irqs(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()
1250 xgbe_start_timers(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()
1258 xgbe_free_irqs(pdata); in xgbe_start()
1261 xgbe_napi_disable(pdata, 1); in xgbe_start()
1263 hw_if->exit(pdata); in xgbe_start()
1268 static void xgbe_stop(struct xgbe_prv_data *pdata) in xgbe_stop() argument
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()
1279 if (test_bit(XGBE_STOPPED, &pdata->dev_state)) in xgbe_stop()
1283 netif_carrier_off(pdata->netdev); in xgbe_stop()
1285 xgbe_stop_timers(pdata); 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()
1295 xgbe_free_irqs(pdata); in xgbe_stop()
1297 xgbe_napi_disable(pdata, 1); 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()
1310 set_bit(XGBE_STOPPED, &pdata->dev_state); in xgbe_stop()
1317 struct xgbe_prv_data *pdata = container_of(work, in xgbe_stopdev() local
1323 xgbe_stop(pdata); in xgbe_stopdev()
1325 xgbe_free_tx_data(pdata); in xgbe_stopdev()
1326 xgbe_free_rx_data(pdata); in xgbe_stopdev()
1330 netdev_alert(pdata->netdev, "device stopped\n"); in xgbe_stopdev()
1333 void xgbe_full_restart_dev(struct xgbe_prv_data *pdata) in xgbe_full_restart_dev() argument
1336 if (!netif_running(pdata->netdev)) in xgbe_full_restart_dev()
1339 xgbe_stop(pdata); in xgbe_full_restart_dev()
1341 xgbe_free_memory(pdata); in xgbe_full_restart_dev()
1342 xgbe_alloc_memory(pdata); in xgbe_full_restart_dev()
1344 xgbe_start(pdata); in xgbe_full_restart_dev()
1347 void xgbe_restart_dev(struct xgbe_prv_data *pdata) in xgbe_restart_dev() argument
1350 if (!netif_running(pdata->netdev)) in xgbe_restart_dev()
1353 xgbe_stop(pdata); in xgbe_restart_dev()
1355 xgbe_free_tx_data(pdata); in xgbe_restart_dev()
1356 xgbe_free_rx_data(pdata); in xgbe_restart_dev()
1358 xgbe_start(pdata); in xgbe_restart_dev()
1363 struct xgbe_prv_data *pdata = container_of(work, in xgbe_restart() local
1369 xgbe_restart_dev(pdata); in xgbe_restart()
1461 static void xgbe_packet_info(struct xgbe_prv_data *pdata, in xgbe_packet_info() argument
1514 (pdata->tstamp_config.tx_type == HWTSTAMP_TX_ON)) in xgbe_packet_info()
1534 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_open() local
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()
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()
1564 ret = xgbe_phy_reset(pdata); 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()
1587 xgbe_init_ptp(pdata); in xgbe_open()
1589 ret = xgbe_alloc_memory(pdata); in xgbe_open()
1593 ret = xgbe_start(pdata); in xgbe_open()
1597 clear_bit(XGBE_DOWN, &pdata->dev_state); in xgbe_open()
1602 xgbe_free_memory(pdata); 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()
1621 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_close() local
1624 xgbe_stop(pdata); in xgbe_close()
1626 xgbe_free_memory(pdata); in xgbe_close()
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()
1643 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_xmit() local
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()
1654 channel = pdata->channel[skb->queue_mapping]; in xgbe_xmit()
1662 netif_err(pdata, tx_err, netdev, in xgbe_xmit()
1670 xgbe_packet_info(pdata, ring, skb, packet); in xgbe_xmit()
1679 netif_err(pdata, tx_err, netdev, in xgbe_xmit()
1691 xgbe_prep_tx_tstamp(pdata, skb, packet); in xgbe_xmit()
1699 if (netif_msg_pktdata(pdata)) in xgbe_xmit()
1713 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_set_rx_mode() local
1714 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_set_rx_mode()
1718 hw_if->config_rx_mode(pdata); in xgbe_set_rx_mode()
1725 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_set_mac_address() local
1726 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_set_mac_address()
1736 hw_if->set_mac_address(pdata, netdev->dev_addr); in xgbe_set_mac_address()
1745 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_ioctl() local
1750 ret = xgbe_get_hwtstamp_settings(pdata, ifreq); in xgbe_ioctl()
1754 ret = xgbe_set_hwtstamp_settings(pdata, ifreq); in xgbe_ioctl()
1766 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_change_mtu() local
1775 pdata->rx_buf_size = ret; in xgbe_change_mtu()
1778 xgbe_restart_dev(pdata); in xgbe_change_mtu()
1787 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_tx_timeout() local
1790 schedule_work(&pdata->restart_work); in xgbe_tx_timeout()
1796 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_get_stats64() local
1797 struct xgbe_mmc_stats *pstats = &pdata->mmc_stats; in xgbe_get_stats64()
1801 pdata->hw_if.read_mmc_stats(pdata); in xgbe_get_stats64()
1825 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_vlan_rx_add_vid() local
1826 struct xgbe_hw_if *hw_if = &pdata->hw_if; 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()
1841 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_vlan_rx_kill_vid() local
1842 struct xgbe_hw_if *hw_if = &pdata->hw_if; 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()
1857 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_poll_controller() local
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()
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()
1881 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_setup_tc() local
1891 if (tc > pdata->hw_feat.tc_cnt) in xgbe_setup_tc()
1894 pdata->num_tcs = tc; in xgbe_setup_tc()
1895 pdata->hw_if.config_tc(pdata); in xgbe_setup_tc()
1903 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_fix_features() local
1908 if (!pdata->hw_feat.vxn) in xgbe_fix_features()
1946 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_set_features() local
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()
2031 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_rx_refresh() local
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()
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()
2061 static struct sk_buff *xgbe_create_skb(struct xgbe_prv_data *pdata, in xgbe_create_skb() argument
2076 dma_sync_single_range_for_cpu(pdata->dev, rdata->rx.hdr.dma_base, in xgbe_create_skb()
2127 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_tx_poll() local
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()
2133 struct net_device *netdev = pdata->netdev; in xgbe_tx_poll()
2164 if (netif_msg_tx_done(pdata)) in xgbe_tx_poll()
2165 xgbe_dump_tx_desc(pdata, ring, ring->dirty, 1, 0); in xgbe_tx_poll()
2173 desc_if->unmap_rdata(pdata, rdata); in xgbe_tx_poll()
2198 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_rx_poll() local
2199 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_rx_poll()
2203 struct net_device *netdev = pdata->netdev; in xgbe_rx_poll()
2221 napi = (pdata->per_channel_irq) ? &channel->napi : &pdata->napi; in xgbe_rx_poll()
2267 netif_err(pdata, rx_err, netdev, in xgbe_rx_poll()
2289 skb = xgbe_create_skb(pdata, napi, rdata, in xgbe_rx_poll()
2298 dma_sync_single_range_for_cpu(pdata->dev, in xgbe_rx_poll()
2329 netif_err(pdata, rx_err, netdev, in xgbe_rx_poll()
2335 if (netif_msg_pktdata(pdata)) in xgbe_rx_poll()
2396 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_one_poll() local
2410 if (pdata->channel_irq_mode) in xgbe_one_poll()
2411 xgbe_enable_rx_tx_int(pdata, channel); in xgbe_one_poll()
2423 struct xgbe_prv_data *pdata = container_of(napi, struct xgbe_prv_data, in xgbe_all_poll() local
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()
2453 xgbe_enable_rx_tx_ints(pdata); in xgbe_all_poll()
2461 void xgbe_dump_tx_desc(struct xgbe_prv_data *pdata, struct xgbe_ring *ring, in xgbe_dump_tx_desc() argument
2470 netdev_dbg(pdata->netdev, in xgbe_dump_tx_desc()
2481 void xgbe_dump_rx_desc(struct xgbe_prv_data *pdata, struct xgbe_ring *ring, in xgbe_dump_rx_desc() argument
2489 netdev_dbg(pdata->netdev, in xgbe_dump_rx_desc()