Lines Matching full:pf
32 static void i40e_handle_reset_warning(struct i40e_pf *pf, bool lock_acquired);
35 static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired);
36 static int i40e_setup_misc_vector(struct i40e_pf *pf);
37 static void i40e_determine_queue_usage(struct i40e_pf *pf);
38 static int i40e_setup_pf_filter_control(struct i40e_pf *pf);
39 static void i40e_prep_for_reset(struct i40e_pf *pf);
40 static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit,
42 static int i40e_reset(struct i40e_pf *pf);
43 static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired);
44 static int i40e_setup_misc_vector_for_recovery_mode(struct i40e_pf *pf);
45 static int i40e_restore_interrupt_scheme(struct i40e_pf *pf);
46 static bool i40e_check_recovery_mode(struct i40e_pf *pf);
47 static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw);
48 static void i40e_fdir_sb_setup(struct i40e_pf *pf);
50 static int i40e_get_capabilities(struct i40e_pf *pf,
52 static bool i40e_is_total_port_shutdown_enabled(struct i40e_pf *pf);
132 struct i40e_pf *pf = (struct i40e_pf *)hw->back; in i40e_allocate_dma_mem_d() local
135 mem->va = dma_alloc_coherent(&pf->pdev->dev, mem->size, &mem->pa, in i40e_allocate_dma_mem_d()
150 struct i40e_pf *pf = (struct i40e_pf *)hw->back; in i40e_free_dma_mem_d() local
152 dma_free_coherent(&pf->pdev->dev, mem->size, mem->va, mem->pa); in i40e_free_dma_mem_d()
195 * @pf: board private structure
202 static int i40e_get_lump(struct i40e_pf *pf, struct i40e_lump_tracking *pile, in i40e_get_lump() argument
209 dev_info(&pf->pdev->dev, in i40e_get_lump()
218 if (pile == pf->qp_pile && pf->vsi[id]->type == I40E_VSI_FDIR) { in i40e_get_lump()
220 dev_err(&pf->pdev->dev, in i40e_get_lump()
288 * @pf: the pf structure to search for the vsi
291 struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id) in i40e_find_vsi_from_id() argument
295 for (i = 0; i < pf->num_alloc_vsi; i++) in i40e_find_vsi_from_id()
296 if (pf->vsi[i] && (pf->vsi[i]->id == id)) in i40e_find_vsi_from_id()
297 return pf->vsi[i]; in i40e_find_vsi_from_id()
304 * @pf: board private structure
308 void i40e_service_event_schedule(struct i40e_pf *pf) in i40e_service_event_schedule() argument
310 if ((!test_bit(__I40E_DOWN, pf->state) && in i40e_service_event_schedule()
311 !test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) || in i40e_service_event_schedule()
312 test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_service_event_schedule()
313 queue_work(i40e_wq, &pf->service_task); in i40e_service_event_schedule()
329 struct i40e_pf *pf = vsi->back; in i40e_tx_timeout() local
334 pf->tx_timeout_count++; in i40e_tx_timeout()
347 if (time_after(jiffies, (pf->tx_timeout_last_recovery + HZ*20))) in i40e_tx_timeout()
348 pf->tx_timeout_recovery_level = 1; /* reset after some time */ in i40e_tx_timeout()
350 (pf->tx_timeout_last_recovery + netdev->watchdog_timeo))) in i40e_tx_timeout()
354 if (test_and_set_bit(__I40E_TIMEOUT_RECOVERY_PENDING, pf->state)) in i40e_tx_timeout()
360 if (pf->flags & I40E_FLAG_MSIX_ENABLED) in i40e_tx_timeout()
361 val = rd32(&pf->hw, in i40e_tx_timeout()
365 val = rd32(&pf->hw, I40E_PFINT_DYN_CTL0); in i40e_tx_timeout()
373 pf->tx_timeout_last_recovery = jiffies; in i40e_tx_timeout()
375 pf->tx_timeout_recovery_level, txqueue); in i40e_tx_timeout()
377 switch (pf->tx_timeout_recovery_level) { in i40e_tx_timeout()
379 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_tx_timeout()
382 set_bit(__I40E_CORE_RESET_REQUESTED, pf->state); in i40e_tx_timeout()
385 set_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state); in i40e_tx_timeout()
389 set_bit(__I40E_DOWN_REQUESTED, pf->state); in i40e_tx_timeout()
394 i40e_service_event_schedule(pf); in i40e_tx_timeout()
395 pf->tx_timeout_recovery_level++; in i40e_tx_timeout()
529 * i40e_pf_reset_stats - Reset all of the stats for the given PF
530 * @pf: the PF to be reset
532 void i40e_pf_reset_stats(struct i40e_pf *pf) in i40e_pf_reset_stats() argument
536 memset(&pf->stats, 0, sizeof(pf->stats)); in i40e_pf_reset_stats()
537 memset(&pf->stats_offsets, 0, sizeof(pf->stats_offsets)); in i40e_pf_reset_stats()
538 pf->stat_offsets_loaded = false; in i40e_pf_reset_stats()
541 if (pf->veb[i]) { in i40e_pf_reset_stats()
542 memset(&pf->veb[i]->stats, 0, in i40e_pf_reset_stats()
543 sizeof(pf->veb[i]->stats)); in i40e_pf_reset_stats()
544 memset(&pf->veb[i]->stats_offsets, 0, in i40e_pf_reset_stats()
545 sizeof(pf->veb[i]->stats_offsets)); in i40e_pf_reset_stats()
546 memset(&pf->veb[i]->tc_stats, 0, in i40e_pf_reset_stats()
547 sizeof(pf->veb[i]->tc_stats)); in i40e_pf_reset_stats()
548 memset(&pf->veb[i]->tc_stats_offsets, 0, in i40e_pf_reset_stats()
549 sizeof(pf->veb[i]->tc_stats_offsets)); in i40e_pf_reset_stats()
550 pf->veb[i]->stat_offsets_loaded = false; in i40e_pf_reset_stats()
553 pf->hw_csum_rx_error = 0; in i40e_pf_reset_stats()
703 struct i40e_pf *pf = vsi->back; in i40e_update_eth_stats() local
704 struct i40e_hw *hw = &pf->hw; in i40e_update_eth_stats()
768 struct i40e_pf *pf = veb->pf; in i40e_update_veb_stats() local
769 struct i40e_hw *hw = &pf->hw; in i40e_update_veb_stats()
854 struct i40e_pf *pf = vsi->back; in i40e_update_vsi_stats() local
871 test_bit(__I40E_CONFIG_BUSY, pf->state)) in i40e_update_vsi_stats()
979 /* pull in a couple PF stats if this is the main vsi */ in i40e_update_vsi_stats()
980 if (vsi == pf->vsi[pf->lan_vsi]) { in i40e_update_vsi_stats()
981 ns->rx_crc_errors = pf->stats.crc_errors; in i40e_update_vsi_stats()
982 ns->rx_errors = pf->stats.crc_errors + pf->stats.illegal_bytes; in i40e_update_vsi_stats()
983 ns->rx_length_errors = pf->stats.rx_length_errors; in i40e_update_vsi_stats()
988 * i40e_update_pf_stats - Update the PF statistics counters.
989 * @pf: the PF to be updated
991 static void i40e_update_pf_stats(struct i40e_pf *pf) in i40e_update_pf_stats() argument
993 struct i40e_hw_port_stats *osd = &pf->stats_offsets; in i40e_update_pf_stats()
994 struct i40e_hw_port_stats *nsd = &pf->stats; in i40e_update_pf_stats()
995 struct i40e_hw *hw = &pf->hw; in i40e_update_pf_stats()
1001 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1005 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1008 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1013 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1018 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1023 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1028 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1033 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1038 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1043 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1048 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1052 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1056 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1060 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1065 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1070 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1073 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1076 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()
1088 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1092 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1096 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1101 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1108 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1112 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1116 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1120 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1124 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1128 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1132 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1137 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1141 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1145 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1149 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1153 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1157 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1161 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1165 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1168 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1171 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1174 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1196 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1199 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1202 if (pf->flags & I40E_FLAG_FD_SB_ENABLED && in i40e_update_pf_stats()
1203 !test_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state)) in i40e_update_pf_stats()
1208 if (pf->flags & I40E_FLAG_FD_ATR_ENABLED && in i40e_update_pf_stats()
1209 !test_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state)) in i40e_update_pf_stats()
1214 pf->stat_offsets_loaded = true; in i40e_update_pf_stats()
1225 struct i40e_pf *pf = vsi->back; in i40e_update_stats() local
1227 if (vsi == pf->vsi[pf->lan_vsi]) in i40e_update_stats()
1228 i40e_update_pf_stats(pf); in i40e_update_stats()
1468 struct i40e_pf *pf = vsi->back; in i40e_get_vf_new_vlan() local
1478 !(pf->flags & I40E_FLAG_VF_VLAN_PRUNING)); in i40e_get_vf_new_vlan()
1557 * @vsi: the PF Main VSI - inappropriate for any other VSI
1566 struct i40e_pf *pf = vsi->back; in i40e_rm_default_mac_filter() local
1568 /* Only appropriate for the PF main VSI */ in i40e_rm_default_mac_filter()
1577 i40e_aq_remove_macvlan(&pf->hw, vsi->seid, &element, 1, NULL); in i40e_rm_default_mac_filter()
1585 i40e_aq_remove_macvlan(&pf->hw, vsi->seid, &element, 1, NULL); in i40e_rm_default_mac_filter()
1784 struct i40e_pf *pf = vsi->back; in i40e_set_mac() local
1785 struct i40e_hw *hw = &pf->hw; in i40e_set_mac()
1797 if (test_bit(__I40E_DOWN, pf->state) || in i40e_set_mac()
1798 test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_set_mac()
1833 i40e_service_event_schedule(pf); in i40e_set_mac()
1847 struct i40e_pf *pf = vsi->back; in i40e_config_rss_aq() local
1848 struct i40e_hw *hw = &pf->hw; in i40e_config_rss_aq()
1856 dev_info(&pf->pdev->dev, in i40e_config_rss_aq()
1868 dev_info(&pf->pdev->dev, in i40e_config_rss_aq()
1884 struct i40e_pf *pf = vsi->back; in i40e_vsi_config_rss() local
1889 if (!(pf->hw_features & I40E_HW_RSS_AQ_CAPABLE)) in i40e_vsi_config_rss()
1892 vsi->rss_size = min_t(int, pf->alloc_rss_size, in i40e_vsi_config_rss()
1906 i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, vsi->rss_size); in i40e_vsi_config_rss()
2017 struct i40e_pf *pf = vsi->back; in i40e_vsi_setup_queue_map() local
2044 else if (pf->flags & I40E_FLAG_MSIX_ENABLED) in i40e_vsi_setup_queue_map()
2045 vsi->num_queue_pairs = pf->num_lan_msix; in i40e_vsi_setup_queue_map()
2064 dev_warn(&pf->pdev->dev, "DCB is enabled but no TC enabled, forcing TC0\n"); in i40e_vsi_setup_queue_map()
2069 i40e_pf_get_max_q_per_tc(pf)); in i40e_vsi_setup_queue_map()
2076 if (pf->flags & I40E_FLAG_MSIX_ENABLED) in i40e_vsi_setup_queue_map()
2077 num_tc_qps = min_t(int, num_tc_qps, pf->num_lan_msix); in i40e_vsi_setup_queue_map()
2088 if (!(pf->flags & (I40E_FLAG_FD_SB_ENABLED | in i40e_vsi_setup_queue_map()
2091 qcount = min_t(int, pf->alloc_rss_size, in i40e_vsi_setup_queue_map()
2460 * @pf: board private structure
2463 * There are different ways of setting promiscuous mode on a PF depending on
2467 static int i40e_set_promiscuous(struct i40e_pf *pf, bool promisc) in i40e_set_promiscuous() argument
2469 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; in i40e_set_promiscuous()
2470 struct i40e_hw *hw = &pf->hw; in i40e_set_promiscuous()
2474 pf->lan_veb != I40E_NO_VEB && in i40e_set_promiscuous()
2475 !(pf->flags & I40E_FLAG_MFP_ENABLED)) { in i40e_set_promiscuous()
2490 dev_info(&pf->pdev->dev, in i40e_set_promiscuous()
2502 dev_info(&pf->pdev->dev, in i40e_set_promiscuous()
2512 dev_info(&pf->pdev->dev, in i40e_set_promiscuous()
2520 pf->cur_promisc = promisc; in i40e_set_promiscuous()
2542 char vsi_name[16] = "PF"; in i40e_sync_vsi_filters()
2547 struct i40e_pf *pf; in i40e_sync_vsi_filters() local
2561 pf = vsi->back; in i40e_sync_vsi_filters()
2621 vlan_filters, pf->vf[vsi->vf_id].trusted); in i40e_sync_vsi_filters()
2783 dev_info(&pf->pdev->dev, in i40e_sync_vsi_filters()
2791 if ((vsi->type == I40E_VSI_SRIOV) && !pf->vf[vsi->vf_id].trusted) { in i40e_sync_vsi_filters()
2816 dev_info(&pf->pdev->dev, in i40e_sync_vsi_filters()
2822 dev_info(&pf->pdev->dev, "%s allmulti mode.\n", in i40e_sync_vsi_filters()
2832 aq_ret = i40e_set_promiscuous(pf, cur_promisc); in i40e_sync_vsi_filters()
2836 dev_info(&pf->pdev->dev, in i40e_sync_vsi_filters()
2867 * @pf: board private structure
2869 static void i40e_sync_filters_subtask(struct i40e_pf *pf) in i40e_sync_filters_subtask() argument
2873 if (!pf) in i40e_sync_filters_subtask()
2875 if (!test_and_clear_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state)) in i40e_sync_filters_subtask()
2877 if (test_bit(__I40E_VF_DISABLE, pf->state)) { in i40e_sync_filters_subtask()
2878 set_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state); in i40e_sync_filters_subtask()
2882 for (v = 0; v < pf->num_alloc_vsi; v++) { in i40e_sync_filters_subtask()
2883 if (pf->vsi[v] && in i40e_sync_filters_subtask()
2884 (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED) && in i40e_sync_filters_subtask()
2885 !test_bit(__I40E_VSI_RELEASING, pf->vsi[v]->state)) { in i40e_sync_filters_subtask()
2886 int ret = i40e_sync_vsi_filters(pf->vsi[v]); in i40e_sync_filters_subtask()
2891 pf->state); in i40e_sync_filters_subtask()
2921 struct i40e_pf *pf = vsi->back; in i40e_change_mtu() local
2935 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_change_mtu()
2936 set_bit(__I40E_CLIENT_L2_CHANGE, pf->state); in i40e_change_mtu()
2949 struct i40e_pf *pf = np->vsi->back; in i40e_ioctl() local
2953 return i40e_ptp_get_ts_config(pf, ifr); in i40e_ioctl()
2955 return i40e_ptp_set_ts_config(pf, ifr); in i40e_ioctl()
3777 * @pf: Pointer to the targeted PF
3781 static void i40e_reset_fdir_filter_cnt(struct i40e_pf *pf) in i40e_reset_fdir_filter_cnt() argument
3783 pf->fd_tcp4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3784 pf->fd_udp4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3785 pf->fd_sctp4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3786 pf->fd_ip4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3787 pf->fd_tcp6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3788 pf->fd_udp6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3789 pf->fd_sctp6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3790 pf->fd_ip6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3803 struct i40e_pf *pf = vsi->back; in i40e_fdir_filter_restore() local
3806 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED)) in i40e_fdir_filter_restore()
3810 i40e_reset_fdir_filter_cnt(pf); in i40e_fdir_filter_restore()
3813 &pf->fdir_filter_list, fdir_node) { in i40e_fdir_filter_restore()
3843 struct i40e_pf *pf = vsi->back; in i40e_vsi_configure_msix() local
3844 struct i40e_hw *hw = &pf->hw; in i40e_vsi_configure_msix()
3924 * @pf: pointer to private device data structure
3926 static void i40e_enable_misc_int_causes(struct i40e_pf *pf) in i40e_enable_misc_int_causes() argument
3928 struct i40e_hw *hw = &pf->hw; in i40e_enable_misc_int_causes()
3944 if (pf->flags & I40E_FLAG_IWARP_ENABLED) in i40e_enable_misc_int_causes()
3947 if (pf->flags & I40E_FLAG_PTP) in i40e_enable_misc_int_causes()
3968 struct i40e_pf *pf = vsi->back; in i40e_configure_msi_and_legacy() local
3969 struct i40e_hw *hw = &pf->hw; in i40e_configure_msi_and_legacy()
3981 i40e_enable_misc_int_causes(pf); in i40e_configure_msi_and_legacy()
4005 * @pf: board private structure
4007 void i40e_irq_dynamic_disable_icr0(struct i40e_pf *pf) in i40e_irq_dynamic_disable_icr0() argument
4009 struct i40e_hw *hw = &pf->hw; in i40e_irq_dynamic_disable_icr0()
4018 * @pf: board private structure
4020 void i40e_irq_dynamic_enable_icr0(struct i40e_pf *pf) in i40e_irq_dynamic_enable_icr0() argument
4022 struct i40e_hw *hw = &pf->hw; in i40e_irq_dynamic_enable_icr0()
4087 struct i40e_pf *pf = vsi->back; in i40e_vsi_request_irq_msix() local
4098 irq_num = pf->msix_entries[base + vector].vector; in i40e_vsi_request_irq_msix()
4120 dev_info(&pf->pdev->dev, in i40e_vsi_request_irq_msix()
4145 irq_num = pf->msix_entries[base + vector].vector; in i40e_vsi_request_irq_msix()
4159 struct i40e_pf *pf = vsi->back; in i40e_vsi_disable_irq() local
4160 struct i40e_hw *hw = &pf->hw; in i40e_vsi_disable_irq()
4182 if (pf->flags & I40E_FLAG_MSIX_ENABLED) { in i40e_vsi_disable_irq()
4189 synchronize_irq(pf->msix_entries[i + base].vector); in i40e_vsi_disable_irq()
4195 synchronize_irq(pf->pdev->irq); in i40e_vsi_disable_irq()
4205 struct i40e_pf *pf = vsi->back; in i40e_vsi_enable_irq() local
4208 if (pf->flags & I40E_FLAG_MSIX_ENABLED) { in i40e_vsi_enable_irq()
4212 i40e_irq_dynamic_enable_icr0(pf); in i40e_vsi_enable_irq()
4215 i40e_flush(&pf->hw); in i40e_vsi_enable_irq()
4221 * @pf: board private structure
4223 static void i40e_free_misc_vector(struct i40e_pf *pf) in i40e_free_misc_vector() argument
4226 wr32(&pf->hw, I40E_PFINT_ICR0_ENA, 0); in i40e_free_misc_vector()
4227 i40e_flush(&pf->hw); in i40e_free_misc_vector()
4229 if (pf->flags & I40E_FLAG_MSIX_ENABLED && pf->msix_entries) { in i40e_free_misc_vector()
4230 free_irq(pf->msix_entries[0].vector, pf); in i40e_free_misc_vector()
4231 clear_bit(__I40E_MISC_IRQ_REQUESTED, pf->state); in i40e_free_misc_vector()
4246 struct i40e_pf *pf = (struct i40e_pf *)data; in i40e_intr() local
4247 struct i40e_hw *hw = &pf->hw; in i40e_intr()
4262 pf->sw_int_count++; in i40e_intr()
4264 if ((pf->flags & I40E_FLAG_IWARP_ENABLED) && in i40e_intr()
4267 dev_dbg(&pf->pdev->dev, "cleared PE_CRITERR\n"); in i40e_intr()
4268 set_bit(__I40E_CORE_RESET_REQUESTED, pf->state); in i40e_intr()
4273 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; in i40e_intr()
4282 if (!test_bit(__I40E_DOWN, pf->state)) in i40e_intr()
4288 set_bit(__I40E_ADMINQ_EVENT_PENDING, pf->state); in i40e_intr()
4289 i40e_debug(&pf->hw, I40E_DEBUG_NVM, "AdminQ event\n"); in i40e_intr()
4294 set_bit(__I40E_MDD_EVENT_PENDING, pf->state); in i40e_intr()
4299 if (test_bit(__I40E_VF_RESETS_DISABLED, pf->state)) { in i40e_intr()
4306 set_bit(__I40E_VFLR_EVENT_PENDING, pf->state); in i40e_intr()
4311 if (!test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_intr()
4312 set_bit(__I40E_RESET_INTR_RECEIVED, pf->state); in i40e_intr()
4318 pf->corer_count++; in i40e_intr()
4320 pf->globr_count++; in i40e_intr()
4322 pf->empr_count++; in i40e_intr()
4323 set_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state); in i40e_intr()
4329 dev_info(&pf->pdev->dev, "HMC error interrupt\n"); in i40e_intr()
4330 dev_info(&pf->pdev->dev, "HMC error info 0x%x, HMC error data 0x%x\n", in i40e_intr()
4339 schedule_work(&pf->ptp_extts0_work); in i40e_intr()
4342 i40e_ptp_tx_hwtstamp(pf); in i40e_intr()
4353 dev_info(&pf->pdev->dev, "unhandled interrupt icr0=0x%08x\n", in i40e_intr()
4358 dev_info(&pf->pdev->dev, "device will be reset\n"); in i40e_intr()
4359 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_intr()
4360 i40e_service_event_schedule(pf); in i40e_intr()
4369 if (!test_bit(__I40E_DOWN, pf->state) || in i40e_intr()
4370 test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_intr()
4371 i40e_service_event_schedule(pf); in i40e_intr()
4372 i40e_irq_dynamic_enable_icr0(pf); in i40e_intr()
4567 struct i40e_pf *pf = vsi->back; in i40e_vsi_request_irq() local
4570 if (pf->flags & I40E_FLAG_MSIX_ENABLED) in i40e_vsi_request_irq()
4572 else if (pf->flags & I40E_FLAG_MSI_ENABLED) in i40e_vsi_request_irq()
4573 err = request_irq(pf->pdev->irq, i40e_intr, 0, in i40e_vsi_request_irq()
4574 pf->int_name, pf); in i40e_vsi_request_irq()
4576 err = request_irq(pf->pdev->irq, i40e_intr, IRQF_SHARED, in i40e_vsi_request_irq()
4577 pf->int_name, pf); in i40e_vsi_request_irq()
4580 dev_info(&pf->pdev->dev, "request_irq failed, Error %d\n", err); in i40e_vsi_request_irq()
4597 struct i40e_pf *pf = vsi->back; in i40e_netpoll() local
4604 if (pf->flags & I40E_FLAG_MSIX_ENABLED) { in i40e_netpoll()
4608 i40e_intr(pf->pdev->irq, netdev); in i40e_netpoll()
4616 * i40e_pf_txq_wait - Wait for a PF's Tx queue to be enabled or disabled
4617 * @pf: the PF being configured
4618 * @pf_q: the PF queue
4621 * This routine will wait for the given Tx queue of the PF to reach the
4626 static int i40e_pf_txq_wait(struct i40e_pf *pf, int pf_q, bool enable) in i40e_pf_txq_wait() argument
4632 tx_reg = rd32(&pf->hw, I40E_QTX_ENA(pf_q)); in i40e_pf_txq_wait()
4646 * @pf: the PF structure
4647 * @pf_q: the PF queue to configure
4654 static void i40e_control_tx_q(struct i40e_pf *pf, int pf_q, bool enable) in i40e_control_tx_q() argument
4656 struct i40e_hw *hw = &pf->hw; in i40e_control_tx_q()
4661 i40e_pre_tx_queue_cfg(&pf->hw, pf_q, enable); in i40e_control_tx_q()
4691 * @pf: the PF structure
4692 * @pf_q: the PF queue to configure
4696 int i40e_control_wait_tx_q(int seid, struct i40e_pf *pf, int pf_q, in i40e_control_wait_tx_q() argument
4701 i40e_control_tx_q(pf, pf_q, enable); in i40e_control_wait_tx_q()
4704 ret = i40e_pf_txq_wait(pf, pf_q, enable); in i40e_control_wait_tx_q()
4706 dev_info(&pf->pdev->dev, in i40e_control_wait_tx_q()
4721 struct i40e_pf *pf = vsi->back; in i40e_vsi_enable_tx() local
4726 ret = i40e_control_wait_tx_q(vsi->seid, pf, in i40e_vsi_enable_tx()
4735 ret = i40e_control_wait_tx_q(vsi->seid, pf, in i40e_vsi_enable_tx()
4745 * i40e_pf_rxq_wait - Wait for a PF's Rx queue to be enabled or disabled
4746 * @pf: the PF being configured
4747 * @pf_q: the PF queue
4750 * This routine will wait for the given Rx queue of the PF to reach the
4755 static int i40e_pf_rxq_wait(struct i40e_pf *pf, int pf_q, bool enable) in i40e_pf_rxq_wait() argument
4761 rx_reg = rd32(&pf->hw, I40E_QRX_ENA(pf_q)); in i40e_pf_rxq_wait()
4775 * @pf: the PF structure
4776 * @pf_q: the PF queue to configure
4783 static void i40e_control_rx_q(struct i40e_pf *pf, int pf_q, bool enable) in i40e_control_rx_q() argument
4785 struct i40e_hw *hw = &pf->hw; in i40e_control_rx_q()
4812 * @pf: the PF structure
4820 int i40e_control_wait_rx_q(struct i40e_pf *pf, int pf_q, bool enable) in i40e_control_wait_rx_q() argument
4824 i40e_control_rx_q(pf, pf_q, enable); in i40e_control_wait_rx_q()
4827 ret = i40e_pf_rxq_wait(pf, pf_q, enable); in i40e_control_wait_rx_q()
4840 struct i40e_pf *pf = vsi->back; in i40e_vsi_enable_rx() local
4845 ret = i40e_control_wait_rx_q(pf, pf_q, true); in i40e_vsi_enable_rx()
4847 dev_info(&pf->pdev->dev, in i40e_vsi_enable_rx()
4882 struct i40e_pf *pf = vsi->back; in i40e_vsi_stop_rings() local
4891 i40e_pre_tx_queue_cfg(&pf->hw, (u32)pf_q, false); in i40e_vsi_stop_rings()
4894 err = i40e_control_wait_rx_q(pf, pf_q, false); in i40e_vsi_stop_rings()
4896 dev_info(&pf->pdev->dev, in i40e_vsi_stop_rings()
4904 wr32(&pf->hw, I40E_QTX_ENA(pf_q), 0); in i40e_vsi_stop_rings()
4922 struct i40e_pf *pf = vsi->back; in i40e_vsi_stop_rings_no_wait() local
4927 i40e_control_tx_q(pf, pf_q, false); in i40e_vsi_stop_rings_no_wait()
4928 i40e_control_rx_q(pf, pf_q, false); in i40e_vsi_stop_rings_no_wait()
4938 struct i40e_pf *pf = vsi->back; in i40e_vsi_free_irq() local
4939 struct i40e_hw *hw = &pf->hw; in i40e_vsi_free_irq()
4944 if (pf->flags & I40E_FLAG_MSIX_ENABLED) { in i40e_vsi_free_irq()
4957 irq_num = pf->msix_entries[vector].vector; in i40e_vsi_free_irq()
5017 free_irq(pf->pdev->irq, pf); in i40e_vsi_free_irq()
5101 * @pf: board private structure
5103 static void i40e_reset_interrupt_capability(struct i40e_pf *pf) in i40e_reset_interrupt_capability() argument
5106 if (pf->flags & I40E_FLAG_MSIX_ENABLED) { in i40e_reset_interrupt_capability()
5107 pci_disable_msix(pf->pdev); in i40e_reset_interrupt_capability()
5108 kfree(pf->msix_entries); in i40e_reset_interrupt_capability()
5109 pf->msix_entries = NULL; in i40e_reset_interrupt_capability()
5110 kfree(pf->irq_pile); in i40e_reset_interrupt_capability()
5111 pf->irq_pile = NULL; in i40e_reset_interrupt_capability()
5112 } else if (pf->flags & I40E_FLAG_MSI_ENABLED) { in i40e_reset_interrupt_capability()
5113 pci_disable_msi(pf->pdev); in i40e_reset_interrupt_capability()
5115 pf->flags &= ~(I40E_FLAG_MSIX_ENABLED | I40E_FLAG_MSI_ENABLED); in i40e_reset_interrupt_capability()
5120 * @pf: board private structure
5125 static void i40e_clear_interrupt_scheme(struct i40e_pf *pf) in i40e_clear_interrupt_scheme() argument
5129 if (test_bit(__I40E_MISC_IRQ_REQUESTED, pf->state)) in i40e_clear_interrupt_scheme()
5130 i40e_free_misc_vector(pf); in i40e_clear_interrupt_scheme()
5132 i40e_put_lump(pf->irq_pile, pf->iwarp_base_vector, in i40e_clear_interrupt_scheme()
5135 i40e_put_lump(pf->irq_pile, 0, I40E_PILE_VALID_BIT-1); in i40e_clear_interrupt_scheme()
5136 for (i = 0; i < pf->num_alloc_vsi; i++) in i40e_clear_interrupt_scheme()
5137 if (pf->vsi[i]) in i40e_clear_interrupt_scheme()
5138 i40e_vsi_free_q_vectors(pf->vsi[i]); in i40e_clear_interrupt_scheme()
5139 i40e_reset_interrupt_capability(pf); in i40e_clear_interrupt_scheme()
5186 struct i40e_pf *pf = vsi->back; in i40e_vsi_close() local
5193 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_vsi_close()
5194 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_vsi_close()
5195 set_bit(__I40E_CLIENT_RESET, pf->state); in i40e_vsi_close()
5230 * i40e_pf_quiesce_all_vsi - Pause all VSIs on a PF
5231 * @pf: the PF
5233 static void i40e_pf_quiesce_all_vsi(struct i40e_pf *pf) in i40e_pf_quiesce_all_vsi() argument
5237 for (v = 0; v < pf->num_alloc_vsi; v++) { in i40e_pf_quiesce_all_vsi()
5238 if (pf->vsi[v]) in i40e_pf_quiesce_all_vsi()
5239 i40e_quiesce_vsi(pf->vsi[v]); in i40e_pf_quiesce_all_vsi()
5244 * i40e_pf_unquiesce_all_vsi - Resume all VSIs on a PF
5245 * @pf: the PF
5247 static void i40e_pf_unquiesce_all_vsi(struct i40e_pf *pf) in i40e_pf_unquiesce_all_vsi() argument
5251 for (v = 0; v < pf->num_alloc_vsi; v++) { in i40e_pf_unquiesce_all_vsi()
5252 if (pf->vsi[v]) in i40e_pf_unquiesce_all_vsi()
5253 i40e_unquiesce_vsi(pf->vsi[v]); in i40e_pf_unquiesce_all_vsi()
5265 struct i40e_pf *pf = vsi->back; in i40e_vsi_wait_queues_disabled() local
5271 ret = i40e_pf_txq_wait(pf, pf_q, false); in i40e_vsi_wait_queues_disabled()
5273 dev_info(&pf->pdev->dev, in i40e_vsi_wait_queues_disabled()
5283 ret = i40e_pf_txq_wait(pf, pf_q + vsi->alloc_queue_pairs, in i40e_vsi_wait_queues_disabled()
5286 dev_info(&pf->pdev->dev, in i40e_vsi_wait_queues_disabled()
5293 ret = i40e_pf_rxq_wait(pf, pf_q, false); in i40e_vsi_wait_queues_disabled()
5295 dev_info(&pf->pdev->dev, in i40e_vsi_wait_queues_disabled()
5307 * i40e_pf_wait_queues_disabled - Wait for all queues of PF VSIs to be disabled
5308 * @pf: the PF
5311 * VSIs that are managed by this PF.
5313 static int i40e_pf_wait_queues_disabled(struct i40e_pf *pf) in i40e_pf_wait_queues_disabled() argument
5317 for (v = 0; v < pf->hw.func_caps.num_vsis; v++) { in i40e_pf_wait_queues_disabled()
5318 if (pf->vsi[v]) { in i40e_pf_wait_queues_disabled()
5319 ret = i40e_vsi_wait_queues_disabled(pf->vsi[v]); in i40e_pf_wait_queues_disabled()
5332 * @pf: pointer to PF
5334 * Get TC map for ISCSI PF type that will include iSCSI TC
5337 static u8 i40e_get_iscsi_tc_map(struct i40e_pf *pf) in i40e_get_iscsi_tc_map() argument
5340 struct i40e_hw *hw = &pf->hw; in i40e_get_iscsi_tc_map()
5422 * @pf: PF being queried
5427 static u8 i40e_mqprio_get_enabled_tc(struct i40e_pf *pf) in i40e_mqprio_get_enabled_tc() argument
5429 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; in i40e_mqprio_get_enabled_tc()
5439 * i40e_pf_get_num_tc - Get enabled traffic classes for PF
5440 * @pf: PF being queried
5442 * Return number of traffic classes enabled for the given PF
5444 static u8 i40e_pf_get_num_tc(struct i40e_pf *pf) in i40e_pf_get_num_tc() argument
5446 struct i40e_hw *hw = &pf->hw; in i40e_pf_get_num_tc()
5451 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_pf_get_num_tc()
5452 return pf->vsi[pf->lan_vsi]->mqprio_qopt.qopt.num_tc; in i40e_pf_get_num_tc()
5455 if (!(pf->flags & I40E_FLAG_DCB_ENABLED)) in i40e_pf_get_num_tc()
5459 if (!(pf->flags & I40E_FLAG_MFP_ENABLED)) in i40e_pf_get_num_tc()
5462 /* MFP mode return count of enabled TCs for this PF */ in i40e_pf_get_num_tc()
5463 if (pf->hw.func_caps.iscsi) in i40e_pf_get_num_tc()
5464 enabled_tc = i40e_get_iscsi_tc_map(pf); in i40e_pf_get_num_tc()
5477 * @pf: PF being queried
5479 * Return a bitmap for enabled traffic classes for this PF.
5481 static u8 i40e_pf_get_tc_map(struct i40e_pf *pf) in i40e_pf_get_tc_map() argument
5483 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_pf_get_tc_map()
5484 return i40e_mqprio_get_enabled_tc(pf); in i40e_pf_get_tc_map()
5486 /* If neither MQPRIO nor DCB is enabled for this PF then just return in i40e_pf_get_tc_map()
5489 if (!(pf->flags & I40E_FLAG_DCB_ENABLED)) in i40e_pf_get_tc_map()
5492 /* SFP mode we want PF to be enabled for all TCs */ in i40e_pf_get_tc_map()
5493 if (!(pf->flags & I40E_FLAG_MFP_ENABLED)) in i40e_pf_get_tc_map()
5494 return i40e_dcb_get_enabled_tc(&pf->hw.local_dcbx_config); in i40e_pf_get_tc_map()
5496 /* MFP enabled and iSCSI PF type */ in i40e_pf_get_tc_map()
5497 if (pf->hw.func_caps.iscsi) in i40e_pf_get_tc_map()
5498 return i40e_get_iscsi_tc_map(pf); in i40e_pf_get_tc_map()
5513 struct i40e_pf *pf = vsi->back; in i40e_vsi_get_bw_info() local
5514 struct i40e_hw *hw = &pf->hw; in i40e_vsi_get_bw_info()
5522 dev_info(&pf->pdev->dev, in i40e_vsi_get_bw_info()
5523 "couldn't get PF vsi bw config, err %s aq_err %s\n", in i40e_vsi_get_bw_info()
5524 i40e_stat_str(&pf->hw, ret), in i40e_vsi_get_bw_info()
5525 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_vsi_get_bw_info()
5533 dev_info(&pf->pdev->dev, in i40e_vsi_get_bw_info()
5534 "couldn't get PF vsi ets bw config, err %s aq_err %s\n", in i40e_vsi_get_bw_info()
5535 i40e_stat_str(&pf->hw, ret), in i40e_vsi_get_bw_info()
5536 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_vsi_get_bw_info()
5541 dev_info(&pf->pdev->dev, in i40e_vsi_get_bw_info()
5575 struct i40e_pf *pf = vsi->back; in i40e_vsi_configure_bw_alloc() local
5580 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_vsi_configure_bw_alloc()
5582 if (!vsi->mqprio_qopt.qopt.hw && !(pf->flags & I40E_FLAG_DCB_ENABLED)) { in i40e_vsi_configure_bw_alloc()
5585 dev_info(&pf->pdev->dev, in i40e_vsi_configure_bw_alloc()
5595 ret = i40e_aq_config_vsi_tc_bw(&pf->hw, vsi->seid, &bw_data, NULL); in i40e_vsi_configure_bw_alloc()
5597 dev_info(&pf->pdev->dev, in i40e_vsi_configure_bw_alloc()
5599 pf->hw.aq.asq_last_status); in i40e_vsi_configure_bw_alloc()
5618 struct i40e_pf *pf = vsi->back; in i40e_vsi_config_netdev_tc() local
5619 struct i40e_hw *hw = &pf->hw; in i40e_vsi_config_netdev_tc()
5652 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_vsi_config_netdev_tc()
5692 struct i40e_pf *pf; in i40e_update_adq_vsi_queues() local
5698 pf = vsi->back; in i40e_update_adq_vsi_queues()
5699 hw = &pf->hw; in i40e_update_adq_vsi_queues()
5712 vsi->rss_size = min_t(int, pf->alloc_rss_size, in i40e_update_adq_vsi_queues()
5716 dev_info(&pf->pdev->dev, "Failed to reconfig rss for num_queues\n"); in i40e_update_adq_vsi_queues()
5724 dev_info(&pf->pdev->dev, "Update vsi config failed, err %s aq_err %s\n", in i40e_update_adq_vsi_queues()
5752 struct i40e_pf *pf = vsi->back; in i40e_vsi_config_tc() local
5753 struct i40e_hw *hw = &pf->hw; in i40e_vsi_config_tc()
5773 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5779 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5792 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5800 dev_err(&pf->pdev->dev, in i40e_vsi_config_tc()
5813 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_vsi_config_tc()
5846 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5859 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5879 struct i40e_pf *pf = vsi->back; in i40e_get_link_speed() local
5881 switch (pf->hw.phy.link_info.link_speed) { in i40e_get_link_speed()
5927 struct i40e_pf *pf = vsi->back; in i40e_set_bw_limit() local
5934 dev_err(&pf->pdev->dev, in i40e_set_bw_limit()
5940 dev_warn(&pf->pdev->dev, in i40e_set_bw_limit()
5948 ret = i40e_aq_config_vsi_bw_limit(&pf->hw, seid, credits, in i40e_set_bw_limit()
5951 dev_err(&pf->pdev->dev, in i40e_set_bw_limit()
5953 max_tx_rate, seid, i40e_stat_str(&pf->hw, ret), in i40e_set_bw_limit()
5954 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_set_bw_limit()
5969 struct i40e_pf *pf = vsi->back; in i40e_remove_queue_channels() local
6013 &pf->cloud_filter_list, cloud_node) { in i40e_remove_queue_channels()
6025 last_aq_status = pf->hw.aq.asq_last_status; in i40e_remove_queue_channels()
6027 dev_info(&pf->pdev->dev, in i40e_remove_queue_channels()
6029 i40e_stat_str(&pf->hw, ret), in i40e_remove_queue_channels()
6030 i40e_aq_str(&pf->hw, last_aq_status)); in i40e_remove_queue_channels()
6070 * @pf: ptr to PF device
6079 static int i40e_validate_num_queues(struct i40e_pf *pf, int num_queues, in i40e_validate_num_queues() argument
6090 dev_dbg(&pf->pdev->dev, in i40e_validate_num_queues()
6096 dev_dbg(&pf->pdev->dev, in i40e_validate_num_queues()
6111 dev_dbg(&pf->pdev->dev, in i40e_validate_num_queues()
6131 struct i40e_pf *pf = vsi->back; in i40e_vsi_reconfig_rss() local
6133 struct i40e_hw *hw = &pf->hw; in i40e_vsi_reconfig_rss()
6150 i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, local_rss_size); in i40e_vsi_reconfig_rss()
6162 dev_info(&pf->pdev->dev, in i40e_vsi_reconfig_rss()
6181 * @pf: ptr to PF device
6187 static void i40e_channel_setup_queue_map(struct i40e_pf *pf, in i40e_channel_setup_queue_map() argument
6198 qcount = min_t(int, ch->num_queue_pairs, pf->num_lan_msix); in i40e_channel_setup_queue_map()
6220 * @pf: ptr to PF device
6226 static int i40e_add_channel(struct i40e_pf *pf, u16 uplink_seid, in i40e_add_channel() argument
6229 struct i40e_hw *hw = &pf->hw; in i40e_add_channel()
6235 dev_info(&pf->pdev->dev, in i40e_add_channel()
6248 if (pf->flags & I40E_FLAG_VEB_MODE_ENABLED) { in i40e_add_channel()
6256 i40e_channel_setup_queue_map(pf, &ctxt, ch); in i40e_add_channel()
6261 dev_info(&pf->pdev->dev, in i40e_add_channel()
6263 i40e_stat_str(&pf->hw, ret), in i40e_add_channel()
6264 i40e_aq_str(&pf->hw, in i40e_add_channel()
6265 pf->hw.aq.asq_last_status)); in i40e_add_channel()
6319 * @pf: ptr to PF device
6326 static int i40e_channel_config_tx_ring(struct i40e_pf *pf, in i40e_channel_config_tx_ring() argument
6371 * @pf: ptr to PF device
6380 static inline int i40e_setup_hw_channel(struct i40e_pf *pf, in i40e_setup_hw_channel() argument
6392 ret = i40e_add_channel(pf, uplink_seid, ch); in i40e_setup_hw_channel()
6394 dev_info(&pf->pdev->dev, in i40e_setup_hw_channel()
6404 ret = i40e_channel_config_tx_ring(pf, vsi, ch); in i40e_setup_hw_channel()
6406 dev_info(&pf->pdev->dev, in i40e_setup_hw_channel()
6414 dev_dbg(&pf->pdev->dev, in i40e_setup_hw_channel()
6415 …"Added channel: vsi_seid %u, vsi_number %u, stat_counter_idx %u, num_queue_pairs %u, pf->next_base… in i40e_setup_hw_channel()
6424 * @pf: ptr to PF device
6431 static bool i40e_setup_channel(struct i40e_pf *pf, struct i40e_vsi *vsi, in i40e_setup_channel() argument
6441 dev_err(&pf->pdev->dev, "unsupported parent vsi type(%d)\n", in i40e_setup_channel()
6447 seid = pf->vsi[pf->lan_vsi]->uplink_seid; in i40e_setup_channel()
6450 ret = i40e_setup_hw_channel(pf, vsi, ch, seid, vsi_type); in i40e_setup_channel()
6452 dev_err(&pf->pdev->dev, "failed to setup hw_channel\n"); in i40e_setup_channel()
6461 * @vsi: ptr to VSI which has PF backing
6469 struct i40e_pf *pf = vsi->back; in i40e_validate_and_set_switch_mode() local
6470 struct i40e_hw *hw = &pf->hw; in i40e_validate_and_set_switch_mode()
6473 ret = i40e_get_capabilities(pf, i40e_aqc_opc_list_dev_capabilities); in i40e_validate_and_set_switch_mode()
6486 dev_err(&pf->pdev->dev, in i40e_validate_and_set_switch_mode()
6503 ret = i40e_aq_set_switch_config(hw, pf->last_sw_conf_flags, in i40e_validate_and_set_switch_mode()
6504 pf->last_sw_conf_valid_flags, in i40e_validate_and_set_switch_mode()
6507 dev_err(&pf->pdev->dev, in i40e_validate_and_set_switch_mode()
6527 struct i40e_pf *pf = vsi->back; in i40e_create_queue_channel() local
6535 dev_err(&pf->pdev->dev, "Invalid num_queues requested: %d\n", in i40e_create_queue_channel()
6541 err = i40e_validate_num_queues(pf, ch->num_queue_pairs, vsi, in i40e_create_queue_channel()
6544 dev_info(&pf->pdev->dev, "Failed to validate num_queues (%d)\n", in i40e_create_queue_channel()
6553 if (!(pf->flags & I40E_FLAG_VEB_MODE_ENABLED)) { in i40e_create_queue_channel()
6554 pf->flags |= I40E_FLAG_VEB_MODE_ENABLED; in i40e_create_queue_channel()
6557 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_create_queue_channel()
6558 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_create_queue_channel()
6560 i40e_do_reset_safe(pf, I40E_PF_RESET_FLAG); in i40e_create_queue_channel()
6571 dev_dbg(&pf->pdev->dev, in i40e_create_queue_channel()
6581 dev_info(&pf->pdev->dev, in i40e_create_queue_channel()
6588 if (!i40e_setup_channel(pf, vsi, ch)) { in i40e_create_queue_channel()
6589 dev_info(&pf->pdev->dev, "Failed to setup channel\n"); in i40e_create_queue_channel()
6593 dev_info(&pf->pdev->dev, in i40e_create_queue_channel()
6605 dev_dbg(&pf->pdev->dev, in i40e_create_queue_channel()
6688 struct i40e_pf *pf = veb->pf; in i40e_veb_config_tc() local
6705 ret = i40e_aq_config_switch_comp_bw_config(&pf->hw, veb->seid, in i40e_veb_config_tc()
6708 dev_info(&pf->pdev->dev, in i40e_veb_config_tc()
6710 i40e_stat_str(&pf->hw, ret), in i40e_veb_config_tc()
6711 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_veb_config_tc()
6718 dev_info(&pf->pdev->dev, in i40e_veb_config_tc()
6720 i40e_stat_str(&pf->hw, ret), in i40e_veb_config_tc()
6721 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_veb_config_tc()
6731 * @pf: PF struct
6733 * Reconfigure VEB/VSIs on a given PF; it is assumed that
6737 static void i40e_dcb_reconfigure(struct i40e_pf *pf) in i40e_dcb_reconfigure() argument
6743 /* Enable the TCs available on PF to all VEBs */ in i40e_dcb_reconfigure()
6744 tc_map = i40e_pf_get_tc_map(pf); in i40e_dcb_reconfigure()
6749 if (!pf->veb[v]) in i40e_dcb_reconfigure()
6751 ret = i40e_veb_config_tc(pf->veb[v], tc_map); in i40e_dcb_reconfigure()
6753 dev_info(&pf->pdev->dev, in i40e_dcb_reconfigure()
6755 pf->veb[v]->seid); in i40e_dcb_reconfigure()
6761 for (v = 0; v < pf->num_alloc_vsi; v++) { in i40e_dcb_reconfigure()
6762 if (!pf->vsi[v]) in i40e_dcb_reconfigure()
6768 if (v == pf->lan_vsi) in i40e_dcb_reconfigure()
6769 tc_map = i40e_pf_get_tc_map(pf); in i40e_dcb_reconfigure()
6773 ret = i40e_vsi_config_tc(pf->vsi[v], tc_map); in i40e_dcb_reconfigure()
6775 dev_info(&pf->pdev->dev, in i40e_dcb_reconfigure()
6777 pf->vsi[v]->seid); in i40e_dcb_reconfigure()
6781 i40e_vsi_map_rings_to_vectors(pf->vsi[v]); in i40e_dcb_reconfigure()
6782 if (pf->vsi[v]->netdev) in i40e_dcb_reconfigure()
6783 i40e_dcbnl_set_all(pf->vsi[v]); in i40e_dcb_reconfigure()
6790 * @pf: PF struct
6792 * Resume a port's Tx and issue a PF reset in case of failure to
6795 static int i40e_resume_port_tx(struct i40e_pf *pf) in i40e_resume_port_tx() argument
6797 struct i40e_hw *hw = &pf->hw; in i40e_resume_port_tx()
6802 dev_info(&pf->pdev->dev, in i40e_resume_port_tx()
6804 i40e_stat_str(&pf->hw, ret), in i40e_resume_port_tx()
6805 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_resume_port_tx()
6806 /* Schedule PF reset to recover */ in i40e_resume_port_tx()
6807 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_resume_port_tx()
6808 i40e_service_event_schedule(pf); in i40e_resume_port_tx()
6816 * @pf: PF struct
6818 * Suspend a port's Tx and issue a PF reset in case of failure.
6820 static int i40e_suspend_port_tx(struct i40e_pf *pf) in i40e_suspend_port_tx() argument
6822 struct i40e_hw *hw = &pf->hw; in i40e_suspend_port_tx()
6825 ret = i40e_aq_suspend_port_tx(hw, pf->mac_seid, NULL); in i40e_suspend_port_tx()
6827 dev_info(&pf->pdev->dev, in i40e_suspend_port_tx()
6829 i40e_stat_str(&pf->hw, ret), in i40e_suspend_port_tx()
6830 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_suspend_port_tx()
6831 /* Schedule PF reset to recover */ in i40e_suspend_port_tx()
6832 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_suspend_port_tx()
6833 i40e_service_event_schedule(pf); in i40e_suspend_port_tx()
6841 * @pf: PF being configured
6845 * given PF. Uses "Set LLDP MIB" AQC to program the hardware.
6847 static int i40e_hw_set_dcb_config(struct i40e_pf *pf, in i40e_hw_set_dcb_config() argument
6850 struct i40e_dcbx_config *old_cfg = &pf->hw.local_dcbx_config; in i40e_hw_set_dcb_config()
6855 dev_dbg(&pf->pdev->dev, "No Change in DCB Config required.\n"); in i40e_hw_set_dcb_config()
6860 i40e_pf_quiesce_all_vsi(pf); in i40e_hw_set_dcb_config()
6865 ret = i40e_set_dcb_config(&pf->hw); in i40e_hw_set_dcb_config()
6867 dev_info(&pf->pdev->dev, in i40e_hw_set_dcb_config()
6869 i40e_stat_str(&pf->hw, ret), in i40e_hw_set_dcb_config()
6870 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_hw_set_dcb_config()
6875 i40e_dcb_reconfigure(pf); in i40e_hw_set_dcb_config()
6878 if (!test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) { in i40e_hw_set_dcb_config()
6880 ret = i40e_resume_port_tx(pf); in i40e_hw_set_dcb_config()
6884 i40e_pf_unquiesce_all_vsi(pf); in i40e_hw_set_dcb_config()
6892 * @pf: PF being configured
6896 * given PF
6898 int i40e_hw_dcb_config(struct i40e_pf *pf, struct i40e_dcbx_config *new_cfg) in i40e_hw_dcb_config() argument
6906 struct i40e_hw *hw = &pf->hw; in i40e_hw_dcb_config()
6915 dev_dbg(&pf->pdev->dev, "Configuring DCB registers directly\n"); in i40e_hw_dcb_config()
6957 need_reconfig = i40e_dcb_need_reconfig(pf, old_cfg, new_cfg); in i40e_hw_dcb_config()
6965 pf->flags |= I40E_FLAG_DCB_ENABLED; in i40e_hw_dcb_config()
6967 pf->flags &= ~I40E_FLAG_DCB_ENABLED; in i40e_hw_dcb_config()
6969 set_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_hw_dcb_config()
6971 i40e_pf_quiesce_all_vsi(pf); in i40e_hw_dcb_config()
6972 ret = i40e_suspend_port_tx(pf); in i40e_hw_dcb_config()
6981 (hw, pf->mac_seid, &ets_data, in i40e_hw_dcb_config()
6984 dev_info(&pf->pdev->dev, in i40e_hw_dcb_config()
6986 i40e_stat_str(&pf->hw, ret), in i40e_hw_dcb_config()
6987 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_hw_dcb_config()
7007 mfs_tc[i] = pf->vsi[pf->lan_vsi]->netdev->mtu; in i40e_hw_dcb_config()
7014 i40e_dcb_hw_rx_pb_config(hw, &pf->pb_cfg, &pb_cfg); in i40e_hw_dcb_config()
7017 pf->pb_cfg = pb_cfg; in i40e_hw_dcb_config()
7020 ret = i40e_aq_dcb_updated(&pf->hw, NULL); in i40e_hw_dcb_config()
7022 dev_info(&pf->pdev->dev, in i40e_hw_dcb_config()
7024 i40e_stat_str(&pf->hw, ret), in i40e_hw_dcb_config()
7025 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_hw_dcb_config()
7033 i40e_dcb_reconfigure(pf); in i40e_hw_dcb_config()
7037 ret = i40e_resume_port_tx(pf); in i40e_hw_dcb_config()
7039 clear_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_hw_dcb_config()
7044 /* Wait for the PF's queues to be disabled */ in i40e_hw_dcb_config()
7045 ret = i40e_pf_wait_queues_disabled(pf); in i40e_hw_dcb_config()
7047 /* Schedule PF reset to recover */ in i40e_hw_dcb_config()
7048 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_hw_dcb_config()
7049 i40e_service_event_schedule(pf); in i40e_hw_dcb_config()
7052 i40e_pf_unquiesce_all_vsi(pf); in i40e_hw_dcb_config()
7053 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_hw_dcb_config()
7054 set_bit(__I40E_CLIENT_L2_CHANGE, pf->state); in i40e_hw_dcb_config()
7057 if (pf->hw_features & I40E_HW_USE_SET_LLDP_MIB) in i40e_hw_dcb_config()
7058 ret = i40e_hw_set_dcb_config(pf, new_cfg); in i40e_hw_dcb_config()
7067 * @pf: PF being queried
7071 int i40e_dcb_sw_default_config(struct i40e_pf *pf) in i40e_dcb_sw_default_config() argument
7073 struct i40e_dcbx_config *dcb_cfg = &pf->hw.local_dcbx_config; in i40e_dcb_sw_default_config()
7075 struct i40e_hw *hw = &pf->hw; in i40e_dcb_sw_default_config()
7078 if (pf->hw_features & I40E_HW_USE_SET_LLDP_MIB) { in i40e_dcb_sw_default_config()
7080 memset(&pf->tmp_cfg, 0, sizeof(struct i40e_dcbx_config)); in i40e_dcb_sw_default_config()
7081 pf->tmp_cfg.etscfg.willing = I40E_IEEE_DEFAULT_ETS_WILLING; in i40e_dcb_sw_default_config()
7082 pf->tmp_cfg.etscfg.maxtcs = 0; in i40e_dcb_sw_default_config()
7083 pf->tmp_cfg.etscfg.tcbwtable[0] = I40E_IEEE_DEFAULT_ETS_TCBW; in i40e_dcb_sw_default_config()
7084 pf->tmp_cfg.etscfg.tsatable[0] = I40E_IEEE_TSA_ETS; in i40e_dcb_sw_default_config()
7085 pf->tmp_cfg.pfc.willing = I40E_IEEE_DEFAULT_PFC_WILLING; in i40e_dcb_sw_default_config()
7086 pf->tmp_cfg.pfc.pfccap = I40E_MAX_TRAFFIC_CLASS; in i40e_dcb_sw_default_config()
7088 pf->tmp_cfg.numapps = I40E_IEEE_DEFAULT_NUM_APPS; in i40e_dcb_sw_default_config()
7089 pf->tmp_cfg.app[0].selector = I40E_APP_SEL_ETHTYPE; in i40e_dcb_sw_default_config()
7090 pf->tmp_cfg.app[0].priority = I40E_IEEE_DEFAULT_APP_PRIO; in i40e_dcb_sw_default_config()
7091 pf->tmp_cfg.app[0].protocolid = I40E_APP_PROTOID_FCOE; in i40e_dcb_sw_default_config()
7093 return i40e_hw_set_dcb_config(pf, &pf->tmp_cfg); in i40e_dcb_sw_default_config()
7103 (hw, pf->mac_seid, &ets_data, in i40e_dcb_sw_default_config()
7106 dev_info(&pf->pdev->dev, in i40e_dcb_sw_default_config()
7108 i40e_stat_str(&pf->hw, err), in i40e_dcb_sw_default_config()
7109 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_dcb_sw_default_config()
7126 * @pf: PF being configured
7131 static int i40e_init_pf_dcb(struct i40e_pf *pf) in i40e_init_pf_dcb() argument
7133 struct i40e_hw *hw = &pf->hw; in i40e_init_pf_dcb()
7139 if (pf->hw_features & I40E_HW_NO_DCB_SUPPORT) { in i40e_init_pf_dcb()
7140 dev_info(&pf->pdev->dev, "DCB is not supported.\n"); in i40e_init_pf_dcb()
7144 if (pf->flags & I40E_FLAG_DISABLE_FW_LLDP) { in i40e_init_pf_dcb()
7145 dev_info(&pf->pdev->dev, "FW LLDP is disabled, attempting SW DCB\n"); in i40e_init_pf_dcb()
7146 err = i40e_dcb_sw_default_config(pf); in i40e_init_pf_dcb()
7148 dev_info(&pf->pdev->dev, "Could not initialize SW DCB\n"); in i40e_init_pf_dcb()
7151 dev_info(&pf->pdev->dev, "SW DCB initialization succeeded.\n"); in i40e_init_pf_dcb()
7152 pf->dcbx_cap = DCB_CAP_DCBX_HOST | in i40e_init_pf_dcb()
7155 pf->flags |= I40E_FLAG_DCB_CAPABLE; in i40e_init_pf_dcb()
7156 pf->flags &= ~I40E_FLAG_DCB_ENABLED; in i40e_init_pf_dcb()
7164 dev_info(&pf->pdev->dev, in i40e_init_pf_dcb()
7165 "DCBX offload is not supported or is disabled for this PF.\n"); in i40e_init_pf_dcb()
7168 pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED | in i40e_init_pf_dcb()
7171 pf->flags |= I40E_FLAG_DCB_CAPABLE; in i40e_init_pf_dcb()
7176 pf->flags |= I40E_FLAG_DCB_ENABLED; in i40e_init_pf_dcb()
7178 pf->flags &= ~I40E_FLAG_DCB_ENABLED; in i40e_init_pf_dcb()
7179 dev_dbg(&pf->pdev->dev, in i40e_init_pf_dcb()
7180 "DCBX offload is supported for this PF.\n"); in i40e_init_pf_dcb()
7182 } else if (pf->hw.aq.asq_last_status == I40E_AQ_RC_EPERM) { in i40e_init_pf_dcb()
7183 dev_info(&pf->pdev->dev, "FW LLDP disabled for this PF.\n"); in i40e_init_pf_dcb()
7184 pf->flags |= I40E_FLAG_DISABLE_FW_LLDP; in i40e_init_pf_dcb()
7186 dev_info(&pf->pdev->dev, in i40e_init_pf_dcb()
7188 i40e_stat_str(&pf->hw, err), in i40e_init_pf_dcb()
7189 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_init_pf_dcb()
7205 struct i40e_pf *pf = vsi->back; in i40e_print_link_message() local
7213 new_speed = pf->hw.phy.link_info.link_speed; in i40e_print_link_message()
7229 if (pf->hw.func_caps.npar_enable && in i40e_print_link_message()
7230 (pf->hw.phy.link_info.link_speed == I40E_LINK_SPEED_1GB || in i40e_print_link_message()
7231 pf->hw.phy.link_info.link_speed == I40E_LINK_SPEED_100MB)) in i40e_print_link_message()
7235 switch (pf->hw.phy.link_info.link_speed) { in i40e_print_link_message()
7264 switch (pf->hw.fc.current_mode) { in i40e_print_link_message()
7279 if (pf->hw.phy.link_info.link_speed == I40E_LINK_SPEED_25GB) { in i40e_print_link_message()
7284 if (pf->hw.phy.link_info.an_info & I40E_AQ_AN_COMPLETED) in i40e_print_link_message()
7287 if (pf->hw.phy.link_info.fec_info & in i40e_print_link_message()
7290 else if (pf->hw.phy.link_info.fec_info & in i40e_print_link_message()
7308 } else if (pf->hw.device_id == I40E_DEV_ID_KX_X722) { in i40e_print_link_message()
7313 if (pf->hw.phy.link_info.an_info & I40E_AQ_AN_COMPLETED) in i40e_print_link_message()
7316 if (pf->hw.phy.link_info.fec_info & in i40e_print_link_message()
7320 if (pf->hw.phy.link_info.req_fec_info & in i40e_print_link_message()
7341 struct i40e_pf *pf = vsi->back; in i40e_up_complete() local
7344 if (pf->flags & I40E_FLAG_MSIX_ENABLED) in i40e_up_complete()
7358 if ((pf->hw.phy.link_info.link_info & I40E_AQ_LINK_UP) && in i40e_up_complete()
7368 pf->fd_add_err = 0; in i40e_up_complete()
7369 pf->fd_atr_cnt = 0; in i40e_up_complete()
7376 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_up_complete()
7377 i40e_service_event_schedule(pf); in i40e_up_complete()
7391 struct i40e_pf *pf = vsi->back; in i40e_vsi_reinit_locked() local
7393 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) in i40e_vsi_reinit_locked()
7398 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_vsi_reinit_locked()
7403 * @pf: board private structure
7406 static i40e_status i40e_force_link_state(struct i40e_pf *pf, bool is_up) in i40e_force_link_state() argument
7411 struct i40e_hw *hw = &pf->hw; in i40e_force_link_state()
7425 dev_err(&pf->pdev->dev, in i40e_force_link_state()
7437 dev_err(&pf->pdev->dev, in i40e_force_link_state()
7448 if (pf->flags & I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENABLED) in i40e_force_link_state()
7464 if (pf->flags & I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENABLED) { in i40e_force_link_state()
7482 dev_err(&pf->pdev->dev, in i40e_force_link_state()
7484 i40e_stat_str(&pf->hw, err), in i40e_force_link_state()
7485 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_force_link_state()
7770 struct i40e_pf *pf = vsi->back; in i40e_fwd_ring_up() local
7771 struct i40e_hw *hw = &pf->hw; in i40e_fwd_ring_up()
7823 dev_info(&pf->pdev->dev, in i40e_fwd_ring_up()
7843 struct i40e_pf *pf = vsi->back; in i40e_setup_macvlans() local
7844 struct i40e_hw *hw = &pf->hw; in i40e_setup_macvlans()
7880 dev_info(&pf->pdev->dev, in i40e_setup_macvlans()
7896 dev_info(&pf->pdev->dev, in i40e_setup_macvlans()
7916 if (!i40e_setup_channel(pf, vsi, ch)) { in i40e_setup_macvlans()
7930 dev_info(&pf->pdev->dev, "Failed to setup macvlans\n"); in i40e_setup_macvlans()
7946 struct i40e_pf *pf = vsi->back; in i40e_fwd_add() local
7950 if ((pf->flags & I40E_FLAG_DCB_ENABLED)) { in i40e_fwd_add()
7954 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_fwd_add()
7958 if (pf->num_lan_msix < I40E_MIN_MACVLAN_VECTORS) { in i40e_fwd_add()
7970 /* reserve bit 0 for the pf device */ in i40e_fwd_add()
7977 vectors = pf->num_lan_msix; in i40e_fwd_add()
7979 /* allocate 4 Qs per macvlan and 32 Qs to the PF*/ in i40e_fwd_add()
7983 /* allocate 2 Qs per macvlan and 16 Qs to the PF*/ in i40e_fwd_add()
7987 /* allocate 1 Q per macvlan and 16 Qs to the PF*/ in i40e_fwd_add()
7991 /* allocate 1 Q per macvlan and 8 Qs to the PF */ in i40e_fwd_add()
7995 /* allocate 1 Q per macvlan and 1 Q to the PF */ in i40e_fwd_add()
8054 struct i40e_pf *pf = vsi->back; in i40e_del_all_macvlans() local
8055 struct i40e_hw *hw = &pf->hw; in i40e_del_all_macvlans()
8091 struct i40e_pf *pf = vsi->back; in i40e_fwd_del() local
8092 struct i40e_hw *hw = &pf->hw; in i40e_fwd_del()
8112 dev_info(&pf->pdev->dev, in i40e_fwd_del()
8132 struct i40e_pf *pf = vsi->back; in i40e_setup_tc() local
8145 pf->flags &= ~I40E_FLAG_TC_MQPRIO; in i40e_setup_tc()
8151 if (pf->flags & I40E_FLAG_MFP_ENABLED) { in i40e_setup_tc()
8158 pf->flags &= ~I40E_FLAG_TC_MQPRIO; in i40e_setup_tc()
8161 if (!(pf->flags & I40E_FLAG_DCB_ENABLED)) { in i40e_setup_tc()
8168 if (num_tc > i40e_pf_get_num_tc(pf)) { in i40e_setup_tc()
8175 if (pf->flags & I40E_FLAG_DCB_ENABLED) { in i40e_setup_tc()
8180 if (!(pf->flags & I40E_FLAG_MSIX_ENABLED)) in i40e_setup_tc()
8187 pf->flags |= I40E_FLAG_TC_MQPRIO; in i40e_setup_tc()
8188 pf->flags &= ~I40E_FLAG_DCB_ENABLED; in i40e_setup_tc()
8207 if (!hw && !i40e_is_tc_mqprio_enabled(pf)) in i40e_setup_tc()
8231 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_setup_tc()
8329 struct i40e_pf *pf = vsi->back; in i40e_add_del_cloud_filter() local
8368 ret = i40e_aq_add_cloud_filters(&pf->hw, filter->seid, in i40e_add_del_cloud_filter()
8371 ret = i40e_aq_rem_cloud_filters(&pf->hw, filter->seid, in i40e_add_del_cloud_filter()
8374 dev_dbg(&pf->pdev->dev, in i40e_add_del_cloud_filter()
8377 pf->hw.aq.asq_last_status); in i40e_add_del_cloud_filter()
8379 dev_info(&pf->pdev->dev, in i40e_add_del_cloud_filter()
8399 struct i40e_pf *pf = vsi->back; in i40e_add_del_cloud_filter_big_buf() local
8457 dev_err(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8470 dev_err(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8476 ret = i40e_aq_add_cloud_filters_bb(&pf->hw, filter->seid, in i40e_add_del_cloud_filter_big_buf()
8479 ret = i40e_aq_rem_cloud_filters_bb(&pf->hw, filter->seid, in i40e_add_del_cloud_filter_big_buf()
8484 dev_dbg(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8486 add ? "add" : "delete", ret, pf->hw.aq.asq_last_status); in i40e_add_del_cloud_filter_big_buf()
8488 dev_info(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8509 struct i40e_pf *pf = vsi->back; in i40e_parse_cls_flower() local
8521 dev_err(&pf->pdev->dev, "Unsupported key used: 0x%x\n", in i40e_parse_cls_flower()
8561 dev_err(&pf->pdev->dev, "Bad ether dest mask %pM\n", in i40e_parse_cls_flower()
8571 dev_err(&pf->pdev->dev, "Bad ether src mask %pM\n", in i40e_parse_cls_flower()
8589 dev_err(&pf->pdev->dev, "Bad vlan mask 0x%04x\n", in i40e_parse_cls_flower()
8613 dev_err(&pf->pdev->dev, "Bad ip dst mask %pI4b\n", in i40e_parse_cls_flower()
8623 dev_err(&pf->pdev->dev, "Bad ip src mask %pI4b\n", in i40e_parse_cls_flower()
8630 dev_err(&pf->pdev->dev, "Tenant id not allowed for ip filter\n"); in i40e_parse_cls_flower()
8647 dev_err(&pf->pdev->dev, in i40e_parse_cls_flower()
8669 dev_err(&pf->pdev->dev, "Bad src port mask 0x%04x\n", in i40e_parse_cls_flower()
8679 dev_err(&pf->pdev->dev, "Bad dst port mask 0x%04x\n", in i40e_parse_cls_flower()
8693 dev_err(&pf->pdev->dev, in i40e_parse_cls_flower()
8748 struct i40e_pf *pf = vsi->back; in i40e_configure_clsflower() local
8757 dev_err(&pf->pdev->dev, "Unable to add filter because of invalid destination"); in i40e_configure_clsflower()
8761 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_configure_clsflower()
8762 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_configure_clsflower()
8765 if (pf->fdir_pf_active_filters || in i40e_configure_clsflower()
8766 (!hlist_empty(&pf->fdir_filter_list))) { in i40e_configure_clsflower()
8800 dev_err(&pf->pdev->dev, "Failed to add cloud filter, err %d\n", in i40e_configure_clsflower()
8808 hlist_add_head(&filter->cloud_node, &pf->cloud_filter_list); in i40e_configure_clsflower()
8810 pf->num_cloud_filters++; in i40e_configure_clsflower()
8847 struct i40e_pf *pf = vsi->back; in i40e_delete_clsflower() local
8864 dev_err(&pf->pdev->dev, in i40e_delete_clsflower()
8866 i40e_stat_str(&pf->hw, err)); in i40e_delete_clsflower()
8867 return i40e_aq_rc_to_posix(err, pf->hw.aq.asq_last_status); in i40e_delete_clsflower()
8870 pf->num_cloud_filters--; in i40e_delete_clsflower()
8871 if (!pf->num_cloud_filters) in i40e_delete_clsflower()
8872 if ((pf->flags & I40E_FLAG_FD_SB_TO_CLOUD_FILTER) && in i40e_delete_clsflower()
8873 !(pf->flags & I40E_FLAG_FD_SB_INACTIVE)) { in i40e_delete_clsflower()
8874 pf->flags |= I40E_FLAG_FD_SB_ENABLED; in i40e_delete_clsflower()
8875 pf->flags &= ~I40E_FLAG_FD_SB_TO_CLOUD_FILTER; in i40e_delete_clsflower()
8876 pf->flags &= ~I40E_FLAG_FD_SB_INACTIVE; in i40e_delete_clsflower()
8956 struct i40e_pf *pf = vsi->back; in i40e_open() local
8960 if (test_bit(__I40E_TESTING, pf->state) || in i40e_open()
8961 test_bit(__I40E_BAD_EEPROM, pf->state)) in i40e_open()
8966 if (i40e_force_link_state(pf, true)) in i40e_open()
8974 wr32(&pf->hw, I40E_GLLAN_TSOMSK_F, be32_to_cpu(TCP_FLAG_PSH | in i40e_open()
8976 wr32(&pf->hw, I40E_GLLAN_TSOMSK_M, be32_to_cpu(TCP_FLAG_PSH | in i40e_open()
8979 wr32(&pf->hw, I40E_GLLAN_TSOMSK_L, be32_to_cpu(TCP_FLAG_CWR) >> 16); in i40e_open()
9018 struct i40e_pf *pf = vsi->back; in i40e_vsi_open() local
9036 dev_driver_string(&pf->pdev->dev), vsi->netdev->name); in i40e_vsi_open()
9048 dev_driver_string(&pf->pdev->dev), in i40e_vsi_open()
9049 dev_name(&pf->pdev->dev)); in i40e_vsi_open()
9073 if (vsi == pf->vsi[pf->lan_vsi]) in i40e_vsi_open()
9074 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_vsi_open()
9081 * @pf: Pointer to PF
9086 static void i40e_fdir_filter_exit(struct i40e_pf *pf) in i40e_fdir_filter_exit() argument
9093 &pf->fdir_filter_list, fdir_node) { in i40e_fdir_filter_exit()
9098 list_for_each_entry_safe(pit_entry, tmp, &pf->l3_flex_pit_list, list) { in i40e_fdir_filter_exit()
9102 INIT_LIST_HEAD(&pf->l3_flex_pit_list); in i40e_fdir_filter_exit()
9104 list_for_each_entry_safe(pit_entry, tmp, &pf->l4_flex_pit_list, list) { in i40e_fdir_filter_exit()
9108 INIT_LIST_HEAD(&pf->l4_flex_pit_list); in i40e_fdir_filter_exit()
9110 pf->fdir_pf_active_filters = 0; in i40e_fdir_filter_exit()
9111 i40e_reset_fdir_filter_cnt(pf); in i40e_fdir_filter_exit()
9114 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_TCP, in i40e_fdir_filter_exit()
9119 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV6_TCP, in i40e_fdir_filter_exit()
9124 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_UDP, in i40e_fdir_filter_exit()
9129 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV6_UDP, in i40e_fdir_filter_exit()
9134 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_SCTP, in i40e_fdir_filter_exit()
9139 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV6_SCTP, in i40e_fdir_filter_exit()
9144 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_OTHER, in i40e_fdir_filter_exit()
9147 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_FRAG_IPV4, in i40e_fdir_filter_exit()
9151 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV6_OTHER, in i40e_fdir_filter_exit()
9154 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_FRAG_IPV6, in i40e_fdir_filter_exit()
9160 * @pf: Pointer to PF
9165 static void i40e_cloud_filter_exit(struct i40e_pf *pf) in i40e_cloud_filter_exit() argument
9171 &pf->cloud_filter_list, cloud_node) { in i40e_cloud_filter_exit()
9175 pf->num_cloud_filters = 0; in i40e_cloud_filter_exit()
9177 if ((pf->flags & I40E_FLAG_FD_SB_TO_CLOUD_FILTER) && in i40e_cloud_filter_exit()
9178 !(pf->flags & I40E_FLAG_FD_SB_INACTIVE)) { in i40e_cloud_filter_exit()
9179 pf->flags |= I40E_FLAG_FD_SB_ENABLED; in i40e_cloud_filter_exit()
9180 pf->flags &= ~I40E_FLAG_FD_SB_TO_CLOUD_FILTER; in i40e_cloud_filter_exit()
9181 pf->flags &= ~I40E_FLAG_FD_SB_INACTIVE; in i40e_cloud_filter_exit()
9206 * i40e_do_reset - Start a PF or Core Reset sequence
9207 * @pf: board private structure
9212 * The essential difference in resets is that the PF Reset
9216 void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired) in i40e_do_reset() argument
9231 dev_dbg(&pf->pdev->dev, "GlobalR requested\n"); in i40e_do_reset()
9232 val = rd32(&pf->hw, I40E_GLGEN_RTRIG); in i40e_do_reset()
9234 wr32(&pf->hw, I40E_GLGEN_RTRIG, val); in i40e_do_reset()
9242 dev_dbg(&pf->pdev->dev, "CoreR requested\n"); in i40e_do_reset()
9243 val = rd32(&pf->hw, I40E_GLGEN_RTRIG); in i40e_do_reset()
9245 wr32(&pf->hw, I40E_GLGEN_RTRIG, val); in i40e_do_reset()
9246 i40e_flush(&pf->hw); in i40e_do_reset()
9250 /* Request a PF Reset in i40e_do_reset()
9252 * Resets only the PF-specific registers in i40e_do_reset()
9258 dev_dbg(&pf->pdev->dev, "PFR requested\n"); in i40e_do_reset()
9259 i40e_handle_reset_warning(pf, lock_acquired); in i40e_do_reset()
9262 /* Request a PF Reset in i40e_do_reset()
9264 * Resets PF and reinitializes PFs VSI. in i40e_do_reset()
9266 i40e_prep_for_reset(pf); in i40e_do_reset()
9267 i40e_reset_and_rebuild(pf, true, lock_acquired); in i40e_do_reset()
9268 dev_info(&pf->pdev->dev, in i40e_do_reset()
9269 pf->flags & I40E_FLAG_DISABLE_FW_LLDP ? in i40e_do_reset()
9277 dev_info(&pf->pdev->dev, in i40e_do_reset()
9279 for (v = 0; v < pf->num_alloc_vsi; v++) { in i40e_do_reset()
9280 struct i40e_vsi *vsi = pf->vsi[v]; in i40e_do_reset()
9285 i40e_vsi_reinit_locked(pf->vsi[v]); in i40e_do_reset()
9291 dev_info(&pf->pdev->dev, "VSI down requested\n"); in i40e_do_reset()
9292 for (v = 0; v < pf->num_alloc_vsi; v++) { in i40e_do_reset()
9293 struct i40e_vsi *vsi = pf->vsi[v]; in i40e_do_reset()
9303 dev_info(&pf->pdev->dev, in i40e_do_reset()
9311 * @pf: board private structure
9315 bool i40e_dcb_need_reconfig(struct i40e_pf *pf, in i40e_dcb_need_reconfig() argument
9330 dev_dbg(&pf->pdev->dev, "ETS UP2TC changed.\n"); in i40e_dcb_need_reconfig()
9336 dev_dbg(&pf->pdev->dev, "ETS TC BW Table changed.\n"); in i40e_dcb_need_reconfig()
9341 dev_dbg(&pf->pdev->dev, "ETS TSA Table changed.\n"); in i40e_dcb_need_reconfig()
9349 dev_dbg(&pf->pdev->dev, "PFC config change detected.\n"); in i40e_dcb_need_reconfig()
9357 dev_dbg(&pf->pdev->dev, "APP Table change detected.\n"); in i40e_dcb_need_reconfig()
9360 dev_dbg(&pf->pdev->dev, "dcb need_reconfig=%d\n", need_reconfig); in i40e_dcb_need_reconfig()
9366 * @pf: board private structure
9369 static int i40e_handle_lldp_event(struct i40e_pf *pf, in i40e_handle_lldp_event() argument
9374 struct i40e_hw *hw = &pf->hw; in i40e_handle_lldp_event()
9384 !(pf->flags & I40E_FLAG_DCB_CAPABLE)) in i40e_handle_lldp_event()
9386 pf->flags |= I40E_FLAG_DCB_CAPABLE; in i40e_handle_lldp_event()
9389 if (!(pf->flags & I40E_FLAG_DCB_CAPABLE)) in i40e_handle_lldp_event()
9395 dev_dbg(&pf->pdev->dev, "LLDP event mib bridge type 0x%x\n", type); in i40e_handle_lldp_event()
9401 dev_dbg(&pf->pdev->dev, in i40e_handle_lldp_event()
9417 ret = i40e_get_dcb_config(&pf->hw); in i40e_handle_lldp_event()
9423 dev_warn(&pf->pdev->dev, in i40e_handle_lldp_event()
9425 pf->flags &= ~I40E_FLAG_DCB_CAPABLE; in i40e_handle_lldp_event()
9427 dev_info(&pf->pdev->dev, in i40e_handle_lldp_event()
9429 i40e_stat_str(&pf->hw, ret), in i40e_handle_lldp_event()
9430 i40e_aq_str(&pf->hw, in i40e_handle_lldp_event()
9431 pf->hw.aq.asq_last_status)); in i40e_handle_lldp_event()
9439 dev_dbg(&pf->pdev->dev, "No change detected in DCBX configuration.\n"); in i40e_handle_lldp_event()
9443 need_reconfig = i40e_dcb_need_reconfig(pf, &tmp_dcbx_cfg, in i40e_handle_lldp_event()
9446 i40e_dcbnl_flush_apps(pf, &tmp_dcbx_cfg, &hw->local_dcbx_config); in i40e_handle_lldp_event()
9453 pf->flags |= I40E_FLAG_DCB_ENABLED; in i40e_handle_lldp_event()
9455 pf->flags &= ~I40E_FLAG_DCB_ENABLED; in i40e_handle_lldp_event()
9457 set_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_handle_lldp_event()
9459 i40e_pf_quiesce_all_vsi(pf); in i40e_handle_lldp_event()
9462 i40e_dcb_reconfigure(pf); in i40e_handle_lldp_event()
9464 ret = i40e_resume_port_tx(pf); in i40e_handle_lldp_event()
9466 clear_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_handle_lldp_event()
9471 /* Wait for the PF's queues to be disabled */ in i40e_handle_lldp_event()
9472 ret = i40e_pf_wait_queues_disabled(pf); in i40e_handle_lldp_event()
9474 /* Schedule PF reset to recover */ in i40e_handle_lldp_event()
9475 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_handle_lldp_event()
9476 i40e_service_event_schedule(pf); in i40e_handle_lldp_event()
9478 i40e_pf_unquiesce_all_vsi(pf); in i40e_handle_lldp_event()
9479 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_handle_lldp_event()
9480 set_bit(__I40E_CLIENT_L2_CHANGE, pf->state); in i40e_handle_lldp_event()
9490 * @pf: board private structure
9494 void i40e_do_reset_safe(struct i40e_pf *pf, u32 reset_flags) in i40e_do_reset_safe() argument
9497 i40e_do_reset(pf, reset_flags, true); in i40e_do_reset_safe()
9503 * @pf: board private structure
9506 * Handler for LAN Queue Overflow Event generated by the firmware for PF
9509 static void i40e_handle_lan_overflow_event(struct i40e_pf *pf, in i40e_handle_lan_overflow_event() argument
9516 struct i40e_hw *hw = &pf->hw; in i40e_handle_lan_overflow_event()
9520 dev_dbg(&pf->pdev->dev, "overflow Rx Queue Number = %d QTX_CTL=0x%08x\n", in i40e_handle_lan_overflow_event()
9529 vf = &pf->vf[vf_id]; in i40e_handle_lan_overflow_event()
9539 * @pf: board private structure
9541 u32 i40e_get_cur_guaranteed_fd_count(struct i40e_pf *pf) in i40e_get_cur_guaranteed_fd_count() argument
9545 val = rd32(&pf->hw, I40E_PFQF_FDSTAT); in i40e_get_cur_guaranteed_fd_count()
9551 * i40e_get_current_fd_count - Get total FD filters programmed for this PF
9552 * @pf: board private structure
9554 u32 i40e_get_current_fd_count(struct i40e_pf *pf) in i40e_get_current_fd_count() argument
9558 val = rd32(&pf->hw, I40E_PFQF_FDSTAT); in i40e_get_current_fd_count()
9567 * @pf: board private structure
9569 u32 i40e_get_global_fd_count(struct i40e_pf *pf) in i40e_get_global_fd_count() argument
9573 val = rd32(&pf->hw, I40E_GLQF_FDCNT_0); in i40e_get_global_fd_count()
9582 * @pf: board private structure
9584 static void i40e_reenable_fdir_sb(struct i40e_pf *pf) in i40e_reenable_fdir_sb() argument
9586 if (test_and_clear_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state)) in i40e_reenable_fdir_sb()
9587 if ((pf->flags & I40E_FLAG_FD_SB_ENABLED) && in i40e_reenable_fdir_sb()
9588 (I40E_DEBUG_FD & pf->hw.debug_mask)) in i40e_reenable_fdir_sb()
9589 …dev_info(&pf->pdev->dev, "FD Sideband/ntuple is being enabled since we have space in the table now… in i40e_reenable_fdir_sb()
9594 * @pf: board private structure
9596 static void i40e_reenable_fdir_atr(struct i40e_pf *pf) in i40e_reenable_fdir_atr() argument
9598 if (test_and_clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state)) { in i40e_reenable_fdir_atr()
9604 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_TCP, in i40e_reenable_fdir_atr()
9608 if ((pf->flags & I40E_FLAG_FD_ATR_ENABLED) && in i40e_reenable_fdir_atr()
9609 (I40E_DEBUG_FD & pf->hw.debug_mask)) in i40e_reenable_fdir_atr()
9610 …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()
9616 * @pf: board private structure
9619 static void i40e_delete_invalid_filter(struct i40e_pf *pf, in i40e_delete_invalid_filter() argument
9623 pf->fdir_pf_active_filters--; in i40e_delete_invalid_filter()
9624 pf->fd_inv = 0; in i40e_delete_invalid_filter()
9628 pf->fd_tcp4_filter_cnt--; in i40e_delete_invalid_filter()
9631 pf->fd_udp4_filter_cnt--; in i40e_delete_invalid_filter()
9634 pf->fd_sctp4_filter_cnt--; in i40e_delete_invalid_filter()
9637 pf->fd_tcp6_filter_cnt--; in i40e_delete_invalid_filter()
9640 pf->fd_udp6_filter_cnt--; in i40e_delete_invalid_filter()
9643 pf->fd_udp6_filter_cnt--; in i40e_delete_invalid_filter()
9648 pf->fd_tcp4_filter_cnt--; in i40e_delete_invalid_filter()
9651 pf->fd_udp4_filter_cnt--; in i40e_delete_invalid_filter()
9654 pf->fd_sctp4_filter_cnt--; in i40e_delete_invalid_filter()
9657 pf->fd_ip4_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_sctp6_filter_cnt--; in i40e_delete_invalid_filter()
9673 pf->fd_ip6_filter_cnt--; in i40e_delete_invalid_filter()
9686 * @pf: board private structure
9688 void i40e_fdir_check_and_reenable(struct i40e_pf *pf) in i40e_fdir_check_and_reenable() argument
9694 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_fdir_check_and_reenable()
9698 fcnt_prog = i40e_get_global_fd_count(pf); in i40e_fdir_check_and_reenable()
9699 fcnt_avail = pf->fdir_pf_filter_count; in i40e_fdir_check_and_reenable()
9701 (pf->fd_add_err == 0) || in i40e_fdir_check_and_reenable()
9702 (i40e_get_current_atr_cnt(pf) < pf->fd_atr_cnt)) in i40e_fdir_check_and_reenable()
9703 i40e_reenable_fdir_sb(pf); in i40e_fdir_check_and_reenable()
9710 pf->fd_tcp4_filter_cnt == 0 && pf->fd_tcp6_filter_cnt == 0) in i40e_fdir_check_and_reenable()
9711 i40e_reenable_fdir_atr(pf); in i40e_fdir_check_and_reenable()
9714 if (pf->fd_inv > 0) { in i40e_fdir_check_and_reenable()
9716 &pf->fdir_filter_list, fdir_node) in i40e_fdir_check_and_reenable()
9717 if (filter->fd_id == pf->fd_inv) in i40e_fdir_check_and_reenable()
9718 i40e_delete_invalid_filter(pf, filter); in i40e_fdir_check_and_reenable()
9726 * @pf: board private structure
9728 static void i40e_fdir_flush_and_replay(struct i40e_pf *pf) in i40e_fdir_flush_and_replay() argument
9736 if (!time_after(jiffies, pf->fd_flush_timestamp + in i40e_fdir_flush_and_replay()
9743 min_flush_time = pf->fd_flush_timestamp + in i40e_fdir_flush_and_replay()
9745 fd_room = pf->fdir_pf_filter_count - pf->fdir_pf_active_filters; in i40e_fdir_flush_and_replay()
9749 if (I40E_DEBUG_FD & pf->hw.debug_mask) in i40e_fdir_flush_and_replay()
9750 dev_info(&pf->pdev->dev, "ATR disabled, not enough FD filter space.\n"); in i40e_fdir_flush_and_replay()
9754 pf->fd_flush_timestamp = jiffies; in i40e_fdir_flush_and_replay()
9755 set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state); in i40e_fdir_flush_and_replay()
9757 wr32(&pf->hw, I40E_PFQF_CTL_1, in i40e_fdir_flush_and_replay()
9759 i40e_flush(&pf->hw); in i40e_fdir_flush_and_replay()
9760 pf->fd_flush_cnt++; in i40e_fdir_flush_and_replay()
9761 pf->fd_add_err = 0; in i40e_fdir_flush_and_replay()
9765 reg = rd32(&pf->hw, I40E_PFQF_CTL_1); in i40e_fdir_flush_and_replay()
9770 dev_warn(&pf->pdev->dev, "FD table did not flush, needs more time\n"); in i40e_fdir_flush_and_replay()
9773 i40e_fdir_filter_restore(pf->vsi[pf->lan_vsi]); in i40e_fdir_flush_and_replay()
9774 if (!disable_atr && !pf->fd_tcp4_filter_cnt) in i40e_fdir_flush_and_replay()
9775 clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state); in i40e_fdir_flush_and_replay()
9776 clear_bit(__I40E_FD_FLUSH_REQUESTED, pf->state); in i40e_fdir_flush_and_replay()
9777 if (I40E_DEBUG_FD & pf->hw.debug_mask) in i40e_fdir_flush_and_replay()
9778 dev_info(&pf->pdev->dev, "FD Filter table flushed and FD-SB replayed.\n"); in i40e_fdir_flush_and_replay()
9784 * @pf: board private structure
9786 u32 i40e_get_current_atr_cnt(struct i40e_pf *pf) in i40e_get_current_atr_cnt() argument
9788 return i40e_get_current_fd_count(pf) - pf->fdir_pf_active_filters; in i40e_get_current_atr_cnt()
9793 * @pf: board private structure
9795 static void i40e_fdir_reinit_subtask(struct i40e_pf *pf) in i40e_fdir_reinit_subtask() argument
9799 if (test_bit(__I40E_DOWN, pf->state)) in i40e_fdir_reinit_subtask()
9802 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_fdir_reinit_subtask()
9803 i40e_fdir_flush_and_replay(pf); in i40e_fdir_reinit_subtask()
9805 i40e_fdir_check_and_reenable(pf); in i40e_fdir_reinit_subtask()
9851 struct i40e_pf *pf; in i40e_veb_link_event() local
9854 if (!veb || !veb->pf) in i40e_veb_link_event()
9856 pf = veb->pf; in i40e_veb_link_event()
9860 if (pf->veb[i] && (pf->veb[i]->uplink_seid == veb->seid)) in i40e_veb_link_event()
9861 i40e_veb_link_event(pf->veb[i], link_up); in i40e_veb_link_event()
9864 for (i = 0; i < pf->num_alloc_vsi; i++) in i40e_veb_link_event()
9865 if (pf->vsi[i] && (pf->vsi[i]->uplink_seid == veb->seid)) in i40e_veb_link_event()
9866 i40e_vsi_link_event(pf->vsi[i], link_up); in i40e_veb_link_event()
9871 * @pf: board private structure
9873 static void i40e_link_event(struct i40e_pf *pf) in i40e_link_event() argument
9875 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; in i40e_link_event()
9884 pf->hw.phy.get_link_info = true; in i40e_link_event()
9885 old_link = (pf->hw.phy.link_info_old.link_info & I40E_AQ_LINK_UP); in i40e_link_event()
9886 status = i40e_get_link_status(&pf->hw, &new_link); in i40e_link_event()
9890 clear_bit(__I40E_TEMP_LINK_POLLING, pf->state); in i40e_link_event()
9895 set_bit(__I40E_TEMP_LINK_POLLING, pf->state); in i40e_link_event()
9896 dev_dbg(&pf->pdev->dev, "couldn't get link state, status: %d\n", in i40e_link_event()
9901 old_link_speed = pf->hw.phy.link_info_old.link_speed; in i40e_link_event()
9902 new_link_speed = pf->hw.phy.link_info.link_speed; in i40e_link_event()
9915 if (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb]) in i40e_link_event()
9916 i40e_veb_link_event(pf->veb[pf->lan_veb], new_link); in i40e_link_event()
9920 if (pf->vf) in i40e_link_event()
9921 i40e_vc_notify_link_state(pf); in i40e_link_event()
9923 if (pf->flags & I40E_FLAG_PTP) in i40e_link_event()
9924 i40e_ptp_set_increment(pf); in i40e_link_event()
9929 if (pf->dcbx_cap & DCB_CAP_DCBX_LLD_MANAGED) in i40e_link_event()
9936 dev_dbg(&pf->pdev->dev, "Reconfig DCB to single TC as result of Link Down\n"); in i40e_link_event()
9937 memset(&pf->tmp_cfg, 0, sizeof(pf->tmp_cfg)); in i40e_link_event()
9938 err = i40e_dcb_sw_default_config(pf); in i40e_link_event()
9940 pf->flags &= ~(I40E_FLAG_DCB_CAPABLE | in i40e_link_event()
9943 pf->dcbx_cap = DCB_CAP_DCBX_HOST | in i40e_link_event()
9945 pf->flags |= I40E_FLAG_DCB_CAPABLE; in i40e_link_event()
9946 pf->flags &= ~I40E_FLAG_DCB_ENABLED; in i40e_link_event()
9954 * @pf: board private structure
9956 static void i40e_watchdog_subtask(struct i40e_pf *pf) in i40e_watchdog_subtask() argument
9961 if (test_bit(__I40E_DOWN, pf->state) || in i40e_watchdog_subtask()
9962 test_bit(__I40E_CONFIG_BUSY, pf->state)) in i40e_watchdog_subtask()
9966 if (time_before(jiffies, (pf->service_timer_previous + in i40e_watchdog_subtask()
9967 pf->service_timer_period))) in i40e_watchdog_subtask()
9969 pf->service_timer_previous = jiffies; in i40e_watchdog_subtask()
9971 if ((pf->flags & I40E_FLAG_LINK_POLLING_ENABLED) || in i40e_watchdog_subtask()
9972 test_bit(__I40E_TEMP_LINK_POLLING, pf->state)) in i40e_watchdog_subtask()
9973 i40e_link_event(pf); in i40e_watchdog_subtask()
9978 for (i = 0; i < pf->num_alloc_vsi; i++) in i40e_watchdog_subtask()
9979 if (pf->vsi[i] && pf->vsi[i]->netdev) in i40e_watchdog_subtask()
9980 i40e_update_stats(pf->vsi[i]); in i40e_watchdog_subtask()
9982 if (pf->flags & I40E_FLAG_VEB_STATS_ENABLED) { in i40e_watchdog_subtask()
9985 if (pf->veb[i]) in i40e_watchdog_subtask()
9986 i40e_update_veb_stats(pf->veb[i]); in i40e_watchdog_subtask()
9989 i40e_ptp_rx_hang(pf); in i40e_watchdog_subtask()
9990 i40e_ptp_tx_hang(pf); in i40e_watchdog_subtask()
9995 * @pf: board private structure
9997 static void i40e_reset_subtask(struct i40e_pf *pf) in i40e_reset_subtask() argument
10001 if (test_bit(__I40E_REINIT_REQUESTED, pf->state)) { in i40e_reset_subtask()
10003 clear_bit(__I40E_REINIT_REQUESTED, pf->state); in i40e_reset_subtask()
10005 if (test_bit(__I40E_PF_RESET_REQUESTED, pf->state)) { in i40e_reset_subtask()
10007 clear_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_reset_subtask()
10009 if (test_bit(__I40E_CORE_RESET_REQUESTED, pf->state)) { in i40e_reset_subtask()
10011 clear_bit(__I40E_CORE_RESET_REQUESTED, pf->state); in i40e_reset_subtask()
10013 if (test_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state)) { in i40e_reset_subtask()
10015 clear_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state); in i40e_reset_subtask()
10017 if (test_bit(__I40E_DOWN_REQUESTED, pf->state)) { in i40e_reset_subtask()
10019 clear_bit(__I40E_DOWN_REQUESTED, pf->state); in i40e_reset_subtask()
10025 if (test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) { in i40e_reset_subtask()
10026 i40e_prep_for_reset(pf); in i40e_reset_subtask()
10027 i40e_reset(pf); in i40e_reset_subtask()
10028 i40e_rebuild(pf, false, false); in i40e_reset_subtask()
10033 !test_bit(__I40E_DOWN, pf->state) && in i40e_reset_subtask()
10034 !test_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_reset_subtask()
10035 i40e_do_reset(pf, reset_flags, false); in i40e_reset_subtask()
10041 * @pf: board private structure
10044 static void i40e_handle_link_event(struct i40e_pf *pf, in i40e_handle_link_event() argument
10056 i40e_link_event(pf); in i40e_handle_link_event()
10060 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10062 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10071 (!(pf->flags & I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED))) { in i40e_handle_link_event()
10072 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10074 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10082 * @pf: board private structure
10084 static void i40e_clean_adminq_subtask(struct i40e_pf *pf) in i40e_clean_adminq_subtask() argument
10087 struct i40e_hw *hw = &pf->hw; in i40e_clean_adminq_subtask()
10094 /* Do not run clean AQ when PF reset fails */ in i40e_clean_adminq_subtask()
10095 if (test_bit(__I40E_RESET_FAILED, pf->state)) in i40e_clean_adminq_subtask()
10099 val = rd32(&pf->hw, pf->hw.aq.arq.len); in i40e_clean_adminq_subtask()
10103 dev_info(&pf->pdev->dev, "ARQ VF Error detected\n"); in i40e_clean_adminq_subtask()
10108 dev_info(&pf->pdev->dev, "ARQ Overflow Error detected\n"); in i40e_clean_adminq_subtask()
10110 pf->arq_overflows++; in i40e_clean_adminq_subtask()
10114 dev_info(&pf->pdev->dev, "ARQ Critical Error detected\n"); in i40e_clean_adminq_subtask()
10118 wr32(&pf->hw, pf->hw.aq.arq.len, val); in i40e_clean_adminq_subtask()
10120 val = rd32(&pf->hw, pf->hw.aq.asq.len); in i40e_clean_adminq_subtask()
10123 if (pf->hw.debug_mask & I40E_DEBUG_AQ) in i40e_clean_adminq_subtask()
10124 dev_info(&pf->pdev->dev, "ASQ VF Error detected\n"); in i40e_clean_adminq_subtask()
10128 if (pf->hw.debug_mask & I40E_DEBUG_AQ) in i40e_clean_adminq_subtask()
10129 dev_info(&pf->pdev->dev, "ASQ Overflow Error detected\n"); in i40e_clean_adminq_subtask()
10133 if (pf->hw.debug_mask & I40E_DEBUG_AQ) in i40e_clean_adminq_subtask()
10134 dev_info(&pf->pdev->dev, "ASQ Critical Error detected\n"); in i40e_clean_adminq_subtask()
10138 wr32(&pf->hw, pf->hw.aq.asq.len, val); in i40e_clean_adminq_subtask()
10150 dev_info(&pf->pdev->dev, "ARQ event error %d\n", ret); in i40e_clean_adminq_subtask()
10159 i40e_handle_link_event(pf, &event); in i40e_clean_adminq_subtask()
10163 ret = i40e_vc_process_vf_msg(pf, in i40e_clean_adminq_subtask()
10171 dev_dbg(&pf->pdev->dev, "ARQ: Update LLDP MIB event received\n"); in i40e_clean_adminq_subtask()
10174 i40e_handle_lldp_event(pf, &event); in i40e_clean_adminq_subtask()
10179 dev_dbg(&pf->pdev->dev, "ARQ LAN queue overflow event received\n"); in i40e_clean_adminq_subtask()
10180 i40e_handle_lan_overflow_event(pf, &event); in i40e_clean_adminq_subtask()
10183 dev_info(&pf->pdev->dev, "ARQ: Msg from other pf\n"); in i40e_clean_adminq_subtask()
10188 i40e_debug(&pf->hw, I40E_DEBUG_NVM, in i40e_clean_adminq_subtask()
10193 dev_info(&pf->pdev->dev, in i40e_clean_adminq_subtask()
10198 } while (i++ < pf->adminq_work_limit); in i40e_clean_adminq_subtask()
10200 if (i < pf->adminq_work_limit) in i40e_clean_adminq_subtask()
10201 clear_bit(__I40E_ADMINQ_EVENT_PENDING, pf->state); in i40e_clean_adminq_subtask()
10214 * @pf: board private structure
10216 static void i40e_verify_eeprom(struct i40e_pf *pf) in i40e_verify_eeprom() argument
10220 err = i40e_diag_eeprom_test(&pf->hw); in i40e_verify_eeprom()
10223 err = i40e_diag_eeprom_test(&pf->hw); in i40e_verify_eeprom()
10225 dev_info(&pf->pdev->dev, "eeprom check failed (%d), Tx/Rx traffic disabled\n", in i40e_verify_eeprom()
10227 set_bit(__I40E_BAD_EEPROM, pf->state); in i40e_verify_eeprom()
10231 if (!err && test_bit(__I40E_BAD_EEPROM, pf->state)) { in i40e_verify_eeprom()
10232 dev_info(&pf->pdev->dev, "eeprom check passed, Tx/Rx traffic enabled\n"); in i40e_verify_eeprom()
10233 clear_bit(__I40E_BAD_EEPROM, pf->state); in i40e_verify_eeprom()
10239 * @pf: pointer to the PF structure
10243 static void i40e_enable_pf_switch_lb(struct i40e_pf *pf) in i40e_enable_pf_switch_lb() argument
10245 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; in i40e_enable_pf_switch_lb()
10249 ctxt.seid = pf->main_vsi_seid; in i40e_enable_pf_switch_lb()
10250 ctxt.pf_num = pf->hw.pf_id; in i40e_enable_pf_switch_lb()
10252 ret = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL); in i40e_enable_pf_switch_lb()
10254 dev_info(&pf->pdev->dev, in i40e_enable_pf_switch_lb()
10255 "couldn't get PF vsi config, err %s aq_err %s\n", in i40e_enable_pf_switch_lb()
10256 i40e_stat_str(&pf->hw, ret), in i40e_enable_pf_switch_lb()
10257 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_enable_pf_switch_lb()
10266 dev_info(&pf->pdev->dev, in i40e_enable_pf_switch_lb()
10268 i40e_stat_str(&pf->hw, ret), in i40e_enable_pf_switch_lb()
10269 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_enable_pf_switch_lb()
10275 * @pf: pointer to the PF structure
10279 static void i40e_disable_pf_switch_lb(struct i40e_pf *pf) in i40e_disable_pf_switch_lb() argument
10281 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; in i40e_disable_pf_switch_lb()
10285 ctxt.seid = pf->main_vsi_seid; in i40e_disable_pf_switch_lb()
10286 ctxt.pf_num = pf->hw.pf_id; in i40e_disable_pf_switch_lb()
10288 ret = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL); in i40e_disable_pf_switch_lb()
10290 dev_info(&pf->pdev->dev, in i40e_disable_pf_switch_lb()
10291 "couldn't get PF vsi config, err %s aq_err %s\n", in i40e_disable_pf_switch_lb()
10292 i40e_stat_str(&pf->hw, ret), in i40e_disable_pf_switch_lb()
10293 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_disable_pf_switch_lb()
10302 dev_info(&pf->pdev->dev, in i40e_disable_pf_switch_lb()
10304 i40e_stat_str(&pf->hw, ret), in i40e_disable_pf_switch_lb()
10305 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_disable_pf_switch_lb()
10319 struct i40e_pf *pf = veb->pf; in i40e_config_bridge_mode() local
10321 if (pf->hw.debug_mask & I40E_DEBUG_LAN) in i40e_config_bridge_mode()
10322 dev_info(&pf->pdev->dev, "enabling bridge mode: %s\n", in i40e_config_bridge_mode()
10325 i40e_disable_pf_switch_lb(pf); in i40e_config_bridge_mode()
10327 i40e_enable_pf_switch_lb(pf); in i40e_config_bridge_mode()
10342 struct i40e_pf *pf = veb->pf; in i40e_reconstitute_veb() local
10347 for (v = 0; v < pf->num_alloc_vsi && !ctl_vsi; v++) { in i40e_reconstitute_veb()
10348 if (pf->vsi[v] && in i40e_reconstitute_veb()
10349 pf->vsi[v]->veb_idx == veb->idx && in i40e_reconstitute_veb()
10350 pf->vsi[v]->flags & I40E_VSI_FLAG_VEB_OWNER) { in i40e_reconstitute_veb()
10351 ctl_vsi = pf->vsi[v]; in i40e_reconstitute_veb()
10356 dev_info(&pf->pdev->dev, in i40e_reconstitute_veb()
10361 if (ctl_vsi != pf->vsi[pf->lan_vsi]) in i40e_reconstitute_veb()
10362 ctl_vsi->uplink_seid = pf->vsi[pf->lan_vsi]->uplink_seid; in i40e_reconstitute_veb()
10365 dev_info(&pf->pdev->dev, in i40e_reconstitute_veb()
10377 if (pf->flags & I40E_FLAG_VEB_MODE_ENABLED) in i40e_reconstitute_veb()
10384 for (v = 0; v < pf->num_alloc_vsi; v++) { in i40e_reconstitute_veb()
10385 if (!pf->vsi[v] || pf->vsi[v] == ctl_vsi) in i40e_reconstitute_veb()
10388 if (pf->vsi[v]->veb_idx == veb->idx) { in i40e_reconstitute_veb()
10389 struct i40e_vsi *vsi = pf->vsi[v]; in i40e_reconstitute_veb()
10394 dev_info(&pf->pdev->dev, in i40e_reconstitute_veb()
10405 if (pf->veb[veb_idx] && pf->veb[veb_idx]->veb_idx == veb->idx) { in i40e_reconstitute_veb()
10406 pf->veb[veb_idx]->uplink_seid = veb->seid; in i40e_reconstitute_veb()
10407 ret = i40e_reconstitute_veb(pf->veb[veb_idx]); in i40e_reconstitute_veb()
10419 * @pf: the PF struct
10422 static int i40e_get_capabilities(struct i40e_pf *pf, in i40e_get_capabilities() argument
10437 err = i40e_aq_discover_capabilities(&pf->hw, cap_buf, buf_len, in i40e_get_capabilities()
10443 if (pf->hw.aq.asq_last_status == I40E_AQ_RC_ENOMEM) { in i40e_get_capabilities()
10446 } else if (pf->hw.aq.asq_last_status != I40E_AQ_RC_OK || err) { in i40e_get_capabilities()
10447 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10449 i40e_stat_str(&pf->hw, err), in i40e_get_capabilities()
10450 i40e_aq_str(&pf->hw, in i40e_get_capabilities()
10451 pf->hw.aq.asq_last_status)); in i40e_get_capabilities()
10456 if (pf->hw.debug_mask & I40E_DEBUG_USER) { in i40e_get_capabilities()
10458 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10459 "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()
10460 pf->hw.pf_id, pf->hw.func_caps.num_vfs, in i40e_get_capabilities()
10461 pf->hw.func_caps.num_msix_vectors, in i40e_get_capabilities()
10462 pf->hw.func_caps.num_msix_vectors_vf, in i40e_get_capabilities()
10463 pf->hw.func_caps.fd_filters_guaranteed, in i40e_get_capabilities()
10464 pf->hw.func_caps.fd_filters_best_effort, in i40e_get_capabilities()
10465 pf->hw.func_caps.num_tx_qp, in i40e_get_capabilities()
10466 pf->hw.func_caps.num_vsis); in i40e_get_capabilities()
10468 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10470 pf->hw.dev_caps.switch_mode, in i40e_get_capabilities()
10471 pf->hw.dev_caps.valid_functions); in i40e_get_capabilities()
10472 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10474 pf->hw.dev_caps.sr_iov_1_1, in i40e_get_capabilities()
10475 pf->hw.dev_caps.num_vfs); in i40e_get_capabilities()
10476 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10478 pf->hw.dev_caps.num_vsis, in i40e_get_capabilities()
10479 pf->hw.dev_caps.num_rx_qp, in i40e_get_capabilities()
10480 pf->hw.dev_caps.num_tx_qp); in i40e_get_capabilities()
10484 #define DEF_NUM_VSI (1 + (pf->hw.func_caps.fcoe ? 1 : 0) \ in i40e_get_capabilities()
10485 + pf->hw.func_caps.num_vfs) in i40e_get_capabilities()
10486 if (pf->hw.revision_id == 0 && in i40e_get_capabilities()
10487 pf->hw.func_caps.num_vsis < DEF_NUM_VSI) { in i40e_get_capabilities()
10488 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10490 pf->hw.func_caps.num_vsis, DEF_NUM_VSI); in i40e_get_capabilities()
10491 pf->hw.func_caps.num_vsis = DEF_NUM_VSI; in i40e_get_capabilities()
10501 * @pf: board private structure
10503 static void i40e_fdir_sb_setup(struct i40e_pf *pf) in i40e_fdir_sb_setup() argument
10510 if (!rd32(&pf->hw, I40E_GLQF_HKEY(0))) { in i40e_fdir_sb_setup()
10519 wr32(&pf->hw, I40E_GLQF_HKEY(i), hkey[i]); in i40e_fdir_sb_setup()
10522 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED)) in i40e_fdir_sb_setup()
10526 vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR); in i40e_fdir_sb_setup()
10530 vsi = i40e_vsi_setup(pf, I40E_VSI_FDIR, in i40e_fdir_sb_setup()
10531 pf->vsi[pf->lan_vsi]->seid, 0); in i40e_fdir_sb_setup()
10533 dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n"); in i40e_fdir_sb_setup()
10534 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED; in i40e_fdir_sb_setup()
10535 pf->flags |= I40E_FLAG_FD_SB_INACTIVE; in i40e_fdir_sb_setup()
10545 * @pf: board private structure
10547 static void i40e_fdir_teardown(struct i40e_pf *pf) in i40e_fdir_teardown() argument
10551 i40e_fdir_filter_exit(pf); in i40e_fdir_teardown()
10552 vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR); in i40e_fdir_teardown()
10559 * @vsi: PF main vsi
10568 struct i40e_pf *pf = vsi->back; in i40e_rebuild_cloud_filters() local
10573 hlist_for_each_entry_safe(cfilter, node, &pf->cloud_filter_list, in i40e_rebuild_cloud_filters()
10585 dev_dbg(&pf->pdev->dev, in i40e_rebuild_cloud_filters()
10587 i40e_stat_str(&pf->hw, ret), in i40e_rebuild_cloud_filters()
10588 i40e_aq_str(&pf->hw, in i40e_rebuild_cloud_filters()
10589 pf->hw.aq.asq_last_status)); in i40e_rebuild_cloud_filters()
10598 * @vsi: PF main vsi
10674 * @pf: board private structure
10676 * Close up the VFs and other things in prep for PF Reset.
10678 static void i40e_prep_for_reset(struct i40e_pf *pf) in i40e_prep_for_reset() argument
10680 struct i40e_hw *hw = &pf->hw; in i40e_prep_for_reset()
10684 clear_bit(__I40E_RESET_INTR_RECEIVED, pf->state); in i40e_prep_for_reset()
10685 if (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_prep_for_reset()
10687 if (i40e_check_asq_alive(&pf->hw)) in i40e_prep_for_reset()
10688 i40e_vc_notify_reset(pf); in i40e_prep_for_reset()
10690 dev_dbg(&pf->pdev->dev, "Tearing down internal switch for reset\n"); in i40e_prep_for_reset()
10693 i40e_pf_quiesce_all_vsi(pf); in i40e_prep_for_reset()
10695 for (v = 0; v < pf->num_alloc_vsi; v++) { in i40e_prep_for_reset()
10696 if (pf->vsi[v]) { in i40e_prep_for_reset()
10697 i40e_clean_xps_state(pf->vsi[v]); in i40e_prep_for_reset()
10698 pf->vsi[v]->seid = 0; in i40e_prep_for_reset()
10702 i40e_shutdown_adminq(&pf->hw); in i40e_prep_for_reset()
10708 dev_warn(&pf->pdev->dev, in i40e_prep_for_reset()
10715 i40e_ptp_save_hw_time(pf); in i40e_prep_for_reset()
10720 * @pf: PF struct
10722 static void i40e_send_version(struct i40e_pf *pf) in i40e_send_version() argument
10731 i40e_aq_send_driver_version(&pf->hw, &dv, NULL); in i40e_send_version()
10780 * i40e_reset - wait for core reset to finish reset, reset pf if corer not seen
10781 * @pf: board private structure
10783 static int i40e_reset(struct i40e_pf *pf) in i40e_reset() argument
10785 struct i40e_hw *hw = &pf->hw; in i40e_reset()
10790 dev_info(&pf->pdev->dev, "PF reset failed, %d\n", ret); in i40e_reset()
10791 set_bit(__I40E_RESET_FAILED, pf->state); in i40e_reset()
10792 clear_bit(__I40E_RESET_RECOVERY_PENDING, pf->state); in i40e_reset()
10794 pf->pfr_count++; in i40e_reset()
10801 * @pf: board private structure
10806 static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired) in i40e_rebuild() argument
10808 const bool is_recovery_mode_reported = i40e_check_recovery_mode(pf); in i40e_rebuild()
10809 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; in i40e_rebuild()
10810 struct i40e_hw *hw = &pf->hw; in i40e_rebuild()
10815 if (test_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state) && in i40e_rebuild()
10817 i40e_set_ethtool_ops(pf->vsi[pf->lan_vsi]->netdev); in i40e_rebuild()
10819 if (test_bit(__I40E_DOWN, pf->state) && in i40e_rebuild()
10820 !test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_rebuild()
10822 dev_dbg(&pf->pdev->dev, "Rebuilding internal switch\n"); in i40e_rebuild()
10825 ret = i40e_init_adminq(&pf->hw); in i40e_rebuild()
10827 dev_info(&pf->pdev->dev, "Rebuild AdminQ failed, err %s aq_err %s\n", in i40e_rebuild()
10828 i40e_stat_str(&pf->hw, ret), in i40e_rebuild()
10829 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_rebuild()
10832 i40e_get_oem_version(&pf->hw); in i40e_rebuild()
10834 if (test_and_clear_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state)) { in i40e_rebuild()
10840 if (test_and_clear_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state)) in i40e_rebuild()
10841 i40e_verify_eeprom(pf); in i40e_rebuild()
10847 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_rebuild()
10848 if (i40e_get_capabilities(pf, in i40e_rebuild()
10856 if (i40e_setup_misc_vector_for_recovery_mode(pf)) in i40e_rebuild()
10865 free_irq(pf->pdev->irq, pf); in i40e_rebuild()
10866 i40e_clear_interrupt_scheme(pf); in i40e_rebuild()
10867 if (i40e_restore_interrupt_scheme(pf)) in i40e_rebuild()
10872 i40e_send_version(pf); in i40e_rebuild()
10881 ret = i40e_get_capabilities(pf, i40e_aqc_opc_list_func_capabilities); in i40e_rebuild()
10888 dev_info(&pf->pdev->dev, "init_lan_hmc failed: %d\n", ret); in i40e_rebuild()
10893 dev_info(&pf->pdev->dev, "configure_lan_hmc failed: %d\n", ret); in i40e_rebuild()
10902 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_rebuild()
10909 dev_warn(&pf->pdev->dev, in i40e_rebuild()
10911 pf->flags &= ~I40E_FLAG_DCB_CAPABLE; in i40e_rebuild()
10914 ret = i40e_init_pf_dcb(pf); in i40e_rebuild()
10916 dev_info(&pf->pdev->dev, "DCB init failed %d, disabled\n", in i40e_rebuild()
10918 pf->flags &= ~I40E_FLAG_DCB_CAPABLE; in i40e_rebuild()
10927 ret = i40e_setup_pf_switch(pf, reinit, true); in i40e_rebuild()
10934 ret = i40e_aq_set_phy_int_mask(&pf->hw, in i40e_rebuild()
10939 dev_info(&pf->pdev->dev, "set phy mask fail, err %s aq_err %s\n", in i40e_rebuild()
10940 i40e_stat_str(&pf->hw, ret), in i40e_rebuild()
10941 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_rebuild()
10948 * to recover minimal use by getting the basic PF VSI working. in i40e_rebuild()
10950 if (vsi->uplink_seid != pf->mac_seid) { in i40e_rebuild()
10951 dev_dbg(&pf->pdev->dev, "attempting to rebuild switch\n"); in i40e_rebuild()
10954 if (!pf->veb[v]) in i40e_rebuild()
10957 if (pf->veb[v]->uplink_seid == pf->mac_seid || in i40e_rebuild()
10958 pf->veb[v]->uplink_seid == 0) { in i40e_rebuild()
10959 ret = i40e_reconstitute_veb(pf->veb[v]); in i40e_rebuild()
10966 * for minimal rebuild of PF VSI. in i40e_rebuild()
10970 if (pf->veb[v]->uplink_seid == pf->mac_seid) { in i40e_rebuild()
10971 dev_info(&pf->pdev->dev, in i40e_rebuild()
10972 "rebuild of switch failed: %d, will try to set up simple PF connection\n", in i40e_rebuild()
10974 vsi->uplink_seid = pf->mac_seid; in i40e_rebuild()
10976 } else if (pf->veb[v]->uplink_seid == 0) { in i40e_rebuild()
10977 dev_info(&pf->pdev->dev, in i40e_rebuild()
10985 if (vsi->uplink_seid == pf->mac_seid) { in i40e_rebuild()
10986 dev_dbg(&pf->pdev->dev, "attempting to rebuild PF VSI\n"); in i40e_rebuild()
10990 dev_info(&pf->pdev->dev, in i40e_rebuild()
11018 /* PF Main VSI is rebuild by now, go ahead and rebuild channel VSIs in i40e_rebuild()
11039 if (pf->hw_features & I40E_HW_RESTART_AUTONEG) { in i40e_rebuild()
11041 ret = i40e_aq_set_link_restart_an(&pf->hw, true, NULL); in i40e_rebuild()
11043 dev_info(&pf->pdev->dev, "link restart failed, err %s aq_err %s\n", in i40e_rebuild()
11044 i40e_stat_str(&pf->hw, ret), in i40e_rebuild()
11045 i40e_aq_str(&pf->hw, in i40e_rebuild()
11046 pf->hw.aq.asq_last_status)); in i40e_rebuild()
11049 if (pf->flags & I40E_FLAG_MSIX_ENABLED) in i40e_rebuild()
11050 ret = i40e_setup_misc_vector(pf); in i40e_rebuild()
11055 * PF/VF VSIs. in i40e_rebuild()
11058 i40e_add_filter_to_drop_tx_flow_control_frames(&pf->hw, in i40e_rebuild()
11059 pf->main_vsi_seid); in i40e_rebuild()
11062 i40e_pf_unquiesce_all_vsi(pf); in i40e_rebuild()
11069 ret = i40e_set_promiscuous(pf, pf->cur_promisc); in i40e_rebuild()
11071 dev_warn(&pf->pdev->dev, in i40e_rebuild()
11073 pf->cur_promisc ? "on" : "off", in i40e_rebuild()
11074 i40e_stat_str(&pf->hw, ret), in i40e_rebuild()
11075 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_rebuild()
11077 i40e_reset_all_vfs(pf, true); in i40e_rebuild()
11080 i40e_send_version(pf); in i40e_rebuild()
11089 clear_bit(__I40E_RESET_FAILED, pf->state); in i40e_rebuild()
11091 clear_bit(__I40E_RESET_RECOVERY_PENDING, pf->state); in i40e_rebuild()
11092 clear_bit(__I40E_TIMEOUT_RECOVERY_PENDING, pf->state); in i40e_rebuild()
11097 * @pf: board private structure
11102 static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit, in i40e_reset_and_rebuild() argument
11107 if (test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_reset_and_rebuild()
11113 ret = i40e_reset(pf); in i40e_reset_and_rebuild()
11115 i40e_rebuild(pf, reinit, lock_acquired); in i40e_reset_and_rebuild()
11119 * i40e_handle_reset_warning - prep for the PF to reset, reset and rebuild
11120 * @pf: board private structure
11127 static void i40e_handle_reset_warning(struct i40e_pf *pf, bool lock_acquired) in i40e_handle_reset_warning() argument
11129 i40e_prep_for_reset(pf); in i40e_handle_reset_warning()
11130 i40e_reset_and_rebuild(pf, false, lock_acquired); in i40e_handle_reset_warning()
11135 * @pf: pointer to the PF structure
11139 static void i40e_handle_mdd_event(struct i40e_pf *pf) in i40e_handle_mdd_event() argument
11141 struct i40e_hw *hw = &pf->hw; in i40e_handle_mdd_event()
11147 if (!test_bit(__I40E_MDD_EVENT_PENDING, pf->state)) in i40e_handle_mdd_event()
11161 pf->hw.func_caps.base_queue; in i40e_handle_mdd_event()
11162 if (netif_msg_tx_err(pf)) in i40e_handle_mdd_event()
11163 …dev_info(&pf->pdev->dev, "Malicious Driver Detection event 0x%02x on TX queue %d PF number 0x%02x … in i40e_handle_mdd_event()
11176 pf->hw.func_caps.base_queue; in i40e_handle_mdd_event()
11177 if (netif_msg_rx_err(pf)) in i40e_handle_mdd_event()
11178 …dev_info(&pf->pdev->dev, "Malicious Driver Detection event 0x%02x on RX queue %d of function 0x%02… in i40e_handle_mdd_event()
11188 dev_dbg(&pf->pdev->dev, "TX driver issue detected on PF\n"); in i40e_handle_mdd_event()
11193 dev_dbg(&pf->pdev->dev, "RX driver issue detected on PF\n"); in i40e_handle_mdd_event()
11198 for (i = 0; i < pf->num_alloc_vfs && mdd_detected; i++) { in i40e_handle_mdd_event()
11199 vf = &(pf->vf[i]); in i40e_handle_mdd_event()
11204 dev_info(&pf->pdev->dev, "TX driver issue detected on VF %d\n", in i40e_handle_mdd_event()
11206 dev_info(&pf->pdev->dev, in i40e_handle_mdd_event()
11207 "Use PF Control I/F to re-enable the VF\n"); in i40e_handle_mdd_event()
11215 dev_info(&pf->pdev->dev, "RX driver issue detected on VF %d\n", in i40e_handle_mdd_event()
11217 dev_info(&pf->pdev->dev, in i40e_handle_mdd_event()
11218 "Use PF Control I/F to re-enable the VF\n"); in i40e_handle_mdd_event()
11224 clear_bit(__I40E_MDD_EVENT_PENDING, pf->state); in i40e_handle_mdd_event()
11237 struct i40e_pf *pf = container_of(work, in i40e_service_task() local
11243 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_service_task()
11244 test_bit(__I40E_SUSPENDED, pf->state)) in i40e_service_task()
11247 if (test_and_set_bit(__I40E_SERVICE_SCHED, pf->state)) in i40e_service_task()
11250 if (!test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_service_task()
11251 i40e_detect_recover_hung(pf->vsi[pf->lan_vsi]); in i40e_service_task()
11252 i40e_sync_filters_subtask(pf); in i40e_service_task()
11253 i40e_reset_subtask(pf); in i40e_service_task()
11254 i40e_handle_mdd_event(pf); in i40e_service_task()
11255 i40e_vc_process_vflr_event(pf); in i40e_service_task()
11256 i40e_watchdog_subtask(pf); in i40e_service_task()
11257 i40e_fdir_reinit_subtask(pf); in i40e_service_task()
11258 if (test_and_clear_bit(__I40E_CLIENT_RESET, pf->state)) { in i40e_service_task()
11260 i40e_notify_client_of_netdev_close(pf->vsi[pf->lan_vsi], in i40e_service_task()
11263 i40e_client_subtask(pf); in i40e_service_task()
11265 pf->state)) in i40e_service_task()
11267 pf->vsi[pf->lan_vsi]); in i40e_service_task()
11269 i40e_sync_filters_subtask(pf); in i40e_service_task()
11271 i40e_reset_subtask(pf); in i40e_service_task()
11274 i40e_clean_adminq_subtask(pf); in i40e_service_task()
11278 clear_bit(__I40E_SERVICE_SCHED, pf->state); in i40e_service_task()
11284 if (time_after(jiffies, (start_time + pf->service_timer_period)) || in i40e_service_task()
11285 test_bit(__I40E_ADMINQ_EVENT_PENDING, pf->state) || in i40e_service_task()
11286 test_bit(__I40E_MDD_EVENT_PENDING, pf->state) || in i40e_service_task()
11287 test_bit(__I40E_VFLR_EVENT_PENDING, pf->state)) in i40e_service_task()
11288 i40e_service_event_schedule(pf); in i40e_service_task()
11297 struct i40e_pf *pf = from_timer(pf, t, service_timer); in i40e_service_timer() local
11299 mod_timer(&pf->service_timer, in i40e_service_timer()
11300 round_jiffies(jiffies + pf->service_timer_period)); in i40e_service_timer()
11301 i40e_service_event_schedule(pf); in i40e_service_timer()
11310 struct i40e_pf *pf = vsi->back; in i40e_set_num_rings_in_vsi() local
11314 vsi->alloc_queue_pairs = pf->num_lan_qps; in i40e_set_num_rings_in_vsi()
11321 if (pf->flags & I40E_FLAG_MSIX_ENABLED) in i40e_set_num_rings_in_vsi()
11322 vsi->num_q_vectors = pf->num_lan_msix; in i40e_set_num_rings_in_vsi()
11334 vsi->num_q_vectors = pf->num_fdsb_msix; in i40e_set_num_rings_in_vsi()
11338 vsi->alloc_queue_pairs = pf->num_vmdq_qps; in i40e_set_num_rings_in_vsi()
11345 vsi->num_q_vectors = pf->num_vmdq_msix; in i40e_set_num_rings_in_vsi()
11349 vsi->alloc_queue_pairs = pf->num_vf_qps; in i40e_set_num_rings_in_vsi()
11415 * i40e_vsi_mem_alloc - Allocates the next available struct vsi in the PF
11416 * @pf: board private structure
11420 * On success: returns vsi index in PF (positive)
11422 static int i40e_vsi_mem_alloc(struct i40e_pf *pf, enum i40e_vsi_type type) in i40e_vsi_mem_alloc() argument
11429 /* Need to protect the allocation of the VSIs at the PF level */ in i40e_vsi_mem_alloc()
11430 mutex_lock(&pf->switch_mutex); in i40e_vsi_mem_alloc()
11438 i = pf->next_vsi; in i40e_vsi_mem_alloc()
11439 while (i < pf->num_alloc_vsi && pf->vsi[i]) in i40e_vsi_mem_alloc()
11441 if (i >= pf->num_alloc_vsi) { in i40e_vsi_mem_alloc()
11443 while (i < pf->next_vsi && pf->vsi[i]) in i40e_vsi_mem_alloc()
11447 if (i < pf->num_alloc_vsi && !pf->vsi[i]) { in i40e_vsi_mem_alloc()
11453 pf->next_vsi = ++i; in i40e_vsi_mem_alloc()
11461 vsi->back = pf; in i40e_vsi_mem_alloc()
11467 pf->rss_table_size : 64; in i40e_vsi_mem_alloc()
11474 vsi->af_xdp_zc_qps = bitmap_zalloc(pf->num_lan_qps, GFP_KERNEL); in i40e_vsi_mem_alloc()
11492 pf->vsi[vsi_idx] = vsi; in i40e_vsi_mem_alloc()
11498 pf->next_vsi = i - 1; in i40e_vsi_mem_alloc()
11501 mutex_unlock(&pf->switch_mutex); in i40e_vsi_mem_alloc()
11549 struct i40e_pf *pf; in i40e_vsi_clear() local
11556 pf = vsi->back; in i40e_vsi_clear()
11558 mutex_lock(&pf->switch_mutex); in i40e_vsi_clear()
11559 if (!pf->vsi[vsi->idx]) { in i40e_vsi_clear()
11560 dev_err(&pf->pdev->dev, "pf->vsi[%d] is NULL, just free vsi[%d](type %d)\n", in i40e_vsi_clear()
11565 if (pf->vsi[vsi->idx] != vsi) { in i40e_vsi_clear()
11566 dev_err(&pf->pdev->dev, in i40e_vsi_clear()
11567 "pf->vsi[%d](type %d) != vsi[%d](type %d): no free!\n", in i40e_vsi_clear()
11568 pf->vsi[vsi->idx]->idx, in i40e_vsi_clear()
11569 pf->vsi[vsi->idx]->type, in i40e_vsi_clear()
11574 /* updates the PF for this cleared vsi */ in i40e_vsi_clear()
11575 i40e_put_lump(pf->qp_pile, vsi->base_queue, vsi->idx); in i40e_vsi_clear()
11576 i40e_put_lump(pf->irq_pile, vsi->base_vector, vsi->idx); in i40e_vsi_clear()
11582 pf->vsi[vsi->idx] = NULL; in i40e_vsi_clear()
11583 if (vsi->idx < pf->next_vsi) in i40e_vsi_clear()
11584 pf->next_vsi = vsi->idx; in i40e_vsi_clear()
11587 mutex_unlock(&pf->switch_mutex); in i40e_vsi_clear()
11620 struct i40e_pf *pf = vsi->back; in i40e_alloc_rings() local
11635 ring->dev = &pf->pdev->dev; in i40e_alloc_rings()
11641 ring->itr_setting = pf->tx_itr_default; in i40e_alloc_rings()
11652 ring->dev = &pf->pdev->dev; in i40e_alloc_rings()
11659 ring->itr_setting = pf->tx_itr_default; in i40e_alloc_rings()
11668 ring->dev = &pf->pdev->dev; in i40e_alloc_rings()
11672 ring->itr_setting = pf->rx_itr_default; in i40e_alloc_rings()
11685 * @pf: board private structure
11690 static int i40e_reserve_msix_vectors(struct i40e_pf *pf, int vectors) in i40e_reserve_msix_vectors() argument
11692 vectors = pci_enable_msix_range(pf->pdev, pf->msix_entries, in i40e_reserve_msix_vectors()
11695 dev_info(&pf->pdev->dev, in i40e_reserve_msix_vectors()
11705 * @pf: board private structure
11711 static int i40e_init_msix(struct i40e_pf *pf) in i40e_init_msix() argument
11713 struct i40e_hw *hw = &pf->hw; in i40e_init_msix()
11720 if (!(pf->flags & I40E_FLAG_MSIX_ENABLED)) in i40e_init_msix()
11747 /* reserve some vectors for the main PF traffic queues. Initially we in i40e_init_msix()
11755 pf->num_lan_msix = min_t(int, cpus, vectors_left / 2); in i40e_init_msix()
11756 vectors_left -= pf->num_lan_msix; in i40e_init_msix()
11759 if (pf->flags & I40E_FLAG_FD_SB_ENABLED) { in i40e_init_msix()
11761 pf->num_fdsb_msix = 1; in i40e_init_msix()
11765 pf->num_fdsb_msix = 0; in i40e_init_msix()
11770 if (pf->flags & I40E_FLAG_IWARP_ENABLED) { in i40e_init_msix()
11771 iwarp_requested = pf->num_iwarp_msix; in i40e_init_msix()
11774 pf->num_iwarp_msix = 0; in i40e_init_msix()
11775 else if (vectors_left < pf->num_iwarp_msix) in i40e_init_msix()
11776 pf->num_iwarp_msix = 1; in i40e_init_msix()
11777 v_budget += pf->num_iwarp_msix; in i40e_init_msix()
11778 vectors_left -= pf->num_iwarp_msix; in i40e_init_msix()
11782 if (pf->flags & I40E_FLAG_VMDQ_ENABLED) { in i40e_init_msix()
11784 pf->num_vmdq_msix = 0; in i40e_init_msix()
11785 pf->num_vmdq_qps = 0; in i40e_init_msix()
11788 pf->num_vmdq_vsis * pf->num_vmdq_qps; in i40e_init_msix()
11795 * queues/vectors used by the PF later with the ethtool in i40e_init_msix()
11799 pf->num_vmdq_qps = 1; in i40e_init_msix()
11800 vmdq_vecs_wanted = pf->num_vmdq_vsis; in i40e_init_msix()
11805 pf->num_vmdq_msix = pf->num_vmdq_qps; in i40e_init_msix()
11821 extra_vectors = min_t(int, cpus - pf->num_lan_msix, vectors_left); in i40e_init_msix()
11822 pf->num_lan_msix += extra_vectors; in i40e_init_msix()
11828 v_budget += pf->num_lan_msix; in i40e_init_msix()
11829 pf->msix_entries = kcalloc(v_budget, sizeof(struct msix_entry), in i40e_init_msix()
11831 if (!pf->msix_entries) in i40e_init_msix()
11835 pf->msix_entries[i].entry = i; in i40e_init_msix()
11836 v_actual = i40e_reserve_msix_vectors(pf, v_budget); in i40e_init_msix()
11839 pf->flags &= ~I40E_FLAG_MSIX_ENABLED; in i40e_init_msix()
11840 kfree(pf->msix_entries); in i40e_init_msix()
11841 pf->msix_entries = NULL; in i40e_init_msix()
11842 pci_disable_msix(pf->pdev); in i40e_init_msix()
11847 pf->num_vmdq_vsis = 0; in i40e_init_msix()
11848 pf->num_vmdq_qps = 0; in i40e_init_msix()
11849 pf->num_lan_qps = 1; in i40e_init_msix()
11850 pf->num_lan_msix = 1; in i40e_init_msix()
11860 dev_info(&pf->pdev->dev, in i40e_init_msix()
11867 pf->num_vmdq_msix = 1; /* force VMDqs to only one vector */ in i40e_init_msix()
11868 pf->num_vmdq_vsis = 1; in i40e_init_msix()
11869 pf->num_vmdq_qps = 1; in i40e_init_msix()
11874 pf->num_lan_msix = 1; in i40e_init_msix()
11877 if (pf->flags & I40E_FLAG_IWARP_ENABLED) { in i40e_init_msix()
11878 pf->num_lan_msix = 1; in i40e_init_msix()
11879 pf->num_iwarp_msix = 1; in i40e_init_msix()
11881 pf->num_lan_msix = 2; in i40e_init_msix()
11885 if (pf->flags & I40E_FLAG_IWARP_ENABLED) { in i40e_init_msix()
11886 pf->num_iwarp_msix = min_t(int, (vec / 3), in i40e_init_msix()
11888 pf->num_vmdq_vsis = min_t(int, (vec / 3), in i40e_init_msix()
11891 pf->num_vmdq_vsis = min_t(int, (vec / 2), in i40e_init_msix()
11894 if (pf->flags & I40E_FLAG_FD_SB_ENABLED) { in i40e_init_msix()
11895 pf->num_fdsb_msix = 1; in i40e_init_msix()
11898 pf->num_lan_msix = min_t(int, in i40e_init_msix()
11899 (vec - (pf->num_iwarp_msix + pf->num_vmdq_vsis)), in i40e_init_msix()
11900 pf->num_lan_msix); in i40e_init_msix()
11901 pf->num_lan_qps = pf->num_lan_msix; in i40e_init_msix()
11906 if ((pf->flags & I40E_FLAG_FD_SB_ENABLED) && in i40e_init_msix()
11907 (pf->num_fdsb_msix == 0)) { in i40e_init_msix()
11908 dev_info(&pf->pdev->dev, "Sideband Flowdir disabled, not enough MSI-X vectors\n"); in i40e_init_msix()
11909 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED; in i40e_init_msix()
11910 pf->flags |= I40E_FLAG_FD_SB_INACTIVE; in i40e_init_msix()
11912 if ((pf->flags & I40E_FLAG_VMDQ_ENABLED) && in i40e_init_msix()
11913 (pf->num_vmdq_msix == 0)) { in i40e_init_msix()
11914 dev_info(&pf->pdev->dev, "VMDq disabled, not enough MSI-X vectors\n"); in i40e_init_msix()
11915 pf->flags &= ~I40E_FLAG_VMDQ_ENABLED; in i40e_init_msix()
11918 if ((pf->flags & I40E_FLAG_IWARP_ENABLED) && in i40e_init_msix()
11919 (pf->num_iwarp_msix == 0)) { in i40e_init_msix()
11920 dev_info(&pf->pdev->dev, "IWARP disabled, not enough MSI-X vectors\n"); in i40e_init_msix()
11921 pf->flags &= ~I40E_FLAG_IWARP_ENABLED; in i40e_init_msix()
11923 i40e_debug(&pf->hw, I40E_DEBUG_INIT, in i40e_init_msix()
11924 "MSI-X vector distribution: PF %d, VMDq %d, FDSB %d, iWARP %d\n", in i40e_init_msix()
11925 pf->num_lan_msix, in i40e_init_msix()
11926 pf->num_vmdq_msix * pf->num_vmdq_vsis, in i40e_init_msix()
11927 pf->num_fdsb_msix, in i40e_init_msix()
11928 pf->num_iwarp_msix); in i40e_init_msix()
11971 struct i40e_pf *pf = vsi->back; in i40e_vsi_alloc_q_vectors() local
11975 if (pf->flags & I40E_FLAG_MSIX_ENABLED) in i40e_vsi_alloc_q_vectors()
11977 else if (vsi == pf->vsi[pf->lan_vsi]) in i40e_vsi_alloc_q_vectors()
11999 * @pf: board private structure to initialize
12001 static int i40e_init_interrupt_scheme(struct i40e_pf *pf) in i40e_init_interrupt_scheme() argument
12006 if (pf->flags & I40E_FLAG_MSIX_ENABLED) { in i40e_init_interrupt_scheme()
12007 vectors = i40e_init_msix(pf); in i40e_init_interrupt_scheme()
12009 pf->flags &= ~(I40E_FLAG_MSIX_ENABLED | in i40e_init_interrupt_scheme()
12018 pf->flags |= I40E_FLAG_FD_SB_INACTIVE; in i40e_init_interrupt_scheme()
12021 i40e_determine_queue_usage(pf); in i40e_init_interrupt_scheme()
12025 if (!(pf->flags & I40E_FLAG_MSIX_ENABLED) && in i40e_init_interrupt_scheme()
12026 (pf->flags & I40E_FLAG_MSI_ENABLED)) { in i40e_init_interrupt_scheme()
12027 dev_info(&pf->pdev->dev, "MSI-X not available, trying MSI\n"); in i40e_init_interrupt_scheme()
12028 vectors = pci_enable_msi(pf->pdev); in i40e_init_interrupt_scheme()
12030 dev_info(&pf->pdev->dev, "MSI init failed - %d\n", in i40e_init_interrupt_scheme()
12032 pf->flags &= ~I40E_FLAG_MSI_ENABLED; in i40e_init_interrupt_scheme()
12037 if (!(pf->flags & (I40E_FLAG_MSIX_ENABLED | I40E_FLAG_MSI_ENABLED))) in i40e_init_interrupt_scheme()
12038 dev_info(&pf->pdev->dev, "MSI-X and MSI not available, falling back to Legacy IRQ\n"); in i40e_init_interrupt_scheme()
12042 pf->irq_pile = kzalloc(size, GFP_KERNEL); in i40e_init_interrupt_scheme()
12043 if (!pf->irq_pile) in i40e_init_interrupt_scheme()
12046 pf->irq_pile->num_entries = vectors; in i40e_init_interrupt_scheme()
12049 (void)i40e_get_lump(pf, pf->irq_pile, 1, I40E_PILE_VALID_BIT - 1); in i40e_init_interrupt_scheme()
12056 * @pf: private board data structure
12062 static int i40e_restore_interrupt_scheme(struct i40e_pf *pf) in i40e_restore_interrupt_scheme() argument
12070 pf->flags |= (I40E_FLAG_MSIX_ENABLED | I40E_FLAG_MSI_ENABLED); in i40e_restore_interrupt_scheme()
12072 err = i40e_init_interrupt_scheme(pf); in i40e_restore_interrupt_scheme()
12079 for (i = 0; i < pf->num_alloc_vsi; i++) { in i40e_restore_interrupt_scheme()
12080 if (pf->vsi[i]) { in i40e_restore_interrupt_scheme()
12081 err = i40e_vsi_alloc_q_vectors(pf->vsi[i]); in i40e_restore_interrupt_scheme()
12084 i40e_vsi_map_rings_to_vectors(pf->vsi[i]); in i40e_restore_interrupt_scheme()
12088 err = i40e_setup_misc_vector(pf); in i40e_restore_interrupt_scheme()
12092 if (pf->flags & I40E_FLAG_IWARP_ENABLED) in i40e_restore_interrupt_scheme()
12093 i40e_client_update_msix_info(pf); in i40e_restore_interrupt_scheme()
12099 if (pf->vsi[i]) in i40e_restore_interrupt_scheme()
12100 i40e_vsi_free_q_vectors(pf->vsi[i]); in i40e_restore_interrupt_scheme()
12109 * @pf: board private structure
12116 static int i40e_setup_misc_vector_for_recovery_mode(struct i40e_pf *pf) in i40e_setup_misc_vector_for_recovery_mode() argument
12120 if (pf->flags & I40E_FLAG_MSIX_ENABLED) { in i40e_setup_misc_vector_for_recovery_mode()
12121 err = i40e_setup_misc_vector(pf); in i40e_setup_misc_vector_for_recovery_mode()
12124 dev_info(&pf->pdev->dev, in i40e_setup_misc_vector_for_recovery_mode()
12130 u32 flags = pf->flags & I40E_FLAG_MSI_ENABLED ? 0 : IRQF_SHARED; in i40e_setup_misc_vector_for_recovery_mode()
12132 err = request_irq(pf->pdev->irq, i40e_intr, flags, in i40e_setup_misc_vector_for_recovery_mode()
12133 pf->int_name, pf); in i40e_setup_misc_vector_for_recovery_mode()
12136 dev_info(&pf->pdev->dev, in i40e_setup_misc_vector_for_recovery_mode()
12141 i40e_enable_misc_int_causes(pf); in i40e_setup_misc_vector_for_recovery_mode()
12142 i40e_irq_dynamic_enable_icr0(pf); in i40e_setup_misc_vector_for_recovery_mode()
12150 * @pf: board private structure
12156 static int i40e_setup_misc_vector(struct i40e_pf *pf) in i40e_setup_misc_vector() argument
12158 struct i40e_hw *hw = &pf->hw; in i40e_setup_misc_vector()
12162 if (!test_and_set_bit(__I40E_MISC_IRQ_REQUESTED, pf->state)) { in i40e_setup_misc_vector()
12163 err = request_irq(pf->msix_entries[0].vector, in i40e_setup_misc_vector()
12164 i40e_intr, 0, pf->int_name, pf); in i40e_setup_misc_vector()
12166 clear_bit(__I40E_MISC_IRQ_REQUESTED, pf->state); in i40e_setup_misc_vector()
12167 dev_info(&pf->pdev->dev, in i40e_setup_misc_vector()
12169 pf->int_name, err); in i40e_setup_misc_vector()
12174 i40e_enable_misc_int_causes(pf); in i40e_setup_misc_vector()
12182 i40e_irq_dynamic_enable_icr0(pf); in i40e_setup_misc_vector()
12199 struct i40e_pf *pf = vsi->back; in i40e_get_rss_aq() local
12200 struct i40e_hw *hw = &pf->hw; in i40e_get_rss_aq()
12207 dev_info(&pf->pdev->dev, in i40e_get_rss_aq()
12209 i40e_stat_str(&pf->hw, ret), in i40e_get_rss_aq()
12210 i40e_aq_str(&pf->hw, in i40e_get_rss_aq()
12211 pf->hw.aq.asq_last_status)); in i40e_get_rss_aq()
12221 dev_info(&pf->pdev->dev, in i40e_get_rss_aq()
12223 i40e_stat_str(&pf->hw, ret), in i40e_get_rss_aq()
12224 i40e_aq_str(&pf->hw, in i40e_get_rss_aq()
12225 pf->hw.aq.asq_last_status)); in i40e_get_rss_aq()
12245 struct i40e_pf *pf = vsi->back; in i40e_config_rss_reg() local
12246 struct i40e_hw *hw = &pf->hw; in i40e_config_rss_reg()
12261 dev_err(&pf->pdev->dev, "Cannot set RSS seed - invalid VSI type\n"); in i40e_config_rss_reg()
12279 dev_err(&pf->pdev->dev, "Cannot set RSS LUT - invalid VSI type\n"); in i40e_config_rss_reg()
12299 struct i40e_pf *pf = vsi->back; in i40e_get_rss_reg() local
12300 struct i40e_hw *hw = &pf->hw; in i40e_get_rss_reg()
12332 struct i40e_pf *pf = vsi->back; in i40e_config_rss() local
12334 if (pf->hw_features & I40E_HW_RSS_AQ_CAPABLE) in i40e_config_rss()
12351 struct i40e_pf *pf = vsi->back; in i40e_get_rss() local
12353 if (pf->hw_features & I40E_HW_RSS_AQ_CAPABLE) in i40e_get_rss()
12361 * @pf: Pointer to board private structure
12366 void i40e_fill_rss_lut(struct i40e_pf *pf, u8 *lut, in i40e_fill_rss_lut() argument
12377 * @pf: board private structure
12379 static int i40e_pf_config_rss(struct i40e_pf *pf) in i40e_pf_config_rss() argument
12381 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; in i40e_pf_config_rss()
12384 struct i40e_hw *hw = &pf->hw; in i40e_pf_config_rss()
12392 hena |= i40e_pf_get_default_rss_hena(pf); in i40e_pf_config_rss()
12399 reg_val = (pf->rss_table_size == 512) ? in i40e_pf_config_rss()
12414 vsi->rss_size = min_t(int, pf->alloc_rss_size, qcount); in i40e_pf_config_rss()
12427 i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, vsi->rss_size); in i40e_pf_config_rss()
12444 * @pf: board private structure
12451 int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count) in i40e_reconfig_rss_queues() argument
12453 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; in i40e_reconfig_rss_queues()
12456 if (!(pf->flags & I40E_FLAG_RSS_ENABLED)) in i40e_reconfig_rss_queues()
12460 new_rss_size = min_t(int, queue_count, pf->rss_size_max); in i40e_reconfig_rss_queues()
12466 i40e_prep_for_reset(pf); in i40e_reconfig_rss_queues()
12467 if (test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_reconfig_rss_queues()
12468 return pf->alloc_rss_size; in i40e_reconfig_rss_queues()
12470 pf->alloc_rss_size = new_rss_size; in i40e_reconfig_rss_queues()
12472 i40e_reset_and_rebuild(pf, true, true); in i40e_reconfig_rss_queues()
12479 dev_dbg(&pf->pdev->dev, in i40e_reconfig_rss_queues()
12485 vsi->rss_size = min_t(int, pf->alloc_rss_size, qcount); in i40e_reconfig_rss_queues()
12487 i40e_pf_config_rss(pf); in i40e_reconfig_rss_queues()
12489 dev_info(&pf->pdev->dev, "User requested queue count/HW max RSS count: %d/%d\n", in i40e_reconfig_rss_queues()
12490 vsi->req_queue_pairs, pf->rss_size_max); in i40e_reconfig_rss_queues()
12491 return pf->alloc_rss_size; in i40e_reconfig_rss_queues()
12495 * i40e_get_partition_bw_setting - Retrieve BW settings for this PF partition
12496 * @pf: board private structure
12498 i40e_status i40e_get_partition_bw_setting(struct i40e_pf *pf) in i40e_get_partition_bw_setting() argument
12504 status = i40e_read_bw_from_alt_ram(&pf->hw, &max_bw, &min_bw, in i40e_get_partition_bw_setting()
12509 pf->min_bw = min_bw; in i40e_get_partition_bw_setting()
12511 pf->max_bw = max_bw; in i40e_get_partition_bw_setting()
12518 * i40e_set_partition_bw_setting - Set BW settings for this PF partition
12519 * @pf: board private structure
12521 i40e_status i40e_set_partition_bw_setting(struct i40e_pf *pf) in i40e_set_partition_bw_setting() argument
12528 /* Set the valid bit for this PF */ in i40e_set_partition_bw_setting()
12529 bw_data.pf_valid_bits = cpu_to_le16(BIT(pf->hw.pf_id)); in i40e_set_partition_bw_setting()
12530 bw_data.max_bw[pf->hw.pf_id] = pf->max_bw & I40E_ALT_BW_VALUE_MASK; in i40e_set_partition_bw_setting()
12531 bw_data.min_bw[pf->hw.pf_id] = pf->min_bw & I40E_ALT_BW_VALUE_MASK; in i40e_set_partition_bw_setting()
12534 status = i40e_aq_configure_partition_bw(&pf->hw, &bw_data, NULL); in i40e_set_partition_bw_setting()
12540 * i40e_commit_partition_bw_setting - Commit BW settings for this PF partition
12541 * @pf: board private structure
12543 i40e_status i40e_commit_partition_bw_setting(struct i40e_pf *pf) in i40e_commit_partition_bw_setting() argument
12550 if (pf->hw.partition_id != 1) { in i40e_commit_partition_bw_setting()
12551 dev_info(&pf->pdev->dev, in i40e_commit_partition_bw_setting()
12553 pf->hw.partition_id); in i40e_commit_partition_bw_setting()
12559 ret = i40e_acquire_nvm(&pf->hw, I40E_RESOURCE_READ); in i40e_commit_partition_bw_setting()
12560 last_aq_status = pf->hw.aq.asq_last_status; in i40e_commit_partition_bw_setting()
12562 dev_info(&pf->pdev->dev, in i40e_commit_partition_bw_setting()
12564 i40e_stat_str(&pf->hw, ret), in i40e_commit_partition_bw_setting()
12565 i40e_aq_str(&pf->hw, last_aq_status)); in i40e_commit_partition_bw_setting()
12570 ret = i40e_aq_read_nvm(&pf->hw, in i40e_commit_partition_bw_setting()
12577 last_aq_status = pf->hw.aq.asq_last_status; in i40e_commit_partition_bw_setting()
12578 i40e_release_nvm(&pf->hw); in i40e_commit_partition_bw_setting()
12580 dev_info(&pf->pdev->dev, "NVM read error, err %s aq_err %s\n", in i40e_commit_partition_bw_setting()
12581 i40e_stat_str(&pf->hw, ret), in i40e_commit_partition_bw_setting()
12582 i40e_aq_str(&pf->hw, last_aq_status)); in i40e_commit_partition_bw_setting()
12590 ret = i40e_acquire_nvm(&pf->hw, I40E_RESOURCE_WRITE); in i40e_commit_partition_bw_setting()
12591 last_aq_status = pf->hw.aq.asq_last_status; in i40e_commit_partition_bw_setting()
12593 dev_info(&pf->pdev->dev, in i40e_commit_partition_bw_setting()
12595 i40e_stat_str(&pf->hw, ret), in i40e_commit_partition_bw_setting()
12596 i40e_aq_str(&pf->hw, last_aq_status)); in i40e_commit_partition_bw_setting()
12603 ret = i40e_aq_update_nvm(&pf->hw, in i40e_commit_partition_bw_setting()
12610 last_aq_status = pf->hw.aq.asq_last_status; in i40e_commit_partition_bw_setting()
12611 i40e_release_nvm(&pf->hw); in i40e_commit_partition_bw_setting()
12613 dev_info(&pf->pdev->dev, in i40e_commit_partition_bw_setting()
12615 i40e_stat_str(&pf->hw, ret), in i40e_commit_partition_bw_setting()
12616 i40e_aq_str(&pf->hw, last_aq_status)); in i40e_commit_partition_bw_setting()
12624 * if total port shutdown feature is enabled for this PF
12625 * @pf: board private structure
12627 static bool i40e_is_total_port_shutdown_enabled(struct i40e_pf *pf) in i40e_is_total_port_shutdown_enabled() argument
12642 read_status = i40e_read_nvm_word(&pf->hw, in i40e_is_total_port_shutdown_enabled()
12647 read_status = i40e_read_nvm_word(&pf->hw, in i40e_is_total_port_shutdown_enabled()
12654 read_status = i40e_read_nvm_module_data(&pf->hw, in i40e_is_total_port_shutdown_enabled()
12662 link_behavior >>= (pf->hw.port * I40E_LINK_BEHAVIOR_PORT_BIT_LENGTH); in i40e_is_total_port_shutdown_enabled()
12668 dev_warn(&pf->pdev->dev, in i40e_is_total_port_shutdown_enabled()
12670 i40e_stat_str(&pf->hw, read_status)); in i40e_is_total_port_shutdown_enabled()
12676 * @pf: board private structure to initialize
12682 static int i40e_sw_init(struct i40e_pf *pf) in i40e_sw_init() argument
12689 pf->flags = I40E_FLAG_RX_CSUM_ENABLED | in i40e_sw_init()
12694 pf->rx_itr_default = I40E_ITR_RX_DEF; in i40e_sw_init()
12695 pf->tx_itr_default = I40E_ITR_TX_DEF; in i40e_sw_init()
12697 /* Depending on PF configurations, it is possible that the RSS in i40e_sw_init()
12700 pf->rss_size_max = BIT(pf->hw.func_caps.rss_table_entry_width); in i40e_sw_init()
12701 pf->alloc_rss_size = 1; in i40e_sw_init()
12702 pf->rss_table_size = pf->hw.func_caps.rss_table_size; in i40e_sw_init()
12703 pf->rss_size_max = min_t(int, pf->rss_size_max, in i40e_sw_init()
12704 pf->hw.func_caps.num_tx_qp); in i40e_sw_init()
12708 pf->rss_size_max = min_t(int, pf->rss_size_max, pow); in i40e_sw_init()
12710 if (pf->hw.func_caps.rss) { in i40e_sw_init()
12711 pf->flags |= I40E_FLAG_RSS_ENABLED; in i40e_sw_init()
12712 pf->alloc_rss_size = min_t(int, pf->rss_size_max, in i40e_sw_init()
12717 if (pf->hw.func_caps.npar_enable || pf->hw.func_caps.flex10_enable) { in i40e_sw_init()
12718 pf->flags |= I40E_FLAG_MFP_ENABLED; in i40e_sw_init()
12719 dev_info(&pf->pdev->dev, "MFP mode Enabled\n"); in i40e_sw_init()
12720 if (i40e_get_partition_bw_setting(pf)) { in i40e_sw_init()
12721 dev_warn(&pf->pdev->dev, in i40e_sw_init()
12724 dev_info(&pf->pdev->dev, in i40e_sw_init()
12726 pf->min_bw, pf->max_bw); in i40e_sw_init()
12729 i40e_set_partition_bw_setting(pf); in i40e_sw_init()
12733 if ((pf->hw.func_caps.fd_filters_guaranteed > 0) || in i40e_sw_init()
12734 (pf->hw.func_caps.fd_filters_best_effort > 0)) { in i40e_sw_init()
12735 pf->flags |= I40E_FLAG_FD_ATR_ENABLED; in i40e_sw_init()
12736 pf->atr_sample_rate = I40E_DEFAULT_ATR_SAMPLE_RATE; in i40e_sw_init()
12737 if (pf->flags & I40E_FLAG_MFP_ENABLED && in i40e_sw_init()
12738 pf->hw.num_partitions > 1) in i40e_sw_init()
12739 dev_info(&pf->pdev->dev, in i40e_sw_init()
12742 pf->flags |= I40E_FLAG_FD_SB_ENABLED; in i40e_sw_init()
12743 pf->fdir_pf_filter_count = in i40e_sw_init()
12744 pf->hw.func_caps.fd_filters_guaranteed; in i40e_sw_init()
12745 pf->hw.fdir_shared_filter_count = in i40e_sw_init()
12746 pf->hw.func_caps.fd_filters_best_effort; in i40e_sw_init()
12749 if (pf->hw.mac.type == I40E_MAC_X722) { in i40e_sw_init()
12750 pf->hw_features |= (I40E_HW_RSS_AQ_CAPABLE | in i40e_sw_init()
12763 if (rd32(&pf->hw, I40E_GLQF_FDEVICTENA(1)) != in i40e_sw_init()
12765 dev_warn(&pf->pdev->dev, in i40e_sw_init()
12767 pf->hw_features &= ~I40E_HW_ATR_EVICT_CAPABLE; in i40e_sw_init()
12769 } else if ((pf->hw.aq.api_maj_ver > 1) || in i40e_sw_init()
12770 ((pf->hw.aq.api_maj_ver == 1) && in i40e_sw_init()
12771 (pf->hw.aq.api_min_ver > 4))) { in i40e_sw_init()
12773 pf->hw_features |= I40E_HW_GENEVE_OFFLOAD_CAPABLE; in i40e_sw_init()
12777 if (pf->hw_features & I40E_HW_ATR_EVICT_CAPABLE) in i40e_sw_init()
12778 pf->flags |= I40E_FLAG_HW_ATR_EVICT_ENABLED; in i40e_sw_init()
12780 if ((pf->hw.mac.type == I40E_MAC_XL710) && in i40e_sw_init()
12781 (((pf->hw.aq.fw_maj_ver == 4) && (pf->hw.aq.fw_min_ver < 33)) || in i40e_sw_init()
12782 (pf->hw.aq.fw_maj_ver < 4))) { in i40e_sw_init()
12783 pf->hw_features |= I40E_HW_RESTART_AUTONEG; in i40e_sw_init()
12785 pf->hw_features |= I40E_HW_NO_DCB_SUPPORT; in i40e_sw_init()
12789 if ((pf->hw.mac.type == I40E_MAC_XL710) && in i40e_sw_init()
12790 (((pf->hw.aq.fw_maj_ver == 4) && (pf->hw.aq.fw_min_ver < 3)) || in i40e_sw_init()
12791 (pf->hw.aq.fw_maj_ver < 4))) in i40e_sw_init()
12792 pf->hw_features |= I40E_HW_STOP_FW_LLDP; in i40e_sw_init()
12795 if ((pf->hw.mac.type == I40E_MAC_XL710) && in i40e_sw_init()
12796 (((pf->hw.aq.fw_maj_ver == 4) && (pf->hw.aq.fw_min_ver >= 40)) || in i40e_sw_init()
12797 (pf->hw.aq.fw_maj_ver >= 5))) in i40e_sw_init()
12798 pf->hw_features |= I40E_HW_USE_SET_LLDP_MIB; in i40e_sw_init()
12801 if (pf->hw.mac.type == I40E_MAC_XL710 && in i40e_sw_init()
12802 pf->hw.aq.fw_maj_ver >= 6) in i40e_sw_init()
12803 pf->hw_features |= I40E_HW_PTP_L4_CAPABLE; in i40e_sw_init()
12805 if (pf->hw.func_caps.vmdq && num_online_cpus() != 1) { in i40e_sw_init()
12806 pf->num_vmdq_vsis = I40E_DEFAULT_NUM_VMDQ_VSI; in i40e_sw_init()
12807 pf->flags |= I40E_FLAG_VMDQ_ENABLED; in i40e_sw_init()
12808 pf->num_vmdq_qps = i40e_default_queues_per_vmdq(pf); in i40e_sw_init()
12811 if (pf->hw.func_caps.iwarp && num_online_cpus() != 1) { in i40e_sw_init()
12812 pf->flags |= I40E_FLAG_IWARP_ENABLED; in i40e_sw_init()
12814 pf->num_iwarp_msix = (int)num_online_cpus() + 1; in i40e_sw_init()
12821 if (pf->hw.mac.type == I40E_MAC_XL710 && in i40e_sw_init()
12822 pf->hw.func_caps.npar_enable && in i40e_sw_init()
12823 (pf->hw.flags & I40E_HW_FLAG_FW_LLDP_STOPPABLE)) in i40e_sw_init()
12824 pf->hw.flags &= ~I40E_HW_FLAG_FW_LLDP_STOPPABLE; in i40e_sw_init()
12827 if (pf->hw.func_caps.num_vfs && pf->hw.partition_id == 1) { in i40e_sw_init()
12828 pf->num_vf_qps = I40E_DEFAULT_QUEUES_PER_VF; in i40e_sw_init()
12829 pf->flags |= I40E_FLAG_SRIOV_ENABLED; in i40e_sw_init()
12830 pf->num_req_vfs = min_t(int, in i40e_sw_init()
12831 pf->hw.func_caps.num_vfs, in i40e_sw_init()
12835 pf->eeprom_version = 0xDEAD; in i40e_sw_init()
12836 pf->lan_veb = I40E_NO_VEB; in i40e_sw_init()
12837 pf->lan_vsi = I40E_NO_VSI; in i40e_sw_init()
12840 pf->flags &= ~I40E_FLAG_VEB_STATS_ENABLED; in i40e_sw_init()
12844 + (sizeof(u16) * pf->hw.func_caps.num_tx_qp); in i40e_sw_init()
12845 pf->qp_pile = kzalloc(size, GFP_KERNEL); in i40e_sw_init()
12846 if (!pf->qp_pile) { in i40e_sw_init()
12850 pf->qp_pile->num_entries = pf->hw.func_caps.num_tx_qp; in i40e_sw_init()
12852 pf->tx_timeout_recovery_level = 1; in i40e_sw_init()
12854 if (pf->hw.mac.type != I40E_MAC_X722 && in i40e_sw_init()
12855 i40e_is_total_port_shutdown_enabled(pf)) { in i40e_sw_init()
12859 pf->flags |= (I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENABLED | in i40e_sw_init()
12861 dev_info(&pf->pdev->dev, in i40e_sw_init()
12864 mutex_init(&pf->switch_mutex); in i40e_sw_init()
12872 * @pf: board private structure to initialize
12877 bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features) in i40e_set_ntuple() argument
12886 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED)) in i40e_set_ntuple()
12891 if (pf->num_fdsb_msix > 0 && !pf->num_cloud_filters) { in i40e_set_ntuple()
12892 pf->flags |= I40E_FLAG_FD_SB_ENABLED; in i40e_set_ntuple()
12893 pf->flags &= ~I40E_FLAG_FD_SB_INACTIVE; in i40e_set_ntuple()
12897 if (pf->flags & I40E_FLAG_FD_SB_ENABLED) { in i40e_set_ntuple()
12899 i40e_fdir_filter_exit(pf); in i40e_set_ntuple()
12901 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED; in i40e_set_ntuple()
12902 clear_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state); in i40e_set_ntuple()
12903 pf->flags |= I40E_FLAG_FD_SB_INACTIVE; in i40e_set_ntuple()
12906 pf->fd_add_err = 0; in i40e_set_ntuple()
12907 pf->fd_atr_cnt = 0; in i40e_set_ntuple()
12909 if (test_and_clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state)) in i40e_set_ntuple()
12910 if ((pf->flags & I40E_FLAG_FD_ATR_ENABLED) && in i40e_set_ntuple()
12911 (I40E_DEBUG_FD & pf->hw.debug_mask)) in i40e_set_ntuple()
12912 dev_info(&pf->pdev->dev, "ATR re-enabled.\n"); in i40e_set_ntuple()
12923 struct i40e_pf *pf = vsi->back; in i40e_clear_rss_lut() local
12924 struct i40e_hw *hw = &pf->hw; in i40e_clear_rss_lut()
12935 dev_err(&pf->pdev->dev, "Cannot set RSS LUT - invalid VSI type\n"); in i40e_clear_rss_lut()
12950 struct i40e_pf *pf = vsi->back; in i40e_set_features() local
12954 i40e_pf_config_rss(pf); in i40e_set_features()
12965 (netdev->features & NETIF_F_HW_TC) && pf->num_cloud_filters) { in i40e_set_features()
12966 dev_err(&pf->pdev->dev, in i40e_set_features()
12974 need_reset = i40e_set_ntuple(pf, features); in i40e_set_features()
12977 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_set_features()
13030 struct i40e_pf *pf = np->vsi->back; in i40e_get_phys_port_id() local
13031 struct i40e_hw *hw = &pf->hw; in i40e_get_phys_port_id()
13033 if (!(pf->hw_features & I40E_HW_PORT_ID_VALID)) in i40e_get_phys_port_id()
13059 struct i40e_pf *pf = np->vsi->back; in i40e_ndo_fdb_add() local
13062 if (!(pf->flags & I40E_FLAG_SRIOV_ENABLED)) in i40e_ndo_fdb_add()
13102 * is to change the mode then that requires a PF reset to
13115 struct i40e_pf *pf = vsi->back; in i40e_ndo_bridge_setlink() local
13120 /* Only for PF VSI for now */ in i40e_ndo_bridge_setlink()
13121 if (vsi->seid != pf->vsi[pf->lan_vsi]->seid) in i40e_ndo_bridge_setlink()
13124 /* Find the HW bridge for PF VSI */ in i40e_ndo_bridge_setlink()
13126 if (pf->veb[i] && pf->veb[i]->seid == vsi->uplink_seid) in i40e_ndo_bridge_setlink()
13127 veb = pf->veb[i]; in i40e_ndo_bridge_setlink()
13145 veb = i40e_veb_setup(pf, 0, vsi->uplink_seid, vsi->seid, in i40e_ndo_bridge_setlink()
13160 pf->flags |= I40E_FLAG_VEB_MODE_ENABLED; in i40e_ndo_bridge_setlink()
13162 pf->flags &= ~I40E_FLAG_VEB_MODE_ENABLED; in i40e_ndo_bridge_setlink()
13163 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_ndo_bridge_setlink()
13190 struct i40e_pf *pf = vsi->back; in i40e_ndo_bridge_getlink() local
13194 /* Only for PF VSI for now */ in i40e_ndo_bridge_getlink()
13195 if (vsi->seid != pf->vsi[pf->lan_vsi]->seid) in i40e_ndo_bridge_getlink()
13198 /* Find the HW bridge for the PF VSI */ in i40e_ndo_bridge_getlink()
13200 if (pf->veb[i] && pf->veb[i]->seid == vsi->uplink_seid) in i40e_ndo_bridge_getlink()
13201 veb = pf->veb[i]; in i40e_ndo_bridge_getlink()
13279 struct i40e_pf *pf = vsi->back; in i40e_xdp_setup() local
13294 i40e_prep_for_reset(pf); in i40e_xdp_setup()
13297 if (test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_xdp_setup()
13306 i40e_reset_and_rebuild(pf, true, true); in i40e_xdp_setup()
13343 struct i40e_pf *pf = vsi->back; in i40e_enter_busy_conf() local
13346 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_enter_busy_conf()
13362 struct i40e_pf *pf = vsi->back; in i40e_exit_busy_conf() local
13364 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_exit_busy_conf()
13437 struct i40e_pf *pf = vsi->back; in i40e_queue_pair_toggle_rings() local
13441 ret = i40e_control_wait_tx_q(vsi->seid, pf, pf_q, in i40e_queue_pair_toggle_rings()
13444 dev_info(&pf->pdev->dev, in i40e_queue_pair_toggle_rings()
13450 i40e_control_rx_q(pf, pf_q, enable); in i40e_queue_pair_toggle_rings()
13451 ret = i40e_pf_rxq_wait(pf, pf_q, enable); in i40e_queue_pair_toggle_rings()
13453 dev_info(&pf->pdev->dev, in i40e_queue_pair_toggle_rings()
13468 ret = i40e_control_wait_tx_q(vsi->seid, pf, in i40e_queue_pair_toggle_rings()
13472 dev_info(&pf->pdev->dev, in i40e_queue_pair_toggle_rings()
13488 struct i40e_pf *pf = vsi->back; in i40e_queue_pair_enable_irq() local
13489 struct i40e_hw *hw = &pf->hw; in i40e_queue_pair_enable_irq()
13492 if (pf->flags & I40E_FLAG_MSIX_ENABLED) in i40e_queue_pair_enable_irq()
13495 i40e_irq_dynamic_enable_icr0(pf); in i40e_queue_pair_enable_irq()
13508 struct i40e_pf *pf = vsi->back; in i40e_queue_pair_disable_irq() local
13509 struct i40e_hw *hw = &pf->hw; in i40e_queue_pair_disable_irq()
13517 if (pf->flags & I40E_FLAG_MSIX_ENABLED) { in i40e_queue_pair_disable_irq()
13522 synchronize_irq(pf->msix_entries[intpf].vector); in i40e_queue_pair_disable_irq()
13528 synchronize_irq(pf->pdev->irq); in i40e_queue_pair_disable_irq()
13663 struct i40e_pf *pf = vsi->back; in i40e_config_netdev() local
13664 struct i40e_hw *hw = &pf->hw; in i40e_config_netdev()
13702 if (!(pf->hw_features & I40E_HW_OUTER_UDP_CSUM_CAPABLE)) in i40e_config_netdev()
13705 netdev->udp_tunnel_nic_info = &pf->udp_tunnel_nic; in i40e_config_netdev()
13738 if (!(pf->flags & I40E_FLAG_MFP_ENABLED)) in i40e_config_netdev()
13749 SET_NETDEV_DEV(netdev, &pf->pdev->dev); in i40e_config_netdev()
13773 pf->vsi[pf->lan_vsi]->netdev->name); in i40e_config_netdev()
13845 struct i40e_pf *pf = vsi->back; in i40e_is_vsi_uplink_mode_veb() local
13851 veb = pf->veb[vsi->veb_idx]; in i40e_is_vsi_uplink_mode_veb()
13853 dev_info(&pf->pdev->dev, in i40e_is_vsi_uplink_mode_veb()
13880 struct i40e_pf *pf = vsi->back; in i40e_add_vsi() local
13881 struct i40e_hw *hw = &pf->hw; in i40e_add_vsi()
13893 /* The PF's main VSI is already setup as part of the in i40e_add_vsi()
13898 ctxt.seid = pf->main_vsi_seid; in i40e_add_vsi()
13899 ctxt.pf_num = pf->hw.pf_id; in i40e_add_vsi()
13901 ret = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL); in i40e_add_vsi()
13904 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13905 "couldn't get PF vsi config, err %s aq_err %s\n", in i40e_add_vsi()
13906 i40e_stat_str(&pf->hw, ret), in i40e_add_vsi()
13907 i40e_aq_str(&pf->hw, in i40e_add_vsi()
13908 pf->hw.aq.asq_last_status)); in i40e_add_vsi()
13917 enabled_tc = i40e_pf_get_tc_map(pf); in i40e_add_vsi()
13923 if (pf->flags & I40E_FLAG_SOURCE_PRUNING_DISABLED) { in i40e_add_vsi()
13925 ctxt.seid = pf->main_vsi_seid; in i40e_add_vsi()
13926 ctxt.pf_num = pf->hw.pf_id; in i40e_add_vsi()
13934 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13936 i40e_stat_str(&pf->hw, ret), in i40e_add_vsi()
13937 i40e_aq_str(&pf->hw, in i40e_add_vsi()
13938 pf->hw.aq.asq_last_status)); in i40e_add_vsi()
13945 if ((pf->flags & I40E_FLAG_MFP_ENABLED) && in i40e_add_vsi()
13946 !(pf->hw.func_caps.iscsi)) { /* NIC type PF */ in i40e_add_vsi()
13948 ctxt.seid = pf->main_vsi_seid; in i40e_add_vsi()
13949 ctxt.pf_num = pf->hw.pf_id; in i40e_add_vsi()
13954 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13956 i40e_stat_str(&pf->hw, ret), in i40e_add_vsi()
13957 i40e_aq_str(&pf->hw, in i40e_add_vsi()
13958 pf->hw.aq.asq_last_status)); in i40e_add_vsi()
13969 * For MFP case the iSCSI PF would use this in i40e_add_vsi()
13977 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13980 i40e_stat_str(&pf->hw, ret), in i40e_add_vsi()
13981 i40e_aq_str(&pf->hw, in i40e_add_vsi()
13982 pf->hw.aq.asq_last_status)); in i40e_add_vsi()
13993 if ((pf->flags & I40E_FLAG_VEB_MODE_ENABLED) && in i40e_add_vsi()
14051 if (pf->vf[vsi->vf_id].spoofchk) { in i40e_add_vsi()
14075 i40e_stat_str(&pf->hw, ret), in i40e_add_vsi()
14076 i40e_aq_str(&pf->hw, in i40e_add_vsi()
14077 pf->hw.aq.asq_last_status)); in i40e_add_vsi()
14099 set_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state); in i40e_add_vsi()
14105 dev_info(&pf->pdev->dev, in i40e_add_vsi()
14107 i40e_stat_str(&pf->hw, ret), in i40e_add_vsi()
14108 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_add_vsi()
14128 struct i40e_pf *pf; in i40e_vsi_release() local
14132 pf = vsi->back; in i40e_vsi_release()
14136 dev_info(&pf->pdev->dev, "VSI %d has existing VEB %d\n", in i40e_vsi_release()
14140 if (vsi == pf->vsi[pf->lan_vsi] && in i40e_vsi_release()
14141 !test_bit(__I40E_DOWN, pf->state)) { in i40e_vsi_release()
14142 dev_info(&pf->pdev->dev, "Can't remove PF VSI\n"); in i40e_vsi_release()
14193 for (n = 0, i = 0; i < pf->num_alloc_vsi; i++) { in i40e_vsi_release()
14194 if (pf->vsi[i] && in i40e_vsi_release()
14195 pf->vsi[i]->uplink_seid == uplink_seid && in i40e_vsi_release()
14196 (pf->vsi[i]->flags & I40E_VSI_FLAG_VEB_OWNER) == 0) { in i40e_vsi_release()
14201 if (!pf->veb[i]) in i40e_vsi_release()
14203 if (pf->veb[i]->uplink_seid == uplink_seid) in i40e_vsi_release()
14205 if (pf->veb[i]->seid == uplink_seid) in i40e_vsi_release()
14206 veb = pf->veb[i]; in i40e_vsi_release()
14227 struct i40e_pf *pf = vsi->back; in i40e_vsi_setup_vectors() local
14230 dev_info(&pf->pdev->dev, "VSI %d has existing q_vectors\n", in i40e_vsi_setup_vectors()
14236 dev_info(&pf->pdev->dev, "VSI %d has non-zero base vector %d\n", in i40e_vsi_setup_vectors()
14243 dev_info(&pf->pdev->dev, in i40e_vsi_setup_vectors()
14253 if (!(pf->flags & I40E_FLAG_MSIX_ENABLED)) in i40e_vsi_setup_vectors()
14256 vsi->base_vector = i40e_get_lump(pf, pf->irq_pile, in i40e_vsi_setup_vectors()
14259 dev_info(&pf->pdev->dev, in i40e_vsi_setup_vectors()
14283 struct i40e_pf *pf; in i40e_vsi_reinit_setup() local
14290 pf = vsi->back; in i40e_vsi_reinit_setup()
14292 i40e_put_lump(pf->qp_pile, vsi->base_queue, vsi->idx); in i40e_vsi_reinit_setup()
14304 ret = i40e_get_lump(pf, pf->qp_pile, alloc_queue_pairs, vsi->idx); in i40e_vsi_reinit_setup()
14306 dev_info(&pf->pdev->dev, in i40e_vsi_reinit_setup()
14316 enabled_tc = pf->vsi[pf->lan_vsi]->tc_config.enabled_tc; in i40e_vsi_reinit_setup()
14317 pf->vsi[pf->lan_vsi]->tc_config.enabled_tc = 0; in i40e_vsi_reinit_setup()
14318 pf->vsi[pf->lan_vsi]->seid = pf->main_vsi_seid; in i40e_vsi_reinit_setup()
14319 i40e_vsi_config_tc(pf->vsi[pf->lan_vsi], enabled_tc); in i40e_vsi_reinit_setup()
14321 i40e_rm_default_mac_filter(vsi, pf->hw.mac.perm_addr); in i40e_vsi_reinit_setup()
14340 i40e_aq_delete_element(&pf->hw, vsi->seid, NULL); in i40e_vsi_reinit_setup()
14348 * @pf: board private structure
14359 struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type, in i40e_vsi_setup() argument
14369 * - the PF's port seid in i40e_vsi_setup()
14370 * no VEB is needed because this is the PF in i40e_vsi_setup()
14376 * - seid of the PF VSI, which is what creates the first VEB in i40e_vsi_setup()
14382 if (pf->veb[i] && pf->veb[i]->seid == uplink_seid) { in i40e_vsi_setup()
14383 veb = pf->veb[i]; in i40e_vsi_setup()
14388 if (!veb && uplink_seid != pf->mac_seid) { in i40e_vsi_setup()
14390 for (i = 0; i < pf->num_alloc_vsi; i++) { in i40e_vsi_setup()
14391 if (pf->vsi[i] && pf->vsi[i]->seid == uplink_seid) { in i40e_vsi_setup()
14392 vsi = pf->vsi[i]; in i40e_vsi_setup()
14397 dev_info(&pf->pdev->dev, "no such uplink_seid %d\n", in i40e_vsi_setup()
14402 if (vsi->uplink_seid == pf->mac_seid) in i40e_vsi_setup()
14403 veb = i40e_veb_setup(pf, 0, pf->mac_seid, vsi->seid, in i40e_vsi_setup()
14406 veb = i40e_veb_setup(pf, 0, vsi->uplink_seid, vsi->seid, in i40e_vsi_setup()
14409 if (vsi->seid != pf->vsi[pf->lan_vsi]->seid) { in i40e_vsi_setup()
14418 if (!(pf->flags & I40E_FLAG_VEB_MODE_ENABLED)) { in i40e_vsi_setup()
14420 pf->flags &= ~I40E_FLAG_VEB_MODE_ENABLED; in i40e_vsi_setup()
14425 if (pf->veb[i] && pf->veb[i]->seid == vsi->uplink_seid) in i40e_vsi_setup()
14426 veb = pf->veb[i]; in i40e_vsi_setup()
14429 dev_info(&pf->pdev->dev, "couldn't add VEB\n"); in i40e_vsi_setup()
14438 v_idx = i40e_vsi_mem_alloc(pf, type); in i40e_vsi_setup()
14441 vsi = pf->vsi[v_idx]; in i40e_vsi_setup()
14448 pf->lan_vsi = v_idx; in i40e_vsi_setup()
14455 ret = i40e_get_lump(pf, pf->qp_pile, alloc_queue_pairs, vsi->idx); in i40e_vsi_setup()
14457 dev_info(&pf->pdev->dev, in i40e_vsi_setup()
14510 if ((pf->hw_features & I40E_HW_RSS_AQ_CAPABLE) && in i40e_vsi_setup()
14526 i40e_aq_delete_element(&pf->hw, vsi->seid, NULL); in i40e_vsi_setup()
14543 struct i40e_pf *pf = veb->pf; in i40e_veb_get_bw_info() local
14544 struct i40e_hw *hw = &pf->hw; in i40e_veb_get_bw_info()
14552 dev_info(&pf->pdev->dev, in i40e_veb_get_bw_info()
14554 i40e_stat_str(&pf->hw, ret), in i40e_veb_get_bw_info()
14555 i40e_aq_str(&pf->hw, hw->aq.asq_last_status)); in i40e_veb_get_bw_info()
14562 dev_info(&pf->pdev->dev, in i40e_veb_get_bw_info()
14564 i40e_stat_str(&pf->hw, ret), in i40e_veb_get_bw_info()
14565 i40e_aq_str(&pf->hw, hw->aq.asq_last_status)); in i40e_veb_get_bw_info()
14587 * i40e_veb_mem_alloc - Allocates the next available struct veb in the PF
14588 * @pf: board private structure
14591 * On success: returns vsi index in PF (positive)
14593 static int i40e_veb_mem_alloc(struct i40e_pf *pf) in i40e_veb_mem_alloc() argument
14599 /* Need to protect the allocation of switch elements at the PF level */ in i40e_veb_mem_alloc()
14600 mutex_lock(&pf->switch_mutex); in i40e_veb_mem_alloc()
14609 while ((i < I40E_MAX_VEB) && (pf->veb[i] != NULL)) in i40e_veb_mem_alloc()
14621 veb->pf = pf; in i40e_veb_mem_alloc()
14625 pf->veb[i] = veb; in i40e_veb_mem_alloc()
14628 mutex_unlock(&pf->switch_mutex); in i40e_veb_mem_alloc()
14641 struct i40e_pf *pf = branch->pf; in i40e_switch_branch_release() local
14648 if (!pf->veb[i]) in i40e_switch_branch_release()
14650 if (pf->veb[i]->uplink_seid == branch->seid) in i40e_switch_branch_release()
14651 i40e_switch_branch_release(pf->veb[i]); in i40e_switch_branch_release()
14659 for (i = 0; i < pf->num_alloc_vsi; i++) { in i40e_switch_branch_release()
14660 if (!pf->vsi[i]) in i40e_switch_branch_release()
14662 if (pf->vsi[i]->uplink_seid == branch_seid && in i40e_switch_branch_release()
14663 (pf->vsi[i]->flags & I40E_VSI_FLAG_VEB_OWNER) == 0) { in i40e_switch_branch_release()
14664 i40e_vsi_release(pf->vsi[i]); in i40e_switch_branch_release()
14673 if (pf->veb[veb_idx]) in i40e_switch_branch_release()
14674 i40e_veb_release(pf->veb[veb_idx]); in i40e_switch_branch_release()
14686 if (veb->pf) { in i40e_veb_clear()
14687 struct i40e_pf *pf = veb->pf; in i40e_veb_clear() local
14689 mutex_lock(&pf->switch_mutex); in i40e_veb_clear()
14690 if (pf->veb[veb->idx] == veb) in i40e_veb_clear()
14691 pf->veb[veb->idx] = NULL; in i40e_veb_clear()
14692 mutex_unlock(&pf->switch_mutex); in i40e_veb_clear()
14705 struct i40e_pf *pf; in i40e_veb_release() local
14708 pf = veb->pf; in i40e_veb_release()
14711 for (i = 0; i < pf->num_alloc_vsi; i++) { in i40e_veb_release()
14712 if (pf->vsi[i] && pf->vsi[i]->uplink_seid == veb->seid) { in i40e_veb_release()
14714 vsi = pf->vsi[i]; in i40e_veb_release()
14718 dev_info(&pf->pdev->dev, in i40e_veb_release()
14728 if (veb->uplink_seid == pf->mac_seid) in i40e_veb_release()
14734 vsi->uplink_seid = pf->vsi[pf->lan_vsi]->uplink_seid; in i40e_veb_release()
14735 vsi->veb_idx = pf->vsi[pf->lan_vsi]->veb_idx; in i40e_veb_release()
14738 i40e_aq_delete_element(&pf->hw, veb->seid, NULL); in i40e_veb_release()
14749 struct i40e_pf *pf = veb->pf; in i40e_add_veb() local
14750 bool enable_stats = !!(pf->flags & I40E_FLAG_VEB_STATS_ENABLED); in i40e_add_veb()
14753 ret = i40e_aq_add_veb(&pf->hw, veb->uplink_seid, vsi->seid, in i40e_add_veb()
14759 dev_info(&pf->pdev->dev, in i40e_add_veb()
14761 i40e_stat_str(&pf->hw, ret), in i40e_add_veb()
14762 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_add_veb()
14767 ret = i40e_aq_get_veb_parameters(&pf->hw, veb->seid, NULL, NULL, in i40e_add_veb()
14770 dev_info(&pf->pdev->dev, in i40e_add_veb()
14772 i40e_stat_str(&pf->hw, ret), in i40e_add_veb()
14773 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_add_veb()
14778 dev_info(&pf->pdev->dev, in i40e_add_veb()
14780 i40e_stat_str(&pf->hw, ret), in i40e_add_veb()
14781 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_add_veb()
14782 i40e_aq_delete_element(&pf->hw, veb->seid, NULL); in i40e_add_veb()
14795 * @pf: board private structure
14809 struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags, in i40e_veb_setup() argument
14820 dev_info(&pf->pdev->dev, in i40e_veb_setup()
14827 for (vsi_idx = 0; vsi_idx < pf->num_alloc_vsi; vsi_idx++) in i40e_veb_setup()
14828 if (pf->vsi[vsi_idx] && pf->vsi[vsi_idx]->seid == vsi_seid) in i40e_veb_setup()
14830 if (vsi_idx == pf->num_alloc_vsi && vsi_seid != 0) { in i40e_veb_setup()
14831 dev_info(&pf->pdev->dev, "vsi seid %d not found\n", in i40e_veb_setup()
14836 if (uplink_seid && uplink_seid != pf->mac_seid) { in i40e_veb_setup()
14838 if (pf->veb[veb_idx] && in i40e_veb_setup()
14839 pf->veb[veb_idx]->seid == uplink_seid) { in i40e_veb_setup()
14840 uplink_veb = pf->veb[veb_idx]; in i40e_veb_setup()
14845 dev_info(&pf->pdev->dev, in i40e_veb_setup()
14852 veb_idx = i40e_veb_mem_alloc(pf); in i40e_veb_setup()
14855 veb = pf->veb[veb_idx]; in i40e_veb_setup()
14862 ret = i40e_add_veb(veb, pf->vsi[vsi_idx]); in i40e_veb_setup()
14865 if (vsi_idx == pf->lan_vsi) in i40e_veb_setup()
14866 pf->lan_veb = veb->idx; in i40e_veb_setup()
14877 * i40e_setup_pf_switch_element - set PF vars based on switch type
14878 * @pf: board private structure
14885 static void i40e_setup_pf_switch_element(struct i40e_pf *pf, in i40e_setup_pf_switch_element() argument
14895 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch_element()
14901 pf->mac_seid = seid; in i40e_setup_pf_switch_element()
14905 if (uplink_seid != pf->mac_seid) in i40e_setup_pf_switch_element()
14907 if (pf->lan_veb >= I40E_MAX_VEB) { in i40e_setup_pf_switch_element()
14912 if (pf->veb[v] && (pf->veb[v]->seid == seid)) { in i40e_setup_pf_switch_element()
14913 pf->lan_veb = v; in i40e_setup_pf_switch_element()
14917 if (pf->lan_veb >= I40E_MAX_VEB) { in i40e_setup_pf_switch_element()
14918 v = i40e_veb_mem_alloc(pf); in i40e_setup_pf_switch_element()
14921 pf->lan_veb = v; in i40e_setup_pf_switch_element()
14924 if (pf->lan_veb >= I40E_MAX_VEB) in i40e_setup_pf_switch_element()
14927 pf->veb[pf->lan_veb]->seid = seid; in i40e_setup_pf_switch_element()
14928 pf->veb[pf->lan_veb]->uplink_seid = pf->mac_seid; in i40e_setup_pf_switch_element()
14929 pf->veb[pf->lan_veb]->pf = pf; in i40e_setup_pf_switch_element()
14930 pf->veb[pf->lan_veb]->veb_idx = I40E_NO_VEB; in i40e_setup_pf_switch_element()
14936 * the PF's VSI in i40e_setup_pf_switch_element()
14938 pf->mac_seid = uplink_seid; in i40e_setup_pf_switch_element()
14939 pf->pf_seid = downlink_seid; in i40e_setup_pf_switch_element()
14940 pf->main_vsi_seid = seid; in i40e_setup_pf_switch_element()
14942 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch_element()
14944 pf->pf_seid, pf->main_vsi_seid); in i40e_setup_pf_switch_element()
14955 dev_info(&pf->pdev->dev, "unknown element type=%d seid=%d\n", in i40e_setup_pf_switch_element()
14963 * @pf: board private structure
14969 int i40e_fetch_switch_configuration(struct i40e_pf *pf, bool printconfig) in i40e_fetch_switch_configuration() argument
14985 ret = i40e_aq_get_switch_config(&pf->hw, sw_config, in i40e_fetch_switch_configuration()
14989 dev_info(&pf->pdev->dev, in i40e_fetch_switch_configuration()
14991 i40e_stat_str(&pf->hw, ret), in i40e_fetch_switch_configuration()
14992 i40e_aq_str(&pf->hw, in i40e_fetch_switch_configuration()
14993 pf->hw.aq.asq_last_status)); in i40e_fetch_switch_configuration()
15002 dev_info(&pf->pdev->dev, in i40e_fetch_switch_configuration()
15010 i40e_setup_pf_switch_element(pf, ele, num_reported, in i40e_fetch_switch_configuration()
15021 * @pf: board private structure
15027 static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired) in i40e_setup_pf_switch() argument
15033 ret = i40e_fetch_switch_configuration(pf, false); in i40e_setup_pf_switch()
15035 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch()
15037 i40e_stat_str(&pf->hw, ret), in i40e_setup_pf_switch()
15038 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_setup_pf_switch()
15041 i40e_pf_reset_stats(pf); in i40e_setup_pf_switch()
15049 if ((pf->hw.pf_id == 0) && in i40e_setup_pf_switch()
15050 !(pf->flags & I40E_FLAG_TRUE_PROMISC_SUPPORT)) { in i40e_setup_pf_switch()
15052 pf->last_sw_conf_flags = flags; in i40e_setup_pf_switch()
15055 if (pf->hw.pf_id == 0) { in i40e_setup_pf_switch()
15059 ret = i40e_aq_set_switch_config(&pf->hw, flags, valid_flags, 0, in i40e_setup_pf_switch()
15061 if (ret && pf->hw.aq.asq_last_status != I40E_AQ_RC_ESRCH) { in i40e_setup_pf_switch()
15062 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch()
15064 i40e_stat_str(&pf->hw, ret), in i40e_setup_pf_switch()
15065 i40e_aq_str(&pf->hw, in i40e_setup_pf_switch()
15066 pf->hw.aq.asq_last_status)); in i40e_setup_pf_switch()
15069 pf->last_sw_conf_valid_flags = valid_flags; in i40e_setup_pf_switch()
15073 if (pf->lan_vsi == I40E_NO_VSI || reinit) { in i40e_setup_pf_switch()
15077 /* Set up the PF VSI associated with the PF's main VSI in i40e_setup_pf_switch()
15080 if (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb]) in i40e_setup_pf_switch()
15081 uplink_seid = pf->veb[pf->lan_veb]->seid; in i40e_setup_pf_switch()
15083 uplink_seid = pf->mac_seid; in i40e_setup_pf_switch()
15084 if (pf->lan_vsi == I40E_NO_VSI) in i40e_setup_pf_switch()
15085 vsi = i40e_vsi_setup(pf, I40E_VSI_MAIN, uplink_seid, 0); in i40e_setup_pf_switch()
15087 vsi = i40e_vsi_reinit_setup(pf->vsi[pf->lan_vsi]); in i40e_setup_pf_switch()
15089 dev_info(&pf->pdev->dev, "setup of MAIN VSI failed\n"); in i40e_setup_pf_switch()
15090 i40e_cloud_filter_exit(pf); in i40e_setup_pf_switch()
15091 i40e_fdir_teardown(pf); in i40e_setup_pf_switch()
15096 u8 enabled_tc = pf->vsi[pf->lan_vsi]->tc_config.enabled_tc; in i40e_setup_pf_switch()
15098 pf->vsi[pf->lan_vsi]->tc_config.enabled_tc = 0; in i40e_setup_pf_switch()
15099 pf->vsi[pf->lan_vsi]->seid = pf->main_vsi_seid; in i40e_setup_pf_switch()
15100 i40e_vsi_config_tc(pf->vsi[pf->lan_vsi], enabled_tc); in i40e_setup_pf_switch()
15102 i40e_vlan_stripping_disable(pf->vsi[pf->lan_vsi]); in i40e_setup_pf_switch()
15104 i40e_fdir_sb_setup(pf); in i40e_setup_pf_switch()
15106 /* Setup static PF queue filter control settings */ in i40e_setup_pf_switch()
15107 ret = i40e_setup_pf_filter_control(pf); in i40e_setup_pf_switch()
15109 dev_info(&pf->pdev->dev, "setup_pf_filter_control failed: %d\n", in i40e_setup_pf_switch()
15117 if ((pf->flags & I40E_FLAG_RSS_ENABLED)) in i40e_setup_pf_switch()
15118 i40e_pf_config_rss(pf); in i40e_setup_pf_switch()
15121 i40e_link_event(pf); in i40e_setup_pf_switch()
15124 pf->fc_autoneg_status = ((pf->hw.phy.link_info.an_info & in i40e_setup_pf_switch()
15127 i40e_ptp_init(pf); in i40e_setup_pf_switch()
15133 udp_tunnel_nic_reset_ntf(pf->vsi[pf->lan_vsi]->netdev); in i40e_setup_pf_switch()
15143 * @pf: board private structure
15145 static void i40e_determine_queue_usage(struct i40e_pf *pf) in i40e_determine_queue_usage() argument
15150 pf->num_lan_qps = 0; in i40e_determine_queue_usage()
15156 queues_left = pf->hw.func_caps.num_tx_qp; in i40e_determine_queue_usage()
15159 !(pf->flags & I40E_FLAG_MSIX_ENABLED)) { in i40e_determine_queue_usage()
15160 /* one qp for PF, no queues for anything else */ in i40e_determine_queue_usage()
15162 pf->alloc_rss_size = pf->num_lan_qps = 1; in i40e_determine_queue_usage()
15165 pf->flags &= ~(I40E_FLAG_RSS_ENABLED | in i40e_determine_queue_usage()
15173 pf->flags |= I40E_FLAG_FD_SB_INACTIVE; in i40e_determine_queue_usage()
15174 } else if (!(pf->flags & (I40E_FLAG_RSS_ENABLED | in i40e_determine_queue_usage()
15178 /* one qp for PF */ in i40e_determine_queue_usage()
15179 pf->alloc_rss_size = pf->num_lan_qps = 1; in i40e_determine_queue_usage()
15180 queues_left -= pf->num_lan_qps; in i40e_determine_queue_usage()
15182 pf->flags &= ~(I40E_FLAG_RSS_ENABLED | in i40e_determine_queue_usage()
15188 pf->flags |= I40E_FLAG_FD_SB_INACTIVE; in i40e_determine_queue_usage()
15191 if ((pf->flags & I40E_FLAG_DCB_CAPABLE) && in i40e_determine_queue_usage()
15193 pf->flags &= ~(I40E_FLAG_DCB_CAPABLE | in i40e_determine_queue_usage()
15195 dev_info(&pf->pdev->dev, "not enough queues for DCB. DCB is disabled.\n"); in i40e_determine_queue_usage()
15199 q_max = max_t(int, pf->rss_size_max, num_online_cpus()); in i40e_determine_queue_usage()
15200 q_max = min_t(int, q_max, pf->hw.func_caps.num_tx_qp); in i40e_determine_queue_usage()
15201 q_max = min_t(int, q_max, pf->hw.func_caps.num_msix_vectors); in i40e_determine_queue_usage()
15202 pf->num_lan_qps = q_max; in i40e_determine_queue_usage()
15204 queues_left -= pf->num_lan_qps; in i40e_determine_queue_usage()
15207 if (pf->flags & I40E_FLAG_FD_SB_ENABLED) { in i40e_determine_queue_usage()
15211 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED; in i40e_determine_queue_usage()
15212 pf->flags |= I40E_FLAG_FD_SB_INACTIVE; in i40e_determine_queue_usage()
15213 …dev_info(&pf->pdev->dev, "not enough queues for Flow Director. Flow Director feature is disabled\n… in i40e_determine_queue_usage()
15217 if ((pf->flags & I40E_FLAG_SRIOV_ENABLED) && in i40e_determine_queue_usage()
15218 pf->num_vf_qps && pf->num_req_vfs && queues_left) { in i40e_determine_queue_usage()
15219 pf->num_req_vfs = min_t(int, pf->num_req_vfs, in i40e_determine_queue_usage()
15220 (queues_left / pf->num_vf_qps)); in i40e_determine_queue_usage()
15221 queues_left -= (pf->num_req_vfs * pf->num_vf_qps); in i40e_determine_queue_usage()
15224 if ((pf->flags & I40E_FLAG_VMDQ_ENABLED) && in i40e_determine_queue_usage()
15225 pf->num_vmdq_vsis && pf->num_vmdq_qps && queues_left) { in i40e_determine_queue_usage()
15226 pf->num_vmdq_vsis = min_t(int, pf->num_vmdq_vsis, in i40e_determine_queue_usage()
15227 (queues_left / pf->num_vmdq_qps)); in i40e_determine_queue_usage()
15228 queues_left -= (pf->num_vmdq_vsis * pf->num_vmdq_qps); in i40e_determine_queue_usage()
15231 pf->queues_left = queues_left; in i40e_determine_queue_usage()
15232 dev_dbg(&pf->pdev->dev, in i40e_determine_queue_usage()
15234 pf->hw.func_caps.num_tx_qp, in i40e_determine_queue_usage()
15235 !!(pf->flags & I40E_FLAG_FD_SB_ENABLED), in i40e_determine_queue_usage()
15236 pf->num_lan_qps, pf->alloc_rss_size, pf->num_req_vfs, in i40e_determine_queue_usage()
15237 pf->num_vf_qps, pf->num_vmdq_vsis, pf->num_vmdq_qps, in i40e_determine_queue_usage()
15242 * i40e_setup_pf_filter_control - Setup PF static filter control
15243 * @pf: PF to be setup
15245 * i40e_setup_pf_filter_control sets up a PF's initial filter control
15246 * settings. If PE/FCoE are enabled then it will also set the per PF
15248 * ethertype and macvlan type filter settings for the pf.
15252 static int i40e_setup_pf_filter_control(struct i40e_pf *pf) in i40e_setup_pf_filter_control() argument
15254 struct i40e_filter_control_settings *settings = &pf->filter_settings; in i40e_setup_pf_filter_control()
15259 if (pf->flags & (I40E_FLAG_FD_SB_ENABLED | I40E_FLAG_FD_ATR_ENABLED)) in i40e_setup_pf_filter_control()
15262 /* Ethtype and MACVLAN filters enabled for PF */ in i40e_setup_pf_filter_control()
15266 if (i40e_set_filter_control(&pf->hw, settings)) in i40e_setup_pf_filter_control()
15274 static void i40e_print_features(struct i40e_pf *pf) in i40e_print_features() argument
15276 struct i40e_hw *hw = &pf->hw; in i40e_print_features()
15284 i = snprintf(buf, INFO_STRING_LEN, "Features: PF-id[%d]", hw->pf_id); in i40e_print_features()
15286 i += scnprintf(&buf[i], REMAIN(i), " VFs: %d", pf->num_req_vfs); in i40e_print_features()
15289 pf->hw.func_caps.num_vsis, in i40e_print_features()
15290 pf->vsi[pf->lan_vsi]->num_queue_pairs); in i40e_print_features()
15291 if (pf->flags & I40E_FLAG_RSS_ENABLED) in i40e_print_features()
15293 if (pf->flags & I40E_FLAG_FD_ATR_ENABLED) in i40e_print_features()
15295 if (pf->flags & I40E_FLAG_FD_SB_ENABLED) { in i40e_print_features()
15299 if (pf->flags & I40E_FLAG_DCB_CAPABLE) in i40e_print_features()
15303 if (pf->flags & I40E_FLAG_PTP) in i40e_print_features()
15305 if (pf->flags & I40E_FLAG_VEB_MODE_ENABLED) in i40e_print_features()
15310 dev_info(&pf->pdev->dev, "%s\n", buf); in i40e_print_features()
15318 * @pf: board private structure
15325 static void i40e_get_platform_mac_addr(struct pci_dev *pdev, struct i40e_pf *pf) in i40e_get_platform_mac_addr() argument
15327 if (eth_platform_get_mac_address(&pdev->dev, pf->hw.mac.addr)) in i40e_get_platform_mac_addr()
15328 i40e_get_mac_addr(&pf->hw, pf->hw.mac.addr); in i40e_get_platform_mac_addr()
15356 * @pf: board private structure
15363 static bool i40e_check_recovery_mode(struct i40e_pf *pf) in i40e_check_recovery_mode() argument
15365 u32 val = rd32(&pf->hw, I40E_GL_FWSTS); in i40e_check_recovery_mode()
15368 dev_crit(&pf->pdev->dev, "Firmware recovery mode detected. Limiting functionality.\n"); in i40e_check_recovery_mode()
15369 …dev_crit(&pf->pdev->dev, "Refer to the Intel(R) Ethernet Adapters and Devices User Guide for detai… in i40e_check_recovery_mode()
15370 set_bit(__I40E_RECOVERY_MODE, pf->state); in i40e_check_recovery_mode()
15374 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_check_recovery_mode()
15375 …dev_info(&pf->pdev->dev, "Please do Power-On Reset to initialize adapter in normal mode with full … in i40e_check_recovery_mode()
15382 * @pf: board private structure
15391 * state is to issue a series of pf-resets and check a return value.
15392 * If a PF reset returns success then the firmware could be in recovery
15401 static i40e_status i40e_pf_loop_reset(struct i40e_pf *pf) in i40e_pf_loop_reset() argument
15403 /* wait max 10 seconds for PF reset to succeed */ in i40e_pf_loop_reset()
15406 struct i40e_hw *hw = &pf->hw; in i40e_pf_loop_reset()
15416 pf->pfr_count++; in i40e_pf_loop_reset()
15418 dev_info(&pf->pdev->dev, "PF reset failed: %d\n", ret); in i40e_pf_loop_reset()
15425 * @pf: board private structure
15434 static bool i40e_check_fw_empr(struct i40e_pf *pf) in i40e_check_fw_empr() argument
15436 const u32 fw_sts = rd32(&pf->hw, I40E_GL_FWSTS) & in i40e_check_fw_empr()
15443 * i40e_handle_resets - handle EMP resets and PF resets
15444 * @pf: board private structure
15446 * Handle both EMP resets and PF resets and conclude whether there are
15453 static i40e_status i40e_handle_resets(struct i40e_pf *pf) in i40e_handle_resets() argument
15455 const i40e_status pfr = i40e_pf_loop_reset(pf); in i40e_handle_resets()
15456 const bool is_empr = i40e_check_fw_empr(pf); in i40e_handle_resets()
15459 …dev_crit(&pf->pdev->dev, "Entering recovery mode due to repeated FW resets. This may take several … in i40e_handle_resets()
15466 * @pf: board private structure
15474 static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw) in i40e_init_recovery_mode() argument
15480 pci_save_state(pf->pdev); in i40e_init_recovery_mode()
15483 timer_setup(&pf->service_timer, i40e_service_timer, 0); in i40e_init_recovery_mode()
15484 pf->service_timer_period = HZ; in i40e_init_recovery_mode()
15486 INIT_WORK(&pf->service_task, i40e_service_task); in i40e_init_recovery_mode()
15487 clear_bit(__I40E_SERVICE_SCHED, pf->state); in i40e_init_recovery_mode()
15489 err = i40e_init_interrupt_scheme(pf); in i40e_init_recovery_mode()
15498 if (pf->hw.func_caps.num_vsis < I40E_MIN_VSI_ALLOC) in i40e_init_recovery_mode()
15499 pf->num_alloc_vsi = I40E_MIN_VSI_ALLOC; in i40e_init_recovery_mode()
15501 pf->num_alloc_vsi = pf->hw.func_caps.num_vsis; in i40e_init_recovery_mode()
15503 /* Set up the vsi struct and our local tracking of the MAIN PF vsi. */ in i40e_init_recovery_mode()
15504 pf->vsi = kcalloc(pf->num_alloc_vsi, sizeof(struct i40e_vsi *), in i40e_init_recovery_mode()
15506 if (!pf->vsi) { in i40e_init_recovery_mode()
15514 v_idx = i40e_vsi_mem_alloc(pf, I40E_VSI_MAIN); in i40e_init_recovery_mode()
15519 pf->lan_vsi = v_idx; in i40e_init_recovery_mode()
15520 vsi = pf->vsi[v_idx]; in i40e_init_recovery_mode()
15533 i40e_dbg_pf_init(pf); in i40e_init_recovery_mode()
15535 err = i40e_setup_misc_vector_for_recovery_mode(pf); in i40e_init_recovery_mode()
15540 i40e_send_version(pf); in i40e_init_recovery_mode()
15543 mod_timer(&pf->service_timer, in i40e_init_recovery_mode()
15544 round_jiffies(jiffies + pf->service_timer_period)); in i40e_init_recovery_mode()
15549 i40e_reset_interrupt_capability(pf); in i40e_init_recovery_mode()
15550 del_timer_sync(&pf->service_timer); in i40e_init_recovery_mode()
15553 pci_disable_pcie_error_reporting(pf->pdev); in i40e_init_recovery_mode()
15554 pci_release_mem_regions(pf->pdev); in i40e_init_recovery_mode()
15555 pci_disable_device(pf->pdev); in i40e_init_recovery_mode()
15556 kfree(pf); in i40e_init_recovery_mode()
15582 * i40e_probe initializes a PF identified by a pci_dev structure.
15583 * The OS initialization, configuring of the PF private structure,
15595 struct i40e_pf *pf; in i40e_probe() local
15632 pf = kzalloc(sizeof(*pf), GFP_KERNEL); in i40e_probe()
15633 if (!pf) { in i40e_probe()
15637 pf->next_vsi = 0; in i40e_probe()
15638 pf->pdev = pdev; in i40e_probe()
15639 set_bit(__I40E_DOWN, pf->state); in i40e_probe()
15641 hw = &pf->hw; in i40e_probe()
15642 hw->back = pf; in i40e_probe()
15644 pf->ioremap_len = min_t(int, pci_resource_len(pdev, 0), in i40e_probe()
15651 if (pf->ioremap_len < I40E_GLGEN_STAT_CLEAR) { in i40e_probe()
15653 pf->ioremap_len); in i40e_probe()
15657 hw->hw_addr = ioremap(pci_resource_start(pdev, 0), pf->ioremap_len); in i40e_probe()
15662 pf->ioremap_len, err); in i40e_probe()
15673 pf->instance = pfs_found; in i40e_probe()
15682 INIT_LIST_HEAD(&pf->l3_flex_pit_list); in i40e_probe()
15683 INIT_LIST_HEAD(&pf->l4_flex_pit_list); in i40e_probe()
15684 INIT_LIST_HEAD(&pf->ddp_old_prof); in i40e_probe()
15692 pf->msg_enable = netif_msg_init(debug, in i40e_probe()
15697 pf->hw.debug_mask = debug; in i40e_probe()
15705 pf->corer_count++; in i40e_probe()
15710 /* Reset here to make sure all is clean and to define PF 'n' */ in i40e_probe()
15720 err = i40e_handle_resets(pf); in i40e_probe()
15724 i40e_check_recovery_mode(pf); in i40e_probe()
15735 pf->adminq_work_limit = I40E_AQ_WORK_LIMIT; in i40e_probe()
15737 snprintf(pf->int_name, sizeof(pf->int_name) - 1, in i40e_probe()
15739 dev_driver_string(&pf->pdev->dev), dev_name(&pdev->dev)); in i40e_probe()
15749 pf->hw.fc.requested_mode = I40E_FC_NONE; in i40e_probe()
15791 i40e_verify_eeprom(pf); in i40e_probe()
15799 err = i40e_get_capabilities(pf, i40e_aqc_opc_list_func_capabilities); in i40e_probe()
15803 err = i40e_sw_init(pf); in i40e_probe()
15809 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_probe()
15810 return i40e_init_recovery_mode(pf, hw); in i40e_probe()
15830 if (pf->hw_features & I40E_HW_STOP_FW_LLDP) { in i40e_probe()
15836 i40e_get_platform_mac_addr(pdev, pf); in i40e_probe()
15847 pf->hw_features |= I40E_HW_PORT_ID_VALID; in i40e_probe()
15849 i40e_ptp_alloc_pins(pf); in i40e_probe()
15850 pci_set_drvdata(pdev, pf); in i40e_probe()
15854 status = i40e_get_fw_lldp_status(&pf->hw, &lldp_status); in i40e_probe()
15857 (pf->flags &= ~I40E_FLAG_DISABLE_FW_LLDP) : in i40e_probe()
15858 (pf->flags |= I40E_FLAG_DISABLE_FW_LLDP); in i40e_probe()
15860 (pf->flags & I40E_FLAG_DISABLE_FW_LLDP) ? in i40e_probe()
15867 err = i40e_init_pf_dcb(pf); in i40e_probe()
15870 pf->flags &= ~(I40E_FLAG_DCB_CAPABLE | I40E_FLAG_DCB_ENABLED); in i40e_probe()
15876 timer_setup(&pf->service_timer, i40e_service_timer, 0); in i40e_probe()
15877 pf->service_timer_period = HZ; in i40e_probe()
15879 INIT_WORK(&pf->service_task, i40e_service_task); in i40e_probe()
15880 clear_bit(__I40E_SERVICE_SCHED, pf->state); in i40e_probe()
15885 pf->wol_en = false; in i40e_probe()
15887 pf->wol_en = true; in i40e_probe()
15888 device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en); in i40e_probe()
15891 i40e_determine_queue_usage(pf); in i40e_probe()
15892 err = i40e_init_interrupt_scheme(pf); in i40e_probe()
15898 * pairs than MSI-X vectors (pf->num_lan_msix) exist. Thus in i40e_probe()
15899 * vsi->num_queue_pairs will be equal to pf->num_lan_msix, i.e., 1. in i40e_probe()
15902 pf->num_lan_msix = 1; in i40e_probe()
15904 pf->udp_tunnel_nic.set_port = i40e_udp_tunnel_set_port; in i40e_probe()
15905 pf->udp_tunnel_nic.unset_port = i40e_udp_tunnel_unset_port; in i40e_probe()
15906 pf->udp_tunnel_nic.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP; in i40e_probe()
15907 pf->udp_tunnel_nic.shared = &pf->udp_tunnel_shared; in i40e_probe()
15908 pf->udp_tunnel_nic.tables[0].n_entries = I40E_MAX_PF_UDP_OFFLOAD_PORTS; in i40e_probe()
15909 pf->udp_tunnel_nic.tables[0].tunnel_types = UDP_TUNNEL_TYPE_VXLAN | in i40e_probe()
15917 if (pf->hw.func_caps.num_vsis < I40E_MIN_VSI_ALLOC) in i40e_probe()
15918 pf->num_alloc_vsi = I40E_MIN_VSI_ALLOC; in i40e_probe()
15920 pf->num_alloc_vsi = pf->hw.func_caps.num_vsis; in i40e_probe()
15921 if (pf->num_alloc_vsi > UDP_TUNNEL_NIC_MAX_SHARING_DEVICES) { in i40e_probe()
15922 dev_warn(&pf->pdev->dev, in i40e_probe()
15924 pf->num_alloc_vsi, UDP_TUNNEL_NIC_MAX_SHARING_DEVICES); in i40e_probe()
15925 pf->num_alloc_vsi = UDP_TUNNEL_NIC_MAX_SHARING_DEVICES; in i40e_probe()
15928 /* Set up the *vsi struct and our local tracking of the MAIN PF vsi. */ in i40e_probe()
15929 pf->vsi = kcalloc(pf->num_alloc_vsi, sizeof(struct i40e_vsi *), in i40e_probe()
15931 if (!pf->vsi) { in i40e_probe()
15938 if ((pf->flags & I40E_FLAG_SRIOV_ENABLED) && in i40e_probe()
15939 (pf->flags & I40E_FLAG_MSIX_ENABLED) && in i40e_probe()
15940 !test_bit(__I40E_BAD_EEPROM, pf->state)) { in i40e_probe()
15942 pf->flags |= I40E_FLAG_VEB_MODE_ENABLED; in i40e_probe()
15945 err = i40e_setup_pf_switch(pf, false, false); in i40e_probe()
15950 INIT_LIST_HEAD(&pf->vsi[pf->lan_vsi]->ch_list); in i40e_probe()
15953 for (i = 0; i < pf->num_alloc_vsi; i++) { in i40e_probe()
15954 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) { in i40e_probe()
15955 i40e_vsi_open(pf->vsi[i]); in i40e_probe()
15963 err = i40e_aq_set_phy_int_mask(&pf->hw, in i40e_probe()
15968 dev_info(&pf->pdev->dev, "set phy mask fail, err %s aq_err %s\n", in i40e_probe()
15969 i40e_stat_str(&pf->hw, err), in i40e_probe()
15970 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_probe()
15983 if (pf->hw_features & I40E_HW_RESTART_AUTONEG) { in i40e_probe()
15985 err = i40e_aq_set_link_restart_an(&pf->hw, true, NULL); in i40e_probe()
15987 dev_info(&pf->pdev->dev, "link restart failed, err %s aq_err %s\n", in i40e_probe()
15988 i40e_stat_str(&pf->hw, err), in i40e_probe()
15989 i40e_aq_str(&pf->hw, in i40e_probe()
15990 pf->hw.aq.asq_last_status)); in i40e_probe()
15996 clear_bit(__I40E_DOWN, pf->state); in i40e_probe()
16003 if (pf->flags & I40E_FLAG_MSIX_ENABLED) { in i40e_probe()
16004 err = i40e_setup_misc_vector(pf); in i40e_probe()
16008 i40e_cloud_filter_exit(pf); in i40e_probe()
16009 i40e_fdir_teardown(pf); in i40e_probe()
16016 if ((pf->flags & I40E_FLAG_SRIOV_ENABLED) && in i40e_probe()
16017 (pf->flags & I40E_FLAG_MSIX_ENABLED) && in i40e_probe()
16018 !test_bit(__I40E_BAD_EEPROM, pf->state)) { in i40e_probe()
16028 err = i40e_alloc_vfs(pf, pci_num_vf(pdev)); in i40e_probe()
16037 if (pf->flags & I40E_FLAG_IWARP_ENABLED) { in i40e_probe()
16038 pf->iwarp_base_vector = i40e_get_lump(pf, pf->irq_pile, in i40e_probe()
16039 pf->num_iwarp_msix, in i40e_probe()
16041 if (pf->iwarp_base_vector < 0) { in i40e_probe()
16044 pf->num_iwarp_msix, pf->iwarp_base_vector); in i40e_probe()
16045 pf->flags &= ~I40E_FLAG_IWARP_ENABLED; in i40e_probe()
16049 i40e_dbg_pf_init(pf); in i40e_probe()
16052 i40e_send_version(pf); in i40e_probe()
16055 mod_timer(&pf->service_timer, in i40e_probe()
16056 round_jiffies(jiffies + pf->service_timer_period)); in i40e_probe()
16058 /* add this PF to client device list and launch a client service task */ in i40e_probe()
16059 if (pf->flags & I40E_FLAG_IWARP_ENABLED) { in i40e_probe()
16060 err = i40e_lan_add_device(pf); in i40e_probe()
16062 dev_info(&pdev->dev, "Failed to add PF to client API service list: %d\n", in i40e_probe()
16072 if (!(pf->hw_features & I40E_HW_NO_PCI_LINK_CHECK)) { in i40e_probe()
16079 pcie_capability_read_word(pf->pdev, PCI_EXP_LNKSTA, in i40e_probe()
16120 dev_dbg(&pf->pdev->dev, "get requested speeds ret = %s last_status = %s\n", in i40e_probe()
16121 i40e_stat_str(&pf->hw, err), in i40e_probe()
16122 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_probe()
16123 pf->hw.phy.link_info.requested_speeds = abilities.link_speed; in i40e_probe()
16126 i40e_set_fec_in_flags(abilities.fec_cfg_curr_mod_ext_info, &pf->flags); in i40e_probe()
16131 dev_dbg(&pf->pdev->dev, "get supported phy types ret = %s last_status = %s\n", in i40e_probe()
16132 i40e_stat_str(&pf->hw, err), in i40e_probe()
16133 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_probe()
16137 val = (rd32(&pf->hw, I40E_PRTGL_SAH) & in i40e_probe()
16146 * PF/VF VSIs. in i40e_probe()
16149 i40e_add_filter_to_drop_tx_flow_control_frames(&pf->hw, in i40e_probe()
16150 pf->main_vsi_seid); in i40e_probe()
16152 if ((pf->hw.device_id == I40E_DEV_ID_10G_BASE_T) || in i40e_probe()
16153 (pf->hw.device_id == I40E_DEV_ID_10G_BASE_T4)) in i40e_probe()
16154 pf->hw_features |= I40E_HW_PHY_CONTROLS_LEDS; in i40e_probe()
16155 if (pf->hw.device_id == I40E_DEV_ID_SFP_I_X722) in i40e_probe()
16156 pf->hw_features |= I40E_HW_HAVE_CRT_RETIMER; in i40e_probe()
16158 i40e_print_features(pf); in i40e_probe()
16164 set_bit(__I40E_DOWN, pf->state); in i40e_probe()
16165 i40e_clear_interrupt_scheme(pf); in i40e_probe()
16166 kfree(pf->vsi); in i40e_probe()
16168 i40e_reset_interrupt_capability(pf); in i40e_probe()
16169 del_timer_sync(&pf->service_timer); in i40e_probe()
16174 kfree(pf->qp_pile); in i40e_probe()
16180 kfree(pf); in i40e_probe()
16201 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_remove() local
16202 struct i40e_hw *hw = &pf->hw; in i40e_remove()
16206 i40e_dbg_pf_exit(pf); in i40e_remove()
16208 i40e_ptp_stop(pf); in i40e_remove()
16218 while (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_remove()
16220 set_bit(__I40E_IN_REMOVE, pf->state); in i40e_remove()
16222 if (pf->flags & I40E_FLAG_SRIOV_ENABLED) { in i40e_remove()
16223 set_bit(__I40E_VF_RESETS_DISABLED, pf->state); in i40e_remove()
16224 i40e_free_vfs(pf); in i40e_remove()
16225 pf->flags &= ~I40E_FLAG_SRIOV_ENABLED; in i40e_remove()
16228 set_bit(__I40E_SUSPENDED, pf->state); in i40e_remove()
16229 set_bit(__I40E_DOWN, pf->state); in i40e_remove()
16230 if (pf->service_timer.function) in i40e_remove()
16231 del_timer_sync(&pf->service_timer); in i40e_remove()
16232 if (pf->service_task.func) in i40e_remove()
16233 cancel_work_sync(&pf->service_task); in i40e_remove()
16235 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_remove()
16236 struct i40e_vsi *vsi = pf->vsi[0]; in i40e_remove()
16238 /* We know that we have allocated only one vsi for this PF, in i40e_remove()
16251 i40e_notify_client_of_netdev_close(pf->vsi[pf->lan_vsi], false); in i40e_remove()
16253 i40e_fdir_teardown(pf); in i40e_remove()
16256 * This will leave only the PF's VSI remaining. in i40e_remove()
16259 if (!pf->veb[i]) in i40e_remove()
16262 if (pf->veb[i]->uplink_seid == pf->mac_seid || in i40e_remove()
16263 pf->veb[i]->uplink_seid == 0) in i40e_remove()
16264 i40e_switch_branch_release(pf->veb[i]); in i40e_remove()
16267 /* Now we can shutdown the PF's VSI, just before we kill in i40e_remove()
16270 if (pf->vsi[pf->lan_vsi]) in i40e_remove()
16271 i40e_vsi_release(pf->vsi[pf->lan_vsi]); in i40e_remove()
16273 i40e_cloud_filter_exit(pf); in i40e_remove()
16276 if (pf->flags & I40E_FLAG_IWARP_ENABLED) { in i40e_remove()
16277 ret_code = i40e_lan_del_device(pf); in i40e_remove()
16294 if (test_bit(__I40E_RECOVERY_MODE, pf->state) && in i40e_remove()
16295 !(pf->flags & I40E_FLAG_MSIX_ENABLED)) in i40e_remove()
16296 free_irq(pf->pdev->irq, pf); in i40e_remove()
16307 i40e_clear_interrupt_scheme(pf); in i40e_remove()
16308 for (i = 0; i < pf->num_alloc_vsi; i++) { in i40e_remove()
16309 if (pf->vsi[i]) { in i40e_remove()
16310 if (!test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_remove()
16311 i40e_vsi_clear_rings(pf->vsi[i]); in i40e_remove()
16312 i40e_vsi_clear(pf->vsi[i]); in i40e_remove()
16313 pf->vsi[i] = NULL; in i40e_remove()
16319 kfree(pf->veb[i]); in i40e_remove()
16320 pf->veb[i] = NULL; in i40e_remove()
16323 kfree(pf->qp_pile); in i40e_remove()
16324 kfree(pf->vsi); in i40e_remove()
16327 kfree(pf); in i40e_remove()
16346 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_detected() local
16350 if (!pf) { in i40e_pci_error_detected()
16357 if (!test_bit(__I40E_SUSPENDED, pf->state)) in i40e_pci_error_detected()
16358 i40e_prep_for_reset(pf); in i40e_pci_error_detected()
16375 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_slot_reset() local
16390 reg = rd32(&pf->hw, I40E_GLGEN_RTRIG); in i40e_pci_error_slot_reset()
16406 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_reset_prepare() local
16408 i40e_prep_for_reset(pf); in i40e_pci_error_reset_prepare()
16417 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_reset_done() local
16419 if (test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_pci_error_reset_done()
16422 i40e_reset_and_rebuild(pf, false, false); in i40e_pci_error_reset_done()
16434 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_resume() local
16437 if (test_bit(__I40E_SUSPENDED, pf->state)) in i40e_pci_error_resume()
16440 i40e_handle_reset_warning(pf, false); in i40e_pci_error_resume()
16446 * @pf: pointer to i40e_pf struct
16448 static void i40e_enable_mc_magic_wake(struct i40e_pf *pf) in i40e_enable_mc_magic_wake() argument
16450 struct i40e_hw *hw = &pf->hw; in i40e_enable_mc_magic_wake()
16456 if (pf->vsi[pf->lan_vsi] && pf->vsi[pf->lan_vsi]->netdev) { in i40e_enable_mc_magic_wake()
16458 pf->vsi[pf->lan_vsi]->netdev->dev_addr); in i40e_enable_mc_magic_wake()
16460 dev_err(&pf->pdev->dev, in i40e_enable_mc_magic_wake()
16476 dev_err(&pf->pdev->dev, in i40e_enable_mc_magic_wake()
16486 dev_err(&pf->pdev->dev, in i40e_enable_mc_magic_wake()
16496 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_shutdown() local
16497 struct i40e_hw *hw = &pf->hw; in i40e_shutdown()
16499 set_bit(__I40E_SUSPENDED, pf->state); in i40e_shutdown()
16500 set_bit(__I40E_DOWN, pf->state); in i40e_shutdown()
16502 del_timer_sync(&pf->service_timer); in i40e_shutdown()
16503 cancel_work_sync(&pf->service_task); in i40e_shutdown()
16504 i40e_cloud_filter_exit(pf); in i40e_shutdown()
16505 i40e_fdir_teardown(pf); in i40e_shutdown()
16510 i40e_notify_client_of_netdev_close(pf->vsi[pf->lan_vsi], false); in i40e_shutdown()
16512 if (pf->wol_en && (pf->hw_features & I40E_HW_WOL_MC_MAGIC_PKT_WAKE)) in i40e_shutdown()
16513 i40e_enable_mc_magic_wake(pf); in i40e_shutdown()
16515 i40e_prep_for_reset(pf); in i40e_shutdown()
16518 (pf->wol_en ? I40E_PFPM_APM_APME_MASK : 0)); in i40e_shutdown()
16520 (pf->wol_en ? I40E_PFPM_WUFC_MAG_MASK : 0)); in i40e_shutdown()
16523 if (test_bit(__I40E_RECOVERY_MODE, pf->state) && in i40e_shutdown()
16524 !(pf->flags & I40E_FLAG_MSIX_ENABLED)) in i40e_shutdown()
16525 free_irq(pf->pdev->irq, pf); in i40e_shutdown()
16532 i40e_clear_interrupt_scheme(pf); in i40e_shutdown()
16536 pci_wake_from_d3(pdev, pf->wol_en); in i40e_shutdown()
16547 struct i40e_pf *pf = dev_get_drvdata(dev); in i40e_suspend() local
16548 struct i40e_hw *hw = &pf->hw; in i40e_suspend()
16551 if (test_and_set_bit(__I40E_SUSPENDED, pf->state)) in i40e_suspend()
16554 set_bit(__I40E_DOWN, pf->state); in i40e_suspend()
16557 del_timer_sync(&pf->service_timer); in i40e_suspend()
16558 cancel_work_sync(&pf->service_task); in i40e_suspend()
16563 i40e_notify_client_of_netdev_close(pf->vsi[pf->lan_vsi], false); in i40e_suspend()
16565 if (pf->wol_en && (pf->hw_features & I40E_HW_WOL_MC_MAGIC_PKT_WAKE)) in i40e_suspend()
16566 i40e_enable_mc_magic_wake(pf); in i40e_suspend()
16574 i40e_prep_for_reset(pf); in i40e_suspend()
16576 wr32(hw, I40E_PFPM_APM, (pf->wol_en ? I40E_PFPM_APM_APME_MASK : 0)); in i40e_suspend()
16577 wr32(hw, I40E_PFPM_WUFC, (pf->wol_en ? I40E_PFPM_WUFC_MAG_MASK : 0)); in i40e_suspend()
16584 i40e_clear_interrupt_scheme(pf); in i40e_suspend()
16597 struct i40e_pf *pf = dev_get_drvdata(dev); in i40e_resume() local
16601 if (!test_bit(__I40E_SUSPENDED, pf->state)) in i40e_resume()
16612 err = i40e_restore_interrupt_scheme(pf); in i40e_resume()
16618 clear_bit(__I40E_DOWN, pf->state); in i40e_resume()
16619 i40e_reset_and_rebuild(pf, false, true); in i40e_resume()
16624 clear_bit(__I40E_SUSPENDED, pf->state); in i40e_resume()
16627 mod_timer(&pf->service_timer, in i40e_resume()
16628 round_jiffies(jiffies + pf->service_timer_period)); in i40e_resume()