Lines Matching refs:adapter

15 static int iavf_setup_all_tx_resources(struct iavf_adapter *adapter);
16 static int iavf_setup_all_rx_resources(struct iavf_adapter *adapter);
18 static void iavf_init_get_resources(struct iavf_adapter *adapter);
175 static bool iavf_is_reset_in_progress(struct iavf_adapter *adapter) in iavf_is_reset_in_progress() argument
177 if (adapter->state == __IAVF_RESETTING || in iavf_is_reset_in_progress()
178 adapter->flags & (IAVF_FLAG_RESET_PENDING | in iavf_is_reset_in_progress()
191 int iavf_wait_for_reset(struct iavf_adapter *adapter) in iavf_wait_for_reset() argument
193 int ret = wait_event_interruptible_timeout(adapter->reset_waitqueue, in iavf_wait_for_reset()
194 !iavf_is_reset_in_progress(adapter), in iavf_wait_for_reset()
221 struct iavf_adapter *adapter = (struct iavf_adapter *)hw->back; in iavf_allocate_dma_mem_d() local
227 mem->va = dma_alloc_coherent(&adapter->pdev->dev, mem->size, in iavf_allocate_dma_mem_d()
242 struct iavf_adapter *adapter = (struct iavf_adapter *)hw->back; in iavf_free_dma_mem() local
246 dma_free_coherent(&adapter->pdev->dev, mem->size, in iavf_free_dma_mem()
287 void iavf_schedule_reset(struct iavf_adapter *adapter, u64 flags) in iavf_schedule_reset() argument
289 if (!test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section) && in iavf_schedule_reset()
290 !(adapter->flags & in iavf_schedule_reset()
292 adapter->flags |= flags; in iavf_schedule_reset()
293 queue_work(adapter->wq, &adapter->reset_task); in iavf_schedule_reset()
302 void iavf_schedule_aq_request(struct iavf_adapter *adapter, u64 flags) in iavf_schedule_aq_request() argument
304 adapter->aq_required |= flags; in iavf_schedule_aq_request()
305 mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); in iavf_schedule_aq_request()
315 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_tx_timeout() local
317 adapter->tx_timeout_count++; in iavf_tx_timeout()
318 iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); in iavf_tx_timeout()
325 static void iavf_misc_irq_disable(struct iavf_adapter *adapter) in iavf_misc_irq_disable() argument
327 struct iavf_hw *hw = &adapter->hw; in iavf_misc_irq_disable()
329 if (!adapter->msix_entries) in iavf_misc_irq_disable()
336 synchronize_irq(adapter->msix_entries[0].vector); in iavf_misc_irq_disable()
343 static void iavf_misc_irq_enable(struct iavf_adapter *adapter) in iavf_misc_irq_enable() argument
345 struct iavf_hw *hw = &adapter->hw; in iavf_misc_irq_enable()
358 static void iavf_irq_disable(struct iavf_adapter *adapter) in iavf_irq_disable() argument
361 struct iavf_hw *hw = &adapter->hw; in iavf_irq_disable()
363 if (!adapter->msix_entries) in iavf_irq_disable()
366 for (i = 1; i < adapter->num_msix_vectors; i++) { in iavf_irq_disable()
368 synchronize_irq(adapter->msix_entries[i].vector); in iavf_irq_disable()
377 static void iavf_irq_enable_queues(struct iavf_adapter *adapter) in iavf_irq_enable_queues() argument
379 struct iavf_hw *hw = &adapter->hw; in iavf_irq_enable_queues()
382 for (i = 1; i < adapter->num_msix_vectors; i++) { in iavf_irq_enable_queues()
394 void iavf_irq_enable(struct iavf_adapter *adapter, bool flush) in iavf_irq_enable() argument
396 struct iavf_hw *hw = &adapter->hw; in iavf_irq_enable()
398 iavf_misc_irq_enable(adapter); in iavf_irq_enable()
399 iavf_irq_enable_queues(adapter); in iavf_irq_enable()
413 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_msix_aq() local
414 struct iavf_hw *hw = &adapter->hw; in iavf_msix_aq()
420 if (adapter->state != __IAVF_REMOVE) in iavf_msix_aq()
422 queue_work(adapter->wq, &adapter->adminq_task); in iavf_msix_aq()
451 iavf_map_vector_to_rxq(struct iavf_adapter *adapter, int v_idx, int r_idx) in iavf_map_vector_to_rxq() argument
453 struct iavf_q_vector *q_vector = &adapter->q_vectors[v_idx]; in iavf_map_vector_to_rxq()
454 struct iavf_ring *rx_ring = &adapter->rx_rings[r_idx]; in iavf_map_vector_to_rxq()
455 struct iavf_hw *hw = &adapter->hw; in iavf_map_vector_to_rxq()
459 rx_ring->vsi = &adapter->vsi; in iavf_map_vector_to_rxq()
477 iavf_map_vector_to_txq(struct iavf_adapter *adapter, int v_idx, int t_idx) in iavf_map_vector_to_txq() argument
479 struct iavf_q_vector *q_vector = &adapter->q_vectors[v_idx]; in iavf_map_vector_to_txq()
480 struct iavf_ring *tx_ring = &adapter->tx_rings[t_idx]; in iavf_map_vector_to_txq()
481 struct iavf_hw *hw = &adapter->hw; in iavf_map_vector_to_txq()
485 tx_ring->vsi = &adapter->vsi; in iavf_map_vector_to_txq()
506 static void iavf_map_rings_to_vectors(struct iavf_adapter *adapter) in iavf_map_rings_to_vectors() argument
508 int rings_remaining = adapter->num_active_queues; in iavf_map_rings_to_vectors()
512 q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_map_rings_to_vectors()
515 iavf_map_vector_to_rxq(adapter, vidx, ridx); in iavf_map_rings_to_vectors()
516 iavf_map_vector_to_txq(adapter, vidx, ridx); in iavf_map_rings_to_vectors()
525 adapter->aq_required |= IAVF_FLAG_AQ_MAP_VECTORS; in iavf_map_rings_to_vectors()
564 iavf_request_traffic_irqs(struct iavf_adapter *adapter, char *basename) in iavf_request_traffic_irqs() argument
571 iavf_irq_disable(adapter); in iavf_request_traffic_irqs()
573 q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_request_traffic_irqs()
576 struct iavf_q_vector *q_vector = &adapter->q_vectors[vector]; in iavf_request_traffic_irqs()
578 irq_num = adapter->msix_entries[vector + NONQ_VECS].vector; in iavf_request_traffic_irqs()
600 dev_info(&adapter->pdev->dev, in iavf_request_traffic_irqs()
622 irq_num = adapter->msix_entries[vector + NONQ_VECS].vector; in iavf_request_traffic_irqs()
625 free_irq(irq_num, &adapter->q_vectors[vector]); in iavf_request_traffic_irqs()
638 static int iavf_request_misc_irq(struct iavf_adapter *adapter) in iavf_request_misc_irq() argument
640 struct net_device *netdev = adapter->netdev; in iavf_request_misc_irq()
643 snprintf(adapter->misc_vector_name, in iavf_request_misc_irq()
644 sizeof(adapter->misc_vector_name) - 1, "iavf-%s:mbx", in iavf_request_misc_irq()
645 dev_name(&adapter->pdev->dev)); in iavf_request_misc_irq()
646 err = request_irq(adapter->msix_entries[0].vector, in iavf_request_misc_irq()
648 adapter->misc_vector_name, netdev); in iavf_request_misc_irq()
650 dev_err(&adapter->pdev->dev, in iavf_request_misc_irq()
652 adapter->misc_vector_name, err); in iavf_request_misc_irq()
653 free_irq(adapter->msix_entries[0].vector, netdev); in iavf_request_misc_irq()
664 static void iavf_free_traffic_irqs(struct iavf_adapter *adapter) in iavf_free_traffic_irqs() argument
668 if (!adapter->msix_entries) in iavf_free_traffic_irqs()
671 q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_free_traffic_irqs()
674 irq_num = adapter->msix_entries[vector + NONQ_VECS].vector; in iavf_free_traffic_irqs()
677 free_irq(irq_num, &adapter->q_vectors[vector]); in iavf_free_traffic_irqs()
687 static void iavf_free_misc_irq(struct iavf_adapter *adapter) in iavf_free_misc_irq() argument
689 struct net_device *netdev = adapter->netdev; in iavf_free_misc_irq()
691 if (!adapter->msix_entries) in iavf_free_misc_irq()
694 free_irq(adapter->msix_entries[0].vector, netdev); in iavf_free_misc_irq()
703 static void iavf_configure_tx(struct iavf_adapter *adapter) in iavf_configure_tx() argument
705 struct iavf_hw *hw = &adapter->hw; in iavf_configure_tx()
708 for (i = 0; i < adapter->num_active_queues; i++) in iavf_configure_tx()
709 adapter->tx_rings[i].tail = hw->hw_addr + IAVF_QTX_TAIL1(i); in iavf_configure_tx()
718 static void iavf_configure_rx(struct iavf_adapter *adapter) in iavf_configure_rx() argument
720 struct iavf_hw *hw = &adapter->hw; in iavf_configure_rx()
722 for (u32 i = 0; i < adapter->num_active_queues; i++) in iavf_configure_rx()
723 adapter->rx_rings[i].tail = hw->hw_addr + IAVF_QRX_TAIL1(i); in iavf_configure_rx()
735 iavf_vlan_filter *iavf_find_vlan(struct iavf_adapter *adapter, in iavf_find_vlan() argument
740 list_for_each_entry(f, &adapter->vlan_filter_list, list) { in iavf_find_vlan()
757 iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter, in iavf_add_vlan() argument
762 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_add_vlan()
764 f = iavf_find_vlan(adapter, vlan); in iavf_add_vlan()
772 list_add_tail(&f->list, &adapter->vlan_filter_list); in iavf_add_vlan()
774 adapter->num_vlan_filters++; in iavf_add_vlan()
775 iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ADD_VLAN_FILTER); in iavf_add_vlan()
779 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_add_vlan()
788 static void iavf_del_vlan(struct iavf_adapter *adapter, struct iavf_vlan vlan) in iavf_del_vlan() argument
792 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_del_vlan()
794 f = iavf_find_vlan(adapter, vlan); in iavf_del_vlan()
797 iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_DEL_VLAN_FILTER); in iavf_del_vlan()
800 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_del_vlan()
809 static void iavf_restore_filters(struct iavf_adapter *adapter) in iavf_restore_filters() argument
814 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_restore_filters()
816 list_for_each_entry(f, &adapter->vlan_filter_list, list) { in iavf_restore_filters()
821 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_restore_filters()
822 adapter->aq_required |= IAVF_FLAG_AQ_ADD_VLAN_FILTER; in iavf_restore_filters()
829 u16 iavf_get_num_vlans_added(struct iavf_adapter *adapter) in iavf_get_num_vlans_added() argument
831 return adapter->num_vlan_filters; in iavf_get_num_vlans_added()
842 static u16 iavf_get_max_vlans_allowed(struct iavf_adapter *adapter) in iavf_get_max_vlans_allowed() argument
847 if (VLAN_ALLOWED(adapter)) in iavf_get_max_vlans_allowed()
849 else if (VLAN_V2_ALLOWED(adapter)) in iavf_get_max_vlans_allowed()
850 return adapter->vlan_v2_caps.filtering.max_filters; in iavf_get_max_vlans_allowed()
859 static bool iavf_max_vlans_added(struct iavf_adapter *adapter) in iavf_max_vlans_added() argument
861 if (iavf_get_num_vlans_added(adapter) < in iavf_max_vlans_added()
862 iavf_get_max_vlans_allowed(adapter)) in iavf_max_vlans_added()
877 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_vlan_rx_add_vid() local
883 if (!VLAN_FILTERING_ALLOWED(adapter)) in iavf_vlan_rx_add_vid()
886 if (iavf_max_vlans_added(adapter)) { in iavf_vlan_rx_add_vid()
888 iavf_get_max_vlans_allowed(adapter)); in iavf_vlan_rx_add_vid()
892 if (!iavf_add_vlan(adapter, IAVF_VLAN(vid, be16_to_cpu(proto)))) in iavf_vlan_rx_add_vid()
907 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_vlan_rx_kill_vid() local
913 iavf_del_vlan(adapter, IAVF_VLAN(vid, be16_to_cpu(proto))); in iavf_vlan_rx_kill_vid()
926 iavf_mac_filter *iavf_find_filter(struct iavf_adapter *adapter, in iavf_find_filter() argument
934 list_for_each_entry(f, &adapter->mac_filter_list, list) { in iavf_find_filter()
948 struct iavf_mac_filter *iavf_add_filter(struct iavf_adapter *adapter, in iavf_add_filter() argument
956 f = iavf_find_filter(adapter, macaddr); in iavf_add_filter()
964 list_add_tail(&f->list, &adapter->mac_filter_list); in iavf_add_filter()
968 f->is_primary = ether_addr_equal(macaddr, adapter->hw.mac.addr); in iavf_add_filter()
969 adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER; in iavf_add_filter()
988 static int iavf_replace_primary_mac(struct iavf_adapter *adapter, in iavf_replace_primary_mac() argument
991 struct iavf_hw *hw = &adapter->hw; in iavf_replace_primary_mac()
995 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_replace_primary_mac()
997 new_f = iavf_add_filter(adapter, new_mac); in iavf_replace_primary_mac()
999 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_replace_primary_mac()
1003 old_f = iavf_find_filter(adapter, hw->mac.addr); in iavf_replace_primary_mac()
1007 adapter->aq_required |= IAVF_FLAG_AQ_DEL_MAC_FILTER; in iavf_replace_primary_mac()
1016 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_replace_primary_mac()
1019 iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ADD_MAC_FILTER); in iavf_replace_primary_mac()
1033 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_is_mac_set_handled() local
1037 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_is_mac_set_handled()
1039 f = iavf_find_filter(adapter, macaddr); in iavf_is_mac_set_handled()
1044 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_is_mac_set_handled()
1058 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_set_mac() local
1065 ret = iavf_replace_primary_mac(adapter, addr->sa_data); in iavf_set_mac()
1070 ret = wait_event_interruptible_timeout(adapter->vc_waitqueue, in iavf_set_mac()
1102 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_addr_sync() local
1104 if (iavf_add_filter(adapter, addr)) in iavf_addr_sync()
1120 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_addr_unsync() local
1131 f = iavf_find_filter(adapter, addr); in iavf_addr_unsync()
1134 adapter->aq_required |= IAVF_FLAG_AQ_DEL_MAC_FILTER; in iavf_addr_unsync()
1143 bool iavf_promiscuous_mode_changed(struct iavf_adapter *adapter) in iavf_promiscuous_mode_changed() argument
1145 return (adapter->current_netdev_promisc_flags ^ adapter->netdev->flags) & in iavf_promiscuous_mode_changed()
1155 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_set_rx_mode() local
1157 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_set_rx_mode()
1160 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_set_rx_mode()
1162 spin_lock_bh(&adapter->current_netdev_promisc_flags_lock); in iavf_set_rx_mode()
1163 if (iavf_promiscuous_mode_changed(adapter)) in iavf_set_rx_mode()
1164 adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_PROMISC_MODE; in iavf_set_rx_mode()
1165 spin_unlock_bh(&adapter->current_netdev_promisc_flags_lock); in iavf_set_rx_mode()
1172 static void iavf_napi_enable_all(struct iavf_adapter *adapter) in iavf_napi_enable_all() argument
1176 int q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_napi_enable_all()
1181 q_vector = &adapter->q_vectors[q_idx]; in iavf_napi_enable_all()
1191 static void iavf_napi_disable_all(struct iavf_adapter *adapter) in iavf_napi_disable_all() argument
1195 int q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_napi_disable_all()
1198 q_vector = &adapter->q_vectors[q_idx]; in iavf_napi_disable_all()
1207 static void iavf_configure(struct iavf_adapter *adapter) in iavf_configure() argument
1209 struct net_device *netdev = adapter->netdev; in iavf_configure()
1214 iavf_configure_tx(adapter); in iavf_configure()
1215 iavf_configure_rx(adapter); in iavf_configure()
1216 adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_QUEUES; in iavf_configure()
1218 for (i = 0; i < adapter->num_active_queues; i++) { in iavf_configure()
1219 struct iavf_ring *ring = &adapter->rx_rings[i]; in iavf_configure()
1231 static void iavf_up_complete(struct iavf_adapter *adapter) in iavf_up_complete() argument
1233 iavf_change_state(adapter, __IAVF_RUNNING); in iavf_up_complete()
1234 clear_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_up_complete()
1236 iavf_napi_enable_all(adapter); in iavf_up_complete()
1238 iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ENABLE_QUEUES); in iavf_up_complete()
1246 static void iavf_clear_mac_vlan_filters(struct iavf_adapter *adapter) in iavf_clear_mac_vlan_filters() argument
1251 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_clear_mac_vlan_filters()
1253 __dev_uc_unsync(adapter->netdev, NULL); in iavf_clear_mac_vlan_filters()
1254 __dev_mc_unsync(adapter->netdev, NULL); in iavf_clear_mac_vlan_filters()
1257 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, in iavf_clear_mac_vlan_filters()
1268 list_for_each_entry_safe(vlf, vlftmp, &adapter->vlan_filter_list, in iavf_clear_mac_vlan_filters()
1272 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_clear_mac_vlan_filters()
1280 static void iavf_clear_cloud_filters(struct iavf_adapter *adapter) in iavf_clear_cloud_filters() argument
1285 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_clear_cloud_filters()
1286 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, in iavf_clear_cloud_filters()
1291 adapter->num_cloud_filters--; in iavf_clear_cloud_filters()
1296 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_clear_cloud_filters()
1304 static void iavf_clear_fdir_filters(struct iavf_adapter *adapter) in iavf_clear_fdir_filters() argument
1309 spin_lock_bh(&adapter->fdir_fltr_lock); in iavf_clear_fdir_filters()
1310 list_for_each_entry(fdir, &adapter->fdir_list_head, list) { in iavf_clear_fdir_filters()
1322 spin_unlock_bh(&adapter->fdir_fltr_lock); in iavf_clear_fdir_filters()
1330 static void iavf_clear_adv_rss_conf(struct iavf_adapter *adapter) in iavf_clear_adv_rss_conf() argument
1335 spin_lock_bh(&adapter->adv_rss_lock); in iavf_clear_adv_rss_conf()
1336 list_for_each_entry_safe(rss, rsstmp, &adapter->adv_rss_list_head, in iavf_clear_adv_rss_conf()
1345 spin_unlock_bh(&adapter->adv_rss_lock); in iavf_clear_adv_rss_conf()
1354 void iavf_down(struct iavf_adapter *adapter) in iavf_down() argument
1356 struct net_device *netdev = adapter->netdev; in iavf_down()
1358 if (adapter->state <= __IAVF_DOWN_PENDING) in iavf_down()
1363 adapter->link_up = false; in iavf_down()
1364 iavf_napi_disable_all(adapter); in iavf_down()
1365 iavf_irq_disable(adapter); in iavf_down()
1367 iavf_clear_mac_vlan_filters(adapter); in iavf_down()
1368 iavf_clear_cloud_filters(adapter); in iavf_down()
1369 iavf_clear_fdir_filters(adapter); in iavf_down()
1370 iavf_clear_adv_rss_conf(adapter); in iavf_down()
1372 if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) in iavf_down()
1375 if (!test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) { in iavf_down()
1377 adapter->current_op = VIRTCHNL_OP_UNKNOWN; in iavf_down()
1382 if (!list_empty(&adapter->mac_filter_list)) in iavf_down()
1383 adapter->aq_required |= IAVF_FLAG_AQ_DEL_MAC_FILTER; in iavf_down()
1384 if (!list_empty(&adapter->vlan_filter_list)) in iavf_down()
1385 adapter->aq_required |= IAVF_FLAG_AQ_DEL_VLAN_FILTER; in iavf_down()
1386 if (!list_empty(&adapter->cloud_filter_list)) in iavf_down()
1387 adapter->aq_required |= IAVF_FLAG_AQ_DEL_CLOUD_FILTER; in iavf_down()
1388 if (!list_empty(&adapter->fdir_list_head)) in iavf_down()
1389 adapter->aq_required |= IAVF_FLAG_AQ_DEL_FDIR_FILTER; in iavf_down()
1390 if (!list_empty(&adapter->adv_rss_list_head)) in iavf_down()
1391 adapter->aq_required |= IAVF_FLAG_AQ_DEL_ADV_RSS_CFG; in iavf_down()
1394 iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_DISABLE_QUEUES); in iavf_down()
1407 iavf_acquire_msix_vectors(struct iavf_adapter *adapter, int vectors) in iavf_acquire_msix_vectors() argument
1423 err = pci_enable_msix_range(adapter->pdev, adapter->msix_entries, in iavf_acquire_msix_vectors()
1426 dev_err(&adapter->pdev->dev, "Unable to allocate MSI-X interrupts\n"); in iavf_acquire_msix_vectors()
1427 kfree(adapter->msix_entries); in iavf_acquire_msix_vectors()
1428 adapter->msix_entries = NULL; in iavf_acquire_msix_vectors()
1436 adapter->num_msix_vectors = err; in iavf_acquire_msix_vectors()
1446 static void iavf_free_queues(struct iavf_adapter *adapter) in iavf_free_queues() argument
1448 if (!adapter->vsi_res) in iavf_free_queues()
1450 adapter->num_active_queues = 0; in iavf_free_queues()
1451 kfree(adapter->tx_rings); in iavf_free_queues()
1452 adapter->tx_rings = NULL; in iavf_free_queues()
1453 kfree(adapter->rx_rings); in iavf_free_queues()
1454 adapter->rx_rings = NULL; in iavf_free_queues()
1466 void iavf_set_queue_vlan_tag_loc(struct iavf_adapter *adapter) in iavf_set_queue_vlan_tag_loc() argument
1470 for (i = 0; i < adapter->num_active_queues; i++) { in iavf_set_queue_vlan_tag_loc()
1471 struct iavf_ring *tx_ring = &adapter->tx_rings[i]; in iavf_set_queue_vlan_tag_loc()
1472 struct iavf_ring *rx_ring = &adapter->rx_rings[i]; in iavf_set_queue_vlan_tag_loc()
1482 if (VLAN_ALLOWED(adapter)) { in iavf_set_queue_vlan_tag_loc()
1485 } else if (VLAN_V2_ALLOWED(adapter)) { in iavf_set_queue_vlan_tag_loc()
1490 &adapter->vlan_v2_caps.offloads.stripping_support; in iavf_set_queue_vlan_tag_loc()
1492 &adapter->vlan_v2_caps.offloads.insertion_support; in iavf_set_queue_vlan_tag_loc()
1545 static int iavf_alloc_queues(struct iavf_adapter *adapter) in iavf_alloc_queues() argument
1554 if (adapter->num_req_queues) in iavf_alloc_queues()
1555 num_active_queues = adapter->num_req_queues; in iavf_alloc_queues()
1556 else if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) && in iavf_alloc_queues()
1557 adapter->num_tc) in iavf_alloc_queues()
1558 num_active_queues = adapter->ch_config.total_qps; in iavf_alloc_queues()
1561 adapter->vsi_res->num_queue_pairs, in iavf_alloc_queues()
1565 adapter->tx_rings = kcalloc(num_active_queues, in iavf_alloc_queues()
1567 if (!adapter->tx_rings) in iavf_alloc_queues()
1569 adapter->rx_rings = kcalloc(num_active_queues, in iavf_alloc_queues()
1571 if (!adapter->rx_rings) in iavf_alloc_queues()
1578 tx_ring = &adapter->tx_rings[i]; in iavf_alloc_queues()
1581 tx_ring->netdev = adapter->netdev; in iavf_alloc_queues()
1582 tx_ring->dev = &adapter->pdev->dev; in iavf_alloc_queues()
1583 tx_ring->count = adapter->tx_desc_count; in iavf_alloc_queues()
1585 if (adapter->flags & IAVF_FLAG_WB_ON_ITR_CAPABLE) in iavf_alloc_queues()
1588 rx_ring = &adapter->rx_rings[i]; in iavf_alloc_queues()
1590 rx_ring->netdev = adapter->netdev; in iavf_alloc_queues()
1591 rx_ring->count = adapter->rx_desc_count; in iavf_alloc_queues()
1595 adapter->num_active_queues = num_active_queues; in iavf_alloc_queues()
1597 iavf_set_queue_vlan_tag_loc(adapter); in iavf_alloc_queues()
1602 iavf_free_queues(adapter); in iavf_alloc_queues()
1613 static int iavf_set_interrupt_capability(struct iavf_adapter *adapter) in iavf_set_interrupt_capability() argument
1619 if (!adapter->vsi_res) { in iavf_set_interrupt_capability()
1623 pairs = adapter->num_active_queues; in iavf_set_interrupt_capability()
1631 (int)adapter->vf_res->max_vectors); in iavf_set_interrupt_capability()
1633 adapter->msix_entries = kcalloc(v_budget, in iavf_set_interrupt_capability()
1635 if (!adapter->msix_entries) { in iavf_set_interrupt_capability()
1641 adapter->msix_entries[vector].entry = vector; in iavf_set_interrupt_capability()
1643 err = iavf_acquire_msix_vectors(adapter, v_budget); in iavf_set_interrupt_capability()
1645 iavf_schedule_finish_config(adapter); in iavf_set_interrupt_capability()
1657 static int iavf_config_rss_aq(struct iavf_adapter *adapter) in iavf_config_rss_aq() argument
1660 (struct iavf_aqc_get_set_rss_key_data *)adapter->rss_key; in iavf_config_rss_aq()
1661 struct iavf_hw *hw = &adapter->hw; in iavf_config_rss_aq()
1664 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) { in iavf_config_rss_aq()
1666 dev_err(&adapter->pdev->dev, "Cannot configure RSS, command %d pending\n", in iavf_config_rss_aq()
1667 adapter->current_op); in iavf_config_rss_aq()
1671 status = iavf_aq_set_rss_key(hw, adapter->vsi.id, rss_key); in iavf_config_rss_aq()
1673 dev_err(&adapter->pdev->dev, "Cannot set RSS key, err %s aq_err %s\n", in iavf_config_rss_aq()
1680 status = iavf_aq_set_rss_lut(hw, adapter->vsi.id, false, in iavf_config_rss_aq()
1681 adapter->rss_lut, adapter->rss_lut_size); in iavf_config_rss_aq()
1683 dev_err(&adapter->pdev->dev, "Cannot set RSS lut, err %s aq_err %s\n", in iavf_config_rss_aq()
1699 static int iavf_config_rss_reg(struct iavf_adapter *adapter) in iavf_config_rss_reg() argument
1701 struct iavf_hw *hw = &adapter->hw; in iavf_config_rss_reg()
1705 dw = (u32 *)adapter->rss_key; in iavf_config_rss_reg()
1706 for (i = 0; i <= adapter->rss_key_size / 4; i++) in iavf_config_rss_reg()
1709 dw = (u32 *)adapter->rss_lut; in iavf_config_rss_reg()
1710 for (i = 0; i <= adapter->rss_lut_size / 4; i++) in iavf_config_rss_reg()
1724 int iavf_config_rss(struct iavf_adapter *adapter) in iavf_config_rss() argument
1727 if (RSS_PF(adapter)) { in iavf_config_rss()
1728 adapter->aq_required |= IAVF_FLAG_AQ_SET_RSS_LUT | in iavf_config_rss()
1731 } else if (RSS_AQ(adapter)) { in iavf_config_rss()
1732 return iavf_config_rss_aq(adapter); in iavf_config_rss()
1734 return iavf_config_rss_reg(adapter); in iavf_config_rss()
1742 static void iavf_fill_rss_lut(struct iavf_adapter *adapter) in iavf_fill_rss_lut() argument
1746 for (i = 0; i < adapter->rss_lut_size; i++) in iavf_fill_rss_lut()
1747 adapter->rss_lut[i] = i % adapter->num_active_queues; in iavf_fill_rss_lut()
1756 static int iavf_init_rss(struct iavf_adapter *adapter) in iavf_init_rss() argument
1758 struct iavf_hw *hw = &adapter->hw; in iavf_init_rss()
1760 if (!RSS_PF(adapter)) { in iavf_init_rss()
1762 if (adapter->vf_res->vf_cap_flags & in iavf_init_rss()
1764 adapter->hena = IAVF_DEFAULT_RSS_HENA_EXPANDED; in iavf_init_rss()
1766 adapter->hena = IAVF_DEFAULT_RSS_HENA; in iavf_init_rss()
1768 wr32(hw, IAVF_VFQF_HENA(0), (u32)adapter->hena); in iavf_init_rss()
1769 wr32(hw, IAVF_VFQF_HENA(1), (u32)(adapter->hena >> 32)); in iavf_init_rss()
1772 iavf_fill_rss_lut(adapter); in iavf_init_rss()
1773 netdev_rss_key_fill((void *)adapter->rss_key, adapter->rss_key_size); in iavf_init_rss()
1775 return iavf_config_rss(adapter); in iavf_init_rss()
1785 static int iavf_alloc_q_vectors(struct iavf_adapter *adapter) in iavf_alloc_q_vectors() argument
1790 num_q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_alloc_q_vectors()
1791 adapter->q_vectors = kcalloc(num_q_vectors, sizeof(*q_vector), in iavf_alloc_q_vectors()
1793 if (!adapter->q_vectors) in iavf_alloc_q_vectors()
1797 q_vector = &adapter->q_vectors[q_idx]; in iavf_alloc_q_vectors()
1798 q_vector->adapter = adapter; in iavf_alloc_q_vectors()
1799 q_vector->vsi = &adapter->vsi; in iavf_alloc_q_vectors()
1803 netif_napi_add(adapter->netdev, &q_vector->napi, in iavf_alloc_q_vectors()
1818 static void iavf_free_q_vectors(struct iavf_adapter *adapter) in iavf_free_q_vectors() argument
1822 if (!adapter->q_vectors) in iavf_free_q_vectors()
1825 num_q_vectors = adapter->num_msix_vectors - NONQ_VECS; in iavf_free_q_vectors()
1828 struct iavf_q_vector *q_vector = &adapter->q_vectors[q_idx]; in iavf_free_q_vectors()
1832 kfree(adapter->q_vectors); in iavf_free_q_vectors()
1833 adapter->q_vectors = NULL; in iavf_free_q_vectors()
1841 static void iavf_reset_interrupt_capability(struct iavf_adapter *adapter) in iavf_reset_interrupt_capability() argument
1843 if (!adapter->msix_entries) in iavf_reset_interrupt_capability()
1846 pci_disable_msix(adapter->pdev); in iavf_reset_interrupt_capability()
1847 kfree(adapter->msix_entries); in iavf_reset_interrupt_capability()
1848 adapter->msix_entries = NULL; in iavf_reset_interrupt_capability()
1856 static int iavf_init_interrupt_scheme(struct iavf_adapter *adapter) in iavf_init_interrupt_scheme() argument
1860 err = iavf_alloc_queues(adapter); in iavf_init_interrupt_scheme()
1862 dev_err(&adapter->pdev->dev, in iavf_init_interrupt_scheme()
1867 err = iavf_set_interrupt_capability(adapter); in iavf_init_interrupt_scheme()
1869 dev_err(&adapter->pdev->dev, in iavf_init_interrupt_scheme()
1874 err = iavf_alloc_q_vectors(adapter); in iavf_init_interrupt_scheme()
1876 dev_err(&adapter->pdev->dev, in iavf_init_interrupt_scheme()
1886 if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) && in iavf_init_interrupt_scheme()
1887 adapter->num_tc) in iavf_init_interrupt_scheme()
1888 dev_info(&adapter->pdev->dev, "ADq Enabled, %u TCs created", in iavf_init_interrupt_scheme()
1889 adapter->num_tc); in iavf_init_interrupt_scheme()
1891 dev_info(&adapter->pdev->dev, "Multiqueue %s: Queue pair count = %u", in iavf_init_interrupt_scheme()
1892 (adapter->num_active_queues > 1) ? "Enabled" : "Disabled", in iavf_init_interrupt_scheme()
1893 adapter->num_active_queues); in iavf_init_interrupt_scheme()
1897 iavf_reset_interrupt_capability(adapter); in iavf_init_interrupt_scheme()
1899 iavf_free_queues(adapter); in iavf_init_interrupt_scheme()
1908 static void iavf_free_interrupt_scheme(struct iavf_adapter *adapter) in iavf_free_interrupt_scheme() argument
1910 iavf_free_q_vectors(adapter); in iavf_free_interrupt_scheme()
1911 iavf_reset_interrupt_capability(adapter); in iavf_free_interrupt_scheme()
1912 iavf_free_queues(adapter); in iavf_free_interrupt_scheme()
1919 static void iavf_free_rss(struct iavf_adapter *adapter) in iavf_free_rss() argument
1921 kfree(adapter->rss_key); in iavf_free_rss()
1922 adapter->rss_key = NULL; in iavf_free_rss()
1924 kfree(adapter->rss_lut); in iavf_free_rss()
1925 adapter->rss_lut = NULL; in iavf_free_rss()
1935 static int iavf_reinit_interrupt_scheme(struct iavf_adapter *adapter, bool running) in iavf_reinit_interrupt_scheme() argument
1937 struct net_device *netdev = adapter->netdev; in iavf_reinit_interrupt_scheme()
1941 iavf_free_traffic_irqs(adapter); in iavf_reinit_interrupt_scheme()
1942 iavf_free_misc_irq(adapter); in iavf_reinit_interrupt_scheme()
1943 iavf_free_interrupt_scheme(adapter); in iavf_reinit_interrupt_scheme()
1945 err = iavf_init_interrupt_scheme(adapter); in iavf_reinit_interrupt_scheme()
1951 err = iavf_request_misc_irq(adapter); in iavf_reinit_interrupt_scheme()
1955 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_reinit_interrupt_scheme()
1957 iavf_map_rings_to_vectors(adapter); in iavf_reinit_interrupt_scheme()
1970 struct iavf_adapter *adapter; in iavf_finish_config() local
1973 adapter = container_of(work, struct iavf_adapter, finish_config); in iavf_finish_config()
1977 mutex_lock(&adapter->crit_lock); in iavf_finish_config()
1979 if ((adapter->flags & IAVF_FLAG_SETUP_NETDEV_FEATURES) && in iavf_finish_config()
1980 adapter->netdev->reg_state == NETREG_REGISTERED && in iavf_finish_config()
1981 !test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) { in iavf_finish_config()
1982 netdev_update_features(adapter->netdev); in iavf_finish_config()
1983 adapter->flags &= ~IAVF_FLAG_SETUP_NETDEV_FEATURES; in iavf_finish_config()
1986 switch (adapter->state) { in iavf_finish_config()
1988 if (adapter->netdev->reg_state != NETREG_REGISTERED) { in iavf_finish_config()
1989 err = register_netdevice(adapter->netdev); in iavf_finish_config()
1991 dev_err(&adapter->pdev->dev, "Unable to register netdev (%d)\n", in iavf_finish_config()
1995 iavf_free_rss(adapter); in iavf_finish_config()
1996 iavf_free_misc_irq(adapter); in iavf_finish_config()
1997 iavf_reset_interrupt_capability(adapter); in iavf_finish_config()
1998 iavf_change_state(adapter, in iavf_finish_config()
2009 pairs = adapter->num_active_queues; in iavf_finish_config()
2010 netif_set_real_num_rx_queues(adapter->netdev, pairs); in iavf_finish_config()
2011 netif_set_real_num_tx_queues(adapter->netdev, pairs); in iavf_finish_config()
2019 mutex_unlock(&adapter->crit_lock); in iavf_finish_config()
2027 void iavf_schedule_finish_config(struct iavf_adapter *adapter) in iavf_schedule_finish_config() argument
2029 if (!test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) in iavf_schedule_finish_config()
2030 queue_work(adapter->wq, &adapter->finish_config); in iavf_schedule_finish_config()
2042 static int iavf_process_aq_command(struct iavf_adapter *adapter) in iavf_process_aq_command() argument
2044 if (adapter->aq_required & IAVF_FLAG_AQ_GET_CONFIG) in iavf_process_aq_command()
2045 return iavf_send_vf_config_msg(adapter); in iavf_process_aq_command()
2046 if (adapter->aq_required & IAVF_FLAG_AQ_GET_OFFLOAD_VLAN_V2_CAPS) in iavf_process_aq_command()
2047 return iavf_send_vf_offload_vlan_v2_msg(adapter); in iavf_process_aq_command()
2048 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_QUEUES) { in iavf_process_aq_command()
2049 iavf_disable_queues(adapter); in iavf_process_aq_command()
2053 if (adapter->aq_required & IAVF_FLAG_AQ_MAP_VECTORS) { in iavf_process_aq_command()
2054 iavf_map_queues(adapter); in iavf_process_aq_command()
2058 if (adapter->aq_required & IAVF_FLAG_AQ_ADD_MAC_FILTER) { in iavf_process_aq_command()
2059 iavf_add_ether_addrs(adapter); in iavf_process_aq_command()
2063 if (adapter->aq_required & IAVF_FLAG_AQ_ADD_VLAN_FILTER) { in iavf_process_aq_command()
2064 iavf_add_vlans(adapter); in iavf_process_aq_command()
2068 if (adapter->aq_required & IAVF_FLAG_AQ_DEL_MAC_FILTER) { in iavf_process_aq_command()
2069 iavf_del_ether_addrs(adapter); in iavf_process_aq_command()
2073 if (adapter->aq_required & IAVF_FLAG_AQ_DEL_VLAN_FILTER) { in iavf_process_aq_command()
2074 iavf_del_vlans(adapter); in iavf_process_aq_command()
2078 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_VLAN_STRIPPING) { in iavf_process_aq_command()
2079 iavf_enable_vlan_stripping(adapter); in iavf_process_aq_command()
2083 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_VLAN_STRIPPING) { in iavf_process_aq_command()
2084 iavf_disable_vlan_stripping(adapter); in iavf_process_aq_command()
2088 if (adapter->aq_required & IAVF_FLAG_AQ_CONFIGURE_QUEUES) { in iavf_process_aq_command()
2089 iavf_configure_queues(adapter); in iavf_process_aq_command()
2093 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_QUEUES) { in iavf_process_aq_command()
2094 iavf_enable_queues(adapter); in iavf_process_aq_command()
2098 if (adapter->aq_required & IAVF_FLAG_AQ_CONFIGURE_RSS) { in iavf_process_aq_command()
2103 adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_RSS; in iavf_process_aq_command()
2106 if (adapter->aq_required & IAVF_FLAG_AQ_GET_HENA) { in iavf_process_aq_command()
2107 iavf_get_hena(adapter); in iavf_process_aq_command()
2110 if (adapter->aq_required & IAVF_FLAG_AQ_SET_HENA) { in iavf_process_aq_command()
2111 iavf_set_hena(adapter); in iavf_process_aq_command()
2114 if (adapter->aq_required & IAVF_FLAG_AQ_SET_RSS_KEY) { in iavf_process_aq_command()
2115 iavf_set_rss_key(adapter); in iavf_process_aq_command()
2118 if (adapter->aq_required & IAVF_FLAG_AQ_SET_RSS_LUT) { in iavf_process_aq_command()
2119 iavf_set_rss_lut(adapter); in iavf_process_aq_command()
2122 if (adapter->aq_required & IAVF_FLAG_AQ_SET_RSS_HFUNC) { in iavf_process_aq_command()
2123 iavf_set_rss_hfunc(adapter); in iavf_process_aq_command()
2127 if (adapter->aq_required & IAVF_FLAG_AQ_CONFIGURE_PROMISC_MODE) { in iavf_process_aq_command()
2128 iavf_set_promiscuous(adapter); in iavf_process_aq_command()
2132 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_CHANNELS) { in iavf_process_aq_command()
2133 iavf_enable_channels(adapter); in iavf_process_aq_command()
2137 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_CHANNELS) { in iavf_process_aq_command()
2138 iavf_disable_channels(adapter); in iavf_process_aq_command()
2141 if (adapter->aq_required & IAVF_FLAG_AQ_ADD_CLOUD_FILTER) { in iavf_process_aq_command()
2142 iavf_add_cloud_filter(adapter); in iavf_process_aq_command()
2145 if (adapter->aq_required & IAVF_FLAG_AQ_DEL_CLOUD_FILTER) { in iavf_process_aq_command()
2146 iavf_del_cloud_filter(adapter); in iavf_process_aq_command()
2149 if (adapter->aq_required & IAVF_FLAG_AQ_ADD_FDIR_FILTER) { in iavf_process_aq_command()
2150 iavf_add_fdir_filter(adapter); in iavf_process_aq_command()
2153 if (adapter->aq_required & IAVF_FLAG_AQ_DEL_FDIR_FILTER) { in iavf_process_aq_command()
2154 iavf_del_fdir_filter(adapter); in iavf_process_aq_command()
2157 if (adapter->aq_required & IAVF_FLAG_AQ_ADD_ADV_RSS_CFG) { in iavf_process_aq_command()
2158 iavf_add_adv_rss_cfg(adapter); in iavf_process_aq_command()
2161 if (adapter->aq_required & IAVF_FLAG_AQ_DEL_ADV_RSS_CFG) { in iavf_process_aq_command()
2162 iavf_del_adv_rss_cfg(adapter); in iavf_process_aq_command()
2165 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_CTAG_VLAN_STRIPPING) { in iavf_process_aq_command()
2166 iavf_disable_vlan_stripping_v2(adapter, ETH_P_8021Q); in iavf_process_aq_command()
2169 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_STAG_VLAN_STRIPPING) { in iavf_process_aq_command()
2170 iavf_disable_vlan_stripping_v2(adapter, ETH_P_8021AD); in iavf_process_aq_command()
2173 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_CTAG_VLAN_STRIPPING) { in iavf_process_aq_command()
2174 iavf_enable_vlan_stripping_v2(adapter, ETH_P_8021Q); in iavf_process_aq_command()
2177 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_STAG_VLAN_STRIPPING) { in iavf_process_aq_command()
2178 iavf_enable_vlan_stripping_v2(adapter, ETH_P_8021AD); in iavf_process_aq_command()
2181 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_CTAG_VLAN_INSERTION) { in iavf_process_aq_command()
2182 iavf_disable_vlan_insertion_v2(adapter, ETH_P_8021Q); in iavf_process_aq_command()
2185 if (adapter->aq_required & IAVF_FLAG_AQ_DISABLE_STAG_VLAN_INSERTION) { in iavf_process_aq_command()
2186 iavf_disable_vlan_insertion_v2(adapter, ETH_P_8021AD); in iavf_process_aq_command()
2189 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_CTAG_VLAN_INSERTION) { in iavf_process_aq_command()
2190 iavf_enable_vlan_insertion_v2(adapter, ETH_P_8021Q); in iavf_process_aq_command()
2193 if (adapter->aq_required & IAVF_FLAG_AQ_ENABLE_STAG_VLAN_INSERTION) { in iavf_process_aq_command()
2194 iavf_enable_vlan_insertion_v2(adapter, ETH_P_8021AD); in iavf_process_aq_command()
2198 if (adapter->aq_required & IAVF_FLAG_AQ_REQUEST_STATS) { in iavf_process_aq_command()
2199 iavf_request_stats(adapter); in iavf_process_aq_command()
2218 iavf_set_vlan_offload_features(struct iavf_adapter *adapter, in iavf_set_vlan_offload_features() argument
2248 if (VLAN_ALLOWED(adapter)) { in iavf_set_vlan_offload_features()
2258 } else if (VLAN_V2_ALLOWED(adapter)) { in iavf_set_vlan_offload_features()
2286 iavf_schedule_aq_request(adapter, aq_required); in iavf_set_vlan_offload_features()
2297 static void iavf_startup(struct iavf_adapter *adapter) in iavf_startup() argument
2299 struct pci_dev *pdev = adapter->pdev; in iavf_startup()
2300 struct iavf_hw *hw = &adapter->hw; in iavf_startup()
2304 WARN_ON(adapter->state != __IAVF_STARTUP); in iavf_startup()
2307 adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED; in iavf_startup()
2308 adapter->flags &= ~IAVF_FLAG_RESET_PENDING; in iavf_startup()
2327 ret = iavf_send_api_ver(adapter); in iavf_startup()
2333 iavf_change_state(adapter, __IAVF_INIT_VERSION_CHECK); in iavf_startup()
2336 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_startup()
2347 static void iavf_init_version_check(struct iavf_adapter *adapter) in iavf_init_version_check() argument
2349 struct pci_dev *pdev = adapter->pdev; in iavf_init_version_check()
2350 struct iavf_hw *hw = &adapter->hw; in iavf_init_version_check()
2353 WARN_ON(adapter->state != __IAVF_INIT_VERSION_CHECK); in iavf_init_version_check()
2358 iavf_change_state(adapter, __IAVF_STARTUP); in iavf_init_version_check()
2363 err = iavf_verify_api_ver(adapter); in iavf_init_version_check()
2366 err = iavf_send_api_ver(adapter); in iavf_init_version_check()
2369 adapter->pf_version.major, in iavf_init_version_check()
2370 adapter->pf_version.minor, in iavf_init_version_check()
2375 err = iavf_send_vf_config_msg(adapter); in iavf_init_version_check()
2381 iavf_change_state(adapter, __IAVF_INIT_GET_RESOURCES); in iavf_init_version_check()
2384 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_init_version_check()
2391 int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter) in iavf_parse_vf_resource_msg() argument
2393 int i, num_req_queues = adapter->num_req_queues; in iavf_parse_vf_resource_msg()
2394 struct iavf_vsi *vsi = &adapter->vsi; in iavf_parse_vf_resource_msg()
2396 for (i = 0; i < adapter->vf_res->num_vsis; i++) { in iavf_parse_vf_resource_msg()
2397 if (adapter->vf_res->vsi_res[i].vsi_type == VIRTCHNL_VSI_SRIOV) in iavf_parse_vf_resource_msg()
2398 adapter->vsi_res = &adapter->vf_res->vsi_res[i]; in iavf_parse_vf_resource_msg()
2400 if (!adapter->vsi_res) { in iavf_parse_vf_resource_msg()
2401 dev_err(&adapter->pdev->dev, "No LAN VSI found\n"); in iavf_parse_vf_resource_msg()
2406 num_req_queues > adapter->vsi_res->num_queue_pairs) { in iavf_parse_vf_resource_msg()
2411 dev_err(&adapter->pdev->dev, in iavf_parse_vf_resource_msg()
2414 adapter->vsi_res->num_queue_pairs); in iavf_parse_vf_resource_msg()
2415 adapter->flags |= IAVF_FLAG_REINIT_MSIX_NEEDED; in iavf_parse_vf_resource_msg()
2416 adapter->num_req_queues = adapter->vsi_res->num_queue_pairs; in iavf_parse_vf_resource_msg()
2417 iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); in iavf_parse_vf_resource_msg()
2421 adapter->num_req_queues = 0; in iavf_parse_vf_resource_msg()
2422 adapter->vsi.id = adapter->vsi_res->vsi_id; in iavf_parse_vf_resource_msg()
2424 adapter->vsi.back = adapter; in iavf_parse_vf_resource_msg()
2425 adapter->vsi.base_vector = 1; in iavf_parse_vf_resource_msg()
2426 vsi->netdev = adapter->netdev; in iavf_parse_vf_resource_msg()
2427 vsi->qs_handle = adapter->vsi_res->qset_handle; in iavf_parse_vf_resource_msg()
2428 if (adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) { in iavf_parse_vf_resource_msg()
2429 adapter->rss_key_size = adapter->vf_res->rss_key_size; in iavf_parse_vf_resource_msg()
2430 adapter->rss_lut_size = adapter->vf_res->rss_lut_size; in iavf_parse_vf_resource_msg()
2432 adapter->rss_key_size = IAVF_HKEY_ARRAY_SIZE; in iavf_parse_vf_resource_msg()
2433 adapter->rss_lut_size = IAVF_HLUT_ARRAY_SIZE; in iavf_parse_vf_resource_msg()
2448 static void iavf_init_get_resources(struct iavf_adapter *adapter) in iavf_init_get_resources() argument
2450 struct pci_dev *pdev = adapter->pdev; in iavf_init_get_resources()
2451 struct iavf_hw *hw = &adapter->hw; in iavf_init_get_resources()
2454 WARN_ON(adapter->state != __IAVF_INIT_GET_RESOURCES); in iavf_init_get_resources()
2456 if (!adapter->vf_res) { in iavf_init_get_resources()
2457 adapter->vf_res = kzalloc(IAVF_VIRTCHNL_VF_RESOURCE_SIZE, in iavf_init_get_resources()
2459 if (!adapter->vf_res) { in iavf_init_get_resources()
2464 err = iavf_get_vf_config(adapter); in iavf_init_get_resources()
2466 err = iavf_send_vf_config_msg(adapter); in iavf_init_get_resources()
2482 err = iavf_parse_vf_resource_msg(adapter); in iavf_init_get_resources()
2492 adapter->extended_caps = IAVF_EXTENDED_CAPS; in iavf_init_get_resources()
2494 iavf_change_state(adapter, __IAVF_INIT_EXTENDED_CAPS); in iavf_init_get_resources()
2498 kfree(adapter->vf_res); in iavf_init_get_resources()
2499 adapter->vf_res = NULL; in iavf_init_get_resources()
2501 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_init_get_resources()
2512 static void iavf_init_send_offload_vlan_v2_caps(struct iavf_adapter *adapter) in iavf_init_send_offload_vlan_v2_caps() argument
2516 WARN_ON(!(adapter->extended_caps & IAVF_EXTENDED_CAP_SEND_VLAN_V2)); in iavf_init_send_offload_vlan_v2_caps()
2518 ret = iavf_send_vf_offload_vlan_v2_msg(adapter); in iavf_init_send_offload_vlan_v2_caps()
2524 adapter->extended_caps &= ~IAVF_EXTENDED_CAP_RECV_VLAN_V2; in iavf_init_send_offload_vlan_v2_caps()
2528 adapter->extended_caps &= ~IAVF_EXTENDED_CAP_SEND_VLAN_V2; in iavf_init_send_offload_vlan_v2_caps()
2538 static void iavf_init_recv_offload_vlan_v2_caps(struct iavf_adapter *adapter) in iavf_init_recv_offload_vlan_v2_caps() argument
2542 WARN_ON(!(adapter->extended_caps & IAVF_EXTENDED_CAP_RECV_VLAN_V2)); in iavf_init_recv_offload_vlan_v2_caps()
2544 memset(&adapter->vlan_v2_caps, 0, sizeof(adapter->vlan_v2_caps)); in iavf_init_recv_offload_vlan_v2_caps()
2546 ret = iavf_get_vf_vlan_v2_caps(adapter); in iavf_init_recv_offload_vlan_v2_caps()
2551 adapter->extended_caps &= ~IAVF_EXTENDED_CAP_RECV_VLAN_V2; in iavf_init_recv_offload_vlan_v2_caps()
2557 adapter->extended_caps |= IAVF_EXTENDED_CAP_SEND_VLAN_V2; in iavf_init_recv_offload_vlan_v2_caps()
2558 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_init_recv_offload_vlan_v2_caps()
2572 static void iavf_init_process_extended_caps(struct iavf_adapter *adapter) in iavf_init_process_extended_caps() argument
2574 WARN_ON(adapter->state != __IAVF_INIT_EXTENDED_CAPS); in iavf_init_process_extended_caps()
2577 if (adapter->extended_caps & IAVF_EXTENDED_CAP_SEND_VLAN_V2) { in iavf_init_process_extended_caps()
2578 iavf_init_send_offload_vlan_v2_caps(adapter); in iavf_init_process_extended_caps()
2580 } else if (adapter->extended_caps & IAVF_EXTENDED_CAP_RECV_VLAN_V2) { in iavf_init_process_extended_caps()
2581 iavf_init_recv_offload_vlan_v2_caps(adapter); in iavf_init_process_extended_caps()
2588 iavf_change_state(adapter, __IAVF_INIT_CONFIG_ADAPTER); in iavf_init_process_extended_caps()
2598 static void iavf_init_config_adapter(struct iavf_adapter *adapter) in iavf_init_config_adapter() argument
2600 struct net_device *netdev = adapter->netdev; in iavf_init_config_adapter()
2601 struct pci_dev *pdev = adapter->pdev; in iavf_init_config_adapter()
2604 WARN_ON(adapter->state != __IAVF_INIT_CONFIG_ADAPTER); in iavf_init_config_adapter()
2606 if (iavf_process_config(adapter)) in iavf_init_config_adapter()
2609 adapter->current_op = VIRTCHNL_OP_UNKNOWN; in iavf_init_config_adapter()
2611 adapter->flags |= IAVF_FLAG_RX_CSUM_ENABLED; in iavf_init_config_adapter()
2620 if (!is_valid_ether_addr(adapter->hw.mac.addr)) { in iavf_init_config_adapter()
2622 adapter->hw.mac.addr); in iavf_init_config_adapter()
2624 ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr); in iavf_init_config_adapter()
2626 eth_hw_addr_set(netdev, adapter->hw.mac.addr); in iavf_init_config_adapter()
2627 ether_addr_copy(netdev->perm_addr, adapter->hw.mac.addr); in iavf_init_config_adapter()
2630 adapter->tx_desc_count = IAVF_DEFAULT_TXD; in iavf_init_config_adapter()
2631 adapter->rx_desc_count = IAVF_DEFAULT_RXD; in iavf_init_config_adapter()
2632 err = iavf_init_interrupt_scheme(adapter); in iavf_init_config_adapter()
2635 iavf_map_rings_to_vectors(adapter); in iavf_init_config_adapter()
2636 if (adapter->vf_res->vf_cap_flags & in iavf_init_config_adapter()
2638 adapter->flags |= IAVF_FLAG_WB_ON_ITR_CAPABLE; in iavf_init_config_adapter()
2640 err = iavf_request_misc_irq(adapter); in iavf_init_config_adapter()
2645 adapter->link_up = false; in iavf_init_config_adapter()
2648 dev_info(&pdev->dev, "MAC address: %pM\n", adapter->hw.mac.addr); in iavf_init_config_adapter()
2652 iavf_change_state(adapter, __IAVF_DOWN); in iavf_init_config_adapter()
2653 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_init_config_adapter()
2655 iavf_misc_irq_enable(adapter); in iavf_init_config_adapter()
2656 wake_up(&adapter->down_waitqueue); in iavf_init_config_adapter()
2658 adapter->rss_key = kzalloc(adapter->rss_key_size, GFP_KERNEL); in iavf_init_config_adapter()
2659 adapter->rss_lut = kzalloc(adapter->rss_lut_size, GFP_KERNEL); in iavf_init_config_adapter()
2660 if (!adapter->rss_key || !adapter->rss_lut) { in iavf_init_config_adapter()
2664 if (RSS_AQ(adapter)) in iavf_init_config_adapter()
2665 adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_RSS; in iavf_init_config_adapter()
2667 iavf_init_rss(adapter); in iavf_init_config_adapter()
2669 if (VLAN_V2_ALLOWED(adapter)) in iavf_init_config_adapter()
2671 iavf_set_vlan_offload_features(adapter, 0, netdev->features); in iavf_init_config_adapter()
2673 iavf_schedule_finish_config(adapter); in iavf_init_config_adapter()
2677 iavf_free_rss(adapter); in iavf_init_config_adapter()
2678 iavf_free_misc_irq(adapter); in iavf_init_config_adapter()
2680 iavf_reset_interrupt_capability(adapter); in iavf_init_config_adapter()
2682 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_init_config_adapter()
2691 struct iavf_adapter *adapter = container_of(work, in iavf_watchdog_task() local
2694 struct iavf_hw *hw = &adapter->hw; in iavf_watchdog_task()
2697 if (!mutex_trylock(&adapter->crit_lock)) { in iavf_watchdog_task()
2698 if (adapter->state == __IAVF_REMOVE) in iavf_watchdog_task()
2704 if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) in iavf_watchdog_task()
2705 iavf_change_state(adapter, __IAVF_COMM_FAILED); in iavf_watchdog_task()
2707 switch (adapter->state) { in iavf_watchdog_task()
2709 iavf_startup(adapter); in iavf_watchdog_task()
2710 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2711 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2715 iavf_init_version_check(adapter); in iavf_watchdog_task()
2716 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2717 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2721 iavf_init_get_resources(adapter); in iavf_watchdog_task()
2722 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2723 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2727 iavf_init_process_extended_caps(adapter); in iavf_watchdog_task()
2728 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2729 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2733 iavf_init_config_adapter(adapter); in iavf_watchdog_task()
2734 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2735 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2740 &adapter->crit_section)) { in iavf_watchdog_task()
2745 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2748 if (++adapter->aq_wait_count > IAVF_AQ_MAX_ERR) { in iavf_watchdog_task()
2749 dev_err(&adapter->pdev->dev, in iavf_watchdog_task()
2751 adapter->flags |= IAVF_FLAG_PF_COMMS_FAILED; in iavf_watchdog_task()
2753 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2754 queue_delayed_work(adapter->wq, in iavf_watchdog_task()
2755 &adapter->watchdog_task, (5 * HZ)); in iavf_watchdog_task()
2759 iavf_change_state(adapter, adapter->last_state); in iavf_watchdog_task()
2760 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2761 queue_delayed_work(adapter->wq, &adapter->watchdog_task, HZ); in iavf_watchdog_task()
2765 &adapter->crit_section)) { in iavf_watchdog_task()
2770 iavf_change_state(adapter, __IAVF_INIT_FAILED); in iavf_watchdog_task()
2771 adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED; in iavf_watchdog_task()
2772 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2780 dev_err(&adapter->pdev->dev, in iavf_watchdog_task()
2786 iavf_change_state(adapter, __IAVF_STARTUP); in iavf_watchdog_task()
2787 adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED; in iavf_watchdog_task()
2789 adapter->aq_required = 0; in iavf_watchdog_task()
2790 adapter->current_op = VIRTCHNL_OP_UNKNOWN; in iavf_watchdog_task()
2791 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2792 queue_delayed_work(adapter->wq, in iavf_watchdog_task()
2793 &adapter->watchdog_task, in iavf_watchdog_task()
2797 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2798 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2805 if (adapter->current_op) { in iavf_watchdog_task()
2807 dev_dbg(&adapter->pdev->dev, in iavf_watchdog_task()
2809 iavf_send_api_ver(adapter); in iavf_watchdog_task()
2812 int ret = iavf_process_aq_command(adapter); in iavf_watchdog_task()
2819 adapter->state == __IAVF_RUNNING) in iavf_watchdog_task()
2820 iavf_request_stats(adapter); in iavf_watchdog_task()
2822 if (adapter->state == __IAVF_RUNNING) in iavf_watchdog_task()
2823 iavf_detect_recover_hung(&adapter->vsi); in iavf_watchdog_task()
2827 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2834 adapter->aq_required = 0; in iavf_watchdog_task()
2835 adapter->current_op = VIRTCHNL_OP_UNKNOWN; in iavf_watchdog_task()
2836 dev_err(&adapter->pdev->dev, "Hardware reset detected\n"); in iavf_watchdog_task()
2837 iavf_schedule_reset(adapter, IAVF_FLAG_RESET_PENDING); in iavf_watchdog_task()
2838 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2839 queue_delayed_work(adapter->wq, in iavf_watchdog_task()
2840 &adapter->watchdog_task, HZ * 2); in iavf_watchdog_task()
2844 mutex_unlock(&adapter->crit_lock); in iavf_watchdog_task()
2846 if (adapter->state >= __IAVF_DOWN) in iavf_watchdog_task()
2847 queue_work(adapter->wq, &adapter->adminq_task); in iavf_watchdog_task()
2848 if (adapter->aq_required) in iavf_watchdog_task()
2849 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2852 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_watchdog_task()
2863 static void iavf_disable_vf(struct iavf_adapter *adapter) in iavf_disable_vf() argument
2869 adapter->flags |= IAVF_FLAG_PF_COMMS_FAILED; in iavf_disable_vf()
2875 if (adapter->state == __IAVF_RUNNING) { in iavf_disable_vf()
2876 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_disable_vf()
2877 netif_carrier_off(adapter->netdev); in iavf_disable_vf()
2878 netif_tx_disable(adapter->netdev); in iavf_disable_vf()
2879 adapter->link_up = false; in iavf_disable_vf()
2880 iavf_napi_disable_all(adapter); in iavf_disable_vf()
2881 iavf_irq_disable(adapter); in iavf_disable_vf()
2882 iavf_free_traffic_irqs(adapter); in iavf_disable_vf()
2883 iavf_free_all_tx_resources(adapter); in iavf_disable_vf()
2884 iavf_free_all_rx_resources(adapter); in iavf_disable_vf()
2887 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_disable_vf()
2890 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { in iavf_disable_vf()
2895 list_for_each_entry_safe(fv, fvtmp, &adapter->vlan_filter_list, list) { in iavf_disable_vf()
2899 adapter->num_vlan_filters = 0; in iavf_disable_vf()
2901 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_disable_vf()
2903 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_disable_vf()
2904 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, list) { in iavf_disable_vf()
2907 adapter->num_cloud_filters--; in iavf_disable_vf()
2909 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_disable_vf()
2911 iavf_free_misc_irq(adapter); in iavf_disable_vf()
2912 iavf_free_interrupt_scheme(adapter); in iavf_disable_vf()
2913 memset(adapter->vf_res, 0, IAVF_VIRTCHNL_VF_RESOURCE_SIZE); in iavf_disable_vf()
2914 iavf_shutdown_adminq(&adapter->hw); in iavf_disable_vf()
2915 adapter->flags &= ~IAVF_FLAG_RESET_PENDING; in iavf_disable_vf()
2916 iavf_change_state(adapter, __IAVF_DOWN); in iavf_disable_vf()
2917 wake_up(&adapter->down_waitqueue); in iavf_disable_vf()
2918 dev_info(&adapter->pdev->dev, "Reset task did not complete, VF disabled\n"); in iavf_disable_vf()
2931 struct iavf_adapter *adapter = container_of(work, in iavf_reset_task() local
2934 struct virtchnl_vf_resource *vfres = adapter->vf_res; in iavf_reset_task()
2935 struct net_device *netdev = adapter->netdev; in iavf_reset_task()
2936 struct iavf_hw *hw = &adapter->hw; in iavf_reset_task()
2947 if (!mutex_trylock(&adapter->crit_lock)) { in iavf_reset_task()
2948 if (adapter->state != __IAVF_REMOVE) in iavf_reset_task()
2949 queue_work(adapter->wq, &adapter->reset_task); in iavf_reset_task()
2954 iavf_misc_irq_disable(adapter); in iavf_reset_task()
2955 if (adapter->flags & IAVF_FLAG_RESET_NEEDED) { in iavf_reset_task()
2956 adapter->flags &= ~IAVF_FLAG_RESET_NEEDED; in iavf_reset_task()
2962 iavf_request_reset(adapter); in iavf_reset_task()
2964 adapter->flags |= IAVF_FLAG_RESET_PENDING; in iavf_reset_task()
2975 dev_info(&adapter->pdev->dev, "Never saw reset\n"); in iavf_reset_task()
2990 pci_set_master(adapter->pdev); in iavf_reset_task()
2991 pci_restore_msi_state(adapter->pdev); in iavf_reset_task()
2994 dev_err(&adapter->pdev->dev, "Reset never finished (%x)\n", in iavf_reset_task()
2996 iavf_disable_vf(adapter); in iavf_reset_task()
2997 mutex_unlock(&adapter->crit_lock); in iavf_reset_task()
3006 running = adapter->state == __IAVF_RUNNING; in iavf_reset_task()
3011 adapter->link_up = false; in iavf_reset_task()
3012 iavf_napi_disable_all(adapter); in iavf_reset_task()
3014 iavf_irq_disable(adapter); in iavf_reset_task()
3016 iavf_change_state(adapter, __IAVF_RESETTING); in iavf_reset_task()
3017 adapter->flags &= ~IAVF_FLAG_RESET_PENDING; in iavf_reset_task()
3022 iavf_free_all_rx_resources(adapter); in iavf_reset_task()
3023 iavf_free_all_tx_resources(adapter); in iavf_reset_task()
3025 adapter->flags |= IAVF_FLAG_QUEUES_DISABLED; in iavf_reset_task()
3028 adapter->current_op = VIRTCHNL_OP_UNKNOWN; in iavf_reset_task()
3031 dev_info(&adapter->pdev->dev, "Failed to init adminq: %d\n", in iavf_reset_task()
3035 adapter->aq_required = 0; in iavf_reset_task()
3037 if ((adapter->flags & IAVF_FLAG_REINIT_MSIX_NEEDED) || in iavf_reset_task()
3038 (adapter->flags & IAVF_FLAG_REINIT_ITR_NEEDED)) { in iavf_reset_task()
3039 err = iavf_reinit_interrupt_scheme(adapter, running); in iavf_reset_task()
3044 if (RSS_AQ(adapter)) { in iavf_reset_task()
3045 adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_RSS; in iavf_reset_task()
3047 err = iavf_init_rss(adapter); in iavf_reset_task()
3052 adapter->aq_required |= IAVF_FLAG_AQ_GET_CONFIG; in iavf_reset_task()
3059 adapter->aq_required |= IAVF_FLAG_AQ_GET_OFFLOAD_VLAN_V2_CAPS; in iavf_reset_task()
3060 adapter->aq_required |= IAVF_FLAG_AQ_MAP_VECTORS; in iavf_reset_task()
3062 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_reset_task()
3068 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { in iavf_reset_task()
3069 if (ether_addr_equal(f->macaddr, adapter->hw.mac.addr)) { in iavf_reset_task()
3075 list_for_each_entry(f, &adapter->mac_filter_list, list) { in iavf_reset_task()
3078 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_reset_task()
3081 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_reset_task()
3083 adapter->num_tc) { in iavf_reset_task()
3084 list_for_each_entry(cf, &adapter->cloud_filter_list, list) { in iavf_reset_task()
3088 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_reset_task()
3090 adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER; in iavf_reset_task()
3091 adapter->aq_required |= IAVF_FLAG_AQ_ADD_CLOUD_FILTER; in iavf_reset_task()
3092 iavf_misc_irq_enable(adapter); in iavf_reset_task()
3094 mod_delayed_work(adapter->wq, &adapter->watchdog_task, 2); in iavf_reset_task()
3101 err = iavf_setup_all_tx_resources(adapter); in iavf_reset_task()
3106 err = iavf_setup_all_rx_resources(adapter); in iavf_reset_task()
3110 if ((adapter->flags & IAVF_FLAG_REINIT_MSIX_NEEDED) || in iavf_reset_task()
3111 (adapter->flags & IAVF_FLAG_REINIT_ITR_NEEDED)) { in iavf_reset_task()
3112 err = iavf_request_traffic_irqs(adapter, netdev->name); in iavf_reset_task()
3116 adapter->flags &= ~IAVF_FLAG_REINIT_MSIX_NEEDED; in iavf_reset_task()
3119 iavf_configure(adapter); in iavf_reset_task()
3124 iavf_up_complete(adapter); in iavf_reset_task()
3126 iavf_irq_enable(adapter, true); in iavf_reset_task()
3128 iavf_change_state(adapter, __IAVF_DOWN); in iavf_reset_task()
3129 wake_up(&adapter->down_waitqueue); in iavf_reset_task()
3132 adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED; in iavf_reset_task()
3134 wake_up(&adapter->reset_waitqueue); in iavf_reset_task()
3135 mutex_unlock(&adapter->crit_lock); in iavf_reset_task()
3140 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_reset_task()
3141 iavf_free_traffic_irqs(adapter); in iavf_reset_task()
3143 iavf_disable_vf(adapter); in iavf_reset_task()
3145 mutex_unlock(&adapter->crit_lock); in iavf_reset_task()
3146 dev_err(&adapter->pdev->dev, "failed to allocate resources during reinit\n"); in iavf_reset_task()
3155 struct iavf_adapter *adapter = in iavf_adminq_task() local
3157 struct iavf_hw *hw = &adapter->hw; in iavf_adminq_task()
3164 if (!mutex_trylock(&adapter->crit_lock)) { in iavf_adminq_task()
3165 if (adapter->state == __IAVF_REMOVE) in iavf_adminq_task()
3168 queue_work(adapter->wq, &adapter->adminq_task); in iavf_adminq_task()
3172 if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) in iavf_adminq_task()
3188 iavf_virtchnl_completion(adapter, v_op, v_ret, event.msg_buf, in iavf_adminq_task()
3194 if (iavf_is_reset_in_progress(adapter)) in iavf_adminq_task()
3203 dev_info(&adapter->pdev->dev, "ARQ VF Error detected\n"); in iavf_adminq_task()
3207 dev_info(&adapter->pdev->dev, "ARQ Overflow Error detected\n"); in iavf_adminq_task()
3211 dev_info(&adapter->pdev->dev, "ARQ Critical Error detected\n"); in iavf_adminq_task()
3220 dev_info(&adapter->pdev->dev, "ASQ VF Error detected\n"); in iavf_adminq_task()
3224 dev_info(&adapter->pdev->dev, "ASQ Overflow Error detected\n"); in iavf_adminq_task()
3228 dev_info(&adapter->pdev->dev, "ASQ Critical Error detected\n"); in iavf_adminq_task()
3237 mutex_unlock(&adapter->crit_lock); in iavf_adminq_task()
3240 iavf_misc_irq_enable(adapter); in iavf_adminq_task()
3249 void iavf_free_all_tx_resources(struct iavf_adapter *adapter) in iavf_free_all_tx_resources() argument
3253 if (!adapter->tx_rings) in iavf_free_all_tx_resources()
3256 for (i = 0; i < adapter->num_active_queues; i++) in iavf_free_all_tx_resources()
3257 if (adapter->tx_rings[i].desc) in iavf_free_all_tx_resources()
3258 iavf_free_tx_resources(&adapter->tx_rings[i]); in iavf_free_all_tx_resources()
3271 static int iavf_setup_all_tx_resources(struct iavf_adapter *adapter) in iavf_setup_all_tx_resources() argument
3275 for (i = 0; i < adapter->num_active_queues; i++) { in iavf_setup_all_tx_resources()
3276 adapter->tx_rings[i].count = adapter->tx_desc_count; in iavf_setup_all_tx_resources()
3277 err = iavf_setup_tx_descriptors(&adapter->tx_rings[i]); in iavf_setup_all_tx_resources()
3280 dev_err(&adapter->pdev->dev, in iavf_setup_all_tx_resources()
3298 static int iavf_setup_all_rx_resources(struct iavf_adapter *adapter) in iavf_setup_all_rx_resources() argument
3302 for (i = 0; i < adapter->num_active_queues; i++) { in iavf_setup_all_rx_resources()
3303 adapter->rx_rings[i].count = adapter->rx_desc_count; in iavf_setup_all_rx_resources()
3304 err = iavf_setup_rx_descriptors(&adapter->rx_rings[i]); in iavf_setup_all_rx_resources()
3307 dev_err(&adapter->pdev->dev, in iavf_setup_all_rx_resources()
3320 void iavf_free_all_rx_resources(struct iavf_adapter *adapter) in iavf_free_all_rx_resources() argument
3324 if (!adapter->rx_rings) in iavf_free_all_rx_resources()
3327 for (i = 0; i < adapter->num_active_queues; i++) in iavf_free_all_rx_resources()
3328 if (adapter->rx_rings[i].desc) in iavf_free_all_rx_resources()
3329 iavf_free_rx_resources(&adapter->rx_rings[i]); in iavf_free_all_rx_resources()
3337 static int iavf_validate_tx_bandwidth(struct iavf_adapter *adapter, in iavf_validate_tx_bandwidth() argument
3342 if (ADV_LINK_SUPPORT(adapter)) { in iavf_validate_tx_bandwidth()
3343 if (adapter->link_speed_mbps < U32_MAX) { in iavf_validate_tx_bandwidth()
3344 speed = adapter->link_speed_mbps; in iavf_validate_tx_bandwidth()
3347 dev_err(&adapter->pdev->dev, "Unknown link speed\n"); in iavf_validate_tx_bandwidth()
3352 switch (adapter->link_speed) { in iavf_validate_tx_bandwidth()
3383 dev_err(&adapter->pdev->dev, in iavf_validate_tx_bandwidth()
3400 static int iavf_validate_ch_config(struct iavf_adapter *adapter, in iavf_validate_ch_config() argument
3418 dev_err(&adapter->pdev->dev, in iavf_validate_ch_config()
3430 dev_err(&adapter->pdev->dev, in iavf_validate_ch_config()
3439 dev_err(&adapter->pdev->dev, in iavf_validate_ch_config()
3448 if (num_qps > adapter->num_active_queues) { in iavf_validate_ch_config()
3449 dev_err(&adapter->pdev->dev, in iavf_validate_ch_config()
3454 ret = iavf_validate_tx_bandwidth(adapter, total_max_rate); in iavf_validate_ch_config()
3462 static void iavf_del_all_cloud_filters(struct iavf_adapter *adapter) in iavf_del_all_cloud_filters() argument
3466 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_del_all_cloud_filters()
3467 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, in iavf_del_all_cloud_filters()
3471 adapter->num_cloud_filters--; in iavf_del_all_cloud_filters()
3473 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_del_all_cloud_filters()
3487 static bool iavf_is_tc_config_same(struct iavf_adapter *adapter, in iavf_is_tc_config_same() argument
3490 struct virtchnl_channel_info *ch = &adapter->ch_config.ch_info[0]; in iavf_is_tc_config_same()
3493 if (adapter->num_tc != mqprio_qopt->num_tc) in iavf_is_tc_config_same()
3496 for (i = 0; i < adapter->num_tc; i++) { in iavf_is_tc_config_same()
3518 struct iavf_adapter *adapter = netdev_priv(netdev); in __iavf_setup_tc() local
3519 struct virtchnl_vf_resource *vfres = adapter->vf_res; in __iavf_setup_tc()
3531 if (adapter->ch_config.state == __IAVF_TC_RUNNING) { in __iavf_setup_tc()
3534 adapter->num_tc = 0; in __iavf_setup_tc()
3537 iavf_del_all_cloud_filters(adapter); in __iavf_setup_tc()
3538 adapter->aq_required = IAVF_FLAG_AQ_DISABLE_CHANNELS; in __iavf_setup_tc()
3539 total_qps = adapter->orig_num_active_queues; in __iavf_setup_tc()
3549 dev_err(&adapter->pdev->dev, "ADq not supported\n"); in __iavf_setup_tc()
3552 if (adapter->ch_config.state != __IAVF_TC_INVALID) { in __iavf_setup_tc()
3553 dev_err(&adapter->pdev->dev, "TC configuration already exists\n"); in __iavf_setup_tc()
3557 ret = iavf_validate_ch_config(adapter, mqprio_qopt); in __iavf_setup_tc()
3561 if (iavf_is_tc_config_same(adapter, &mqprio_qopt->qopt)) in __iavf_setup_tc()
3563 adapter->num_tc = num_tc; in __iavf_setup_tc()
3567 adapter->ch_config.ch_info[i].count = in __iavf_setup_tc()
3569 adapter->ch_config.ch_info[i].offset = in __iavf_setup_tc()
3576 adapter->ch_config.ch_info[i].max_tx_rate = in __iavf_setup_tc()
3579 adapter->ch_config.ch_info[i].count = 1; in __iavf_setup_tc()
3580 adapter->ch_config.ch_info[i].offset = 0; in __iavf_setup_tc()
3590 adapter->orig_num_active_queues = adapter->num_active_queues; in __iavf_setup_tc()
3596 adapter->ch_config.total_qps = total_qps; in __iavf_setup_tc()
3600 adapter->aq_required |= IAVF_FLAG_AQ_ENABLE_CHANNELS; in __iavf_setup_tc()
3603 netdev_set_num_tc(adapter->netdev, num_tc); in __iavf_setup_tc()
3614 if (test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) in __iavf_setup_tc()
3629 static int iavf_parse_cls_flower(struct iavf_adapter *adapter, in iavf_parse_cls_flower() argument
3652 dev_err(&adapter->pdev->dev, "Unsupported key used: 0x%llx\n", in iavf_parse_cls_flower()
3685 dev_info(&adapter->pdev->dev, "Only TCP transport is supported\n"); in iavf_parse_cls_flower()
3700 dev_err(&adapter->pdev->dev, "Bad ether dest mask %pM\n", in iavf_parse_cls_flower()
3710 dev_err(&adapter->pdev->dev, "Bad ether src mask %pM\n", in iavf_parse_cls_flower()
3745 dev_err(&adapter->pdev->dev, "Bad vlan mask %u\n", in iavf_parse_cls_flower()
3773 dev_err(&adapter->pdev->dev, "Bad ip dst mask 0x%08x\n", in iavf_parse_cls_flower()
3783 dev_err(&adapter->pdev->dev, "Bad ip src mask 0x%08x\n", in iavf_parse_cls_flower()
3790 dev_info(&adapter->pdev->dev, "Tenant id not allowed for ip filter\n"); in iavf_parse_cls_flower()
3810 dev_err(&adapter->pdev->dev, "Bad ipv6 dst mask 0x%02x\n", in iavf_parse_cls_flower()
3820 dev_err(&adapter->pdev->dev, in iavf_parse_cls_flower()
3845 dev_err(&adapter->pdev->dev, "Bad src port mask %u\n", in iavf_parse_cls_flower()
3855 dev_err(&adapter->pdev->dev, "Bad dst port mask %u\n", in iavf_parse_cls_flower()
3881 static int iavf_handle_tclass(struct iavf_adapter *adapter, u32 tc, in iavf_handle_tclass() argument
3886 if (tc < adapter->num_tc) { in iavf_handle_tclass()
3888 dev_err(&adapter->pdev->dev, in iavf_handle_tclass()
3907 static struct iavf_cloud_filter *iavf_find_cf(struct iavf_adapter *adapter, in iavf_find_cf() argument
3915 list_for_each_entry(filter, &adapter->cloud_filter_list, list) { in iavf_find_cf()
3927 static int iavf_configure_clsflower(struct iavf_adapter *adapter, in iavf_configure_clsflower() argument
3930 int tc = tc_classid_to_hwtc(adapter->netdev, cls_flower->classid); in iavf_configure_clsflower()
3935 dev_err(&adapter->pdev->dev, "Invalid traffic class\n"); in iavf_configure_clsflower()
3943 while (!mutex_trylock(&adapter->crit_lock)) { in iavf_configure_clsflower()
3954 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_configure_clsflower()
3955 if (iavf_find_cf(adapter, &cls_flower->cookie)) { in iavf_configure_clsflower()
3956 dev_err(&adapter->pdev->dev, "Failed to add TC Flower filter, it already exists\n"); in iavf_configure_clsflower()
3960 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_configure_clsflower()
3966 err = iavf_parse_cls_flower(adapter, cls_flower, filter); in iavf_configure_clsflower()
3970 err = iavf_handle_tclass(adapter, tc, filter); in iavf_configure_clsflower()
3975 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_configure_clsflower()
3976 list_add_tail(&filter->list, &adapter->cloud_filter_list); in iavf_configure_clsflower()
3977 adapter->num_cloud_filters++; in iavf_configure_clsflower()
3979 adapter->aq_required |= IAVF_FLAG_AQ_ADD_CLOUD_FILTER; in iavf_configure_clsflower()
3981 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_configure_clsflower()
3986 mutex_unlock(&adapter->crit_lock); in iavf_configure_clsflower()
3995 static int iavf_delete_clsflower(struct iavf_adapter *adapter, in iavf_delete_clsflower() argument
4001 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_delete_clsflower()
4002 filter = iavf_find_cf(adapter, &cls_flower->cookie); in iavf_delete_clsflower()
4005 adapter->aq_required |= IAVF_FLAG_AQ_DEL_CLOUD_FILTER; in iavf_delete_clsflower()
4009 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_delete_clsflower()
4019 static int iavf_setup_tc_cls_flower(struct iavf_adapter *adapter, in iavf_setup_tc_cls_flower() argument
4024 return iavf_configure_clsflower(adapter, cls_flower); in iavf_setup_tc_cls_flower()
4026 return iavf_delete_clsflower(adapter, cls_flower); in iavf_setup_tc_cls_flower()
4041 static int iavf_add_cls_u32(struct iavf_adapter *adapter, in iavf_add_cls_u32() argument
4114 if (q_index >= adapter->num_active_queues) { in iavf_add_cls_u32()
4136 fltr->vc_add_msg.vsi_id = adapter->vsi.id; in iavf_add_cls_u32()
4138 return iavf_fdir_add_fltr(adapter, fltr); in iavf_add_cls_u32()
4152 static int iavf_del_cls_u32(struct iavf_adapter *adapter, in iavf_del_cls_u32() argument
4155 return iavf_fdir_del_fltr(adapter, true, cls_u32->knode.handle); in iavf_del_cls_u32()
4165 static int iavf_setup_tc_cls_u32(struct iavf_adapter *adapter, in iavf_setup_tc_cls_u32() argument
4168 if (!TC_U32_SUPPORT(adapter) || !FDIR_FLTR_SUPPORT(adapter)) in iavf_setup_tc_cls_u32()
4174 return iavf_add_cls_u32(adapter, cls_u32); in iavf_setup_tc_cls_u32()
4176 return iavf_del_cls_u32(adapter, cls_u32); in iavf_setup_tc_cls_u32()
4193 struct iavf_adapter *adapter = cb_priv; in iavf_setup_tc_block_cb() local
4195 if (!tc_cls_can_offload_and_chain0(adapter->netdev, type_data)) in iavf_setup_tc_block_cb()
4224 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_setup_tc() local
4233 adapter, adapter, true); in iavf_setup_tc()
4245 static void iavf_restore_fdir_filters(struct iavf_adapter *adapter) in iavf_restore_fdir_filters() argument
4249 spin_lock_bh(&adapter->fdir_fltr_lock); in iavf_restore_fdir_filters()
4250 list_for_each_entry(f, &adapter->fdir_list_head, list) { in iavf_restore_fdir_filters()
4260 adapter->aq_required |= IAVF_FLAG_AQ_ADD_FDIR_FILTER; in iavf_restore_fdir_filters()
4263 spin_unlock_bh(&adapter->fdir_fltr_lock); in iavf_restore_fdir_filters()
4280 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_open() local
4283 if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) { in iavf_open()
4284 dev_err(&adapter->pdev->dev, "Unable to open device due to PF driver failure.\n"); in iavf_open()
4288 while (!mutex_trylock(&adapter->crit_lock)) { in iavf_open()
4294 if (adapter->state == __IAVF_INIT_CONFIG_ADAPTER) in iavf_open()
4300 if (adapter->state != __IAVF_DOWN) { in iavf_open()
4305 if (adapter->state == __IAVF_RUNNING && in iavf_open()
4306 !test_bit(__IAVF_VSI_DOWN, adapter->vsi.state)) { in iavf_open()
4307 dev_dbg(&adapter->pdev->dev, "VF is already open.\n"); in iavf_open()
4313 err = iavf_setup_all_tx_resources(adapter); in iavf_open()
4318 err = iavf_setup_all_rx_resources(adapter); in iavf_open()
4323 err = iavf_request_traffic_irqs(adapter, netdev->name); in iavf_open()
4327 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_open()
4329 iavf_add_filter(adapter, adapter->hw.mac.addr); in iavf_open()
4331 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_open()
4334 iavf_restore_filters(adapter); in iavf_open()
4335 iavf_restore_fdir_filters(adapter); in iavf_open()
4337 iavf_configure(adapter); in iavf_open()
4339 iavf_up_complete(adapter); in iavf_open()
4341 iavf_irq_enable(adapter, true); in iavf_open()
4343 mutex_unlock(&adapter->crit_lock); in iavf_open()
4348 iavf_down(adapter); in iavf_open()
4349 iavf_free_traffic_irqs(adapter); in iavf_open()
4351 iavf_free_all_rx_resources(adapter); in iavf_open()
4353 iavf_free_all_tx_resources(adapter); in iavf_open()
4355 mutex_unlock(&adapter->crit_lock); in iavf_open()
4373 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_close() local
4377 mutex_lock(&adapter->crit_lock); in iavf_close()
4379 if (adapter->state <= __IAVF_DOWN_PENDING) { in iavf_close()
4380 mutex_unlock(&adapter->crit_lock); in iavf_close()
4384 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); in iavf_close()
4394 aq_to_restore = adapter->aq_required; in iavf_close()
4395 adapter->aq_required &= IAVF_FLAG_AQ_GET_CONFIG; in iavf_close()
4409 iavf_down(adapter); in iavf_close()
4410 iavf_change_state(adapter, __IAVF_DOWN_PENDING); in iavf_close()
4411 iavf_free_traffic_irqs(adapter); in iavf_close()
4413 mutex_unlock(&adapter->crit_lock); in iavf_close()
4426 status = wait_event_timeout(adapter->down_waitqueue, in iavf_close()
4427 adapter->state == __IAVF_DOWN, in iavf_close()
4432 mutex_lock(&adapter->crit_lock); in iavf_close()
4433 adapter->aq_required |= aq_to_restore; in iavf_close()
4434 mutex_unlock(&adapter->crit_lock); in iavf_close()
4447 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_change_mtu() local
4455 iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); in iavf_change_mtu()
4456 ret = iavf_wait_for_reset(adapter); in iavf_change_mtu()
4470 static void iavf_disable_fdir(struct iavf_adapter *adapter) in iavf_disable_fdir() argument
4475 adapter->flags &= ~IAVF_FLAG_FDIR_ENABLED; in iavf_disable_fdir()
4478 spin_lock_bh(&adapter->fdir_fltr_lock); in iavf_disable_fdir()
4479 list_for_each_entry_safe(fdir, fdirtmp, &adapter->fdir_list_head, in iavf_disable_fdir()
4485 iavf_dec_fdir_active_fltr(adapter, fdir); in iavf_disable_fdir()
4501 spin_unlock_bh(&adapter->fdir_fltr_lock); in iavf_disable_fdir()
4504 adapter->aq_required |= IAVF_FLAG_AQ_DEL_FDIR_FILTER; in iavf_disable_fdir()
4505 mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); in iavf_disable_fdir()
4523 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_set_features() local
4528 iavf_set_vlan_offload_features(adapter, netdev->features, in iavf_set_features()
4530 if (CRC_OFFLOAD_ALLOWED(adapter) && in iavf_set_features()
4532 iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); in iavf_set_features()
4536 adapter->flags |= IAVF_FLAG_FDIR_ENABLED; in iavf_set_features()
4538 iavf_disable_fdir(adapter); in iavf_set_features()
4610 iavf_get_netdev_vlan_hw_features(struct iavf_adapter *adapter) in iavf_get_netdev_vlan_hw_features() argument
4614 if (!adapter->vf_res || !adapter->vf_res->vf_cap_flags) in iavf_get_netdev_vlan_hw_features()
4618 if (VLAN_ALLOWED(adapter)) { in iavf_get_netdev_vlan_hw_features()
4621 } else if (VLAN_V2_ALLOWED(adapter)) { in iavf_get_netdev_vlan_hw_features()
4623 &adapter->vlan_v2_caps; in iavf_get_netdev_vlan_hw_features()
4661 if (CRC_OFFLOAD_ALLOWED(adapter)) in iavf_get_netdev_vlan_hw_features()
4675 iavf_get_netdev_vlan_features(struct iavf_adapter *adapter) in iavf_get_netdev_vlan_features() argument
4679 if (!adapter->vf_res || !adapter->vf_res->vf_cap_flags) in iavf_get_netdev_vlan_features()
4682 if (VLAN_ALLOWED(adapter)) { in iavf_get_netdev_vlan_features()
4685 } else if (VLAN_V2_ALLOWED(adapter)) { in iavf_get_netdev_vlan_features()
4687 &adapter->vlan_v2_caps; in iavf_get_netdev_vlan_features()
4776 iavf_fix_netdev_vlan_features(struct iavf_adapter *adapter, in iavf_fix_netdev_vlan_features() argument
4781 allowed_features = iavf_get_netdev_vlan_hw_features(adapter) | in iavf_fix_netdev_vlan_features()
4782 iavf_get_netdev_vlan_features(adapter); in iavf_fix_netdev_vlan_features()
4817 adapter->vlan_v2_caps.offloads.ethertype_match == in iavf_fix_netdev_vlan_features()
4819 …netdev_warn(adapter->netdev, "cannot support CTAG and STAG VLAN stripping and/or insertion simulta… in iavf_fix_netdev_vlan_features()
4835 iavf_fix_strip_features(struct iavf_adapter *adapter, in iavf_fix_strip_features() argument
4838 struct net_device *netdev = adapter->netdev; in iavf_fix_strip_features()
4843 crc_offload_req = CRC_OFFLOAD_ALLOWED(adapter) && in iavf_fix_strip_features()
4845 num_non_zero_vlan = iavf_get_num_vlans_added(adapter); in iavf_fix_strip_features()
4886 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_fix_features() local
4888 features = iavf_fix_netdev_vlan_features(adapter, features); in iavf_fix_features()
4890 if (!FDIR_FLTR_SUPPORT(adapter)) in iavf_fix_features()
4893 return iavf_fix_strip_features(adapter, features); in iavf_fix_features()
4942 int iavf_process_config(struct iavf_adapter *adapter) in iavf_process_config() argument
4944 struct virtchnl_vf_resource *vfres = adapter->vf_res; in iavf_process_config()
4946 struct net_device *netdev = adapter->netdev; in iavf_process_config()
4994 hw_vlan_features = iavf_get_netdev_vlan_hw_features(adapter); in iavf_process_config()
4998 TC_U32_SUPPORT(adapter)) in iavf_process_config()
5005 vlan_features = iavf_get_netdev_vlan_features(adapter); in iavf_process_config()
5012 if (FDIR_FLTR_SUPPORT(adapter)) { in iavf_process_config()
5015 adapter->flags |= IAVF_FLAG_FDIR_ENABLED; in iavf_process_config()
5055 struct iavf_adapter *adapter = NULL; in iavf_probe() local
5089 adapter = netdev_priv(netdev); in iavf_probe()
5091 adapter->netdev = netdev; in iavf_probe()
5092 adapter->pdev = pdev; in iavf_probe()
5094 hw = &adapter->hw; in iavf_probe()
5095 hw->back = adapter; in iavf_probe()
5097 adapter->wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, in iavf_probe()
5099 if (!adapter->wq) { in iavf_probe()
5104 adapter->msg_enable = BIT(DEFAULT_DEBUG_LEVEL_SHIFT) - 1; in iavf_probe()
5105 iavf_change_state(adapter, __IAVF_STARTUP); in iavf_probe()
5128 mutex_init(&adapter->crit_lock); in iavf_probe()
5132 spin_lock_init(&adapter->mac_vlan_list_lock); in iavf_probe()
5133 spin_lock_init(&adapter->cloud_filter_list_lock); in iavf_probe()
5134 spin_lock_init(&adapter->fdir_fltr_lock); in iavf_probe()
5135 spin_lock_init(&adapter->adv_rss_lock); in iavf_probe()
5136 spin_lock_init(&adapter->current_netdev_promisc_flags_lock); in iavf_probe()
5138 INIT_LIST_HEAD(&adapter->mac_filter_list); in iavf_probe()
5139 INIT_LIST_HEAD(&adapter->vlan_filter_list); in iavf_probe()
5140 INIT_LIST_HEAD(&adapter->cloud_filter_list); in iavf_probe()
5141 INIT_LIST_HEAD(&adapter->fdir_list_head); in iavf_probe()
5142 INIT_LIST_HEAD(&adapter->adv_rss_list_head); in iavf_probe()
5144 INIT_WORK(&adapter->reset_task, iavf_reset_task); in iavf_probe()
5145 INIT_WORK(&adapter->adminq_task, iavf_adminq_task); in iavf_probe()
5146 INIT_WORK(&adapter->finish_config, iavf_finish_config); in iavf_probe()
5147 INIT_DELAYED_WORK(&adapter->watchdog_task, iavf_watchdog_task); in iavf_probe()
5150 init_waitqueue_head(&adapter->down_waitqueue); in iavf_probe()
5153 init_waitqueue_head(&adapter->reset_waitqueue); in iavf_probe()
5156 init_waitqueue_head(&adapter->vc_waitqueue); in iavf_probe()
5158 queue_delayed_work(adapter->wq, &adapter->watchdog_task, in iavf_probe()
5164 destroy_workqueue(adapter->wq); in iavf_probe()
5184 struct iavf_adapter *adapter = netdev_priv(netdev); in iavf_suspend() local
5188 mutex_lock(&adapter->crit_lock); in iavf_suspend()
5192 iavf_down(adapter); in iavf_suspend()
5195 iavf_free_misc_irq(adapter); in iavf_suspend()
5196 iavf_reset_interrupt_capability(adapter); in iavf_suspend()
5198 mutex_unlock(&adapter->crit_lock); in iavf_suspend()
5212 struct iavf_adapter *adapter; in iavf_resume() local
5215 adapter = iavf_pdev_to_adapter(pdev); in iavf_resume()
5220 err = iavf_set_interrupt_capability(adapter); in iavf_resume()
5226 err = iavf_request_misc_irq(adapter); in iavf_resume()
5233 queue_work(adapter->wq, &adapter->reset_task); in iavf_resume()
5235 netif_device_attach(adapter->netdev); in iavf_resume()
5256 struct iavf_adapter *adapter; in iavf_remove() local
5265 adapter = iavf_pdev_to_adapter(pdev); in iavf_remove()
5266 hw = &adapter->hw; in iavf_remove()
5268 if (test_and_set_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) in iavf_remove()
5275 mutex_lock(&adapter->crit_lock); in iavf_remove()
5276 if (adapter->state == __IAVF_RUNNING || in iavf_remove()
5277 adapter->state == __IAVF_DOWN || in iavf_remove()
5278 adapter->state == __IAVF_INIT_FAILED) { in iavf_remove()
5279 mutex_unlock(&adapter->crit_lock); in iavf_remove()
5283 if (adapter->state == __IAVF_REMOVE) { in iavf_remove()
5284 mutex_unlock(&adapter->crit_lock); in iavf_remove()
5288 mutex_unlock(&adapter->crit_lock); in iavf_remove()
5291 cancel_delayed_work_sync(&adapter->watchdog_task); in iavf_remove()
5292 cancel_work_sync(&adapter->finish_config); in iavf_remove()
5297 mutex_lock(&adapter->crit_lock); in iavf_remove()
5298 dev_info(&adapter->pdev->dev, "Removing device\n"); in iavf_remove()
5299 iavf_change_state(adapter, __IAVF_REMOVE); in iavf_remove()
5301 iavf_request_reset(adapter); in iavf_remove()
5305 iavf_request_reset(adapter); in iavf_remove()
5309 iavf_misc_irq_disable(adapter); in iavf_remove()
5311 cancel_work_sync(&adapter->reset_task); in iavf_remove()
5312 cancel_delayed_work_sync(&adapter->watchdog_task); in iavf_remove()
5313 cancel_work_sync(&adapter->adminq_task); in iavf_remove()
5315 adapter->aq_required = 0; in iavf_remove()
5316 adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED; in iavf_remove()
5318 iavf_free_all_tx_resources(adapter); in iavf_remove()
5319 iavf_free_all_rx_resources(adapter); in iavf_remove()
5320 iavf_free_misc_irq(adapter); in iavf_remove()
5321 iavf_free_interrupt_scheme(adapter); in iavf_remove()
5323 iavf_free_rss(adapter); in iavf_remove()
5331 mutex_unlock(&adapter->crit_lock); in iavf_remove()
5332 mutex_destroy(&adapter->crit_lock); in iavf_remove()
5336 kfree(adapter->vf_res); in iavf_remove()
5337 spin_lock_bh(&adapter->mac_vlan_list_lock); in iavf_remove()
5341 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { in iavf_remove()
5345 list_for_each_entry_safe(vlf, vlftmp, &adapter->vlan_filter_list, in iavf_remove()
5351 spin_unlock_bh(&adapter->mac_vlan_list_lock); in iavf_remove()
5353 spin_lock_bh(&adapter->cloud_filter_list_lock); in iavf_remove()
5354 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, list) { in iavf_remove()
5358 spin_unlock_bh(&adapter->cloud_filter_list_lock); in iavf_remove()
5360 spin_lock_bh(&adapter->fdir_fltr_lock); in iavf_remove()
5361 list_for_each_entry_safe(fdir, fdirtmp, &adapter->fdir_list_head, list) { in iavf_remove()
5365 spin_unlock_bh(&adapter->fdir_fltr_lock); in iavf_remove()
5367 spin_lock_bh(&adapter->adv_rss_lock); in iavf_remove()
5368 list_for_each_entry_safe(rss, rsstmp, &adapter->adv_rss_list_head, in iavf_remove()
5373 spin_unlock_bh(&adapter->adv_rss_lock); in iavf_remove()
5375 destroy_workqueue(adapter->wq); in iavf_remove()