Lines Matching full:adapter
14 static int iavf_setup_all_tx_resources(struct iavf_adapter *adapter);
15 static int iavf_setup_all_rx_resources(struct iavf_adapter *adapter);
17 static void iavf_init_get_resources(struct iavf_adapter *adapter);
161 * iavf_pdev_to_adapter - go from pci_dev to adapter
171 * @adapter: board private structure
173 static bool iavf_is_reset_in_progress(struct iavf_adapter *adapter) in iavf_is_reset_in_progress() argument
175 if (adapter->state == __IAVF_RESETTING || in iavf_is_reset_in_progress()
176 adapter->flags & (IAVF_FLAG_RESET_PENDING | in iavf_is_reset_in_progress()
185 * @adapter: board private structure
189 int iavf_wait_for_reset(struct iavf_adapter *adapter) in iavf_wait_for_reset() argument
191 int ret = wait_event_interruptible_timeout(adapter->reset_waitqueue, in iavf_wait_for_reset()
192 !iavf_is_reset_in_progress(adapter), in iavf_wait_for_reset()
219 struct iavf_adapter *adapter = (struct iavf_adapter *)hw->back; in iavf_allocate_dma_mem_d() local
225 mem->va = dma_alloc_coherent(&adapter->pdev->dev, mem->size, in iavf_allocate_dma_mem_d()
240 struct iavf_adapter *adapter = (struct iavf_adapter *)hw->back; in iavf_free_dma_mem() local
244 dma_free_coherent(&adapter->pdev->dev, mem->size, in iavf_free_dma_mem()
282 * @adapter: board private structure
285 void iavf_schedule_reset(struct iavf_adapter *adapter, u64 flags) in iavf_schedule_reset() argument
287 if (!test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section) && in iavf_schedule_reset()
288 !(adapter->flags & in iavf_schedule_reset()
290 adapter->flags |= flags; in iavf_schedule_reset()
291 queue_work(adapter->wq, &adapter->reset_task); in iavf_schedule_reset()
297 * @adapter: board private structure
300 void iavf_schedule_aq_request(struct iavf_adapter *adapter, u64 flags) in iavf_schedule_aq_request() argument
302 adapter->aq_required |= flags; in iavf_schedule_aq_request()
303 mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); in iavf_schedule_aq_request()
313 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_tx_timeout() local
315 adapter->tx_timeout_count++; in iavf_tx_timeout()
316 iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); in iavf_tx_timeout()
321 * @adapter: board private structure
323 static void iavf_misc_irq_disable(struct iavf_adapter *adapter) in iavf_misc_irq_disable() argument
325 struct iavf_hw *hw = &adapter->hw; in iavf_misc_irq_disable()
327 if (!adapter->msix_entries) in iavf_misc_irq_disable()
334 synchronize_irq(adapter->msix_entries[0].vector); in iavf_misc_irq_disable()
339 * @adapter: board private structure
341 static void iavf_misc_irq_enable(struct iavf_adapter *adapter) in iavf_misc_irq_enable() argument
343 struct iavf_hw *hw = &adapter->hw; in iavf_misc_irq_enable()
354 * @adapter: board private structure
356 static void iavf_irq_disable(struct iavf_adapter *adapter) in iavf_irq_disable() argument
359 struct iavf_hw *hw = &adapter->hw; in iavf_irq_disable()
361 if (!adapter->msix_entries) in iavf_irq_disable()
364 for (i = 1; i < adapter->num_msix_vectors; i++) { in iavf_irq_disable()
366 synchronize_irq(adapter->msix_entries[i].vector); in iavf_irq_disable()
373 * @adapter: board private structure
375 static void iavf_irq_enable_queues(struct iavf_adapter *adapter) in iavf_irq_enable_queues() argument
377 struct iavf_hw *hw = &adapter->hw; in iavf_irq_enable_queues()
380 for (i = 1; i < adapter->num_msix_vectors; i++) { in iavf_irq_enable_queues()
389 * @adapter: board private structure
392 void iavf_irq_enable(struct iavf_adapter *adapter, bool flush) in iavf_irq_enable() argument
394 struct iavf_hw *hw = &adapter->hw; in iavf_irq_enable()
396 iavf_misc_irq_enable(adapter); in iavf_irq_enable()
397 iavf_irq_enable_queues(adapter); in iavf_irq_enable()
411 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_msix_aq() local
412 struct iavf_hw *hw = &adapter->hw; in iavf_msix_aq()
418 if (adapter->state != __IAVF_REMOVE) in iavf_msix_aq()
420 queue_work(adapter->wq, &adapter->adminq_task); in iavf_msix_aq()
444 * @adapter: board private structure
449 iavf_map_vector_to_rxq(struct iavf_adapter *adapter, int v_idx, int r_idx) in iavf_map_vector_to_rxq() argument
451 struct iavf_q_vector *q_vector = &adapter->q_vectors[v_idx]; in iavf_map_vector_to_rxq()
452 struct iavf_ring *rx_ring = &adapter->rx_rings[r_idx]; in iavf_map_vector_to_rxq()
453 struct iavf_hw *hw = &adapter->hw; in iavf_map_vector_to_rxq()
457 rx_ring->vsi = &adapter->vsi; in iavf_map_vector_to_rxq()
470 * @adapter: board private structure
475 iavf_map_vector_to_txq(struct iavf_adapter *adapter, int v_idx, int t_idx) in iavf_map_vector_to_txq() argument
477 struct iavf_q_vector *q_vector = &adapter->q_vectors[v_idx]; in iavf_map_vector_to_txq()
478 struct iavf_ring *tx_ring = &adapter->tx_rings[t_idx]; in iavf_map_vector_to_txq()
479 struct iavf_hw *hw = &adapter->hw; in iavf_map_vector_to_txq()
483 tx_ring->vsi = &adapter->vsi; in iavf_map_vector_to_txq()
496 * @adapter: board private structure to initialize
504 static void iavf_map_rings_to_vectors(struct iavf_adapter *adapter) in iavf_map_rings_to_vectors() argument
506 int rings_remaining = adapter->num_active_queues; in iavf_map_rings_to_vectors()
510 q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_map_rings_to_vectors()
513 iavf_map_vector_to_rxq(adapter, vidx, ridx); in iavf_map_rings_to_vectors()
514 iavf_map_vector_to_txq(adapter, vidx, ridx); in iavf_map_rings_to_vectors()
523 adapter->aq_required |= IAVF_FLAG_AQ_MAP_VECTORS; in iavf_map_rings_to_vectors()
555 * @adapter: board private structure
562 iavf_request_traffic_irqs(struct iavf_adapter *adapter, char *basename) in iavf_request_traffic_irqs() argument
569 iavf_irq_disable(adapter); in iavf_request_traffic_irqs()
571 q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_request_traffic_irqs()
574 struct iavf_q_vector *q_vector = &adapter->q_vectors[vector]; in iavf_request_traffic_irqs()
576 irq_num = adapter->msix_entries[vector + NONQ_VECS].vector; in iavf_request_traffic_irqs()
598 dev_info(&adapter->pdev->dev, in iavf_request_traffic_irqs()
620 irq_num = adapter->msix_entries[vector + NONQ_VECS].vector; in iavf_request_traffic_irqs()
623 free_irq(irq_num, &adapter->q_vectors[vector]); in iavf_request_traffic_irqs()
630 * @adapter: board private structure
636 static int iavf_request_misc_irq(struct iavf_adapter *adapter) in iavf_request_misc_irq() argument
638 struct net_device *netdev = adapter->netdev; in iavf_request_misc_irq()
641 snprintf(adapter->misc_vector_name, in iavf_request_misc_irq()
642 sizeof(adapter->misc_vector_name) - 1, "iavf-%s:mbx", in iavf_request_misc_irq()
643 dev_name(&adapter->pdev->dev)); in iavf_request_misc_irq()
644 err = request_irq(adapter->msix_entries[0].vector, in iavf_request_misc_irq()
646 adapter->misc_vector_name, netdev); in iavf_request_misc_irq()
648 dev_err(&adapter->pdev->dev, in iavf_request_misc_irq()
650 adapter->misc_vector_name, err); in iavf_request_misc_irq()
651 free_irq(adapter->msix_entries[0].vector, netdev); in iavf_request_misc_irq()
658 * @adapter: board private structure
662 static void iavf_free_traffic_irqs(struct iavf_adapter *adapter) in iavf_free_traffic_irqs() argument
666 if (!adapter->msix_entries) in iavf_free_traffic_irqs()
669 q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_free_traffic_irqs()
672 irq_num = adapter->msix_entries[vector + NONQ_VECS].vector; in iavf_free_traffic_irqs()
675 free_irq(irq_num, &adapter->q_vectors[vector]); in iavf_free_traffic_irqs()
681 * @adapter: board private structure
685 static void iavf_free_misc_irq(struct iavf_adapter *adapter) in iavf_free_misc_irq() argument
687 struct net_device *netdev = adapter->netdev; in iavf_free_misc_irq()
689 if (!adapter->msix_entries) in iavf_free_misc_irq()
692 free_irq(adapter->msix_entries[0].vector, netdev); in iavf_free_misc_irq()
697 * @adapter: board private structure
701 static void iavf_configure_tx(struct iavf_adapter *adapter) in iavf_configure_tx() argument
703 struct iavf_hw *hw = &adapter->hw; in iavf_configure_tx()
706 for (i = 0; i < adapter->num_active_queues; i++) in iavf_configure_tx()
707 adapter->tx_rings[i].tail = hw->hw_addr + IAVF_QTX_TAIL1(i); in iavf_configure_tx()
712 * @adapter: board private structure
716 static void iavf_configure_rx(struct iavf_adapter *adapter) in iavf_configure_rx() argument
719 struct iavf_hw *hw = &adapter->hw; in iavf_configure_rx()
724 if (!(adapter->flags & IAVF_FLAG_LEGACY_RX)) { in iavf_configure_rx()
725 struct net_device *netdev = adapter->netdev; in iavf_configure_rx()
743 for (i = 0; i < adapter->num_active_queues; i++) { in iavf_configure_rx()
744 adapter->rx_rings[i].tail = hw->hw_addr + IAVF_QRX_TAIL1(i); in iavf_configure_rx()
745 adapter->rx_rings[i].rx_buf_len = rx_buf_len; in iavf_configure_rx()
747 if (adapter->flags & IAVF_FLAG_LEGACY_RX) in iavf_configure_rx()
748 clear_ring_build_skb_enabled(&adapter->rx_rings[i]); in iavf_configure_rx()
750 set_ring_build_skb_enabled(&adapter->rx_rings[i]); in iavf_configure_rx()
756 * @adapter: board private structure
763 iavf_vlan_filter *iavf_find_vlan(struct iavf_adapter *adapter, in iavf_find_vlan() argument
768 list_for_each_entry(f, &adapter->vlan_filter_list, list) { in iavf_find_vlan()
779 * @adapter: board private structure
785 iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter, in iavf_add_vlan() argument
790 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_add_vlan()
792 f = iavf_find_vlan(adapter, vlan); in iavf_add_vlan()
800 list_add_tail(&f->list, &adapter->vlan_filter_list); in iavf_add_vlan()
802 adapter->num_vlan_filters++; in iavf_add_vlan()
803 iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ADD_VLAN_FILTER); in iavf_add_vlan()
807 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_add_vlan()
813 * @adapter: board private structure
816 static void iavf_del_vlan(struct iavf_adapter *adapter, struct iavf_vlan vlan) in iavf_del_vlan() argument
820 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_del_vlan()
822 f = iavf_find_vlan(adapter, vlan); in iavf_del_vlan()
825 iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_DEL_VLAN_FILTER); in iavf_del_vlan()
828 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_del_vlan()
833 * @adapter: board private structure
837 static void iavf_restore_filters(struct iavf_adapter *adapter) in iavf_restore_filters() argument
842 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_restore_filters()
844 list_for_each_entry(f, &adapter->vlan_filter_list, list) { in iavf_restore_filters()
849 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_restore_filters()
850 adapter->aq_required |= IAVF_FLAG_AQ_ADD_VLAN_FILTER; in iavf_restore_filters()
855 * @adapter: board private structure
857 u16 iavf_get_num_vlans_added(struct iavf_adapter *adapter) in iavf_get_num_vlans_added() argument
859 return adapter->num_vlan_filters; in iavf_get_num_vlans_added()
864 * @adapter: board private structure
870 static u16 iavf_get_max_vlans_allowed(struct iavf_adapter *adapter) in iavf_get_max_vlans_allowed() argument
875 if (VLAN_ALLOWED(adapter)) in iavf_get_max_vlans_allowed()
877 else if (VLAN_V2_ALLOWED(adapter)) in iavf_get_max_vlans_allowed()
878 return adapter->vlan_v2_caps.filtering.max_filters; in iavf_get_max_vlans_allowed()
885 * @adapter: board private structure
887 static bool iavf_max_vlans_added(struct iavf_adapter *adapter) in iavf_max_vlans_added() argument
889 if (iavf_get_num_vlans_added(adapter) < in iavf_max_vlans_added()
890 iavf_get_max_vlans_allowed(adapter)) in iavf_max_vlans_added()
905 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_vlan_rx_add_vid() local
911 if (!VLAN_FILTERING_ALLOWED(adapter)) in iavf_vlan_rx_add_vid()
914 if (iavf_max_vlans_added(adapter)) { in iavf_vlan_rx_add_vid()
916 iavf_get_max_vlans_allowed(adapter)); in iavf_vlan_rx_add_vid()
920 if (!iavf_add_vlan(adapter, IAVF_VLAN(vid, be16_to_cpu(proto)))) in iavf_vlan_rx_add_vid()
935 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_vlan_rx_kill_vid() local
941 iavf_del_vlan(adapter, IAVF_VLAN(vid, be16_to_cpu(proto))); in iavf_vlan_rx_kill_vid()
947 * @adapter: board private structure
954 iavf_mac_filter *iavf_find_filter(struct iavf_adapter *adapter, in iavf_find_filter() argument
962 list_for_each_entry(f, &adapter->mac_filter_list, list) { in iavf_find_filter()
971 * @adapter: board private structure
976 struct iavf_mac_filter *iavf_add_filter(struct iavf_adapter *adapter, in iavf_add_filter() argument
984 f = iavf_find_filter(adapter, macaddr); in iavf_add_filter()
992 list_add_tail(&f->list, &adapter->mac_filter_list); in iavf_add_filter()
996 f->is_primary = ether_addr_equal(macaddr, adapter->hw.mac.addr); in iavf_add_filter()
997 adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER; in iavf_add_filter()
1007 * @adapter: board private structure
1016 static int iavf_replace_primary_mac(struct iavf_adapter *adapter, in iavf_replace_primary_mac() argument
1019 struct iavf_hw *hw = &adapter->hw; in iavf_replace_primary_mac()
1023 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_replace_primary_mac()
1025 new_f = iavf_add_filter(adapter, new_mac); in iavf_replace_primary_mac()
1027 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_replace_primary_mac()
1031 old_f = iavf_find_filter(adapter, hw->mac.addr); in iavf_replace_primary_mac()
1035 adapter->aq_required |= IAVF_FLAG_AQ_DEL_MAC_FILTER; in iavf_replace_primary_mac()
1042 adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER; in iavf_replace_primary_mac()
1045 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_replace_primary_mac()
1048 mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); in iavf_replace_primary_mac()
1062 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_is_mac_set_handled() local
1066 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_is_mac_set_handled()
1068 f = iavf_find_filter(adapter, macaddr); in iavf_is_mac_set_handled()
1073 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_is_mac_set_handled()
1087 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_set_mac() local
1094 ret = iavf_replace_primary_mac(adapter, addr->sa_data); in iavf_set_mac()
1099 ret = wait_event_interruptible_timeout(adapter->vc_waitqueue, in iavf_set_mac()
1131 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_addr_sync() local
1133 if (iavf_add_filter(adapter, addr)) in iavf_addr_sync()
1149 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_addr_unsync() local
1160 f = iavf_find_filter(adapter, addr); in iavf_addr_unsync()
1163 adapter->aq_required |= IAVF_FLAG_AQ_DEL_MAC_FILTER; in iavf_addr_unsync()
1170 * @adapter: device specific adapter
1172 bool iavf_promiscuous_mode_changed(struct iavf_adapter *adapter) in iavf_promiscuous_mode_changed() argument
1174 return (adapter->current_netdev_promisc_flags ^ adapter->netdev->flags) & in iavf_promiscuous_mode_changed()
1184 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_set_rx_mode() local
1186 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_set_rx_mode()
1189 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_set_rx_mode()
1191 spin_lock_bh(&adapter->current_netdev_promisc_flags_lock); in iavf_set_rx_mode()
1192 if (iavf_promiscuous_mode_changed(adapter)) in iavf_set_rx_mode()
1193 adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_PROMISC_MODE; in iavf_set_rx_mode()
1194 spin_unlock_bh(&adapter->current_netdev_promisc_flags_lock); in iavf_set_rx_mode()
1199 * @adapter: board private structure
1201 static void iavf_napi_enable_all(struct iavf_adapter *adapter) in iavf_napi_enable_all() argument
1205 int q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_napi_enable_all()
1210 q_vector = &adapter->q_vectors[q_idx]; in iavf_napi_enable_all()
1218 * @adapter: board private structure
1220 static void iavf_napi_disable_all(struct iavf_adapter *adapter) in iavf_napi_disable_all() argument
1224 int q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_napi_disable_all()
1227 q_vector = &adapter->q_vectors[q_idx]; in iavf_napi_disable_all()
1234 * @adapter: board private structure
1236 static void iavf_configure(struct iavf_adapter *adapter) in iavf_configure() argument
1238 struct net_device *netdev = adapter->netdev; in iavf_configure()
1243 iavf_configure_tx(adapter); in iavf_configure()
1244 iavf_configure_rx(adapter); in iavf_configure()
1245 adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_QUEUES; in iavf_configure()
1247 for (i = 0; i < adapter->num_active_queues; i++) { in iavf_configure()
1248 struct iavf_ring *ring = &adapter->rx_rings[i]; in iavf_configure()
1256 * @adapter: board private structure
1260 static void iavf_up_complete(struct iavf_adapter *adapter) in iavf_up_complete() argument
1262 iavf_change_state(adapter, __IAVF_RUNNING); in iavf_up_complete()
1263 clear_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_up_complete()
1265 iavf_napi_enable_all(adapter); in iavf_up_complete()
1267 adapter->aq_required |= IAVF_FLAG_AQ_ENABLE_QUEUES; in iavf_up_complete()
1268 if (CLIENT_ENABLED(adapter)) in iavf_up_complete()
1269 adapter->flags |= IAVF_FLAG_CLIENT_NEEDS_OPEN; in iavf_up_complete()
1270 mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); in iavf_up_complete()
1276 * @adapter: board private structure
1278 static void iavf_clear_mac_vlan_filters(struct iavf_adapter *adapter) in iavf_clear_mac_vlan_filters() argument
1283 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_clear_mac_vlan_filters()
1285 __dev_uc_unsync(adapter->netdev, NULL); in iavf_clear_mac_vlan_filters()
1286 __dev_mc_unsync(adapter->netdev, NULL); in iavf_clear_mac_vlan_filters()
1289 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, in iavf_clear_mac_vlan_filters()
1300 list_for_each_entry_safe(vlf, vlftmp, &adapter->vlan_filter_list, in iavf_clear_mac_vlan_filters()
1304 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_clear_mac_vlan_filters()
1310 * @adapter: board private structure
1312 static void iavf_clear_cloud_filters(struct iavf_adapter *adapter) in iavf_clear_cloud_filters() argument
1317 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_clear_cloud_filters()
1318 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, in iavf_clear_cloud_filters()
1323 adapter->num_cloud_filters--; in iavf_clear_cloud_filters()
1328 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_clear_cloud_filters()
1334 * @adapter: board private structure
1336 static void iavf_clear_fdir_filters(struct iavf_adapter *adapter) in iavf_clear_fdir_filters() argument
1341 spin_lock_bh(&adapter->fdir_fltr_lock); in iavf_clear_fdir_filters()
1342 list_for_each_entry(fdir, &adapter->fdir_list_head, list) { in iavf_clear_fdir_filters()
1354 spin_unlock_bh(&adapter->fdir_fltr_lock); in iavf_clear_fdir_filters()
1360 * @adapter: board private structure
1362 static void iavf_clear_adv_rss_conf(struct iavf_adapter *adapter) in iavf_clear_adv_rss_conf() argument
1367 spin_lock_bh(&adapter->adv_rss_lock); in iavf_clear_adv_rss_conf()
1368 list_for_each_entry_safe(rss, rsstmp, &adapter->adv_rss_list_head, in iavf_clear_adv_rss_conf()
1377 spin_unlock_bh(&adapter->adv_rss_lock); in iavf_clear_adv_rss_conf()
1382 * @adapter: board private structure
1386 void iavf_down(struct iavf_adapter *adapter) in iavf_down() argument
1388 struct net_device *netdev = adapter->netdev; in iavf_down()
1390 if (adapter->state <= __IAVF_DOWN_PENDING) in iavf_down()
1395 adapter->link_up = false; in iavf_down()
1396 iavf_napi_disable_all(adapter); in iavf_down()
1397 iavf_irq_disable(adapter); in iavf_down()
1399 iavf_clear_mac_vlan_filters(adapter); in iavf_down()
1400 iavf_clear_cloud_filters(adapter); in iavf_down()
1401 iavf_clear_fdir_filters(adapter); in iavf_down()
1402 iavf_clear_adv_rss_conf(adapter); in iavf_down()
1404 if (!(adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) && in iavf_down()
1405 !(test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section))) { in iavf_down()
1407 adapter->current_op = VIRTCHNL_OP_UNKNOWN; in iavf_down()
1412 if (!list_empty(&adapter->mac_filter_list)) in iavf_down()
1413 adapter->aq_required |= IAVF_FLAG_AQ_DEL_MAC_FILTER; in iavf_down()
1414 if (!list_empty(&adapter->vlan_filter_list)) in iavf_down()
1415 adapter->aq_required |= IAVF_FLAG_AQ_DEL_VLAN_FILTER; in iavf_down()
1416 if (!list_empty(&adapter->cloud_filter_list)) in iavf_down()
1417 adapter->aq_required |= IAVF_FLAG_AQ_DEL_CLOUD_FILTER; in iavf_down()
1418 if (!list_empty(&adapter->fdir_list_head)) in iavf_down()
1419 adapter->aq_required |= IAVF_FLAG_AQ_DEL_FDIR_FILTER; in iavf_down()
1420 if (!list_empty(&adapter->adv_rss_list_head)) in iavf_down()
1421 adapter->aq_required |= IAVF_FLAG_AQ_DEL_ADV_RSS_CFG; in iavf_down()
1424 adapter->aq_required |= IAVF_FLAG_AQ_DISABLE_QUEUES; in iavf_down()
1425 mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); in iavf_down()
1430 * @adapter: board private structure
1438 iavf_acquire_msix_vectors(struct iavf_adapter *adapter, int vectors) in iavf_acquire_msix_vectors() argument
1454 err = pci_enable_msix_range(adapter->pdev, adapter->msix_entries, in iavf_acquire_msix_vectors()
1457 dev_err(&adapter->pdev->dev, "Unable to allocate MSI-X interrupts\n"); in iavf_acquire_msix_vectors()
1458 kfree(adapter->msix_entries); in iavf_acquire_msix_vectors()
1459 adapter->msix_entries = NULL; in iavf_acquire_msix_vectors()
1467 adapter->num_msix_vectors = err; in iavf_acquire_msix_vectors()
1473 * @adapter: board private structure to initialize
1477 static void iavf_free_queues(struct iavf_adapter *adapter) in iavf_free_queues() argument
1479 if (!adapter->vsi_res) in iavf_free_queues()
1481 adapter->num_active_queues = 0; in iavf_free_queues()
1482 kfree(adapter->tx_rings); in iavf_free_queues()
1483 adapter->tx_rings = NULL; in iavf_free_queues()
1484 kfree(adapter->rx_rings); in iavf_free_queues()
1485 adapter->rx_rings = NULL; in iavf_free_queues()
1490 * @adapter: board private structure
1497 void iavf_set_queue_vlan_tag_loc(struct iavf_adapter *adapter) in iavf_set_queue_vlan_tag_loc() argument
1501 for (i = 0; i < adapter->num_active_queues; i++) { in iavf_set_queue_vlan_tag_loc()
1502 struct iavf_ring *tx_ring = &adapter->tx_rings[i]; in iavf_set_queue_vlan_tag_loc()
1503 struct iavf_ring *rx_ring = &adapter->rx_rings[i]; in iavf_set_queue_vlan_tag_loc()
1513 if (VLAN_ALLOWED(adapter)) { in iavf_set_queue_vlan_tag_loc()
1516 } else if (VLAN_V2_ALLOWED(adapter)) { in iavf_set_queue_vlan_tag_loc()
1521 &adapter->vlan_v2_caps.offloads.stripping_support; in iavf_set_queue_vlan_tag_loc()
1523 &adapter->vlan_v2_caps.offloads.insertion_support; in iavf_set_queue_vlan_tag_loc()
1570 * @adapter: board private structure to initialize
1576 static int iavf_alloc_queues(struct iavf_adapter *adapter) in iavf_alloc_queues() argument
1585 if (adapter->num_req_queues) in iavf_alloc_queues()
1586 num_active_queues = adapter->num_req_queues; in iavf_alloc_queues()
1587 else if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) && in iavf_alloc_queues()
1588 adapter->num_tc) in iavf_alloc_queues()
1589 num_active_queues = adapter->ch_config.total_qps; in iavf_alloc_queues()
1592 adapter->vsi_res->num_queue_pairs, in iavf_alloc_queues()
1596 adapter->tx_rings = kcalloc(num_active_queues, in iavf_alloc_queues()
1598 if (!adapter->tx_rings) in iavf_alloc_queues()
1600 adapter->rx_rings = kcalloc(num_active_queues, in iavf_alloc_queues()
1602 if (!adapter->rx_rings) in iavf_alloc_queues()
1609 tx_ring = &adapter->tx_rings[i]; in iavf_alloc_queues()
1612 tx_ring->netdev = adapter->netdev; in iavf_alloc_queues()
1613 tx_ring->dev = &adapter->pdev->dev; in iavf_alloc_queues()
1614 tx_ring->count = adapter->tx_desc_count; in iavf_alloc_queues()
1616 if (adapter->flags & IAVF_FLAG_WB_ON_ITR_CAPABLE) in iavf_alloc_queues()
1619 rx_ring = &adapter->rx_rings[i]; in iavf_alloc_queues()
1621 rx_ring->netdev = adapter->netdev; in iavf_alloc_queues()
1622 rx_ring->dev = &adapter->pdev->dev; in iavf_alloc_queues()
1623 rx_ring->count = adapter->rx_desc_count; in iavf_alloc_queues()
1627 adapter->num_active_queues = num_active_queues; in iavf_alloc_queues()
1629 iavf_set_queue_vlan_tag_loc(adapter); in iavf_alloc_queues()
1634 iavf_free_queues(adapter); in iavf_alloc_queues()
1640 * @adapter: board private structure to initialize
1645 static int iavf_set_interrupt_capability(struct iavf_adapter *adapter) in iavf_set_interrupt_capability() argument
1651 if (!adapter->vsi_res) { in iavf_set_interrupt_capability()
1655 pairs = adapter->num_active_queues; in iavf_set_interrupt_capability()
1663 (int)adapter->vf_res->max_vectors); in iavf_set_interrupt_capability()
1665 adapter->msix_entries = kcalloc(v_budget, in iavf_set_interrupt_capability()
1667 if (!adapter->msix_entries) { in iavf_set_interrupt_capability()
1673 adapter->msix_entries[vector].entry = vector; in iavf_set_interrupt_capability()
1675 err = iavf_acquire_msix_vectors(adapter, v_budget); in iavf_set_interrupt_capability()
1677 iavf_schedule_finish_config(adapter); in iavf_set_interrupt_capability()
1685 * @adapter: board private structure
1689 static int iavf_config_rss_aq(struct iavf_adapter *adapter) in iavf_config_rss_aq() argument
1692 (struct iavf_aqc_get_set_rss_key_data *)adapter->rss_key; in iavf_config_rss_aq()
1693 struct iavf_hw *hw = &adapter->hw; in iavf_config_rss_aq()
1696 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) { in iavf_config_rss_aq()
1698 dev_err(&adapter->pdev->dev, "Cannot configure RSS, command %d pending\n", in iavf_config_rss_aq()
1699 adapter->current_op); in iavf_config_rss_aq()
1703 status = iavf_aq_set_rss_key(hw, adapter->vsi.id, rss_key); in iavf_config_rss_aq()
1705 dev_err(&adapter->pdev->dev, "Cannot set RSS key, err %s aq_err %s\n", in iavf_config_rss_aq()
1712 status = iavf_aq_set_rss_lut(hw, adapter->vsi.id, false, in iavf_config_rss_aq()
1713 adapter->rss_lut, adapter->rss_lut_size); in iavf_config_rss_aq()
1715 dev_err(&adapter->pdev->dev, "Cannot set RSS lut, err %s aq_err %s\n", in iavf_config_rss_aq()
1727 * @adapter: board private structure
1731 static int iavf_config_rss_reg(struct iavf_adapter *adapter) in iavf_config_rss_reg() argument
1733 struct iavf_hw *hw = &adapter->hw; in iavf_config_rss_reg()
1737 dw = (u32 *)adapter->rss_key; in iavf_config_rss_reg()
1738 for (i = 0; i <= adapter->rss_key_size / 4; i++) in iavf_config_rss_reg()
1741 dw = (u32 *)adapter->rss_lut; in iavf_config_rss_reg()
1742 for (i = 0; i <= adapter->rss_lut_size / 4; i++) in iavf_config_rss_reg()
1752 * @adapter: board private structure
1756 int iavf_config_rss(struct iavf_adapter *adapter) in iavf_config_rss() argument
1759 if (RSS_PF(adapter)) { in iavf_config_rss()
1760 adapter->aq_required |= IAVF_FLAG_AQ_SET_RSS_LUT | in iavf_config_rss()
1763 } else if (RSS_AQ(adapter)) { in iavf_config_rss()
1764 return iavf_config_rss_aq(adapter); in iavf_config_rss()
1766 return iavf_config_rss_reg(adapter); in iavf_config_rss()
1772 * @adapter: board private structure
1774 static void iavf_fill_rss_lut(struct iavf_adapter *adapter) in iavf_fill_rss_lut() argument
1778 for (i = 0; i < adapter->rss_lut_size; i++) in iavf_fill_rss_lut()
1779 adapter->rss_lut[i] = i % adapter->num_active_queues; in iavf_fill_rss_lut()
1784 * @adapter: board private structure
1788 static int iavf_init_rss(struct iavf_adapter *adapter) in iavf_init_rss() argument
1790 struct iavf_hw *hw = &adapter->hw; in iavf_init_rss()
1792 if (!RSS_PF(adapter)) { in iavf_init_rss()
1794 if (adapter->vf_res->vf_cap_flags & in iavf_init_rss()
1796 adapter->hena = IAVF_DEFAULT_RSS_HENA_EXPANDED; in iavf_init_rss()
1798 adapter->hena = IAVF_DEFAULT_RSS_HENA; in iavf_init_rss()
1800 wr32(hw, IAVF_VFQF_HENA(0), (u32)adapter->hena); in iavf_init_rss()
1801 wr32(hw, IAVF_VFQF_HENA(1), (u32)(adapter->hena >> 32)); in iavf_init_rss()
1804 iavf_fill_rss_lut(adapter); in iavf_init_rss()
1805 netdev_rss_key_fill((void *)adapter->rss_key, adapter->rss_key_size); in iavf_init_rss()
1807 return iavf_config_rss(adapter); in iavf_init_rss()
1812 * @adapter: board private structure to initialize
1817 static int iavf_alloc_q_vectors(struct iavf_adapter *adapter) in iavf_alloc_q_vectors() argument
1822 num_q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_alloc_q_vectors()
1823 adapter->q_vectors = kcalloc(num_q_vectors, sizeof(*q_vector), in iavf_alloc_q_vectors()
1825 if (!adapter->q_vectors) in iavf_alloc_q_vectors()
1829 q_vector = &adapter->q_vectors[q_idx]; in iavf_alloc_q_vectors()
1830 q_vector->adapter = adapter; in iavf_alloc_q_vectors()
1831 q_vector->vsi = &adapter->vsi; in iavf_alloc_q_vectors()
1835 netif_napi_add(adapter->netdev, &q_vector->napi, in iavf_alloc_q_vectors()
1844 * @adapter: board private structure to initialize
1850 static void iavf_free_q_vectors(struct iavf_adapter *adapter) in iavf_free_q_vectors() argument
1854 if (!adapter->q_vectors) in iavf_free_q_vectors()
1857 num_q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_free_q_vectors()
1860 struct iavf_q_vector *q_vector = &adapter->q_vectors[q_idx]; in iavf_free_q_vectors()
1864 kfree(adapter->q_vectors); in iavf_free_q_vectors()
1865 adapter->q_vectors = NULL; in iavf_free_q_vectors()
1870 * @adapter: board private structure
1873 static void iavf_reset_interrupt_capability(struct iavf_adapter *adapter) in iavf_reset_interrupt_capability() argument
1875 if (!adapter->msix_entries) in iavf_reset_interrupt_capability()
1878 pci_disable_msix(adapter->pdev); in iavf_reset_interrupt_capability()
1879 kfree(adapter->msix_entries); in iavf_reset_interrupt_capability()
1880 adapter->msix_entries = NULL; in iavf_reset_interrupt_capability()
1885 * @adapter: board private structure to initialize
1888 static int iavf_init_interrupt_scheme(struct iavf_adapter *adapter) in iavf_init_interrupt_scheme() argument
1892 err = iavf_alloc_queues(adapter); in iavf_init_interrupt_scheme()
1894 dev_err(&adapter->pdev->dev, in iavf_init_interrupt_scheme()
1899 err = iavf_set_interrupt_capability(adapter); in iavf_init_interrupt_scheme()
1901 dev_err(&adapter->pdev->dev, in iavf_init_interrupt_scheme()
1906 err = iavf_alloc_q_vectors(adapter); in iavf_init_interrupt_scheme()
1908 dev_err(&adapter->pdev->dev, in iavf_init_interrupt_scheme()
1918 if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) && in iavf_init_interrupt_scheme()
1919 adapter->num_tc) in iavf_init_interrupt_scheme()
1920 dev_info(&adapter->pdev->dev, "ADq Enabled, %u TCs created", in iavf_init_interrupt_scheme()
1921 adapter->num_tc); in iavf_init_interrupt_scheme()
1923 dev_info(&adapter->pdev->dev, "Multiqueue %s: Queue pair count = %u", in iavf_init_interrupt_scheme()
1924 (adapter->num_active_queues > 1) ? "Enabled" : "Disabled", in iavf_init_interrupt_scheme()
1925 adapter->num_active_queues); in iavf_init_interrupt_scheme()
1929 iavf_reset_interrupt_capability(adapter); in iavf_init_interrupt_scheme()
1931 iavf_free_queues(adapter); in iavf_init_interrupt_scheme()
1938 * @adapter: board private structure
1940 static void iavf_free_rss(struct iavf_adapter *adapter) in iavf_free_rss() argument
1942 kfree(adapter->rss_key); in iavf_free_rss()
1943 adapter->rss_key = NULL; in iavf_free_rss()
1945 kfree(adapter->rss_lut); in iavf_free_rss()
1946 adapter->rss_lut = NULL; in iavf_free_rss()
1951 * @adapter: board private structure
1952 * @running: true if adapter->state == __IAVF_RUNNING
1956 static int iavf_reinit_interrupt_scheme(struct iavf_adapter *adapter, bool running) in iavf_reinit_interrupt_scheme() argument
1958 struct net_device *netdev = adapter->netdev; in iavf_reinit_interrupt_scheme()
1962 iavf_free_traffic_irqs(adapter); in iavf_reinit_interrupt_scheme()
1963 iavf_free_misc_irq(adapter); in iavf_reinit_interrupt_scheme()
1964 iavf_reset_interrupt_capability(adapter); in iavf_reinit_interrupt_scheme()
1965 iavf_free_q_vectors(adapter); in iavf_reinit_interrupt_scheme()
1966 iavf_free_queues(adapter); in iavf_reinit_interrupt_scheme()
1968 err = iavf_init_interrupt_scheme(adapter); in iavf_reinit_interrupt_scheme()
1974 err = iavf_request_misc_irq(adapter); in iavf_reinit_interrupt_scheme()
1978 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_reinit_interrupt_scheme()
1980 iavf_map_rings_to_vectors(adapter); in iavf_reinit_interrupt_scheme()
1993 struct iavf_adapter *adapter; in iavf_finish_config() local
1996 adapter = container_of(work, struct iavf_adapter, finish_config); in iavf_finish_config()
2000 mutex_lock(&adapter->crit_lock); in iavf_finish_config()
2002 if ((adapter->flags & IAVF_FLAG_SETUP_NETDEV_FEATURES) && in iavf_finish_config()
2003 adapter->netdev_registered && in iavf_finish_config()
2004 !test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) { in iavf_finish_config()
2005 netdev_update_features(adapter->netdev); in iavf_finish_config()
2006 adapter->flags &= ~IAVF_FLAG_SETUP_NETDEV_FEATURES; in iavf_finish_config()
2009 switch (adapter->state) { in iavf_finish_config()
2011 if (!adapter->netdev_registered) { in iavf_finish_config()
2012 err = register_netdevice(adapter->netdev); in iavf_finish_config()
2014 dev_err(&adapter->pdev->dev, "Unable to register netdev (%d)\n", in iavf_finish_config()
2018 iavf_free_rss(adapter); in iavf_finish_config()
2019 iavf_free_misc_irq(adapter); in iavf_finish_config()
2020 iavf_reset_interrupt_capability(adapter); in iavf_finish_config()
2021 iavf_change_state(adapter, in iavf_finish_config()
2025 adapter->netdev_registered = true; in iavf_finish_config()
2033 pairs = adapter->num_active_queues; in iavf_finish_config()
2034 netif_set_real_num_rx_queues(adapter->netdev, pairs); in iavf_finish_config()
2035 netif_set_real_num_tx_queues(adapter->netdev, pairs); in iavf_finish_config()
2043 mutex_unlock(&adapter->crit_lock); in iavf_finish_config()
2049 * @adapter: board private structure
2051 void iavf_schedule_finish_config(struct iavf_adapter *adapter) in iavf_schedule_finish_config() argument
2053 if (!test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) in iavf_schedule_finish_config()
2054 queue_work(adapter->wq, &adapter->finish_config); in iavf_schedule_finish_config()
2060 * @adapter: pointer to iavf adapter structure
2066 static int iavf_process_aq_command(struct iavf_adapter *adapter) in iavf_process_aq_command() argument
2068 if (adapter->aq_required & IAVF_FLAG_AQ_GET_CONFIG) in iavf_process_aq_command()
2069 return iavf_send_vf_config_msg(adapter); in iavf_process_aq_command()
2070 if (adapter->aq_required & IAVF_FLAG_AQ_GET_OFFLOAD_VLAN_V2_CAPS) in iavf_process_aq_command()
2071 return iavf_send_vf_offload_vlan_v2_msg(adapter); in iavf_process_aq_command()
2072 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_QUEUES) { in iavf_process_aq_command()
2073 iavf_disable_queues(adapter); in iavf_process_aq_command()
2077 if (adapter->aq_required & IAVF_FLAG_AQ_MAP_VECTORS) { in iavf_process_aq_command()
2078 iavf_map_queues(adapter); in iavf_process_aq_command()
2082 if (adapter->aq_required & IAVF_FLAG_AQ_ADD_MAC_FILTER) { in iavf_process_aq_command()
2083 iavf_add_ether_addrs(adapter); in iavf_process_aq_command()
2087 if (adapter->aq_required & IAVF_FLAG_AQ_ADD_VLAN_FILTER) { in iavf_process_aq_command()
2088 iavf_add_vlans(adapter); in iavf_process_aq_command()
2092 if (adapter->aq_required & IAVF_FLAG_AQ_DEL_MAC_FILTER) { in iavf_process_aq_command()
2093 iavf_del_ether_addrs(adapter); in iavf_process_aq_command()
2097 if (adapter->aq_required & IAVF_FLAG_AQ_DEL_VLAN_FILTER) { in iavf_process_aq_command()
2098 iavf_del_vlans(adapter); in iavf_process_aq_command()
2102 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_VLAN_STRIPPING) { in iavf_process_aq_command()
2103 iavf_enable_vlan_stripping(adapter); in iavf_process_aq_command()
2107 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_VLAN_STRIPPING) { in iavf_process_aq_command()
2108 iavf_disable_vlan_stripping(adapter); in iavf_process_aq_command()
2112 if (adapter->aq_required & IAVF_FLAG_AQ_CONFIGURE_QUEUES) { in iavf_process_aq_command()
2113 iavf_configure_queues(adapter); in iavf_process_aq_command()
2117 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_QUEUES) { in iavf_process_aq_command()
2118 iavf_enable_queues(adapter); in iavf_process_aq_command()
2122 if (adapter->aq_required & IAVF_FLAG_AQ_CONFIGURE_RSS) { in iavf_process_aq_command()
2127 adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_RSS; in iavf_process_aq_command()
2130 if (adapter->aq_required & IAVF_FLAG_AQ_GET_HENA) { in iavf_process_aq_command()
2131 iavf_get_hena(adapter); in iavf_process_aq_command()
2134 if (adapter->aq_required & IAVF_FLAG_AQ_SET_HENA) { in iavf_process_aq_command()
2135 iavf_set_hena(adapter); in iavf_process_aq_command()
2138 if (adapter->aq_required & IAVF_FLAG_AQ_SET_RSS_KEY) { in iavf_process_aq_command()
2139 iavf_set_rss_key(adapter); in iavf_process_aq_command()
2142 if (adapter->aq_required & IAVF_FLAG_AQ_SET_RSS_LUT) { in iavf_process_aq_command()
2143 iavf_set_rss_lut(adapter); in iavf_process_aq_command()
2147 if (adapter->aq_required & IAVF_FLAG_AQ_CONFIGURE_PROMISC_MODE) { in iavf_process_aq_command()
2148 iavf_set_promiscuous(adapter); in iavf_process_aq_command()
2152 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_CHANNELS) { in iavf_process_aq_command()
2153 iavf_enable_channels(adapter); in iavf_process_aq_command()
2157 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_CHANNELS) { in iavf_process_aq_command()
2158 iavf_disable_channels(adapter); in iavf_process_aq_command()
2161 if (adapter->aq_required & IAVF_FLAG_AQ_ADD_CLOUD_FILTER) { in iavf_process_aq_command()
2162 iavf_add_cloud_filter(adapter); in iavf_process_aq_command()
2166 if (adapter->aq_required & IAVF_FLAG_AQ_DEL_CLOUD_FILTER) { in iavf_process_aq_command()
2167 iavf_del_cloud_filter(adapter); in iavf_process_aq_command()
2170 if (adapter->aq_required & IAVF_FLAG_AQ_DEL_CLOUD_FILTER) { in iavf_process_aq_command()
2171 iavf_del_cloud_filter(adapter); in iavf_process_aq_command()
2174 if (adapter->aq_required & IAVF_FLAG_AQ_ADD_CLOUD_FILTER) { in iavf_process_aq_command()
2175 iavf_add_cloud_filter(adapter); in iavf_process_aq_command()
2178 if (adapter->aq_required & IAVF_FLAG_AQ_ADD_FDIR_FILTER) { in iavf_process_aq_command()
2179 iavf_add_fdir_filter(adapter); in iavf_process_aq_command()
2182 if (adapter->aq_required & IAVF_FLAG_AQ_DEL_FDIR_FILTER) { in iavf_process_aq_command()
2183 iavf_del_fdir_filter(adapter); in iavf_process_aq_command()
2186 if (adapter->aq_required & IAVF_FLAG_AQ_ADD_ADV_RSS_CFG) { in iavf_process_aq_command()
2187 iavf_add_adv_rss_cfg(adapter); in iavf_process_aq_command()
2190 if (adapter->aq_required & IAVF_FLAG_AQ_DEL_ADV_RSS_CFG) { in iavf_process_aq_command()
2191 iavf_del_adv_rss_cfg(adapter); in iavf_process_aq_command()
2194 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_CTAG_VLAN_STRIPPING) { in iavf_process_aq_command()
2195 iavf_disable_vlan_stripping_v2(adapter, ETH_P_8021Q); in iavf_process_aq_command()
2198 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_STAG_VLAN_STRIPPING) { in iavf_process_aq_command()
2199 iavf_disable_vlan_stripping_v2(adapter, ETH_P_8021AD); in iavf_process_aq_command()
2202 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_CTAG_VLAN_STRIPPING) { in iavf_process_aq_command()
2203 iavf_enable_vlan_stripping_v2(adapter, ETH_P_8021Q); in iavf_process_aq_command()
2206 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_STAG_VLAN_STRIPPING) { in iavf_process_aq_command()
2207 iavf_enable_vlan_stripping_v2(adapter, ETH_P_8021AD); in iavf_process_aq_command()
2210 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_CTAG_VLAN_INSERTION) { in iavf_process_aq_command()
2211 iavf_disable_vlan_insertion_v2(adapter, ETH_P_8021Q); in iavf_process_aq_command()
2214 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_STAG_VLAN_INSERTION) { in iavf_process_aq_command()
2215 iavf_disable_vlan_insertion_v2(adapter, ETH_P_8021AD); in iavf_process_aq_command()
2218 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_CTAG_VLAN_INSERTION) { in iavf_process_aq_command()
2219 iavf_enable_vlan_insertion_v2(adapter, ETH_P_8021Q); in iavf_process_aq_command()
2222 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_STAG_VLAN_INSERTION) { in iavf_process_aq_command()
2223 iavf_enable_vlan_insertion_v2(adapter, ETH_P_8021AD); in iavf_process_aq_command()
2227 if (adapter->aq_required & IAVF_FLAG_AQ_REQUEST_STATS) { in iavf_process_aq_command()
2228 iavf_request_stats(adapter); in iavf_process_aq_command()
2237 * @adapter: board private structure
2247 iavf_set_vlan_offload_features(struct iavf_adapter *adapter, in iavf_set_vlan_offload_features() argument
2277 if (VLAN_ALLOWED(adapter)) { in iavf_set_vlan_offload_features()
2287 } else if (VLAN_V2_ALLOWED(adapter)) { in iavf_set_vlan_offload_features()
2315 adapter->aq_required |= aq_required; in iavf_set_vlan_offload_features()
2316 mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); in iavf_set_vlan_offload_features()
2322 * @adapter: board private structure
2328 static void iavf_startup(struct iavf_adapter *adapter) in iavf_startup() argument
2330 struct pci_dev *pdev = adapter->pdev; in iavf_startup()
2331 struct iavf_hw *hw = &adapter->hw; in iavf_startup()
2335 WARN_ON(adapter->state != __IAVF_STARTUP); in iavf_startup()
2338 adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED; in iavf_startup()
2339 adapter->flags &= ~IAVF_FLAG_RESET_PENDING; in iavf_startup()
2363 ret = iavf_send_api_ver(adapter); in iavf_startup()
2369 iavf_change_state(adapter, __IAVF_INIT_VERSION_CHECK); in iavf_startup()
2372 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_startup()
2377 * @adapter: board private structure
2383 static void iavf_init_version_check(struct iavf_adapter *adapter) in iavf_init_version_check() argument
2385 struct pci_dev *pdev = adapter->pdev; in iavf_init_version_check()
2386 struct iavf_hw *hw = &adapter->hw; in iavf_init_version_check()
2389 WARN_ON(adapter->state != __IAVF_INIT_VERSION_CHECK); in iavf_init_version_check()
2394 iavf_change_state(adapter, __IAVF_STARTUP); in iavf_init_version_check()
2399 err = iavf_verify_api_ver(adapter); in iavf_init_version_check()
2402 err = iavf_send_api_ver(adapter); in iavf_init_version_check()
2405 adapter->pf_version.major, in iavf_init_version_check()
2406 adapter->pf_version.minor, in iavf_init_version_check()
2411 err = iavf_send_vf_config_msg(adapter); in iavf_init_version_check()
2417 iavf_change_state(adapter, __IAVF_INIT_GET_RESOURCES); in iavf_init_version_check()
2420 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_init_version_check()
2425 * @adapter: board private structure
2427 int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter) in iavf_parse_vf_resource_msg() argument
2429 int i, num_req_queues = adapter->num_req_queues; in iavf_parse_vf_resource_msg()
2430 struct iavf_vsi *vsi = &adapter->vsi; in iavf_parse_vf_resource_msg()
2432 for (i = 0; i < adapter->vf_res->num_vsis; i++) { in iavf_parse_vf_resource_msg()
2433 if (adapter->vf_res->vsi_res[i].vsi_type == VIRTCHNL_VSI_SRIOV) in iavf_parse_vf_resource_msg()
2434 adapter->vsi_res = &adapter->vf_res->vsi_res[i]; in iavf_parse_vf_resource_msg()
2436 if (!adapter->vsi_res) { in iavf_parse_vf_resource_msg()
2437 dev_err(&adapter->pdev->dev, "No LAN VSI found\n"); in iavf_parse_vf_resource_msg()
2442 num_req_queues > adapter->vsi_res->num_queue_pairs) { in iavf_parse_vf_resource_msg()
2447 dev_err(&adapter->pdev->dev, in iavf_parse_vf_resource_msg()
2450 adapter->vsi_res->num_queue_pairs); in iavf_parse_vf_resource_msg()
2451 adapter->flags |= IAVF_FLAG_REINIT_MSIX_NEEDED; in iavf_parse_vf_resource_msg()
2452 adapter->num_req_queues = adapter->vsi_res->num_queue_pairs; in iavf_parse_vf_resource_msg()
2453 iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); in iavf_parse_vf_resource_msg()
2457 adapter->num_req_queues = 0; in iavf_parse_vf_resource_msg()
2458 adapter->vsi.id = adapter->vsi_res->vsi_id; in iavf_parse_vf_resource_msg()
2460 adapter->vsi.back = adapter; in iavf_parse_vf_resource_msg()
2461 adapter->vsi.base_vector = 1; in iavf_parse_vf_resource_msg()
2462 vsi->netdev = adapter->netdev; in iavf_parse_vf_resource_msg()
2463 vsi->qs_handle = adapter->vsi_res->qset_handle; in iavf_parse_vf_resource_msg()
2464 if (adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) { in iavf_parse_vf_resource_msg()
2465 adapter->rss_key_size = adapter->vf_res->rss_key_size; in iavf_parse_vf_resource_msg()
2466 adapter->rss_lut_size = adapter->vf_res->rss_lut_size; in iavf_parse_vf_resource_msg()
2468 adapter->rss_key_size = IAVF_HKEY_ARRAY_SIZE; in iavf_parse_vf_resource_msg()
2469 adapter->rss_lut_size = IAVF_HLUT_ARRAY_SIZE; in iavf_parse_vf_resource_msg()
2477 * @adapter: board private structure
2484 static void iavf_init_get_resources(struct iavf_adapter *adapter) in iavf_init_get_resources() argument
2486 struct pci_dev *pdev = adapter->pdev; in iavf_init_get_resources()
2487 struct iavf_hw *hw = &adapter->hw; in iavf_init_get_resources()
2490 WARN_ON(adapter->state != __IAVF_INIT_GET_RESOURCES); in iavf_init_get_resources()
2492 if (!adapter->vf_res) { in iavf_init_get_resources()
2493 adapter->vf_res = kzalloc(IAVF_VIRTCHNL_VF_RESOURCE_SIZE, in iavf_init_get_resources()
2495 if (!adapter->vf_res) { in iavf_init_get_resources()
2500 err = iavf_get_vf_config(adapter); in iavf_init_get_resources()
2502 err = iavf_send_vf_config_msg(adapter); in iavf_init_get_resources()
2518 err = iavf_parse_vf_resource_msg(adapter); in iavf_init_get_resources()
2528 adapter->extended_caps = IAVF_EXTENDED_CAPS; in iavf_init_get_resources()
2530 iavf_change_state(adapter, __IAVF_INIT_EXTENDED_CAPS); in iavf_init_get_resources()
2534 kfree(adapter->vf_res); in iavf_init_get_resources()
2535 adapter->vf_res = NULL; in iavf_init_get_resources()
2537 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_init_get_resources()
2542 * @adapter: board private structure
2548 static void iavf_init_send_offload_vlan_v2_caps(struct iavf_adapter *adapter) in iavf_init_send_offload_vlan_v2_caps() argument
2552 WARN_ON(!(adapter->extended_caps & IAVF_EXTENDED_CAP_SEND_VLAN_V2)); in iavf_init_send_offload_vlan_v2_caps()
2554 ret = iavf_send_vf_offload_vlan_v2_msg(adapter); in iavf_init_send_offload_vlan_v2_caps()
2560 adapter->extended_caps &= ~IAVF_EXTENDED_CAP_RECV_VLAN_V2; in iavf_init_send_offload_vlan_v2_caps()
2564 adapter->extended_caps &= ~IAVF_EXTENDED_CAP_SEND_VLAN_V2; in iavf_init_send_offload_vlan_v2_caps()
2569 * @adapter: board private structure
2574 static void iavf_init_recv_offload_vlan_v2_caps(struct iavf_adapter *adapter) in iavf_init_recv_offload_vlan_v2_caps() argument
2578 WARN_ON(!(adapter->extended_caps & IAVF_EXTENDED_CAP_RECV_VLAN_V2)); in iavf_init_recv_offload_vlan_v2_caps()
2580 memset(&adapter->vlan_v2_caps, 0, sizeof(adapter->vlan_v2_caps)); in iavf_init_recv_offload_vlan_v2_caps()
2582 ret = iavf_get_vf_vlan_v2_caps(adapter); in iavf_init_recv_offload_vlan_v2_caps()
2587 adapter->extended_caps &= ~IAVF_EXTENDED_CAP_RECV_VLAN_V2; in iavf_init_recv_offload_vlan_v2_caps()
2593 adapter->extended_caps |= IAVF_EXTENDED_CAP_SEND_VLAN_V2; in iavf_init_recv_offload_vlan_v2_caps()
2594 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_init_recv_offload_vlan_v2_caps()
2599 * @adapter: board private structure
2608 static void iavf_init_process_extended_caps(struct iavf_adapter *adapter) in iavf_init_process_extended_caps() argument
2610 WARN_ON(adapter->state != __IAVF_INIT_EXTENDED_CAPS); in iavf_init_process_extended_caps()
2613 if (adapter->extended_caps & IAVF_EXTENDED_CAP_SEND_VLAN_V2) { in iavf_init_process_extended_caps()
2614 iavf_init_send_offload_vlan_v2_caps(adapter); in iavf_init_process_extended_caps()
2616 } else if (adapter->extended_caps & IAVF_EXTENDED_CAP_RECV_VLAN_V2) { in iavf_init_process_extended_caps()
2617 iavf_init_recv_offload_vlan_v2_caps(adapter); in iavf_init_process_extended_caps()
2624 iavf_change_state(adapter, __IAVF_INIT_CONFIG_ADAPTER); in iavf_init_process_extended_caps()
2629 * @adapter: board private structure
2634 static void iavf_init_config_adapter(struct iavf_adapter *adapter) in iavf_init_config_adapter() argument
2636 struct net_device *netdev = adapter->netdev; in iavf_init_config_adapter()
2637 struct pci_dev *pdev = adapter->pdev; in iavf_init_config_adapter()
2640 WARN_ON(adapter->state != __IAVF_INIT_CONFIG_ADAPTER); in iavf_init_config_adapter()
2642 if (iavf_process_config(adapter)) in iavf_init_config_adapter()
2645 adapter->current_op = VIRTCHNL_OP_UNKNOWN; in iavf_init_config_adapter()
2647 adapter->flags |= IAVF_FLAG_RX_CSUM_ENABLED; in iavf_init_config_adapter()
2657 if (!is_valid_ether_addr(adapter->hw.mac.addr)) { in iavf_init_config_adapter()
2659 adapter->hw.mac.addr); in iavf_init_config_adapter()
2661 ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr); in iavf_init_config_adapter()
2663 eth_hw_addr_set(netdev, adapter->hw.mac.addr); in iavf_init_config_adapter()
2664 ether_addr_copy(netdev->perm_addr, adapter->hw.mac.addr); in iavf_init_config_adapter()
2667 adapter->tx_desc_count = IAVF_DEFAULT_TXD; in iavf_init_config_adapter()
2668 adapter->rx_desc_count = IAVF_DEFAULT_RXD; in iavf_init_config_adapter()
2669 err = iavf_init_interrupt_scheme(adapter); in iavf_init_config_adapter()
2672 iavf_map_rings_to_vectors(adapter); in iavf_init_config_adapter()
2673 if (adapter->vf_res->vf_cap_flags & in iavf_init_config_adapter()
2675 adapter->flags |= IAVF_FLAG_WB_ON_ITR_CAPABLE; in iavf_init_config_adapter()
2677 err = iavf_request_misc_irq(adapter); in iavf_init_config_adapter()
2682 adapter->link_up = false; in iavf_init_config_adapter()
2685 if (CLIENT_ALLOWED(adapter)) { in iavf_init_config_adapter()
2686 err = iavf_lan_add_device(adapter); in iavf_init_config_adapter()
2691 dev_info(&pdev->dev, "MAC address: %pM\n", adapter->hw.mac.addr); in iavf_init_config_adapter()
2695 iavf_change_state(adapter, __IAVF_DOWN); in iavf_init_config_adapter()
2696 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_init_config_adapter()
2698 iavf_misc_irq_enable(adapter); in iavf_init_config_adapter()
2699 wake_up(&adapter->down_waitqueue); in iavf_init_config_adapter()
2701 adapter->rss_key = kzalloc(adapter->rss_key_size, GFP_KERNEL); in iavf_init_config_adapter()
2702 adapter->rss_lut = kzalloc(adapter->rss_lut_size, GFP_KERNEL); in iavf_init_config_adapter()
2703 if (!adapter->rss_key || !adapter->rss_lut) { in iavf_init_config_adapter()
2707 if (RSS_AQ(adapter)) in iavf_init_config_adapter()
2708 adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_RSS; in iavf_init_config_adapter()
2710 iavf_init_rss(adapter); in iavf_init_config_adapter()
2712 if (VLAN_V2_ALLOWED(adapter)) in iavf_init_config_adapter()
2714 iavf_set_vlan_offload_features(adapter, 0, netdev->features); in iavf_init_config_adapter()
2716 iavf_schedule_finish_config(adapter); in iavf_init_config_adapter()
2720 iavf_free_rss(adapter); in iavf_init_config_adapter()
2721 iavf_free_misc_irq(adapter); in iavf_init_config_adapter()
2723 iavf_reset_interrupt_capability(adapter); in iavf_init_config_adapter()
2725 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_init_config_adapter()
2734 struct iavf_adapter *adapter = container_of(work, in iavf_watchdog_task() local
2737 struct iavf_hw *hw = &adapter->hw; in iavf_watchdog_task()
2740 if (!mutex_trylock(&adapter->crit_lock)) { in iavf_watchdog_task()
2741 if (adapter->state == __IAVF_REMOVE) in iavf_watchdog_task()
2747 if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) in iavf_watchdog_task()
2748 iavf_change_state(adapter, __IAVF_COMM_FAILED); in iavf_watchdog_task()
2750 switch (adapter->state) { in iavf_watchdog_task()
2752 iavf_startup(adapter); in iavf_watchdog_task()
2753 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2754 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2758 iavf_init_version_check(adapter); in iavf_watchdog_task()
2759 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2760 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2764 iavf_init_get_resources(adapter); in iavf_watchdog_task()
2765 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2766 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2770 iavf_init_process_extended_caps(adapter); in iavf_watchdog_task()
2771 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2772 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2776 iavf_init_config_adapter(adapter); in iavf_watchdog_task()
2777 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2778 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2783 &adapter->crit_section)) { in iavf_watchdog_task()
2788 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2791 if (++adapter->aq_wait_count > IAVF_AQ_MAX_ERR) { in iavf_watchdog_task()
2792 dev_err(&adapter->pdev->dev, in iavf_watchdog_task()
2794 adapter->flags |= IAVF_FLAG_PF_COMMS_FAILED; in iavf_watchdog_task()
2796 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2797 queue_delayed_work(adapter->wq, in iavf_watchdog_task()
2798 &adapter->watchdog_task, (5 * HZ)); in iavf_watchdog_task()
2802 iavf_change_state(adapter, adapter->last_state); in iavf_watchdog_task()
2803 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2804 queue_delayed_work(adapter->wq, &adapter->watchdog_task, HZ); in iavf_watchdog_task()
2808 &adapter->crit_section)) { in iavf_watchdog_task()
2813 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_watchdog_task()
2814 adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED; in iavf_watchdog_task()
2815 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2823 dev_err(&adapter->pdev->dev, in iavf_watchdog_task()
2829 iavf_change_state(adapter, __IAVF_STARTUP); in iavf_watchdog_task()
2830 adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED; in iavf_watchdog_task()
2832 adapter->aq_required = 0; in iavf_watchdog_task()
2833 adapter->current_op = VIRTCHNL_OP_UNKNOWN; in iavf_watchdog_task()
2834 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2835 queue_delayed_work(adapter->wq, in iavf_watchdog_task()
2836 &adapter->watchdog_task, in iavf_watchdog_task()
2840 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2841 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2848 if (adapter->current_op) { in iavf_watchdog_task()
2850 dev_dbg(&adapter->pdev->dev, in iavf_watchdog_task()
2852 iavf_send_api_ver(adapter); in iavf_watchdog_task()
2855 int ret = iavf_process_aq_command(adapter); in iavf_watchdog_task()
2862 adapter->state == __IAVF_RUNNING) in iavf_watchdog_task()
2863 iavf_request_stats(adapter); in iavf_watchdog_task()
2865 if (adapter->state == __IAVF_RUNNING) in iavf_watchdog_task()
2866 iavf_detect_recover_hung(&adapter->vsi); in iavf_watchdog_task()
2870 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2877 adapter->aq_required = 0; in iavf_watchdog_task()
2878 adapter->current_op = VIRTCHNL_OP_UNKNOWN; in iavf_watchdog_task()
2879 dev_err(&adapter->pdev->dev, "Hardware reset detected\n"); in iavf_watchdog_task()
2880 iavf_schedule_reset(adapter, IAVF_FLAG_RESET_PENDING); in iavf_watchdog_task()
2881 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2882 queue_delayed_work(adapter->wq, in iavf_watchdog_task()
2883 &adapter->watchdog_task, HZ * 2); in iavf_watchdog_task()
2887 schedule_delayed_work(&adapter->client_task, msecs_to_jiffies(5)); in iavf_watchdog_task()
2888 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2890 if (adapter->state >= __IAVF_DOWN) in iavf_watchdog_task()
2891 queue_work(adapter->wq, &adapter->adminq_task); in iavf_watchdog_task()
2892 if (adapter->aq_required) in iavf_watchdog_task()
2893 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2896 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2902 * @adapter: board private structure
2907 static void iavf_disable_vf(struct iavf_adapter *adapter) in iavf_disable_vf() argument
2913 adapter->flags |= IAVF_FLAG_PF_COMMS_FAILED; in iavf_disable_vf()
2919 if (adapter->state == __IAVF_RUNNING) { in iavf_disable_vf()
2920 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_disable_vf()
2921 netif_carrier_off(adapter->netdev); in iavf_disable_vf()
2922 netif_tx_disable(adapter->netdev); in iavf_disable_vf()
2923 adapter->link_up = false; in iavf_disable_vf()
2924 iavf_napi_disable_all(adapter); in iavf_disable_vf()
2925 iavf_irq_disable(adapter); in iavf_disable_vf()
2926 iavf_free_traffic_irqs(adapter); in iavf_disable_vf()
2927 iavf_free_all_tx_resources(adapter); in iavf_disable_vf()
2928 iavf_free_all_rx_resources(adapter); in iavf_disable_vf()
2931 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_disable_vf()
2934 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { in iavf_disable_vf()
2939 list_for_each_entry_safe(fv, fvtmp, &adapter->vlan_filter_list, list) { in iavf_disable_vf()
2943 adapter->num_vlan_filters = 0; in iavf_disable_vf()
2945 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_disable_vf()
2947 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_disable_vf()
2948 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, list) { in iavf_disable_vf()
2951 adapter->num_cloud_filters--; in iavf_disable_vf()
2953 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_disable_vf()
2955 iavf_free_misc_irq(adapter); in iavf_disable_vf()
2956 iavf_reset_interrupt_capability(adapter); in iavf_disable_vf()
2957 iavf_free_q_vectors(adapter); in iavf_disable_vf()
2958 iavf_free_queues(adapter); in iavf_disable_vf()
2959 memset(adapter->vf_res, 0, IAVF_VIRTCHNL_VF_RESOURCE_SIZE); in iavf_disable_vf()
2960 iavf_shutdown_adminq(&adapter->hw); in iavf_disable_vf()
2961 adapter->flags &= ~IAVF_FLAG_RESET_PENDING; in iavf_disable_vf()
2962 iavf_change_state(adapter, __IAVF_DOWN); in iavf_disable_vf()
2963 wake_up(&adapter->down_waitqueue); in iavf_disable_vf()
2964 dev_info(&adapter->pdev->dev, "Reset task did not complete, VF disabled\n"); in iavf_disable_vf()
2977 struct iavf_adapter *adapter = container_of(work, in iavf_reset_task() local
2980 struct virtchnl_vf_resource *vfres = adapter->vf_res; in iavf_reset_task()
2981 struct net_device *netdev = adapter->netdev; in iavf_reset_task()
2982 struct iavf_hw *hw = &adapter->hw; in iavf_reset_task()
2993 if (!mutex_trylock(&adapter->crit_lock)) { in iavf_reset_task()
2994 if (adapter->state != __IAVF_REMOVE) in iavf_reset_task()
2995 queue_work(adapter->wq, &adapter->reset_task); in iavf_reset_task()
3000 while (!mutex_trylock(&adapter->client_lock)) in iavf_reset_task()
3002 if (CLIENT_ENABLED(adapter)) { in iavf_reset_task()
3003 adapter->flags &= ~(IAVF_FLAG_CLIENT_NEEDS_OPEN | in iavf_reset_task()
3007 cancel_delayed_work_sync(&adapter->client_task); in iavf_reset_task()
3008 iavf_notify_client_close(&adapter->vsi, true); in iavf_reset_task()
3010 iavf_misc_irq_disable(adapter); in iavf_reset_task()
3011 if (adapter->flags & IAVF_FLAG_RESET_NEEDED) { in iavf_reset_task()
3012 adapter->flags &= ~IAVF_FLAG_RESET_NEEDED; in iavf_reset_task()
3018 iavf_request_reset(adapter); in iavf_reset_task()
3020 adapter->flags |= IAVF_FLAG_RESET_PENDING; in iavf_reset_task()
3031 dev_info(&adapter->pdev->dev, "Never saw reset\n"); in iavf_reset_task()
3046 pci_set_master(adapter->pdev); in iavf_reset_task()
3047 pci_restore_msi_state(adapter->pdev); in iavf_reset_task()
3050 dev_err(&adapter->pdev->dev, "Reset never finished (%x)\n", in iavf_reset_task()
3052 iavf_disable_vf(adapter); in iavf_reset_task()
3053 mutex_unlock(&adapter->client_lock); in iavf_reset_task()
3054 mutex_unlock(&adapter->crit_lock); in iavf_reset_task()
3063 running = adapter->state == __IAVF_RUNNING; in iavf_reset_task()
3068 adapter->link_up = false; in iavf_reset_task()
3069 iavf_napi_disable_all(adapter); in iavf_reset_task()
3071 iavf_irq_disable(adapter); in iavf_reset_task()
3073 iavf_change_state(adapter, __IAVF_RESETTING); in iavf_reset_task()
3074 adapter->flags &= ~IAVF_FLAG_RESET_PENDING; in iavf_reset_task()
3079 iavf_free_all_rx_resources(adapter); in iavf_reset_task()
3080 iavf_free_all_tx_resources(adapter); in iavf_reset_task()
3082 adapter->flags |= IAVF_FLAG_QUEUES_DISABLED; in iavf_reset_task()
3085 adapter->current_op = VIRTCHNL_OP_UNKNOWN; in iavf_reset_task()
3088 dev_info(&adapter->pdev->dev, "Failed to init adminq: %d\n", in iavf_reset_task()
3092 adapter->aq_required = 0; in iavf_reset_task()
3094 if ((adapter->flags & IAVF_FLAG_REINIT_MSIX_NEEDED) || in iavf_reset_task()
3095 (adapter->flags & IAVF_FLAG_REINIT_ITR_NEEDED)) { in iavf_reset_task()
3096 err = iavf_reinit_interrupt_scheme(adapter, running); in iavf_reset_task()
3101 if (RSS_AQ(adapter)) { in iavf_reset_task()
3102 adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_RSS; in iavf_reset_task()
3104 err = iavf_init_rss(adapter); in iavf_reset_task()
3109 adapter->aq_required |= IAVF_FLAG_AQ_GET_CONFIG; in iavf_reset_task()
3116 adapter->aq_required |= IAVF_FLAG_AQ_GET_OFFLOAD_VLAN_V2_CAPS; in iavf_reset_task()
3117 adapter->aq_required |= IAVF_FLAG_AQ_MAP_VECTORS; in iavf_reset_task()
3119 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_reset_task()
3125 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { in iavf_reset_task()
3126 if (ether_addr_equal(f->macaddr, adapter->hw.mac.addr)) { in iavf_reset_task()
3132 list_for_each_entry(f, &adapter->mac_filter_list, list) { in iavf_reset_task()
3135 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_reset_task()
3138 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_reset_task()
3140 adapter->num_tc) { in iavf_reset_task()
3141 list_for_each_entry(cf, &adapter->cloud_filter_list, list) { in iavf_reset_task()
3145 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_reset_task()
3147 adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER; in iavf_reset_task()
3148 adapter->aq_required |= IAVF_FLAG_AQ_ADD_CLOUD_FILTER; in iavf_reset_task()
3149 iavf_misc_irq_enable(adapter); in iavf_reset_task()
3151 mod_delayed_work(adapter->wq, &adapter->watchdog_task, 2); in iavf_reset_task()
3158 err = iavf_setup_all_tx_resources(adapter); in iavf_reset_task()
3163 err = iavf_setup_all_rx_resources(adapter); in iavf_reset_task()
3167 if ((adapter->flags & IAVF_FLAG_REINIT_MSIX_NEEDED) || in iavf_reset_task()
3168 (adapter->flags & IAVF_FLAG_REINIT_ITR_NEEDED)) { in iavf_reset_task()
3169 err = iavf_request_traffic_irqs(adapter, netdev->name); in iavf_reset_task()
3173 adapter->flags &= ~IAVF_FLAG_REINIT_MSIX_NEEDED; in iavf_reset_task()
3176 iavf_configure(adapter); in iavf_reset_task()
3181 iavf_up_complete(adapter); in iavf_reset_task()
3183 iavf_irq_enable(adapter, true); in iavf_reset_task()
3185 iavf_change_state(adapter, __IAVF_DOWN); in iavf_reset_task()
3186 wake_up(&adapter->down_waitqueue); in iavf_reset_task()
3189 adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED; in iavf_reset_task()
3191 wake_up(&adapter->reset_waitqueue); in iavf_reset_task()
3192 mutex_unlock(&adapter->client_lock); in iavf_reset_task()
3193 mutex_unlock(&adapter->crit_lock); in iavf_reset_task()
3198 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_reset_task()
3199 iavf_free_traffic_irqs(adapter); in iavf_reset_task()
3201 iavf_disable_vf(adapter); in iavf_reset_task()
3203 mutex_unlock(&adapter->client_lock); in iavf_reset_task()
3204 mutex_unlock(&adapter->crit_lock); in iavf_reset_task()
3205 dev_err(&adapter->pdev->dev, "failed to allocate resources during reinit\n"); in iavf_reset_task()
3214 struct iavf_adapter *adapter = in iavf_adminq_task() local
3216 struct iavf_hw *hw = &adapter->hw; in iavf_adminq_task()
3223 if (!mutex_trylock(&adapter->crit_lock)) { in iavf_adminq_task()
3224 if (adapter->state == __IAVF_REMOVE) in iavf_adminq_task()
3227 queue_work(adapter->wq, &adapter->adminq_task); in iavf_adminq_task()
3231 if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) in iavf_adminq_task()
3247 iavf_virtchnl_completion(adapter, v_op, v_ret, event.msg_buf, in iavf_adminq_task()
3253 if (iavf_is_reset_in_progress(adapter)) in iavf_adminq_task()
3262 dev_info(&adapter->pdev->dev, "ARQ VF Error detected\n"); in iavf_adminq_task()
3266 dev_info(&adapter->pdev->dev, "ARQ Overflow Error detected\n"); in iavf_adminq_task()
3270 dev_info(&adapter->pdev->dev, "ARQ Critical Error detected\n"); in iavf_adminq_task()
3279 dev_info(&adapter->pdev->dev, "ASQ VF Error detected\n"); in iavf_adminq_task()
3283 dev_info(&adapter->pdev->dev, "ASQ Overflow Error detected\n"); in iavf_adminq_task()
3287 dev_info(&adapter->pdev->dev, "ASQ Critical Error detected\n"); in iavf_adminq_task()
3296 mutex_unlock(&adapter->crit_lock); in iavf_adminq_task()
3299 iavf_misc_irq_enable(adapter); in iavf_adminq_task()
3311 struct iavf_adapter *adapter = in iavf_client_task() local
3318 if (!mutex_trylock(&adapter->client_lock)) in iavf_client_task()
3321 if (adapter->flags & IAVF_FLAG_SERVICE_CLIENT_REQUESTED) { in iavf_client_task()
3322 iavf_client_subtask(adapter); in iavf_client_task()
3323 adapter->flags &= ~IAVF_FLAG_SERVICE_CLIENT_REQUESTED; in iavf_client_task()
3326 if (adapter->flags & IAVF_FLAG_CLIENT_NEEDS_L2_PARAMS) { in iavf_client_task()
3327 iavf_notify_client_l2_params(&adapter->vsi); in iavf_client_task()
3328 adapter->flags &= ~IAVF_FLAG_CLIENT_NEEDS_L2_PARAMS; in iavf_client_task()
3331 if (adapter->flags & IAVF_FLAG_CLIENT_NEEDS_CLOSE) { in iavf_client_task()
3332 iavf_notify_client_close(&adapter->vsi, false); in iavf_client_task()
3333 adapter->flags &= ~IAVF_FLAG_CLIENT_NEEDS_CLOSE; in iavf_client_task()
3336 if (adapter->flags & IAVF_FLAG_CLIENT_NEEDS_OPEN) { in iavf_client_task()
3337 iavf_notify_client_open(&adapter->vsi); in iavf_client_task()
3338 adapter->flags &= ~IAVF_FLAG_CLIENT_NEEDS_OPEN; in iavf_client_task()
3341 mutex_unlock(&adapter->client_lock); in iavf_client_task()
3346 * @adapter: board private structure
3350 void iavf_free_all_tx_resources(struct iavf_adapter *adapter) in iavf_free_all_tx_resources() argument
3354 if (!adapter->tx_rings) in iavf_free_all_tx_resources()
3357 for (i = 0; i < adapter->num_active_queues; i++) in iavf_free_all_tx_resources()
3358 if (adapter->tx_rings[i].desc) in iavf_free_all_tx_resources()
3359 iavf_free_tx_resources(&adapter->tx_rings[i]); in iavf_free_all_tx_resources()
3364 * @adapter: board private structure
3372 static int iavf_setup_all_tx_resources(struct iavf_adapter *adapter) in iavf_setup_all_tx_resources() argument
3376 for (i = 0; i < adapter->num_active_queues; i++) { in iavf_setup_all_tx_resources()
3377 adapter->tx_rings[i].count = adapter->tx_desc_count; in iavf_setup_all_tx_resources()
3378 err = iavf_setup_tx_descriptors(&adapter->tx_rings[i]); in iavf_setup_all_tx_resources()
3381 dev_err(&adapter->pdev->dev, in iavf_setup_all_tx_resources()
3391 * @adapter: board private structure
3399 static int iavf_setup_all_rx_resources(struct iavf_adapter *adapter) in iavf_setup_all_rx_resources() argument
3403 for (i = 0; i < adapter->num_active_queues; i++) { in iavf_setup_all_rx_resources()
3404 adapter->rx_rings[i].count = adapter->rx_desc_count; in iavf_setup_all_rx_resources()
3405 err = iavf_setup_rx_descriptors(&adapter->rx_rings[i]); in iavf_setup_all_rx_resources()
3408 dev_err(&adapter->pdev->dev, in iavf_setup_all_rx_resources()
3417 * @adapter: board private structure
3421 void iavf_free_all_rx_resources(struct iavf_adapter *adapter) in iavf_free_all_rx_resources() argument
3425 if (!adapter->rx_rings) in iavf_free_all_rx_resources()
3428 for (i = 0; i < adapter->num_active_queues; i++) in iavf_free_all_rx_resources()
3429 if (adapter->rx_rings[i].desc) in iavf_free_all_rx_resources()
3430 iavf_free_rx_resources(&adapter->rx_rings[i]); in iavf_free_all_rx_resources()
3435 * @adapter: board private structure
3438 static int iavf_validate_tx_bandwidth(struct iavf_adapter *adapter, in iavf_validate_tx_bandwidth() argument
3443 if (ADV_LINK_SUPPORT(adapter)) { in iavf_validate_tx_bandwidth()
3444 if (adapter->link_speed_mbps < U32_MAX) { in iavf_validate_tx_bandwidth()
3445 speed = adapter->link_speed_mbps; in iavf_validate_tx_bandwidth()
3448 dev_err(&adapter->pdev->dev, "Unknown link speed\n"); in iavf_validate_tx_bandwidth()
3453 switch (adapter->link_speed) { in iavf_validate_tx_bandwidth()
3484 dev_err(&adapter->pdev->dev, in iavf_validate_tx_bandwidth()
3494 * @adapter: board private structure
3501 static int iavf_validate_ch_config(struct iavf_adapter *adapter, in iavf_validate_ch_config() argument
3519 dev_err(&adapter->pdev->dev, in iavf_validate_ch_config()
3531 dev_err(&adapter->pdev->dev, in iavf_validate_ch_config()
3540 dev_err(&adapter->pdev->dev, in iavf_validate_ch_config()
3549 if (num_qps > adapter->num_active_queues) { in iavf_validate_ch_config()
3550 dev_err(&adapter->pdev->dev, in iavf_validate_ch_config()
3555 ret = iavf_validate_tx_bandwidth(adapter, total_max_rate); in iavf_validate_ch_config()
3561 * @adapter: board private structure
3563 static void iavf_del_all_cloud_filters(struct iavf_adapter *adapter) in iavf_del_all_cloud_filters() argument
3567 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_del_all_cloud_filters()
3568 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, in iavf_del_all_cloud_filters()
3572 adapter->num_cloud_filters--; in iavf_del_all_cloud_filters()
3574 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_del_all_cloud_filters()
3579 * TC config already configured on this adapter.
3580 * @adapter: board private structure
3584 * with the config already configured on the adapter.
3588 static bool iavf_is_tc_config_same(struct iavf_adapter *adapter, in iavf_is_tc_config_same() argument
3591 struct virtchnl_channel_info *ch = &adapter->ch_config.ch_info[0]; in iavf_is_tc_config_same()
3594 if (adapter->num_tc != mqprio_qopt->num_tc) in iavf_is_tc_config_same()
3597 for (i = 0; i < adapter->num_tc; i++) { in iavf_is_tc_config_same()
3619 struct iavf_adapter *adapter = netdev_priv(netdev); in __iavf_setup_tc() local
3620 struct virtchnl_vf_resource *vfres = adapter->vf_res; in __iavf_setup_tc()
3632 if (adapter->ch_config.state == __IAVF_TC_RUNNING) { in __iavf_setup_tc()
3635 adapter->num_tc = 0; in __iavf_setup_tc()
3638 iavf_del_all_cloud_filters(adapter); in __iavf_setup_tc()
3639 adapter->aq_required = IAVF_FLAG_AQ_DISABLE_CHANNELS; in __iavf_setup_tc()
3640 total_qps = adapter->orig_num_active_queues; in __iavf_setup_tc()
3650 dev_err(&adapter->pdev->dev, "ADq not supported\n"); in __iavf_setup_tc()
3653 if (adapter->ch_config.state != __IAVF_TC_INVALID) { in __iavf_setup_tc()
3654 dev_err(&adapter->pdev->dev, "TC configuration already exists\n"); in __iavf_setup_tc()
3658 ret = iavf_validate_ch_config(adapter, mqprio_qopt); in __iavf_setup_tc()
3662 if (iavf_is_tc_config_same(adapter, &mqprio_qopt->qopt)) in __iavf_setup_tc()
3664 adapter->num_tc = num_tc; in __iavf_setup_tc()
3668 adapter->ch_config.ch_info[i].count = in __iavf_setup_tc()
3670 adapter->ch_config.ch_info[i].offset = in __iavf_setup_tc()
3677 adapter->ch_config.ch_info[i].max_tx_rate = in __iavf_setup_tc()
3680 adapter->ch_config.ch_info[i].count = 1; in __iavf_setup_tc()
3681 adapter->ch_config.ch_info[i].offset = 0; in __iavf_setup_tc()
3691 adapter->orig_num_active_queues = adapter->num_active_queues; in __iavf_setup_tc()
3697 adapter->ch_config.total_qps = total_qps; in __iavf_setup_tc()
3701 adapter->aq_required |= IAVF_FLAG_AQ_ENABLE_CHANNELS; in __iavf_setup_tc()
3704 netdev_set_num_tc(adapter->netdev, num_tc); in __iavf_setup_tc()
3715 if (test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) in __iavf_setup_tc()
3726 * @adapter: board private structure
3730 static int iavf_parse_cls_flower(struct iavf_adapter *adapter, in iavf_parse_cls_flower() argument
3753 dev_err(&adapter->pdev->dev, "Unsupported key used: 0x%llx\n", in iavf_parse_cls_flower()
3786 dev_info(&adapter->pdev->dev, "Only TCP transport is supported\n"); in iavf_parse_cls_flower()
3801 dev_err(&adapter->pdev->dev, "Bad ether dest mask %pM\n", in iavf_parse_cls_flower()
3811 dev_err(&adapter->pdev->dev, "Bad ether src mask %pM\n", in iavf_parse_cls_flower()
3846 dev_err(&adapter->pdev->dev, "Bad vlan mask %u\n", in iavf_parse_cls_flower()
3870 dev_err(&adapter->pdev->dev, "Bad ip dst mask 0x%08x\n", in iavf_parse_cls_flower()
3880 dev_err(&adapter->pdev->dev, "Bad ip src mask 0x%08x\n", in iavf_parse_cls_flower()
3887 dev_info(&adapter->pdev->dev, "Tenant id not allowed for ip filter\n"); in iavf_parse_cls_flower()
3907 dev_err(&adapter->pdev->dev, "Bad ipv6 dst mask 0x%02x\n", in iavf_parse_cls_flower()
3917 dev_err(&adapter->pdev->dev, in iavf_parse_cls_flower()
3942 dev_err(&adapter->pdev->dev, "Bad src port mask %u\n", in iavf_parse_cls_flower()
3952 dev_err(&adapter->pdev->dev, "Bad dst port mask %u\n", in iavf_parse_cls_flower()
3974 * @adapter: board private structure
3978 static int iavf_handle_tclass(struct iavf_adapter *adapter, u32 tc, in iavf_handle_tclass() argument
3983 if (tc < adapter->num_tc) { in iavf_handle_tclass()
3985 dev_err(&adapter->pdev->dev, in iavf_handle_tclass()
3998 * @adapter: Board private structure
4004 static struct iavf_cloud_filter *iavf_find_cf(struct iavf_adapter *adapter, in iavf_find_cf() argument
4012 list_for_each_entry(filter, &adapter->cloud_filter_list, list) { in iavf_find_cf()
4021 * @adapter: board private structure
4024 static int iavf_configure_clsflower(struct iavf_adapter *adapter, in iavf_configure_clsflower() argument
4027 int tc = tc_classid_to_hwtc(adapter->netdev, cls_flower->classid); in iavf_configure_clsflower()
4032 dev_err(&adapter->pdev->dev, "Invalid traffic class\n"); in iavf_configure_clsflower()
4040 while (!mutex_trylock(&adapter->crit_lock)) { in iavf_configure_clsflower()
4051 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_configure_clsflower()
4052 if (iavf_find_cf(adapter, &cls_flower->cookie)) { in iavf_configure_clsflower()
4053 dev_err(&adapter->pdev->dev, "Failed to add TC Flower filter, it already exists\n"); in iavf_configure_clsflower()
4057 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_configure_clsflower()
4063 err = iavf_parse_cls_flower(adapter, cls_flower, filter); in iavf_configure_clsflower()
4067 err = iavf_handle_tclass(adapter, tc, filter); in iavf_configure_clsflower()
4072 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_configure_clsflower()
4073 list_add_tail(&filter->list, &adapter->cloud_filter_list); in iavf_configure_clsflower()
4074 adapter->num_cloud_filters++; in iavf_configure_clsflower()
4076 adapter->aq_required |= IAVF_FLAG_AQ_ADD_CLOUD_FILTER; in iavf_configure_clsflower()
4078 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_configure_clsflower()
4083 mutex_unlock(&adapter->crit_lock); in iavf_configure_clsflower()
4089 * @adapter: board private structure
4092 static int iavf_delete_clsflower(struct iavf_adapter *adapter, in iavf_delete_clsflower() argument
4098 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_delete_clsflower()
4099 filter = iavf_find_cf(adapter, &cls_flower->cookie); in iavf_delete_clsflower()
4102 adapter->aq_required |= IAVF_FLAG_AQ_DEL_CLOUD_FILTER; in iavf_delete_clsflower()
4106 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_delete_clsflower()
4113 * @adapter: board private structure
4116 static int iavf_setup_tc_cls_flower(struct iavf_adapter *adapter, in iavf_setup_tc_cls_flower() argument
4121 return iavf_configure_clsflower(adapter, cls_flower); in iavf_setup_tc_cls_flower()
4123 return iavf_delete_clsflower(adapter, cls_flower); in iavf_setup_tc_cls_flower()
4142 struct iavf_adapter *adapter = cb_priv; in iavf_setup_tc_block_cb() local
4144 if (!tc_cls_can_offload_and_chain0(adapter->netdev, type_data)) in iavf_setup_tc_block_cb()
4171 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_setup_tc() local
4180 adapter, adapter, true); in iavf_setup_tc()
4188 * @adapter: board private structure
4192 static void iavf_restore_fdir_filters(struct iavf_adapter *adapter) in iavf_restore_fdir_filters() argument
4196 spin_lock_bh(&adapter->fdir_fltr_lock); in iavf_restore_fdir_filters()
4197 list_for_each_entry(f, &adapter->fdir_list_head, list) { in iavf_restore_fdir_filters()
4207 adapter->aq_required |= IAVF_FLAG_AQ_ADD_FDIR_FILTER; in iavf_restore_fdir_filters()
4210 spin_unlock_bh(&adapter->fdir_fltr_lock); in iavf_restore_fdir_filters()
4227 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_open() local
4230 if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) { in iavf_open()
4231 dev_err(&adapter->pdev->dev, "Unable to open device due to PF driver failure.\n"); in iavf_open()
4235 while (!mutex_trylock(&adapter->crit_lock)) { in iavf_open()
4241 if (adapter->state == __IAVF_INIT_CONFIG_ADAPTER) in iavf_open()
4247 if (adapter->state != __IAVF_DOWN) { in iavf_open()
4252 if (adapter->state == __IAVF_RUNNING && in iavf_open()
4253 !test_bit(__IAVF_VSI_DOWN, adapter->vsi.state)) { in iavf_open()
4254 dev_dbg(&adapter->pdev->dev, "VF is already open.\n"); in iavf_open()
4260 err = iavf_setup_all_tx_resources(adapter); in iavf_open()
4265 err = iavf_setup_all_rx_resources(adapter); in iavf_open()
4270 err = iavf_request_traffic_irqs(adapter, netdev->name); in iavf_open()
4274 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_open()
4276 iavf_add_filter(adapter, adapter->hw.mac.addr); in iavf_open()
4278 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_open()
4281 iavf_restore_filters(adapter); in iavf_open()
4282 iavf_restore_fdir_filters(adapter); in iavf_open()
4284 iavf_configure(adapter); in iavf_open()
4286 iavf_up_complete(adapter); in iavf_open()
4288 iavf_irq_enable(adapter, true); in iavf_open()
4290 mutex_unlock(&adapter->crit_lock); in iavf_open()
4295 iavf_down(adapter); in iavf_open()
4296 iavf_free_traffic_irqs(adapter); in iavf_open()
4298 iavf_free_all_rx_resources(adapter); in iavf_open()
4300 iavf_free_all_tx_resources(adapter); in iavf_open()
4302 mutex_unlock(&adapter->crit_lock); in iavf_open()
4320 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_close() local
4324 mutex_lock(&adapter->crit_lock); in iavf_close()
4326 if (adapter->state <= __IAVF_DOWN_PENDING) { in iavf_close()
4327 mutex_unlock(&adapter->crit_lock); in iavf_close()
4331 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_close()
4332 if (CLIENT_ENABLED(adapter)) in iavf_close()
4333 adapter->flags |= IAVF_FLAG_CLIENT_NEEDS_CLOSE; in iavf_close()
4343 aq_to_restore = adapter->aq_required; in iavf_close()
4344 adapter->aq_required &= IAVF_FLAG_AQ_GET_CONFIG; in iavf_close()
4358 iavf_down(adapter); in iavf_close()
4359 iavf_change_state(adapter, __IAVF_DOWN_PENDING); in iavf_close()
4360 iavf_free_traffic_irqs(adapter); in iavf_close()
4362 mutex_unlock(&adapter->crit_lock); in iavf_close()
4375 status = wait_event_timeout(adapter->down_waitqueue, in iavf_close()
4376 adapter->state == __IAVF_DOWN, in iavf_close()
4381 mutex_lock(&adapter->crit_lock); in iavf_close()
4382 adapter->aq_required |= aq_to_restore; in iavf_close()
4383 mutex_unlock(&adapter->crit_lock); in iavf_close()
4396 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_change_mtu() local
4402 if (CLIENT_ENABLED(adapter)) { in iavf_change_mtu()
4403 iavf_notify_client_l2_params(&adapter->vsi); in iavf_change_mtu()
4404 adapter->flags |= IAVF_FLAG_SERVICE_CLIENT_REQUESTED; in iavf_change_mtu()
4408 iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); in iavf_change_mtu()
4409 ret = iavf_wait_for_reset(adapter); in iavf_change_mtu()
4421 * @adapter: board private structure
4423 static void iavf_disable_fdir(struct iavf_adapter *adapter) in iavf_disable_fdir() argument
4428 adapter->flags &= ~IAVF_FLAG_FDIR_ENABLED; in iavf_disable_fdir()
4431 spin_lock_bh(&adapter->fdir_fltr_lock); in iavf_disable_fdir()
4432 list_for_each_entry_safe(fdir, fdirtmp, &adapter->fdir_list_head, in iavf_disable_fdir()
4439 adapter->fdir_active_fltr--; in iavf_disable_fdir()
4454 spin_unlock_bh(&adapter->fdir_fltr_lock); in iavf_disable_fdir()
4457 adapter->aq_required |= IAVF_FLAG_AQ_DEL_FDIR_FILTER; in iavf_disable_fdir()
4458 mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); in iavf_disable_fdir()
4476 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_set_features() local
4481 iavf_set_vlan_offload_features(adapter, netdev->features, in iavf_set_features()
4486 adapter->flags |= IAVF_FLAG_FDIR_ENABLED; in iavf_set_features()
4488 iavf_disable_fdir(adapter); in iavf_set_features()
4554 * @adapter: board private structure
4560 iavf_get_netdev_vlan_hw_features(struct iavf_adapter *adapter) in iavf_get_netdev_vlan_hw_features() argument
4564 if (!adapter->vf_res || !adapter->vf_res->vf_cap_flags) in iavf_get_netdev_vlan_hw_features()
4568 if (VLAN_ALLOWED(adapter)) { in iavf_get_netdev_vlan_hw_features()
4571 } else if (VLAN_V2_ALLOWED(adapter)) { in iavf_get_netdev_vlan_hw_features()
4573 &adapter->vlan_v2_caps; in iavf_get_netdev_vlan_hw_features()
4616 * @adapter: board private structure
4622 iavf_get_netdev_vlan_features(struct iavf_adapter *adapter) in iavf_get_netdev_vlan_features() argument
4626 if (!adapter->vf_res || !adapter->vf_res->vf_cap_flags) in iavf_get_netdev_vlan_features()
4629 if (VLAN_ALLOWED(adapter)) { in iavf_get_netdev_vlan_features()
4632 } else if (VLAN_V2_ALLOWED(adapter)) { in iavf_get_netdev_vlan_features()
4634 &adapter->vlan_v2_caps; in iavf_get_netdev_vlan_features()
4719 * @adapter: board private structure
4723 iavf_fix_netdev_vlan_features(struct iavf_adapter *adapter, in iavf_fix_netdev_vlan_features() argument
4728 allowed_features = iavf_get_netdev_vlan_hw_features(adapter) | in iavf_fix_netdev_vlan_features()
4729 iavf_get_netdev_vlan_features(adapter); in iavf_fix_netdev_vlan_features()
4764 adapter->vlan_v2_caps.offloads.ethertype_match == in iavf_fix_netdev_vlan_features()
4766 …netdev_warn(adapter->netdev, "cannot support CTAG and STAG VLAN stripping and/or insertion simulta… in iavf_fix_netdev_vlan_features()
4784 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_fix_features() local
4786 if (!FDIR_FLTR_SUPPORT(adapter)) in iavf_fix_features()
4789 return iavf_fix_netdev_vlan_features(adapter, features); in iavf_fix_features()
4833 * @adapter: board private structure
4838 int iavf_process_config(struct iavf_adapter *adapter) in iavf_process_config() argument
4840 struct virtchnl_vf_resource *vfres = adapter->vf_res; in iavf_process_config()
4842 struct net_device *netdev = adapter->netdev; in iavf_process_config()
4890 hw_vlan_features = iavf_get_netdev_vlan_hw_features(adapter); in iavf_process_config()
4899 vlan_features = iavf_get_netdev_vlan_features(adapter); in iavf_process_config()
4906 if (FDIR_FLTR_SUPPORT(adapter)) { in iavf_process_config()
4909 adapter->flags |= IAVF_FLAG_FDIR_ENABLED; in iavf_process_config()
4942 * iavf_probe initializes an adapter identified by a pci_dev structure.
4943 * The OS initialization, configuring of the adapter private structure,
4949 struct iavf_adapter *adapter = NULL; in iavf_probe() local
4983 adapter = netdev_priv(netdev); in iavf_probe()
4985 adapter->netdev = netdev; in iavf_probe()
4986 adapter->pdev = pdev; in iavf_probe()
4988 hw = &adapter->hw; in iavf_probe()
4989 hw->back = adapter; in iavf_probe()
4991 adapter->wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, in iavf_probe()
4993 if (!adapter->wq) { in iavf_probe()
4998 adapter->msg_enable = BIT(DEFAULT_DEBUG_LEVEL_SHIFT) - 1; in iavf_probe()
4999 iavf_change_state(adapter, __IAVF_STARTUP); in iavf_probe()
5001 /* Call save state here because it relies on the adapter struct. */ in iavf_probe()
5022 mutex_init(&adapter->crit_lock); in iavf_probe()
5023 mutex_init(&adapter->client_lock); in iavf_probe()
5027 spin_lock_init(&adapter->mac_vlan_list_lock); in iavf_probe()
5028 spin_lock_init(&adapter->cloud_filter_list_lock); in iavf_probe()
5029 spin_lock_init(&adapter->fdir_fltr_lock); in iavf_probe()
5030 spin_lock_init(&adapter->adv_rss_lock); in iavf_probe()
5031 spin_lock_init(&adapter->current_netdev_promisc_flags_lock); in iavf_probe()
5033 INIT_LIST_HEAD(&adapter->mac_filter_list); in iavf_probe()
5034 INIT_LIST_HEAD(&adapter->vlan_filter_list); in iavf_probe()
5035 INIT_LIST_HEAD(&adapter->cloud_filter_list); in iavf_probe()
5036 INIT_LIST_HEAD(&adapter->fdir_list_head); in iavf_probe()
5037 INIT_LIST_HEAD(&adapter->adv_rss_list_head); in iavf_probe()
5039 INIT_WORK(&adapter->reset_task, iavf_reset_task); in iavf_probe()
5040 INIT_WORK(&adapter->adminq_task, iavf_adminq_task); in iavf_probe()
5041 INIT_WORK(&adapter->finish_config, iavf_finish_config); in iavf_probe()
5042 INIT_DELAYED_WORK(&adapter->watchdog_task, iavf_watchdog_task); in iavf_probe()
5043 INIT_DELAYED_WORK(&adapter->client_task, iavf_client_task); in iavf_probe()
5046 init_waitqueue_head(&adapter->down_waitqueue); in iavf_probe()
5049 init_waitqueue_head(&adapter->reset_waitqueue); in iavf_probe()
5052 init_waitqueue_head(&adapter->vc_waitqueue); in iavf_probe()
5054 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_probe()
5060 destroy_workqueue(adapter->wq); in iavf_probe()
5080 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_suspend() local
5084 while (!mutex_trylock(&adapter->crit_lock)) in iavf_suspend()
5089 iavf_down(adapter); in iavf_suspend()
5092 iavf_free_misc_irq(adapter); in iavf_suspend()
5093 iavf_reset_interrupt_capability(adapter); in iavf_suspend()
5095 mutex_unlock(&adapter->crit_lock); in iavf_suspend()
5109 struct iavf_adapter *adapter; in iavf_resume() local
5112 adapter = iavf_pdev_to_adapter(pdev); in iavf_resume()
5117 err = iavf_set_interrupt_capability(adapter); in iavf_resume()
5123 err = iavf_request_misc_irq(adapter); in iavf_resume()
5130 queue_work(adapter->wq, &adapter->reset_task); in iavf_resume()
5132 netif_device_attach(adapter->netdev); in iavf_resume()
5153 struct iavf_adapter *adapter; in iavf_remove() local
5163 adapter = iavf_pdev_to_adapter(pdev); in iavf_remove()
5164 hw = &adapter->hw; in iavf_remove()
5166 if (test_and_set_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) in iavf_remove()
5173 mutex_lock(&adapter->crit_lock); in iavf_remove()
5174 if (adapter->state == __IAVF_RUNNING || in iavf_remove()
5175 adapter->state == __IAVF_DOWN || in iavf_remove()
5176 adapter->state == __IAVF_INIT_FAILED) { in iavf_remove()
5177 mutex_unlock(&adapter->crit_lock); in iavf_remove()
5181 if (adapter->state == __IAVF_REMOVE) { in iavf_remove()
5182 mutex_unlock(&adapter->crit_lock); in iavf_remove()
5186 mutex_unlock(&adapter->crit_lock); in iavf_remove()
5189 cancel_delayed_work_sync(&adapter->watchdog_task); in iavf_remove()
5190 cancel_work_sync(&adapter->finish_config); in iavf_remove()
5193 if (adapter->netdev_registered) { in iavf_remove()
5195 adapter->netdev_registered = false; in iavf_remove()
5199 if (CLIENT_ALLOWED(adapter)) { in iavf_remove()
5200 err = iavf_lan_del_device(adapter); in iavf_remove()
5206 mutex_lock(&adapter->crit_lock); in iavf_remove()
5207 dev_info(&adapter->pdev->dev, "Removing device\n"); in iavf_remove()
5208 iavf_change_state(adapter, __IAVF_REMOVE); in iavf_remove()
5210 iavf_request_reset(adapter); in iavf_remove()
5214 iavf_request_reset(adapter); in iavf_remove()
5218 iavf_misc_irq_disable(adapter); in iavf_remove()
5220 cancel_work_sync(&adapter->reset_task); in iavf_remove()
5221 cancel_delayed_work_sync(&adapter->watchdog_task); in iavf_remove()
5222 cancel_work_sync(&adapter->adminq_task); in iavf_remove()
5223 cancel_delayed_work_sync(&adapter->client_task); in iavf_remove()
5225 adapter->aq_required = 0; in iavf_remove()
5226 adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED; in iavf_remove()
5228 iavf_free_all_tx_resources(adapter); in iavf_remove()
5229 iavf_free_all_rx_resources(adapter); in iavf_remove()
5230 iavf_free_misc_irq(adapter); in iavf_remove()
5232 iavf_reset_interrupt_capability(adapter); in iavf_remove()
5233 iavf_free_q_vectors(adapter); in iavf_remove()
5235 iavf_free_rss(adapter); in iavf_remove()
5243 mutex_destroy(&adapter->client_lock); in iavf_remove()
5244 mutex_unlock(&adapter->crit_lock); in iavf_remove()
5245 mutex_destroy(&adapter->crit_lock); in iavf_remove()
5249 iavf_free_queues(adapter); in iavf_remove()
5250 kfree(adapter->vf_res); in iavf_remove()
5251 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_remove()
5255 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { in iavf_remove()
5259 list_for_each_entry_safe(vlf, vlftmp, &adapter->vlan_filter_list, in iavf_remove()
5265 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_remove()
5267 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_remove()
5268 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, list) { in iavf_remove()
5272 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_remove()
5274 spin_lock_bh(&adapter->fdir_fltr_lock); in iavf_remove()
5275 list_for_each_entry_safe(fdir, fdirtmp, &adapter->fdir_list_head, list) { in iavf_remove()
5279 spin_unlock_bh(&adapter->fdir_fltr_lock); in iavf_remove()
5281 spin_lock_bh(&adapter->adv_rss_lock); in iavf_remove()
5282 list_for_each_entry_safe(rss, rsstmp, &adapter->adv_rss_list_head, in iavf_remove()
5287 spin_unlock_bh(&adapter->adv_rss_lock); in iavf_remove()
5289 destroy_workqueue(adapter->wq); in iavf_remove()