Lines Matching +full:pcie +full:- +full:mac

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2013 - 2019 Intel Corporation. */
16 * fm10k_pci_tbl - PCI Device ID Table
36 struct fm10k_intfc *interface = hw->back; in fm10k_read_pci_cfg_word()
39 if (FM10K_REMOVED(hw->hw_addr)) in fm10k_read_pci_cfg_word()
42 pci_read_config_word(interface->pdev, reg, &value); in fm10k_read_pci_cfg_word()
51 u32 __iomem *hw_addr = READ_ONCE(hw->hw_addr); in fm10k_read_reg()
59 struct fm10k_intfc *interface = hw->back; in fm10k_read_reg()
60 struct net_device *netdev = interface->netdev; in fm10k_read_reg()
62 hw->hw_addr = NULL; in fm10k_read_reg()
64 netdev_err(netdev, "PCIe link lost, device now detached\n"); in fm10k_read_reg()
72 struct fm10k_hw *hw = &interface->hw; in fm10k_hw_ready()
76 return FM10K_REMOVED(hw->hw_addr) ? -ENODEV : 0; in fm10k_hw_ready()
80 * fm10k_macvlan_schedule - Schedule MAC/VLAN queue task
83 * Schedule the MAC/VLAN queue monitor task. If the MAC/VLAN task cannot be
88 /* Avoid processing the MAC/VLAN queue when the service task is in fm10k_macvlan_schedule()
91 if (!test_bit(__FM10K_MACVLAN_DISABLE, interface->state) && in fm10k_macvlan_schedule()
92 !test_and_set_bit(__FM10K_MACVLAN_SCHED, interface->state)) { in fm10k_macvlan_schedule()
93 clear_bit(__FM10K_MACVLAN_REQUEST, interface->state); in fm10k_macvlan_schedule()
95 * multiple MAC/VLAN updates to accumulate before handling in fm10k_macvlan_schedule()
100 &interface->macvlan_task, 10); in fm10k_macvlan_schedule()
102 set_bit(__FM10K_MACVLAN_REQUEST, interface->state); in fm10k_macvlan_schedule()
107 * fm10k_stop_macvlan_task - Stop the MAC/VLAN queue monitor
110 * Wait until the MAC/VLAN queue task has stopped, and cancel any future
115 /* Disable the MAC/VLAN work item */ in fm10k_stop_macvlan_task()
116 set_bit(__FM10K_MACVLAN_DISABLE, interface->state); in fm10k_stop_macvlan_task()
119 cancel_delayed_work_sync(&interface->macvlan_task); in fm10k_stop_macvlan_task()
122 * However, it may not be unset of the MAC/VLAN task never actually in fm10k_stop_macvlan_task()
127 clear_bit(__FM10K_MACVLAN_SCHED, interface->state); in fm10k_stop_macvlan_task()
131 * fm10k_resume_macvlan_task - Restart the MAC/VLAN queue monitor
135 * the MAC/VLAN work monitor.
139 /* Re-enable the MAC/VLAN work item */ in fm10k_resume_macvlan_task()
140 clear_bit(__FM10K_MACVLAN_DISABLE, interface->state); in fm10k_resume_macvlan_task()
142 /* We might have received a MAC/VLAN request while disabled. If so, in fm10k_resume_macvlan_task()
145 if (test_bit(__FM10K_MACVLAN_REQUEST, interface->state)) in fm10k_resume_macvlan_task()
151 if (!test_bit(__FM10K_SERVICE_DISABLE, interface->state) && in fm10k_service_event_schedule()
152 !test_and_set_bit(__FM10K_SERVICE_SCHED, interface->state)) { in fm10k_service_event_schedule()
153 clear_bit(__FM10K_SERVICE_REQUEST, interface->state); in fm10k_service_event_schedule()
154 queue_work(fm10k_workqueue, &interface->service_task); in fm10k_service_event_schedule()
156 set_bit(__FM10K_SERVICE_REQUEST, interface->state); in fm10k_service_event_schedule()
162 WARN_ON(!test_bit(__FM10K_SERVICE_SCHED, interface->state)); in fm10k_service_event_complete()
166 clear_bit(__FM10K_SERVICE_SCHED, interface->state); in fm10k_service_event_complete()
169 * re-schedule now. This ensures we don't drop a request until the in fm10k_service_event_complete()
172 if (test_bit(__FM10K_SERVICE_REQUEST, interface->state)) in fm10k_service_event_complete()
178 set_bit(__FM10K_SERVICE_DISABLE, interface->state); in fm10k_stop_service_event()
179 cancel_work_sync(&interface->service_task); in fm10k_stop_service_event()
188 clear_bit(__FM10K_SERVICE_SCHED, interface->state); in fm10k_stop_service_event()
193 clear_bit(__FM10K_SERVICE_DISABLE, interface->state); in fm10k_start_service_event()
198 * fm10k_service_timer - Timer Call-back
207 mod_timer(&interface->service_timer, (HZ * 2) + jiffies); in fm10k_service_timer()
213 * fm10k_prepare_for_reset - Prepare the driver and device for a pending reset
222 struct net_device *netdev = interface->netdev; in fm10k_prepare_for_reset()
228 if (test_and_set_bit(__FM10K_RESETTING, interface->state)) in fm10k_prepare_for_reset()
231 /* As the MAC/VLAN task will be accessing registers it must not be in fm10k_prepare_for_reset()
239 fm10k_iov_suspend(interface->pdev); in fm10k_prepare_for_reset()
250 interface->last_reset = jiffies + (10 * HZ); in fm10k_prepare_for_reset()
259 struct net_device *netdev = interface->netdev; in fm10k_handle_reset()
260 struct fm10k_hw *hw = &interface->hw; in fm10k_handle_reset()
263 WARN_ON(!test_bit(__FM10K_RESETTING, interface->state)); in fm10k_handle_reset()
267 pci_set_master(interface->pdev); in fm10k_handle_reset()
270 err = hw->mac.ops.reset_hw(hw); in fm10k_handle_reset()
272 dev_err(&interface->pdev->dev, "reset_hw failed: %d\n", err); in fm10k_handle_reset()
276 err = hw->mac.ops.init_hw(hw); in fm10k_handle_reset()
278 dev_err(&interface->pdev->dev, "init_hw failed: %d\n", err); in fm10k_handle_reset()
284 dev_err(&interface->pdev->dev, in fm10k_handle_reset()
289 /* re-associate interrupts */ in fm10k_handle_reset()
299 if (hw->mac.type == fm10k_mac_vf) { in fm10k_handle_reset()
300 if (is_valid_ether_addr(hw->mac.perm_addr)) { in fm10k_handle_reset()
301 ether_addr_copy(hw->mac.addr, hw->mac.perm_addr); in fm10k_handle_reset()
302 ether_addr_copy(netdev->perm_addr, hw->mac.perm_addr); in fm10k_handle_reset()
303 eth_hw_addr_set(netdev, hw->mac.perm_addr); in fm10k_handle_reset()
304 netdev->addr_assign_type &= ~NET_ADDR_RANDOM; in fm10k_handle_reset()
307 if (hw->mac.vlan_override) in fm10k_handle_reset()
308 netdev->features &= ~NETIF_F_HW_VLAN_CTAG_RX; in fm10k_handle_reset()
310 netdev->features |= NETIF_F_HW_VLAN_CTAG_RX; in fm10k_handle_reset()
317 fm10k_iov_resume(interface->pdev); in fm10k_handle_reset()
323 clear_bit(__FM10K_RESETTING, interface->state); in fm10k_handle_reset()
335 clear_bit(__FM10K_RESETTING, interface->state); in fm10k_handle_reset()
342 struct net_device *netdev = interface->netdev; in fm10k_detach_subtask()
347 if (netif_device_present(netdev) || interface->hw.hw_addr) in fm10k_detach_subtask()
350 /* We've lost the PCIe register space, and can no longer access the in fm10k_detach_subtask()
356 set_bit(__FM10K_RESET_DETACHED, interface->state); in fm10k_detach_subtask()
359 hw_addr = READ_ONCE(interface->uc_addr); in fm10k_detach_subtask()
368 interface->state)) in fm10k_detach_subtask()
372 interface->hw.hw_addr = interface->uc_addr; in fm10k_detach_subtask()
374 /* PCIe link has been restored, and the device is active in fm10k_detach_subtask()
380 interface->hw.hw_addr = NULL; in fm10k_detach_subtask()
384 /* Re-attach the netdev */ in fm10k_detach_subtask()
386 netdev_warn(netdev, "PCIe link restored, device now attached\n"); in fm10k_detach_subtask()
396 interface->flags)) in fm10k_reset_subtask()
402 * PCIe link is lost. In this case, we'll just ignore the RESET in fm10k_reset_subtask()
409 netdev_err(interface->netdev, "Reset interface\n"); in fm10k_reset_subtask()
413 dev_err(&interface->pdev->dev, in fm10k_reset_subtask()
418 * fm10k_configure_swpri_map - Configure Receive SWPRI to PC mapping
425 struct net_device *netdev = interface->netdev; in fm10k_configure_swpri_map()
426 struct fm10k_hw *hw = &interface->hw; in fm10k_configure_swpri_map()
430 clear_bit(FM10K_FLAG_SWPRI_CONFIG, interface->flags); in fm10k_configure_swpri_map()
433 if (hw->mac.type != fm10k_mac_pf) in fm10k_configure_swpri_map()
443 * fm10k_watchdog_update_host_state - Update the link status based on host.
448 struct fm10k_hw *hw = &interface->hw; in fm10k_watchdog_update_host_state()
451 if (test_bit(__FM10K_LINK_DOWN, interface->state)) { in fm10k_watchdog_update_host_state()
452 interface->host_ready = false; in fm10k_watchdog_update_host_state()
453 if (time_is_after_jiffies(interface->link_down_event)) in fm10k_watchdog_update_host_state()
455 clear_bit(__FM10K_LINK_DOWN, interface->state); in fm10k_watchdog_update_host_state()
458 if (test_bit(FM10K_FLAG_SWPRI_CONFIG, interface->flags)) { in fm10k_watchdog_update_host_state()
468 err = hw->mac.ops.get_host_state(hw, &interface->host_ready); in fm10k_watchdog_update_host_state()
469 if (err && time_is_before_jiffies(interface->last_reset)) in fm10k_watchdog_update_host_state()
470 set_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags); in fm10k_watchdog_update_host_state()
477 * fm10k_mbx_subtask - Process upstream and downstream mailboxes
485 if (test_bit(__FM10K_RESETTING, interface->state)) in fm10k_mbx_subtask()
496 * fm10k_watchdog_host_is_ready - Update netdev status based on host ready
501 struct net_device *netdev = interface->netdev; in fm10k_watchdog_host_is_ready()
514 * fm10k_watchdog_host_not_ready - Update netdev status based on host not ready
519 struct net_device *netdev = interface->netdev; in fm10k_watchdog_host_not_ready()
532 * fm10k_update_stats - Update the board statistics counters.
537 struct net_device_stats *net_stats = &interface->netdev->stats; in fm10k_update_stats()
538 struct fm10k_hw *hw = &interface->hw; in fm10k_update_stats()
550 if (test_and_set_bit(__FM10K_UPDATING_STATS, interface->state)) in fm10k_update_stats()
554 interface->next_stats_update = jiffies + HZ; in fm10k_update_stats()
557 for (bytes = 0, pkts = 0, i = 0; i < interface->num_tx_queues; i++) { in fm10k_update_stats()
558 struct fm10k_ring *tx_ring = READ_ONCE(interface->tx_ring[i]); in fm10k_update_stats()
563 restart_queue += tx_ring->tx_stats.restart_queue; in fm10k_update_stats()
564 tx_busy += tx_ring->tx_stats.tx_busy; in fm10k_update_stats()
565 tx_csum_errors += tx_ring->tx_stats.csum_err; in fm10k_update_stats()
566 bytes += tx_ring->stats.bytes; in fm10k_update_stats()
567 pkts += tx_ring->stats.packets; in fm10k_update_stats()
568 hw_csum_tx_good += tx_ring->tx_stats.csum_good; in fm10k_update_stats()
571 interface->restart_queue = restart_queue; in fm10k_update_stats()
572 interface->tx_busy = tx_busy; in fm10k_update_stats()
573 net_stats->tx_bytes = bytes; in fm10k_update_stats()
574 net_stats->tx_packets = pkts; in fm10k_update_stats()
575 interface->tx_csum_errors = tx_csum_errors; in fm10k_update_stats()
576 interface->hw_csum_tx_good = hw_csum_tx_good; in fm10k_update_stats()
579 for (bytes = 0, pkts = 0, i = 0; i < interface->num_rx_queues; i++) { in fm10k_update_stats()
580 struct fm10k_ring *rx_ring = READ_ONCE(interface->rx_ring[i]); in fm10k_update_stats()
585 bytes += rx_ring->stats.bytes; in fm10k_update_stats()
586 pkts += rx_ring->stats.packets; in fm10k_update_stats()
587 alloc_failed += rx_ring->rx_stats.alloc_failed; in fm10k_update_stats()
588 rx_csum_errors += rx_ring->rx_stats.csum_err; in fm10k_update_stats()
589 rx_errors += rx_ring->rx_stats.errors; in fm10k_update_stats()
590 hw_csum_rx_good += rx_ring->rx_stats.csum_good; in fm10k_update_stats()
591 rx_switch_errors += rx_ring->rx_stats.switch_errors; in fm10k_update_stats()
592 rx_drops += rx_ring->rx_stats.drops; in fm10k_update_stats()
593 rx_pp_errors += rx_ring->rx_stats.pp_errors; in fm10k_update_stats()
594 rx_link_errors += rx_ring->rx_stats.link_errors; in fm10k_update_stats()
595 rx_length_errors += rx_ring->rx_stats.length_errors; in fm10k_update_stats()
598 net_stats->rx_bytes = bytes; in fm10k_update_stats()
599 net_stats->rx_packets = pkts; in fm10k_update_stats()
600 interface->alloc_failed = alloc_failed; in fm10k_update_stats()
601 interface->rx_csum_errors = rx_csum_errors; in fm10k_update_stats()
602 interface->hw_csum_rx_good = hw_csum_rx_good; in fm10k_update_stats()
603 interface->rx_switch_errors = rx_switch_errors; in fm10k_update_stats()
604 interface->rx_drops = rx_drops; in fm10k_update_stats()
605 interface->rx_pp_errors = rx_pp_errors; in fm10k_update_stats()
606 interface->rx_link_errors = rx_link_errors; in fm10k_update_stats()
607 interface->rx_length_errors = rx_length_errors; in fm10k_update_stats()
609 hw->mac.ops.update_hw_stats(hw, &interface->stats); in fm10k_update_stats()
611 for (i = 0; i < hw->mac.max_queues; i++) { in fm10k_update_stats()
612 struct fm10k_hw_stats_q *q = &interface->stats.q[i]; in fm10k_update_stats()
614 tx_bytes_nic += q->tx_bytes.count; in fm10k_update_stats()
615 tx_pkts_nic += q->tx_packets.count; in fm10k_update_stats()
616 rx_bytes_nic += q->rx_bytes.count; in fm10k_update_stats()
617 rx_pkts_nic += q->rx_packets.count; in fm10k_update_stats()
618 rx_drops_nic += q->rx_drops.count; in fm10k_update_stats()
621 interface->tx_bytes_nic = tx_bytes_nic; in fm10k_update_stats()
622 interface->tx_packets_nic = tx_pkts_nic; in fm10k_update_stats()
623 interface->rx_bytes_nic = rx_bytes_nic; in fm10k_update_stats()
624 interface->rx_packets_nic = rx_pkts_nic; in fm10k_update_stats()
625 interface->rx_drops_nic = rx_drops_nic; in fm10k_update_stats()
628 net_stats->rx_errors = rx_errors; in fm10k_update_stats()
629 net_stats->rx_dropped = interface->stats.nodesc_drop.count; in fm10k_update_stats()
634 clear_bit(__FM10K_UPDATING_STATS, interface->state); in fm10k_update_stats()
638 * fm10k_watchdog_flush_tx - flush queues on host not ready
647 if (netif_carrier_ok(interface->netdev)) in fm10k_watchdog_flush_tx()
650 for (i = 0; i < interface->num_tx_queues; i++) { in fm10k_watchdog_flush_tx()
651 struct fm10k_ring *tx_ring = interface->tx_ring[i]; in fm10k_watchdog_flush_tx()
653 if (tx_ring->next_to_use != tx_ring->next_to_clean) { in fm10k_watchdog_flush_tx()
664 set_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags); in fm10k_watchdog_flush_tx()
668 * fm10k_watchdog_subtask - check and bring link up
674 if (test_bit(__FM10K_DOWN, interface->state) || in fm10k_watchdog_subtask()
675 test_bit(__FM10K_RESETTING, interface->state)) in fm10k_watchdog_subtask()
678 if (interface->host_ready) in fm10k_watchdog_subtask()
684 if (time_is_before_jiffies(interface->next_stats_update)) in fm10k_watchdog_subtask()
692 * fm10k_check_hang_subtask - check for hung queues and dropped interrupts
703 if (test_bit(__FM10K_DOWN, interface->state) || in fm10k_check_hang_subtask()
704 test_bit(__FM10K_RESETTING, interface->state)) in fm10k_check_hang_subtask()
708 if (time_is_after_eq_jiffies(interface->next_tx_hang_check)) in fm10k_check_hang_subtask()
710 interface->next_tx_hang_check = jiffies + (2 * HZ); in fm10k_check_hang_subtask()
712 if (netif_carrier_ok(interface->netdev)) { in fm10k_check_hang_subtask()
716 for (i = 0; i < interface->num_tx_queues; i++) in fm10k_check_hang_subtask()
717 set_check_for_tx_hang(interface->tx_ring[i]); in fm10k_check_hang_subtask()
719 /* Rearm all in-use q_vectors for immediate firing */ in fm10k_check_hang_subtask()
720 for (i = 0; i < interface->num_q_vectors; i++) { in fm10k_check_hang_subtask()
721 struct fm10k_q_vector *qv = interface->q_vector[i]; in fm10k_check_hang_subtask()
723 if (!qv->tx.count && !qv->rx.count) in fm10k_check_hang_subtask()
725 writel(FM10K_ITR_ENABLE | FM10K_ITR_PENDING2, qv->itr); in fm10k_check_hang_subtask()
731 * fm10k_service_task - manages and runs subtasks
756 * fm10k_macvlan_task - send queued MAC/VLAN requests to switch manager
759 * This work item handles sending MAC/VLAN updates to the switch manager. When
761 * switch manager requesting updates for MAC/VLAN pairs. If the Tx fifo of the
777 hw = &interface->hw; in fm10k_macvlan_task()
778 requests = &interface->macvlan_requests; in fm10k_macvlan_task()
782 spin_lock_irqsave(&interface->macvlan_lock, flags); in fm10k_macvlan_task()
787 list_del_init(&item->list); in fm10k_macvlan_task()
789 spin_unlock_irqrestore(&interface->macvlan_lock, flags); in fm10k_macvlan_task()
802 if (!hw->mbx.ops.tx_ready(&hw->mbx, FM10K_VFMBX_MSG_MTU + 5)) { in fm10k_macvlan_task()
803 hw->mbx.ops.process(hw, &hw->mbx); in fm10k_macvlan_task()
804 set_bit(__FM10K_MACVLAN_REQUEST, interface->state); in fm10k_macvlan_task()
808 spin_lock_irqsave(&interface->macvlan_lock, flags); in fm10k_macvlan_task()
809 list_add(&item->list, requests); in fm10k_macvlan_task()
810 spin_unlock_irqrestore(&interface->macvlan_lock, flags); in fm10k_macvlan_task()
814 switch (item->type) { in fm10k_macvlan_task()
816 hw->mac.ops.update_mc_addr(hw, in fm10k_macvlan_task()
817 item->mac.glort, in fm10k_macvlan_task()
818 item->mac.addr, in fm10k_macvlan_task()
819 item->mac.vid, in fm10k_macvlan_task()
820 item->set); in fm10k_macvlan_task()
823 hw->mac.ops.update_uc_addr(hw, in fm10k_macvlan_task()
824 item->mac.glort, in fm10k_macvlan_task()
825 item->mac.addr, in fm10k_macvlan_task()
826 item->mac.vid, in fm10k_macvlan_task()
827 item->set, in fm10k_macvlan_task()
831 hw->mac.ops.update_vlan(hw, in fm10k_macvlan_task()
832 item->vlan.vid, in fm10k_macvlan_task()
833 item->vlan.vsi, in fm10k_macvlan_task()
834 item->set); in fm10k_macvlan_task()
847 WARN_ON(!test_bit(__FM10K_MACVLAN_SCHED, interface->state)); in fm10k_macvlan_task()
851 clear_bit(__FM10K_MACVLAN_SCHED, interface->state); in fm10k_macvlan_task()
853 /* If a MAC/VLAN request was scheduled since we started, we should in fm10k_macvlan_task()
854 * re-schedule. However, there is no reason to re-schedule if there is in fm10k_macvlan_task()
857 if (test_bit(__FM10K_MACVLAN_REQUEST, interface->state)) in fm10k_macvlan_task()
862 * fm10k_configure_tx_ring - Configure Tx ring after Reset
871 struct fm10k_hw *hw = &interface->hw; in fm10k_configure_tx_ring()
872 u64 tdba = ring->dma; in fm10k_configure_tx_ring()
873 u32 size = ring->count * sizeof(struct fm10k_tx_desc); in fm10k_configure_tx_ring()
876 u8 reg_idx = ring->reg_idx; in fm10k_configure_tx_ring()
894 ring->tail = &interface->uc_addr[FM10K_TDT(reg_idx)]; in fm10k_configure_tx_ring()
897 ring->next_to_clean = 0; in fm10k_configure_tx_ring()
898 ring->next_to_use = 0; in fm10k_configure_tx_ring()
901 if (ring->q_vector) { in fm10k_configure_tx_ring()
902 txint = ring->q_vector->v_idx + NON_Q_VECTORS; in fm10k_configure_tx_ring()
913 if (!test_and_set_bit(__FM10K_TX_XPS_INIT_DONE, ring->state) && in fm10k_configure_tx_ring()
914 ring->q_vector) in fm10k_configure_tx_ring()
915 netif_set_xps_queue(ring->netdev, in fm10k_configure_tx_ring()
916 &ring->q_vector->affinity_mask, in fm10k_configure_tx_ring()
917 ring->queue_index); in fm10k_configure_tx_ring()
924 * fm10k_enable_tx_ring - Verify Tx ring is enabled after configuration
933 struct fm10k_hw *hw = &interface->hw; in fm10k_enable_tx_ring()
936 u8 reg_idx = ring->reg_idx; in fm10k_enable_tx_ring()
946 } while (!(txdctl & FM10K_TXDCTL_ENABLE) && --wait_loop); in fm10k_enable_tx_ring()
948 netif_err(interface, drv, interface->netdev, in fm10k_enable_tx_ring()
953 * fm10k_configure_tx - Configure Transmit Unit after Reset
956 * Configure the Tx unit of the MAC after a reset.
963 for (i = 0; i < interface->num_tx_queues; i++) in fm10k_configure_tx()
964 fm10k_configure_tx_ring(interface, interface->tx_ring[i]); in fm10k_configure_tx()
967 for (i = 0; i < interface->num_tx_queues; i++) in fm10k_configure_tx()
968 fm10k_enable_tx_ring(interface, interface->tx_ring[i]); in fm10k_configure_tx()
972 * fm10k_configure_rx_ring - Configure Rx ring after Reset
981 u64 rdba = ring->dma; in fm10k_configure_rx_ring()
982 struct fm10k_hw *hw = &interface->hw; in fm10k_configure_rx_ring()
983 u32 size = ring->count * sizeof(union fm10k_rx_desc); in fm10k_configure_rx_ring()
987 u8 rx_pause = interface->rx_pause; in fm10k_configure_rx_ring()
988 u8 reg_idx = ring->reg_idx; in fm10k_configure_rx_ring()
1008 ring->tail = &interface->uc_addr[FM10K_RDT(reg_idx)]; in fm10k_configure_rx_ring()
1011 ring->next_to_clean = 0; in fm10k_configure_rx_ring()
1012 ring->next_to_use = 0; in fm10k_configure_rx_ring()
1013 ring->next_to_alloc = 0; in fm10k_configure_rx_ring()
1024 if (interface->pfc_en) in fm10k_configure_rx_ring()
1025 rx_pause = interface->pfc_en; in fm10k_configure_rx_ring()
1027 if (!(rx_pause & BIT(ring->qos_pc))) in fm10k_configure_rx_ring()
1033 ring->vid = hw->mac.default_vid; in fm10k_configure_rx_ring()
1036 if (test_bit(hw->mac.default_vid, interface->active_vlans)) in fm10k_configure_rx_ring()
1037 ring->vid |= FM10K_VLAN_CLEAR; in fm10k_configure_rx_ring()
1040 if (ring->q_vector) { in fm10k_configure_rx_ring()
1041 rxint = ring->q_vector->v_idx + NON_Q_VECTORS; in fm10k_configure_rx_ring()
1057 * fm10k_update_rx_drop_en - Configures the drop enable bits for Rx rings
1064 struct fm10k_hw *hw = &interface->hw; in fm10k_update_rx_drop_en()
1065 u8 rx_pause = interface->rx_pause; in fm10k_update_rx_drop_en()
1069 if (interface->pfc_en) in fm10k_update_rx_drop_en()
1070 rx_pause = interface->pfc_en; in fm10k_update_rx_drop_en()
1073 for (i = 0; i < interface->num_rx_queues; i++) { in fm10k_update_rx_drop_en()
1074 struct fm10k_ring *ring = interface->rx_ring[i]; in fm10k_update_rx_drop_en()
1076 u8 reg_idx = ring->reg_idx; in fm10k_update_rx_drop_en()
1078 if (!(rx_pause & BIT(ring->qos_pc))) in fm10k_update_rx_drop_en()
1086 * fm10k_configure_dglort - Configure Receive DGLORT after reset
1094 struct fm10k_hw *hw = &interface->hw; in fm10k_configure_dglort()
1100 fm10k_write_reg(hw, FM10K_RSSRK(0, i), interface->rssrk[i]); in fm10k_configure_dglort()
1104 fm10k_write_reg(hw, FM10K_RETA(0, i), interface->reta[i]); in fm10k_configure_dglort()
1114 if (test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP, interface->flags)) in fm10k_configure_dglort()
1116 if (test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP, interface->flags)) in fm10k_configure_dglort()
1123 dglort.rss_l = fls(interface->ring_feature[RING_F_RSS].mask); in fm10k_configure_dglort()
1124 dglort.pc_l = fls(interface->ring_feature[RING_F_QOS].mask); in fm10k_configure_dglort()
1125 hw->mac.ops.configure_dglort_map(hw, &dglort); in fm10k_configure_dglort()
1128 if (interface->glort_count > 64) { in fm10k_configure_dglort()
1131 dglort.glort = interface->glort + 64; in fm10k_configure_dglort()
1133 dglort.queue_l = fls(interface->num_rx_queues - 1); in fm10k_configure_dglort()
1134 hw->mac.ops.configure_dglort_map(hw, &dglort); in fm10k_configure_dglort()
1140 dglort.glort = interface->glort; in fm10k_configure_dglort()
1141 dglort.rss_l = fls(interface->ring_feature[RING_F_RSS].mask); in fm10k_configure_dglort()
1142 dglort.pc_l = fls(interface->ring_feature[RING_F_QOS].mask); in fm10k_configure_dglort()
1145 if (interface->l2_accel) in fm10k_configure_dglort()
1146 dglort.shared_l = fls(interface->l2_accel->size); in fm10k_configure_dglort()
1147 hw->mac.ops.configure_dglort_map(hw, &dglort); in fm10k_configure_dglort()
1151 * fm10k_configure_rx - Configure Receive Unit after Reset
1154 * Configure the Rx unit of the MAC after a reset.
1167 for (i = 0; i < interface->num_rx_queues; i++) in fm10k_configure_rx()
1168 fm10k_configure_rx_ring(interface, interface->rx_ring[i]); in fm10k_configure_rx()
1178 for (q_idx = 0; q_idx < interface->num_q_vectors; q_idx++) { in fm10k_napi_enable_all()
1179 q_vector = interface->q_vector[q_idx]; in fm10k_napi_enable_all()
1180 napi_enable(&q_vector->napi); in fm10k_napi_enable_all()
1188 if (q_vector->rx.count || q_vector->tx.count) in fm10k_msix_clean_rings()
1189 napi_schedule_irqoff(&q_vector->napi); in fm10k_msix_clean_rings()
1197 struct fm10k_hw *hw = &interface->hw; in fm10k_msix_mbx_vf()
1198 struct fm10k_mbx_info *mbx = &hw->mbx; in fm10k_msix_mbx_vf()
1200 /* re-enable mailbox interrupt and indicate 20us delay */ in fm10k_msix_mbx_vf()
1202 (FM10K_MBX_INT_DELAY >> hw->mac.itr_scale) | in fm10k_msix_mbx_vf()
1207 mbx->ops.process(hw, mbx); in fm10k_msix_mbx_vf()
1211 hw->mac.get_host_state = true; in fm10k_msix_mbx_vf()
1221 struct pci_dev *pdev = interface->pdev; in fm10k_handle_fault()
1222 struct fm10k_hw *hw = &interface->hw; in fm10k_handle_fault()
1223 struct fm10k_iov_data *iov_data = interface->iov_data; in fm10k_handle_fault()
1228 switch (fault->type) { in fm10k_handle_fault()
1242 switch (fault->type) { in fm10k_handle_fault()
1251 switch (fault->type) { in fm10k_handle_fault()
1273 dev_warn(&pdev->dev, in fm10k_handle_fault()
1275 error, fault->address, fault->specinfo, in fm10k_handle_fault()
1276 PCI_SLOT(fault->func), PCI_FUNC(fault->func)); in fm10k_handle_fault()
1281 * the result of non-malicious behavior this will log the fault and in fm10k_handle_fault()
1287 if (fault->func && iov_data) { in fm10k_handle_fault()
1288 int vf = fault->func - 1; in fm10k_handle_fault()
1289 struct fm10k_vf_info *vf_info = &iov_data->vf_info[vf]; in fm10k_handle_fault()
1291 hw->iov.ops.reset_lport(hw, vf_info); in fm10k_handle_fault()
1292 hw->iov.ops.reset_resources(hw, vf_info); in fm10k_handle_fault()
1294 /* reset_lport disables the VF, so re-enable it */ in fm10k_handle_fault()
1295 hw->iov.ops.set_lport(hw, vf_info, vf, in fm10k_handle_fault()
1299 vf_info->mbx.ops.connect(hw, &vf_info->mbx); in fm10k_handle_fault()
1305 struct fm10k_hw *hw = &interface->hw; in fm10k_report_fault()
1317 err = hw->mac.ops.get_fault(hw, type, &fault); in fm10k_report_fault()
1319 dev_err(&interface->pdev->dev, in fm10k_report_fault()
1330 struct fm10k_hw *hw = &interface->hw; in fm10k_reset_drop_on_empty()
1344 interface->rx_overrun_pf++; in fm10k_reset_drop_on_empty()
1347 interface->rx_overrun_vf++; in fm10k_reset_drop_on_empty()
1353 q &= ~(32 - 1); in fm10k_reset_drop_on_empty()
1358 if (q-- % 32) in fm10k_reset_drop_on_empty()
1370 struct fm10k_hw *hw = &interface->hw; in fm10k_msix_mbx_pf()
1371 struct fm10k_mbx_info *mbx = &hw->mbx; in fm10k_msix_mbx_pf()
1388 s32 err = mbx->ops.process(hw, mbx); in fm10k_msix_mbx_pf()
1391 set_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags); in fm10k_msix_mbx_pf()
1401 interface->link_down_event = jiffies + (4 * HZ); in fm10k_msix_mbx_pf()
1402 set_bit(__FM10K_LINK_DOWN, interface->state); in fm10k_msix_mbx_pf()
1405 hw->mac.dglort_map = FM10K_DGLORTMAP_NONE; in fm10k_msix_mbx_pf()
1409 hw->mac.get_host_state = true; in fm10k_msix_mbx_pf()
1414 /* re-enable mailbox interrupt and indicate 20us delay */ in fm10k_msix_mbx_pf()
1416 (FM10K_MBX_INT_DELAY >> hw->mac.itr_scale) | in fm10k_msix_mbx_pf()
1424 struct fm10k_hw *hw = &interface->hw; in fm10k_mbx_free_irq()
1428 /* no mailbox IRQ to free if MSI-X is not enabled */ in fm10k_mbx_free_irq()
1429 if (!interface->msix_entries) in fm10k_mbx_free_irq()
1432 entry = &interface->msix_entries[FM10K_MBX_VECTOR]; in fm10k_mbx_free_irq()
1435 hw->mbx.ops.disconnect(hw, &hw->mbx); in fm10k_mbx_free_irq()
1438 if (hw->mac.type == fm10k_mac_pf) { in fm10k_mbx_free_irq()
1455 free_irq(entry->vector, interface); in fm10k_mbx_free_irq()
1461 bool vlan_override = hw->mac.vlan_override; in fm10k_mbx_mac_addr()
1462 u16 default_vid = hw->mac.default_vid; in fm10k_mbx_mac_addr()
1472 /* MAC was changed so we need reset */ in fm10k_mbx_mac_addr()
1473 if (is_valid_ether_addr(hw->mac.perm_addr) && in fm10k_mbx_mac_addr()
1474 !ether_addr_equal(hw->mac.perm_addr, hw->mac.addr)) in fm10k_mbx_mac_addr()
1475 set_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags); in fm10k_mbx_mac_addr()
1478 if ((vlan_override != hw->mac.vlan_override) || in fm10k_mbx_mac_addr()
1479 (default_vid != hw->mac.default_vid)) in fm10k_mbx_mac_addr()
1480 set_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags); in fm10k_mbx_mac_addr()
1493 pdev = interface->pdev; in fm10k_mbx_error()
1495 dev_err(&pdev->dev, "Unknown message ID %u\n", in fm10k_mbx_error()
1510 struct msix_entry *entry = &interface->msix_entries[FM10K_MBX_VECTOR]; in fm10k_mbx_request_irq_vf()
1511 struct net_device *dev = interface->netdev; in fm10k_mbx_request_irq_vf()
1512 struct fm10k_hw *hw = &interface->hw; in fm10k_mbx_request_irq_vf()
1516 u32 itr = entry->entry | FM10K_INT_MAP_TIMER0; in fm10k_mbx_request_irq_vf()
1519 err = hw->mbx.ops.register_handlers(&hw->mbx, vf_mbx_data); in fm10k_mbx_request_irq_vf()
1524 err = request_irq(entry->vector, fm10k_msix_mbx_vf, 0, in fm10k_mbx_request_irq_vf()
1525 dev->name, interface); in fm10k_mbx_request_irq_vf()
1536 fm10k_write_reg(hw, FM10K_VFITR(entry->entry), FM10K_ITR_ENABLE); in fm10k_mbx_request_irq_vf()
1545 u32 dglort_map = hw->mac.dglort_map; in fm10k_lport_map()
1551 if (!err && hw->swapi.status) { in fm10k_lport_map()
1553 interface->link_down_event = jiffies + (2 * HZ); in fm10k_lport_map()
1554 set_bit(__FM10K_LINK_DOWN, interface->state); in fm10k_lport_map()
1557 hw->mac.dglort_map = FM10K_DGLORTMAP_NONE; in fm10k_lport_map()
1562 if (interface->lport_map_failed) in fm10k_lport_map()
1565 interface->lport_map_failed = true; in fm10k_lport_map()
1567 if (hw->swapi.status == FM10K_MSG_ERR_PEP_NOT_SCHEDULED) in fm10k_lport_map()
1568 dev_warn(&interface->pdev->dev, in fm10k_lport_map()
1569 …"cannot obtain link because the host interface is configured for a PCIe host interface bandwidth o… in fm10k_lport_map()
1570 dev_warn(&interface->pdev->dev, in fm10k_lport_map()
1572 hw->swapi.status); in fm10k_lport_map()
1581 interface->lport_map_failed = false; in fm10k_lport_map()
1584 if (dglort_map != hw->mac.dglort_map) in fm10k_lport_map()
1585 set_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags); in fm10k_lport_map()
1623 if (pvid != hw->mac.default_vid) in fm10k_update_pvid()
1624 set_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags); in fm10k_update_pvid()
1626 hw->mac.default_vid = pvid; in fm10k_update_pvid()
1643 struct msix_entry *entry = &interface->msix_entries[FM10K_MBX_VECTOR]; in fm10k_mbx_request_irq_pf()
1644 struct net_device *dev = interface->netdev; in fm10k_mbx_request_irq_pf()
1645 struct fm10k_hw *hw = &interface->hw; in fm10k_mbx_request_irq_pf()
1649 u32 mbx_itr = entry->entry | FM10K_INT_MAP_TIMER0; in fm10k_mbx_request_irq_pf()
1650 u32 other_itr = entry->entry | FM10K_INT_MAP_IMMEDIATE; in fm10k_mbx_request_irq_pf()
1653 err = hw->mbx.ops.register_handlers(&hw->mbx, pf_mbx_data); in fm10k_mbx_request_irq_pf()
1658 err = request_irq(entry->vector, fm10k_msix_mbx_pf, 0, in fm10k_mbx_request_irq_pf()
1659 dev->name, interface); in fm10k_mbx_request_irq_pf()
1687 fm10k_write_reg(hw, FM10K_ITR(entry->entry), FM10K_ITR_ENABLE); in fm10k_mbx_request_irq_pf()
1694 struct fm10k_hw *hw = &interface->hw; in fm10k_mbx_request_irq()
1698 if (hw->mac.type == fm10k_mac_pf) in fm10k_mbx_request_irq()
1706 err = hw->mbx.ops.connect(hw, &hw->mbx); in fm10k_mbx_request_irq()
1716 * fm10k_qv_free_irq - release interrupts associated with queue vectors
1723 int vector = interface->num_q_vectors; in fm10k_qv_free_irq()
1726 entry = &interface->msix_entries[NON_Q_VECTORS + vector]; in fm10k_qv_free_irq()
1731 vector--; in fm10k_qv_free_irq()
1732 entry--; in fm10k_qv_free_irq()
1733 q_vector = interface->q_vector[vector]; in fm10k_qv_free_irq()
1735 if (!q_vector->tx.count && !q_vector->rx.count) in fm10k_qv_free_irq()
1739 irq_set_affinity_hint(entry->vector, NULL); in fm10k_qv_free_irq()
1742 writel(FM10K_ITR_MASK_SET, q_vector->itr); in fm10k_qv_free_irq()
1744 free_irq(entry->vector, q_vector); in fm10k_qv_free_irq()
1749 * fm10k_qv_request_irq - initialize interrupts for queue vectors
1757 struct net_device *dev = interface->netdev; in fm10k_qv_request_irq()
1758 struct fm10k_hw *hw = &interface->hw; in fm10k_qv_request_irq()
1763 entry = &interface->msix_entries[NON_Q_VECTORS]; in fm10k_qv_request_irq()
1765 for (vector = 0; vector < interface->num_q_vectors; vector++) { in fm10k_qv_request_irq()
1766 struct fm10k_q_vector *q_vector = interface->q_vector[vector]; in fm10k_qv_request_irq()
1769 if (q_vector->tx.count && q_vector->rx.count) { in fm10k_qv_request_irq()
1770 snprintf(q_vector->name, sizeof(q_vector->name), in fm10k_qv_request_irq()
1771 "%s-TxRx-%u", dev->name, ri++); in fm10k_qv_request_irq()
1773 } else if (q_vector->rx.count) { in fm10k_qv_request_irq()
1774 snprintf(q_vector->name, sizeof(q_vector->name), in fm10k_qv_request_irq()
1775 "%s-rx-%u", dev->name, ri++); in fm10k_qv_request_irq()
1776 } else if (q_vector->tx.count) { in fm10k_qv_request_irq()
1777 snprintf(q_vector->name, sizeof(q_vector->name), in fm10k_qv_request_irq()
1778 "%s-tx-%u", dev->name, ti++); in fm10k_qv_request_irq()
1785 q_vector->itr = (hw->mac.type == fm10k_mac_pf) ? in fm10k_qv_request_irq()
1786 &interface->uc_addr[FM10K_ITR(entry->entry)] : in fm10k_qv_request_irq()
1787 &interface->uc_addr[FM10K_VFITR(entry->entry)]; in fm10k_qv_request_irq()
1790 err = request_irq(entry->vector, &fm10k_msix_clean_rings, 0, in fm10k_qv_request_irq()
1791 q_vector->name, q_vector); in fm10k_qv_request_irq()
1800 irq_set_affinity_hint(entry->vector, &q_vector->affinity_mask); in fm10k_qv_request_irq()
1803 writel(FM10K_ITR_ENABLE, q_vector->itr); in fm10k_qv_request_irq()
1815 entry--; in fm10k_qv_request_irq()
1816 vector--; in fm10k_qv_request_irq()
1817 q_vector = interface->q_vector[vector]; in fm10k_qv_request_irq()
1819 if (!q_vector->tx.count && !q_vector->rx.count) in fm10k_qv_request_irq()
1823 irq_set_affinity_hint(entry->vector, NULL); in fm10k_qv_request_irq()
1826 writel(FM10K_ITR_MASK_SET, q_vector->itr); in fm10k_qv_request_irq()
1828 free_irq(entry->vector, q_vector); in fm10k_qv_request_irq()
1836 struct fm10k_hw *hw = &interface->hw; in fm10k_up()
1839 hw->mac.ops.start_hw(hw); in fm10k_up()
1848 hw->mac.ops.update_int_moderator(hw); in fm10k_up()
1851 clear_bit(__FM10K_UPDATING_STATS, interface->state); in fm10k_up()
1854 clear_bit(__FM10K_DOWN, interface->state); in fm10k_up()
1859 /* re-establish Rx filters */ in fm10k_up()
1863 netif_tx_start_all_queues(interface->netdev); in fm10k_up()
1866 hw->mac.get_host_state = true; in fm10k_up()
1867 mod_timer(&interface->service_timer, jiffies); in fm10k_up()
1875 for (q_idx = 0; q_idx < interface->num_q_vectors; q_idx++) { in fm10k_napi_disable_all()
1876 q_vector = interface->q_vector[q_idx]; in fm10k_napi_disable_all()
1877 napi_disable(&q_vector->napi); in fm10k_napi_disable_all()
1883 struct net_device *netdev = interface->netdev; in fm10k_down()
1884 struct fm10k_hw *hw = &interface->hw; in fm10k_down()
1888 if (test_and_set_bit(__FM10K_DOWN, interface->state)) in fm10k_down()
1908 while (test_and_set_bit(__FM10K_UPDATING_STATS, interface->state)) in fm10k_down()
1911 /* skip waiting for TX DMA if we lost PCIe link */ in fm10k_down()
1912 if (FM10K_REMOVED(hw->hw_addr)) in fm10k_down()
1923 err = hw->mac.ops.stop_hw(hw); in fm10k_down()
1932 for (; i < interface->num_tx_queues; i++) in fm10k_down()
1933 if (fm10k_get_tx_pending(interface->tx_ring[i], false)) in fm10k_down()
1937 if (i == interface->num_tx_queues) in fm10k_down()
1942 dev_err(&interface->pdev->dev, in fm10k_down()
1947 err = hw->mac.ops.stop_hw(hw); in fm10k_down()
1949 dev_err(&interface->pdev->dev, in fm10k_down()
1952 dev_err(&interface->pdev->dev, "stop_hw failed: %d\n", err); in fm10k_down()
1960 * fm10k_sw_init - Initialize general software structures
1971 const struct fm10k_info *fi = fm10k_info_tbl[ent->driver_data]; in fm10k_sw_init()
1972 struct fm10k_hw *hw = &interface->hw; in fm10k_sw_init()
1973 struct pci_dev *pdev = interface->pdev; in fm10k_sw_init()
1974 struct net_device *netdev = interface->netdev; in fm10k_sw_init()
1980 hw->back = interface; in fm10k_sw_init()
1981 hw->hw_addr = interface->uc_addr; in fm10k_sw_init()
1984 hw->vendor_id = pdev->vendor; in fm10k_sw_init()
1985 hw->device_id = pdev->device; in fm10k_sw_init()
1986 hw->revision_id = pdev->revision; in fm10k_sw_init()
1987 hw->subsystem_vendor_id = pdev->subsystem_vendor; in fm10k_sw_init()
1988 hw->subsystem_device_id = pdev->subsystem_device; in fm10k_sw_init()
1991 memcpy(&hw->mac.ops, fi->mac_ops, sizeof(hw->mac.ops)); in fm10k_sw_init()
1992 hw->mac.type = fi->mac; in fm10k_sw_init()
1995 if (fi->iov_ops) in fm10k_sw_init()
1996 memcpy(&hw->iov.ops, fi->iov_ops, sizeof(hw->iov.ops)); in fm10k_sw_init()
2000 interface->ring_feature[RING_F_RSS].limit = rss; in fm10k_sw_init()
2001 fi->get_invariants(hw); in fm10k_sw_init()
2003 /* pick up the PCIe bus settings for reporting later */ in fm10k_sw_init()
2004 if (hw->mac.ops.get_bus_info) in fm10k_sw_init()
2005 hw->mac.ops.get_bus_info(hw); in fm10k_sw_init()
2008 if (hw->mac.ops.set_dma_mask) in fm10k_sw_init()
2009 hw->mac.ops.set_dma_mask(hw, dma_get_mask(&pdev->dev)); in fm10k_sw_init()
2012 if (dma_get_mask(&pdev->dev) > DMA_BIT_MASK(32)) { in fm10k_sw_init()
2013 netdev->features |= NETIF_F_HIGHDMA; in fm10k_sw_init()
2014 netdev->vlan_features |= NETIF_F_HIGHDMA; in fm10k_sw_init()
2018 err = hw->mac.ops.reset_hw(hw); in fm10k_sw_init()
2020 dev_err(&pdev->dev, "reset_hw failed: %d\n", err); in fm10k_sw_init()
2024 err = hw->mac.ops.init_hw(hw); in fm10k_sw_init()
2026 dev_err(&pdev->dev, "init_hw failed: %d\n", err); in fm10k_sw_init()
2031 hw->mac.ops.update_hw_stats(hw, &interface->stats); in fm10k_sw_init()
2034 pci_sriov_set_totalvfs(pdev, hw->iov.total_vfs); in fm10k_sw_init()
2037 eth_random_addr(hw->mac.addr); in fm10k_sw_init()
2039 /* Initialize MAC address from hardware */ in fm10k_sw_init()
2040 err = hw->mac.ops.read_mac_addr(hw); in fm10k_sw_init()
2042 dev_warn(&pdev->dev, in fm10k_sw_init()
2043 "Failed to obtain MAC address defaulting to random\n"); in fm10k_sw_init()
2045 netdev->addr_assign_type |= NET_ADDR_RANDOM; in fm10k_sw_init()
2048 eth_hw_addr_set(netdev, hw->mac.addr); in fm10k_sw_init()
2049 ether_addr_copy(netdev->perm_addr, hw->mac.addr); in fm10k_sw_init()
2051 if (!is_valid_ether_addr(netdev->perm_addr)) { in fm10k_sw_init()
2052 dev_err(&pdev->dev, "Invalid MAC Address\n"); in fm10k_sw_init()
2053 return -EIO; in fm10k_sw_init()
2060 interface->tx_ring_count = FM10K_DEFAULT_TXD; in fm10k_sw_init()
2061 interface->rx_ring_count = FM10K_DEFAULT_RXD; in fm10k_sw_init()
2064 interface->tx_itr = FM10K_TX_ITR_DEFAULT; in fm10k_sw_init()
2065 interface->rx_itr = FM10K_ITR_ADAPTIVE | FM10K_RX_ITR_DEFAULT; in fm10k_sw_init()
2067 /* Initialize the MAC/VLAN queue */ in fm10k_sw_init()
2068 INIT_LIST_HEAD(&interface->macvlan_requests); in fm10k_sw_init()
2071 memcpy(interface->rssrk, rss_key, sizeof(rss_key)); in fm10k_sw_init()
2074 spin_lock_init(&interface->mbx_lock); in fm10k_sw_init()
2075 spin_lock_init(&interface->macvlan_lock); in fm10k_sw_init()
2078 set_bit(__FM10K_DOWN, interface->state); in fm10k_sw_init()
2079 set_bit(__FM10K_UPDATING_STATS, interface->state); in fm10k_sw_init()
2085 * fm10k_probe - Device Initialization Routine
2101 if (pdev->error_state != pci_channel_io_normal) { in fm10k_probe()
2102 dev_err(&pdev->dev, in fm10k_probe()
2104 return -EIO; in fm10k_probe()
2109 dev_err(&pdev->dev, in fm10k_probe()
2114 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48)); in fm10k_probe()
2116 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in fm10k_probe()
2118 dev_err(&pdev->dev, in fm10k_probe()
2125 dev_err(&pdev->dev, in fm10k_probe()
2135 netdev = fm10k_alloc_netdev(fm10k_info_tbl[ent->driver_data]); in fm10k_probe()
2137 err = -ENOMEM; in fm10k_probe()
2141 SET_NETDEV_DEV(netdev, &pdev->dev); in fm10k_probe()
2146 interface->netdev = netdev; in fm10k_probe()
2147 interface->pdev = pdev; in fm10k_probe()
2149 interface->uc_addr = ioremap(pci_resource_start(pdev, 0), in fm10k_probe()
2151 if (!interface->uc_addr) { in fm10k_probe()
2152 err = -EIO; in fm10k_probe()
2171 set_bit(__FM10K_SERVICE_DISABLE, interface->state); in fm10k_probe()
2195 timer_setup(&interface->service_timer, fm10k_service_timer, 0); in fm10k_probe()
2196 INIT_WORK(&interface->service_task, fm10k_service_task); in fm10k_probe()
2198 /* Setup the MAC/VLAN queue */ in fm10k_probe()
2199 INIT_DELAYED_WORK(&interface->macvlan_task, fm10k_macvlan_task); in fm10k_probe()
2202 mod_timer(&interface->service_timer, (HZ * 2) + jiffies); in fm10k_probe()
2204 /* print warning for non-optimal configurations */ in fm10k_probe()
2205 pcie_print_link_status(interface->pdev); in fm10k_probe()
2207 /* report MAC address for logging */ in fm10k_probe()
2208 dev_info(&pdev->dev, "%pM\n", netdev->dev_addr); in fm10k_probe()
2210 /* enable SR-IOV after registering netdev to enforce PF/VF ordering */ in fm10k_probe()
2214 clear_bit(__FM10K_SERVICE_DISABLE, interface->state); in fm10k_probe()
2224 if (interface->sw_addr) in fm10k_probe()
2225 iounmap(interface->sw_addr); in fm10k_probe()
2226 iounmap(interface->uc_addr); in fm10k_probe()
2239 * fm10k_remove - Device Removal Routine
2244 * Hot-Plug event, or because the driver is going to be removed from
2250 struct net_device *netdev = interface->netdev; in fm10k_remove()
2252 del_timer_sync(&interface->service_timer); in fm10k_remove()
2257 /* Remove all pending MAC/VLAN requests */ in fm10k_remove()
2258 fm10k_clear_macvlan_queue(interface, interface->glort, true); in fm10k_remove()
2261 if (netdev->reg_state == NETREG_REGISTERED) in fm10k_remove()
2276 if (interface->sw_addr) in fm10k_remove()
2277 iounmap(interface->sw_addr); in fm10k_remove()
2278 iounmap(interface->uc_addr); in fm10k_remove()
2292 * a surprise remove if the PCIe device is disabled while we're in fm10k_prepare_suspend()
2296 * Note that the MAC/VLAN task will be stopped as part of preparing in fm10k_prepare_suspend()
2302 set_bit(__FM10K_RESET_SUSPENDED, interface->state); in fm10k_prepare_suspend()
2307 struct fm10k_hw *hw = &interface->hw; in fm10k_handle_resume()
2313 if (!test_and_clear_bit(__FM10K_RESET_SUSPENDED, interface->state)) in fm10k_handle_resume()
2314 dev_warn(&interface->pdev->dev, in fm10k_handle_resume()
2318 hw->mac.ops.rebind_hw_stats(hw, &interface->stats); in fm10k_handle_resume()
2327 interface->host_ready = false; in fm10k_handle_resume()
2331 interface->link_down_event = jiffies + (HZ); in fm10k_handle_resume()
2332 set_bit(__FM10K_LINK_DOWN, interface->state); in fm10k_handle_resume()
2337 /* Restart the MAC/VLAN request queue in-case of outstanding events */ in fm10k_handle_resume()
2344 * fm10k_resume - Generic PM resume hook
2348 * suspend or hibernation. This function does not need to handle lower PCIe
2354 struct net_device *netdev = interface->netdev; in fm10k_resume()
2355 struct fm10k_hw *hw = &interface->hw; in fm10k_resume()
2359 hw->hw_addr = interface->uc_addr; in fm10k_resume()
2371 * fm10k_suspend - Generic PM suspend hook
2376 * PCIe device state as the stack takes care of that for us.
2381 struct net_device *netdev = interface->netdev; in fm10k_suspend()
2391 * fm10k_io_error_detected - called when PCI error is detected
2402 struct net_device *netdev = interface->netdev; in fm10k_io_error_detected()
2416 * fm10k_io_slot_reset - called after the pci bus has been reset.
2419 * Restart the card from scratch, as if from a cold-boot.
2426 dev_err(&pdev->dev, in fm10k_io_slot_reset()
2427 "Cannot re-enable PCI device after reset.\n"); in fm10k_io_slot_reset()
2433 /* After second error pci->state_saved is false, this in fm10k_io_slot_reset()
2447 * fm10k_io_resume - called when traffic can start flowing again.
2456 struct net_device *netdev = interface->netdev; in fm10k_io_resume()
2462 dev_warn(&pdev->dev, in fm10k_io_resume()
2469 * fm10k_io_reset_prepare - called when PCI function is about to be reset
2479 dev_warn(&pdev->dev, in fm10k_io_reset_prepare()
2480 "PCIe FLR may cause issues for any active VF devices\n"); in fm10k_io_reset_prepare()
2485 * fm10k_io_reset_done - called when PCI function has finished resetting
2497 dev_warn(&pdev->dev, in fm10k_io_reset_done()
2499 netif_device_detach(interface->netdev); in fm10k_io_reset_done()
2526 * fm10k_register_pci_driver - register driver interface
2536 * fm10k_unregister_pci_driver - unregister driver interface