Lines Matching refs:wx
50 static void ngbe_init_type_code(struct wx *wx) in ngbe_init_type_code() argument
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()
60 val = rd32(wx, WX_CFG_PORT_ST); 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()
88 static inline int ngbe_init_rss_key(struct wx *wx) in ngbe_init_rss_key() argument
92 if (!wx->rss_key) { in ngbe_init_rss_key()
98 wx->rss_key = rss_key; in ngbe_init_rss_key()
108 static int ngbe_sw_init(struct wx *wx) in ngbe_sw_init() argument
110 struct pci_dev *pdev = wx->pdev; in ngbe_sw_init()
114 wx->mac.num_rar_entries = NGBE_RAR_ENTRIES; in ngbe_sw_init()
115 wx->mac.max_rx_queues = NGBE_MAX_RX_QUEUES; in ngbe_sw_init()
116 wx->mac.max_tx_queues = NGBE_MAX_TX_QUEUES; in ngbe_sw_init()
117 wx->mac.mcft_size = NGBE_MC_TBL_SIZE; in ngbe_sw_init()
118 wx->mac.vft_size = NGBE_SP_VFT_TBL_SIZE; in ngbe_sw_init()
119 wx->mac.rx_pb_size = NGBE_RX_PB_SIZE; in ngbe_sw_init()
120 wx->mac.tx_pb_size = NGBE_TDB_PB_SZ; in ngbe_sw_init()
123 err = wx_sw_init(wx); in ngbe_sw_init()
128 ngbe_init_type_code(wx); in ngbe_sw_init()
131 wx->max_q_vectors = NGBE_MAX_MSIX_VECTORS; in ngbe_sw_init()
132 err = wx_get_pcie_msix_counts(wx, &msix_count, NGBE_MAX_MSIX_VECTORS); in ngbe_sw_init()
135 wx->mac.max_msix_vectors = msix_count; in ngbe_sw_init()
137 if (ngbe_init_rss_key(wx)) in ngbe_sw_init()
141 wx->rx_itr_setting = 1; in ngbe_sw_init()
142 wx->tx_itr_setting = 1; in ngbe_sw_init()
145 wx->tx_ring_count = NGBE_DEFAULT_TXD; in ngbe_sw_init()
146 wx->rx_ring_count = NGBE_DEFAULT_RXD; in ngbe_sw_init()
149 wx->tx_work_limit = NGBE_DEFAULT_TX_WORK; in ngbe_sw_init()
150 wx->rx_work_limit = NGBE_DEFAULT_RX_WORK; in ngbe_sw_init()
160 static void ngbe_irq_enable(struct wx *wx, bool queues) in ngbe_irq_enable() argument
167 wr32(wx, WX_GPIO_DDR, WX_GPIO_DDR_0); in ngbe_irq_enable()
168 wr32(wx, WX_GPIO_INTEN, WX_GPIO_INTEN_0 | WX_GPIO_INTEN_1); in ngbe_irq_enable()
169 wr32(wx, WX_GPIO_INTTYPE_LEVEL, 0x0); in ngbe_irq_enable()
170 wr32(wx, WX_GPIO_POLARITY, wx->gpio_ctrl ? 0 : 0x3); in ngbe_irq_enable()
172 wr32(wx, WX_PX_MISC_IEN, mask); in ngbe_irq_enable()
176 wx_intr_enable(wx, NGBE_INTR_ALL); in ngbe_irq_enable()
178 wx_intr_enable(wx, NGBE_INTR_MISC(wx)); in ngbe_irq_enable()
189 struct wx *wx = data; in ngbe_intr() local
193 q_vector = wx->q_vector[0]; in ngbe_intr()
194 pdev = wx->pdev; in ngbe_intr()
196 eicr = wx_misc_isb(wx, WX_ISB_VEC0); in ngbe_intr()
201 if (netif_running(wx->netdev)) in ngbe_intr()
202 ngbe_irq_enable(wx, true); in ngbe_intr()
205 wx->isb_mem[WX_ISB_VEC0] = 0; in ngbe_intr()
207 wr32(wx, WX_PX_INTA, 1); in ngbe_intr()
209 wx->isb_mem[WX_ISB_MISC] = 0; in ngbe_intr()
213 if (netif_running(wx->netdev)) in ngbe_intr()
214 ngbe_irq_enable(wx, false); in ngbe_intr()
221 struct wx *wx = data; in ngbe_msix_other() local
224 if (netif_running(wx->netdev)) in ngbe_msix_other()
225 ngbe_irq_enable(wx, false); in ngbe_msix_other()
237 static int ngbe_request_msix_irqs(struct wx *wx) in ngbe_request_msix_irqs() argument
239 struct net_device *netdev = wx->netdev; in ngbe_request_msix_irqs()
242 for (vector = 0; vector < wx->num_q_vectors; vector++) { in ngbe_request_msix_irqs()
243 struct wx_q_vector *q_vector = wx->q_vector[vector]; in ngbe_request_msix_irqs()
244 struct msix_entry *entry = &wx->msix_entries[vector]; in ngbe_request_msix_irqs()
256 wx_err(wx, "request_irq failed for MSIX interrupt %s Error: %d\n", in ngbe_request_msix_irqs()
262 err = request_irq(wx->msix_entries[vector].vector, in ngbe_request_msix_irqs()
263 ngbe_msix_other, 0, netdev->name, wx); in ngbe_request_msix_irqs()
266 wx_err(wx, "request_irq for msix_other failed: %d\n", err); in ngbe_request_msix_irqs()
275 free_irq(wx->msix_entries[vector].vector, in ngbe_request_msix_irqs()
276 wx->q_vector[vector]); in ngbe_request_msix_irqs()
278 wx_reset_interrupt_capability(wx); in ngbe_request_msix_irqs()
289 static int ngbe_request_irq(struct wx *wx) in ngbe_request_irq() argument
291 struct net_device *netdev = wx->netdev; in ngbe_request_irq()
292 struct pci_dev *pdev = wx->pdev; in ngbe_request_irq()
296 err = ngbe_request_msix_irqs(wx); in ngbe_request_irq()
299 netdev->name, wx); in ngbe_request_irq()
302 netdev->name, wx); in ngbe_request_irq()
305 wx_err(wx, "request_irq failed, Error %d\n", err); in ngbe_request_irq()
310 static void ngbe_disable_device(struct wx *wx) in ngbe_disable_device() argument
312 struct net_device *netdev = wx->netdev; in ngbe_disable_device()
316 for (i = 0; i < wx->num_rx_queues; i++) in ngbe_disable_device()
318 wx_disable_rx_queue(wx, wx->rx_ring[i]); in ngbe_disable_device()
320 wx_disable_rx(wx); in ngbe_disable_device()
321 wx_napi_disable_all(wx); in ngbe_disable_device()
324 if (wx->gpio_ctrl) in ngbe_disable_device()
325 ngbe_sfp_modules_txrx_powerctl(wx, false); in ngbe_disable_device()
326 wx_irq_disable(wx); in ngbe_disable_device()
328 for (i = 0; i < wx->num_tx_queues; i++) { in ngbe_disable_device()
329 u8 reg_idx = wx->tx_ring[i]->reg_idx; in ngbe_disable_device()
331 wr32(wx, WX_PX_TR_CFG(reg_idx), WX_PX_TR_CFG_SWFLSH); in ngbe_disable_device()
335 static void ngbe_down(struct wx *wx) in ngbe_down() argument
337 phy_stop(wx->phydev); in ngbe_down()
338 ngbe_disable_device(wx); in ngbe_down()
339 wx_clean_all_tx_rings(wx); in ngbe_down()
340 wx_clean_all_rx_rings(wx); in ngbe_down()
343 static void ngbe_up(struct wx *wx) in ngbe_up() argument
345 wx_configure_vectors(wx); in ngbe_up()
349 wx_napi_enable_all(wx); in ngbe_up()
351 netif_tx_start_all_queues(wx->netdev); in ngbe_up()
354 rd32(wx, WX_PX_IC(0)); in ngbe_up()
355 rd32(wx, WX_PX_MISC_IC); in ngbe_up()
356 ngbe_irq_enable(wx, true); in ngbe_up()
357 if (wx->gpio_ctrl) in ngbe_up()
358 ngbe_sfp_modules_txrx_powerctl(wx, true); in ngbe_up()
360 phy_start(wx->phydev); in ngbe_up()
374 struct wx *wx = netdev_priv(netdev); in ngbe_open() local
377 wx_control_hw(wx, true); in ngbe_open()
379 err = wx_setup_resources(wx); in ngbe_open()
383 wx_configure(wx); in ngbe_open()
385 err = ngbe_request_irq(wx); in ngbe_open()
389 err = ngbe_phy_connect(wx); in ngbe_open()
393 err = netif_set_real_num_tx_queues(netdev, wx->num_tx_queues); in ngbe_open()
397 err = netif_set_real_num_rx_queues(netdev, wx->num_rx_queues); in ngbe_open()
401 ngbe_up(wx); in ngbe_open()
405 phy_disconnect(wx->phydev); in ngbe_open()
407 wx_free_irq(wx); in ngbe_open()
409 wx_free_resources(wx); in ngbe_open()
426 struct wx *wx = netdev_priv(netdev); in ngbe_close() local
428 ngbe_down(wx); in ngbe_close()
429 wx_free_irq(wx); in ngbe_close()
430 wx_free_resources(wx); in ngbe_close()
431 phy_disconnect(wx->phydev); in ngbe_close()
432 wx_control_hw(wx, false); in ngbe_close()
439 struct wx *wx = pci_get_drvdata(pdev); in ngbe_dev_shutdown() local
441 u32 wufc = wx->wol; in ngbe_dev_shutdown()
443 netdev = wx->netdev; in ngbe_dev_shutdown()
449 wx_clear_interrupt_scheme(wx); in ngbe_dev_shutdown()
454 wx_configure_rx(wx); in ngbe_dev_shutdown()
455 wr32(wx, NGBE_PSR_WKUP_CTL, wufc); in ngbe_dev_shutdown()
457 wr32(wx, NGBE_PSR_WKUP_CTL, 0); in ngbe_dev_shutdown()
461 wx_control_hw(wx, false); in ngbe_dev_shutdown()
468 struct wx *wx = pci_get_drvdata(pdev); in ngbe_shutdown() local
471 wake = !!wx->wol; in ngbe_shutdown()
511 struct wx *wx = NULL; in ngbe_probe() local
541 sizeof(struct wx), in ngbe_probe()
551 wx = netdev_priv(netdev); in ngbe_probe()
552 wx->netdev = netdev; in ngbe_probe()
553 wx->pdev = pdev; in ngbe_probe()
554 wx->msg_enable = BIT(3) - 1; in ngbe_probe()
556 wx->hw_addr = devm_ioremap(&pdev->dev, in ngbe_probe()
559 if (!wx->hw_addr) { in ngbe_probe()
564 wx->driver_name = ngbe_driver_name; in ngbe_probe()
588 wx->bd_number = func_nums; in ngbe_probe()
590 err = ngbe_sw_init(wx); in ngbe_probe()
595 err = wx_check_flash_load(wx, NGBE_SPI_ILDR_STATUS_PERST); in ngbe_probe()
598 err = wx_check_flash_load(wx, NGBE_SPI_ILDR_STATUS_PWRRST); in ngbe_probe()
602 err = wx_mng_present(wx); in ngbe_probe()
608 err = ngbe_reset_hw(wx); in ngbe_probe()
614 if (wx->bus.func == 0) { in ngbe_probe()
615 wr32(wx, NGBE_CALSUM_CAP_STATUS, 0x0); in ngbe_probe()
616 wr32(wx, NGBE_EEPROM_VERSION_STORE_REG, 0x0); in ngbe_probe()
618 e2rom_cksum_cap = rd32(wx, NGBE_CALSUM_CAP_STATUS); in ngbe_probe()
619 saved_ver = rd32(wx, NGBE_EEPROM_VERSION_STORE_REG); in ngbe_probe()
622 wx_init_eeprom_params(wx); in ngbe_probe()
623 if (wx->bus.func == 0 || e2rom_cksum_cap == 0) { in ngbe_probe()
625 err = ngbe_eeprom_chksum_hostif(wx); in ngbe_probe()
633 wx->wol = 0; in ngbe_probe()
634 if (wx->wol_hw_supported) in ngbe_probe()
635 wx->wol = NGBE_PSR_WKUP_CTL_MAG; in ngbe_probe()
637 netdev->wol_enabled = !!(wx->wol); in ngbe_probe()
638 wr32(wx, NGBE_PSR_WKUP_CTL, wx->wol); in ngbe_probe()
639 device_set_wakeup_enable(&pdev->dev, wx->wol); in ngbe_probe()
647 wx_read_ee_hostif(wx, in ngbe_probe()
648 wx->eeprom.sw_region_offset + NGBE_EEPROM_VERSION_H, in ngbe_probe()
651 wx_read_ee_hostif(wx, in ngbe_probe()
652 wx->eeprom.sw_region_offset + NGBE_EEPROM_VERSION_L, in ngbe_probe()
655 wr32(wx, NGBE_EEPROM_VERSION_STORE_REG, etrack_id); in ngbe_probe()
657 snprintf(wx->eeprom_id, sizeof(wx->eeprom_id), in ngbe_probe()
660 eth_hw_addr_set(netdev, wx->mac.perm_addr); in ngbe_probe()
661 wx_mac_set_default_filter(wx, wx->mac.perm_addr); in ngbe_probe()
663 err = wx_init_interrupt_scheme(wx); in ngbe_probe()
668 err = ngbe_mdio_init(wx); in ngbe_probe()
676 pci_set_drvdata(pdev, wx); in ngbe_probe()
678 netif_info(wx, probe, netdev, in ngbe_probe()
680 wx->mac_type == em_mac_type_mdi ? "Internal" : "External"); in ngbe_probe()
681 netif_info(wx, probe, netdev, "%pM\n", netdev->dev_addr); in ngbe_probe()
686 wx_control_hw(wx, false); in ngbe_probe()
688 wx_clear_interrupt_scheme(wx); in ngbe_probe()
690 kfree(wx->mac_table); in ngbe_probe()
710 struct wx *wx = pci_get_drvdata(pdev); in ngbe_remove() local
713 netdev = wx->netdev; in ngbe_remove()
718 kfree(wx->mac_table); in ngbe_remove()
719 wx_clear_interrupt_scheme(wx); in ngbe_remove()
737 struct wx *wx; in ngbe_resume() local
740 wx = pci_get_drvdata(pdev); in ngbe_resume()
741 netdev = wx->netdev; in ngbe_resume()
745 wx_err(wx, "Cannot enable PCI device from suspend\n"); in ngbe_resume()
751 ngbe_reset_hw(wx); in ngbe_resume()
753 err = wx_init_interrupt_scheme(wx); in ngbe_resume()