Lines Matching refs:pdata

127 static int xgbe_all_poll(struct xgbe_prv_data *pdata, int budget);
129 static int xgbe_alloc_channels(struct xgbe_prv_data *pdata) in xgbe_alloc_channels() argument
136 count = max_t(unsigned int, pdata->tx_ring_count, pdata->rx_ring_count); in xgbe_alloc_channels()
140 tx_ring = malloc(pdata->tx_ring_count * sizeof(struct xgbe_ring), in xgbe_alloc_channels()
142 rx_ring = malloc(pdata->rx_ring_count * sizeof(struct xgbe_ring), in xgbe_alloc_channels()
147 channel->pdata = pdata; in xgbe_alloc_channels()
149 channel->dma_tag = rman_get_bustag(pdata->xgmac_res); in xgbe_alloc_channels()
151 rman_get_bushandle(pdata->xgmac_res), in xgbe_alloc_channels()
155 if (pdata->per_channel_irq) { in xgbe_alloc_channels()
156 if (pdata->chan_irq_res[i] == NULL) in xgbe_alloc_channels()
159 channel->dma_irq_res = pdata->chan_irq_res[i]; in xgbe_alloc_channels()
162 if (i < pdata->tx_ring_count) { in xgbe_alloc_channels()
167 if (i < pdata->rx_ring_count) { in xgbe_alloc_channels()
173 pdata->channel = channel_mem; in xgbe_alloc_channels()
174 pdata->channel_count = count; in xgbe_alloc_channels()
186 static void xgbe_free_channels(struct xgbe_prv_data *pdata) in xgbe_free_channels() argument
188 if (!pdata->channel) in xgbe_free_channels()
191 free(pdata->channel->rx_ring, M_AXGBE); in xgbe_free_channels()
192 free(pdata->channel->tx_ring, M_AXGBE); in xgbe_free_channels()
193 free(pdata->channel, M_AXGBE); in xgbe_free_channels()
195 pdata->channel = NULL; in xgbe_free_channels()
196 pdata->channel_count = 0; in xgbe_free_channels()
212 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_maybe_stop_tx_queue() local
219 pdata->hw_if.tx_start_xmit(channel, ring); in xgbe_maybe_stop_tx_queue()
244 static void xgbe_enable_rx_tx_ints(struct xgbe_prv_data *pdata) in xgbe_enable_rx_tx_ints() argument
246 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_enable_rx_tx_ints()
251 channel = pdata->channel; in xgbe_enable_rx_tx_ints()
252 for (i = 0; i < pdata->channel_count; i++, channel++) { in xgbe_enable_rx_tx_ints()
268 struct xgbe_prv_data *pdata = data; in xgbe_isr() local
269 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_isr()
279 dma_isr = XGMAC_IOREAD(pdata, DMA_ISR); in xgbe_isr()
283 for (i = 0; i < pdata->channel_count; i++) { in xgbe_isr()
287 channel = pdata->channel + i; in xgbe_isr()
295 if (!pdata->per_channel_irq && in xgbe_isr()
298 xgbe_all_poll(pdata, 16); in xgbe_isr()
302 pdata->ext_stats.rx_buffer_unavailable++; in xgbe_isr()
307 &pdata->restart_work); in xgbe_isr()
314 mac_isr = XGMAC_IOREAD(pdata, MAC_ISR); in xgbe_isr()
317 hw_if->tx_mmc_int(pdata); in xgbe_isr()
320 hw_if->rx_mmc_int(pdata); in xgbe_isr()
333 struct xgbe_prv_data *pdata = ctx; in xgbe_service() local
335 pdata->phy_if.phy_status(pdata); in xgbe_service()
340 struct xgbe_prv_data *pdata = data; in xgbe_service_timer() local
343 taskqueue_enqueue(pdata->dev_workqueue, &pdata->service_work); in xgbe_service_timer()
345 callout_reset(&pdata->service_timer, hz, xgbe_service_timer, pdata); in xgbe_service_timer()
349 static void xgbe_init_timers(struct xgbe_prv_data *pdata) in xgbe_init_timers() argument
352 callout_init(&pdata->service_timer, 1); in xgbe_init_timers()
355 static void xgbe_start_timers(struct xgbe_prv_data *pdata) in xgbe_start_timers() argument
357 callout_reset(&pdata->service_timer, hz, xgbe_service_timer, pdata); in xgbe_start_timers()
360 static void xgbe_stop_timers(struct xgbe_prv_data *pdata) in xgbe_stop_timers() argument
363 callout_drain(&pdata->service_timer); in xgbe_stop_timers()
366 void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) in xgbe_get_all_hw_features() argument
369 struct xgbe_hw_features *hw_feat = &pdata->hw_feat; in xgbe_get_all_hw_features()
373 mac_hfr0 = XGMAC_IOREAD(pdata, MAC_HWF0R); in xgbe_get_all_hw_features()
374 mac_hfr1 = XGMAC_IOREAD(pdata, MAC_HWF1R); in xgbe_get_all_hw_features()
375 mac_hfr2 = XGMAC_IOREAD(pdata, MAC_HWF2R); in xgbe_get_all_hw_features()
379 hw_feat->version = XGMAC_IOREAD(pdata, MAC_VR); in xgbe_get_all_hw_features()
466 static int xgbe_request_irqs(struct xgbe_prv_data *pdata) in xgbe_request_irqs() argument
472 ret = bus_setup_intr(pdata->dev, pdata->dev_irq_res, in xgbe_request_irqs()
473 INTR_MPSAFE | INTR_TYPE_NET, NULL, xgbe_isr, pdata, in xgbe_request_irqs()
474 &pdata->dev_irq_tag); in xgbe_request_irqs()
479 if (!pdata->per_channel_irq) in xgbe_request_irqs()
482 channel = pdata->channel; in xgbe_request_irqs()
483 for (i = 0; i < pdata->channel_count; i++, channel++) { in xgbe_request_irqs()
484 ret = bus_setup_intr(pdata->dev, channel->dma_irq_res, in xgbe_request_irqs()
496 for (i--, channel--; i < pdata->channel_count; i--, channel--) in xgbe_request_irqs()
497 bus_teardown_intr(pdata->dev, channel->dma_irq_res, in xgbe_request_irqs()
500 bus_teardown_intr(pdata->dev, pdata->dev_irq_res, pdata->dev_irq_tag); in xgbe_request_irqs()
505 static void xgbe_free_irqs(struct xgbe_prv_data *pdata) in xgbe_free_irqs() argument
510 bus_teardown_intr(pdata->dev, pdata->dev_irq_res, pdata->dev_irq_tag); in xgbe_free_irqs()
512 if (!pdata->per_channel_irq) in xgbe_free_irqs()
515 channel = pdata->channel; in xgbe_free_irqs()
516 for (i = 0; i < pdata->channel_count; i++, channel++) in xgbe_free_irqs()
517 bus_teardown_intr(pdata->dev, channel->dma_irq_res, in xgbe_free_irqs()
521 void xgbe_init_tx_coalesce(struct xgbe_prv_data *pdata) in xgbe_init_tx_coalesce() argument
523 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_init_tx_coalesce()
527 pdata->tx_usecs = XGMAC_INIT_DMA_TX_USECS; in xgbe_init_tx_coalesce()
528 pdata->tx_frames = XGMAC_INIT_DMA_TX_FRAMES; in xgbe_init_tx_coalesce()
530 hw_if->config_tx_coalesce(pdata); in xgbe_init_tx_coalesce()
535 void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata) in xgbe_init_rx_coalesce() argument
537 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_init_rx_coalesce()
541 pdata->rx_riwt = hw_if->usec_to_riwt(pdata, XGMAC_INIT_DMA_RX_USECS); in xgbe_init_rx_coalesce()
542 pdata->rx_usecs = XGMAC_INIT_DMA_RX_USECS; in xgbe_init_rx_coalesce()
543 pdata->rx_frames = XGMAC_INIT_DMA_RX_FRAMES; in xgbe_init_rx_coalesce()
545 hw_if->config_rx_coalesce(pdata); in xgbe_init_rx_coalesce()
550 static void xgbe_free_tx_data(struct xgbe_prv_data *pdata) in xgbe_free_tx_data() argument
552 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_free_tx_data()
560 channel = pdata->channel; in xgbe_free_tx_data()
561 for (i = 0; i < pdata->channel_count; i++, channel++) { in xgbe_free_tx_data()
568 desc_if->unmap_rdata(pdata, rdata); in xgbe_free_tx_data()
575 static void xgbe_free_rx_data(struct xgbe_prv_data *pdata) in xgbe_free_rx_data() argument
577 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_free_rx_data()
585 channel = pdata->channel; in xgbe_free_rx_data()
586 for (i = 0; i < pdata->channel_count; i++, channel++) { in xgbe_free_rx_data()
593 desc_if->unmap_rdata(pdata, rdata); in xgbe_free_rx_data()
600 static int xgbe_phy_init(struct xgbe_prv_data *pdata) in xgbe_phy_init() argument
602 pdata->phy_link = -1; in xgbe_phy_init()
603 pdata->phy_speed = SPEED_UNKNOWN; in xgbe_phy_init()
605 return pdata->phy_if.phy_reset(pdata); in xgbe_phy_init()
608 static int xgbe_start(struct xgbe_prv_data *pdata) in xgbe_start() argument
610 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_start()
611 struct xgbe_phy_if *phy_if = &pdata->phy_if; in xgbe_start()
616 hw_if->init(pdata); in xgbe_start()
618 ret = phy_if->phy_start(pdata); in xgbe_start()
622 ret = xgbe_request_irqs(pdata); in xgbe_start()
626 hw_if->enable_tx(pdata); in xgbe_start()
627 hw_if->enable_rx(pdata); in xgbe_start()
629 xgbe_enable_rx_tx_ints(pdata); in xgbe_start()
631 xgbe_start_timers(pdata); in xgbe_start()
632 taskqueue_enqueue(pdata->dev_workqueue, &pdata->service_work); in xgbe_start()
639 phy_if->phy_stop(pdata); in xgbe_start()
642 hw_if->exit(pdata); in xgbe_start()
647 static void xgbe_stop(struct xgbe_prv_data *pdata) in xgbe_stop() argument
649 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_stop()
650 struct xgbe_phy_if *phy_if = &pdata->phy_if; in xgbe_stop()
654 xgbe_stop_timers(pdata); in xgbe_stop()
655 taskqueue_drain_all(pdata->dev_workqueue); in xgbe_stop()
657 hw_if->disable_tx(pdata); in xgbe_stop()
658 hw_if->disable_rx(pdata); in xgbe_stop()
660 xgbe_free_irqs(pdata); in xgbe_stop()
662 phy_if->phy_stop(pdata); in xgbe_stop()
664 hw_if->exit(pdata); in xgbe_stop()
669 static void xgbe_restart_dev(struct xgbe_prv_data *pdata) in xgbe_restart_dev() argument
674 if ((pdata->netdev->if_drv_flags & IFF_DRV_RUNNING) == 0) in xgbe_restart_dev()
677 xgbe_stop(pdata); in xgbe_restart_dev()
679 xgbe_free_tx_data(pdata); in xgbe_restart_dev()
680 xgbe_free_rx_data(pdata); in xgbe_restart_dev()
682 xgbe_start(pdata); in xgbe_restart_dev()
689 struct xgbe_prv_data *pdata = ctx; in xgbe_restart() local
691 xgbe_restart_dev(pdata); in xgbe_restart()
694 static void xgbe_packet_info(struct xgbe_prv_data *pdata, in xgbe_packet_info() argument
718 struct xgbe_prv_data *pdata = netdev->if_softc; in xgbe_open() local
719 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_open()
725 ret = xgbe_phy_init(pdata); in xgbe_open()
734 pdata->rx_buf_size = ret; in xgbe_open()
737 ret = xgbe_alloc_channels(pdata); in xgbe_open()
744 ret = desc_if->alloc_ring_resources(pdata); in xgbe_open()
750 TASK_INIT(&pdata->service_work, 0, xgbe_service, pdata); in xgbe_open()
751 TASK_INIT(&pdata->restart_work, 0, xgbe_restart, pdata); in xgbe_open()
752 xgbe_init_timers(pdata); in xgbe_open()
754 ret = xgbe_start(pdata); in xgbe_open()
758 clear_bit(XGBE_DOWN, &pdata->dev_state); in xgbe_open()
765 desc_if->free_ring_resources(pdata); in xgbe_open()
768 xgbe_free_channels(pdata); in xgbe_open()
777 struct xgbe_prv_data *pdata = netdev->if_softc; in xgbe_close() local
778 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_close()
783 xgbe_stop(pdata); in xgbe_close()
786 desc_if->free_ring_resources(pdata); in xgbe_close()
789 xgbe_free_channels(pdata); in xgbe_close()
791 set_bit(XGBE_DOWN, &pdata->dev_state); in xgbe_close()
800 struct xgbe_prv_data *pdata = ifp->if_softc; in xgbe_xmit() local
801 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_xmit()
802 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_xmit()
811 if (__predict_false(test_bit(XGBE_DOWN, &pdata->dev_state) || in xgbe_xmit()
812 !pdata->phy.link)) { in xgbe_xmit()
817 channel = pdata->channel; in xgbe_xmit()
823 xgbe_packet_info(pdata, ring, m, packet); in xgbe_xmit()
847 struct xgbe_prv_data *pdata = netdev->if_softc; in xgbe_change_mtu() local
856 pdata->rx_buf_size = ret; in xgbe_change_mtu()
859 xgbe_restart_dev(pdata); in xgbe_change_mtu()
868 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_rx_refresh() local
869 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_rx_refresh()
870 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_rx_refresh()
878 desc_if->unmap_rdata(pdata, rdata); in xgbe_rx_refresh()
880 if (desc_if->map_rx_buffer(pdata, ring, rdata)) in xgbe_rx_refresh()
883 hw_if->rx_desc_reset(pdata, rdata, ring->dirty); in xgbe_rx_refresh()
900 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_tx_poll() local
901 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_tx_poll()
902 struct xgbe_desc_if *desc_if = &pdata->desc_if; in xgbe_tx_poll()
933 desc_if->unmap_rdata(pdata, rdata); in xgbe_tx_poll()
950 struct xgbe_prv_data *pdata = channel->pdata; in xgbe_rx_poll() local
951 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_rx_poll()
955 struct ifnet *ifp = pdata->netdev; in xgbe_rx_poll()
1047 static int xgbe_all_poll(struct xgbe_prv_data *pdata, int budget) in xgbe_all_poll() argument
1057 ring_budget = budget / pdata->rx_ring_count; in xgbe_all_poll()
1061 channel = pdata->channel; in xgbe_all_poll()
1062 for (i = 0; i < pdata->channel_count; i++, channel++) { in xgbe_all_poll()