Lines Matching full:pf

36 static void i40e_handle_reset_warning(struct i40e_pf *pf, bool lock_acquired);
39 static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired);
40 static int i40e_setup_misc_vector(struct i40e_pf *pf);
41 static void i40e_determine_queue_usage(struct i40e_pf *pf);
42 static int i40e_setup_pf_filter_control(struct i40e_pf *pf);
43 static void i40e_prep_for_reset(struct i40e_pf *pf);
44 static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit,
46 static int i40e_reset(struct i40e_pf *pf);
47 static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired);
48 static int i40e_setup_misc_vector_for_recovery_mode(struct i40e_pf *pf);
49 static int i40e_restore_interrupt_scheme(struct i40e_pf *pf);
50 static bool i40e_check_recovery_mode(struct i40e_pf *pf);
51 static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw);
52 static void i40e_fdir_sb_setup(struct i40e_pf *pf);
54 static int i40e_get_capabilities(struct i40e_pf *pf,
56 static bool i40e_is_total_port_shutdown_enabled(struct i40e_pf *pf);
139 struct i40e_pf *pf = i40e_hw_to_pf(hw); in i40e_hw_to_dev() local
141 return &pf->pdev->dev; in i40e_hw_to_dev()
154 struct i40e_pf *pf = i40e_hw_to_pf(hw); in i40e_allocate_dma_mem() local
157 mem->va = dma_alloc_coherent(&pf->pdev->dev, mem->size, &mem->pa, in i40e_allocate_dma_mem()
172 struct i40e_pf *pf = i40e_hw_to_pf(hw); in i40e_free_dma_mem() local
174 dma_free_coherent(&pf->pdev->dev, mem->size, mem->va, mem->pa); in i40e_free_dma_mem()
217 * @pf: board private structure
224 static int i40e_get_lump(struct i40e_pf *pf, struct i40e_lump_tracking *pile, in i40e_get_lump() argument
231 dev_info(&pf->pdev->dev, in i40e_get_lump()
240 if (pile == pf->qp_pile && pf->vsi[id]->type == I40E_VSI_FDIR) { in i40e_get_lump()
242 dev_err(&pf->pdev->dev, in i40e_get_lump()
310 * @pf: the pf structure to search for the vsi
313 struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id) in i40e_find_vsi_from_id() argument
318 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_find_vsi_from_id()
327 * @pf: board private structure
331 void i40e_service_event_schedule(struct i40e_pf *pf) in i40e_service_event_schedule() argument
333 if ((!test_bit(__I40E_DOWN, pf->state) && in i40e_service_event_schedule()
334 !test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) || in i40e_service_event_schedule()
335 test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_service_event_schedule()
336 queue_work(i40e_wq, &pf->service_task); in i40e_service_event_schedule()
352 struct i40e_pf *pf = vsi->back; in i40e_tx_timeout() local
357 pf->tx_timeout_count++; in i40e_tx_timeout()
370 if (time_after(jiffies, (pf->tx_timeout_last_recovery + HZ*20))) in i40e_tx_timeout()
371 pf->tx_timeout_recovery_level = 1; /* reset after some time */ in i40e_tx_timeout()
373 (pf->tx_timeout_last_recovery + netdev->watchdog_timeo))) in i40e_tx_timeout()
377 if (test_and_set_bit(__I40E_TIMEOUT_RECOVERY_PENDING, pf->state)) in i40e_tx_timeout()
383 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_tx_timeout()
384 val = rd32(&pf->hw, in i40e_tx_timeout()
388 val = rd32(&pf->hw, I40E_PFINT_DYN_CTL0); in i40e_tx_timeout()
396 pf->tx_timeout_last_recovery = jiffies; in i40e_tx_timeout()
398 pf->tx_timeout_recovery_level, txqueue); in i40e_tx_timeout()
400 switch (pf->tx_timeout_recovery_level) { in i40e_tx_timeout()
402 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_tx_timeout()
405 set_bit(__I40E_CORE_RESET_REQUESTED, pf->state); in i40e_tx_timeout()
408 set_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state); in i40e_tx_timeout()
412 set_bit(__I40E_DOWN_REQUESTED, pf->state); in i40e_tx_timeout()
417 i40e_service_event_schedule(pf); in i40e_tx_timeout()
418 pf->tx_timeout_recovery_level++; in i40e_tx_timeout()
553 * i40e_pf_reset_stats - Reset all of the stats for the given PF
554 * @pf: the PF to be reset
556 void i40e_pf_reset_stats(struct i40e_pf *pf) in i40e_pf_reset_stats() argument
561 memset(&pf->stats, 0, sizeof(pf->stats)); in i40e_pf_reset_stats()
562 memset(&pf->stats_offsets, 0, sizeof(pf->stats_offsets)); in i40e_pf_reset_stats()
563 pf->stat_offsets_loaded = false; in i40e_pf_reset_stats()
565 i40e_pf_for_each_veb(pf, i, veb) { in i40e_pf_reset_stats()
572 pf->hw_csum_rx_error = 0; in i40e_pf_reset_stats()
718 struct i40e_pf *pf = vsi->back; in i40e_update_eth_stats() local
719 struct i40e_hw *hw = &pf->hw; in i40e_update_eth_stats()
780 struct i40e_pf *pf = veb->pf; in i40e_update_veb_stats() local
781 struct i40e_hw *hw = &pf->hw; in i40e_update_veb_stats()
866 struct i40e_pf *pf = vsi->back; in i40e_update_vsi_stats() local
883 test_bit(__I40E_CONFIG_BUSY, pf->state)) in i40e_update_vsi_stats()
993 /* pull in a couple PF stats if this is the main vsi */ in i40e_update_vsi_stats()
995 ns->rx_crc_errors = pf->stats.crc_errors; in i40e_update_vsi_stats()
996 ns->rx_errors = pf->stats.crc_errors + pf->stats.illegal_bytes; in i40e_update_vsi_stats()
997 ns->rx_length_errors = pf->stats.rx_length_errors; in i40e_update_vsi_stats()
1002 * i40e_update_pf_stats - Update the PF statistics counters.
1003 * @pf: the PF to be updated
1005 static void i40e_update_pf_stats(struct i40e_pf *pf) in i40e_update_pf_stats() argument
1007 struct i40e_hw_port_stats *osd = &pf->stats_offsets; in i40e_update_pf_stats()
1008 struct i40e_hw_port_stats *nsd = &pf->stats; in i40e_update_pf_stats()
1009 struct i40e_hw *hw = &pf->hw; in i40e_update_pf_stats()
1015 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1019 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1022 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1027 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1032 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1037 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1042 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1047 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1052 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1057 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1062 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1066 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1070 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1074 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1079 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1084 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1087 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1090 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1093 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1098 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1102 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1106 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1110 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1115 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1122 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1126 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1130 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1134 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1138 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1142 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1146 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1151 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1155 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1159 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1163 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1167 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1171 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1175 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1179 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1182 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1185 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1188 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1208 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1211 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1214 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) && in i40e_update_pf_stats()
1215 !test_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state)) in i40e_update_pf_stats()
1220 if (test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags) && in i40e_update_pf_stats()
1221 !test_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state)) in i40e_update_pf_stats()
1226 pf->stat_offsets_loaded = true; in i40e_update_pf_stats()
1237 struct i40e_pf *pf = vsi->back; in i40e_update_stats() local
1240 i40e_update_pf_stats(pf); in i40e_update_stats()
1504 struct i40e_pf *pf = vsi->back; in i40e_get_vf_new_vlan() local
1514 !test_bit(I40E_FLAG_VF_VLAN_PRUNING_ENA, pf->flags)); in i40e_get_vf_new_vlan()
1595 * @vsi: the PF Main VSI - inappropriate for any other VSI
1604 struct i40e_pf *pf = vsi->back; in i40e_rm_default_mac_filter() local
1606 /* Only appropriate for the PF main VSI */ in i40e_rm_default_mac_filter()
1615 i40e_aq_remove_macvlan(&pf->hw, vsi->seid, &element, 1, NULL); in i40e_rm_default_mac_filter()
1623 i40e_aq_remove_macvlan(&pf->hw, vsi->seid, &element, 1, NULL); in i40e_rm_default_mac_filter()
1799 struct i40e_pf *pf = vsi->back; in i40e_set_mac() local
1800 struct i40e_hw *hw = &pf->hw; in i40e_set_mac()
1806 if (test_bit(__I40E_DOWN, pf->state) || in i40e_set_mac()
1807 test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_set_mac()
1842 i40e_service_event_schedule(pf); in i40e_set_mac()
1856 struct i40e_pf *pf = vsi->back; in i40e_config_rss_aq() local
1857 struct i40e_hw *hw = &pf->hw; in i40e_config_rss_aq()
1865 dev_info(&pf->pdev->dev, in i40e_config_rss_aq()
1877 dev_info(&pf->pdev->dev, in i40e_config_rss_aq()
1893 struct i40e_pf *pf = vsi->back; in i40e_vsi_config_rss() local
1898 if (!test_bit(I40E_HW_CAP_RSS_AQ, pf->hw.caps)) in i40e_vsi_config_rss()
1901 vsi->rss_size = min_t(int, pf->alloc_rss_size, in i40e_vsi_config_rss()
1915 i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, vsi->rss_size); in i40e_vsi_config_rss()
2026 struct i40e_pf *pf = vsi->back; in i40e_vsi_setup_queue_map() local
2053 else if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_vsi_setup_queue_map()
2054 vsi->num_queue_pairs = pf->num_lan_msix; in i40e_vsi_setup_queue_map()
2073 dev_warn(&pf->pdev->dev, "DCB is enabled but no TC enabled, forcing TC0\n"); in i40e_vsi_setup_queue_map()
2078 i40e_pf_get_max_q_per_tc(pf)); in i40e_vsi_setup_queue_map()
2085 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_vsi_setup_queue_map()
2086 num_tc_qps = min_t(int, num_tc_qps, pf->num_lan_msix); in i40e_vsi_setup_queue_map()
2098 pf->flags) && in i40e_vsi_setup_queue_map()
2100 pf->flags)) || in i40e_vsi_setup_queue_map()
2102 qcount = min_t(int, pf->alloc_rss_size, in i40e_vsi_setup_queue_map()
2468 * @pf: board private structure
2471 * There are different ways of setting promiscuous mode on a PF depending on
2475 static int i40e_set_promiscuous(struct i40e_pf *pf, bool promisc) in i40e_set_promiscuous() argument
2477 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_set_promiscuous()
2478 struct i40e_hw *hw = &pf->hw; in i40e_set_promiscuous()
2482 i40e_pf_get_main_veb(pf) && in i40e_set_promiscuous()
2483 !test_bit(I40E_FLAG_MFP_ENA, pf->flags)) { in i40e_set_promiscuous()
2498 dev_info(&pf->pdev->dev, in i40e_set_promiscuous()
2510 dev_info(&pf->pdev->dev, in i40e_set_promiscuous()
2520 dev_info(&pf->pdev->dev, in i40e_set_promiscuous()
2528 pf->cur_promisc = promisc; in i40e_set_promiscuous()
2550 char vsi_name[16] = "PF"; in i40e_sync_vsi_filters()
2554 struct i40e_pf *pf; in i40e_sync_vsi_filters() local
2569 pf = vsi->back; in i40e_sync_vsi_filters()
2627 else if (pf->vf) in i40e_sync_vsi_filters()
2630 vlan_filters, pf->vf[vsi->vf_id].trusted); in i40e_sync_vsi_filters()
2793 dev_info(&pf->pdev->dev, in i40e_sync_vsi_filters()
2801 if (vsi->type == I40E_VSI_SRIOV && pf->vf && in i40e_sync_vsi_filters()
2802 !pf->vf[vsi->vf_id].trusted) { in i40e_sync_vsi_filters()
2827 dev_info(&pf->pdev->dev, in i40e_sync_vsi_filters()
2833 dev_info(&pf->pdev->dev, "%s allmulti mode.\n", in i40e_sync_vsi_filters()
2843 aq_ret = i40e_set_promiscuous(pf, cur_promisc); in i40e_sync_vsi_filters()
2847 dev_info(&pf->pdev->dev, in i40e_sync_vsi_filters()
2878 * @pf: board private structure
2880 static void i40e_sync_filters_subtask(struct i40e_pf *pf) in i40e_sync_filters_subtask() argument
2885 if (!pf) in i40e_sync_filters_subtask()
2887 if (!test_and_clear_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state)) in i40e_sync_filters_subtask()
2889 if (test_bit(__I40E_VF_DISABLE, pf->state)) { in i40e_sync_filters_subtask()
2890 set_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state); in i40e_sync_filters_subtask()
2894 i40e_pf_for_each_vsi(pf, v, vsi) { in i40e_sync_filters_subtask()
2902 pf->state); in i40e_sync_filters_subtask()
2952 struct i40e_pf *pf = vsi->back; in i40e_change_mtu() local
2967 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_change_mtu()
2968 set_bit(__I40E_CLIENT_L2_CHANGE, pf->state); in i40e_change_mtu()
3799 * @pf: Pointer to the targeted PF
3803 static void i40e_reset_fdir_filter_cnt(struct i40e_pf *pf) in i40e_reset_fdir_filter_cnt() argument
3805 pf->fd_tcp4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3806 pf->fd_udp4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3807 pf->fd_sctp4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3808 pf->fd_ip4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3809 pf->fd_tcp6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3810 pf->fd_udp6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3811 pf->fd_sctp6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3812 pf->fd_ip6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3825 struct i40e_pf *pf = vsi->back; in i40e_fdir_filter_restore() local
3828 if (!test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) in i40e_fdir_filter_restore()
3832 i40e_reset_fdir_filter_cnt(pf); in i40e_fdir_filter_restore()
3835 &pf->fdir_filter_list, fdir_node) { in i40e_fdir_filter_restore()
3865 struct i40e_pf *pf = vsi->back; in i40e_vsi_configure_msix() local
3866 struct i40e_hw *hw = &pf->hw; in i40e_vsi_configure_msix()
3952 * @pf: pointer to private device data structure
3954 static void i40e_enable_misc_int_causes(struct i40e_pf *pf) in i40e_enable_misc_int_causes() argument
3956 struct i40e_hw *hw = &pf->hw; in i40e_enable_misc_int_causes()
3972 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) in i40e_enable_misc_int_causes()
3975 if (test_bit(I40E_FLAG_PTP_ENA, pf->flags)) in i40e_enable_misc_int_causes()
3996 struct i40e_pf *pf = vsi->back; in i40e_configure_msi_and_legacy() local
3997 struct i40e_hw *hw = &pf->hw; in i40e_configure_msi_and_legacy()
4009 i40e_enable_misc_int_causes(pf); in i40e_configure_msi_and_legacy()
4033 * @pf: board private structure
4035 void i40e_irq_dynamic_disable_icr0(struct i40e_pf *pf) in i40e_irq_dynamic_disable_icr0() argument
4037 struct i40e_hw *hw = &pf->hw; in i40e_irq_dynamic_disable_icr0()
4046 * @pf: board private structure
4048 void i40e_irq_dynamic_enable_icr0(struct i40e_pf *pf) in i40e_irq_dynamic_enable_icr0() argument
4050 struct i40e_hw *hw = &pf->hw; in i40e_irq_dynamic_enable_icr0()
4115 struct i40e_pf *pf = vsi->back; in i40e_vsi_request_irq_msix() local
4126 irq_num = pf->msix_entries[base + vector].vector; in i40e_vsi_request_irq_msix()
4148 dev_info(&pf->pdev->dev, in i40e_vsi_request_irq_msix()
4174 irq_num = pf->msix_entries[base + vector].vector; in i40e_vsi_request_irq_msix()
4188 struct i40e_pf *pf = vsi->back; in i40e_vsi_disable_irq() local
4189 struct i40e_hw *hw = &pf->hw; in i40e_vsi_disable_irq()
4211 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_vsi_disable_irq()
4218 synchronize_irq(pf->msix_entries[i + base].vector); in i40e_vsi_disable_irq()
4224 synchronize_irq(pf->pdev->irq); in i40e_vsi_disable_irq()
4234 struct i40e_pf *pf = vsi->back; in i40e_vsi_enable_irq() local
4237 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_vsi_enable_irq()
4241 i40e_irq_dynamic_enable_icr0(pf); in i40e_vsi_enable_irq()
4244 i40e_flush(&pf->hw); in i40e_vsi_enable_irq()
4250 * @pf: board private structure
4252 static void i40e_free_misc_vector(struct i40e_pf *pf) in i40e_free_misc_vector() argument
4255 wr32(&pf->hw, I40E_PFINT_ICR0_ENA, 0); in i40e_free_misc_vector()
4256 i40e_flush(&pf->hw); in i40e_free_misc_vector()
4258 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags) && pf->msix_entries) { in i40e_free_misc_vector()
4259 free_irq(pf->msix_entries[0].vector, pf); in i40e_free_misc_vector()
4260 clear_bit(__I40E_MISC_IRQ_REQUESTED, pf->state); in i40e_free_misc_vector()
4275 struct i40e_pf *pf = (struct i40e_pf *)data; in i40e_intr() local
4276 struct i40e_hw *hw = &pf->hw; in i40e_intr()
4291 pf->sw_int_count++; in i40e_intr()
4293 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags) && in i40e_intr()
4296 dev_dbg(&pf->pdev->dev, "cleared PE_CRITERR\n"); in i40e_intr()
4297 set_bit(__I40E_CORE_RESET_REQUESTED, pf->state); in i40e_intr()
4302 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_intr()
4311 if (!test_bit(__I40E_DOWN, pf->state)) in i40e_intr()
4317 set_bit(__I40E_ADMINQ_EVENT_PENDING, pf->state); in i40e_intr()
4318 i40e_debug(&pf->hw, I40E_DEBUG_NVM, "AdminQ event\n"); in i40e_intr()
4323 set_bit(__I40E_MDD_EVENT_PENDING, pf->state); in i40e_intr()
4328 if (test_bit(__I40E_VF_RESETS_DISABLED, pf->state)) { in i40e_intr()
4335 set_bit(__I40E_VFLR_EVENT_PENDING, pf->state); in i40e_intr()
4340 if (!test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_intr()
4341 set_bit(__I40E_RESET_INTR_RECEIVED, pf->state); in i40e_intr()
4346 pf->corer_count++; in i40e_intr()
4348 pf->globr_count++; in i40e_intr()
4350 pf->empr_count++; in i40e_intr()
4351 set_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state); in i40e_intr()
4357 dev_info(&pf->pdev->dev, "HMC error interrupt\n"); in i40e_intr()
4358 dev_info(&pf->pdev->dev, "HMC error info 0x%x, HMC error data 0x%x\n", in i40e_intr()
4367 schedule_work(&pf->ptp_extts0_work); in i40e_intr()
4370 i40e_ptp_tx_hwtstamp(pf); in i40e_intr()
4381 dev_info(&pf->pdev->dev, "unhandled interrupt icr0=0x%08x\n", in i40e_intr()
4386 dev_info(&pf->pdev->dev, "device will be reset\n"); in i40e_intr()
4387 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_intr()
4388 i40e_service_event_schedule(pf); in i40e_intr()
4397 if (!test_bit(__I40E_DOWN, pf->state) || in i40e_intr()
4398 test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_intr()
4399 i40e_service_event_schedule(pf); in i40e_intr()
4400 i40e_irq_dynamic_enable_icr0(pf); in i40e_intr()
4595 struct i40e_pf *pf = vsi->back; in i40e_vsi_request_irq() local
4598 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_vsi_request_irq()
4600 else if (test_bit(I40E_FLAG_MSI_ENA, pf->flags)) in i40e_vsi_request_irq()
4601 err = request_irq(pf->pdev->irq, i40e_intr, 0, in i40e_vsi_request_irq()
4602 pf->int_name, pf); in i40e_vsi_request_irq()
4604 err = request_irq(pf->pdev->irq, i40e_intr, IRQF_SHARED, in i40e_vsi_request_irq()
4605 pf->int_name, pf); in i40e_vsi_request_irq()
4608 dev_info(&pf->pdev->dev, "request_irq failed, Error %d\n", err); in i40e_vsi_request_irq()
4625 struct i40e_pf *pf = vsi->back; in i40e_netpoll() local
4632 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_netpoll()
4636 i40e_intr(pf->pdev->irq, netdev); in i40e_netpoll()
4644 * i40e_pf_txq_wait - Wait for a PF's Tx queue to be enabled or disabled
4645 * @pf: the PF being configured
4646 * @pf_q: the PF queue
4649 * This routine will wait for the given Tx queue of the PF to reach the
4654 static int i40e_pf_txq_wait(struct i40e_pf *pf, int pf_q, bool enable) in i40e_pf_txq_wait() argument
4660 tx_reg = rd32(&pf->hw, I40E_QTX_ENA(pf_q)); in i40e_pf_txq_wait()
4674 * @pf: the PF structure
4675 * @pf_q: the PF queue to configure
4682 static void i40e_control_tx_q(struct i40e_pf *pf, int pf_q, bool enable) in i40e_control_tx_q() argument
4684 struct i40e_hw *hw = &pf->hw; in i40e_control_tx_q()
4689 i40e_pre_tx_queue_cfg(&pf->hw, pf_q, enable); in i40e_control_tx_q()
4719 * @pf: the PF structure
4720 * @pf_q: the PF queue to configure
4724 int i40e_control_wait_tx_q(int seid, struct i40e_pf *pf, int pf_q, in i40e_control_wait_tx_q() argument
4729 i40e_control_tx_q(pf, pf_q, enable); in i40e_control_wait_tx_q()
4732 ret = i40e_pf_txq_wait(pf, pf_q, enable); in i40e_control_wait_tx_q()
4734 dev_info(&pf->pdev->dev, in i40e_control_wait_tx_q()
4749 struct i40e_pf *pf = vsi->back; in i40e_vsi_enable_tx() local
4754 ret = i40e_control_wait_tx_q(vsi->seid, pf, in i40e_vsi_enable_tx()
4763 ret = i40e_control_wait_tx_q(vsi->seid, pf, in i40e_vsi_enable_tx()
4773 * i40e_pf_rxq_wait - Wait for a PF's Rx queue to be enabled or disabled
4774 * @pf: the PF being configured
4775 * @pf_q: the PF queue
4778 * This routine will wait for the given Rx queue of the PF to reach the
4783 static int i40e_pf_rxq_wait(struct i40e_pf *pf, int pf_q, bool enable) in i40e_pf_rxq_wait() argument
4789 rx_reg = rd32(&pf->hw, I40E_QRX_ENA(pf_q)); in i40e_pf_rxq_wait()
4803 * @pf: the PF structure
4804 * @pf_q: the PF queue to configure
4811 static void i40e_control_rx_q(struct i40e_pf *pf, int pf_q, bool enable) in i40e_control_rx_q() argument
4813 struct i40e_hw *hw = &pf->hw; in i40e_control_rx_q()
4840 * @pf: the PF structure
4848 int i40e_control_wait_rx_q(struct i40e_pf *pf, int pf_q, bool enable) in i40e_control_wait_rx_q() argument
4852 i40e_control_rx_q(pf, pf_q, enable); in i40e_control_wait_rx_q()
4855 ret = i40e_pf_rxq_wait(pf, pf_q, enable); in i40e_control_wait_rx_q()
4868 struct i40e_pf *pf = vsi->back; in i40e_vsi_enable_rx() local
4873 ret = i40e_control_wait_rx_q(pf, pf_q, true); in i40e_vsi_enable_rx()
4875 dev_info(&pf->pdev->dev, in i40e_vsi_enable_rx()
4910 struct i40e_pf *pf = vsi->back; in i40e_vsi_stop_rings() local
4920 i40e_pre_tx_queue_cfg(&pf->hw, pf_q, false); in i40e_vsi_stop_rings()
4924 i40e_control_rx_q(pf, pf_q, false); in i40e_vsi_stop_rings()
4928 wr32(&pf->hw, I40E_QTX_ENA(pf_q), 0); in i40e_vsi_stop_rings()
4946 struct i40e_pf *pf = vsi->back; in i40e_vsi_stop_rings_no_wait() local
4951 i40e_control_tx_q(pf, pf_q, false); in i40e_vsi_stop_rings_no_wait()
4952 i40e_control_rx_q(pf, pf_q, false); in i40e_vsi_stop_rings_no_wait()
4962 struct i40e_pf *pf = vsi->back; in i40e_vsi_free_irq() local
4963 struct i40e_hw *hw = &pf->hw; in i40e_vsi_free_irq()
4968 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_vsi_free_irq()
4981 irq_num = pf->msix_entries[vector].vector; in i40e_vsi_free_irq()
5041 free_irq(pf->pdev->irq, pf); in i40e_vsi_free_irq()
5124 * @pf: board private structure
5126 static void i40e_reset_interrupt_capability(struct i40e_pf *pf) in i40e_reset_interrupt_capability() argument
5129 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_reset_interrupt_capability()
5130 pci_disable_msix(pf->pdev); in i40e_reset_interrupt_capability()
5131 kfree(pf->msix_entries); in i40e_reset_interrupt_capability()
5132 pf->msix_entries = NULL; in i40e_reset_interrupt_capability()
5133 kfree(pf->irq_pile); in i40e_reset_interrupt_capability()
5134 pf->irq_pile = NULL; in i40e_reset_interrupt_capability()
5135 } else if (test_bit(I40E_FLAG_MSI_ENA, pf->flags)) { in i40e_reset_interrupt_capability()
5136 pci_disable_msi(pf->pdev); in i40e_reset_interrupt_capability()
5138 clear_bit(I40E_FLAG_MSI_ENA, pf->flags); in i40e_reset_interrupt_capability()
5139 clear_bit(I40E_FLAG_MSIX_ENA, pf->flags); in i40e_reset_interrupt_capability()
5144 * @pf: board private structure
5149 static void i40e_clear_interrupt_scheme(struct i40e_pf *pf) in i40e_clear_interrupt_scheme() argument
5154 if (test_bit(__I40E_MISC_IRQ_REQUESTED, pf->state)) in i40e_clear_interrupt_scheme()
5155 i40e_free_misc_vector(pf); in i40e_clear_interrupt_scheme()
5157 i40e_put_lump(pf->irq_pile, pf->iwarp_base_vector, in i40e_clear_interrupt_scheme()
5160 i40e_put_lump(pf->irq_pile, 0, I40E_PILE_VALID_BIT-1); in i40e_clear_interrupt_scheme()
5162 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_clear_interrupt_scheme()
5165 i40e_reset_interrupt_capability(pf); in i40e_clear_interrupt_scheme()
5212 struct i40e_pf *pf = vsi->back; in i40e_vsi_close() local
5219 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_vsi_close()
5220 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_vsi_close()
5221 set_bit(__I40E_CLIENT_RESET, pf->state); in i40e_vsi_close()
5256 * i40e_pf_quiesce_all_vsi - Pause all VSIs on a PF
5257 * @pf: the PF
5259 static void i40e_pf_quiesce_all_vsi(struct i40e_pf *pf) in i40e_pf_quiesce_all_vsi() argument
5264 i40e_pf_for_each_vsi(pf, v, vsi) in i40e_pf_quiesce_all_vsi()
5269 * i40e_pf_unquiesce_all_vsi - Resume all VSIs on a PF
5270 * @pf: the PF
5272 static void i40e_pf_unquiesce_all_vsi(struct i40e_pf *pf) in i40e_pf_unquiesce_all_vsi() argument
5277 i40e_pf_for_each_vsi(pf, v, vsi) in i40e_pf_unquiesce_all_vsi()
5289 struct i40e_pf *pf = vsi->back; in i40e_vsi_wait_queues_disabled() local
5295 ret = i40e_pf_txq_wait(pf, pf_q, false); in i40e_vsi_wait_queues_disabled()
5297 dev_info(&pf->pdev->dev, in i40e_vsi_wait_queues_disabled()
5307 ret = i40e_pf_txq_wait(pf, pf_q + vsi->alloc_queue_pairs, in i40e_vsi_wait_queues_disabled()
5310 dev_info(&pf->pdev->dev, in i40e_vsi_wait_queues_disabled()
5317 ret = i40e_pf_rxq_wait(pf, pf_q, false); in i40e_vsi_wait_queues_disabled()
5319 dev_info(&pf->pdev->dev, in i40e_vsi_wait_queues_disabled()
5331 * i40e_pf_wait_queues_disabled - Wait for all queues of PF VSIs to be disabled
5332 * @pf: the PF
5335 * VSIs that are managed by this PF.
5337 static int i40e_pf_wait_queues_disabled(struct i40e_pf *pf) in i40e_pf_wait_queues_disabled() argument
5342 i40e_pf_for_each_vsi(pf, v, vsi) { in i40e_pf_wait_queues_disabled()
5355 * @pf: pointer to PF
5357 * Get TC map for ISCSI PF type that will include iSCSI TC
5360 static u8 i40e_get_iscsi_tc_map(struct i40e_pf *pf) in i40e_get_iscsi_tc_map() argument
5363 struct i40e_hw *hw = &pf->hw; in i40e_get_iscsi_tc_map()
5445 * @pf: PF being queried
5450 static u8 i40e_mqprio_get_enabled_tc(struct i40e_pf *pf) in i40e_mqprio_get_enabled_tc() argument
5452 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_mqprio_get_enabled_tc()
5462 * i40e_pf_get_num_tc - Get enabled traffic classes for PF
5463 * @pf: PF being queried
5465 * Return number of traffic classes enabled for the given PF
5467 static u8 i40e_pf_get_num_tc(struct i40e_pf *pf) in i40e_pf_get_num_tc() argument
5472 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_pf_get_num_tc()
5473 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_pf_get_num_tc()
5479 if (!test_bit(I40E_FLAG_DCB_ENA, pf->flags)) in i40e_pf_get_num_tc()
5483 if (!test_bit(I40E_FLAG_MFP_ENA, pf->flags)) in i40e_pf_get_num_tc()
5484 return i40e_dcb_get_num_tc(&pf->hw.local_dcbx_config); in i40e_pf_get_num_tc()
5486 /* MFP mode return count of enabled TCs for this PF */ in i40e_pf_get_num_tc()
5487 if (pf->hw.func_caps.iscsi) in i40e_pf_get_num_tc()
5488 enabled_tc = i40e_get_iscsi_tc_map(pf); in i40e_pf_get_num_tc()
5501 * @pf: PF being queried
5503 * Return a bitmap for enabled traffic classes for this PF.
5505 static u8 i40e_pf_get_tc_map(struct i40e_pf *pf) in i40e_pf_get_tc_map() argument
5507 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_pf_get_tc_map()
5508 return i40e_mqprio_get_enabled_tc(pf); in i40e_pf_get_tc_map()
5510 /* If neither MQPRIO nor DCB is enabled for this PF then just return in i40e_pf_get_tc_map()
5513 if (!test_bit(I40E_FLAG_DCB_ENA, pf->flags)) in i40e_pf_get_tc_map()
5516 /* SFP mode we want PF to be enabled for all TCs */ in i40e_pf_get_tc_map()
5517 if (!test_bit(I40E_FLAG_MFP_ENA, pf->flags)) in i40e_pf_get_tc_map()
5518 return i40e_dcb_get_enabled_tc(&pf->hw.local_dcbx_config); in i40e_pf_get_tc_map()
5520 /* MFP enabled and iSCSI PF type */ in i40e_pf_get_tc_map()
5521 if (pf->hw.func_caps.iscsi) in i40e_pf_get_tc_map()
5522 return i40e_get_iscsi_tc_map(pf); in i40e_pf_get_tc_map()
5537 struct i40e_pf *pf = vsi->back; in i40e_vsi_get_bw_info() local
5538 struct i40e_hw *hw = &pf->hw; in i40e_vsi_get_bw_info()
5546 dev_info(&pf->pdev->dev, in i40e_vsi_get_bw_info()
5547 "couldn't get PF vsi bw config, err %pe aq_err %s\n", in i40e_vsi_get_bw_info()
5549 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_vsi_get_bw_info()
5557 dev_info(&pf->pdev->dev, in i40e_vsi_get_bw_info()
5558 "couldn't get PF vsi ets bw config, err %pe aq_err %s\n", in i40e_vsi_get_bw_info()
5560 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_vsi_get_bw_info()
5565 dev_info(&pf->pdev->dev, in i40e_vsi_get_bw_info()
5599 struct i40e_pf *pf = vsi->back; in i40e_vsi_configure_bw_alloc() local
5604 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_vsi_configure_bw_alloc()
5606 if (!vsi->mqprio_qopt.qopt.hw && !test_bit(I40E_FLAG_DCB_ENA, pf->flags)) { in i40e_vsi_configure_bw_alloc()
5609 dev_info(&pf->pdev->dev, in i40e_vsi_configure_bw_alloc()
5619 ret = i40e_aq_config_vsi_tc_bw(&pf->hw, vsi->seid, &bw_data, NULL); in i40e_vsi_configure_bw_alloc()
5621 dev_info(&pf->pdev->dev, in i40e_vsi_configure_bw_alloc()
5623 pf->hw.aq.asq_last_status); in i40e_vsi_configure_bw_alloc()
5642 struct i40e_pf *pf = vsi->back; in i40e_vsi_config_netdev_tc() local
5643 struct i40e_hw *hw = &pf->hw; in i40e_vsi_config_netdev_tc()
5676 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_vsi_config_netdev_tc()
5716 struct i40e_pf *pf; in i40e_update_adq_vsi_queues() local
5722 pf = vsi->back; in i40e_update_adq_vsi_queues()
5723 hw = &pf->hw; in i40e_update_adq_vsi_queues()
5736 vsi->rss_size = min_t(int, pf->alloc_rss_size, in i40e_update_adq_vsi_queues()
5740 dev_info(&pf->pdev->dev, "Failed to reconfig rss for num_queues\n"); in i40e_update_adq_vsi_queues()
5748 dev_info(&pf->pdev->dev, "Update vsi config failed, err %pe aq_err %s\n", in i40e_update_adq_vsi_queues()
5776 struct i40e_pf *pf = vsi->back; in i40e_vsi_config_tc() local
5777 struct i40e_hw *hw = &pf->hw; in i40e_vsi_config_tc()
5797 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5803 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5816 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5824 dev_err(&pf->pdev->dev, in i40e_vsi_config_tc()
5837 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_vsi_config_tc()
5870 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5883 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5925 struct i40e_pf *pf = vsi->back; in i40e_get_link_speed() local
5927 switch (pf->hw.phy.link_info.link_speed) { in i40e_get_link_speed()
5973 struct i40e_pf *pf = vsi->back; in i40e_set_bw_limit() local
5980 dev_err(&pf->pdev->dev, in i40e_set_bw_limit()
5986 dev_warn(&pf->pdev->dev, in i40e_set_bw_limit()
5994 ret = i40e_aq_config_vsi_bw_limit(&pf->hw, seid, credits, in i40e_set_bw_limit()
5997 dev_err(&pf->pdev->dev, in i40e_set_bw_limit()
6000 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_set_bw_limit()
6015 struct i40e_pf *pf = vsi->back; in i40e_remove_queue_channels() local
6059 &pf->cloud_filter_list, cloud_node) { in i40e_remove_queue_channels()
6071 last_aq_status = pf->hw.aq.asq_last_status; in i40e_remove_queue_channels()
6073 dev_info(&pf->pdev->dev, in i40e_remove_queue_channels()
6116 * @pf: ptr to PF device
6125 static int i40e_validate_num_queues(struct i40e_pf *pf, int num_queues, in i40e_validate_num_queues() argument
6136 dev_dbg(&pf->pdev->dev, in i40e_validate_num_queues()
6142 dev_dbg(&pf->pdev->dev, in i40e_validate_num_queues()
6157 dev_dbg(&pf->pdev->dev, in i40e_validate_num_queues()
6177 struct i40e_pf *pf = vsi->back; in i40e_vsi_reconfig_rss() local
6179 struct i40e_hw *hw = &pf->hw; in i40e_vsi_reconfig_rss()
6196 i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, local_rss_size); in i40e_vsi_reconfig_rss()
6208 dev_info(&pf->pdev->dev, in i40e_vsi_reconfig_rss()
6227 * @pf: ptr to PF device
6233 static void i40e_channel_setup_queue_map(struct i40e_pf *pf, in i40e_channel_setup_queue_map() argument
6244 qcount = min_t(int, ch->num_queue_pairs, pf->num_lan_msix); in i40e_channel_setup_queue_map()
6266 * @pf: ptr to PF device
6272 static int i40e_add_channel(struct i40e_pf *pf, u16 uplink_seid, in i40e_add_channel() argument
6275 struct i40e_hw *hw = &pf->hw; in i40e_add_channel()
6281 dev_info(&pf->pdev->dev, in i40e_add_channel()
6294 if (test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags)) { in i40e_add_channel()
6302 i40e_channel_setup_queue_map(pf, &ctxt, ch); in i40e_add_channel()
6307 dev_info(&pf->pdev->dev, in i40e_add_channel()
6310 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_add_channel()
6364 * @pf: ptr to PF device
6371 static int i40e_channel_config_tx_ring(struct i40e_pf *pf, in i40e_channel_config_tx_ring() argument
6416 * @pf: ptr to PF device
6425 static inline int i40e_setup_hw_channel(struct i40e_pf *pf, in i40e_setup_hw_channel() argument
6437 ret = i40e_add_channel(pf, uplink_seid, ch); in i40e_setup_hw_channel()
6439 dev_info(&pf->pdev->dev, in i40e_setup_hw_channel()
6449 ret = i40e_channel_config_tx_ring(pf, vsi, ch); in i40e_setup_hw_channel()
6451 dev_info(&pf->pdev->dev, in i40e_setup_hw_channel()
6459 dev_dbg(&pf->pdev->dev, in i40e_setup_hw_channel()
6460 …"Added channel: vsi_seid %u, vsi_number %u, stat_counter_idx %u, num_queue_pairs %u, pf->next_base… in i40e_setup_hw_channel()
6469 * @pf: ptr to PF device
6476 static bool i40e_setup_channel(struct i40e_pf *pf, struct i40e_vsi *vsi, in i40e_setup_channel() argument
6487 dev_err(&pf->pdev->dev, "unsupported parent vsi type(%d)\n", in i40e_setup_channel()
6493 main_vsi = i40e_pf_get_main_vsi(pf); in i40e_setup_channel()
6497 ret = i40e_setup_hw_channel(pf, vsi, ch, seid, vsi_type); in i40e_setup_channel()
6499 dev_err(&pf->pdev->dev, "failed to setup hw_channel\n"); in i40e_setup_channel()
6508 * @vsi: ptr to VSI which has PF backing
6516 struct i40e_pf *pf = vsi->back; in i40e_validate_and_set_switch_mode() local
6517 struct i40e_hw *hw = &pf->hw; in i40e_validate_and_set_switch_mode()
6520 ret = i40e_get_capabilities(pf, i40e_aqc_opc_list_dev_capabilities); in i40e_validate_and_set_switch_mode()
6533 dev_err(&pf->pdev->dev, in i40e_validate_and_set_switch_mode()
6550 ret = i40e_aq_set_switch_config(hw, pf->last_sw_conf_flags, in i40e_validate_and_set_switch_mode()
6551 pf->last_sw_conf_valid_flags, in i40e_validate_and_set_switch_mode()
6554 dev_err(&pf->pdev->dev, in i40e_validate_and_set_switch_mode()
6572 struct i40e_pf *pf = vsi->back; in i40e_create_queue_channel() local
6580 dev_err(&pf->pdev->dev, "Invalid num_queues requested: %d\n", in i40e_create_queue_channel()
6586 err = i40e_validate_num_queues(pf, ch->num_queue_pairs, vsi, in i40e_create_queue_channel()
6589 dev_info(&pf->pdev->dev, "Failed to validate num_queues (%d)\n", in i40e_create_queue_channel()
6598 if (!test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags)) { in i40e_create_queue_channel()
6599 set_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags); in i40e_create_queue_channel()
6602 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_create_queue_channel()
6603 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_create_queue_channel()
6605 i40e_do_reset_safe(pf, I40E_PF_RESET_FLAG); in i40e_create_queue_channel()
6616 dev_dbg(&pf->pdev->dev, in i40e_create_queue_channel()
6626 dev_info(&pf->pdev->dev, in i40e_create_queue_channel()
6633 if (!i40e_setup_channel(pf, vsi, ch)) { in i40e_create_queue_channel()
6634 dev_info(&pf->pdev->dev, "Failed to setup channel\n"); in i40e_create_queue_channel()
6638 dev_info(&pf->pdev->dev, in i40e_create_queue_channel()
6650 dev_dbg(&pf->pdev->dev, in i40e_create_queue_channel()
6733 struct i40e_pf *pf = veb->pf; in i40e_veb_config_tc() local
6750 ret = i40e_aq_config_switch_comp_bw_config(&pf->hw, veb->seid, in i40e_veb_config_tc()
6753 dev_info(&pf->pdev->dev, in i40e_veb_config_tc()
6755 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_veb_config_tc()
6762 dev_info(&pf->pdev->dev, in i40e_veb_config_tc()
6764 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_veb_config_tc()
6774 * @pf: PF struct
6776 * Reconfigure VEB/VSIs on a given PF; it is assumed that
6780 static void i40e_dcb_reconfigure(struct i40e_pf *pf) in i40e_dcb_reconfigure() argument
6788 /* Enable the TCs available on PF to all VEBs */ in i40e_dcb_reconfigure()
6789 tc_map = i40e_pf_get_tc_map(pf); in i40e_dcb_reconfigure()
6793 i40e_pf_for_each_veb(pf, v, veb) { in i40e_dcb_reconfigure()
6796 dev_info(&pf->pdev->dev, in i40e_dcb_reconfigure()
6804 i40e_pf_for_each_vsi(pf, v, vsi) { in i40e_dcb_reconfigure()
6809 tc_map = i40e_pf_get_tc_map(pf); in i40e_dcb_reconfigure()
6815 dev_info(&pf->pdev->dev, in i40e_dcb_reconfigure()
6830 * @pf: PF struct
6832 * Resume a port's Tx and issue a PF reset in case of failure to
6835 static int i40e_resume_port_tx(struct i40e_pf *pf) in i40e_resume_port_tx() argument
6837 struct i40e_hw *hw = &pf->hw; in i40e_resume_port_tx()
6842 dev_info(&pf->pdev->dev, in i40e_resume_port_tx()
6845 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_resume_port_tx()
6846 /* Schedule PF reset to recover */ in i40e_resume_port_tx()
6847 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_resume_port_tx()
6848 i40e_service_event_schedule(pf); in i40e_resume_port_tx()
6856 * @pf: PF struct
6858 * Suspend a port's Tx and issue a PF reset in case of failure.
6860 static int i40e_suspend_port_tx(struct i40e_pf *pf) in i40e_suspend_port_tx() argument
6862 struct i40e_hw *hw = &pf->hw; in i40e_suspend_port_tx()
6865 ret = i40e_aq_suspend_port_tx(hw, pf->mac_seid, NULL); in i40e_suspend_port_tx()
6867 dev_info(&pf->pdev->dev, in i40e_suspend_port_tx()
6869 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_suspend_port_tx()
6870 /* Schedule PF reset to recover */ in i40e_suspend_port_tx()
6871 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_suspend_port_tx()
6872 i40e_service_event_schedule(pf); in i40e_suspend_port_tx()
6880 * @pf: PF being configured
6884 * given PF. Uses "Set LLDP MIB" AQC to program the hardware.
6886 static int i40e_hw_set_dcb_config(struct i40e_pf *pf, in i40e_hw_set_dcb_config() argument
6889 struct i40e_dcbx_config *old_cfg = &pf->hw.local_dcbx_config; in i40e_hw_set_dcb_config()
6894 dev_dbg(&pf->pdev->dev, "No Change in DCB Config required.\n"); in i40e_hw_set_dcb_config()
6899 i40e_pf_quiesce_all_vsi(pf); in i40e_hw_set_dcb_config()
6904 ret = i40e_set_dcb_config(&pf->hw); in i40e_hw_set_dcb_config()
6906 dev_info(&pf->pdev->dev, in i40e_hw_set_dcb_config()
6908 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_hw_set_dcb_config()
6913 i40e_dcb_reconfigure(pf); in i40e_hw_set_dcb_config()
6916 if (!test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) { in i40e_hw_set_dcb_config()
6918 ret = i40e_resume_port_tx(pf); in i40e_hw_set_dcb_config()
6922 i40e_pf_unquiesce_all_vsi(pf); in i40e_hw_set_dcb_config()
6930 * @pf: PF being configured
6934 * given PF
6936 int i40e_hw_dcb_config(struct i40e_pf *pf, struct i40e_dcbx_config *new_cfg) in i40e_hw_dcb_config() argument
6944 struct i40e_hw *hw = &pf->hw; in i40e_hw_dcb_config()
6953 dev_dbg(&pf->pdev->dev, "Configuring DCB registers directly\n"); in i40e_hw_dcb_config()
6995 need_reconfig = i40e_dcb_need_reconfig(pf, old_cfg, new_cfg); in i40e_hw_dcb_config()
7003 set_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_hw_dcb_config()
7005 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_hw_dcb_config()
7007 set_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_hw_dcb_config()
7009 i40e_pf_quiesce_all_vsi(pf); in i40e_hw_dcb_config()
7010 ret = i40e_suspend_port_tx(pf); in i40e_hw_dcb_config()
7019 (hw, pf->mac_seid, &ets_data, in i40e_hw_dcb_config()
7022 dev_info(&pf->pdev->dev, in i40e_hw_dcb_config()
7024 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_hw_dcb_config()
7044 struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); in i40e_hw_dcb_config()
7053 i40e_dcb_hw_rx_pb_config(hw, &pf->pb_cfg, &pb_cfg); in i40e_hw_dcb_config()
7056 pf->pb_cfg = pb_cfg; in i40e_hw_dcb_config()
7059 ret = i40e_aq_dcb_updated(&pf->hw, NULL); in i40e_hw_dcb_config()
7061 dev_info(&pf->pdev->dev, in i40e_hw_dcb_config()
7063 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_hw_dcb_config()
7071 i40e_dcb_reconfigure(pf); in i40e_hw_dcb_config()
7075 ret = i40e_resume_port_tx(pf); in i40e_hw_dcb_config()
7077 clear_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_hw_dcb_config()
7082 /* Wait for the PF's queues to be disabled */ in i40e_hw_dcb_config()
7083 ret = i40e_pf_wait_queues_disabled(pf); in i40e_hw_dcb_config()
7085 /* Schedule PF reset to recover */ in i40e_hw_dcb_config()
7086 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_hw_dcb_config()
7087 i40e_service_event_schedule(pf); in i40e_hw_dcb_config()
7090 i40e_pf_unquiesce_all_vsi(pf); in i40e_hw_dcb_config()
7091 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_hw_dcb_config()
7092 set_bit(__I40E_CLIENT_L2_CHANGE, pf->state); in i40e_hw_dcb_config()
7095 if (test_bit(I40E_HW_CAP_USE_SET_LLDP_MIB, pf->hw.caps)) in i40e_hw_dcb_config()
7096 ret = i40e_hw_set_dcb_config(pf, new_cfg); in i40e_hw_dcb_config()
7105 * @pf: PF being queried
7109 int i40e_dcb_sw_default_config(struct i40e_pf *pf) in i40e_dcb_sw_default_config() argument
7111 struct i40e_dcbx_config *dcb_cfg = &pf->hw.local_dcbx_config; in i40e_dcb_sw_default_config()
7113 struct i40e_hw *hw = &pf->hw; in i40e_dcb_sw_default_config()
7116 if (test_bit(I40E_HW_CAP_USE_SET_LLDP_MIB, pf->hw.caps)) { in i40e_dcb_sw_default_config()
7118 memset(&pf->tmp_cfg, 0, sizeof(struct i40e_dcbx_config)); in i40e_dcb_sw_default_config()
7119 pf->tmp_cfg.etscfg.willing = I40E_IEEE_DEFAULT_ETS_WILLING; in i40e_dcb_sw_default_config()
7120 pf->tmp_cfg.etscfg.maxtcs = 0; in i40e_dcb_sw_default_config()
7121 pf->tmp_cfg.etscfg.tcbwtable[0] = I40E_IEEE_DEFAULT_ETS_TCBW; in i40e_dcb_sw_default_config()
7122 pf->tmp_cfg.etscfg.tsatable[0] = I40E_IEEE_TSA_ETS; in i40e_dcb_sw_default_config()
7123 pf->tmp_cfg.pfc.willing = I40E_IEEE_DEFAULT_PFC_WILLING; in i40e_dcb_sw_default_config()
7124 pf->tmp_cfg.pfc.pfccap = I40E_MAX_TRAFFIC_CLASS; in i40e_dcb_sw_default_config()
7126 pf->tmp_cfg.numapps = I40E_IEEE_DEFAULT_NUM_APPS; in i40e_dcb_sw_default_config()
7127 pf->tmp_cfg.app[0].selector = I40E_APP_SEL_ETHTYPE; in i40e_dcb_sw_default_config()
7128 pf->tmp_cfg.app[0].priority = I40E_IEEE_DEFAULT_APP_PRIO; in i40e_dcb_sw_default_config()
7129 pf->tmp_cfg.app[0].protocolid = I40E_APP_PROTOID_FCOE; in i40e_dcb_sw_default_config()
7131 return i40e_hw_set_dcb_config(pf, &pf->tmp_cfg); in i40e_dcb_sw_default_config()
7141 (hw, pf->mac_seid, &ets_data, in i40e_dcb_sw_default_config()
7144 dev_info(&pf->pdev->dev, in i40e_dcb_sw_default_config()
7146 ERR_PTR(err), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_dcb_sw_default_config()
7163 * @pf: PF being configured
7168 static int i40e_init_pf_dcb(struct i40e_pf *pf) in i40e_init_pf_dcb() argument
7170 struct i40e_hw *hw = &pf->hw; in i40e_init_pf_dcb()
7176 if (test_bit(I40E_HW_CAP_NO_DCB_SUPPORT, pf->hw.caps)) { in i40e_init_pf_dcb()
7177 dev_info(&pf->pdev->dev, "DCB is not supported.\n"); in i40e_init_pf_dcb()
7181 if (test_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags)) { in i40e_init_pf_dcb()
7182 dev_info(&pf->pdev->dev, "FW LLDP is disabled, attempting SW DCB\n"); in i40e_init_pf_dcb()
7183 err = i40e_dcb_sw_default_config(pf); in i40e_init_pf_dcb()
7185 dev_info(&pf->pdev->dev, "Could not initialize SW DCB\n"); in i40e_init_pf_dcb()
7188 dev_info(&pf->pdev->dev, "SW DCB initialization succeeded.\n"); in i40e_init_pf_dcb()
7189 pf->dcbx_cap = DCB_CAP_DCBX_HOST | in i40e_init_pf_dcb()
7192 set_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_init_pf_dcb()
7193 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_init_pf_dcb()
7201 dev_info(&pf->pdev->dev, in i40e_init_pf_dcb()
7202 "DCBX offload is not supported or is disabled for this PF.\n"); in i40e_init_pf_dcb()
7205 pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED | in i40e_init_pf_dcb()
7208 set_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_init_pf_dcb()
7213 set_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_init_pf_dcb()
7215 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_init_pf_dcb()
7216 dev_dbg(&pf->pdev->dev, in i40e_init_pf_dcb()
7217 "DCBX offload is supported for this PF.\n"); in i40e_init_pf_dcb()
7219 } else if (pf->hw.aq.asq_last_status == LIBIE_AQ_RC_EPERM) { in i40e_init_pf_dcb()
7220 dev_info(&pf->pdev->dev, "FW LLDP disabled for this PF.\n"); in i40e_init_pf_dcb()
7221 set_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags); in i40e_init_pf_dcb()
7223 dev_info(&pf->pdev->dev, in i40e_init_pf_dcb()
7225 ERR_PTR(err), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_init_pf_dcb()
7261 struct i40e_pf *pf = vsi->back; in i40e_print_link_message() local
7269 new_speed = pf->hw.phy.link_info.link_speed; in i40e_print_link_message()
7285 if (pf->hw.func_caps.npar_enable && in i40e_print_link_message()
7286 (pf->hw.phy.link_info.link_speed == I40E_LINK_SPEED_1GB || in i40e_print_link_message()
7287 pf->hw.phy.link_info.link_speed == I40E_LINK_SPEED_100MB)) in i40e_print_link_message()
7291 switch (pf->hw.phy.link_info.link_speed) { in i40e_print_link_message()
7320 switch (pf->hw.fc.current_mode) { in i40e_print_link_message()
7335 if (pf->hw.phy.link_info.link_speed == I40E_LINK_SPEED_25GB) { in i40e_print_link_message()
7340 if (pf->hw.phy.link_info.an_info & I40E_AQ_AN_COMPLETED) in i40e_print_link_message()
7343 if (pf->hw.phy.link_info.fec_info & in i40e_print_link_message()
7346 else if (pf->hw.phy.link_info.fec_info & in i40e_print_link_message()
7364 } else if (pf->hw.device_id == I40E_DEV_ID_KX_X722) { in i40e_print_link_message()
7369 if (pf->hw.phy.link_info.an_info & I40E_AQ_AN_COMPLETED) in i40e_print_link_message()
7372 if (pf->hw.phy.link_info.fec_info & in i40e_print_link_message()
7376 if (pf->hw.phy.link_info.req_fec_info & in i40e_print_link_message()
7395 struct i40e_pf *pf = vsi->back; in i40e_up_complete() local
7398 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_up_complete()
7412 if ((pf->hw.phy.link_info.link_info & I40E_AQ_LINK_UP) && in i40e_up_complete()
7422 pf->fd_add_err = 0; in i40e_up_complete()
7423 pf->fd_atr_cnt = 0; in i40e_up_complete()
7430 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_up_complete()
7431 i40e_service_event_schedule(pf); in i40e_up_complete()
7445 struct i40e_pf *pf = vsi->back; in i40e_vsi_reinit_locked() local
7447 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) in i40e_vsi_reinit_locked()
7452 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_vsi_reinit_locked()
7457 * @pf: board private structure
7460 static int i40e_force_link_state(struct i40e_pf *pf, bool is_up) in i40e_force_link_state() argument
7465 struct i40e_hw *hw = &pf->hw; in i40e_force_link_state()
7479 dev_err(&pf->pdev->dev, in i40e_force_link_state()
7490 dev_err(&pf->pdev->dev, in i40e_force_link_state()
7500 if (test_bit(I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags)) in i40e_force_link_state()
7516 if (test_bit(I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags)) { in i40e_force_link_state()
7534 dev_err(&pf->pdev->dev, in i40e_force_link_state()
7536 ERR_PTR(err), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_force_link_state()
7821 struct i40e_pf *pf = vsi->back; in i40e_fwd_ring_up() local
7822 struct i40e_hw *hw = &pf->hw; in i40e_fwd_ring_up()
7874 dev_info(&pf->pdev->dev, in i40e_fwd_ring_up()
7893 struct i40e_pf *pf = vsi->back; in i40e_setup_macvlans() local
7894 struct i40e_hw *hw = &pf->hw; in i40e_setup_macvlans()
7930 dev_info(&pf->pdev->dev, in i40e_setup_macvlans()
7946 dev_info(&pf->pdev->dev, in i40e_setup_macvlans()
7965 if (!i40e_setup_channel(pf, vsi, ch)) { in i40e_setup_macvlans()
7979 dev_info(&pf->pdev->dev, "Failed to setup macvlans\n"); in i40e_setup_macvlans()
7995 struct i40e_pf *pf = vsi->back; in i40e_fwd_add() local
7999 if (test_bit(I40E_FLAG_DCB_ENA, pf->flags)) { in i40e_fwd_add()
8003 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_fwd_add()
8007 if (pf->num_lan_msix < I40E_MIN_MACVLAN_VECTORS) { in i40e_fwd_add()
8019 /* reserve bit 0 for the pf device */ in i40e_fwd_add()
8026 vectors = pf->num_lan_msix; in i40e_fwd_add()
8028 /* allocate 4 Qs per macvlan and 32 Qs to the PF*/ in i40e_fwd_add()
8032 /* allocate 2 Qs per macvlan and 16 Qs to the PF*/ in i40e_fwd_add()
8036 /* allocate 1 Q per macvlan and 16 Qs to the PF*/ in i40e_fwd_add()
8040 /* allocate 1 Q per macvlan and 8 Qs to the PF */ in i40e_fwd_add()
8044 /* allocate 1 Q per macvlan and 1 Q to the PF */ in i40e_fwd_add()
8103 struct i40e_pf *pf = vsi->back; in i40e_del_all_macvlans() local
8104 struct i40e_hw *hw = &pf->hw; in i40e_del_all_macvlans()
8140 struct i40e_pf *pf = vsi->back; in i40e_fwd_del() local
8141 struct i40e_hw *hw = &pf->hw; in i40e_fwd_del()
8161 dev_info(&pf->pdev->dev, in i40e_fwd_del()
8180 struct i40e_pf *pf = vsi->back; in i40e_setup_tc() local
8193 clear_bit(I40E_FLAG_TC_MQPRIO_ENA, pf->flags); in i40e_setup_tc()
8199 if (test_bit(I40E_FLAG_MFP_ENA, pf->flags)) { in i40e_setup_tc()
8206 clear_bit(I40E_FLAG_TC_MQPRIO_ENA, pf->flags); in i40e_setup_tc()
8209 if (!test_bit(I40E_FLAG_DCB_ENA, pf->flags)) { in i40e_setup_tc()
8216 if (num_tc > i40e_pf_get_num_tc(pf)) { in i40e_setup_tc()
8223 if (test_bit(I40E_FLAG_DCB_ENA, pf->flags)) { in i40e_setup_tc()
8228 if (!test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_setup_tc()
8235 set_bit(I40E_FLAG_TC_MQPRIO_ENA, pf->flags); in i40e_setup_tc()
8236 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_setup_tc()
8255 if (!hw && !i40e_is_tc_mqprio_enabled(pf)) in i40e_setup_tc()
8279 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_setup_tc()
8377 struct i40e_pf *pf = vsi->back; in i40e_add_del_cloud_filter() local
8416 ret = i40e_aq_add_cloud_filters(&pf->hw, filter->seid, in i40e_add_del_cloud_filter()
8419 ret = i40e_aq_rem_cloud_filters(&pf->hw, filter->seid, in i40e_add_del_cloud_filter()
8422 dev_dbg(&pf->pdev->dev, in i40e_add_del_cloud_filter()
8425 pf->hw.aq.asq_last_status); in i40e_add_del_cloud_filter()
8427 dev_info(&pf->pdev->dev, in i40e_add_del_cloud_filter()
8447 struct i40e_pf *pf = vsi->back; in i40e_add_del_cloud_filter_big_buf() local
8505 dev_err(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8518 dev_err(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8524 ret = i40e_aq_add_cloud_filters_bb(&pf->hw, filter->seid, in i40e_add_del_cloud_filter_big_buf()
8527 ret = i40e_aq_rem_cloud_filters_bb(&pf->hw, filter->seid, in i40e_add_del_cloud_filter_big_buf()
8532 dev_dbg(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8534 add ? "add" : "delete", ret, pf->hw.aq.asq_last_status); in i40e_add_del_cloud_filter_big_buf()
8536 dev_info(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8557 struct i40e_pf *pf = vsi->back; in i40e_parse_cls_flower() local
8569 dev_err(&pf->pdev->dev, "Unsupported key used: 0x%llx\n", in i40e_parse_cls_flower()
8609 dev_err(&pf->pdev->dev, "Bad ether dest mask %pM\n", in i40e_parse_cls_flower()
8619 dev_err(&pf->pdev->dev, "Bad ether src mask %pM\n", in i40e_parse_cls_flower()
8637 dev_err(&pf->pdev->dev, "Bad vlan mask 0x%04x\n", in i40e_parse_cls_flower()
8665 dev_err(&pf->pdev->dev, "Bad ip dst mask %pI4b\n", in i40e_parse_cls_flower()
8675 dev_err(&pf->pdev->dev, "Bad ip src mask %pI4b\n", in i40e_parse_cls_flower()
8682 dev_err(&pf->pdev->dev, "Tenant id not allowed for ip filter\n"); in i40e_parse_cls_flower()
8699 dev_err(&pf->pdev->dev, in i40e_parse_cls_flower()
8721 dev_err(&pf->pdev->dev, "Bad src port mask 0x%04x\n", in i40e_parse_cls_flower()
8731 dev_err(&pf->pdev->dev, "Bad dst port mask 0x%04x\n", in i40e_parse_cls_flower()
8745 dev_err(&pf->pdev->dev, in i40e_parse_cls_flower()
8800 struct i40e_pf *pf = vsi->back; in i40e_configure_clsflower() local
8809 dev_err(&pf->pdev->dev, "Unable to add filter because of invalid destination"); in i40e_configure_clsflower()
8813 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_configure_clsflower()
8814 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_configure_clsflower()
8817 if (pf->fdir_pf_active_filters || in i40e_configure_clsflower()
8818 (!hlist_empty(&pf->fdir_filter_list))) { in i40e_configure_clsflower()
8852 dev_err(&pf->pdev->dev, "Failed to add cloud filter, err %d\n", in i40e_configure_clsflower()
8860 hlist_add_head(&filter->cloud_node, &pf->cloud_filter_list); in i40e_configure_clsflower()
8862 pf->num_cloud_filters++; in i40e_configure_clsflower()
8899 struct i40e_pf *pf = vsi->back; in i40e_delete_clsflower() local
8916 dev_err(&pf->pdev->dev, in i40e_delete_clsflower()
8919 return i40e_aq_rc_to_posix(err, pf->hw.aq.asq_last_status); in i40e_delete_clsflower()
8922 pf->num_cloud_filters--; in i40e_delete_clsflower()
8923 if (!pf->num_cloud_filters) in i40e_delete_clsflower()
8924 if (test_bit(I40E_FLAG_FD_SB_TO_CLOUD_FILTER, pf->flags) && in i40e_delete_clsflower()
8925 !test_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags)) { in i40e_delete_clsflower()
8926 set_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_delete_clsflower()
8927 clear_bit(I40E_FLAG_FD_SB_TO_CLOUD_FILTER, pf->flags); in i40e_delete_clsflower()
8928 clear_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_delete_clsflower()
9008 struct i40e_pf *pf = vsi->back; in i40e_open() local
9012 if (test_bit(__I40E_TESTING, pf->state) || in i40e_open()
9013 test_bit(__I40E_BAD_EEPROM, pf->state)) in i40e_open()
9018 if (i40e_force_link_state(pf, true)) in i40e_open()
9026 wr32(&pf->hw, I40E_GLLAN_TSOMSK_F, be32_to_cpu(TCP_FLAG_PSH | in i40e_open()
9028 wr32(&pf->hw, I40E_GLLAN_TSOMSK_M, be32_to_cpu(TCP_FLAG_PSH | in i40e_open()
9031 wr32(&pf->hw, I40E_GLLAN_TSOMSK_L, be32_to_cpu(TCP_FLAG_CWR) >> 16); in i40e_open()
9070 struct i40e_pf *pf = vsi->back; in i40e_vsi_open() local
9088 dev_driver_string(&pf->pdev->dev), vsi->netdev->name); in i40e_vsi_open()
9100 dev_driver_string(&pf->pdev->dev), in i40e_vsi_open()
9101 dev_name(&pf->pdev->dev)); in i40e_vsi_open()
9126 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_vsi_open()
9133 * @pf: Pointer to PF
9138 static void i40e_fdir_filter_exit(struct i40e_pf *pf) in i40e_fdir_filter_exit() argument
9145 &pf->fdir_filter_list, fdir_node) { in i40e_fdir_filter_exit()
9150 list_for_each_entry_safe(pit_entry, tmp, &pf->l3_flex_pit_list, list) { in i40e_fdir_filter_exit()
9154 INIT_LIST_HEAD(&pf->l3_flex_pit_list); in i40e_fdir_filter_exit()
9156 list_for_each_entry_safe(pit_entry, tmp, &pf->l4_flex_pit_list, list) { in i40e_fdir_filter_exit()
9160 INIT_LIST_HEAD(&pf->l4_flex_pit_list); in i40e_fdir_filter_exit()
9162 pf->fdir_pf_active_filters = 0; in i40e_fdir_filter_exit()
9163 i40e_reset_fdir_filter_cnt(pf); in i40e_fdir_filter_exit()
9166 i40e_write_fd_input_set(pf, LIBIE_FILTER_PCTYPE_NONF_IPV4_TCP, in i40e_fdir_filter_exit()
9171 i40e_write_fd_input_set(pf, LIBIE_FILTER_PCTYPE_NONF_IPV6_TCP, in i40e_fdir_filter_exit()
9176 i40e_write_fd_input_set(pf, LIBIE_FILTER_PCTYPE_NONF_IPV4_UDP, in i40e_fdir_filter_exit()
9181 i40e_write_fd_input_set(pf, LIBIE_FILTER_PCTYPE_NONF_IPV6_UDP, in i40e_fdir_filter_exit()
9186 i40e_write_fd_input_set(pf, LIBIE_FILTER_PCTYPE_NONF_IPV4_SCTP, in i40e_fdir_filter_exit()
9191 i40e_write_fd_input_set(pf, LIBIE_FILTER_PCTYPE_NONF_IPV6_SCTP, in i40e_fdir_filter_exit()
9196 i40e_write_fd_input_set(pf, LIBIE_FILTER_PCTYPE_NONF_IPV4_OTHER, in i40e_fdir_filter_exit()
9199 i40e_write_fd_input_set(pf, LIBIE_FILTER_PCTYPE_FRAG_IPV4, in i40e_fdir_filter_exit()
9203 i40e_write_fd_input_set(pf, LIBIE_FILTER_PCTYPE_NONF_IPV6_OTHER, in i40e_fdir_filter_exit()
9206 i40e_write_fd_input_set(pf, LIBIE_FILTER_PCTYPE_FRAG_IPV6, in i40e_fdir_filter_exit()
9212 * @pf: Pointer to PF
9217 static void i40e_cloud_filter_exit(struct i40e_pf *pf) in i40e_cloud_filter_exit() argument
9223 &pf->cloud_filter_list, cloud_node) { in i40e_cloud_filter_exit()
9227 pf->num_cloud_filters = 0; in i40e_cloud_filter_exit()
9229 if (test_bit(I40E_FLAG_FD_SB_TO_CLOUD_FILTER, pf->flags) && in i40e_cloud_filter_exit()
9230 !test_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags)) { in i40e_cloud_filter_exit()
9231 set_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_cloud_filter_exit()
9232 clear_bit(I40E_FLAG_FD_SB_TO_CLOUD_FILTER, pf->flags); in i40e_cloud_filter_exit()
9233 clear_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_cloud_filter_exit()
9258 * i40e_do_reset - Start a PF or Core Reset sequence
9259 * @pf: board private structure
9264 * The essential difference in resets is that the PF Reset
9268 void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired) in i40e_do_reset() argument
9285 dev_dbg(&pf->pdev->dev, "GlobalR requested\n"); in i40e_do_reset()
9286 val = rd32(&pf->hw, I40E_GLGEN_RTRIG); in i40e_do_reset()
9288 wr32(&pf->hw, I40E_GLGEN_RTRIG, val); in i40e_do_reset()
9296 dev_dbg(&pf->pdev->dev, "CoreR requested\n"); in i40e_do_reset()
9297 val = rd32(&pf->hw, I40E_GLGEN_RTRIG); in i40e_do_reset()
9299 wr32(&pf->hw, I40E_GLGEN_RTRIG, val); in i40e_do_reset()
9300 i40e_flush(&pf->hw); in i40e_do_reset()
9304 /* Request a PF Reset in i40e_do_reset()
9306 * Resets only the PF-specific registers in i40e_do_reset()
9312 dev_dbg(&pf->pdev->dev, "PFR requested\n"); in i40e_do_reset()
9313 i40e_handle_reset_warning(pf, lock_acquired); in i40e_do_reset()
9316 /* Request a PF Reset in i40e_do_reset()
9318 * Resets PF and reinitializes PFs VSI. in i40e_do_reset()
9320 i40e_prep_for_reset(pf); in i40e_do_reset()
9321 i40e_reset_and_rebuild(pf, true, lock_acquired); in i40e_do_reset()
9322 dev_info(&pf->pdev->dev, in i40e_do_reset()
9323 test_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags) ? in i40e_do_reset()
9329 dev_info(&pf->pdev->dev, "VSI reinit requested\n"); in i40e_do_reset()
9331 i40e_pf_for_each_vsi(pf, i, vsi) { in i40e_do_reset()
9338 dev_info(&pf->pdev->dev, "VSI down requested\n"); in i40e_do_reset()
9340 i40e_pf_for_each_vsi(pf, i, vsi) { in i40e_do_reset()
9348 dev_info(&pf->pdev->dev, in i40e_do_reset()
9356 * @pf: board private structure
9360 bool i40e_dcb_need_reconfig(struct i40e_pf *pf, in i40e_dcb_need_reconfig() argument
9375 dev_dbg(&pf->pdev->dev, "ETS UP2TC changed.\n"); in i40e_dcb_need_reconfig()
9381 dev_dbg(&pf->pdev->dev, "ETS TC BW Table changed.\n"); in i40e_dcb_need_reconfig()
9386 dev_dbg(&pf->pdev->dev, "ETS TSA Table changed.\n"); in i40e_dcb_need_reconfig()
9394 dev_dbg(&pf->pdev->dev, "PFC config change detected.\n"); in i40e_dcb_need_reconfig()
9402 dev_dbg(&pf->pdev->dev, "APP Table change detected.\n"); in i40e_dcb_need_reconfig()
9405 dev_dbg(&pf->pdev->dev, "dcb need_reconfig=%d\n", need_reconfig); in i40e_dcb_need_reconfig()
9411 * @pf: board private structure
9414 static int i40e_handle_lldp_event(struct i40e_pf *pf, in i40e_handle_lldp_event() argument
9418 struct i40e_hw *hw = &pf->hw; in i40e_handle_lldp_event()
9428 !test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags)) in i40e_handle_lldp_event()
9430 set_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_handle_lldp_event()
9433 if (!test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags)) in i40e_handle_lldp_event()
9439 dev_dbg(&pf->pdev->dev, "LLDP event mib bridge type 0x%x\n", type); in i40e_handle_lldp_event()
9445 dev_dbg(&pf->pdev->dev, in i40e_handle_lldp_event()
9461 ret = i40e_get_dcb_config(&pf->hw); in i40e_handle_lldp_event()
9467 dev_warn(&pf->pdev->dev, in i40e_handle_lldp_event()
9469 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_handle_lldp_event()
9471 dev_info(&pf->pdev->dev, in i40e_handle_lldp_event()
9474 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_handle_lldp_event()
9482 dev_dbg(&pf->pdev->dev, "No change detected in DCBX configuration.\n"); in i40e_handle_lldp_event()
9486 need_reconfig = i40e_dcb_need_reconfig(pf, &tmp_dcbx_cfg, in i40e_handle_lldp_event()
9489 i40e_dcbnl_flush_apps(pf, &tmp_dcbx_cfg, &hw->local_dcbx_config); in i40e_handle_lldp_event()
9496 set_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_handle_lldp_event()
9498 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_handle_lldp_event()
9500 set_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_handle_lldp_event()
9502 i40e_pf_quiesce_all_vsi(pf); in i40e_handle_lldp_event()
9505 i40e_dcb_reconfigure(pf); in i40e_handle_lldp_event()
9507 ret = i40e_resume_port_tx(pf); in i40e_handle_lldp_event()
9509 clear_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_handle_lldp_event()
9514 /* Wait for the PF's queues to be disabled */ in i40e_handle_lldp_event()
9515 ret = i40e_pf_wait_queues_disabled(pf); in i40e_handle_lldp_event()
9517 /* Schedule PF reset to recover */ in i40e_handle_lldp_event()
9518 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_handle_lldp_event()
9519 i40e_service_event_schedule(pf); in i40e_handle_lldp_event()
9521 i40e_pf_unquiesce_all_vsi(pf); in i40e_handle_lldp_event()
9522 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_handle_lldp_event()
9523 set_bit(__I40E_CLIENT_L2_CHANGE, pf->state); in i40e_handle_lldp_event()
9533 * @pf: board private structure
9537 void i40e_do_reset_safe(struct i40e_pf *pf, u32 reset_flags) in i40e_do_reset_safe() argument
9540 i40e_do_reset(pf, reset_flags, true); in i40e_do_reset_safe()
9546 * @pf: board private structure
9549 * Handler for LAN Queue Overflow Event generated by the firmware for PF
9552 static void i40e_handle_lan_overflow_event(struct i40e_pf *pf, in i40e_handle_lan_overflow_event() argument
9558 struct i40e_hw *hw = &pf->hw; in i40e_handle_lan_overflow_event()
9562 dev_dbg(&pf->pdev->dev, "overflow Rx Queue Number = %d QTX_CTL=0x%08x\n", in i40e_handle_lan_overflow_event()
9572 vf = &pf->vf[vf_id]; in i40e_handle_lan_overflow_event()
9580 * i40e_get_current_fd_count - Get total FD filters programmed for this PF
9581 * @pf: board private structure
9583 u32 i40e_get_current_fd_count(struct i40e_pf *pf) in i40e_get_current_fd_count() argument
9587 val = rd32(&pf->hw, I40E_PFQF_FDSTAT); in i40e_get_current_fd_count()
9595 * @pf: board private structure
9597 u32 i40e_get_global_fd_count(struct i40e_pf *pf) in i40e_get_global_fd_count() argument
9601 val = rd32(&pf->hw, I40E_GLQF_FDCNT_0); in i40e_get_global_fd_count()
9609 * @pf: board private structure
9611 static void i40e_reenable_fdir_sb(struct i40e_pf *pf) in i40e_reenable_fdir_sb() argument
9613 if (test_and_clear_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state)) in i40e_reenable_fdir_sb()
9614 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) && in i40e_reenable_fdir_sb()
9615 (I40E_DEBUG_FD & pf->hw.debug_mask)) in i40e_reenable_fdir_sb()
9616 …dev_info(&pf->pdev->dev, "FD Sideband/ntuple is being enabled since we have space in the table now… in i40e_reenable_fdir_sb()
9621 * @pf: board private structure
9623 static void i40e_reenable_fdir_atr(struct i40e_pf *pf) in i40e_reenable_fdir_atr() argument
9625 if (test_and_clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state)) { in i40e_reenable_fdir_atr()
9631 i40e_write_fd_input_set(pf, LIBIE_FILTER_PCTYPE_NONF_IPV4_TCP, in i40e_reenable_fdir_atr()
9635 if (test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags) && in i40e_reenable_fdir_atr()
9636 (I40E_DEBUG_FD & pf->hw.debug_mask)) in i40e_reenable_fdir_atr()
9637 …dev_info(&pf->pdev->dev, "ATR is being enabled since we have space in the table and there are no c… in i40e_reenable_fdir_atr()
9643 * @pf: board private structure
9646 static void i40e_delete_invalid_filter(struct i40e_pf *pf, in i40e_delete_invalid_filter() argument
9650 pf->fdir_pf_active_filters--; in i40e_delete_invalid_filter()
9651 pf->fd_inv = 0; in i40e_delete_invalid_filter()
9655 pf->fd_tcp4_filter_cnt--; in i40e_delete_invalid_filter()
9658 pf->fd_udp4_filter_cnt--; in i40e_delete_invalid_filter()
9661 pf->fd_sctp4_filter_cnt--; in i40e_delete_invalid_filter()
9664 pf->fd_tcp6_filter_cnt--; in i40e_delete_invalid_filter()
9667 pf->fd_udp6_filter_cnt--; in i40e_delete_invalid_filter()
9670 pf->fd_udp6_filter_cnt--; in i40e_delete_invalid_filter()
9675 pf->fd_tcp4_filter_cnt--; in i40e_delete_invalid_filter()
9678 pf->fd_udp4_filter_cnt--; in i40e_delete_invalid_filter()
9681 pf->fd_sctp4_filter_cnt--; in i40e_delete_invalid_filter()
9684 pf->fd_ip4_filter_cnt--; in i40e_delete_invalid_filter()
9691 pf->fd_tcp6_filter_cnt--; in i40e_delete_invalid_filter()
9694 pf->fd_udp6_filter_cnt--; in i40e_delete_invalid_filter()
9697 pf->fd_sctp6_filter_cnt--; in i40e_delete_invalid_filter()
9700 pf->fd_ip6_filter_cnt--; in i40e_delete_invalid_filter()
9713 * @pf: board private structure
9715 void i40e_fdir_check_and_reenable(struct i40e_pf *pf) in i40e_fdir_check_and_reenable() argument
9721 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_fdir_check_and_reenable()
9725 fcnt_prog = i40e_get_global_fd_count(pf); in i40e_fdir_check_and_reenable()
9726 fcnt_avail = pf->fdir_pf_filter_count; in i40e_fdir_check_and_reenable()
9728 (pf->fd_add_err == 0) || in i40e_fdir_check_and_reenable()
9729 (i40e_get_current_atr_cnt(pf) < pf->fd_atr_cnt)) in i40e_fdir_check_and_reenable()
9730 i40e_reenable_fdir_sb(pf); in i40e_fdir_check_and_reenable()
9737 pf->fd_tcp4_filter_cnt == 0 && pf->fd_tcp6_filter_cnt == 0) in i40e_fdir_check_and_reenable()
9738 i40e_reenable_fdir_atr(pf); in i40e_fdir_check_and_reenable()
9741 if (pf->fd_inv > 0) { in i40e_fdir_check_and_reenable()
9743 &pf->fdir_filter_list, fdir_node) in i40e_fdir_check_and_reenable()
9744 if (filter->fd_id == pf->fd_inv) in i40e_fdir_check_and_reenable()
9745 i40e_delete_invalid_filter(pf, filter); in i40e_fdir_check_and_reenable()
9753 * @pf: board private structure
9755 static void i40e_fdir_flush_and_replay(struct i40e_pf *pf) in i40e_fdir_flush_and_replay() argument
9763 if (!time_after(jiffies, pf->fd_flush_timestamp + in i40e_fdir_flush_and_replay()
9770 min_flush_time = pf->fd_flush_timestamp + in i40e_fdir_flush_and_replay()
9772 fd_room = pf->fdir_pf_filter_count - pf->fdir_pf_active_filters; in i40e_fdir_flush_and_replay()
9776 if (I40E_DEBUG_FD & pf->hw.debug_mask) in i40e_fdir_flush_and_replay()
9777 dev_info(&pf->pdev->dev, "ATR disabled, not enough FD filter space.\n"); in i40e_fdir_flush_and_replay()
9781 pf->fd_flush_timestamp = jiffies; in i40e_fdir_flush_and_replay()
9782 set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state); in i40e_fdir_flush_and_replay()
9784 wr32(&pf->hw, I40E_PFQF_CTL_1, in i40e_fdir_flush_and_replay()
9786 i40e_flush(&pf->hw); in i40e_fdir_flush_and_replay()
9787 pf->fd_flush_cnt++; in i40e_fdir_flush_and_replay()
9788 pf->fd_add_err = 0; in i40e_fdir_flush_and_replay()
9792 reg = rd32(&pf->hw, I40E_PFQF_CTL_1); in i40e_fdir_flush_and_replay()
9797 dev_warn(&pf->pdev->dev, "FD table did not flush, needs more time\n"); in i40e_fdir_flush_and_replay()
9800 i40e_fdir_filter_restore(i40e_pf_get_main_vsi(pf)); in i40e_fdir_flush_and_replay()
9801 if (!disable_atr && !pf->fd_tcp4_filter_cnt) in i40e_fdir_flush_and_replay()
9802 clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state); in i40e_fdir_flush_and_replay()
9803 clear_bit(__I40E_FD_FLUSH_REQUESTED, pf->state); in i40e_fdir_flush_and_replay()
9804 if (I40E_DEBUG_FD & pf->hw.debug_mask) in i40e_fdir_flush_and_replay()
9805 dev_info(&pf->pdev->dev, "FD Filter table flushed and FD-SB replayed.\n"); in i40e_fdir_flush_and_replay()
9811 * @pf: board private structure
9813 u32 i40e_get_current_atr_cnt(struct i40e_pf *pf) in i40e_get_current_atr_cnt() argument
9815 return i40e_get_current_fd_count(pf) - pf->fdir_pf_active_filters; in i40e_get_current_atr_cnt()
9820 * @pf: board private structure
9822 static void i40e_fdir_reinit_subtask(struct i40e_pf *pf) in i40e_fdir_reinit_subtask() argument
9826 if (test_bit(__I40E_DOWN, pf->state)) in i40e_fdir_reinit_subtask()
9829 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_fdir_reinit_subtask()
9830 i40e_fdir_flush_and_replay(pf); in i40e_fdir_reinit_subtask()
9832 i40e_fdir_check_and_reenable(pf); in i40e_fdir_reinit_subtask()
9879 struct i40e_pf *pf; in i40e_veb_link_event() local
9882 if (!veb || !veb->pf) in i40e_veb_link_event()
9884 pf = veb->pf; in i40e_veb_link_event()
9887 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_veb_link_event()
9894 * @pf: board private structure
9896 static void i40e_link_event(struct i40e_pf *pf) in i40e_link_event() argument
9898 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_link_event()
9899 struct i40e_veb *veb = i40e_pf_get_main_veb(pf); in i40e_link_event()
9908 pf->hw.phy.get_link_info = true; in i40e_link_event()
9909 old_link = (pf->hw.phy.link_info_old.link_info & I40E_AQ_LINK_UP); in i40e_link_event()
9910 status = i40e_get_link_status(&pf->hw, &new_link); in i40e_link_event()
9914 clear_bit(__I40E_TEMP_LINK_POLLING, pf->state); in i40e_link_event()
9919 set_bit(__I40E_TEMP_LINK_POLLING, pf->state); in i40e_link_event()
9920 dev_dbg(&pf->pdev->dev, "couldn't get link state, status: %d\n", in i40e_link_event()
9925 old_link_speed = pf->hw.phy.link_info_old.link_speed; in i40e_link_event()
9926 new_link_speed = pf->hw.phy.link_info.link_speed; in i40e_link_event()
9935 pf->link_down_events++; in i40e_link_event()
9947 if (pf->vf) in i40e_link_event()
9948 i40e_vc_notify_link_state(pf); in i40e_link_event()
9950 if (test_bit(I40E_FLAG_PTP_ENA, pf->flags)) in i40e_link_event()
9951 i40e_ptp_set_increment(pf); in i40e_link_event()
9956 if (pf->dcbx_cap & DCB_CAP_DCBX_LLD_MANAGED) in i40e_link_event()
9963 dev_dbg(&pf->pdev->dev, "Reconfig DCB to single TC as result of Link Down\n"); in i40e_link_event()
9964 memset(&pf->tmp_cfg, 0, sizeof(pf->tmp_cfg)); in i40e_link_event()
9965 err = i40e_dcb_sw_default_config(pf); in i40e_link_event()
9967 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_link_event()
9968 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_link_event()
9970 pf->dcbx_cap = DCB_CAP_DCBX_HOST | in i40e_link_event()
9972 set_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_link_event()
9973 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_link_event()
9981 * @pf: board private structure
9983 static void i40e_watchdog_subtask(struct i40e_pf *pf) in i40e_watchdog_subtask() argument
9990 if (test_bit(__I40E_DOWN, pf->state) || in i40e_watchdog_subtask()
9991 test_bit(__I40E_CONFIG_BUSY, pf->state)) in i40e_watchdog_subtask()
9995 if (time_before(jiffies, (pf->service_timer_previous + in i40e_watchdog_subtask()
9996 pf->service_timer_period))) in i40e_watchdog_subtask()
9998 pf->service_timer_previous = jiffies; in i40e_watchdog_subtask()
10000 if (test_bit(I40E_FLAG_LINK_POLLING_ENA, pf->flags) || in i40e_watchdog_subtask()
10001 test_bit(__I40E_TEMP_LINK_POLLING, pf->state)) in i40e_watchdog_subtask()
10002 i40e_link_event(pf); in i40e_watchdog_subtask()
10007 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_watchdog_subtask()
10011 if (test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags)) { in i40e_watchdog_subtask()
10013 i40e_pf_for_each_veb(pf, i, veb) in i40e_watchdog_subtask()
10017 i40e_ptp_rx_hang(pf); in i40e_watchdog_subtask()
10018 i40e_ptp_tx_hang(pf); in i40e_watchdog_subtask()
10023 * @pf: board private structure
10025 static void i40e_reset_subtask(struct i40e_pf *pf) in i40e_reset_subtask() argument
10029 if (test_bit(__I40E_REINIT_REQUESTED, pf->state)) { in i40e_reset_subtask()
10031 clear_bit(__I40E_REINIT_REQUESTED, pf->state); in i40e_reset_subtask()
10033 if (test_bit(__I40E_PF_RESET_REQUESTED, pf->state)) { in i40e_reset_subtask()
10035 clear_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_reset_subtask()
10037 if (test_bit(__I40E_CORE_RESET_REQUESTED, pf->state)) { in i40e_reset_subtask()
10039 clear_bit(__I40E_CORE_RESET_REQUESTED, pf->state); in i40e_reset_subtask()
10041 if (test_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state)) { in i40e_reset_subtask()
10043 clear_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state); in i40e_reset_subtask()
10045 if (test_bit(__I40E_DOWN_REQUESTED, pf->state)) { in i40e_reset_subtask()
10047 clear_bit(__I40E_DOWN_REQUESTED, pf->state); in i40e_reset_subtask()
10053 if (test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) { in i40e_reset_subtask()
10054 i40e_prep_for_reset(pf); in i40e_reset_subtask()
10055 i40e_reset(pf); in i40e_reset_subtask()
10056 i40e_rebuild(pf, false, false); in i40e_reset_subtask()
10061 !test_bit(__I40E_DOWN, pf->state) && in i40e_reset_subtask()
10062 !test_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_reset_subtask()
10063 i40e_do_reset(pf, reset_flags, false); in i40e_reset_subtask()
10069 * @pf: board private structure
10072 static void i40e_handle_link_event(struct i40e_pf *pf, in i40e_handle_link_event() argument
10083 i40e_link_event(pf); in i40e_handle_link_event()
10087 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10089 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10098 (!test_bit(I40E_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags))) { in i40e_handle_link_event()
10099 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10101 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10109 * @pf: board private structure
10111 static void i40e_clean_adminq_subtask(struct i40e_pf *pf) in i40e_clean_adminq_subtask() argument
10114 struct i40e_hw *hw = &pf->hw; in i40e_clean_adminq_subtask()
10121 /* Do not run clean AQ when PF reset fails */ in i40e_clean_adminq_subtask()
10122 if (test_bit(__I40E_RESET_FAILED, pf->state)) in i40e_clean_adminq_subtask()
10126 val = rd32(&pf->hw, I40E_PF_ARQLEN); in i40e_clean_adminq_subtask()
10130 dev_info(&pf->pdev->dev, "ARQ VF Error detected\n"); in i40e_clean_adminq_subtask()
10135 dev_info(&pf->pdev->dev, "ARQ Overflow Error detected\n"); in i40e_clean_adminq_subtask()
10137 pf->arq_overflows++; in i40e_clean_adminq_subtask()
10141 dev_info(&pf->pdev->dev, "ARQ Critical Error detected\n"); in i40e_clean_adminq_subtask()
10145 wr32(&pf->hw, I40E_PF_ARQLEN, val); in i40e_clean_adminq_subtask()
10147 val = rd32(&pf->hw, I40E_PF_ATQLEN); in i40e_clean_adminq_subtask()
10150 if (pf->hw.debug_mask & I40E_DEBUG_AQ) in i40e_clean_adminq_subtask()
10151 dev_info(&pf->pdev->dev, "ASQ VF Error detected\n"); in i40e_clean_adminq_subtask()
10155 if (pf->hw.debug_mask & I40E_DEBUG_AQ) in i40e_clean_adminq_subtask()
10156 dev_info(&pf->pdev->dev, "ASQ Overflow Error detected\n"); in i40e_clean_adminq_subtask()
10160 if (pf->hw.debug_mask & I40E_DEBUG_AQ) in i40e_clean_adminq_subtask()
10161 dev_info(&pf->pdev->dev, "ASQ Critical Error detected\n"); in i40e_clean_adminq_subtask()
10165 wr32(&pf->hw, I40E_PF_ATQLEN, val); in i40e_clean_adminq_subtask()
10177 dev_info(&pf->pdev->dev, "ARQ event error %d\n", ret); in i40e_clean_adminq_subtask()
10186 i40e_handle_link_event(pf, &event); in i40e_clean_adminq_subtask()
10190 ret = i40e_vc_process_vf_msg(pf, in i40e_clean_adminq_subtask()
10198 dev_dbg(&pf->pdev->dev, "ARQ: Update LLDP MIB event received\n"); in i40e_clean_adminq_subtask()
10201 i40e_handle_lldp_event(pf, &event); in i40e_clean_adminq_subtask()
10206 dev_dbg(&pf->pdev->dev, "ARQ LAN queue overflow event received\n"); in i40e_clean_adminq_subtask()
10207 i40e_handle_lan_overflow_event(pf, &event); in i40e_clean_adminq_subtask()
10210 dev_info(&pf->pdev->dev, "ARQ: Msg from other pf\n"); in i40e_clean_adminq_subtask()
10215 i40e_debug(&pf->hw, I40E_DEBUG_NVM, in i40e_clean_adminq_subtask()
10220 dev_info(&pf->pdev->dev, in i40e_clean_adminq_subtask()
10228 clear_bit(__I40E_ADMINQ_EVENT_PENDING, pf->state); in i40e_clean_adminq_subtask()
10241 * @pf: board private structure
10243 static void i40e_verify_eeprom(struct i40e_pf *pf) in i40e_verify_eeprom() argument
10247 err = i40e_diag_eeprom_test(&pf->hw); in i40e_verify_eeprom()
10250 err = i40e_diag_eeprom_test(&pf->hw); in i40e_verify_eeprom()
10252 dev_info(&pf->pdev->dev, "eeprom check failed (%d), Tx/Rx traffic disabled\n", in i40e_verify_eeprom()
10254 set_bit(__I40E_BAD_EEPROM, pf->state); in i40e_verify_eeprom()
10258 if (!err && test_bit(__I40E_BAD_EEPROM, pf->state)) { in i40e_verify_eeprom()
10259 dev_info(&pf->pdev->dev, "eeprom check passed, Tx/Rx traffic enabled\n"); in i40e_verify_eeprom()
10260 clear_bit(__I40E_BAD_EEPROM, pf->state); in i40e_verify_eeprom()
10266 * @pf: pointer to the PF structure
10270 static void i40e_enable_pf_switch_lb(struct i40e_pf *pf) in i40e_enable_pf_switch_lb() argument
10272 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_enable_pf_switch_lb()
10276 ctxt.seid = pf->main_vsi_seid; in i40e_enable_pf_switch_lb()
10277 ctxt.pf_num = pf->hw.pf_id; in i40e_enable_pf_switch_lb()
10279 ret = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL); in i40e_enable_pf_switch_lb()
10281 dev_info(&pf->pdev->dev, in i40e_enable_pf_switch_lb()
10282 "couldn't get PF vsi config, err %pe aq_err %s\n", in i40e_enable_pf_switch_lb()
10283 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_enable_pf_switch_lb()
10292 dev_info(&pf->pdev->dev, in i40e_enable_pf_switch_lb()
10294 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_enable_pf_switch_lb()
10300 * @pf: pointer to the PF structure
10304 static void i40e_disable_pf_switch_lb(struct i40e_pf *pf) in i40e_disable_pf_switch_lb() argument
10306 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_disable_pf_switch_lb()
10310 ctxt.seid = pf->main_vsi_seid; in i40e_disable_pf_switch_lb()
10311 ctxt.pf_num = pf->hw.pf_id; in i40e_disable_pf_switch_lb()
10313 ret = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL); in i40e_disable_pf_switch_lb()
10315 dev_info(&pf->pdev->dev, in i40e_disable_pf_switch_lb()
10316 "couldn't get PF vsi config, err %pe aq_err %s\n", in i40e_disable_pf_switch_lb()
10317 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_disable_pf_switch_lb()
10326 dev_info(&pf->pdev->dev, in i40e_disable_pf_switch_lb()
10328 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_disable_pf_switch_lb()
10342 struct i40e_pf *pf = veb->pf; in i40e_config_bridge_mode() local
10344 if (pf->hw.debug_mask & I40E_DEBUG_LAN) in i40e_config_bridge_mode()
10345 dev_info(&pf->pdev->dev, "enabling bridge mode: %s\n", in i40e_config_bridge_mode()
10348 i40e_disable_pf_switch_lb(pf); in i40e_config_bridge_mode()
10350 i40e_enable_pf_switch_lb(pf); in i40e_config_bridge_mode()
10364 struct i40e_pf *pf = veb->pf; in i40e_reconstitute_veb() local
10372 if (WARN_ON(veb->uplink_seid && veb->uplink_seid != pf->mac_seid)) { in i40e_reconstitute_veb()
10373 dev_err(&pf->pdev->dev, in i40e_reconstitute_veb()
10378 if (veb->uplink_seid == pf->mac_seid) { in i40e_reconstitute_veb()
10380 ctl_vsi = i40e_pf_get_main_vsi(pf); in i40e_reconstitute_veb()
10384 dev_err(&pf->pdev->dev, in i40e_reconstitute_veb()
10392 dev_err(&pf->pdev->dev, in i40e_reconstitute_veb()
10407 if (test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags)) in i40e_reconstitute_veb()
10415 i40e_pf_for_each_vsi(pf, v, vsi) { in i40e_reconstitute_veb()
10423 dev_info(&pf->pdev->dev, in i40e_reconstitute_veb()
10437 * @pf: the PF struct
10440 static int i40e_get_capabilities(struct i40e_pf *pf, in i40e_get_capabilities() argument
10455 err = i40e_aq_discover_capabilities(&pf->hw, cap_buf, buf_len, in i40e_get_capabilities()
10461 if (pf->hw.aq.asq_last_status == LIBIE_AQ_RC_ENOMEM) { in i40e_get_capabilities()
10464 } else if (pf->hw.aq.asq_last_status != LIBIE_AQ_RC_OK || err) { in i40e_get_capabilities()
10465 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10468 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_get_capabilities()
10473 if (pf->hw.debug_mask & I40E_DEBUG_USER) { in i40e_get_capabilities()
10475 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10476 "pf=%d, num_vfs=%d, msix_pf=%d, msix_vf=%d, fd_g=%d, fd_b=%d, pf_max_q=%d num_vsi=%d\n", in i40e_get_capabilities()
10477 pf->hw.pf_id, pf->hw.func_caps.num_vfs, in i40e_get_capabilities()
10478 pf->hw.func_caps.num_msix_vectors, in i40e_get_capabilities()
10479 pf->hw.func_caps.num_msix_vectors_vf, in i40e_get_capabilities()
10480 pf->hw.func_caps.fd_filters_guaranteed, in i40e_get_capabilities()
10481 pf->hw.func_caps.fd_filters_best_effort, in i40e_get_capabilities()
10482 pf->hw.func_caps.num_tx_qp, in i40e_get_capabilities()
10483 pf->hw.func_caps.num_vsis); in i40e_get_capabilities()
10485 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10487 pf->hw.dev_caps.switch_mode, in i40e_get_capabilities()
10488 pf->hw.dev_caps.valid_functions); in i40e_get_capabilities()
10489 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10491 pf->hw.dev_caps.sr_iov_1_1, in i40e_get_capabilities()
10492 pf->hw.dev_caps.num_vfs); in i40e_get_capabilities()
10493 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10495 pf->hw.dev_caps.num_vsis, in i40e_get_capabilities()
10496 pf->hw.dev_caps.num_rx_qp, in i40e_get_capabilities()
10497 pf->hw.dev_caps.num_tx_qp); in i40e_get_capabilities()
10501 #define DEF_NUM_VSI (1 + (pf->hw.func_caps.fcoe ? 1 : 0) \ in i40e_get_capabilities()
10502 + pf->hw.func_caps.num_vfs) in i40e_get_capabilities()
10503 if (pf->hw.revision_id == 0 && in i40e_get_capabilities()
10504 pf->hw.func_caps.num_vsis < DEF_NUM_VSI) { in i40e_get_capabilities()
10505 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10507 pf->hw.func_caps.num_vsis, DEF_NUM_VSI); in i40e_get_capabilities()
10508 pf->hw.func_caps.num_vsis = DEF_NUM_VSI; in i40e_get_capabilities()
10518 * @pf: board private structure
10520 static void i40e_fdir_sb_setup(struct i40e_pf *pf) in i40e_fdir_sb_setup() argument
10527 if (!rd32(&pf->hw, I40E_GLQF_HKEY(0))) { in i40e_fdir_sb_setup()
10536 wr32(&pf->hw, I40E_GLQF_HKEY(i), hkey[i]); in i40e_fdir_sb_setup()
10539 if (!test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) in i40e_fdir_sb_setup()
10543 vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR); in i40e_fdir_sb_setup()
10547 main_vsi = i40e_pf_get_main_vsi(pf); in i40e_fdir_sb_setup()
10548 vsi = i40e_vsi_setup(pf, I40E_VSI_FDIR, main_vsi->seid, 0); in i40e_fdir_sb_setup()
10550 dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n"); in i40e_fdir_sb_setup()
10551 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_fdir_sb_setup()
10552 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_fdir_sb_setup()
10562 * @pf: board private structure
10564 static void i40e_fdir_teardown(struct i40e_pf *pf) in i40e_fdir_teardown() argument
10568 i40e_fdir_filter_exit(pf); in i40e_fdir_teardown()
10569 vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR); in i40e_fdir_teardown()
10576 * @vsi: PF main vsi
10585 struct i40e_pf *pf = vsi->back; in i40e_rebuild_cloud_filters() local
10590 hlist_for_each_entry_safe(cfilter, node, &pf->cloud_filter_list, in i40e_rebuild_cloud_filters()
10602 dev_dbg(&pf->pdev->dev, in i40e_rebuild_cloud_filters()
10605 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_rebuild_cloud_filters()
10614 * @vsi: PF main vsi
10690 * @pf: board private structure
10692 * Close up the VFs and other things in prep for PF Reset.
10694 static void i40e_prep_for_reset(struct i40e_pf *pf) in i40e_prep_for_reset() argument
10696 struct i40e_hw *hw = &pf->hw; in i40e_prep_for_reset()
10701 clear_bit(__I40E_RESET_INTR_RECEIVED, pf->state); in i40e_prep_for_reset()
10702 if (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_prep_for_reset()
10704 if (i40e_check_asq_alive(&pf->hw)) in i40e_prep_for_reset()
10705 i40e_vc_notify_reset(pf); in i40e_prep_for_reset()
10707 dev_dbg(&pf->pdev->dev, "Tearing down internal switch for reset\n"); in i40e_prep_for_reset()
10710 i40e_pf_quiesce_all_vsi(pf); in i40e_prep_for_reset()
10712 i40e_pf_for_each_vsi(pf, v, vsi) { in i40e_prep_for_reset()
10717 i40e_shutdown_adminq(&pf->hw); in i40e_prep_for_reset()
10723 dev_warn(&pf->pdev->dev, in i40e_prep_for_reset()
10730 i40e_ptp_save_hw_time(pf); in i40e_prep_for_reset()
10735 * @pf: PF struct
10737 static void i40e_send_version(struct i40e_pf *pf) in i40e_send_version() argument
10746 i40e_aq_send_driver_version(&pf->hw, &dv, NULL); in i40e_send_version()
10797 * i40e_reset - wait for core reset to finish reset, reset pf if corer not seen
10798 * @pf: board private structure
10800 static int i40e_reset(struct i40e_pf *pf) in i40e_reset() argument
10802 struct i40e_hw *hw = &pf->hw; in i40e_reset()
10807 dev_info(&pf->pdev->dev, "PF reset failed, %d\n", ret); in i40e_reset()
10808 set_bit(__I40E_RESET_FAILED, pf->state); in i40e_reset()
10809 clear_bit(__I40E_RESET_RECOVERY_PENDING, pf->state); in i40e_reset()
10811 pf->pfr_count++; in i40e_reset()
10818 * @pf: board private structure
10823 static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired) in i40e_rebuild() argument
10825 const bool is_recovery_mode_reported = i40e_check_recovery_mode(pf); in i40e_rebuild()
10826 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_rebuild()
10827 struct i40e_hw *hw = &pf->hw; in i40e_rebuild()
10833 if (test_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state) && in i40e_rebuild()
10837 if (test_bit(__I40E_DOWN, pf->state) && in i40e_rebuild()
10838 !test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_rebuild()
10840 dev_dbg(&pf->pdev->dev, "Rebuilding internal switch\n"); in i40e_rebuild()
10843 ret = i40e_init_adminq(&pf->hw); in i40e_rebuild()
10845 dev_info(&pf->pdev->dev, "Rebuild AdminQ failed, err %pe aq_err %s\n", in i40e_rebuild()
10846 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_rebuild()
10849 i40e_get_oem_version(&pf->hw); in i40e_rebuild()
10851 if (test_and_clear_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state)) { in i40e_rebuild()
10857 if (test_and_clear_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state)) in i40e_rebuild()
10858 i40e_verify_eeprom(pf); in i40e_rebuild()
10864 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_rebuild()
10865 if (i40e_get_capabilities(pf, in i40e_rebuild()
10873 if (i40e_setup_misc_vector_for_recovery_mode(pf)) in i40e_rebuild()
10882 free_irq(pf->pdev->irq, pf); in i40e_rebuild()
10883 i40e_clear_interrupt_scheme(pf); in i40e_rebuild()
10884 if (i40e_restore_interrupt_scheme(pf)) in i40e_rebuild()
10889 i40e_send_version(pf); in i40e_rebuild()
10898 ret = i40e_get_capabilities(pf, i40e_aqc_opc_list_func_capabilities); in i40e_rebuild()
10905 dev_info(&pf->pdev->dev, "init_lan_hmc failed: %d\n", ret); in i40e_rebuild()
10910 dev_info(&pf->pdev->dev, "configure_lan_hmc failed: %d\n", ret); in i40e_rebuild()
10919 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_rebuild()
10926 dev_warn(&pf->pdev->dev, in i40e_rebuild()
10928 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_rebuild()
10931 ret = i40e_init_pf_dcb(pf); in i40e_rebuild()
10933 dev_info(&pf->pdev->dev, "DCB init failed %d, disabled\n", in i40e_rebuild()
10935 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_rebuild()
10944 ret = i40e_setup_pf_switch(pf, reinit, true); in i40e_rebuild()
10951 ret = i40e_aq_set_phy_int_mask(&pf->hw, in i40e_rebuild()
10956 dev_info(&pf->pdev->dev, "set phy mask fail, err %pe aq_err %s\n", in i40e_rebuild()
10957 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_rebuild()
10964 * to recover minimal use by getting the basic PF VSI working. in i40e_rebuild()
10966 if (vsi->uplink_seid != pf->mac_seid) { in i40e_rebuild()
10967 dev_dbg(&pf->pdev->dev, "attempting to rebuild switch\n"); in i40e_rebuild()
10970 i40e_pf_for_each_veb(pf, v, veb) { in i40e_rebuild()
10977 * for minimal rebuild of PF VSI. in i40e_rebuild()
10981 if (veb->uplink_seid == pf->mac_seid) { in i40e_rebuild()
10982 dev_info(&pf->pdev->dev, in i40e_rebuild()
10983 "rebuild of switch failed: %d, will try to set up simple PF connection\n", in i40e_rebuild()
10985 vsi->uplink_seid = pf->mac_seid; in i40e_rebuild()
10988 dev_info(&pf->pdev->dev, in i40e_rebuild()
10995 if (vsi->uplink_seid == pf->mac_seid) { in i40e_rebuild()
10996 dev_dbg(&pf->pdev->dev, "attempting to rebuild PF VSI\n"); in i40e_rebuild()
11000 dev_info(&pf->pdev->dev, in i40e_rebuild()
11028 /* PF Main VSI is rebuild by now, go ahead and rebuild channel VSIs in i40e_rebuild()
11049 if (test_bit(I40E_HW_CAP_RESTART_AUTONEG, pf->hw.caps)) { in i40e_rebuild()
11051 ret = i40e_aq_set_link_restart_an(&pf->hw, true, NULL); in i40e_rebuild()
11053 dev_info(&pf->pdev->dev, "link restart failed, err %pe aq_err %s\n", in i40e_rebuild()
11055 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_rebuild()
11058 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_rebuild()
11059 ret = i40e_setup_misc_vector(pf); in i40e_rebuild()
11067 * PF/VF VSIs. in i40e_rebuild()
11070 i40e_add_filter_to_drop_tx_flow_control_frames(&pf->hw, in i40e_rebuild()
11071 pf->main_vsi_seid); in i40e_rebuild()
11074 i40e_pf_unquiesce_all_vsi(pf); in i40e_rebuild()
11081 ret = i40e_set_promiscuous(pf, pf->cur_promisc); in i40e_rebuild()
11083 dev_warn(&pf->pdev->dev, in i40e_rebuild()
11085 pf->cur_promisc ? "on" : "off", in i40e_rebuild()
11086 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_rebuild()
11088 i40e_reset_all_vfs(pf, true); in i40e_rebuild()
11091 i40e_send_version(pf); in i40e_rebuild()
11100 clear_bit(__I40E_RESET_FAILED, pf->state); in i40e_rebuild()
11102 clear_bit(__I40E_RESET_RECOVERY_PENDING, pf->state); in i40e_rebuild()
11103 clear_bit(__I40E_TIMEOUT_RECOVERY_PENDING, pf->state); in i40e_rebuild()
11108 * @pf: board private structure
11113 static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit, in i40e_reset_and_rebuild() argument
11118 if (test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_reset_and_rebuild()
11124 ret = i40e_reset(pf); in i40e_reset_and_rebuild()
11126 i40e_rebuild(pf, reinit, lock_acquired); in i40e_reset_and_rebuild()
11128 dev_err(&pf->pdev->dev, "%s: i40e_reset() FAILED", __func__); in i40e_reset_and_rebuild()
11132 * i40e_handle_reset_warning - prep for the PF to reset, reset and rebuild
11133 * @pf: board private structure
11140 static void i40e_handle_reset_warning(struct i40e_pf *pf, bool lock_acquired) in i40e_handle_reset_warning() argument
11142 i40e_prep_for_reset(pf); in i40e_handle_reset_warning()
11143 i40e_reset_and_rebuild(pf, false, lock_acquired); in i40e_handle_reset_warning()
11148 * @pf: board private structure
11152 static void i40e_print_vf_mdd_event(struct i40e_pf *pf, struct i40e_vf *vf, in i40e_print_vf_mdd_event() argument
11155 dev_err(&pf->pdev->dev, is_tx ? in i40e_print_vf_mdd_event()
11156 …"%lld Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pm. mdd-auto-reset-vfs=%s\… in i40e_print_vf_mdd_event()
11157 …"%lld Rx Malicious Driver Detection events detected on PF %d VF %d MAC %pm. mdd-auto-reset-vfs=%s\… in i40e_print_vf_mdd_event()
11159 pf->hw.pf_id, in i40e_print_vf_mdd_event()
11162 str_on_off(test_bit(I40E_FLAG_MDD_AUTO_RESET_VF, pf->flags))); in i40e_print_vf_mdd_event()
11167 * @pf: pointer to the PF structure
11171 static void i40e_print_vfs_mdd_events(struct i40e_pf *pf) in i40e_print_vfs_mdd_events() argument
11176 if (!test_and_clear_bit(__I40E_MDD_VF_PRINT_PENDING, pf->state)) in i40e_print_vfs_mdd_events()
11179 if (!__ratelimit(&pf->mdd_message_rate_limit)) in i40e_print_vfs_mdd_events()
11182 for (i = 0; i < pf->num_alloc_vfs; i++) { in i40e_print_vfs_mdd_events()
11183 struct i40e_vf *vf = &pf->vf[i]; in i40e_print_vfs_mdd_events()
11189 i40e_print_vf_mdd_event(pf, vf, false); in i40e_print_vfs_mdd_events()
11196 i40e_print_vf_mdd_event(pf, vf, true); in i40e_print_vfs_mdd_events()
11200 if (is_printed && !test_bit(I40E_FLAG_MDD_AUTO_RESET_VF, pf->flags)) in i40e_print_vfs_mdd_events()
11201 dev_info(&pf->pdev->dev, in i40e_print_vfs_mdd_events()
11202 "Use PF Control I/F to re-enable the VF #%d\n", in i40e_print_vfs_mdd_events()
11209 * @pf: pointer to the PF structure
11213 static void i40e_handle_mdd_event(struct i40e_pf *pf) in i40e_handle_mdd_event() argument
11215 struct i40e_hw *hw = &pf->hw; in i40e_handle_mdd_event()
11221 if (!test_and_clear_bit(__I40E_MDD_EVENT_PENDING, pf->state)) { in i40e_handle_mdd_event()
11225 i40e_print_vfs_mdd_events(pf); in i40e_handle_mdd_event()
11236 pf->hw.func_caps.base_queue; in i40e_handle_mdd_event()
11237 if (netif_msg_tx_err(pf)) in i40e_handle_mdd_event()
11238 …dev_info(&pf->pdev->dev, "Malicious Driver Detection event 0x%02x on TX queue %d PF number 0x%02x … in i40e_handle_mdd_event()
11248 pf->hw.func_caps.base_queue; in i40e_handle_mdd_event()
11249 if (netif_msg_rx_err(pf)) in i40e_handle_mdd_event()
11250 …dev_info(&pf->pdev->dev, "Malicious Driver Detection event 0x%02x on RX queue %d of function 0x%02… in i40e_handle_mdd_event()
11260 dev_dbg(&pf->pdev->dev, "TX driver issue detected on PF\n"); in i40e_handle_mdd_event()
11265 dev_dbg(&pf->pdev->dev, "RX driver issue detected on PF\n"); in i40e_handle_mdd_event()
11270 for (i = 0; i < pf->num_alloc_vfs && mdd_detected; i++) { in i40e_handle_mdd_event()
11274 vf = &(pf->vf[i]); in i40e_handle_mdd_event()
11277 set_bit(__I40E_MDD_VF_PRINT_PENDING, pf->state); in i40e_handle_mdd_event()
11286 set_bit(__I40E_MDD_VF_PRINT_PENDING, pf->state); in i40e_handle_mdd_event()
11294 test_bit(I40E_FLAG_MDD_AUTO_RESET_VF, pf->flags)) { in i40e_handle_mdd_event()
11299 i40e_print_vf_mdd_event(pf, vf, false); in i40e_handle_mdd_event()
11301 i40e_print_vf_mdd_event(pf, vf, true); in i40e_handle_mdd_event()
11312 i40e_print_vfs_mdd_events(pf); in i40e_handle_mdd_event()
11321 struct i40e_pf *pf = container_of(work, in i40e_service_task() local
11327 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_service_task()
11328 test_bit(__I40E_SUSPENDED, pf->state)) in i40e_service_task()
11331 if (test_and_set_bit(__I40E_SERVICE_SCHED, pf->state)) in i40e_service_task()
11334 if (!test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_service_task()
11335 i40e_detect_recover_hung(pf); in i40e_service_task()
11336 i40e_sync_filters_subtask(pf); in i40e_service_task()
11337 i40e_reset_subtask(pf); in i40e_service_task()
11338 i40e_handle_mdd_event(pf); in i40e_service_task()
11339 i40e_vc_process_vflr_event(pf); in i40e_service_task()
11340 i40e_watchdog_subtask(pf); in i40e_service_task()
11341 i40e_fdir_reinit_subtask(pf); in i40e_service_task()
11342 if (test_and_clear_bit(__I40E_CLIENT_RESET, pf->state)) { in i40e_service_task()
11344 i40e_notify_client_of_netdev_close(pf, true); in i40e_service_task()
11346 i40e_client_subtask(pf); in i40e_service_task()
11348 pf->state)) in i40e_service_task()
11349 i40e_notify_client_of_l2_param_changes(pf); in i40e_service_task()
11351 i40e_sync_filters_subtask(pf); in i40e_service_task()
11353 i40e_reset_subtask(pf); in i40e_service_task()
11356 i40e_clean_adminq_subtask(pf); in i40e_service_task()
11360 clear_bit(__I40E_SERVICE_SCHED, pf->state); in i40e_service_task()
11366 if (time_after(jiffies, (start_time + pf->service_timer_period)) || in i40e_service_task()
11367 test_bit(__I40E_ADMINQ_EVENT_PENDING, pf->state) || in i40e_service_task()
11368 test_bit(__I40E_MDD_EVENT_PENDING, pf->state) || in i40e_service_task()
11369 test_bit(__I40E_VFLR_EVENT_PENDING, pf->state)) in i40e_service_task()
11370 i40e_service_event_schedule(pf); in i40e_service_task()
11379 struct i40e_pf *pf = timer_container_of(pf, t, service_timer); in i40e_service_timer() local
11381 mod_timer(&pf->service_timer, in i40e_service_timer()
11382 round_jiffies(jiffies + pf->service_timer_period)); in i40e_service_timer()
11383 i40e_service_event_schedule(pf); in i40e_service_timer()
11392 struct i40e_pf *pf = vsi->back; in i40e_set_num_rings_in_vsi() local
11396 vsi->alloc_queue_pairs = pf->num_lan_qps; in i40e_set_num_rings_in_vsi()
11403 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_set_num_rings_in_vsi()
11404 vsi->num_q_vectors = pf->num_lan_msix; in i40e_set_num_rings_in_vsi()
11416 vsi->num_q_vectors = pf->num_fdsb_msix; in i40e_set_num_rings_in_vsi()
11420 vsi->alloc_queue_pairs = pf->num_vmdq_qps; in i40e_set_num_rings_in_vsi()
11427 vsi->num_q_vectors = pf->num_vmdq_msix; in i40e_set_num_rings_in_vsi()
11431 vsi->alloc_queue_pairs = pf->num_vf_qps; in i40e_set_num_rings_in_vsi()
11497 * i40e_vsi_mem_alloc - Allocates the next available struct vsi in the PF
11498 * @pf: board private structure
11502 * On success: returns vsi index in PF (positive)
11504 static int i40e_vsi_mem_alloc(struct i40e_pf *pf, enum i40e_vsi_type type) in i40e_vsi_mem_alloc() argument
11511 /* Need to protect the allocation of the VSIs at the PF level */ in i40e_vsi_mem_alloc()
11512 mutex_lock(&pf->switch_mutex); in i40e_vsi_mem_alloc()
11520 i = pf->next_vsi; in i40e_vsi_mem_alloc()
11521 while (i < pf->num_alloc_vsi && pf->vsi[i]) in i40e_vsi_mem_alloc()
11523 if (i >= pf->num_alloc_vsi) { in i40e_vsi_mem_alloc()
11525 while (i < pf->next_vsi && pf->vsi[i]) in i40e_vsi_mem_alloc()
11529 if (i < pf->num_alloc_vsi && !pf->vsi[i]) { in i40e_vsi_mem_alloc()
11535 pf->next_vsi = ++i; in i40e_vsi_mem_alloc()
11543 vsi->back = pf; in i40e_vsi_mem_alloc()
11549 pf->rss_table_size : 64; in i40e_vsi_mem_alloc()
11556 vsi->af_xdp_zc_qps = bitmap_zalloc(pf->num_lan_qps, GFP_KERNEL); in i40e_vsi_mem_alloc()
11574 pf->vsi[vsi_idx] = vsi; in i40e_vsi_mem_alloc()
11580 pf->next_vsi = i - 1; in i40e_vsi_mem_alloc()
11583 mutex_unlock(&pf->switch_mutex); in i40e_vsi_mem_alloc()
11631 struct i40e_pf *pf; in i40e_vsi_clear() local
11638 pf = vsi->back; in i40e_vsi_clear()
11640 mutex_lock(&pf->switch_mutex); in i40e_vsi_clear()
11641 if (!pf->vsi[vsi->idx]) { in i40e_vsi_clear()
11642 dev_err(&pf->pdev->dev, "pf->vsi[%d] is NULL, just free vsi[%d](type %d)\n", in i40e_vsi_clear()
11647 if (pf->vsi[vsi->idx] != vsi) { in i40e_vsi_clear()
11648 dev_err(&pf->pdev->dev, in i40e_vsi_clear()
11649 "pf->vsi[%d](type %d) != vsi[%d](type %d): no free!\n", in i40e_vsi_clear()
11650 pf->vsi[vsi->idx]->idx, in i40e_vsi_clear()
11651 pf->vsi[vsi->idx]->type, in i40e_vsi_clear()
11656 /* updates the PF for this cleared vsi */ in i40e_vsi_clear()
11657 i40e_put_lump(pf->qp_pile, vsi->base_queue, vsi->idx); in i40e_vsi_clear()
11658 i40e_put_lump(pf->irq_pile, vsi->base_vector, vsi->idx); in i40e_vsi_clear()
11664 pf->vsi[vsi->idx] = NULL; in i40e_vsi_clear()
11665 if (vsi->idx < pf->next_vsi) in i40e_vsi_clear()
11666 pf->next_vsi = vsi->idx; in i40e_vsi_clear()
11669 mutex_unlock(&pf->switch_mutex); in i40e_vsi_clear()
11702 struct i40e_pf *pf = vsi->back; in i40e_alloc_rings() local
11717 ring->dev = &pf->pdev->dev; in i40e_alloc_rings()
11723 ring->itr_setting = pf->tx_itr_default; in i40e_alloc_rings()
11734 ring->dev = &pf->pdev->dev; in i40e_alloc_rings()
11741 ring->itr_setting = pf->tx_itr_default; in i40e_alloc_rings()
11750 ring->dev = &pf->pdev->dev; in i40e_alloc_rings()
11754 ring->itr_setting = pf->rx_itr_default; in i40e_alloc_rings()
11767 * @pf: board private structure
11772 static int i40e_reserve_msix_vectors(struct i40e_pf *pf, int vectors) in i40e_reserve_msix_vectors() argument
11774 vectors = pci_enable_msix_range(pf->pdev, pf->msix_entries, in i40e_reserve_msix_vectors()
11777 dev_info(&pf->pdev->dev, in i40e_reserve_msix_vectors()
11787 * @pf: board private structure
11793 static int i40e_init_msix(struct i40e_pf *pf) in i40e_init_msix() argument
11795 struct i40e_hw *hw = &pf->hw; in i40e_init_msix()
11802 if (!test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_init_msix()
11829 /* reserve some vectors for the main PF traffic queues. Initially we in i40e_init_msix()
11837 pf->num_lan_msix = min_t(int, cpus, vectors_left / 2); in i40e_init_msix()
11838 vectors_left -= pf->num_lan_msix; in i40e_init_msix()
11841 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) { in i40e_init_msix()
11843 pf->num_fdsb_msix = 1; in i40e_init_msix()
11847 pf->num_fdsb_msix = 0; in i40e_init_msix()
11852 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_init_msix()
11853 iwarp_requested = pf->num_iwarp_msix; in i40e_init_msix()
11856 pf->num_iwarp_msix = 0; in i40e_init_msix()
11857 else if (vectors_left < pf->num_iwarp_msix) in i40e_init_msix()
11858 pf->num_iwarp_msix = 1; in i40e_init_msix()
11859 v_budget += pf->num_iwarp_msix; in i40e_init_msix()
11860 vectors_left -= pf->num_iwarp_msix; in i40e_init_msix()
11864 if (test_bit(I40E_FLAG_VMDQ_ENA, pf->flags)) { in i40e_init_msix()
11866 pf->num_vmdq_msix = 0; in i40e_init_msix()
11867 pf->num_vmdq_qps = 0; in i40e_init_msix()
11870 pf->num_vmdq_vsis * pf->num_vmdq_qps; in i40e_init_msix()
11877 * queues/vectors used by the PF later with the ethtool in i40e_init_msix()
11881 pf->num_vmdq_qps = 1; in i40e_init_msix()
11882 vmdq_vecs_wanted = pf->num_vmdq_vsis; in i40e_init_msix()
11887 pf->num_vmdq_msix = pf->num_vmdq_qps; in i40e_init_msix()
11903 extra_vectors = min_t(int, cpus - pf->num_lan_msix, vectors_left); in i40e_init_msix()
11904 pf->num_lan_msix += extra_vectors; in i40e_init_msix()
11910 v_budget += pf->num_lan_msix; in i40e_init_msix()
11911 pf->msix_entries = kcalloc(v_budget, sizeof(struct msix_entry), in i40e_init_msix()
11913 if (!pf->msix_entries) in i40e_init_msix()
11917 pf->msix_entries[i].entry = i; in i40e_init_msix()
11918 v_actual = i40e_reserve_msix_vectors(pf, v_budget); in i40e_init_msix()
11921 clear_bit(I40E_FLAG_MSIX_ENA, pf->flags); in i40e_init_msix()
11922 kfree(pf->msix_entries); in i40e_init_msix()
11923 pf->msix_entries = NULL; in i40e_init_msix()
11924 pci_disable_msix(pf->pdev); in i40e_init_msix()
11929 pf->num_vmdq_vsis = 0; in i40e_init_msix()
11930 pf->num_vmdq_qps = 0; in i40e_init_msix()
11931 pf->num_lan_qps = 1; in i40e_init_msix()
11932 pf->num_lan_msix = 1; in i40e_init_msix()
11942 dev_info(&pf->pdev->dev, in i40e_init_msix()
11949 pf->num_vmdq_msix = 1; /* force VMDqs to only one vector */ in i40e_init_msix()
11950 pf->num_vmdq_vsis = 1; in i40e_init_msix()
11951 pf->num_vmdq_qps = 1; in i40e_init_msix()
11956 pf->num_lan_msix = 1; in i40e_init_msix()
11959 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_init_msix()
11960 pf->num_lan_msix = 1; in i40e_init_msix()
11961 pf->num_iwarp_msix = 1; in i40e_init_msix()
11963 pf->num_lan_msix = 2; in i40e_init_msix()
11967 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_init_msix()
11968 pf->num_iwarp_msix = min_t(int, (vec / 3), in i40e_init_msix()
11970 pf->num_vmdq_vsis = min_t(int, (vec / 3), in i40e_init_msix()
11973 pf->num_vmdq_vsis = min_t(int, (vec / 2), in i40e_init_msix()
11976 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) { in i40e_init_msix()
11977 pf->num_fdsb_msix = 1; in i40e_init_msix()
11980 pf->num_lan_msix = min_t(int, in i40e_init_msix()
11981 (vec - (pf->num_iwarp_msix + pf->num_vmdq_vsis)), in i40e_init_msix()
11982 pf->num_lan_msix); in i40e_init_msix()
11983 pf->num_lan_qps = pf->num_lan_msix; in i40e_init_msix()
11988 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) && pf->num_fdsb_msix == 0) { in i40e_init_msix()
11989 dev_info(&pf->pdev->dev, "Sideband Flowdir disabled, not enough MSI-X vectors\n"); in i40e_init_msix()
11990 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_init_msix()
11991 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_init_msix()
11993 if (test_bit(I40E_FLAG_VMDQ_ENA, pf->flags) && pf->num_vmdq_msix == 0) { in i40e_init_msix()
11994 dev_info(&pf->pdev->dev, "VMDq disabled, not enough MSI-X vectors\n"); in i40e_init_msix()
11995 clear_bit(I40E_FLAG_VMDQ_ENA, pf->flags); in i40e_init_msix()
11998 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags) && in i40e_init_msix()
11999 pf->num_iwarp_msix == 0) { in i40e_init_msix()
12000 dev_info(&pf->pdev->dev, "IWARP disabled, not enough MSI-X vectors\n"); in i40e_init_msix()
12001 clear_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_init_msix()
12003 i40e_debug(&pf->hw, I40E_DEBUG_INIT, in i40e_init_msix()
12004 "MSI-X vector distribution: PF %d, VMDq %d, FDSB %d, iWARP %d\n", in i40e_init_msix()
12005 pf->num_lan_msix, in i40e_init_msix()
12006 pf->num_vmdq_msix * pf->num_vmdq_vsis, in i40e_init_msix()
12007 pf->num_fdsb_msix, in i40e_init_msix()
12008 pf->num_iwarp_msix); in i40e_init_msix()
12051 struct i40e_pf *pf = vsi->back; in i40e_vsi_alloc_q_vectors() local
12055 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_vsi_alloc_q_vectors()
12079 * @pf: board private structure to initialize
12081 static int i40e_init_interrupt_scheme(struct i40e_pf *pf) in i40e_init_interrupt_scheme() argument
12086 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_init_interrupt_scheme()
12087 vectors = i40e_init_msix(pf); in i40e_init_interrupt_scheme()
12089 clear_bit(I40E_FLAG_MSIX_ENA, pf->flags); in i40e_init_interrupt_scheme()
12090 clear_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_init_interrupt_scheme()
12091 clear_bit(I40E_FLAG_RSS_ENA, pf->flags); in i40e_init_interrupt_scheme()
12092 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_init_interrupt_scheme()
12093 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_init_interrupt_scheme()
12094 clear_bit(I40E_FLAG_SRIOV_ENA, pf->flags); in i40e_init_interrupt_scheme()
12095 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_init_interrupt_scheme()
12096 clear_bit(I40E_FLAG_FD_ATR_ENA, pf->flags); in i40e_init_interrupt_scheme()
12097 clear_bit(I40E_FLAG_VMDQ_ENA, pf->flags); in i40e_init_interrupt_scheme()
12098 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_init_interrupt_scheme()
12101 i40e_determine_queue_usage(pf); in i40e_init_interrupt_scheme()
12105 if (!test_bit(I40E_FLAG_MSIX_ENA, pf->flags) && in i40e_init_interrupt_scheme()
12106 test_bit(I40E_FLAG_MSI_ENA, pf->flags)) { in i40e_init_interrupt_scheme()
12107 dev_info(&pf->pdev->dev, "MSI-X not available, trying MSI\n"); in i40e_init_interrupt_scheme()
12108 vectors = pci_enable_msi(pf->pdev); in i40e_init_interrupt_scheme()
12110 dev_info(&pf->pdev->dev, "MSI init failed - %d\n", in i40e_init_interrupt_scheme()
12112 clear_bit(I40E_FLAG_MSI_ENA, pf->flags); in i40e_init_interrupt_scheme()
12117 if (!test_bit(I40E_FLAG_MSI_ENA, pf->flags) && in i40e_init_interrupt_scheme()
12118 !test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_init_interrupt_scheme()
12119 dev_info(&pf->pdev->dev, "MSI-X and MSI not available, falling back to Legacy IRQ\n"); in i40e_init_interrupt_scheme()
12123 pf->irq_pile = kzalloc(size, GFP_KERNEL); in i40e_init_interrupt_scheme()
12124 if (!pf->irq_pile) in i40e_init_interrupt_scheme()
12127 pf->irq_pile->num_entries = vectors; in i40e_init_interrupt_scheme()
12130 (void)i40e_get_lump(pf, pf->irq_pile, 1, I40E_PILE_VALID_BIT - 1); in i40e_init_interrupt_scheme()
12137 * @pf: private board data structure
12143 static int i40e_restore_interrupt_scheme(struct i40e_pf *pf) in i40e_restore_interrupt_scheme() argument
12152 set_bit(I40E_FLAG_MSI_ENA, pf->flags); in i40e_restore_interrupt_scheme()
12153 set_bit(I40E_FLAG_MSIX_ENA, pf->flags); in i40e_restore_interrupt_scheme()
12155 err = i40e_init_interrupt_scheme(pf); in i40e_restore_interrupt_scheme()
12162 i40e_pf_for_each_vsi(pf, i, vsi) { in i40e_restore_interrupt_scheme()
12170 err = i40e_setup_misc_vector(pf); in i40e_restore_interrupt_scheme()
12174 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) in i40e_restore_interrupt_scheme()
12175 i40e_client_update_msix_info(pf); in i40e_restore_interrupt_scheme()
12181 if (pf->vsi[i]) in i40e_restore_interrupt_scheme()
12182 i40e_vsi_free_q_vectors(pf->vsi[i]); in i40e_restore_interrupt_scheme()
12191 * @pf: board private structure
12198 static int i40e_setup_misc_vector_for_recovery_mode(struct i40e_pf *pf) in i40e_setup_misc_vector_for_recovery_mode() argument
12202 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_setup_misc_vector_for_recovery_mode()
12203 err = i40e_setup_misc_vector(pf); in i40e_setup_misc_vector_for_recovery_mode()
12206 dev_info(&pf->pdev->dev, in i40e_setup_misc_vector_for_recovery_mode()
12212 u32 flags = test_bit(I40E_FLAG_MSI_ENA, pf->flags) ? 0 : IRQF_SHARED; in i40e_setup_misc_vector_for_recovery_mode()
12214 err = request_irq(pf->pdev->irq, i40e_intr, flags, in i40e_setup_misc_vector_for_recovery_mode()
12215 pf->int_name, pf); in i40e_setup_misc_vector_for_recovery_mode()
12218 dev_info(&pf->pdev->dev, in i40e_setup_misc_vector_for_recovery_mode()
12223 i40e_enable_misc_int_causes(pf); in i40e_setup_misc_vector_for_recovery_mode()
12224 i40e_irq_dynamic_enable_icr0(pf); in i40e_setup_misc_vector_for_recovery_mode()
12232 * @pf: board private structure
12238 static int i40e_setup_misc_vector(struct i40e_pf *pf) in i40e_setup_misc_vector() argument
12240 struct i40e_hw *hw = &pf->hw; in i40e_setup_misc_vector()
12244 if (!test_and_set_bit(__I40E_MISC_IRQ_REQUESTED, pf->state)) { in i40e_setup_misc_vector()
12245 err = request_irq(pf->msix_entries[0].vector, in i40e_setup_misc_vector()
12246 i40e_intr, 0, pf->int_name, pf); in i40e_setup_misc_vector()
12248 clear_bit(__I40E_MISC_IRQ_REQUESTED, pf->state); in i40e_setup_misc_vector()
12249 dev_info(&pf->pdev->dev, in i40e_setup_misc_vector()
12251 pf->int_name, err); in i40e_setup_misc_vector()
12256 i40e_enable_misc_int_causes(pf); in i40e_setup_misc_vector()
12264 i40e_irq_dynamic_enable_icr0(pf); in i40e_setup_misc_vector()
12281 struct i40e_pf *pf = vsi->back; in i40e_get_rss_aq() local
12282 struct i40e_hw *hw = &pf->hw; in i40e_get_rss_aq()
12289 dev_info(&pf->pdev->dev, in i40e_get_rss_aq()
12292 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_get_rss_aq()
12302 dev_info(&pf->pdev->dev, in i40e_get_rss_aq()
12305 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_get_rss_aq()
12325 struct i40e_pf *pf = vsi->back; in i40e_config_rss_reg() local
12326 struct i40e_hw *hw = &pf->hw; in i40e_config_rss_reg()
12341 dev_err(&pf->pdev->dev, "Cannot set RSS seed - invalid VSI type\n"); in i40e_config_rss_reg()
12359 dev_err(&pf->pdev->dev, "Cannot set RSS LUT - invalid VSI type\n"); in i40e_config_rss_reg()
12379 struct i40e_pf *pf = vsi->back; in i40e_get_rss_reg() local
12380 struct i40e_hw *hw = &pf->hw; in i40e_get_rss_reg()
12412 struct i40e_pf *pf = vsi->back; in i40e_config_rss() local
12414 if (test_bit(I40E_HW_CAP_RSS_AQ, pf->hw.caps)) in i40e_config_rss()
12431 struct i40e_pf *pf = vsi->back; in i40e_get_rss() local
12433 if (test_bit(I40E_HW_CAP_RSS_AQ, pf->hw.caps)) in i40e_get_rss()
12441 * @pf: Pointer to board private structure
12446 void i40e_fill_rss_lut(struct i40e_pf *pf, u8 *lut, in i40e_fill_rss_lut() argument
12457 * @pf: board private structure
12459 static int i40e_pf_config_rss(struct i40e_pf *pf) in i40e_pf_config_rss() argument
12461 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_pf_config_rss()
12464 struct i40e_hw *hw = &pf->hw; in i40e_pf_config_rss()
12472 hena |= i40e_pf_get_default_rss_hashcfg(pf); in i40e_pf_config_rss()
12479 reg_val = (pf->rss_table_size == 512) ? in i40e_pf_config_rss()
12494 vsi->rss_size = min_t(int, pf->alloc_rss_size, qcount); in i40e_pf_config_rss()
12507 i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, vsi->rss_size); in i40e_pf_config_rss()
12524 * @pf: board private structure
12531 int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count) in i40e_reconfig_rss_queues() argument
12533 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_reconfig_rss_queues()
12536 if (!test_bit(I40E_FLAG_RSS_ENA, pf->flags)) in i40e_reconfig_rss_queues()
12540 new_rss_size = min_t(int, queue_count, pf->rss_size_max); in i40e_reconfig_rss_queues()
12546 i40e_prep_for_reset(pf); in i40e_reconfig_rss_queues()
12547 if (test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_reconfig_rss_queues()
12548 return pf->alloc_rss_size; in i40e_reconfig_rss_queues()
12550 pf->alloc_rss_size = new_rss_size; in i40e_reconfig_rss_queues()
12552 i40e_reset_and_rebuild(pf, true, true); in i40e_reconfig_rss_queues()
12559 dev_dbg(&pf->pdev->dev, in i40e_reconfig_rss_queues()
12565 vsi->rss_size = min_t(int, pf->alloc_rss_size, qcount); in i40e_reconfig_rss_queues()
12567 i40e_pf_config_rss(pf); in i40e_reconfig_rss_queues()
12569 dev_info(&pf->pdev->dev, "User requested queue count/HW max RSS count: %d/%d\n", in i40e_reconfig_rss_queues()
12570 vsi->req_queue_pairs, pf->rss_size_max); in i40e_reconfig_rss_queues()
12571 return pf->alloc_rss_size; in i40e_reconfig_rss_queues()
12575 * i40e_get_partition_bw_setting - Retrieve BW settings for this PF partition
12576 * @pf: board private structure
12578 int i40e_get_partition_bw_setting(struct i40e_pf *pf) in i40e_get_partition_bw_setting() argument
12584 status = i40e_read_bw_from_alt_ram(&pf->hw, &max_bw, &min_bw, in i40e_get_partition_bw_setting()
12589 pf->min_bw = min_bw; in i40e_get_partition_bw_setting()
12591 pf->max_bw = max_bw; in i40e_get_partition_bw_setting()
12598 * i40e_set_partition_bw_setting - Set BW settings for this PF partition
12599 * @pf: board private structure
12601 int i40e_set_partition_bw_setting(struct i40e_pf *pf) in i40e_set_partition_bw_setting() argument
12608 /* Set the valid bit for this PF */ in i40e_set_partition_bw_setting()
12609 bw_data.pf_valid_bits = cpu_to_le16(BIT(pf->hw.pf_id)); in i40e_set_partition_bw_setting()
12610 bw_data.max_bw[pf->hw.pf_id] = pf->max_bw & I40E_ALT_BW_VALUE_MASK; in i40e_set_partition_bw_setting()
12611 bw_data.min_bw[pf->hw.pf_id] = pf->min_bw & I40E_ALT_BW_VALUE_MASK; in i40e_set_partition_bw_setting()
12614 status = i40e_aq_configure_partition_bw(&pf->hw, &bw_data, NULL); in i40e_set_partition_bw_setting()
12621 * if total port shutdown feature is enabled for this PF
12622 * @pf: board private structure
12624 static bool i40e_is_total_port_shutdown_enabled(struct i40e_pf *pf) in i40e_is_total_port_shutdown_enabled() argument
12639 read_status = i40e_read_nvm_word(&pf->hw, in i40e_is_total_port_shutdown_enabled()
12644 read_status = i40e_read_nvm_word(&pf->hw, in i40e_is_total_port_shutdown_enabled()
12651 read_status = i40e_read_nvm_module_data(&pf->hw, in i40e_is_total_port_shutdown_enabled()
12659 link_behavior >>= (pf->hw.port * I40E_LINK_BEHAVIOR_PORT_BIT_LENGTH); in i40e_is_total_port_shutdown_enabled()
12665 dev_warn(&pf->pdev->dev, in i40e_is_total_port_shutdown_enabled()
12673 * @pf: board private structure to initialize
12679 static int i40e_sw_init(struct i40e_pf *pf) in i40e_sw_init() argument
12686 bitmap_zero(pf->flags, I40E_PF_FLAGS_NBITS); in i40e_sw_init()
12687 set_bit(I40E_FLAG_MSI_ENA, pf->flags); in i40e_sw_init()
12688 set_bit(I40E_FLAG_MSIX_ENA, pf->flags); in i40e_sw_init()
12691 pf->rx_itr_default = I40E_ITR_RX_DEF; in i40e_sw_init()
12692 pf->tx_itr_default = I40E_ITR_TX_DEF; in i40e_sw_init()
12694 /* Depending on PF configurations, it is possible that the RSS in i40e_sw_init()
12697 pf->rss_size_max = BIT(pf->hw.func_caps.rss_table_entry_width); in i40e_sw_init()
12698 pf->alloc_rss_size = 1; in i40e_sw_init()
12699 pf->rss_table_size = pf->hw.func_caps.rss_table_size; in i40e_sw_init()
12700 pf->rss_size_max = min_t(int, pf->rss_size_max, in i40e_sw_init()
12701 pf->hw.func_caps.num_tx_qp); in i40e_sw_init()
12705 pf->rss_size_max = min_t(int, pf->rss_size_max, pow); in i40e_sw_init()
12707 if (pf->hw.func_caps.rss) { in i40e_sw_init()
12708 set_bit(I40E_FLAG_RSS_ENA, pf->flags); in i40e_sw_init()
12709 pf->alloc_rss_size = min_t(int, pf->rss_size_max, in i40e_sw_init()
12714 if (pf->hw.func_caps.npar_enable || pf->hw.func_caps.flex10_enable) { in i40e_sw_init()
12715 set_bit(I40E_FLAG_MFP_ENA, pf->flags); in i40e_sw_init()
12716 dev_info(&pf->pdev->dev, "MFP mode Enabled\n"); in i40e_sw_init()
12717 if (i40e_get_partition_bw_setting(pf)) { in i40e_sw_init()
12718 dev_warn(&pf->pdev->dev, in i40e_sw_init()
12721 dev_info(&pf->pdev->dev, in i40e_sw_init()
12723 pf->min_bw, pf->max_bw); in i40e_sw_init()
12726 i40e_set_partition_bw_setting(pf); in i40e_sw_init()
12730 if ((pf->hw.func_caps.fd_filters_guaranteed > 0) || in i40e_sw_init()
12731 (pf->hw.func_caps.fd_filters_best_effort > 0)) { in i40e_sw_init()
12732 set_bit(I40E_FLAG_FD_ATR_ENA, pf->flags); in i40e_sw_init()
12733 if (test_bit(I40E_FLAG_MFP_ENA, pf->flags) && in i40e_sw_init()
12734 pf->hw.num_partitions > 1) in i40e_sw_init()
12735 dev_info(&pf->pdev->dev, in i40e_sw_init()
12738 set_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_sw_init()
12739 pf->fdir_pf_filter_count = in i40e_sw_init()
12740 pf->hw.func_caps.fd_filters_guaranteed; in i40e_sw_init()
12741 pf->hw.fdir_shared_filter_count = in i40e_sw_init()
12742 pf->hw.func_caps.fd_filters_best_effort; in i40e_sw_init()
12746 if (test_bit(I40E_HW_CAP_ATR_EVICT, pf->hw.caps)) in i40e_sw_init()
12747 set_bit(I40E_FLAG_HW_ATR_EVICT_ENA, pf->flags); in i40e_sw_init()
12749 if (pf->hw.func_caps.vmdq && num_online_cpus() != 1) { in i40e_sw_init()
12750 pf->num_vmdq_vsis = I40E_DEFAULT_NUM_VMDQ_VSI; in i40e_sw_init()
12751 set_bit(I40E_FLAG_VMDQ_ENA, pf->flags); in i40e_sw_init()
12752 pf->num_vmdq_qps = i40e_default_queues_per_vmdq(pf); in i40e_sw_init()
12755 if (pf->hw.func_caps.iwarp && num_online_cpus() != 1) { in i40e_sw_init()
12756 set_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_sw_init()
12758 pf->num_iwarp_msix = (int)num_online_cpus() + 1; in i40e_sw_init()
12765 if (pf->hw.mac.type == I40E_MAC_XL710 && in i40e_sw_init()
12766 pf->hw.func_caps.npar_enable) in i40e_sw_init()
12767 clear_bit(I40E_HW_CAP_FW_LLDP_STOPPABLE, pf->hw.caps); in i40e_sw_init()
12770 if (pf->hw.func_caps.num_vfs && pf->hw.partition_id == 1) { in i40e_sw_init()
12771 pf->num_vf_qps = I40E_DEFAULT_QUEUES_PER_VF; in i40e_sw_init()
12772 set_bit(I40E_FLAG_SRIOV_ENA, pf->flags); in i40e_sw_init()
12773 pf->num_req_vfs = min_t(int, in i40e_sw_init()
12774 pf->hw.func_caps.num_vfs, in i40e_sw_init()
12778 pf->lan_veb = I40E_NO_VEB; in i40e_sw_init()
12779 pf->lan_vsi = I40E_NO_VSI; in i40e_sw_init()
12782 clear_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags); in i40e_sw_init()
12786 + (sizeof(u16) * pf->hw.func_caps.num_tx_qp); in i40e_sw_init()
12787 pf->qp_pile = kzalloc(size, GFP_KERNEL); in i40e_sw_init()
12788 if (!pf->qp_pile) { in i40e_sw_init()
12792 pf->qp_pile->num_entries = pf->hw.func_caps.num_tx_qp; in i40e_sw_init()
12794 pf->tx_timeout_recovery_level = 1; in i40e_sw_init()
12796 if (pf->hw.mac.type != I40E_MAC_X722 && in i40e_sw_init()
12797 i40e_is_total_port_shutdown_enabled(pf)) { in i40e_sw_init()
12801 set_bit(I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags); in i40e_sw_init()
12802 set_bit(I40E_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags); in i40e_sw_init()
12803 dev_info(&pf->pdev->dev, in i40e_sw_init()
12806 mutex_init(&pf->switch_mutex); in i40e_sw_init()
12814 * @pf: board private structure to initialize
12819 bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features) in i40e_set_ntuple() argument
12828 if (!test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) in i40e_set_ntuple()
12833 if (pf->num_fdsb_msix > 0 && !pf->num_cloud_filters) { in i40e_set_ntuple()
12834 set_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_set_ntuple()
12835 clear_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_set_ntuple()
12839 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) { in i40e_set_ntuple()
12841 i40e_fdir_filter_exit(pf); in i40e_set_ntuple()
12843 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_set_ntuple()
12844 clear_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state); in i40e_set_ntuple()
12845 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_set_ntuple()
12848 pf->fd_add_err = 0; in i40e_set_ntuple()
12849 pf->fd_atr_cnt = 0; in i40e_set_ntuple()
12851 if (test_and_clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state)) in i40e_set_ntuple()
12852 if (test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags) && in i40e_set_ntuple()
12853 (I40E_DEBUG_FD & pf->hw.debug_mask)) in i40e_set_ntuple()
12854 dev_info(&pf->pdev->dev, "ATR re-enabled.\n"); in i40e_set_ntuple()
12865 struct i40e_pf *pf = vsi->back; in i40e_clear_rss_lut() local
12866 struct i40e_hw *hw = &pf->hw; in i40e_clear_rss_lut()
12877 dev_err(&pf->pdev->dev, "Cannot set RSS LUT - invalid VSI type\n"); in i40e_clear_rss_lut()
12882 * i40e_set_loopback - turn on/off loopback mode on underlying PF
12915 struct i40e_pf *pf = vsi->back; in i40e_set_features() local
12919 i40e_pf_config_rss(pf); in i40e_set_features()
12930 (netdev->features & NETIF_F_HW_TC) && pf->num_cloud_filters) { in i40e_set_features()
12931 dev_err(&pf->pdev->dev, in i40e_set_features()
12939 need_reset = i40e_set_ntuple(pf, features); in i40e_set_features()
12942 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_set_features()
12996 struct i40e_pf *pf = np->vsi->back; in i40e_get_phys_port_id() local
12997 struct i40e_hw *hw = &pf->hw; in i40e_get_phys_port_id()
12999 if (!test_bit(I40E_HW_CAP_PORT_ID_VALID, pf->hw.caps)) in i40e_get_phys_port_id()
13026 struct i40e_pf *pf = np->vsi->back; in i40e_ndo_fdb_add() local
13029 if (!test_bit(I40E_FLAG_SRIOV_ENA, pf->flags)) in i40e_ndo_fdb_add()
13069 * is to change the mode then that requires a PF reset to
13082 struct i40e_pf *pf = vsi->back; in i40e_ndo_bridge_setlink() local
13087 /* Only for PF VSI for now */ in i40e_ndo_bridge_setlink()
13091 /* Find the HW bridge for PF VSI */ in i40e_ndo_bridge_setlink()
13092 veb = i40e_pf_get_veb_by_seid(pf, vsi->uplink_seid); in i40e_ndo_bridge_setlink()
13107 veb = i40e_veb_setup(pf, vsi->uplink_seid, vsi->seid, in i40e_ndo_bridge_setlink()
13122 set_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags); in i40e_ndo_bridge_setlink()
13124 clear_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags); in i40e_ndo_bridge_setlink()
13125 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_ndo_bridge_setlink()
13152 struct i40e_pf *pf = vsi->back; in i40e_ndo_bridge_getlink() local
13155 /* Only for PF VSI for now */ in i40e_ndo_bridge_getlink()
13159 /* Find the HW bridge for the PF VSI */ in i40e_ndo_bridge_getlink()
13160 veb = i40e_pf_get_veb_by_seid(pf, vsi->uplink_seid); in i40e_ndo_bridge_getlink()
13236 struct i40e_pf *pf = vsi->back; in i40e_xdp_setup() local
13242 if (prog && test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_xdp_setup()
13254 i40e_prep_for_reset(pf); in i40e_xdp_setup()
13264 i40e_reset_and_rebuild(pf, true, true); in i40e_xdp_setup()
13303 struct i40e_pf *pf = vsi->back; in i40e_enter_busy_conf() local
13306 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_enter_busy_conf()
13322 struct i40e_pf *pf = vsi->back; in i40e_exit_busy_conf() local
13324 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_exit_busy_conf()
13397 struct i40e_pf *pf = vsi->back; in i40e_queue_pair_toggle_rings() local
13401 ret = i40e_control_wait_tx_q(vsi->seid, pf, pf_q, in i40e_queue_pair_toggle_rings()
13404 dev_info(&pf->pdev->dev, in i40e_queue_pair_toggle_rings()
13410 i40e_control_rx_q(pf, pf_q, enable); in i40e_queue_pair_toggle_rings()
13411 ret = i40e_pf_rxq_wait(pf, pf_q, enable); in i40e_queue_pair_toggle_rings()
13413 dev_info(&pf->pdev->dev, in i40e_queue_pair_toggle_rings()
13428 ret = i40e_control_wait_tx_q(vsi->seid, pf, in i40e_queue_pair_toggle_rings()
13432 dev_info(&pf->pdev->dev, in i40e_queue_pair_toggle_rings()
13448 struct i40e_pf *pf = vsi->back; in i40e_queue_pair_enable_irq() local
13449 struct i40e_hw *hw = &pf->hw; in i40e_queue_pair_enable_irq()
13452 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_queue_pair_enable_irq()
13455 i40e_irq_dynamic_enable_icr0(pf); in i40e_queue_pair_enable_irq()
13468 struct i40e_pf *pf = vsi->back; in i40e_queue_pair_disable_irq() local
13469 struct i40e_hw *hw = &pf->hw; in i40e_queue_pair_disable_irq()
13477 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_queue_pair_disable_irq()
13482 synchronize_irq(pf->msix_entries[intpf].vector); in i40e_queue_pair_disable_irq()
13488 synchronize_irq(pf->pdev->irq); in i40e_queue_pair_disable_irq()
13624 struct i40e_pf *pf = vsi->back; in i40e_config_netdev() local
13625 struct i40e_hw *hw = &pf->hw; in i40e_config_netdev()
13663 if (!test_bit(I40E_HW_CAP_OUTER_UDP_CSUM, pf->hw.caps)) in i40e_config_netdev()
13666 netdev->udp_tunnel_nic_info = &pf->udp_tunnel_nic; in i40e_config_netdev()
13699 if (!test_bit(I40E_FLAG_MFP_ENA, pf->flags)) in i40e_config_netdev()
13710 SET_NETDEV_DEV(netdev, &pf->pdev->dev); in i40e_config_netdev()
13738 struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); in i40e_config_netdev()
13813 struct i40e_pf *pf = vsi->back; in i40e_is_vsi_uplink_mode_veb() local
13819 veb = pf->veb[vsi->veb_idx]; in i40e_is_vsi_uplink_mode_veb()
13821 dev_info(&pf->pdev->dev, in i40e_is_vsi_uplink_mode_veb()
13848 struct i40e_pf *pf = vsi->back; in i40e_add_vsi() local
13849 struct i40e_hw *hw = &pf->hw; in i40e_add_vsi()
13861 /* The PF's main VSI is already setup as part of the in i40e_add_vsi()
13866 ctxt.seid = pf->main_vsi_seid; in i40e_add_vsi()
13867 ctxt.pf_num = pf->hw.pf_id; in i40e_add_vsi()
13869 ret = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL); in i40e_add_vsi()
13872 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13873 "couldn't get PF vsi config, err %pe aq_err %s\n", in i40e_add_vsi()
13875 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_add_vsi()
13884 enabled_tc = i40e_pf_get_tc_map(pf); in i40e_add_vsi()
13890 if (test_bit(I40E_FLAG_SOURCE_PRUNING_DIS, pf->flags)) { in i40e_add_vsi()
13892 ctxt.seid = pf->main_vsi_seid; in i40e_add_vsi()
13893 ctxt.pf_num = pf->hw.pf_id; in i40e_add_vsi()
13901 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13904 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_add_vsi()
13911 if (test_bit(I40E_FLAG_MFP_ENA, pf->flags) && in i40e_add_vsi()
13912 !(pf->hw.func_caps.iscsi)) { /* NIC type PF */ in i40e_add_vsi()
13914 ctxt.seid = pf->main_vsi_seid; in i40e_add_vsi()
13915 ctxt.pf_num = pf->hw.pf_id; in i40e_add_vsi()
13920 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13923 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_add_vsi()
13934 * For MFP case the iSCSI PF would use this in i40e_add_vsi()
13942 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13946 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_add_vsi()
13957 if (test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags) && in i40e_add_vsi()
14015 if (pf->vf[vsi->vf_id].spoofchk) { in i40e_add_vsi()
14040 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_add_vsi()
14062 set_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state); in i40e_add_vsi()
14068 dev_info(&pf->pdev->dev, in i40e_add_vsi()
14070 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_add_vsi()
14090 struct i40e_pf *pf; in i40e_vsi_release() local
14094 pf = vsi->back; in i40e_vsi_release()
14098 dev_info(&pf->pdev->dev, "VSI %d has existing VEB %d\n", in i40e_vsi_release()
14102 if (vsi->type == I40E_VSI_MAIN && !test_bit(__I40E_DOWN, pf->state)) { in i40e_vsi_release()
14103 dev_info(&pf->pdev->dev, "Can't remove PF VSI\n"); in i40e_vsi_release()
14123 i40e_devlink_destroy_port(pf); in i40e_vsi_release()
14158 veb = i40e_pf_get_veb_by_seid(pf, uplink_seid); in i40e_vsi_release()
14163 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_vsi_release()
14191 struct i40e_pf *pf = vsi->back; in i40e_vsi_setup_vectors() local
14194 dev_info(&pf->pdev->dev, "VSI %d has existing q_vectors\n", in i40e_vsi_setup_vectors()
14200 dev_info(&pf->pdev->dev, "VSI %d has non-zero base vector %d\n", in i40e_vsi_setup_vectors()
14207 dev_info(&pf->pdev->dev, in i40e_vsi_setup_vectors()
14217 if (!test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_vsi_setup_vectors()
14220 vsi->base_vector = i40e_get_lump(pf, pf->irq_pile, in i40e_vsi_setup_vectors()
14223 dev_info(&pf->pdev->dev, in i40e_vsi_setup_vectors()
14248 struct i40e_pf *pf; in i40e_vsi_reinit_setup() local
14254 pf = vsi->back; in i40e_vsi_reinit_setup()
14256 i40e_put_lump(pf->qp_pile, vsi->base_queue, vsi->idx); in i40e_vsi_reinit_setup()
14268 ret = i40e_get_lump(pf, pf->qp_pile, alloc_queue_pairs, vsi->idx); in i40e_vsi_reinit_setup()
14270 dev_info(&pf->pdev->dev, in i40e_vsi_reinit_setup()
14280 main_vsi = i40e_pf_get_main_vsi(pf); in i40e_vsi_reinit_setup()
14281 main_vsi->seid = pf->main_vsi_seid; in i40e_vsi_reinit_setup()
14285 i40e_rm_default_mac_filter(vsi, pf->hw.mac.perm_addr); in i40e_vsi_reinit_setup()
14305 i40e_devlink_destroy_port(pf); in i40e_vsi_reinit_setup()
14306 i40e_aq_delete_element(&pf->hw, vsi->seid, NULL); in i40e_vsi_reinit_setup()
14314 * @pf: board private structure
14325 struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type, in i40e_vsi_setup() argument
14335 * - the PF's port seid in i40e_vsi_setup()
14336 * no VEB is needed because this is the PF in i40e_vsi_setup()
14342 * - seid of the PF VSI, which is what creates the first VEB in i40e_vsi_setup()
14347 veb = i40e_pf_get_veb_by_seid(pf, uplink_seid); in i40e_vsi_setup()
14348 if (!veb && uplink_seid != pf->mac_seid) { in i40e_vsi_setup()
14349 vsi = i40e_pf_get_vsi_by_seid(pf, uplink_seid); in i40e_vsi_setup()
14351 dev_info(&pf->pdev->dev, "no such uplink_seid %d\n", in i40e_vsi_setup()
14356 if (vsi->uplink_seid == pf->mac_seid) in i40e_vsi_setup()
14357 veb = i40e_veb_setup(pf, pf->mac_seid, vsi->seid, in i40e_vsi_setup()
14360 veb = i40e_veb_setup(pf, vsi->uplink_seid, vsi->seid, in i40e_vsi_setup()
14372 if (!test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags)) { in i40e_vsi_setup()
14374 clear_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags); in i40e_vsi_setup()
14378 veb = i40e_pf_get_veb_by_seid(pf, vsi->uplink_seid); in i40e_vsi_setup()
14380 dev_info(&pf->pdev->dev, "couldn't add VEB\n"); in i40e_vsi_setup()
14389 v_idx = i40e_vsi_mem_alloc(pf, type); in i40e_vsi_setup()
14392 vsi = pf->vsi[v_idx]; in i40e_vsi_setup()
14399 pf->lan_vsi = v_idx; in i40e_vsi_setup()
14406 ret = i40e_get_lump(pf, pf->qp_pile, alloc_queue_pairs, vsi->idx); in i40e_vsi_setup()
14408 dev_info(&pf->pdev->dev, in i40e_vsi_setup()
14432 ret = i40e_devlink_create_port(pf); in i40e_vsi_setup()
14435 SET_NETDEV_DEVLINK_PORT(vsi->netdev, &pf->devlink_port); in i40e_vsi_setup()
14467 if (test_bit(I40E_HW_CAP_RSS_AQ, pf->hw.caps) && in i40e_vsi_setup()
14488 i40e_devlink_destroy_port(pf); in i40e_vsi_setup()
14490 i40e_aq_delete_element(&pf->hw, vsi->seid, NULL); in i40e_vsi_setup()
14507 struct i40e_pf *pf = veb->pf; in i40e_veb_get_bw_info() local
14508 struct i40e_hw *hw = &pf->hw; in i40e_veb_get_bw_info()
14516 dev_info(&pf->pdev->dev, in i40e_veb_get_bw_info()
14525 dev_info(&pf->pdev->dev, in i40e_veb_get_bw_info()
14549 * i40e_veb_mem_alloc - Allocates the next available struct veb in the PF
14550 * @pf: board private structure
14553 * On success: returns vsi index in PF (positive)
14555 static int i40e_veb_mem_alloc(struct i40e_pf *pf) in i40e_veb_mem_alloc() argument
14561 /* Need to protect the allocation of switch elements at the PF level */ in i40e_veb_mem_alloc()
14562 mutex_lock(&pf->switch_mutex); in i40e_veb_mem_alloc()
14571 while ((i < I40E_MAX_VEB) && (pf->veb[i] != NULL)) in i40e_veb_mem_alloc()
14583 veb->pf = pf; in i40e_veb_mem_alloc()
14587 pf->veb[i] = veb; in i40e_veb_mem_alloc()
14590 mutex_unlock(&pf->switch_mutex); in i40e_veb_mem_alloc()
14603 struct i40e_pf *pf = branch->pf; in i40e_switch_branch_release() local
14611 i40e_pf_for_each_veb(pf, i, veb) in i40e_switch_branch_release()
14620 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_switch_branch_release()
14630 if (pf->veb[veb_idx]) in i40e_switch_branch_release()
14631 i40e_veb_release(pf->veb[veb_idx]); in i40e_switch_branch_release()
14643 if (veb->pf) { in i40e_veb_clear()
14644 struct i40e_pf *pf = veb->pf; in i40e_veb_clear() local
14646 mutex_lock(&pf->switch_mutex); in i40e_veb_clear()
14647 if (pf->veb[veb->idx] == veb) in i40e_veb_clear()
14648 pf->veb[veb->idx] = NULL; in i40e_veb_clear()
14649 mutex_unlock(&pf->switch_mutex); in i40e_veb_clear()
14662 struct i40e_pf *pf; in i40e_veb_release() local
14665 pf = veb->pf; in i40e_veb_release()
14668 i40e_pf_for_each_vsi(pf, i, vsi_it) in i40e_veb_release()
14679 dev_info(&pf->pdev->dev, in i40e_veb_release()
14692 i40e_aq_delete_element(&pf->hw, veb->seid, NULL); in i40e_veb_release()
14703 struct i40e_pf *pf = veb->pf; in i40e_add_veb() local
14704 bool enable_stats = !!test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags); in i40e_add_veb()
14707 ret = i40e_aq_add_veb(&pf->hw, veb->uplink_seid, vsi ? vsi->seid : 0, in i40e_add_veb()
14713 dev_info(&pf->pdev->dev, in i40e_add_veb()
14715 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_add_veb()
14720 ret = i40e_aq_get_veb_parameters(&pf->hw, veb->seid, NULL, NULL, in i40e_add_veb()
14723 dev_info(&pf->pdev->dev, in i40e_add_veb()
14725 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_add_veb()
14730 dev_info(&pf->pdev->dev, in i40e_add_veb()
14732 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_add_veb()
14733 i40e_aq_delete_element(&pf->hw, veb->seid, NULL); in i40e_add_veb()
14748 * @pf: board private structure
14761 struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 uplink_seid, in i40e_veb_setup() argument
14772 dev_info(&pf->pdev->dev, in i40e_veb_setup()
14780 vsi = i40e_pf_get_vsi_by_seid(pf, vsi_seid); in i40e_veb_setup()
14782 dev_err(&pf->pdev->dev, "vsi seid %d not found\n", in i40e_veb_setup()
14789 veb_idx = i40e_veb_mem_alloc(pf); in i40e_veb_setup()
14792 veb = pf->veb[veb_idx]; in i40e_veb_setup()
14801 if (vsi && vsi->idx == pf->lan_vsi) in i40e_veb_setup()
14802 pf->lan_veb = veb->idx; in i40e_veb_setup()
14813 * i40e_setup_pf_switch_element - set PF vars based on switch type
14814 * @pf: board private structure
14821 static void i40e_setup_pf_switch_element(struct i40e_pf *pf, in i40e_setup_pf_switch_element() argument
14832 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch_element()
14838 pf->mac_seid = seid; in i40e_setup_pf_switch_element()
14842 if (uplink_seid != pf->mac_seid) in i40e_setup_pf_switch_element()
14844 veb = i40e_pf_get_main_veb(pf); in i40e_setup_pf_switch_element()
14849 veb = i40e_pf_get_veb_by_seid(pf, seid); in i40e_setup_pf_switch_element()
14851 pf->lan_veb = veb->idx; in i40e_setup_pf_switch_element()
14853 v = i40e_veb_mem_alloc(pf); in i40e_setup_pf_switch_element()
14856 pf->lan_veb = v; in i40e_setup_pf_switch_element()
14860 /* Try to get again main VEB as pf->lan_veb may have changed */ in i40e_setup_pf_switch_element()
14861 veb = i40e_pf_get_main_veb(pf); in i40e_setup_pf_switch_element()
14866 veb->uplink_seid = pf->mac_seid; in i40e_setup_pf_switch_element()
14867 veb->pf = pf; in i40e_setup_pf_switch_element()
14873 * the PF's VSI in i40e_setup_pf_switch_element()
14875 pf->mac_seid = uplink_seid; in i40e_setup_pf_switch_element()
14876 pf->main_vsi_seid = seid; in i40e_setup_pf_switch_element()
14878 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch_element()
14880 downlink_seid, pf->main_vsi_seid); in i40e_setup_pf_switch_element()
14891 dev_info(&pf->pdev->dev, "unknown element type=%d seid=%d\n", in i40e_setup_pf_switch_element()
14899 * @pf: board private structure
14905 int i40e_fetch_switch_configuration(struct i40e_pf *pf, bool printconfig) in i40e_fetch_switch_configuration() argument
14921 ret = i40e_aq_get_switch_config(&pf->hw, sw_config, in i40e_fetch_switch_configuration()
14925 dev_info(&pf->pdev->dev, in i40e_fetch_switch_configuration()
14927 ret, libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_fetch_switch_configuration()
14936 dev_info(&pf->pdev->dev, in i40e_fetch_switch_configuration()
14944 i40e_setup_pf_switch_element(pf, ele, num_reported, in i40e_fetch_switch_configuration()
14955 * @pf: board private structure
14961 static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired) in i40e_setup_pf_switch() argument
14968 ret = i40e_fetch_switch_configuration(pf, false); in i40e_setup_pf_switch()
14970 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch()
14972 ERR_PTR(ret), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_setup_pf_switch()
14975 i40e_pf_reset_stats(pf); in i40e_setup_pf_switch()
14983 if ((pf->hw.pf_id == 0) && in i40e_setup_pf_switch()
14984 !test_bit(I40E_FLAG_TRUE_PROMISC_ENA, pf->flags)) { in i40e_setup_pf_switch()
14986 pf->last_sw_conf_flags = flags; in i40e_setup_pf_switch()
14989 if (pf->hw.pf_id == 0) { in i40e_setup_pf_switch()
14993 ret = i40e_aq_set_switch_config(&pf->hw, flags, valid_flags, 0, in i40e_setup_pf_switch()
14995 if (ret && pf->hw.aq.asq_last_status != LIBIE_AQ_RC_ESRCH) { in i40e_setup_pf_switch()
14996 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch()
14999 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_setup_pf_switch()
15002 pf->last_sw_conf_valid_flags = valid_flags; in i40e_setup_pf_switch()
15006 main_vsi = i40e_pf_get_main_vsi(pf); in i40e_setup_pf_switch()
15011 /* Set up the PF VSI associated with the PF's main VSI in i40e_setup_pf_switch()
15014 veb = i40e_pf_get_main_veb(pf); in i40e_setup_pf_switch()
15018 uplink_seid = pf->mac_seid; in i40e_setup_pf_switch()
15020 main_vsi = i40e_vsi_setup(pf, I40E_VSI_MAIN, in i40e_setup_pf_switch()
15025 dev_info(&pf->pdev->dev, "setup of MAIN VSI failed\n"); in i40e_setup_pf_switch()
15026 i40e_cloud_filter_exit(pf); in i40e_setup_pf_switch()
15027 i40e_fdir_teardown(pf); in i40e_setup_pf_switch()
15032 main_vsi->seid = pf->main_vsi_seid; in i40e_setup_pf_switch()
15037 i40e_fdir_sb_setup(pf); in i40e_setup_pf_switch()
15039 /* Setup static PF queue filter control settings */ in i40e_setup_pf_switch()
15040 ret = i40e_setup_pf_filter_control(pf); in i40e_setup_pf_switch()
15042 dev_info(&pf->pdev->dev, "setup_pf_filter_control failed: %d\n", in i40e_setup_pf_switch()
15050 if (test_bit(I40E_FLAG_RSS_ENA, pf->flags)) in i40e_setup_pf_switch()
15051 i40e_pf_config_rss(pf); in i40e_setup_pf_switch()
15054 i40e_link_event(pf); in i40e_setup_pf_switch()
15056 i40e_ptp_init(pf); in i40e_setup_pf_switch()
15072 * @pf: board private structure
15074 static void i40e_determine_queue_usage(struct i40e_pf *pf) in i40e_determine_queue_usage() argument
15079 pf->num_lan_qps = 0; in i40e_determine_queue_usage()
15085 queues_left = pf->hw.func_caps.num_tx_qp; in i40e_determine_queue_usage()
15088 !test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_determine_queue_usage()
15089 /* one qp for PF, no queues for anything else */ in i40e_determine_queue_usage()
15091 pf->alloc_rss_size = pf->num_lan_qps = 1; in i40e_determine_queue_usage()
15094 clear_bit(I40E_FLAG_RSS_ENA, pf->flags); in i40e_determine_queue_usage()
15095 clear_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_determine_queue_usage()
15096 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_determine_queue_usage()
15097 clear_bit(I40E_FLAG_FD_ATR_ENA, pf->flags); in i40e_determine_queue_usage()
15098 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_determine_queue_usage()
15099 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_determine_queue_usage()
15100 clear_bit(I40E_FLAG_SRIOV_ENA, pf->flags); in i40e_determine_queue_usage()
15101 clear_bit(I40E_FLAG_VMDQ_ENA, pf->flags); in i40e_determine_queue_usage()
15102 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_determine_queue_usage()
15103 } else if (!test_bit(I40E_FLAG_RSS_ENA, pf->flags) && in i40e_determine_queue_usage()
15104 !test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) && in i40e_determine_queue_usage()
15105 !test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags) && in i40e_determine_queue_usage()
15106 !test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags)) { in i40e_determine_queue_usage()
15107 /* one qp for PF */ in i40e_determine_queue_usage()
15108 pf->alloc_rss_size = pf->num_lan_qps = 1; in i40e_determine_queue_usage()
15109 queues_left -= pf->num_lan_qps; in i40e_determine_queue_usage()
15111 clear_bit(I40E_FLAG_RSS_ENA, pf->flags); in i40e_determine_queue_usage()
15112 clear_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_determine_queue_usage()
15113 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_determine_queue_usage()
15114 clear_bit(I40E_FLAG_FD_ATR_ENA, pf->flags); in i40e_determine_queue_usage()
15115 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_determine_queue_usage()
15116 clear_bit(I40E_FLAG_VMDQ_ENA, pf->flags); in i40e_determine_queue_usage()
15117 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_determine_queue_usage()
15120 if (test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags) && in i40e_determine_queue_usage()
15122 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_determine_queue_usage()
15123 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_determine_queue_usage()
15124 dev_info(&pf->pdev->dev, "not enough queues for DCB. DCB is disabled.\n"); in i40e_determine_queue_usage()
15128 q_max = max_t(int, pf->rss_size_max, num_online_cpus()); in i40e_determine_queue_usage()
15129 q_max = min_t(int, q_max, pf->hw.func_caps.num_tx_qp); in i40e_determine_queue_usage()
15130 q_max = min_t(int, q_max, pf->hw.func_caps.num_msix_vectors); in i40e_determine_queue_usage()
15131 pf->num_lan_qps = q_max; in i40e_determine_queue_usage()
15133 queues_left -= pf->num_lan_qps; in i40e_determine_queue_usage()
15136 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) { in i40e_determine_queue_usage()
15140 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_determine_queue_usage()
15141 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_determine_queue_usage()
15142 …dev_info(&pf->pdev->dev, "not enough queues for Flow Director. Flow Director feature is disabled\n… in i40e_determine_queue_usage()
15146 if (test_bit(I40E_FLAG_SRIOV_ENA, pf->flags) && in i40e_determine_queue_usage()
15147 pf->num_vf_qps && pf->num_req_vfs && queues_left) { in i40e_determine_queue_usage()
15148 pf->num_req_vfs = min_t(int, pf->num_req_vfs, in i40e_determine_queue_usage()
15149 (queues_left / pf->num_vf_qps)); in i40e_determine_queue_usage()
15150 queues_left -= (pf->num_req_vfs * pf->num_vf_qps); in i40e_determine_queue_usage()
15153 if (test_bit(I40E_FLAG_VMDQ_ENA, pf->flags) && in i40e_determine_queue_usage()
15154 pf->num_vmdq_vsis && pf->num_vmdq_qps && queues_left) { in i40e_determine_queue_usage()
15155 pf->num_vmdq_vsis = min_t(int, pf->num_vmdq_vsis, in i40e_determine_queue_usage()
15156 (queues_left / pf->num_vmdq_qps)); in i40e_determine_queue_usage()
15157 queues_left -= (pf->num_vmdq_vsis * pf->num_vmdq_qps); in i40e_determine_queue_usage()
15160 pf->queues_left = queues_left; in i40e_determine_queue_usage()
15161 dev_dbg(&pf->pdev->dev, in i40e_determine_queue_usage()
15163 pf->hw.func_caps.num_tx_qp, in i40e_determine_queue_usage()
15164 !!test_bit(I40E_FLAG_FD_SB_ENA, pf->flags), in i40e_determine_queue_usage()
15165 pf->num_lan_qps, pf->alloc_rss_size, pf->num_req_vfs, in i40e_determine_queue_usage()
15166 pf->num_vf_qps, pf->num_vmdq_vsis, pf->num_vmdq_qps, in i40e_determine_queue_usage()
15171 * i40e_setup_pf_filter_control - Setup PF static filter control
15172 * @pf: PF to be setup
15174 * i40e_setup_pf_filter_control sets up a PF's initial filter control
15175 * settings. If PE/FCoE are enabled then it will also set the per PF
15177 * ethertype and macvlan type filter settings for the pf.
15181 static int i40e_setup_pf_filter_control(struct i40e_pf *pf) in i40e_setup_pf_filter_control() argument
15183 struct i40e_filter_control_settings *settings = &pf->filter_settings; in i40e_setup_pf_filter_control()
15188 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) || in i40e_setup_pf_filter_control()
15189 test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags)) in i40e_setup_pf_filter_control()
15192 /* Ethtype and MACVLAN filters enabled for PF */ in i40e_setup_pf_filter_control()
15196 if (i40e_set_filter_control(&pf->hw, settings)) in i40e_setup_pf_filter_control()
15204 static void i40e_print_features(struct i40e_pf *pf) in i40e_print_features() argument
15206 struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); in i40e_print_features()
15207 struct i40e_hw *hw = &pf->hw; in i40e_print_features()
15215 i = snprintf(buf, INFO_STRING_LEN, "Features: PF-id[%d]", hw->pf_id); in i40e_print_features()
15217 i += scnprintf(&buf[i], REMAIN(i), " VFs: %d", pf->num_req_vfs); in i40e_print_features()
15220 pf->hw.func_caps.num_vsis, main_vsi->num_queue_pairs); in i40e_print_features()
15221 if (test_bit(I40E_FLAG_RSS_ENA, pf->flags)) in i40e_print_features()
15223 if (test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags)) in i40e_print_features()
15225 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) { in i40e_print_features()
15229 if (test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags)) in i40e_print_features()
15233 if (test_bit(I40E_FLAG_PTP_ENA, pf->flags)) in i40e_print_features()
15235 if (test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags)) in i40e_print_features()
15240 dev_info(&pf->pdev->dev, "%s\n", buf); in i40e_print_features()
15248 * @pf: board private structure
15255 static void i40e_get_platform_mac_addr(struct pci_dev *pdev, struct i40e_pf *pf) in i40e_get_platform_mac_addr() argument
15257 if (eth_platform_get_mac_address(&pdev->dev, pf->hw.mac.addr)) in i40e_get_platform_mac_addr()
15258 i40e_get_mac_addr(&pf->hw, pf->hw.mac.addr); in i40e_get_platform_mac_addr()
15290 * @pf: board private structure
15297 static bool i40e_check_recovery_mode(struct i40e_pf *pf) in i40e_check_recovery_mode() argument
15299 u32 val = rd32(&pf->hw, I40E_GL_FWSTS); in i40e_check_recovery_mode()
15302 dev_crit(&pf->pdev->dev, "Firmware recovery mode detected. Limiting functionality.\n"); in i40e_check_recovery_mode()
15303 …dev_crit(&pf->pdev->dev, "Refer to the Intel(R) Ethernet Adapters and Devices User Guide for detai… in i40e_check_recovery_mode()
15304 set_bit(__I40E_RECOVERY_MODE, pf->state); in i40e_check_recovery_mode()
15308 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_check_recovery_mode()
15309 …dev_info(&pf->pdev->dev, "Please do Power-On Reset to initialize adapter in normal mode with full … in i40e_check_recovery_mode()
15316 * @pf: board private structure
15325 * state is to issue a series of pf-resets and check a return value.
15326 * If a PF reset returns success then the firmware could be in recovery
15335 static int i40e_pf_loop_reset(struct i40e_pf *pf) in i40e_pf_loop_reset() argument
15337 /* wait max 10 seconds for PF reset to succeed */ in i40e_pf_loop_reset()
15339 struct i40e_hw *hw = &pf->hw; in i40e_pf_loop_reset()
15349 pf->pfr_count++; in i40e_pf_loop_reset()
15351 dev_info(&pf->pdev->dev, "PF reset failed: %d\n", ret); in i40e_pf_loop_reset()
15358 * @pf: board private structure
15367 static bool i40e_check_fw_empr(struct i40e_pf *pf) in i40e_check_fw_empr() argument
15369 const u32 fw_sts = rd32(&pf->hw, I40E_GL_FWSTS) & in i40e_check_fw_empr()
15376 * i40e_handle_resets - handle EMP resets and PF resets
15377 * @pf: board private structure
15379 * Handle both EMP resets and PF resets and conclude whether there are
15386 static int i40e_handle_resets(struct i40e_pf *pf) in i40e_handle_resets() argument
15388 const int pfr = i40e_pf_loop_reset(pf); in i40e_handle_resets()
15389 const bool is_empr = i40e_check_fw_empr(pf); in i40e_handle_resets()
15392 …dev_crit(&pf->pdev->dev, "Entering recovery mode due to repeated FW resets. This may take several … in i40e_handle_resets()
15399 * @pf: board private structure
15407 static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw) in i40e_init_recovery_mode() argument
15413 pci_set_drvdata(pf->pdev, pf); in i40e_init_recovery_mode()
15414 pci_save_state(pf->pdev); in i40e_init_recovery_mode()
15417 timer_setup(&pf->service_timer, i40e_service_timer, 0); in i40e_init_recovery_mode()
15418 pf->service_timer_period = HZ; in i40e_init_recovery_mode()
15420 INIT_WORK(&pf->service_task, i40e_service_task); in i40e_init_recovery_mode()
15421 clear_bit(__I40E_SERVICE_SCHED, pf->state); in i40e_init_recovery_mode()
15423 err = i40e_init_interrupt_scheme(pf); in i40e_init_recovery_mode()
15432 if (pf->hw.func_caps.num_vsis < I40E_MIN_VSI_ALLOC) in i40e_init_recovery_mode()
15433 pf->num_alloc_vsi = I40E_MIN_VSI_ALLOC; in i40e_init_recovery_mode()
15435 pf->num_alloc_vsi = pf->hw.func_caps.num_vsis; in i40e_init_recovery_mode()
15437 /* Set up the vsi struct and our local tracking of the MAIN PF vsi. */ in i40e_init_recovery_mode()
15438 pf->vsi = kcalloc(pf->num_alloc_vsi, sizeof(struct i40e_vsi *), in i40e_init_recovery_mode()
15440 if (!pf->vsi) { in i40e_init_recovery_mode()
15448 v_idx = i40e_vsi_mem_alloc(pf, I40E_VSI_MAIN); in i40e_init_recovery_mode()
15453 pf->lan_vsi = v_idx; in i40e_init_recovery_mode()
15454 vsi = pf->vsi[v_idx]; in i40e_init_recovery_mode()
15467 i40e_dbg_pf_init(pf); in i40e_init_recovery_mode()
15469 err = i40e_setup_misc_vector_for_recovery_mode(pf); in i40e_init_recovery_mode()
15474 i40e_send_version(pf); in i40e_init_recovery_mode()
15477 mod_timer(&pf->service_timer, in i40e_init_recovery_mode()
15478 round_jiffies(jiffies + pf->service_timer_period)); in i40e_init_recovery_mode()
15483 i40e_reset_interrupt_capability(pf); in i40e_init_recovery_mode()
15484 timer_shutdown_sync(&pf->service_timer); in i40e_init_recovery_mode()
15487 pci_release_mem_regions(pf->pdev); in i40e_init_recovery_mode()
15488 pci_disable_device(pf->pdev); in i40e_init_recovery_mode()
15489 i40e_free_pf(pf); in i40e_init_recovery_mode()
15503 struct i40e_pf *pf = i40e_hw_to_pf(hw); in i40e_set_subsystem_device_id() local
15505 hw->subsystem_device_id = pf->pdev->subsystem_device ? in i40e_set_subsystem_device_id()
15506 pf->pdev->subsystem_device : in i40e_set_subsystem_device_id()
15515 * i40e_probe initializes a PF identified by a pci_dev structure.
15516 * The OS initialization, configuring of the PF private structure,
15528 struct i40e_pf *pf; in i40e_probe() local
15566 pf = i40e_alloc_pf(&pdev->dev); in i40e_probe()
15567 if (!pf) { in i40e_probe()
15571 pf->next_vsi = 0; in i40e_probe()
15572 pf->pdev = pdev; in i40e_probe()
15573 set_bit(__I40E_DOWN, pf->state); in i40e_probe()
15575 hw = &pf->hw; in i40e_probe()
15577 pf->ioremap_len = min_t(int, pci_resource_len(pdev, 0), in i40e_probe()
15584 if (pf->ioremap_len < I40E_GLGEN_STAT_CLEAR) { in i40e_probe()
15586 pf->ioremap_len); in i40e_probe()
15590 hw->hw_addr = ioremap(pci_resource_start(pdev, 0), pf->ioremap_len); in i40e_probe()
15595 pf->ioremap_len, err); in i40e_probe()
15614 INIT_LIST_HEAD(&pf->l3_flex_pit_list); in i40e_probe()
15615 INIT_LIST_HEAD(&pf->l4_flex_pit_list); in i40e_probe()
15616 INIT_LIST_HEAD(&pf->ddp_old_prof); in i40e_probe()
15624 pf->msg_enable = netif_msg_init(debug, in i40e_probe()
15629 pf->hw.debug_mask = debug; in i40e_probe()
15637 pf->corer_count++; in i40e_probe()
15642 /* Reset here to make sure all is clean and to define PF 'n' */ in i40e_probe()
15652 err = i40e_handle_resets(pf); in i40e_probe()
15656 i40e_check_recovery_mode(pf); in i40e_probe()
15668 snprintf(pf->int_name, sizeof(pf->int_name) - 1, in i40e_probe()
15670 dev_driver_string(&pf->pdev->dev), dev_name(&pdev->dev)); in i40e_probe()
15680 pf->hw.fc.requested_mode = I40E_FC_NONE; in i40e_probe()
15724 i40e_verify_eeprom(pf); in i40e_probe()
15732 err = i40e_get_capabilities(pf, i40e_aqc_opc_list_func_capabilities); in i40e_probe()
15736 err = i40e_sw_init(pf); in i40e_probe()
15742 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_probe()
15743 return i40e_init_recovery_mode(pf, hw); in i40e_probe()
15763 if (test_bit(I40E_HW_CAP_STOP_FW_LLDP, pf->hw.caps)) { in i40e_probe()
15769 i40e_get_platform_mac_addr(pdev, pf); in i40e_probe()
15780 set_bit(I40E_HW_CAP_PORT_ID_VALID, pf->hw.caps); in i40e_probe()
15782 i40e_ptp_alloc_pins(pf); in i40e_probe()
15783 pci_set_drvdata(pdev, pf); in i40e_probe()
15787 status = i40e_get_fw_lldp_status(&pf->hw, &lldp_status); in i40e_probe()
15790 (clear_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags)) : in i40e_probe()
15791 (set_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags)); in i40e_probe()
15793 test_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags) ? in i40e_probe()
15800 err = i40e_init_pf_dcb(pf); in i40e_probe()
15803 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_probe()
15804 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_probe()
15810 timer_setup(&pf->service_timer, i40e_service_timer, 0); in i40e_probe()
15811 pf->service_timer_period = HZ; in i40e_probe()
15813 INIT_WORK(&pf->service_task, i40e_service_task); in i40e_probe()
15814 clear_bit(__I40E_SERVICE_SCHED, pf->state); in i40e_probe()
15819 pf->wol_en = false; in i40e_probe()
15821 pf->wol_en = true; in i40e_probe()
15822 device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en); in i40e_probe()
15825 i40e_determine_queue_usage(pf); in i40e_probe()
15826 err = i40e_init_interrupt_scheme(pf); in i40e_probe()
15832 * pairs than MSI-X vectors (pf->num_lan_msix) exist. Thus in i40e_probe()
15833 * vsi->num_queue_pairs will be equal to pf->num_lan_msix, i.e., 1. in i40e_probe()
15836 pf->num_lan_msix = 1; in i40e_probe()
15838 pf->udp_tunnel_nic.set_port = i40e_udp_tunnel_set_port; in i40e_probe()
15839 pf->udp_tunnel_nic.unset_port = i40e_udp_tunnel_unset_port; in i40e_probe()
15840 pf->udp_tunnel_nic.shared = &pf->udp_tunnel_shared; in i40e_probe()
15841 pf->udp_tunnel_nic.tables[0].n_entries = I40E_MAX_PF_UDP_OFFLOAD_PORTS; in i40e_probe()
15842 pf->udp_tunnel_nic.tables[0].tunnel_types = UDP_TUNNEL_TYPE_VXLAN | in i40e_probe()
15850 if (pf->hw.func_caps.num_vsis < I40E_MIN_VSI_ALLOC) in i40e_probe()
15851 pf->num_alloc_vsi = I40E_MIN_VSI_ALLOC; in i40e_probe()
15853 pf->num_alloc_vsi = pf->hw.func_caps.num_vsis; in i40e_probe()
15854 if (pf->num_alloc_vsi > UDP_TUNNEL_NIC_MAX_SHARING_DEVICES) { in i40e_probe()
15855 dev_warn(&pf->pdev->dev, in i40e_probe()
15857 pf->num_alloc_vsi, UDP_TUNNEL_NIC_MAX_SHARING_DEVICES); in i40e_probe()
15858 pf->num_alloc_vsi = UDP_TUNNEL_NIC_MAX_SHARING_DEVICES; in i40e_probe()
15861 /* Set up the *vsi struct and our local tracking of the MAIN PF vsi. */ in i40e_probe()
15862 pf->vsi = kcalloc(pf->num_alloc_vsi, sizeof(struct i40e_vsi *), in i40e_probe()
15864 if (!pf->vsi) { in i40e_probe()
15871 if (test_bit(I40E_FLAG_SRIOV_ENA, pf->flags) && in i40e_probe()
15872 test_bit(I40E_FLAG_MSIX_ENA, pf->flags) && in i40e_probe()
15873 !test_bit(__I40E_BAD_EEPROM, pf->state)) { in i40e_probe()
15875 set_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags); in i40e_probe()
15878 err = i40e_setup_pf_switch(pf, false, false); in i40e_probe()
15884 vsi = i40e_pf_get_main_vsi(pf); in i40e_probe()
15888 vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR); in i40e_probe()
15895 err = i40e_aq_set_phy_int_mask(&pf->hw, in i40e_probe()
15900 dev_info(&pf->pdev->dev, "set phy mask fail, err %pe aq_err %s\n", in i40e_probe()
15901 ERR_PTR(err), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_probe()
15904 ratelimit_state_init(&pf->mdd_message_rate_limit, 1 * HZ, 1); in i40e_probe()
15917 if (test_bit(I40E_HW_CAP_RESTART_AUTONEG, pf->hw.caps)) { in i40e_probe()
15919 err = i40e_aq_set_link_restart_an(&pf->hw, true, NULL); in i40e_probe()
15921 dev_info(&pf->pdev->dev, "link restart failed, err %pe aq_err %s\n", in i40e_probe()
15923 libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_probe()
15929 clear_bit(__I40E_DOWN, pf->state); in i40e_probe()
15936 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_probe()
15937 err = i40e_setup_misc_vector(pf); in i40e_probe()
15941 i40e_cloud_filter_exit(pf); in i40e_probe()
15942 i40e_fdir_teardown(pf); in i40e_probe()
15949 if (test_bit(I40E_FLAG_SRIOV_ENA, pf->flags) && in i40e_probe()
15950 test_bit(I40E_FLAG_MSIX_ENA, pf->flags) && in i40e_probe()
15951 !test_bit(__I40E_BAD_EEPROM, pf->state)) { in i40e_probe()
15961 err = i40e_alloc_vfs(pf, pci_num_vf(pdev)); in i40e_probe()
15970 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_probe()
15971 pf->iwarp_base_vector = i40e_get_lump(pf, pf->irq_pile, in i40e_probe()
15972 pf->num_iwarp_msix, in i40e_probe()
15974 if (pf->iwarp_base_vector < 0) { in i40e_probe()
15977 pf->num_iwarp_msix, pf->iwarp_base_vector); in i40e_probe()
15978 clear_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_probe()
15982 i40e_dbg_pf_init(pf); in i40e_probe()
15985 i40e_send_version(pf); in i40e_probe()
15988 mod_timer(&pf->service_timer, in i40e_probe()
15989 round_jiffies(jiffies + pf->service_timer_period)); in i40e_probe()
15991 /* add this PF to client device list and launch a client service task */ in i40e_probe()
15992 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_probe()
15993 err = i40e_lan_add_device(pf); in i40e_probe()
15995 dev_info(&pdev->dev, "Failed to add PF to client API service list: %d\n", in i40e_probe()
16005 if (!test_bit(I40E_HW_CAP_NO_PCI_LINK_CHECK, pf->hw.caps)) { in i40e_probe()
16012 pcie_capability_read_word(pf->pdev, PCI_EXP_LNKSTA, in i40e_probe()
16053 dev_dbg(&pf->pdev->dev, "get requested speeds ret = %pe last_status = %s\n", in i40e_probe()
16054 ERR_PTR(err), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_probe()
16055 pf->hw.phy.link_info.requested_speeds = abilities.link_speed; in i40e_probe()
16058 i40e_set_fec_in_flags(abilities.fec_cfg_curr_mod_ext_info, pf->flags); in i40e_probe()
16063 dev_dbg(&pf->pdev->dev, "get supported phy types ret = %pe last_status = %s\n", in i40e_probe()
16064 ERR_PTR(err), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_probe()
16071 ERR_PTR(err), libie_aq_str(pf->hw.aq.asq_last_status)); in i40e_probe()
16081 * PF/VF VSIs. in i40e_probe()
16084 i40e_add_filter_to_drop_tx_flow_control_frames(&pf->hw, in i40e_probe()
16085 pf->main_vsi_seid); in i40e_probe()
16087 if ((pf->hw.device_id == I40E_DEV_ID_10G_BASE_T) || in i40e_probe()
16088 (pf->hw.device_id == I40E_DEV_ID_10G_BASE_T4)) in i40e_probe()
16089 set_bit(I40E_HW_CAP_PHY_CONTROLS_LEDS, pf->hw.caps); in i40e_probe()
16090 if (pf->hw.device_id == I40E_DEV_ID_SFP_I_X722) in i40e_probe()
16091 set_bit(I40E_HW_CAP_CRT_RETIMER, pf->hw.caps); in i40e_probe()
16093 i40e_print_features(pf); in i40e_probe()
16095 i40e_devlink_register(pf); in i40e_probe()
16101 set_bit(__I40E_DOWN, pf->state); in i40e_probe()
16102 i40e_clear_interrupt_scheme(pf); in i40e_probe()
16103 kfree(pf->vsi); in i40e_probe()
16105 i40e_reset_interrupt_capability(pf); in i40e_probe()
16106 timer_shutdown_sync(&pf->service_timer); in i40e_probe()
16111 kfree(pf->qp_pile); in i40e_probe()
16117 i40e_free_pf(pf); in i40e_probe()
16137 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_remove() local
16138 struct i40e_hw *hw = &pf->hw; in i40e_remove()
16144 i40e_devlink_unregister(pf); in i40e_remove()
16146 i40e_dbg_pf_exit(pf); in i40e_remove()
16148 i40e_ptp_stop(pf); in i40e_remove()
16158 while (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_remove()
16160 set_bit(__I40E_IN_REMOVE, pf->state); in i40e_remove()
16162 if (test_bit(I40E_FLAG_SRIOV_ENA, pf->flags)) { in i40e_remove()
16163 set_bit(__I40E_VF_RESETS_DISABLED, pf->state); in i40e_remove()
16164 i40e_free_vfs(pf); in i40e_remove()
16165 clear_bit(I40E_FLAG_SRIOV_ENA, pf->flags); in i40e_remove()
16168 set_bit(__I40E_SUSPENDED, pf->state); in i40e_remove()
16169 set_bit(__I40E_DOWN, pf->state); in i40e_remove()
16170 if (pf->service_timer.function) in i40e_remove()
16171 timer_shutdown_sync(&pf->service_timer); in i40e_remove()
16172 if (pf->service_task.func) in i40e_remove()
16173 cancel_work_sync(&pf->service_task); in i40e_remove()
16175 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_remove()
16176 struct i40e_vsi *vsi = pf->vsi[0]; in i40e_remove()
16178 /* We know that we have allocated only one vsi for this PF, in i40e_remove()
16191 i40e_notify_client_of_netdev_close(pf, false); in i40e_remove()
16193 i40e_fdir_teardown(pf); in i40e_remove()
16196 * This will leave only the PF's VSI remaining. in i40e_remove()
16198 i40e_pf_for_each_veb(pf, i, veb) in i40e_remove()
16199 if (veb->uplink_seid == pf->mac_seid || in i40e_remove()
16203 /* Now we can shutdown the PF's VSIs, just before we kill in i40e_remove()
16206 i40e_pf_for_each_vsi(pf, i, vsi) { in i40e_remove()
16209 pf->vsi[i] = NULL; in i40e_remove()
16212 i40e_cloud_filter_exit(pf); in i40e_remove()
16215 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_remove()
16216 ret_code = i40e_lan_del_device(pf); in i40e_remove()
16233 if (test_bit(__I40E_RECOVERY_MODE, pf->state) && in i40e_remove()
16234 !test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_remove()
16235 free_irq(pf->pdev->irq, pf); in i40e_remove()
16246 i40e_clear_interrupt_scheme(pf); in i40e_remove()
16247 i40e_pf_for_each_vsi(pf, i, vsi) { in i40e_remove()
16248 if (!test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_remove()
16252 pf->vsi[i] = NULL; in i40e_remove()
16256 i40e_pf_for_each_veb(pf, i, veb) { in i40e_remove()
16258 pf->veb[i] = NULL; in i40e_remove()
16261 kfree(pf->qp_pile); in i40e_remove()
16262 kfree(pf->vsi); in i40e_remove()
16265 i40e_free_pf(pf); in i40e_remove()
16274 * @pf: pointer to i40e_pf struct
16276 static void i40e_enable_mc_magic_wake(struct i40e_pf *pf) in i40e_enable_mc_magic_wake() argument
16278 struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); in i40e_enable_mc_magic_wake()
16279 struct i40e_hw *hw = &pf->hw; in i40e_enable_mc_magic_wake()
16288 dev_err(&pf->pdev->dev, in i40e_enable_mc_magic_wake()
16304 dev_err(&pf->pdev->dev, in i40e_enable_mc_magic_wake()
16314 dev_err(&pf->pdev->dev, in i40e_enable_mc_magic_wake()
16320 * @pf: pointer to i40e_pf struct
16323 static int i40e_io_suspend(struct i40e_pf *pf) in i40e_io_suspend() argument
16325 struct i40e_hw *hw = &pf->hw; in i40e_io_suspend()
16327 set_bit(__I40E_DOWN, pf->state); in i40e_io_suspend()
16330 timer_delete_sync(&pf->service_timer); in i40e_io_suspend()
16331 cancel_work_sync(&pf->service_task); in i40e_io_suspend()
16336 i40e_notify_client_of_netdev_close(pf, false); in i40e_io_suspend()
16338 if (test_bit(I40E_HW_CAP_WOL_MC_MAGIC_PKT_WAKE, pf->hw.caps) && in i40e_io_suspend()
16339 pf->wol_en) in i40e_io_suspend()
16340 i40e_enable_mc_magic_wake(pf); in i40e_io_suspend()
16348 i40e_prep_for_reset(pf); in i40e_io_suspend()
16350 wr32(hw, I40E_PFPM_APM, (pf->wol_en ? I40E_PFPM_APM_APME_MASK : 0)); in i40e_io_suspend()
16351 wr32(hw, I40E_PFPM_WUFC, (pf->wol_en ? I40E_PFPM_WUFC_MAG_MASK : 0)); in i40e_io_suspend()
16358 i40e_clear_interrupt_scheme(pf); in i40e_io_suspend()
16367 * @pf: pointer to i40e_pf struct
16370 static int i40e_io_resume(struct i40e_pf *pf) in i40e_io_resume() argument
16372 struct device *dev = &pf->pdev->dev; in i40e_io_resume()
16383 err = i40e_restore_interrupt_scheme(pf); in i40e_io_resume()
16389 clear_bit(__I40E_DOWN, pf->state); in i40e_io_resume()
16390 i40e_reset_and_rebuild(pf, false, true); in i40e_io_resume()
16395 clear_bit(__I40E_SUSPENDED, pf->state); in i40e_io_resume()
16398 mod_timer(&pf->service_timer, in i40e_io_resume()
16399 round_jiffies(jiffies + pf->service_timer_period)); in i40e_io_resume()
16416 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_detected() local
16420 if (!pf) { in i40e_pci_error_detected()
16427 if (!test_bit(__I40E_SUSPENDED, pf->state)) in i40e_pci_error_detected()
16428 i40e_io_suspend(pf); in i40e_pci_error_detected()
16445 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_slot_reset() local
16461 reg = rd32(&pf->hw, I40E_GLGEN_RTRIG); in i40e_pci_error_slot_reset()
16477 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_reset_prepare() local
16479 i40e_prep_for_reset(pf); in i40e_pci_error_reset_prepare()
16488 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_reset_done() local
16490 if (test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_pci_error_reset_done()
16493 i40e_reset_and_rebuild(pf, false, false); in i40e_pci_error_reset_done()
16508 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_resume() local
16511 if (test_bit(__I40E_SUSPENDED, pf->state)) in i40e_pci_error_resume()
16514 i40e_io_resume(pf); in i40e_pci_error_resume()
16523 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_shutdown() local
16524 struct i40e_hw *hw = &pf->hw; in i40e_shutdown()
16526 set_bit(__I40E_SUSPENDED, pf->state); in i40e_shutdown()
16527 set_bit(__I40E_DOWN, pf->state); in i40e_shutdown()
16529 timer_delete_sync(&pf->service_timer); in i40e_shutdown()
16530 cancel_work_sync(&pf->service_task); in i40e_shutdown()
16531 i40e_cloud_filter_exit(pf); in i40e_shutdown()
16532 i40e_fdir_teardown(pf); in i40e_shutdown()
16537 i40e_notify_client_of_netdev_close(pf, false); in i40e_shutdown()
16539 if (test_bit(I40E_HW_CAP_WOL_MC_MAGIC_PKT_WAKE, pf->hw.caps) && in i40e_shutdown()
16540 pf->wol_en) in i40e_shutdown()
16541 i40e_enable_mc_magic_wake(pf); in i40e_shutdown()
16543 i40e_prep_for_reset(pf); in i40e_shutdown()
16546 (pf->wol_en ? I40E_PFPM_APM_APME_MASK : 0)); in i40e_shutdown()
16548 (pf->wol_en ? I40E_PFPM_WUFC_MAG_MASK : 0)); in i40e_shutdown()
16551 if (test_bit(__I40E_RECOVERY_MODE, pf->state) && in i40e_shutdown()
16552 !test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_shutdown()
16553 free_irq(pf->pdev->irq, pf); in i40e_shutdown()
16560 i40e_clear_interrupt_scheme(pf); in i40e_shutdown()
16564 pci_wake_from_d3(pdev, pf->wol_en); in i40e_shutdown()
16575 struct i40e_pf *pf = dev_get_drvdata(dev); in i40e_suspend() local
16578 if (test_and_set_bit(__I40E_SUSPENDED, pf->state)) in i40e_suspend()
16580 return i40e_io_suspend(pf); in i40e_suspend()
16589 struct i40e_pf *pf = dev_get_drvdata(dev); in i40e_resume() local
16592 if (!test_bit(__I40E_SUSPENDED, pf->state)) in i40e_resume()
16594 return i40e_io_resume(pf); in i40e_resume()