Lines Matching +full:mac +full:- +full:wol
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2019 - 2022 Beijing WangXun Technology Co., Ltd. */
24 /* ngbe_pci_tbl - PCI Device ID Table
47 * ngbe_init_type_code - Initialize the shared code
55 wx->mac.type = wx_mac_em; in ngbe_init_type_code()
56 type_mask = (u16)(wx->subsystem_device_id & NGBE_OEM_MASK); in ngbe_init_type_code()
57 ncsi_mask = wx->subsystem_device_id & NGBE_NCSI_MASK; in ngbe_init_type_code()
58 wol_mask = wx->subsystem_device_id & NGBE_WOL_MASK; in ngbe_init_type_code()
61 wx->mac_type = (val & BIT(7)) >> 7 ? in ngbe_init_type_code()
65 wx->wol_hw_supported = (wol_mask == NGBE_WOL_SUP) ? 1 : 0; in ngbe_init_type_code()
66 wx->ncsi_enabled = (ncsi_mask == NGBE_NCSI_MASK || in ngbe_init_type_code()
74 wx->gpio_ctrl = 1; in ngbe_init_type_code()
77 wx->gpio_ctrl = 0; in ngbe_init_type_code()
83 * ngbe_sw_init - Initialize general software structures
88 struct pci_dev *pdev = wx->pdev; in ngbe_sw_init()
92 wx->mac.num_rar_entries = NGBE_RAR_ENTRIES; in ngbe_sw_init()
93 wx->mac.max_rx_queues = NGBE_MAX_RX_QUEUES; in ngbe_sw_init()
94 wx->mac.max_tx_queues = NGBE_MAX_TX_QUEUES; in ngbe_sw_init()
95 wx->mac.mcft_size = NGBE_MC_TBL_SIZE; in ngbe_sw_init()
96 wx->mac.vft_size = NGBE_SP_VFT_TBL_SIZE; in ngbe_sw_init()
97 wx->mac.rx_pb_size = NGBE_RX_PB_SIZE; in ngbe_sw_init()
98 wx->mac.tx_pb_size = NGBE_TDB_PB_SZ; in ngbe_sw_init()
105 /* mac type, phy type , oem type */ in ngbe_sw_init()
109 wx->max_q_vectors = NGBE_MAX_MSIX_VECTORS; in ngbe_sw_init()
112 dev_err(&pdev->dev, "Do not support MSI-X\n"); in ngbe_sw_init()
113 wx->mac.max_msix_vectors = msix_count; in ngbe_sw_init()
115 wx->ring_feature[RING_F_RSS].limit = min_t(int, NGBE_MAX_RSS_INDICES, in ngbe_sw_init()
117 wx->rss_enabled = true; in ngbe_sw_init()
120 wx->rx_itr_setting = 1; in ngbe_sw_init()
121 wx->tx_itr_setting = 1; in ngbe_sw_init()
124 wx->tx_ring_count = NGBE_DEFAULT_TXD; in ngbe_sw_init()
125 wx->rx_ring_count = NGBE_DEFAULT_RXD; in ngbe_sw_init()
128 wx->tx_work_limit = NGBE_DEFAULT_TX_WORK; in ngbe_sw_init()
129 wx->rx_work_limit = NGBE_DEFAULT_RX_WORK; in ngbe_sw_init()
135 * ngbe_irq_enable - Enable default interrupt generation settings
149 wr32(wx, WX_GPIO_POLARITY, wx->gpio_ctrl ? 0 : 0x3); in ngbe_irq_enable()
161 * ngbe_intr - msi/legacy mode Interrupt Handler
172 q_vector = wx->q_vector[0]; in ngbe_intr()
173 pdev = wx->pdev; in ngbe_intr()
180 if (netif_running(wx->netdev)) in ngbe_intr()
184 wx->isb_mem[WX_ISB_VEC0] = 0; in ngbe_intr()
185 if (!(pdev->msi_enabled)) in ngbe_intr()
188 wx->isb_mem[WX_ISB_MISC] = 0; in ngbe_intr()
190 napi_schedule_irqoff(&q_vector->napi); in ngbe_intr()
192 if (netif_running(wx->netdev)) in ngbe_intr()
202 /* re-enable the original interrupt state, no lsc, no queues */ in ngbe_msix_other()
203 if (netif_running(wx->netdev)) in ngbe_msix_other()
210 * ngbe_request_msix_irqs - Initialize MSI-X interrupts
213 * ngbe_request_msix_irqs allocates MSI-X vectors and requests
218 struct net_device *netdev = wx->netdev; in ngbe_request_msix_irqs()
221 for (vector = 0; vector < wx->num_q_vectors; vector++) { in ngbe_request_msix_irqs()
222 struct wx_q_vector *q_vector = wx->q_vector[vector]; in ngbe_request_msix_irqs()
223 struct msix_entry *entry = &wx->msix_q_entries[vector]; in ngbe_request_msix_irqs()
225 if (q_vector->tx.ring && q_vector->rx.ring) in ngbe_request_msix_irqs()
226 snprintf(q_vector->name, sizeof(q_vector->name) - 1, in ngbe_request_msix_irqs()
227 "%s-TxRx-%d", netdev->name, entry->entry); in ngbe_request_msix_irqs()
232 err = request_irq(entry->vector, wx_msix_clean_rings, 0, in ngbe_request_msix_irqs()
233 q_vector->name, q_vector); in ngbe_request_msix_irqs()
236 q_vector->name, err); in ngbe_request_msix_irqs()
241 err = request_irq(wx->msix_entry->vector, in ngbe_request_msix_irqs()
242 ngbe_msix_other, 0, netdev->name, wx); in ngbe_request_msix_irqs()
253 vector--; in ngbe_request_msix_irqs()
254 free_irq(wx->msix_q_entries[vector].vector, in ngbe_request_msix_irqs()
255 wx->q_vector[vector]); in ngbe_request_msix_irqs()
262 * ngbe_request_irq - initialize interrupts
270 struct net_device *netdev = wx->netdev; in ngbe_request_irq()
271 struct pci_dev *pdev = wx->pdev; in ngbe_request_irq()
274 if (pdev->msix_enabled) in ngbe_request_irq()
276 else if (pdev->msi_enabled) in ngbe_request_irq()
277 err = request_irq(pdev->irq, ngbe_intr, 0, in ngbe_request_irq()
278 netdev->name, wx); in ngbe_request_irq()
280 err = request_irq(pdev->irq, ngbe_intr, IRQF_SHARED, in ngbe_request_irq()
281 netdev->name, wx); in ngbe_request_irq()
291 struct net_device *netdev = wx->netdev; in ngbe_disable_device()
295 for (i = 0; i < wx->num_rx_queues; i++) in ngbe_disable_device()
297 wx_disable_rx_queue(wx, wx->rx_ring[i]); in ngbe_disable_device()
303 if (wx->gpio_ctrl) in ngbe_disable_device()
307 for (i = 0; i < wx->num_tx_queues; i++) { in ngbe_disable_device()
308 u8 reg_idx = wx->tx_ring[i]->reg_idx; in ngbe_disable_device()
318 phylink_stop(wx->phylink); in ngbe_down()
328 /* make sure to complete pre-operations */ in ngbe_up()
332 netif_tx_start_all_queues(wx->netdev); in ngbe_up()
338 if (wx->gpio_ctrl) in ngbe_up()
341 phylink_start(wx->phylink); in ngbe_up()
345 * ngbe_open - Called when a network interface is made active
370 err = phylink_connect_phy(wx->phylink, wx->phydev); in ngbe_open()
374 err = netif_set_real_num_tx_queues(netdev, wx->num_tx_queues); in ngbe_open()
378 err = netif_set_real_num_rx_queues(netdev, wx->num_rx_queues); in ngbe_open()
386 phylink_disconnect_phy(wx->phylink); in ngbe_open()
396 * ngbe_close - Disables a network interface
401 * The close entry point is called when an interface is de-activated
403 * needs to be disabled. A global MAC reset is issued to stop the
414 phylink_disconnect_phy(wx->phylink); in ngbe_close()
424 u32 wufc = wx->wol; in ngbe_dev_shutdown()
426 netdev = wx->netdev; in ngbe_dev_shutdown()
454 wake = !!wx->wol; in ngbe_shutdown()
465 * ngbe_setup_tc - routine to configure net_device for multiple traffic
513 * ngbe_probe - Device Initialization Routine
539 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in ngbe_probe()
541 dev_err(&pdev->dev, in ngbe_probe()
550 dev_err(&pdev->dev, in ngbe_probe()
557 netdev = devm_alloc_etherdev_mqs(&pdev->dev, in ngbe_probe()
562 err = -ENOMEM; in ngbe_probe()
566 SET_NETDEV_DEV(netdev, &pdev->dev); in ngbe_probe()
569 wx->netdev = netdev; in ngbe_probe()
570 wx->pdev = pdev; in ngbe_probe()
571 wx->msg_enable = BIT(3) - 1; in ngbe_probe()
573 wx->hw_addr = devm_ioremap(&pdev->dev, in ngbe_probe()
576 if (!wx->hw_addr) { in ngbe_probe()
577 err = -EIO; in ngbe_probe()
581 wx->driver_name = ngbe_driver_name; in ngbe_probe()
583 netdev->netdev_ops = &ngbe_netdev_ops; in ngbe_probe()
585 netdev->features = NETIF_F_SG | NETIF_F_IP_CSUM | in ngbe_probe()
588 netdev->features |= NETIF_F_SCTP_CRC | NETIF_F_TSO_MANGLEID; in ngbe_probe()
589 netdev->vlan_features |= netdev->features; in ngbe_probe()
590 netdev->features |= NETIF_F_IPV6_CSUM | NETIF_F_VLAN_FEATURES; in ngbe_probe()
592 netdev->hw_features |= netdev->features | NETIF_F_RXALL; in ngbe_probe()
593 netdev->hw_features |= NETIF_F_NTUPLE | NETIF_F_HW_TC; in ngbe_probe()
594 netdev->features |= NETIF_F_HIGHDMA; in ngbe_probe()
595 netdev->hw_features |= NETIF_F_GRO; in ngbe_probe()
596 netdev->features |= NETIF_F_GRO; in ngbe_probe()
598 netdev->priv_flags |= IFF_UNICAST_FLT; in ngbe_probe()
599 netdev->priv_flags |= IFF_SUPP_NOFCS; in ngbe_probe()
600 netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE; in ngbe_probe()
602 netdev->min_mtu = ETH_MIN_MTU; in ngbe_probe()
603 netdev->max_mtu = WX_MAX_JUMBO_FRAME_SIZE - in ngbe_probe()
606 wx->bd_number = func_nums; in ngbe_probe()
622 dev_err(&pdev->dev, "Management capability is not present\n"); in ngbe_probe()
628 dev_err(&pdev->dev, "HW Init failed: %d\n", err); in ngbe_probe()
632 if (wx->bus.func == 0) { in ngbe_probe()
641 if (wx->bus.func == 0 || e2rom_cksum_cap == 0) { in ngbe_probe()
645 dev_err(&pdev->dev, "The EEPROM Checksum Is Not Valid\n"); in ngbe_probe()
646 err = -EIO; in ngbe_probe()
651 wx->wol = 0; in ngbe_probe()
652 if (wx->wol_hw_supported) in ngbe_probe()
653 wx->wol = NGBE_PSR_WKUP_CTL_MAG; in ngbe_probe()
655 netdev->ethtool->wol_enabled = !!(wx->wol); in ngbe_probe()
656 wr32(wx, NGBE_PSR_WKUP_CTL, wx->wol); in ngbe_probe()
657 device_set_wakeup_enable(&pdev->dev, wx->wol); in ngbe_probe()
666 wx->eeprom.sw_region_offset + NGBE_EEPROM_VERSION_H, in ngbe_probe()
670 wx->eeprom.sw_region_offset + NGBE_EEPROM_VERSION_L, in ngbe_probe()
675 snprintf(wx->eeprom_id, sizeof(wx->eeprom_id), in ngbe_probe()
678 eth_hw_addr_set(netdev, wx->mac.perm_addr); in ngbe_probe()
679 wx_mac_set_default_filter(wx, wx->mac.perm_addr); in ngbe_probe()
699 phylink_destroy(wx->phylink); in ngbe_probe()
704 kfree(wx->mac_table); in ngbe_probe()
714 * ngbe_remove - Device Removal Routine
719 * Hot-Plug event, or because the driver is going to be removed from
727 netdev = wx->netdev; in ngbe_remove()
729 phylink_destroy(wx->phylink); in ngbe_remove()
733 kfree(wx->rss_key); in ngbe_remove()
734 kfree(wx->mac_table); in ngbe_remove()
745 device_set_wakeup_enable(&pdev->dev, wake); in ngbe_suspend()
757 netdev = wx->netdev; in ngbe_resume()
765 device_wakeup_disable(&pdev->dev); in ngbe_resume()
792 MODULE_AUTHOR("Beijing WangXun Technology Co., Ltd, <software@net-swift.com>");