Lines Matching full:pf
35 static void i40e_handle_reset_warning(struct i40e_pf *pf, bool lock_acquired);
38 static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired);
39 static int i40e_setup_misc_vector(struct i40e_pf *pf);
40 static void i40e_determine_queue_usage(struct i40e_pf *pf);
41 static int i40e_setup_pf_filter_control(struct i40e_pf *pf);
42 static void i40e_prep_for_reset(struct i40e_pf *pf);
43 static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit,
45 static int i40e_reset(struct i40e_pf *pf);
46 static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired);
47 static int i40e_setup_misc_vector_for_recovery_mode(struct i40e_pf *pf);
48 static int i40e_restore_interrupt_scheme(struct i40e_pf *pf);
49 static bool i40e_check_recovery_mode(struct i40e_pf *pf);
50 static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw);
51 static void i40e_fdir_sb_setup(struct i40e_pf *pf);
53 static int i40e_get_capabilities(struct i40e_pf *pf,
55 static bool i40e_is_total_port_shutdown_enabled(struct i40e_pf *pf);
137 struct i40e_pf *pf = i40e_hw_to_pf(hw); in i40e_hw_to_dev() local
139 return &pf->pdev->dev; in i40e_hw_to_dev()
152 struct i40e_pf *pf = i40e_hw_to_pf(hw); in i40e_allocate_dma_mem() local
155 mem->va = dma_alloc_coherent(&pf->pdev->dev, mem->size, &mem->pa, in i40e_allocate_dma_mem()
170 struct i40e_pf *pf = i40e_hw_to_pf(hw); in i40e_free_dma_mem() local
172 dma_free_coherent(&pf->pdev->dev, mem->size, mem->va, mem->pa); in i40e_free_dma_mem()
215 * @pf: board private structure
222 static int i40e_get_lump(struct i40e_pf *pf, struct i40e_lump_tracking *pile, in i40e_get_lump() argument
229 dev_info(&pf->pdev->dev, in i40e_get_lump()
238 if (pile == pf->qp_pile && pf->vsi[id]->type == I40E_VSI_FDIR) { in i40e_get_lump()
240 dev_err(&pf->pdev->dev, in i40e_get_lump()
308 * @pf: the pf structure to search for the vsi
311 struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id) in i40e_find_vsi_from_id() argument
316 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_find_vsi_from_id()
325 * @pf: board private structure
329 void i40e_service_event_schedule(struct i40e_pf *pf) in i40e_service_event_schedule() argument
331 if ((!test_bit(__I40E_DOWN, pf->state) && in i40e_service_event_schedule()
332 !test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) || in i40e_service_event_schedule()
333 test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_service_event_schedule()
334 queue_work(i40e_wq, &pf->service_task); in i40e_service_event_schedule()
350 struct i40e_pf *pf = vsi->back; in i40e_tx_timeout() local
355 pf->tx_timeout_count++; in i40e_tx_timeout()
368 if (time_after(jiffies, (pf->tx_timeout_last_recovery + HZ*20))) in i40e_tx_timeout()
369 pf->tx_timeout_recovery_level = 1; /* reset after some time */ in i40e_tx_timeout()
371 (pf->tx_timeout_last_recovery + netdev->watchdog_timeo))) in i40e_tx_timeout()
375 if (test_and_set_bit(__I40E_TIMEOUT_RECOVERY_PENDING, pf->state)) in i40e_tx_timeout()
381 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_tx_timeout()
382 val = rd32(&pf->hw, in i40e_tx_timeout()
386 val = rd32(&pf->hw, I40E_PFINT_DYN_CTL0); in i40e_tx_timeout()
394 pf->tx_timeout_last_recovery = jiffies; in i40e_tx_timeout()
396 pf->tx_timeout_recovery_level, txqueue); in i40e_tx_timeout()
398 switch (pf->tx_timeout_recovery_level) { in i40e_tx_timeout()
400 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_tx_timeout()
403 set_bit(__I40E_CORE_RESET_REQUESTED, pf->state); in i40e_tx_timeout()
406 set_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state); in i40e_tx_timeout()
410 set_bit(__I40E_DOWN_REQUESTED, pf->state); in i40e_tx_timeout()
415 i40e_service_event_schedule(pf); in i40e_tx_timeout()
416 pf->tx_timeout_recovery_level++; in i40e_tx_timeout()
551 * i40e_pf_reset_stats - Reset all of the stats for the given PF
552 * @pf: the PF to be reset
554 void i40e_pf_reset_stats(struct i40e_pf *pf) in i40e_pf_reset_stats() argument
559 memset(&pf->stats, 0, sizeof(pf->stats)); in i40e_pf_reset_stats()
560 memset(&pf->stats_offsets, 0, sizeof(pf->stats_offsets)); in i40e_pf_reset_stats()
561 pf->stat_offsets_loaded = false; in i40e_pf_reset_stats()
563 i40e_pf_for_each_veb(pf, i, veb) { in i40e_pf_reset_stats()
570 pf->hw_csum_rx_error = 0; in i40e_pf_reset_stats()
716 struct i40e_pf *pf = vsi->back; in i40e_update_eth_stats() local
717 struct i40e_hw *hw = &pf->hw; in i40e_update_eth_stats()
778 struct i40e_pf *pf = veb->pf; in i40e_update_veb_stats() local
779 struct i40e_hw *hw = &pf->hw; in i40e_update_veb_stats()
864 struct i40e_pf *pf = vsi->back; in i40e_update_vsi_stats() local
881 test_bit(__I40E_CONFIG_BUSY, pf->state)) in i40e_update_vsi_stats()
991 /* pull in a couple PF stats if this is the main vsi */ in i40e_update_vsi_stats()
993 ns->rx_crc_errors = pf->stats.crc_errors; in i40e_update_vsi_stats()
994 ns->rx_errors = pf->stats.crc_errors + pf->stats.illegal_bytes; in i40e_update_vsi_stats()
995 ns->rx_length_errors = pf->stats.rx_length_errors; in i40e_update_vsi_stats()
1000 * i40e_update_pf_stats - Update the PF statistics counters.
1001 * @pf: the PF to be updated
1003 static void i40e_update_pf_stats(struct i40e_pf *pf) in i40e_update_pf_stats() argument
1005 struct i40e_hw_port_stats *osd = &pf->stats_offsets; in i40e_update_pf_stats()
1006 struct i40e_hw_port_stats *nsd = &pf->stats; in i40e_update_pf_stats()
1007 struct i40e_hw *hw = &pf->hw; in i40e_update_pf_stats()
1013 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1017 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1020 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1025 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1030 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1035 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1040 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1045 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1050 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1055 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1060 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1064 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1068 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1072 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1077 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1082 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1085 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1088 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1091 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1096 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1100 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1104 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1108 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1113 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()
1136 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1140 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1144 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()
1169 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1173 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1177 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1180 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1183 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1186 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1206 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1209 pf->stat_offsets_loaded, in i40e_update_pf_stats()
1212 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) && in i40e_update_pf_stats()
1213 !test_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state)) in i40e_update_pf_stats()
1218 if (test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags) && in i40e_update_pf_stats()
1219 !test_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state)) in i40e_update_pf_stats()
1224 pf->stat_offsets_loaded = true; in i40e_update_pf_stats()
1235 struct i40e_pf *pf = vsi->back; in i40e_update_stats() local
1238 i40e_update_pf_stats(pf); in i40e_update_stats()
1484 struct i40e_pf *pf = vsi->back; in i40e_get_vf_new_vlan() local
1494 !test_bit(I40E_FLAG_VF_VLAN_PRUNING_ENA, pf->flags)); in i40e_get_vf_new_vlan()
1575 * @vsi: the PF Main VSI - inappropriate for any other VSI
1584 struct i40e_pf *pf = vsi->back; in i40e_rm_default_mac_filter() local
1586 /* Only appropriate for the PF main VSI */ in i40e_rm_default_mac_filter()
1595 i40e_aq_remove_macvlan(&pf->hw, vsi->seid, &element, 1, NULL); in i40e_rm_default_mac_filter()
1603 i40e_aq_remove_macvlan(&pf->hw, vsi->seid, &element, 1, NULL); in i40e_rm_default_mac_filter()
1779 struct i40e_pf *pf = vsi->back; in i40e_set_mac() local
1780 struct i40e_hw *hw = &pf->hw; in i40e_set_mac()
1786 if (test_bit(__I40E_DOWN, pf->state) || in i40e_set_mac()
1787 test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_set_mac()
1822 i40e_service_event_schedule(pf); in i40e_set_mac()
1836 struct i40e_pf *pf = vsi->back; in i40e_config_rss_aq() local
1837 struct i40e_hw *hw = &pf->hw; in i40e_config_rss_aq()
1845 dev_info(&pf->pdev->dev, in i40e_config_rss_aq()
1857 dev_info(&pf->pdev->dev, in i40e_config_rss_aq()
1873 struct i40e_pf *pf = vsi->back; in i40e_vsi_config_rss() local
1878 if (!test_bit(I40E_HW_CAP_RSS_AQ, pf->hw.caps)) in i40e_vsi_config_rss()
1881 vsi->rss_size = min_t(int, pf->alloc_rss_size, in i40e_vsi_config_rss()
1895 i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, vsi->rss_size); in i40e_vsi_config_rss()
2006 struct i40e_pf *pf = vsi->back; in i40e_vsi_setup_queue_map() local
2033 else if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_vsi_setup_queue_map()
2034 vsi->num_queue_pairs = pf->num_lan_msix; in i40e_vsi_setup_queue_map()
2053 dev_warn(&pf->pdev->dev, "DCB is enabled but no TC enabled, forcing TC0\n"); in i40e_vsi_setup_queue_map()
2058 i40e_pf_get_max_q_per_tc(pf)); in i40e_vsi_setup_queue_map()
2065 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_vsi_setup_queue_map()
2066 num_tc_qps = min_t(int, num_tc_qps, pf->num_lan_msix); in i40e_vsi_setup_queue_map()
2078 pf->flags) && in i40e_vsi_setup_queue_map()
2080 pf->flags)) || in i40e_vsi_setup_queue_map()
2082 qcount = min_t(int, pf->alloc_rss_size, in i40e_vsi_setup_queue_map()
2452 * @pf: board private structure
2455 * There are different ways of setting promiscuous mode on a PF depending on
2459 static int i40e_set_promiscuous(struct i40e_pf *pf, bool promisc) in i40e_set_promiscuous() argument
2461 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_set_promiscuous()
2462 struct i40e_hw *hw = &pf->hw; in i40e_set_promiscuous()
2466 i40e_pf_get_main_veb(pf) && in i40e_set_promiscuous()
2467 !test_bit(I40E_FLAG_MFP_ENA, pf->flags)) { in i40e_set_promiscuous()
2482 dev_info(&pf->pdev->dev, in i40e_set_promiscuous()
2494 dev_info(&pf->pdev->dev, in i40e_set_promiscuous()
2504 dev_info(&pf->pdev->dev, in i40e_set_promiscuous()
2512 pf->cur_promisc = promisc; in i40e_set_promiscuous()
2534 char vsi_name[16] = "PF"; in i40e_sync_vsi_filters()
2538 struct i40e_pf *pf; in i40e_sync_vsi_filters() local
2553 pf = vsi->back; in i40e_sync_vsi_filters()
2611 else if (pf->vf) in i40e_sync_vsi_filters()
2614 vlan_filters, pf->vf[vsi->vf_id].trusted); in i40e_sync_vsi_filters()
2777 dev_info(&pf->pdev->dev, in i40e_sync_vsi_filters()
2785 if (vsi->type == I40E_VSI_SRIOV && pf->vf && in i40e_sync_vsi_filters()
2786 !pf->vf[vsi->vf_id].trusted) { in i40e_sync_vsi_filters()
2811 dev_info(&pf->pdev->dev, in i40e_sync_vsi_filters()
2817 dev_info(&pf->pdev->dev, "%s allmulti mode.\n", in i40e_sync_vsi_filters()
2827 aq_ret = i40e_set_promiscuous(pf, cur_promisc); in i40e_sync_vsi_filters()
2831 dev_info(&pf->pdev->dev, in i40e_sync_vsi_filters()
2862 * @pf: board private structure
2864 static void i40e_sync_filters_subtask(struct i40e_pf *pf) in i40e_sync_filters_subtask() argument
2869 if (!pf) in i40e_sync_filters_subtask()
2871 if (!test_and_clear_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state)) in i40e_sync_filters_subtask()
2873 if (test_bit(__I40E_VF_DISABLE, pf->state)) { in i40e_sync_filters_subtask()
2874 set_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state); in i40e_sync_filters_subtask()
2878 i40e_pf_for_each_vsi(pf, v, vsi) { in i40e_sync_filters_subtask()
2886 pf->state); in i40e_sync_filters_subtask()
2936 struct i40e_pf *pf = vsi->back; in i40e_change_mtu() local
2951 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_change_mtu()
2952 set_bit(__I40E_CLIENT_L2_CHANGE, pf->state); in i40e_change_mtu()
2965 struct i40e_pf *pf = np->vsi->back; in i40e_ioctl() local
2969 return i40e_ptp_get_ts_config(pf, ifr); in i40e_ioctl()
2971 return i40e_ptp_set_ts_config(pf, ifr); in i40e_ioctl()
3807 * @pf: Pointer to the targeted PF
3811 static void i40e_reset_fdir_filter_cnt(struct i40e_pf *pf) in i40e_reset_fdir_filter_cnt() argument
3813 pf->fd_tcp4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3814 pf->fd_udp4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3815 pf->fd_sctp4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3816 pf->fd_ip4_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3817 pf->fd_tcp6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3818 pf->fd_udp6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3819 pf->fd_sctp6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3820 pf->fd_ip6_filter_cnt = 0; in i40e_reset_fdir_filter_cnt()
3833 struct i40e_pf *pf = vsi->back; in i40e_fdir_filter_restore() local
3836 if (!test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) in i40e_fdir_filter_restore()
3840 i40e_reset_fdir_filter_cnt(pf); in i40e_fdir_filter_restore()
3843 &pf->fdir_filter_list, fdir_node) { in i40e_fdir_filter_restore()
3873 struct i40e_pf *pf = vsi->back; in i40e_vsi_configure_msix() local
3874 struct i40e_hw *hw = &pf->hw; in i40e_vsi_configure_msix()
3960 * @pf: pointer to private device data structure
3962 static void i40e_enable_misc_int_causes(struct i40e_pf *pf) in i40e_enable_misc_int_causes() argument
3964 struct i40e_hw *hw = &pf->hw; in i40e_enable_misc_int_causes()
3980 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) in i40e_enable_misc_int_causes()
3983 if (test_bit(I40E_FLAG_PTP_ENA, pf->flags)) in i40e_enable_misc_int_causes()
4004 struct i40e_pf *pf = vsi->back; in i40e_configure_msi_and_legacy() local
4005 struct i40e_hw *hw = &pf->hw; in i40e_configure_msi_and_legacy()
4017 i40e_enable_misc_int_causes(pf); in i40e_configure_msi_and_legacy()
4041 * @pf: board private structure
4043 void i40e_irq_dynamic_disable_icr0(struct i40e_pf *pf) in i40e_irq_dynamic_disable_icr0() argument
4045 struct i40e_hw *hw = &pf->hw; in i40e_irq_dynamic_disable_icr0()
4054 * @pf: board private structure
4056 void i40e_irq_dynamic_enable_icr0(struct i40e_pf *pf) in i40e_irq_dynamic_enable_icr0() argument
4058 struct i40e_hw *hw = &pf->hw; in i40e_irq_dynamic_enable_icr0()
4123 struct i40e_pf *pf = vsi->back; in i40e_vsi_request_irq_msix() local
4134 irq_num = pf->msix_entries[base + vector].vector; in i40e_vsi_request_irq_msix()
4156 dev_info(&pf->pdev->dev, in i40e_vsi_request_irq_msix()
4182 irq_num = pf->msix_entries[base + vector].vector; in i40e_vsi_request_irq_msix()
4196 struct i40e_pf *pf = vsi->back; in i40e_vsi_disable_irq() local
4197 struct i40e_hw *hw = &pf->hw; in i40e_vsi_disable_irq()
4219 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_vsi_disable_irq()
4226 synchronize_irq(pf->msix_entries[i + base].vector); in i40e_vsi_disable_irq()
4232 synchronize_irq(pf->pdev->irq); in i40e_vsi_disable_irq()
4242 struct i40e_pf *pf = vsi->back; in i40e_vsi_enable_irq() local
4245 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_vsi_enable_irq()
4249 i40e_irq_dynamic_enable_icr0(pf); in i40e_vsi_enable_irq()
4252 i40e_flush(&pf->hw); in i40e_vsi_enable_irq()
4258 * @pf: board private structure
4260 static void i40e_free_misc_vector(struct i40e_pf *pf) in i40e_free_misc_vector() argument
4263 wr32(&pf->hw, I40E_PFINT_ICR0_ENA, 0); in i40e_free_misc_vector()
4264 i40e_flush(&pf->hw); in i40e_free_misc_vector()
4266 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags) && pf->msix_entries) { in i40e_free_misc_vector()
4267 free_irq(pf->msix_entries[0].vector, pf); in i40e_free_misc_vector()
4268 clear_bit(__I40E_MISC_IRQ_REQUESTED, pf->state); in i40e_free_misc_vector()
4283 struct i40e_pf *pf = (struct i40e_pf *)data; in i40e_intr() local
4284 struct i40e_hw *hw = &pf->hw; in i40e_intr()
4299 pf->sw_int_count++; in i40e_intr()
4301 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags) && in i40e_intr()
4304 dev_dbg(&pf->pdev->dev, "cleared PE_CRITERR\n"); in i40e_intr()
4305 set_bit(__I40E_CORE_RESET_REQUESTED, pf->state); in i40e_intr()
4310 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_intr()
4319 if (!test_bit(__I40E_DOWN, pf->state)) in i40e_intr()
4325 set_bit(__I40E_ADMINQ_EVENT_PENDING, pf->state); in i40e_intr()
4326 i40e_debug(&pf->hw, I40E_DEBUG_NVM, "AdminQ event\n"); in i40e_intr()
4331 set_bit(__I40E_MDD_EVENT_PENDING, pf->state); in i40e_intr()
4336 if (test_bit(__I40E_VF_RESETS_DISABLED, pf->state)) { in i40e_intr()
4343 set_bit(__I40E_VFLR_EVENT_PENDING, pf->state); in i40e_intr()
4348 if (!test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_intr()
4349 set_bit(__I40E_RESET_INTR_RECEIVED, pf->state); in i40e_intr()
4354 pf->corer_count++; in i40e_intr()
4356 pf->globr_count++; in i40e_intr()
4358 pf->empr_count++; in i40e_intr()
4359 set_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state); in i40e_intr()
4365 dev_info(&pf->pdev->dev, "HMC error interrupt\n"); in i40e_intr()
4366 dev_info(&pf->pdev->dev, "HMC error info 0x%x, HMC error data 0x%x\n", in i40e_intr()
4375 schedule_work(&pf->ptp_extts0_work); in i40e_intr()
4378 i40e_ptp_tx_hwtstamp(pf); in i40e_intr()
4389 dev_info(&pf->pdev->dev, "unhandled interrupt icr0=0x%08x\n", in i40e_intr()
4394 dev_info(&pf->pdev->dev, "device will be reset\n"); in i40e_intr()
4395 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_intr()
4396 i40e_service_event_schedule(pf); in i40e_intr()
4405 if (!test_bit(__I40E_DOWN, pf->state) || in i40e_intr()
4406 test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_intr()
4407 i40e_service_event_schedule(pf); in i40e_intr()
4408 i40e_irq_dynamic_enable_icr0(pf); in i40e_intr()
4603 struct i40e_pf *pf = vsi->back; in i40e_vsi_request_irq() local
4606 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_vsi_request_irq()
4608 else if (test_bit(I40E_FLAG_MSI_ENA, pf->flags)) in i40e_vsi_request_irq()
4609 err = request_irq(pf->pdev->irq, i40e_intr, 0, in i40e_vsi_request_irq()
4610 pf->int_name, pf); in i40e_vsi_request_irq()
4612 err = request_irq(pf->pdev->irq, i40e_intr, IRQF_SHARED, in i40e_vsi_request_irq()
4613 pf->int_name, pf); in i40e_vsi_request_irq()
4616 dev_info(&pf->pdev->dev, "request_irq failed, Error %d\n", err); in i40e_vsi_request_irq()
4633 struct i40e_pf *pf = vsi->back; in i40e_netpoll() local
4640 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_netpoll()
4644 i40e_intr(pf->pdev->irq, netdev); in i40e_netpoll()
4652 * i40e_pf_txq_wait - Wait for a PF's Tx queue to be enabled or disabled
4653 * @pf: the PF being configured
4654 * @pf_q: the PF queue
4657 * This routine will wait for the given Tx queue of the PF to reach the
4662 static int i40e_pf_txq_wait(struct i40e_pf *pf, int pf_q, bool enable) in i40e_pf_txq_wait() argument
4668 tx_reg = rd32(&pf->hw, I40E_QTX_ENA(pf_q)); in i40e_pf_txq_wait()
4682 * @pf: the PF structure
4683 * @pf_q: the PF queue to configure
4690 static void i40e_control_tx_q(struct i40e_pf *pf, int pf_q, bool enable) in i40e_control_tx_q() argument
4692 struct i40e_hw *hw = &pf->hw; in i40e_control_tx_q()
4697 i40e_pre_tx_queue_cfg(&pf->hw, pf_q, enable); in i40e_control_tx_q()
4727 * @pf: the PF structure
4728 * @pf_q: the PF queue to configure
4732 int i40e_control_wait_tx_q(int seid, struct i40e_pf *pf, int pf_q, in i40e_control_wait_tx_q() argument
4737 i40e_control_tx_q(pf, pf_q, enable); in i40e_control_wait_tx_q()
4740 ret = i40e_pf_txq_wait(pf, pf_q, enable); in i40e_control_wait_tx_q()
4742 dev_info(&pf->pdev->dev, in i40e_control_wait_tx_q()
4757 struct i40e_pf *pf = vsi->back; in i40e_vsi_enable_tx() local
4762 ret = i40e_control_wait_tx_q(vsi->seid, pf, in i40e_vsi_enable_tx()
4771 ret = i40e_control_wait_tx_q(vsi->seid, pf, in i40e_vsi_enable_tx()
4781 * i40e_pf_rxq_wait - Wait for a PF's Rx queue to be enabled or disabled
4782 * @pf: the PF being configured
4783 * @pf_q: the PF queue
4786 * This routine will wait for the given Rx queue of the PF to reach the
4791 static int i40e_pf_rxq_wait(struct i40e_pf *pf, int pf_q, bool enable) in i40e_pf_rxq_wait() argument
4797 rx_reg = rd32(&pf->hw, I40E_QRX_ENA(pf_q)); in i40e_pf_rxq_wait()
4811 * @pf: the PF structure
4812 * @pf_q: the PF queue to configure
4819 static void i40e_control_rx_q(struct i40e_pf *pf, int pf_q, bool enable) in i40e_control_rx_q() argument
4821 struct i40e_hw *hw = &pf->hw; in i40e_control_rx_q()
4848 * @pf: the PF structure
4856 int i40e_control_wait_rx_q(struct i40e_pf *pf, int pf_q, bool enable) in i40e_control_wait_rx_q() argument
4860 i40e_control_rx_q(pf, pf_q, enable); in i40e_control_wait_rx_q()
4863 ret = i40e_pf_rxq_wait(pf, pf_q, enable); in i40e_control_wait_rx_q()
4876 struct i40e_pf *pf = vsi->back; in i40e_vsi_enable_rx() local
4881 ret = i40e_control_wait_rx_q(pf, pf_q, true); in i40e_vsi_enable_rx()
4883 dev_info(&pf->pdev->dev, in i40e_vsi_enable_rx()
4918 struct i40e_pf *pf = vsi->back; in i40e_vsi_stop_rings() local
4928 i40e_pre_tx_queue_cfg(&pf->hw, pf_q, false); in i40e_vsi_stop_rings()
4932 i40e_control_rx_q(pf, pf_q, false); in i40e_vsi_stop_rings()
4936 wr32(&pf->hw, I40E_QTX_ENA(pf_q), 0); in i40e_vsi_stop_rings()
4954 struct i40e_pf *pf = vsi->back; in i40e_vsi_stop_rings_no_wait() local
4959 i40e_control_tx_q(pf, pf_q, false); in i40e_vsi_stop_rings_no_wait()
4960 i40e_control_rx_q(pf, pf_q, false); in i40e_vsi_stop_rings_no_wait()
4970 struct i40e_pf *pf = vsi->back; in i40e_vsi_free_irq() local
4971 struct i40e_hw *hw = &pf->hw; in i40e_vsi_free_irq()
4976 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_vsi_free_irq()
4989 irq_num = pf->msix_entries[vector].vector; in i40e_vsi_free_irq()
5049 free_irq(pf->pdev->irq, pf); in i40e_vsi_free_irq()
5132 * @pf: board private structure
5134 static void i40e_reset_interrupt_capability(struct i40e_pf *pf) in i40e_reset_interrupt_capability() argument
5137 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_reset_interrupt_capability()
5138 pci_disable_msix(pf->pdev); in i40e_reset_interrupt_capability()
5139 kfree(pf->msix_entries); in i40e_reset_interrupt_capability()
5140 pf->msix_entries = NULL; in i40e_reset_interrupt_capability()
5141 kfree(pf->irq_pile); in i40e_reset_interrupt_capability()
5142 pf->irq_pile = NULL; in i40e_reset_interrupt_capability()
5143 } else if (test_bit(I40E_FLAG_MSI_ENA, pf->flags)) { in i40e_reset_interrupt_capability()
5144 pci_disable_msi(pf->pdev); in i40e_reset_interrupt_capability()
5146 clear_bit(I40E_FLAG_MSI_ENA, pf->flags); in i40e_reset_interrupt_capability()
5147 clear_bit(I40E_FLAG_MSIX_ENA, pf->flags); in i40e_reset_interrupt_capability()
5152 * @pf: board private structure
5157 static void i40e_clear_interrupt_scheme(struct i40e_pf *pf) in i40e_clear_interrupt_scheme() argument
5162 if (test_bit(__I40E_MISC_IRQ_REQUESTED, pf->state)) in i40e_clear_interrupt_scheme()
5163 i40e_free_misc_vector(pf); in i40e_clear_interrupt_scheme()
5165 i40e_put_lump(pf->irq_pile, pf->iwarp_base_vector, in i40e_clear_interrupt_scheme()
5168 i40e_put_lump(pf->irq_pile, 0, I40E_PILE_VALID_BIT-1); in i40e_clear_interrupt_scheme()
5170 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_clear_interrupt_scheme()
5173 i40e_reset_interrupt_capability(pf); in i40e_clear_interrupt_scheme()
5220 struct i40e_pf *pf = vsi->back; in i40e_vsi_close() local
5227 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_vsi_close()
5228 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_vsi_close()
5229 set_bit(__I40E_CLIENT_RESET, pf->state); in i40e_vsi_close()
5264 * i40e_pf_quiesce_all_vsi - Pause all VSIs on a PF
5265 * @pf: the PF
5267 static void i40e_pf_quiesce_all_vsi(struct i40e_pf *pf) in i40e_pf_quiesce_all_vsi() argument
5272 i40e_pf_for_each_vsi(pf, v, vsi) in i40e_pf_quiesce_all_vsi()
5277 * i40e_pf_unquiesce_all_vsi - Resume all VSIs on a PF
5278 * @pf: the PF
5280 static void i40e_pf_unquiesce_all_vsi(struct i40e_pf *pf) in i40e_pf_unquiesce_all_vsi() argument
5285 i40e_pf_for_each_vsi(pf, v, vsi) in i40e_pf_unquiesce_all_vsi()
5297 struct i40e_pf *pf = vsi->back; in i40e_vsi_wait_queues_disabled() local
5303 ret = i40e_pf_txq_wait(pf, pf_q, false); in i40e_vsi_wait_queues_disabled()
5305 dev_info(&pf->pdev->dev, in i40e_vsi_wait_queues_disabled()
5315 ret = i40e_pf_txq_wait(pf, pf_q + vsi->alloc_queue_pairs, in i40e_vsi_wait_queues_disabled()
5318 dev_info(&pf->pdev->dev, in i40e_vsi_wait_queues_disabled()
5325 ret = i40e_pf_rxq_wait(pf, pf_q, false); in i40e_vsi_wait_queues_disabled()
5327 dev_info(&pf->pdev->dev, in i40e_vsi_wait_queues_disabled()
5339 * i40e_pf_wait_queues_disabled - Wait for all queues of PF VSIs to be disabled
5340 * @pf: the PF
5343 * VSIs that are managed by this PF.
5345 static int i40e_pf_wait_queues_disabled(struct i40e_pf *pf) in i40e_pf_wait_queues_disabled() argument
5350 i40e_pf_for_each_vsi(pf, v, vsi) { in i40e_pf_wait_queues_disabled()
5363 * @pf: pointer to PF
5365 * Get TC map for ISCSI PF type that will include iSCSI TC
5368 static u8 i40e_get_iscsi_tc_map(struct i40e_pf *pf) in i40e_get_iscsi_tc_map() argument
5371 struct i40e_hw *hw = &pf->hw; in i40e_get_iscsi_tc_map()
5453 * @pf: PF being queried
5458 static u8 i40e_mqprio_get_enabled_tc(struct i40e_pf *pf) in i40e_mqprio_get_enabled_tc() argument
5460 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_mqprio_get_enabled_tc()
5470 * i40e_pf_get_num_tc - Get enabled traffic classes for PF
5471 * @pf: PF being queried
5473 * Return number of traffic classes enabled for the given PF
5475 static u8 i40e_pf_get_num_tc(struct i40e_pf *pf) in i40e_pf_get_num_tc() argument
5480 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_pf_get_num_tc()
5481 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_pf_get_num_tc()
5487 if (!test_bit(I40E_FLAG_DCB_ENA, pf->flags)) in i40e_pf_get_num_tc()
5491 if (!test_bit(I40E_FLAG_MFP_ENA, pf->flags)) in i40e_pf_get_num_tc()
5492 return i40e_dcb_get_num_tc(&pf->hw.local_dcbx_config); in i40e_pf_get_num_tc()
5494 /* MFP mode return count of enabled TCs for this PF */ in i40e_pf_get_num_tc()
5495 if (pf->hw.func_caps.iscsi) in i40e_pf_get_num_tc()
5496 enabled_tc = i40e_get_iscsi_tc_map(pf); in i40e_pf_get_num_tc()
5509 * @pf: PF being queried
5511 * Return a bitmap for enabled traffic classes for this PF.
5513 static u8 i40e_pf_get_tc_map(struct i40e_pf *pf) in i40e_pf_get_tc_map() argument
5515 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_pf_get_tc_map()
5516 return i40e_mqprio_get_enabled_tc(pf); in i40e_pf_get_tc_map()
5518 /* If neither MQPRIO nor DCB is enabled for this PF then just return in i40e_pf_get_tc_map()
5521 if (!test_bit(I40E_FLAG_DCB_ENA, pf->flags)) in i40e_pf_get_tc_map()
5524 /* SFP mode we want PF to be enabled for all TCs */ in i40e_pf_get_tc_map()
5525 if (!test_bit(I40E_FLAG_MFP_ENA, pf->flags)) in i40e_pf_get_tc_map()
5526 return i40e_dcb_get_enabled_tc(&pf->hw.local_dcbx_config); in i40e_pf_get_tc_map()
5528 /* MFP enabled and iSCSI PF type */ in i40e_pf_get_tc_map()
5529 if (pf->hw.func_caps.iscsi) in i40e_pf_get_tc_map()
5530 return i40e_get_iscsi_tc_map(pf); in i40e_pf_get_tc_map()
5545 struct i40e_pf *pf = vsi->back; in i40e_vsi_get_bw_info() local
5546 struct i40e_hw *hw = &pf->hw; in i40e_vsi_get_bw_info()
5554 dev_info(&pf->pdev->dev, in i40e_vsi_get_bw_info()
5555 "couldn't get PF vsi bw config, err %pe aq_err %s\n", in i40e_vsi_get_bw_info()
5557 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_vsi_get_bw_info()
5565 dev_info(&pf->pdev->dev, in i40e_vsi_get_bw_info()
5566 "couldn't get PF vsi ets bw config, err %pe aq_err %s\n", in i40e_vsi_get_bw_info()
5568 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_vsi_get_bw_info()
5573 dev_info(&pf->pdev->dev, in i40e_vsi_get_bw_info()
5607 struct i40e_pf *pf = vsi->back; in i40e_vsi_configure_bw_alloc() local
5612 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_vsi_configure_bw_alloc()
5614 if (!vsi->mqprio_qopt.qopt.hw && !test_bit(I40E_FLAG_DCB_ENA, pf->flags)) { in i40e_vsi_configure_bw_alloc()
5617 dev_info(&pf->pdev->dev, in i40e_vsi_configure_bw_alloc()
5627 ret = i40e_aq_config_vsi_tc_bw(&pf->hw, vsi->seid, &bw_data, NULL); in i40e_vsi_configure_bw_alloc()
5629 dev_info(&pf->pdev->dev, in i40e_vsi_configure_bw_alloc()
5631 pf->hw.aq.asq_last_status); in i40e_vsi_configure_bw_alloc()
5650 struct i40e_pf *pf = vsi->back; in i40e_vsi_config_netdev_tc() local
5651 struct i40e_hw *hw = &pf->hw; in i40e_vsi_config_netdev_tc()
5684 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_vsi_config_netdev_tc()
5724 struct i40e_pf *pf; in i40e_update_adq_vsi_queues() local
5730 pf = vsi->back; in i40e_update_adq_vsi_queues()
5731 hw = &pf->hw; in i40e_update_adq_vsi_queues()
5744 vsi->rss_size = min_t(int, pf->alloc_rss_size, in i40e_update_adq_vsi_queues()
5748 dev_info(&pf->pdev->dev, "Failed to reconfig rss for num_queues\n"); in i40e_update_adq_vsi_queues()
5756 dev_info(&pf->pdev->dev, "Update vsi config failed, err %pe aq_err %s\n", in i40e_update_adq_vsi_queues()
5784 struct i40e_pf *pf = vsi->back; in i40e_vsi_config_tc() local
5785 struct i40e_hw *hw = &pf->hw; in i40e_vsi_config_tc()
5805 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5811 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5824 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5832 dev_err(&pf->pdev->dev, in i40e_vsi_config_tc()
5845 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_vsi_config_tc()
5878 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5891 dev_info(&pf->pdev->dev, in i40e_vsi_config_tc()
5933 struct i40e_pf *pf = vsi->back; in i40e_get_link_speed() local
5935 switch (pf->hw.phy.link_info.link_speed) { in i40e_get_link_speed()
5981 struct i40e_pf *pf = vsi->back; in i40e_set_bw_limit() local
5988 dev_err(&pf->pdev->dev, in i40e_set_bw_limit()
5994 dev_warn(&pf->pdev->dev, in i40e_set_bw_limit()
6002 ret = i40e_aq_config_vsi_bw_limit(&pf->hw, seid, credits, in i40e_set_bw_limit()
6005 dev_err(&pf->pdev->dev, in i40e_set_bw_limit()
6008 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_set_bw_limit()
6023 struct i40e_pf *pf = vsi->back; in i40e_remove_queue_channels() local
6067 &pf->cloud_filter_list, cloud_node) { in i40e_remove_queue_channels()
6079 last_aq_status = pf->hw.aq.asq_last_status; in i40e_remove_queue_channels()
6081 dev_info(&pf->pdev->dev, in i40e_remove_queue_channels()
6084 i40e_aq_str(&pf->hw, last_aq_status)); in i40e_remove_queue_channels()
6124 * @pf: ptr to PF device
6133 static int i40e_validate_num_queues(struct i40e_pf *pf, int num_queues, in i40e_validate_num_queues() argument
6144 dev_dbg(&pf->pdev->dev, in i40e_validate_num_queues()
6150 dev_dbg(&pf->pdev->dev, in i40e_validate_num_queues()
6165 dev_dbg(&pf->pdev->dev, in i40e_validate_num_queues()
6185 struct i40e_pf *pf = vsi->back; in i40e_vsi_reconfig_rss() local
6187 struct i40e_hw *hw = &pf->hw; in i40e_vsi_reconfig_rss()
6204 i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, local_rss_size); in i40e_vsi_reconfig_rss()
6216 dev_info(&pf->pdev->dev, in i40e_vsi_reconfig_rss()
6235 * @pf: ptr to PF device
6241 static void i40e_channel_setup_queue_map(struct i40e_pf *pf, in i40e_channel_setup_queue_map() argument
6252 qcount = min_t(int, ch->num_queue_pairs, pf->num_lan_msix); in i40e_channel_setup_queue_map()
6274 * @pf: ptr to PF device
6280 static int i40e_add_channel(struct i40e_pf *pf, u16 uplink_seid, in i40e_add_channel() argument
6283 struct i40e_hw *hw = &pf->hw; in i40e_add_channel()
6289 dev_info(&pf->pdev->dev, in i40e_add_channel()
6302 if (test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags)) { in i40e_add_channel()
6310 i40e_channel_setup_queue_map(pf, &ctxt, ch); in i40e_add_channel()
6315 dev_info(&pf->pdev->dev, in i40e_add_channel()
6318 i40e_aq_str(&pf->hw, in i40e_add_channel()
6319 pf->hw.aq.asq_last_status)); in i40e_add_channel()
6373 * @pf: ptr to PF device
6380 static int i40e_channel_config_tx_ring(struct i40e_pf *pf, in i40e_channel_config_tx_ring() argument
6425 * @pf: ptr to PF device
6434 static inline int i40e_setup_hw_channel(struct i40e_pf *pf, in i40e_setup_hw_channel() argument
6446 ret = i40e_add_channel(pf, uplink_seid, ch); in i40e_setup_hw_channel()
6448 dev_info(&pf->pdev->dev, in i40e_setup_hw_channel()
6458 ret = i40e_channel_config_tx_ring(pf, vsi, ch); in i40e_setup_hw_channel()
6460 dev_info(&pf->pdev->dev, in i40e_setup_hw_channel()
6468 dev_dbg(&pf->pdev->dev, in i40e_setup_hw_channel()
6469 …"Added channel: vsi_seid %u, vsi_number %u, stat_counter_idx %u, num_queue_pairs %u, pf->next_base… in i40e_setup_hw_channel()
6478 * @pf: ptr to PF device
6485 static bool i40e_setup_channel(struct i40e_pf *pf, struct i40e_vsi *vsi, in i40e_setup_channel() argument
6496 dev_err(&pf->pdev->dev, "unsupported parent vsi type(%d)\n", in i40e_setup_channel()
6502 main_vsi = i40e_pf_get_main_vsi(pf); in i40e_setup_channel()
6506 ret = i40e_setup_hw_channel(pf, vsi, ch, seid, vsi_type); in i40e_setup_channel()
6508 dev_err(&pf->pdev->dev, "failed to setup hw_channel\n"); in i40e_setup_channel()
6517 * @vsi: ptr to VSI which has PF backing
6525 struct i40e_pf *pf = vsi->back; in i40e_validate_and_set_switch_mode() local
6526 struct i40e_hw *hw = &pf->hw; in i40e_validate_and_set_switch_mode()
6529 ret = i40e_get_capabilities(pf, i40e_aqc_opc_list_dev_capabilities); in i40e_validate_and_set_switch_mode()
6542 dev_err(&pf->pdev->dev, in i40e_validate_and_set_switch_mode()
6559 ret = i40e_aq_set_switch_config(hw, pf->last_sw_conf_flags, in i40e_validate_and_set_switch_mode()
6560 pf->last_sw_conf_valid_flags, in i40e_validate_and_set_switch_mode()
6563 dev_err(&pf->pdev->dev, in i40e_validate_and_set_switch_mode()
6583 struct i40e_pf *pf = vsi->back; in i40e_create_queue_channel() local
6591 dev_err(&pf->pdev->dev, "Invalid num_queues requested: %d\n", in i40e_create_queue_channel()
6597 err = i40e_validate_num_queues(pf, ch->num_queue_pairs, vsi, in i40e_create_queue_channel()
6600 dev_info(&pf->pdev->dev, "Failed to validate num_queues (%d)\n", in i40e_create_queue_channel()
6609 if (!test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags)) { in i40e_create_queue_channel()
6610 set_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags); in i40e_create_queue_channel()
6613 if (i40e_is_tc_mqprio_enabled(pf)) in i40e_create_queue_channel()
6614 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_create_queue_channel()
6616 i40e_do_reset_safe(pf, I40E_PF_RESET_FLAG); in i40e_create_queue_channel()
6627 dev_dbg(&pf->pdev->dev, in i40e_create_queue_channel()
6637 dev_info(&pf->pdev->dev, in i40e_create_queue_channel()
6644 if (!i40e_setup_channel(pf, vsi, ch)) { in i40e_create_queue_channel()
6645 dev_info(&pf->pdev->dev, "Failed to setup channel\n"); in i40e_create_queue_channel()
6649 dev_info(&pf->pdev->dev, in i40e_create_queue_channel()
6661 dev_dbg(&pf->pdev->dev, in i40e_create_queue_channel()
6744 struct i40e_pf *pf = veb->pf; in i40e_veb_config_tc() local
6761 ret = i40e_aq_config_switch_comp_bw_config(&pf->hw, veb->seid, in i40e_veb_config_tc()
6764 dev_info(&pf->pdev->dev, in i40e_veb_config_tc()
6767 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_veb_config_tc()
6774 dev_info(&pf->pdev->dev, in i40e_veb_config_tc()
6777 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_veb_config_tc()
6787 * @pf: PF struct
6789 * Reconfigure VEB/VSIs on a given PF; it is assumed that
6793 static void i40e_dcb_reconfigure(struct i40e_pf *pf) in i40e_dcb_reconfigure() argument
6801 /* Enable the TCs available on PF to all VEBs */ in i40e_dcb_reconfigure()
6802 tc_map = i40e_pf_get_tc_map(pf); in i40e_dcb_reconfigure()
6806 i40e_pf_for_each_veb(pf, v, veb) { in i40e_dcb_reconfigure()
6809 dev_info(&pf->pdev->dev, in i40e_dcb_reconfigure()
6817 i40e_pf_for_each_vsi(pf, v, vsi) { in i40e_dcb_reconfigure()
6822 tc_map = i40e_pf_get_tc_map(pf); in i40e_dcb_reconfigure()
6828 dev_info(&pf->pdev->dev, in i40e_dcb_reconfigure()
6843 * @pf: PF struct
6845 * Resume a port's Tx and issue a PF reset in case of failure to
6848 static int i40e_resume_port_tx(struct i40e_pf *pf) in i40e_resume_port_tx() argument
6850 struct i40e_hw *hw = &pf->hw; in i40e_resume_port_tx()
6855 dev_info(&pf->pdev->dev, in i40e_resume_port_tx()
6858 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_resume_port_tx()
6859 /* Schedule PF reset to recover */ in i40e_resume_port_tx()
6860 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_resume_port_tx()
6861 i40e_service_event_schedule(pf); in i40e_resume_port_tx()
6869 * @pf: PF struct
6871 * Suspend a port's Tx and issue a PF reset in case of failure.
6873 static int i40e_suspend_port_tx(struct i40e_pf *pf) in i40e_suspend_port_tx() argument
6875 struct i40e_hw *hw = &pf->hw; in i40e_suspend_port_tx()
6878 ret = i40e_aq_suspend_port_tx(hw, pf->mac_seid, NULL); in i40e_suspend_port_tx()
6880 dev_info(&pf->pdev->dev, in i40e_suspend_port_tx()
6883 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_suspend_port_tx()
6884 /* Schedule PF reset to recover */ in i40e_suspend_port_tx()
6885 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_suspend_port_tx()
6886 i40e_service_event_schedule(pf); in i40e_suspend_port_tx()
6894 * @pf: PF being configured
6898 * given PF. Uses "Set LLDP MIB" AQC to program the hardware.
6900 static int i40e_hw_set_dcb_config(struct i40e_pf *pf, in i40e_hw_set_dcb_config() argument
6903 struct i40e_dcbx_config *old_cfg = &pf->hw.local_dcbx_config; in i40e_hw_set_dcb_config()
6908 dev_dbg(&pf->pdev->dev, "No Change in DCB Config required.\n"); in i40e_hw_set_dcb_config()
6913 i40e_pf_quiesce_all_vsi(pf); in i40e_hw_set_dcb_config()
6918 ret = i40e_set_dcb_config(&pf->hw); in i40e_hw_set_dcb_config()
6920 dev_info(&pf->pdev->dev, in i40e_hw_set_dcb_config()
6923 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_hw_set_dcb_config()
6928 i40e_dcb_reconfigure(pf); in i40e_hw_set_dcb_config()
6931 if (!test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) { in i40e_hw_set_dcb_config()
6933 ret = i40e_resume_port_tx(pf); in i40e_hw_set_dcb_config()
6937 i40e_pf_unquiesce_all_vsi(pf); in i40e_hw_set_dcb_config()
6945 * @pf: PF being configured
6949 * given PF
6951 int i40e_hw_dcb_config(struct i40e_pf *pf, struct i40e_dcbx_config *new_cfg) in i40e_hw_dcb_config() argument
6959 struct i40e_hw *hw = &pf->hw; in i40e_hw_dcb_config()
6968 dev_dbg(&pf->pdev->dev, "Configuring DCB registers directly\n"); in i40e_hw_dcb_config()
7010 need_reconfig = i40e_dcb_need_reconfig(pf, old_cfg, new_cfg); in i40e_hw_dcb_config()
7018 set_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_hw_dcb_config()
7020 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_hw_dcb_config()
7022 set_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_hw_dcb_config()
7024 i40e_pf_quiesce_all_vsi(pf); in i40e_hw_dcb_config()
7025 ret = i40e_suspend_port_tx(pf); in i40e_hw_dcb_config()
7034 (hw, pf->mac_seid, &ets_data, in i40e_hw_dcb_config()
7037 dev_info(&pf->pdev->dev, in i40e_hw_dcb_config()
7040 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_hw_dcb_config()
7060 struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); in i40e_hw_dcb_config()
7069 i40e_dcb_hw_rx_pb_config(hw, &pf->pb_cfg, &pb_cfg); in i40e_hw_dcb_config()
7072 pf->pb_cfg = pb_cfg; in i40e_hw_dcb_config()
7075 ret = i40e_aq_dcb_updated(&pf->hw, NULL); in i40e_hw_dcb_config()
7077 dev_info(&pf->pdev->dev, in i40e_hw_dcb_config()
7080 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_hw_dcb_config()
7088 i40e_dcb_reconfigure(pf); in i40e_hw_dcb_config()
7092 ret = i40e_resume_port_tx(pf); in i40e_hw_dcb_config()
7094 clear_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_hw_dcb_config()
7099 /* Wait for the PF's queues to be disabled */ in i40e_hw_dcb_config()
7100 ret = i40e_pf_wait_queues_disabled(pf); in i40e_hw_dcb_config()
7102 /* Schedule PF reset to recover */ in i40e_hw_dcb_config()
7103 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_hw_dcb_config()
7104 i40e_service_event_schedule(pf); in i40e_hw_dcb_config()
7107 i40e_pf_unquiesce_all_vsi(pf); in i40e_hw_dcb_config()
7108 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_hw_dcb_config()
7109 set_bit(__I40E_CLIENT_L2_CHANGE, pf->state); in i40e_hw_dcb_config()
7112 if (test_bit(I40E_HW_CAP_USE_SET_LLDP_MIB, pf->hw.caps)) in i40e_hw_dcb_config()
7113 ret = i40e_hw_set_dcb_config(pf, new_cfg); in i40e_hw_dcb_config()
7122 * @pf: PF being queried
7126 int i40e_dcb_sw_default_config(struct i40e_pf *pf) in i40e_dcb_sw_default_config() argument
7128 struct i40e_dcbx_config *dcb_cfg = &pf->hw.local_dcbx_config; in i40e_dcb_sw_default_config()
7130 struct i40e_hw *hw = &pf->hw; in i40e_dcb_sw_default_config()
7133 if (test_bit(I40E_HW_CAP_USE_SET_LLDP_MIB, pf->hw.caps)) { in i40e_dcb_sw_default_config()
7135 memset(&pf->tmp_cfg, 0, sizeof(struct i40e_dcbx_config)); in i40e_dcb_sw_default_config()
7136 pf->tmp_cfg.etscfg.willing = I40E_IEEE_DEFAULT_ETS_WILLING; in i40e_dcb_sw_default_config()
7137 pf->tmp_cfg.etscfg.maxtcs = 0; in i40e_dcb_sw_default_config()
7138 pf->tmp_cfg.etscfg.tcbwtable[0] = I40E_IEEE_DEFAULT_ETS_TCBW; in i40e_dcb_sw_default_config()
7139 pf->tmp_cfg.etscfg.tsatable[0] = I40E_IEEE_TSA_ETS; in i40e_dcb_sw_default_config()
7140 pf->tmp_cfg.pfc.willing = I40E_IEEE_DEFAULT_PFC_WILLING; in i40e_dcb_sw_default_config()
7141 pf->tmp_cfg.pfc.pfccap = I40E_MAX_TRAFFIC_CLASS; in i40e_dcb_sw_default_config()
7143 pf->tmp_cfg.numapps = I40E_IEEE_DEFAULT_NUM_APPS; in i40e_dcb_sw_default_config()
7144 pf->tmp_cfg.app[0].selector = I40E_APP_SEL_ETHTYPE; in i40e_dcb_sw_default_config()
7145 pf->tmp_cfg.app[0].priority = I40E_IEEE_DEFAULT_APP_PRIO; in i40e_dcb_sw_default_config()
7146 pf->tmp_cfg.app[0].protocolid = I40E_APP_PROTOID_FCOE; in i40e_dcb_sw_default_config()
7148 return i40e_hw_set_dcb_config(pf, &pf->tmp_cfg); in i40e_dcb_sw_default_config()
7158 (hw, pf->mac_seid, &ets_data, in i40e_dcb_sw_default_config()
7161 dev_info(&pf->pdev->dev, in i40e_dcb_sw_default_config()
7164 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_dcb_sw_default_config()
7181 * @pf: PF being configured
7186 static int i40e_init_pf_dcb(struct i40e_pf *pf) in i40e_init_pf_dcb() argument
7188 struct i40e_hw *hw = &pf->hw; in i40e_init_pf_dcb()
7194 if (test_bit(I40E_HW_CAP_NO_DCB_SUPPORT, pf->hw.caps)) { in i40e_init_pf_dcb()
7195 dev_info(&pf->pdev->dev, "DCB is not supported.\n"); in i40e_init_pf_dcb()
7199 if (test_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags)) { in i40e_init_pf_dcb()
7200 dev_info(&pf->pdev->dev, "FW LLDP is disabled, attempting SW DCB\n"); in i40e_init_pf_dcb()
7201 err = i40e_dcb_sw_default_config(pf); in i40e_init_pf_dcb()
7203 dev_info(&pf->pdev->dev, "Could not initialize SW DCB\n"); in i40e_init_pf_dcb()
7206 dev_info(&pf->pdev->dev, "SW DCB initialization succeeded.\n"); in i40e_init_pf_dcb()
7207 pf->dcbx_cap = DCB_CAP_DCBX_HOST | in i40e_init_pf_dcb()
7210 set_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_init_pf_dcb()
7211 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_init_pf_dcb()
7219 dev_info(&pf->pdev->dev, in i40e_init_pf_dcb()
7220 "DCBX offload is not supported or is disabled for this PF.\n"); in i40e_init_pf_dcb()
7223 pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED | in i40e_init_pf_dcb()
7226 set_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_init_pf_dcb()
7231 set_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_init_pf_dcb()
7233 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_init_pf_dcb()
7234 dev_dbg(&pf->pdev->dev, in i40e_init_pf_dcb()
7235 "DCBX offload is supported for this PF.\n"); in i40e_init_pf_dcb()
7237 } else if (pf->hw.aq.asq_last_status == I40E_AQ_RC_EPERM) { in i40e_init_pf_dcb()
7238 dev_info(&pf->pdev->dev, "FW LLDP disabled for this PF.\n"); in i40e_init_pf_dcb()
7239 set_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags); in i40e_init_pf_dcb()
7241 dev_info(&pf->pdev->dev, in i40e_init_pf_dcb()
7244 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_init_pf_dcb()
7280 struct i40e_pf *pf = vsi->back; in i40e_print_link_message() local
7288 new_speed = pf->hw.phy.link_info.link_speed; in i40e_print_link_message()
7304 if (pf->hw.func_caps.npar_enable && in i40e_print_link_message()
7305 (pf->hw.phy.link_info.link_speed == I40E_LINK_SPEED_1GB || in i40e_print_link_message()
7306 pf->hw.phy.link_info.link_speed == I40E_LINK_SPEED_100MB)) in i40e_print_link_message()
7310 switch (pf->hw.phy.link_info.link_speed) { in i40e_print_link_message()
7339 switch (pf->hw.fc.current_mode) { in i40e_print_link_message()
7354 if (pf->hw.phy.link_info.link_speed == I40E_LINK_SPEED_25GB) { in i40e_print_link_message()
7359 if (pf->hw.phy.link_info.an_info & I40E_AQ_AN_COMPLETED) in i40e_print_link_message()
7362 if (pf->hw.phy.link_info.fec_info & in i40e_print_link_message()
7365 else if (pf->hw.phy.link_info.fec_info & in i40e_print_link_message()
7383 } else if (pf->hw.device_id == I40E_DEV_ID_KX_X722) { in i40e_print_link_message()
7388 if (pf->hw.phy.link_info.an_info & I40E_AQ_AN_COMPLETED) in i40e_print_link_message()
7391 if (pf->hw.phy.link_info.fec_info & in i40e_print_link_message()
7395 if (pf->hw.phy.link_info.req_fec_info & in i40e_print_link_message()
7414 struct i40e_pf *pf = vsi->back; in i40e_up_complete() local
7417 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_up_complete()
7431 if ((pf->hw.phy.link_info.link_info & I40E_AQ_LINK_UP) && in i40e_up_complete()
7441 pf->fd_add_err = 0; in i40e_up_complete()
7442 pf->fd_atr_cnt = 0; in i40e_up_complete()
7449 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_up_complete()
7450 i40e_service_event_schedule(pf); in i40e_up_complete()
7464 struct i40e_pf *pf = vsi->back; in i40e_vsi_reinit_locked() local
7466 while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) in i40e_vsi_reinit_locked()
7471 clear_bit(__I40E_CONFIG_BUSY, pf->state); in i40e_vsi_reinit_locked()
7476 * @pf: board private structure
7479 static int i40e_force_link_state(struct i40e_pf *pf, bool is_up) in i40e_force_link_state() argument
7484 struct i40e_hw *hw = &pf->hw; in i40e_force_link_state()
7498 dev_err(&pf->pdev->dev, in i40e_force_link_state()
7510 dev_err(&pf->pdev->dev, in i40e_force_link_state()
7521 if (test_bit(I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags)) in i40e_force_link_state()
7537 if (test_bit(I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags)) { in i40e_force_link_state()
7555 dev_err(&pf->pdev->dev, in i40e_force_link_state()
7558 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_force_link_state()
7843 struct i40e_pf *pf = vsi->back; in i40e_fwd_ring_up() local
7844 struct i40e_hw *hw = &pf->hw; in i40e_fwd_ring_up()
7896 dev_info(&pf->pdev->dev, in i40e_fwd_ring_up()
7916 struct i40e_pf *pf = vsi->back; in i40e_setup_macvlans() local
7917 struct i40e_hw *hw = &pf->hw; in i40e_setup_macvlans()
7953 dev_info(&pf->pdev->dev, in i40e_setup_macvlans()
7969 dev_info(&pf->pdev->dev, in i40e_setup_macvlans()
7989 if (!i40e_setup_channel(pf, vsi, ch)) { in i40e_setup_macvlans()
8003 dev_info(&pf->pdev->dev, "Failed to setup macvlans\n"); in i40e_setup_macvlans()
8019 struct i40e_pf *pf = vsi->back; in i40e_fwd_add() local
8023 if (test_bit(I40E_FLAG_DCB_ENA, pf->flags)) { in i40e_fwd_add()
8027 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_fwd_add()
8031 if (pf->num_lan_msix < I40E_MIN_MACVLAN_VECTORS) { in i40e_fwd_add()
8043 /* reserve bit 0 for the pf device */ in i40e_fwd_add()
8050 vectors = pf->num_lan_msix; in i40e_fwd_add()
8052 /* allocate 4 Qs per macvlan and 32 Qs to the PF*/ in i40e_fwd_add()
8056 /* allocate 2 Qs per macvlan and 16 Qs to the PF*/ in i40e_fwd_add()
8060 /* allocate 1 Q per macvlan and 16 Qs to the PF*/ in i40e_fwd_add()
8064 /* allocate 1 Q per macvlan and 8 Qs to the PF */ in i40e_fwd_add()
8068 /* allocate 1 Q per macvlan and 1 Q to the PF */ in i40e_fwd_add()
8127 struct i40e_pf *pf = vsi->back; in i40e_del_all_macvlans() local
8128 struct i40e_hw *hw = &pf->hw; in i40e_del_all_macvlans()
8164 struct i40e_pf *pf = vsi->back; in i40e_fwd_del() local
8165 struct i40e_hw *hw = &pf->hw; in i40e_fwd_del()
8185 dev_info(&pf->pdev->dev, in i40e_fwd_del()
8205 struct i40e_pf *pf = vsi->back; in i40e_setup_tc() local
8218 clear_bit(I40E_FLAG_TC_MQPRIO_ENA, pf->flags); in i40e_setup_tc()
8224 if (test_bit(I40E_FLAG_MFP_ENA, pf->flags)) { in i40e_setup_tc()
8231 clear_bit(I40E_FLAG_TC_MQPRIO_ENA, pf->flags); in i40e_setup_tc()
8234 if (!test_bit(I40E_FLAG_DCB_ENA, pf->flags)) { in i40e_setup_tc()
8241 if (num_tc > i40e_pf_get_num_tc(pf)) { in i40e_setup_tc()
8248 if (test_bit(I40E_FLAG_DCB_ENA, pf->flags)) { in i40e_setup_tc()
8253 if (!test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_setup_tc()
8260 set_bit(I40E_FLAG_TC_MQPRIO_ENA, pf->flags); in i40e_setup_tc()
8261 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_setup_tc()
8280 if (!hw && !i40e_is_tc_mqprio_enabled(pf)) in i40e_setup_tc()
8304 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_setup_tc()
8402 struct i40e_pf *pf = vsi->back; in i40e_add_del_cloud_filter() local
8441 ret = i40e_aq_add_cloud_filters(&pf->hw, filter->seid, in i40e_add_del_cloud_filter()
8444 ret = i40e_aq_rem_cloud_filters(&pf->hw, filter->seid, in i40e_add_del_cloud_filter()
8447 dev_dbg(&pf->pdev->dev, in i40e_add_del_cloud_filter()
8450 pf->hw.aq.asq_last_status); in i40e_add_del_cloud_filter()
8452 dev_info(&pf->pdev->dev, in i40e_add_del_cloud_filter()
8472 struct i40e_pf *pf = vsi->back; in i40e_add_del_cloud_filter_big_buf() local
8530 dev_err(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8543 dev_err(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8549 ret = i40e_aq_add_cloud_filters_bb(&pf->hw, filter->seid, in i40e_add_del_cloud_filter_big_buf()
8552 ret = i40e_aq_rem_cloud_filters_bb(&pf->hw, filter->seid, in i40e_add_del_cloud_filter_big_buf()
8557 dev_dbg(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8559 add ? "add" : "delete", ret, pf->hw.aq.asq_last_status); in i40e_add_del_cloud_filter_big_buf()
8561 dev_info(&pf->pdev->dev, in i40e_add_del_cloud_filter_big_buf()
8582 struct i40e_pf *pf = vsi->back; in i40e_parse_cls_flower() local
8594 dev_err(&pf->pdev->dev, "Unsupported key used: 0x%llx\n", in i40e_parse_cls_flower()
8634 dev_err(&pf->pdev->dev, "Bad ether dest mask %pM\n", in i40e_parse_cls_flower()
8644 dev_err(&pf->pdev->dev, "Bad ether src mask %pM\n", in i40e_parse_cls_flower()
8662 dev_err(&pf->pdev->dev, "Bad vlan mask 0x%04x\n", in i40e_parse_cls_flower()
8690 dev_err(&pf->pdev->dev, "Bad ip dst mask %pI4b\n", in i40e_parse_cls_flower()
8700 dev_err(&pf->pdev->dev, "Bad ip src mask %pI4b\n", in i40e_parse_cls_flower()
8707 dev_err(&pf->pdev->dev, "Tenant id not allowed for ip filter\n"); in i40e_parse_cls_flower()
8724 dev_err(&pf->pdev->dev, in i40e_parse_cls_flower()
8746 dev_err(&pf->pdev->dev, "Bad src port mask 0x%04x\n", in i40e_parse_cls_flower()
8756 dev_err(&pf->pdev->dev, "Bad dst port mask 0x%04x\n", in i40e_parse_cls_flower()
8770 dev_err(&pf->pdev->dev, in i40e_parse_cls_flower()
8825 struct i40e_pf *pf = vsi->back; in i40e_configure_clsflower() local
8834 dev_err(&pf->pdev->dev, "Unable to add filter because of invalid destination"); in i40e_configure_clsflower()
8838 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_configure_clsflower()
8839 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) in i40e_configure_clsflower()
8842 if (pf->fdir_pf_active_filters || in i40e_configure_clsflower()
8843 (!hlist_empty(&pf->fdir_filter_list))) { in i40e_configure_clsflower()
8877 dev_err(&pf->pdev->dev, "Failed to add cloud filter, err %d\n", in i40e_configure_clsflower()
8885 hlist_add_head(&filter->cloud_node, &pf->cloud_filter_list); in i40e_configure_clsflower()
8887 pf->num_cloud_filters++; in i40e_configure_clsflower()
8924 struct i40e_pf *pf = vsi->back; in i40e_delete_clsflower() local
8941 dev_err(&pf->pdev->dev, in i40e_delete_clsflower()
8944 return i40e_aq_rc_to_posix(err, pf->hw.aq.asq_last_status); in i40e_delete_clsflower()
8947 pf->num_cloud_filters--; in i40e_delete_clsflower()
8948 if (!pf->num_cloud_filters) in i40e_delete_clsflower()
8949 if (test_bit(I40E_FLAG_FD_SB_TO_CLOUD_FILTER, pf->flags) && in i40e_delete_clsflower()
8950 !test_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags)) { in i40e_delete_clsflower()
8951 set_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_delete_clsflower()
8952 clear_bit(I40E_FLAG_FD_SB_TO_CLOUD_FILTER, pf->flags); in i40e_delete_clsflower()
8953 clear_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_delete_clsflower()
9033 struct i40e_pf *pf = vsi->back; in i40e_open() local
9037 if (test_bit(__I40E_TESTING, pf->state) || in i40e_open()
9038 test_bit(__I40E_BAD_EEPROM, pf->state)) in i40e_open()
9043 if (i40e_force_link_state(pf, true)) in i40e_open()
9051 wr32(&pf->hw, I40E_GLLAN_TSOMSK_F, be32_to_cpu(TCP_FLAG_PSH | in i40e_open()
9053 wr32(&pf->hw, I40E_GLLAN_TSOMSK_M, be32_to_cpu(TCP_FLAG_PSH | in i40e_open()
9056 wr32(&pf->hw, I40E_GLLAN_TSOMSK_L, be32_to_cpu(TCP_FLAG_CWR) >> 16); in i40e_open()
9095 struct i40e_pf *pf = vsi->back; in i40e_vsi_open() local
9113 dev_driver_string(&pf->pdev->dev), vsi->netdev->name); in i40e_vsi_open()
9125 dev_driver_string(&pf->pdev->dev), in i40e_vsi_open()
9126 dev_name(&pf->pdev->dev)); in i40e_vsi_open()
9151 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_vsi_open()
9158 * @pf: Pointer to PF
9163 static void i40e_fdir_filter_exit(struct i40e_pf *pf) in i40e_fdir_filter_exit() argument
9170 &pf->fdir_filter_list, fdir_node) { in i40e_fdir_filter_exit()
9175 list_for_each_entry_safe(pit_entry, tmp, &pf->l3_flex_pit_list, list) { in i40e_fdir_filter_exit()
9179 INIT_LIST_HEAD(&pf->l3_flex_pit_list); in i40e_fdir_filter_exit()
9181 list_for_each_entry_safe(pit_entry, tmp, &pf->l4_flex_pit_list, list) { in i40e_fdir_filter_exit()
9185 INIT_LIST_HEAD(&pf->l4_flex_pit_list); in i40e_fdir_filter_exit()
9187 pf->fdir_pf_active_filters = 0; in i40e_fdir_filter_exit()
9188 i40e_reset_fdir_filter_cnt(pf); in i40e_fdir_filter_exit()
9191 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_TCP, in i40e_fdir_filter_exit()
9196 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV6_TCP, in i40e_fdir_filter_exit()
9201 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_UDP, in i40e_fdir_filter_exit()
9206 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV6_UDP, in i40e_fdir_filter_exit()
9211 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_SCTP, in i40e_fdir_filter_exit()
9216 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV6_SCTP, in i40e_fdir_filter_exit()
9221 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_OTHER, in i40e_fdir_filter_exit()
9224 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_FRAG_IPV4, in i40e_fdir_filter_exit()
9228 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV6_OTHER, in i40e_fdir_filter_exit()
9231 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_FRAG_IPV6, in i40e_fdir_filter_exit()
9237 * @pf: Pointer to PF
9242 static void i40e_cloud_filter_exit(struct i40e_pf *pf) in i40e_cloud_filter_exit() argument
9248 &pf->cloud_filter_list, cloud_node) { in i40e_cloud_filter_exit()
9252 pf->num_cloud_filters = 0; in i40e_cloud_filter_exit()
9254 if (test_bit(I40E_FLAG_FD_SB_TO_CLOUD_FILTER, pf->flags) && in i40e_cloud_filter_exit()
9255 !test_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags)) { in i40e_cloud_filter_exit()
9256 set_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_cloud_filter_exit()
9257 clear_bit(I40E_FLAG_FD_SB_TO_CLOUD_FILTER, pf->flags); in i40e_cloud_filter_exit()
9258 clear_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_cloud_filter_exit()
9283 * i40e_do_reset - Start a PF or Core Reset sequence
9284 * @pf: board private structure
9289 * The essential difference in resets is that the PF Reset
9293 void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired) in i40e_do_reset() argument
9310 dev_dbg(&pf->pdev->dev, "GlobalR requested\n"); in i40e_do_reset()
9311 val = rd32(&pf->hw, I40E_GLGEN_RTRIG); in i40e_do_reset()
9313 wr32(&pf->hw, I40E_GLGEN_RTRIG, val); in i40e_do_reset()
9321 dev_dbg(&pf->pdev->dev, "CoreR requested\n"); in i40e_do_reset()
9322 val = rd32(&pf->hw, I40E_GLGEN_RTRIG); in i40e_do_reset()
9324 wr32(&pf->hw, I40E_GLGEN_RTRIG, val); in i40e_do_reset()
9325 i40e_flush(&pf->hw); in i40e_do_reset()
9329 /* Request a PF Reset in i40e_do_reset()
9331 * Resets only the PF-specific registers in i40e_do_reset()
9337 dev_dbg(&pf->pdev->dev, "PFR requested\n"); in i40e_do_reset()
9338 i40e_handle_reset_warning(pf, lock_acquired); in i40e_do_reset()
9341 /* Request a PF Reset in i40e_do_reset()
9343 * Resets PF and reinitializes PFs VSI. in i40e_do_reset()
9345 i40e_prep_for_reset(pf); in i40e_do_reset()
9346 i40e_reset_and_rebuild(pf, true, lock_acquired); in i40e_do_reset()
9347 dev_info(&pf->pdev->dev, in i40e_do_reset()
9348 test_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags) ? in i40e_do_reset()
9354 dev_info(&pf->pdev->dev, "VSI reinit requested\n"); in i40e_do_reset()
9356 i40e_pf_for_each_vsi(pf, i, vsi) { in i40e_do_reset()
9363 dev_info(&pf->pdev->dev, "VSI down requested\n"); in i40e_do_reset()
9365 i40e_pf_for_each_vsi(pf, i, vsi) { in i40e_do_reset()
9373 dev_info(&pf->pdev->dev, in i40e_do_reset()
9381 * @pf: board private structure
9385 bool i40e_dcb_need_reconfig(struct i40e_pf *pf, in i40e_dcb_need_reconfig() argument
9400 dev_dbg(&pf->pdev->dev, "ETS UP2TC changed.\n"); in i40e_dcb_need_reconfig()
9406 dev_dbg(&pf->pdev->dev, "ETS TC BW Table changed.\n"); in i40e_dcb_need_reconfig()
9411 dev_dbg(&pf->pdev->dev, "ETS TSA Table changed.\n"); in i40e_dcb_need_reconfig()
9419 dev_dbg(&pf->pdev->dev, "PFC config change detected.\n"); in i40e_dcb_need_reconfig()
9427 dev_dbg(&pf->pdev->dev, "APP Table change detected.\n"); in i40e_dcb_need_reconfig()
9430 dev_dbg(&pf->pdev->dev, "dcb need_reconfig=%d\n", need_reconfig); in i40e_dcb_need_reconfig()
9436 * @pf: board private structure
9439 static int i40e_handle_lldp_event(struct i40e_pf *pf, in i40e_handle_lldp_event() argument
9444 struct i40e_hw *hw = &pf->hw; in i40e_handle_lldp_event()
9454 !test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags)) in i40e_handle_lldp_event()
9456 set_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_handle_lldp_event()
9459 if (!test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags)) in i40e_handle_lldp_event()
9465 dev_dbg(&pf->pdev->dev, "LLDP event mib bridge type 0x%x\n", type); in i40e_handle_lldp_event()
9471 dev_dbg(&pf->pdev->dev, in i40e_handle_lldp_event()
9487 ret = i40e_get_dcb_config(&pf->hw); in i40e_handle_lldp_event()
9493 dev_warn(&pf->pdev->dev, in i40e_handle_lldp_event()
9495 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_handle_lldp_event()
9497 dev_info(&pf->pdev->dev, in i40e_handle_lldp_event()
9500 i40e_aq_str(&pf->hw, in i40e_handle_lldp_event()
9501 pf->hw.aq.asq_last_status)); in i40e_handle_lldp_event()
9509 dev_dbg(&pf->pdev->dev, "No change detected in DCBX configuration.\n"); in i40e_handle_lldp_event()
9513 need_reconfig = i40e_dcb_need_reconfig(pf, &tmp_dcbx_cfg, in i40e_handle_lldp_event()
9516 i40e_dcbnl_flush_apps(pf, &tmp_dcbx_cfg, &hw->local_dcbx_config); in i40e_handle_lldp_event()
9523 set_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_handle_lldp_event()
9525 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_handle_lldp_event()
9527 set_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_handle_lldp_event()
9529 i40e_pf_quiesce_all_vsi(pf); in i40e_handle_lldp_event()
9532 i40e_dcb_reconfigure(pf); in i40e_handle_lldp_event()
9534 ret = i40e_resume_port_tx(pf); in i40e_handle_lldp_event()
9536 clear_bit(__I40E_PORT_SUSPENDED, pf->state); in i40e_handle_lldp_event()
9541 /* Wait for the PF's queues to be disabled */ in i40e_handle_lldp_event()
9542 ret = i40e_pf_wait_queues_disabled(pf); in i40e_handle_lldp_event()
9544 /* Schedule PF reset to recover */ in i40e_handle_lldp_event()
9545 set_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_handle_lldp_event()
9546 i40e_service_event_schedule(pf); in i40e_handle_lldp_event()
9548 i40e_pf_unquiesce_all_vsi(pf); in i40e_handle_lldp_event()
9549 set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state); in i40e_handle_lldp_event()
9550 set_bit(__I40E_CLIENT_L2_CHANGE, pf->state); in i40e_handle_lldp_event()
9560 * @pf: board private structure
9564 void i40e_do_reset_safe(struct i40e_pf *pf, u32 reset_flags) in i40e_do_reset_safe() argument
9567 i40e_do_reset(pf, reset_flags, true); in i40e_do_reset_safe()
9573 * @pf: board private structure
9576 * Handler for LAN Queue Overflow Event generated by the firmware for PF
9579 static void i40e_handle_lan_overflow_event(struct i40e_pf *pf, in i40e_handle_lan_overflow_event() argument
9586 struct i40e_hw *hw = &pf->hw; in i40e_handle_lan_overflow_event()
9590 dev_dbg(&pf->pdev->dev, "overflow Rx Queue Number = %d QTX_CTL=0x%08x\n", in i40e_handle_lan_overflow_event()
9600 vf = &pf->vf[vf_id]; in i40e_handle_lan_overflow_event()
9608 * i40e_get_current_fd_count - Get total FD filters programmed for this PF
9609 * @pf: board private structure
9611 u32 i40e_get_current_fd_count(struct i40e_pf *pf) in i40e_get_current_fd_count() argument
9615 val = rd32(&pf->hw, I40E_PFQF_FDSTAT); in i40e_get_current_fd_count()
9623 * @pf: board private structure
9625 u32 i40e_get_global_fd_count(struct i40e_pf *pf) in i40e_get_global_fd_count() argument
9629 val = rd32(&pf->hw, I40E_GLQF_FDCNT_0); in i40e_get_global_fd_count()
9637 * @pf: board private structure
9639 static void i40e_reenable_fdir_sb(struct i40e_pf *pf) in i40e_reenable_fdir_sb() argument
9641 if (test_and_clear_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state)) in i40e_reenable_fdir_sb()
9642 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) && in i40e_reenable_fdir_sb()
9643 (I40E_DEBUG_FD & pf->hw.debug_mask)) in i40e_reenable_fdir_sb()
9644 …dev_info(&pf->pdev->dev, "FD Sideband/ntuple is being enabled since we have space in the table now… in i40e_reenable_fdir_sb()
9649 * @pf: board private structure
9651 static void i40e_reenable_fdir_atr(struct i40e_pf *pf) in i40e_reenable_fdir_atr() argument
9653 if (test_and_clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state)) { in i40e_reenable_fdir_atr()
9659 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_TCP, in i40e_reenable_fdir_atr()
9663 if (test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags) && in i40e_reenable_fdir_atr()
9664 (I40E_DEBUG_FD & pf->hw.debug_mask)) in i40e_reenable_fdir_atr()
9665 …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()
9671 * @pf: board private structure
9674 static void i40e_delete_invalid_filter(struct i40e_pf *pf, in i40e_delete_invalid_filter() argument
9678 pf->fdir_pf_active_filters--; in i40e_delete_invalid_filter()
9679 pf->fd_inv = 0; in i40e_delete_invalid_filter()
9683 pf->fd_tcp4_filter_cnt--; in i40e_delete_invalid_filter()
9686 pf->fd_udp4_filter_cnt--; in i40e_delete_invalid_filter()
9689 pf->fd_sctp4_filter_cnt--; in i40e_delete_invalid_filter()
9692 pf->fd_tcp6_filter_cnt--; in i40e_delete_invalid_filter()
9695 pf->fd_udp6_filter_cnt--; in i40e_delete_invalid_filter()
9698 pf->fd_udp6_filter_cnt--; in i40e_delete_invalid_filter()
9703 pf->fd_tcp4_filter_cnt--; in i40e_delete_invalid_filter()
9706 pf->fd_udp4_filter_cnt--; in i40e_delete_invalid_filter()
9709 pf->fd_sctp4_filter_cnt--; in i40e_delete_invalid_filter()
9712 pf->fd_ip4_filter_cnt--; in i40e_delete_invalid_filter()
9719 pf->fd_tcp6_filter_cnt--; in i40e_delete_invalid_filter()
9722 pf->fd_udp6_filter_cnt--; in i40e_delete_invalid_filter()
9725 pf->fd_sctp6_filter_cnt--; in i40e_delete_invalid_filter()
9728 pf->fd_ip6_filter_cnt--; in i40e_delete_invalid_filter()
9741 * @pf: board private structure
9743 void i40e_fdir_check_and_reenable(struct i40e_pf *pf) in i40e_fdir_check_and_reenable() argument
9749 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_fdir_check_and_reenable()
9753 fcnt_prog = i40e_get_global_fd_count(pf); in i40e_fdir_check_and_reenable()
9754 fcnt_avail = pf->fdir_pf_filter_count; in i40e_fdir_check_and_reenable()
9756 (pf->fd_add_err == 0) || in i40e_fdir_check_and_reenable()
9757 (i40e_get_current_atr_cnt(pf) < pf->fd_atr_cnt)) in i40e_fdir_check_and_reenable()
9758 i40e_reenable_fdir_sb(pf); in i40e_fdir_check_and_reenable()
9765 pf->fd_tcp4_filter_cnt == 0 && pf->fd_tcp6_filter_cnt == 0) in i40e_fdir_check_and_reenable()
9766 i40e_reenable_fdir_atr(pf); in i40e_fdir_check_and_reenable()
9769 if (pf->fd_inv > 0) { in i40e_fdir_check_and_reenable()
9771 &pf->fdir_filter_list, fdir_node) in i40e_fdir_check_and_reenable()
9772 if (filter->fd_id == pf->fd_inv) in i40e_fdir_check_and_reenable()
9773 i40e_delete_invalid_filter(pf, filter); in i40e_fdir_check_and_reenable()
9781 * @pf: board private structure
9783 static void i40e_fdir_flush_and_replay(struct i40e_pf *pf) in i40e_fdir_flush_and_replay() argument
9791 if (!time_after(jiffies, pf->fd_flush_timestamp + in i40e_fdir_flush_and_replay()
9798 min_flush_time = pf->fd_flush_timestamp + in i40e_fdir_flush_and_replay()
9800 fd_room = pf->fdir_pf_filter_count - pf->fdir_pf_active_filters; in i40e_fdir_flush_and_replay()
9804 if (I40E_DEBUG_FD & pf->hw.debug_mask) in i40e_fdir_flush_and_replay()
9805 dev_info(&pf->pdev->dev, "ATR disabled, not enough FD filter space.\n"); in i40e_fdir_flush_and_replay()
9809 pf->fd_flush_timestamp = jiffies; in i40e_fdir_flush_and_replay()
9810 set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state); in i40e_fdir_flush_and_replay()
9812 wr32(&pf->hw, I40E_PFQF_CTL_1, in i40e_fdir_flush_and_replay()
9814 i40e_flush(&pf->hw); in i40e_fdir_flush_and_replay()
9815 pf->fd_flush_cnt++; in i40e_fdir_flush_and_replay()
9816 pf->fd_add_err = 0; in i40e_fdir_flush_and_replay()
9820 reg = rd32(&pf->hw, I40E_PFQF_CTL_1); in i40e_fdir_flush_and_replay()
9825 dev_warn(&pf->pdev->dev, "FD table did not flush, needs more time\n"); in i40e_fdir_flush_and_replay()
9828 i40e_fdir_filter_restore(i40e_pf_get_main_vsi(pf)); in i40e_fdir_flush_and_replay()
9829 if (!disable_atr && !pf->fd_tcp4_filter_cnt) in i40e_fdir_flush_and_replay()
9830 clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state); in i40e_fdir_flush_and_replay()
9831 clear_bit(__I40E_FD_FLUSH_REQUESTED, pf->state); in i40e_fdir_flush_and_replay()
9832 if (I40E_DEBUG_FD & pf->hw.debug_mask) in i40e_fdir_flush_and_replay()
9833 dev_info(&pf->pdev->dev, "FD Filter table flushed and FD-SB replayed.\n"); in i40e_fdir_flush_and_replay()
9839 * @pf: board private structure
9841 u32 i40e_get_current_atr_cnt(struct i40e_pf *pf) in i40e_get_current_atr_cnt() argument
9843 return i40e_get_current_fd_count(pf) - pf->fdir_pf_active_filters; in i40e_get_current_atr_cnt()
9848 * @pf: board private structure
9850 static void i40e_fdir_reinit_subtask(struct i40e_pf *pf) in i40e_fdir_reinit_subtask() argument
9854 if (test_bit(__I40E_DOWN, pf->state)) in i40e_fdir_reinit_subtask()
9857 if (test_bit(__I40E_FD_FLUSH_REQUESTED, pf->state)) in i40e_fdir_reinit_subtask()
9858 i40e_fdir_flush_and_replay(pf); in i40e_fdir_reinit_subtask()
9860 i40e_fdir_check_and_reenable(pf); in i40e_fdir_reinit_subtask()
9907 struct i40e_pf *pf; in i40e_veb_link_event() local
9910 if (!veb || !veb->pf) in i40e_veb_link_event()
9912 pf = veb->pf; in i40e_veb_link_event()
9915 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_veb_link_event()
9922 * @pf: board private structure
9924 static void i40e_link_event(struct i40e_pf *pf) in i40e_link_event() argument
9926 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_link_event()
9927 struct i40e_veb *veb = i40e_pf_get_main_veb(pf); in i40e_link_event()
9936 pf->hw.phy.get_link_info = true; in i40e_link_event()
9937 old_link = (pf->hw.phy.link_info_old.link_info & I40E_AQ_LINK_UP); in i40e_link_event()
9938 status = i40e_get_link_status(&pf->hw, &new_link); in i40e_link_event()
9942 clear_bit(__I40E_TEMP_LINK_POLLING, pf->state); in i40e_link_event()
9947 set_bit(__I40E_TEMP_LINK_POLLING, pf->state); in i40e_link_event()
9948 dev_dbg(&pf->pdev->dev, "couldn't get link state, status: %d\n", in i40e_link_event()
9953 old_link_speed = pf->hw.phy.link_info_old.link_speed; in i40e_link_event()
9954 new_link_speed = pf->hw.phy.link_info.link_speed; in i40e_link_event()
9972 if (pf->vf) in i40e_link_event()
9973 i40e_vc_notify_link_state(pf); in i40e_link_event()
9975 if (test_bit(I40E_FLAG_PTP_ENA, pf->flags)) in i40e_link_event()
9976 i40e_ptp_set_increment(pf); in i40e_link_event()
9981 if (pf->dcbx_cap & DCB_CAP_DCBX_LLD_MANAGED) in i40e_link_event()
9988 dev_dbg(&pf->pdev->dev, "Reconfig DCB to single TC as result of Link Down\n"); in i40e_link_event()
9989 memset(&pf->tmp_cfg, 0, sizeof(pf->tmp_cfg)); in i40e_link_event()
9990 err = i40e_dcb_sw_default_config(pf); in i40e_link_event()
9992 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_link_event()
9993 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_link_event()
9995 pf->dcbx_cap = DCB_CAP_DCBX_HOST | in i40e_link_event()
9997 set_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_link_event()
9998 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_link_event()
10006 * @pf: board private structure
10008 static void i40e_watchdog_subtask(struct i40e_pf *pf) in i40e_watchdog_subtask() argument
10015 if (test_bit(__I40E_DOWN, pf->state) || in i40e_watchdog_subtask()
10016 test_bit(__I40E_CONFIG_BUSY, pf->state)) in i40e_watchdog_subtask()
10020 if (time_before(jiffies, (pf->service_timer_previous + in i40e_watchdog_subtask()
10021 pf->service_timer_period))) in i40e_watchdog_subtask()
10023 pf->service_timer_previous = jiffies; in i40e_watchdog_subtask()
10025 if (test_bit(I40E_FLAG_LINK_POLLING_ENA, pf->flags) || in i40e_watchdog_subtask()
10026 test_bit(__I40E_TEMP_LINK_POLLING, pf->state)) in i40e_watchdog_subtask()
10027 i40e_link_event(pf); in i40e_watchdog_subtask()
10032 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_watchdog_subtask()
10036 if (test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags)) { in i40e_watchdog_subtask()
10038 i40e_pf_for_each_veb(pf, i, veb) in i40e_watchdog_subtask()
10042 i40e_ptp_rx_hang(pf); in i40e_watchdog_subtask()
10043 i40e_ptp_tx_hang(pf); in i40e_watchdog_subtask()
10048 * @pf: board private structure
10050 static void i40e_reset_subtask(struct i40e_pf *pf) in i40e_reset_subtask() argument
10054 if (test_bit(__I40E_REINIT_REQUESTED, pf->state)) { in i40e_reset_subtask()
10056 clear_bit(__I40E_REINIT_REQUESTED, pf->state); in i40e_reset_subtask()
10058 if (test_bit(__I40E_PF_RESET_REQUESTED, pf->state)) { in i40e_reset_subtask()
10060 clear_bit(__I40E_PF_RESET_REQUESTED, pf->state); in i40e_reset_subtask()
10062 if (test_bit(__I40E_CORE_RESET_REQUESTED, pf->state)) { in i40e_reset_subtask()
10064 clear_bit(__I40E_CORE_RESET_REQUESTED, pf->state); in i40e_reset_subtask()
10066 if (test_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state)) { in i40e_reset_subtask()
10068 clear_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state); in i40e_reset_subtask()
10070 if (test_bit(__I40E_DOWN_REQUESTED, pf->state)) { in i40e_reset_subtask()
10072 clear_bit(__I40E_DOWN_REQUESTED, pf->state); in i40e_reset_subtask()
10078 if (test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) { in i40e_reset_subtask()
10079 i40e_prep_for_reset(pf); in i40e_reset_subtask()
10080 i40e_reset(pf); in i40e_reset_subtask()
10081 i40e_rebuild(pf, false, false); in i40e_reset_subtask()
10086 !test_bit(__I40E_DOWN, pf->state) && in i40e_reset_subtask()
10087 !test_bit(__I40E_CONFIG_BUSY, pf->state)) { in i40e_reset_subtask()
10088 i40e_do_reset(pf, reset_flags, false); in i40e_reset_subtask()
10094 * @pf: board private structure
10097 static void i40e_handle_link_event(struct i40e_pf *pf, in i40e_handle_link_event() argument
10109 i40e_link_event(pf); in i40e_handle_link_event()
10113 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10115 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10124 (!test_bit(I40E_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags))) { in i40e_handle_link_event()
10125 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10127 dev_err(&pf->pdev->dev, in i40e_handle_link_event()
10135 * @pf: board private structure
10137 static void i40e_clean_adminq_subtask(struct i40e_pf *pf) in i40e_clean_adminq_subtask() argument
10140 struct i40e_hw *hw = &pf->hw; in i40e_clean_adminq_subtask()
10147 /* Do not run clean AQ when PF reset fails */ in i40e_clean_adminq_subtask()
10148 if (test_bit(__I40E_RESET_FAILED, pf->state)) in i40e_clean_adminq_subtask()
10152 val = rd32(&pf->hw, I40E_PF_ARQLEN); in i40e_clean_adminq_subtask()
10156 dev_info(&pf->pdev->dev, "ARQ VF Error detected\n"); in i40e_clean_adminq_subtask()
10161 dev_info(&pf->pdev->dev, "ARQ Overflow Error detected\n"); in i40e_clean_adminq_subtask()
10163 pf->arq_overflows++; in i40e_clean_adminq_subtask()
10167 dev_info(&pf->pdev->dev, "ARQ Critical Error detected\n"); in i40e_clean_adminq_subtask()
10171 wr32(&pf->hw, I40E_PF_ARQLEN, val); in i40e_clean_adminq_subtask()
10173 val = rd32(&pf->hw, I40E_PF_ATQLEN); in i40e_clean_adminq_subtask()
10176 if (pf->hw.debug_mask & I40E_DEBUG_AQ) in i40e_clean_adminq_subtask()
10177 dev_info(&pf->pdev->dev, "ASQ VF Error detected\n"); in i40e_clean_adminq_subtask()
10181 if (pf->hw.debug_mask & I40E_DEBUG_AQ) in i40e_clean_adminq_subtask()
10182 dev_info(&pf->pdev->dev, "ASQ Overflow Error detected\n"); in i40e_clean_adminq_subtask()
10186 if (pf->hw.debug_mask & I40E_DEBUG_AQ) in i40e_clean_adminq_subtask()
10187 dev_info(&pf->pdev->dev, "ASQ Critical Error detected\n"); in i40e_clean_adminq_subtask()
10191 wr32(&pf->hw, I40E_PF_ATQLEN, val); in i40e_clean_adminq_subtask()
10203 dev_info(&pf->pdev->dev, "ARQ event error %d\n", ret); in i40e_clean_adminq_subtask()
10212 i40e_handle_link_event(pf, &event); in i40e_clean_adminq_subtask()
10216 ret = i40e_vc_process_vf_msg(pf, in i40e_clean_adminq_subtask()
10224 dev_dbg(&pf->pdev->dev, "ARQ: Update LLDP MIB event received\n"); in i40e_clean_adminq_subtask()
10227 i40e_handle_lldp_event(pf, &event); in i40e_clean_adminq_subtask()
10232 dev_dbg(&pf->pdev->dev, "ARQ LAN queue overflow event received\n"); in i40e_clean_adminq_subtask()
10233 i40e_handle_lan_overflow_event(pf, &event); in i40e_clean_adminq_subtask()
10236 dev_info(&pf->pdev->dev, "ARQ: Msg from other pf\n"); in i40e_clean_adminq_subtask()
10241 i40e_debug(&pf->hw, I40E_DEBUG_NVM, in i40e_clean_adminq_subtask()
10246 dev_info(&pf->pdev->dev, in i40e_clean_adminq_subtask()
10254 clear_bit(__I40E_ADMINQ_EVENT_PENDING, pf->state); in i40e_clean_adminq_subtask()
10267 * @pf: board private structure
10269 static void i40e_verify_eeprom(struct i40e_pf *pf) in i40e_verify_eeprom() argument
10273 err = i40e_diag_eeprom_test(&pf->hw); in i40e_verify_eeprom()
10276 err = i40e_diag_eeprom_test(&pf->hw); in i40e_verify_eeprom()
10278 dev_info(&pf->pdev->dev, "eeprom check failed (%d), Tx/Rx traffic disabled\n", in i40e_verify_eeprom()
10280 set_bit(__I40E_BAD_EEPROM, pf->state); in i40e_verify_eeprom()
10284 if (!err && test_bit(__I40E_BAD_EEPROM, pf->state)) { in i40e_verify_eeprom()
10285 dev_info(&pf->pdev->dev, "eeprom check passed, Tx/Rx traffic enabled\n"); in i40e_verify_eeprom()
10286 clear_bit(__I40E_BAD_EEPROM, pf->state); in i40e_verify_eeprom()
10292 * @pf: pointer to the PF structure
10296 static void i40e_enable_pf_switch_lb(struct i40e_pf *pf) in i40e_enable_pf_switch_lb() argument
10298 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_enable_pf_switch_lb()
10302 ctxt.seid = pf->main_vsi_seid; in i40e_enable_pf_switch_lb()
10303 ctxt.pf_num = pf->hw.pf_id; in i40e_enable_pf_switch_lb()
10305 ret = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL); in i40e_enable_pf_switch_lb()
10307 dev_info(&pf->pdev->dev, in i40e_enable_pf_switch_lb()
10308 "couldn't get PF vsi config, err %pe aq_err %s\n", in i40e_enable_pf_switch_lb()
10310 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_enable_pf_switch_lb()
10319 dev_info(&pf->pdev->dev, in i40e_enable_pf_switch_lb()
10322 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_enable_pf_switch_lb()
10328 * @pf: pointer to the PF structure
10332 static void i40e_disable_pf_switch_lb(struct i40e_pf *pf) in i40e_disable_pf_switch_lb() argument
10334 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_disable_pf_switch_lb()
10338 ctxt.seid = pf->main_vsi_seid; in i40e_disable_pf_switch_lb()
10339 ctxt.pf_num = pf->hw.pf_id; in i40e_disable_pf_switch_lb()
10341 ret = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL); in i40e_disable_pf_switch_lb()
10343 dev_info(&pf->pdev->dev, in i40e_disable_pf_switch_lb()
10344 "couldn't get PF vsi config, err %pe aq_err %s\n", in i40e_disable_pf_switch_lb()
10346 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_disable_pf_switch_lb()
10355 dev_info(&pf->pdev->dev, in i40e_disable_pf_switch_lb()
10358 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_disable_pf_switch_lb()
10372 struct i40e_pf *pf = veb->pf; in i40e_config_bridge_mode() local
10374 if (pf->hw.debug_mask & I40E_DEBUG_LAN) in i40e_config_bridge_mode()
10375 dev_info(&pf->pdev->dev, "enabling bridge mode: %s\n", in i40e_config_bridge_mode()
10378 i40e_disable_pf_switch_lb(pf); in i40e_config_bridge_mode()
10380 i40e_enable_pf_switch_lb(pf); in i40e_config_bridge_mode()
10394 struct i40e_pf *pf = veb->pf; in i40e_reconstitute_veb() local
10402 if (WARN_ON(veb->uplink_seid && veb->uplink_seid != pf->mac_seid)) { in i40e_reconstitute_veb()
10403 dev_err(&pf->pdev->dev, in i40e_reconstitute_veb()
10408 if (veb->uplink_seid == pf->mac_seid) { in i40e_reconstitute_veb()
10410 ctl_vsi = i40e_pf_get_main_vsi(pf); in i40e_reconstitute_veb()
10414 dev_err(&pf->pdev->dev, in i40e_reconstitute_veb()
10422 dev_err(&pf->pdev->dev, in i40e_reconstitute_veb()
10437 if (test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags)) in i40e_reconstitute_veb()
10445 i40e_pf_for_each_vsi(pf, v, vsi) { in i40e_reconstitute_veb()
10453 dev_info(&pf->pdev->dev, in i40e_reconstitute_veb()
10467 * @pf: the PF struct
10470 static int i40e_get_capabilities(struct i40e_pf *pf, in i40e_get_capabilities() argument
10485 err = i40e_aq_discover_capabilities(&pf->hw, cap_buf, buf_len, in i40e_get_capabilities()
10491 if (pf->hw.aq.asq_last_status == I40E_AQ_RC_ENOMEM) { in i40e_get_capabilities()
10494 } else if (pf->hw.aq.asq_last_status != I40E_AQ_RC_OK || err) { in i40e_get_capabilities()
10495 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10498 i40e_aq_str(&pf->hw, in i40e_get_capabilities()
10499 pf->hw.aq.asq_last_status)); in i40e_get_capabilities()
10504 if (pf->hw.debug_mask & I40E_DEBUG_USER) { in i40e_get_capabilities()
10506 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10507 "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()
10508 pf->hw.pf_id, pf->hw.func_caps.num_vfs, in i40e_get_capabilities()
10509 pf->hw.func_caps.num_msix_vectors, in i40e_get_capabilities()
10510 pf->hw.func_caps.num_msix_vectors_vf, in i40e_get_capabilities()
10511 pf->hw.func_caps.fd_filters_guaranteed, in i40e_get_capabilities()
10512 pf->hw.func_caps.fd_filters_best_effort, in i40e_get_capabilities()
10513 pf->hw.func_caps.num_tx_qp, in i40e_get_capabilities()
10514 pf->hw.func_caps.num_vsis); in i40e_get_capabilities()
10516 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10518 pf->hw.dev_caps.switch_mode, in i40e_get_capabilities()
10519 pf->hw.dev_caps.valid_functions); in i40e_get_capabilities()
10520 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10522 pf->hw.dev_caps.sr_iov_1_1, in i40e_get_capabilities()
10523 pf->hw.dev_caps.num_vfs); in i40e_get_capabilities()
10524 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10526 pf->hw.dev_caps.num_vsis, in i40e_get_capabilities()
10527 pf->hw.dev_caps.num_rx_qp, in i40e_get_capabilities()
10528 pf->hw.dev_caps.num_tx_qp); in i40e_get_capabilities()
10532 #define DEF_NUM_VSI (1 + (pf->hw.func_caps.fcoe ? 1 : 0) \ in i40e_get_capabilities()
10533 + pf->hw.func_caps.num_vfs) in i40e_get_capabilities()
10534 if (pf->hw.revision_id == 0 && in i40e_get_capabilities()
10535 pf->hw.func_caps.num_vsis < DEF_NUM_VSI) { in i40e_get_capabilities()
10536 dev_info(&pf->pdev->dev, in i40e_get_capabilities()
10538 pf->hw.func_caps.num_vsis, DEF_NUM_VSI); in i40e_get_capabilities()
10539 pf->hw.func_caps.num_vsis = DEF_NUM_VSI; in i40e_get_capabilities()
10549 * @pf: board private structure
10551 static void i40e_fdir_sb_setup(struct i40e_pf *pf) in i40e_fdir_sb_setup() argument
10558 if (!rd32(&pf->hw, I40E_GLQF_HKEY(0))) { in i40e_fdir_sb_setup()
10567 wr32(&pf->hw, I40E_GLQF_HKEY(i), hkey[i]); in i40e_fdir_sb_setup()
10570 if (!test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) in i40e_fdir_sb_setup()
10574 vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR); in i40e_fdir_sb_setup()
10578 main_vsi = i40e_pf_get_main_vsi(pf); in i40e_fdir_sb_setup()
10579 vsi = i40e_vsi_setup(pf, I40E_VSI_FDIR, main_vsi->seid, 0); in i40e_fdir_sb_setup()
10581 dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n"); in i40e_fdir_sb_setup()
10582 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_fdir_sb_setup()
10583 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_fdir_sb_setup()
10593 * @pf: board private structure
10595 static void i40e_fdir_teardown(struct i40e_pf *pf) in i40e_fdir_teardown() argument
10599 i40e_fdir_filter_exit(pf); in i40e_fdir_teardown()
10600 vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR); in i40e_fdir_teardown()
10607 * @vsi: PF main vsi
10616 struct i40e_pf *pf = vsi->back; in i40e_rebuild_cloud_filters() local
10621 hlist_for_each_entry_safe(cfilter, node, &pf->cloud_filter_list, in i40e_rebuild_cloud_filters()
10633 dev_dbg(&pf->pdev->dev, in i40e_rebuild_cloud_filters()
10636 i40e_aq_str(&pf->hw, in i40e_rebuild_cloud_filters()
10637 pf->hw.aq.asq_last_status)); in i40e_rebuild_cloud_filters()
10646 * @vsi: PF main vsi
10722 * @pf: board private structure
10724 * Close up the VFs and other things in prep for PF Reset.
10726 static void i40e_prep_for_reset(struct i40e_pf *pf) in i40e_prep_for_reset() argument
10728 struct i40e_hw *hw = &pf->hw; in i40e_prep_for_reset()
10733 clear_bit(__I40E_RESET_INTR_RECEIVED, pf->state); in i40e_prep_for_reset()
10734 if (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_prep_for_reset()
10736 if (i40e_check_asq_alive(&pf->hw)) in i40e_prep_for_reset()
10737 i40e_vc_notify_reset(pf); in i40e_prep_for_reset()
10739 dev_dbg(&pf->pdev->dev, "Tearing down internal switch for reset\n"); in i40e_prep_for_reset()
10742 i40e_pf_quiesce_all_vsi(pf); in i40e_prep_for_reset()
10744 i40e_pf_for_each_vsi(pf, v, vsi) { in i40e_prep_for_reset()
10749 i40e_shutdown_adminq(&pf->hw); in i40e_prep_for_reset()
10755 dev_warn(&pf->pdev->dev, in i40e_prep_for_reset()
10762 i40e_ptp_save_hw_time(pf); in i40e_prep_for_reset()
10767 * @pf: PF struct
10769 static void i40e_send_version(struct i40e_pf *pf) in i40e_send_version() argument
10778 i40e_aq_send_driver_version(&pf->hw, &dv, NULL); in i40e_send_version()
10829 * i40e_reset - wait for core reset to finish reset, reset pf if corer not seen
10830 * @pf: board private structure
10832 static int i40e_reset(struct i40e_pf *pf) in i40e_reset() argument
10834 struct i40e_hw *hw = &pf->hw; in i40e_reset()
10839 dev_info(&pf->pdev->dev, "PF reset failed, %d\n", ret); in i40e_reset()
10840 set_bit(__I40E_RESET_FAILED, pf->state); in i40e_reset()
10841 clear_bit(__I40E_RESET_RECOVERY_PENDING, pf->state); in i40e_reset()
10843 pf->pfr_count++; in i40e_reset()
10850 * @pf: board private structure
10855 static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired) in i40e_rebuild() argument
10857 const bool is_recovery_mode_reported = i40e_check_recovery_mode(pf); in i40e_rebuild()
10858 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_rebuild()
10859 struct i40e_hw *hw = &pf->hw; in i40e_rebuild()
10865 if (test_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state) && in i40e_rebuild()
10869 if (test_bit(__I40E_DOWN, pf->state) && in i40e_rebuild()
10870 !test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_rebuild()
10872 dev_dbg(&pf->pdev->dev, "Rebuilding internal switch\n"); in i40e_rebuild()
10875 ret = i40e_init_adminq(&pf->hw); in i40e_rebuild()
10877 dev_info(&pf->pdev->dev, "Rebuild AdminQ failed, err %pe aq_err %s\n", in i40e_rebuild()
10879 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_rebuild()
10882 i40e_get_oem_version(&pf->hw); in i40e_rebuild()
10884 if (test_and_clear_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state)) { in i40e_rebuild()
10890 if (test_and_clear_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state)) in i40e_rebuild()
10891 i40e_verify_eeprom(pf); in i40e_rebuild()
10897 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_rebuild()
10898 if (i40e_get_capabilities(pf, in i40e_rebuild()
10906 if (i40e_setup_misc_vector_for_recovery_mode(pf)) in i40e_rebuild()
10915 free_irq(pf->pdev->irq, pf); in i40e_rebuild()
10916 i40e_clear_interrupt_scheme(pf); in i40e_rebuild()
10917 if (i40e_restore_interrupt_scheme(pf)) in i40e_rebuild()
10922 i40e_send_version(pf); in i40e_rebuild()
10931 ret = i40e_get_capabilities(pf, i40e_aqc_opc_list_func_capabilities); in i40e_rebuild()
10938 dev_info(&pf->pdev->dev, "init_lan_hmc failed: %d\n", ret); in i40e_rebuild()
10943 dev_info(&pf->pdev->dev, "configure_lan_hmc failed: %d\n", ret); in i40e_rebuild()
10952 if (i40e_is_tc_mqprio_enabled(pf)) { in i40e_rebuild()
10959 dev_warn(&pf->pdev->dev, in i40e_rebuild()
10961 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_rebuild()
10964 ret = i40e_init_pf_dcb(pf); in i40e_rebuild()
10966 dev_info(&pf->pdev->dev, "DCB init failed %d, disabled\n", in i40e_rebuild()
10968 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_rebuild()
10977 ret = i40e_setup_pf_switch(pf, reinit, true); in i40e_rebuild()
10984 ret = i40e_aq_set_phy_int_mask(&pf->hw, in i40e_rebuild()
10989 dev_info(&pf->pdev->dev, "set phy mask fail, err %pe aq_err %s\n", in i40e_rebuild()
10991 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_rebuild()
10998 * to recover minimal use by getting the basic PF VSI working. in i40e_rebuild()
11000 if (vsi->uplink_seid != pf->mac_seid) { in i40e_rebuild()
11001 dev_dbg(&pf->pdev->dev, "attempting to rebuild switch\n"); in i40e_rebuild()
11004 i40e_pf_for_each_veb(pf, v, veb) { in i40e_rebuild()
11011 * for minimal rebuild of PF VSI. in i40e_rebuild()
11015 if (veb->uplink_seid == pf->mac_seid) { in i40e_rebuild()
11016 dev_info(&pf->pdev->dev, in i40e_rebuild()
11017 "rebuild of switch failed: %d, will try to set up simple PF connection\n", in i40e_rebuild()
11019 vsi->uplink_seid = pf->mac_seid; in i40e_rebuild()
11022 dev_info(&pf->pdev->dev, in i40e_rebuild()
11029 if (vsi->uplink_seid == pf->mac_seid) { in i40e_rebuild()
11030 dev_dbg(&pf->pdev->dev, "attempting to rebuild PF VSI\n"); in i40e_rebuild()
11034 dev_info(&pf->pdev->dev, in i40e_rebuild()
11062 /* PF Main VSI is rebuild by now, go ahead and rebuild channel VSIs in i40e_rebuild()
11083 if (test_bit(I40E_HW_CAP_RESTART_AUTONEG, pf->hw.caps)) { in i40e_rebuild()
11085 ret = i40e_aq_set_link_restart_an(&pf->hw, true, NULL); in i40e_rebuild()
11087 dev_info(&pf->pdev->dev, "link restart failed, err %pe aq_err %s\n", in i40e_rebuild()
11089 i40e_aq_str(&pf->hw, in i40e_rebuild()
11090 pf->hw.aq.asq_last_status)); in i40e_rebuild()
11093 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_rebuild()
11094 ret = i40e_setup_misc_vector(pf); in i40e_rebuild()
11102 * PF/VF VSIs. in i40e_rebuild()
11105 i40e_add_filter_to_drop_tx_flow_control_frames(&pf->hw, in i40e_rebuild()
11106 pf->main_vsi_seid); in i40e_rebuild()
11109 i40e_pf_unquiesce_all_vsi(pf); in i40e_rebuild()
11116 ret = i40e_set_promiscuous(pf, pf->cur_promisc); in i40e_rebuild()
11118 dev_warn(&pf->pdev->dev, in i40e_rebuild()
11120 pf->cur_promisc ? "on" : "off", in i40e_rebuild()
11122 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_rebuild()
11124 i40e_reset_all_vfs(pf, true); in i40e_rebuild()
11127 i40e_send_version(pf); in i40e_rebuild()
11136 clear_bit(__I40E_RESET_FAILED, pf->state); in i40e_rebuild()
11138 clear_bit(__I40E_RESET_RECOVERY_PENDING, pf->state); in i40e_rebuild()
11139 clear_bit(__I40E_TIMEOUT_RECOVERY_PENDING, pf->state); in i40e_rebuild()
11144 * @pf: board private structure
11149 static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit, in i40e_reset_and_rebuild() argument
11154 if (test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_reset_and_rebuild()
11160 ret = i40e_reset(pf); in i40e_reset_and_rebuild()
11162 i40e_rebuild(pf, reinit, lock_acquired); in i40e_reset_and_rebuild()
11164 dev_err(&pf->pdev->dev, "%s: i40e_reset() FAILED", __func__); in i40e_reset_and_rebuild()
11168 * i40e_handle_reset_warning - prep for the PF to reset, reset and rebuild
11169 * @pf: board private structure
11176 static void i40e_handle_reset_warning(struct i40e_pf *pf, bool lock_acquired) in i40e_handle_reset_warning() argument
11178 i40e_prep_for_reset(pf); in i40e_handle_reset_warning()
11179 i40e_reset_and_rebuild(pf, false, lock_acquired); in i40e_handle_reset_warning()
11184 * @pf: board private structure
11188 static void i40e_print_vf_mdd_event(struct i40e_pf *pf, struct i40e_vf *vf, in i40e_print_vf_mdd_event() argument
11191 dev_err(&pf->pdev->dev, is_tx ? in i40e_print_vf_mdd_event()
11192 …"%lld Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pm. mdd-auto-reset-vfs=%s\… in i40e_print_vf_mdd_event()
11193 …"%lld Rx Malicious Driver Detection events detected on PF %d VF %d MAC %pm. mdd-auto-reset-vfs=%s\… in i40e_print_vf_mdd_event()
11195 pf->hw.pf_id, in i40e_print_vf_mdd_event()
11198 str_on_off(test_bit(I40E_FLAG_MDD_AUTO_RESET_VF, pf->flags))); in i40e_print_vf_mdd_event()
11203 * @pf: pointer to the PF structure
11207 static void i40e_print_vfs_mdd_events(struct i40e_pf *pf) in i40e_print_vfs_mdd_events() argument
11212 if (!test_and_clear_bit(__I40E_MDD_VF_PRINT_PENDING, pf->state)) in i40e_print_vfs_mdd_events()
11215 if (!__ratelimit(&pf->mdd_message_rate_limit)) in i40e_print_vfs_mdd_events()
11218 for (i = 0; i < pf->num_alloc_vfs; i++) { in i40e_print_vfs_mdd_events()
11219 struct i40e_vf *vf = &pf->vf[i]; in i40e_print_vfs_mdd_events()
11225 i40e_print_vf_mdd_event(pf, vf, false); in i40e_print_vfs_mdd_events()
11232 i40e_print_vf_mdd_event(pf, vf, true); in i40e_print_vfs_mdd_events()
11236 if (is_printed && !test_bit(I40E_FLAG_MDD_AUTO_RESET_VF, pf->flags)) in i40e_print_vfs_mdd_events()
11237 dev_info(&pf->pdev->dev, in i40e_print_vfs_mdd_events()
11238 "Use PF Control I/F to re-enable the VF #%d\n", in i40e_print_vfs_mdd_events()
11245 * @pf: pointer to the PF structure
11249 static void i40e_handle_mdd_event(struct i40e_pf *pf) in i40e_handle_mdd_event() argument
11251 struct i40e_hw *hw = &pf->hw; in i40e_handle_mdd_event()
11257 if (!test_and_clear_bit(__I40E_MDD_EVENT_PENDING, pf->state)) { in i40e_handle_mdd_event()
11261 i40e_print_vfs_mdd_events(pf); in i40e_handle_mdd_event()
11272 pf->hw.func_caps.base_queue; in i40e_handle_mdd_event()
11273 if (netif_msg_tx_err(pf)) in i40e_handle_mdd_event()
11274 …dev_info(&pf->pdev->dev, "Malicious Driver Detection event 0x%02x on TX queue %d PF number 0x%02x … in i40e_handle_mdd_event()
11284 pf->hw.func_caps.base_queue; in i40e_handle_mdd_event()
11285 if (netif_msg_rx_err(pf)) in i40e_handle_mdd_event()
11286 …dev_info(&pf->pdev->dev, "Malicious Driver Detection event 0x%02x on RX queue %d of function 0x%02… in i40e_handle_mdd_event()
11296 dev_dbg(&pf->pdev->dev, "TX driver issue detected on PF\n"); in i40e_handle_mdd_event()
11301 dev_dbg(&pf->pdev->dev, "RX driver issue detected on PF\n"); in i40e_handle_mdd_event()
11306 for (i = 0; i < pf->num_alloc_vfs && mdd_detected; i++) { in i40e_handle_mdd_event()
11310 vf = &(pf->vf[i]); in i40e_handle_mdd_event()
11313 set_bit(__I40E_MDD_VF_PRINT_PENDING, pf->state); in i40e_handle_mdd_event()
11322 set_bit(__I40E_MDD_VF_PRINT_PENDING, pf->state); in i40e_handle_mdd_event()
11330 test_bit(I40E_FLAG_MDD_AUTO_RESET_VF, pf->flags)) { in i40e_handle_mdd_event()
11335 i40e_print_vf_mdd_event(pf, vf, false); in i40e_handle_mdd_event()
11337 i40e_print_vf_mdd_event(pf, vf, true); in i40e_handle_mdd_event()
11348 i40e_print_vfs_mdd_events(pf); in i40e_handle_mdd_event()
11357 struct i40e_pf *pf = container_of(work, in i40e_service_task() local
11363 if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || in i40e_service_task()
11364 test_bit(__I40E_SUSPENDED, pf->state)) in i40e_service_task()
11367 if (test_and_set_bit(__I40E_SERVICE_SCHED, pf->state)) in i40e_service_task()
11370 if (!test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_service_task()
11371 i40e_detect_recover_hung(pf); in i40e_service_task()
11372 i40e_sync_filters_subtask(pf); in i40e_service_task()
11373 i40e_reset_subtask(pf); in i40e_service_task()
11374 i40e_handle_mdd_event(pf); in i40e_service_task()
11375 i40e_vc_process_vflr_event(pf); in i40e_service_task()
11376 i40e_watchdog_subtask(pf); in i40e_service_task()
11377 i40e_fdir_reinit_subtask(pf); in i40e_service_task()
11378 if (test_and_clear_bit(__I40E_CLIENT_RESET, pf->state)) { in i40e_service_task()
11380 i40e_notify_client_of_netdev_close(pf, true); in i40e_service_task()
11382 i40e_client_subtask(pf); in i40e_service_task()
11384 pf->state)) in i40e_service_task()
11385 i40e_notify_client_of_l2_param_changes(pf); in i40e_service_task()
11387 i40e_sync_filters_subtask(pf); in i40e_service_task()
11389 i40e_reset_subtask(pf); in i40e_service_task()
11392 i40e_clean_adminq_subtask(pf); in i40e_service_task()
11396 clear_bit(__I40E_SERVICE_SCHED, pf->state); in i40e_service_task()
11402 if (time_after(jiffies, (start_time + pf->service_timer_period)) || in i40e_service_task()
11403 test_bit(__I40E_ADMINQ_EVENT_PENDING, pf->state) || in i40e_service_task()
11404 test_bit(__I40E_MDD_EVENT_PENDING, pf->state) || in i40e_service_task()
11405 test_bit(__I40E_VFLR_EVENT_PENDING, pf->state)) in i40e_service_task()
11406 i40e_service_event_schedule(pf); in i40e_service_task()
11415 struct i40e_pf *pf = from_timer(pf, t, service_timer); in i40e_service_timer() local
11417 mod_timer(&pf->service_timer, in i40e_service_timer()
11418 round_jiffies(jiffies + pf->service_timer_period)); in i40e_service_timer()
11419 i40e_service_event_schedule(pf); in i40e_service_timer()
11428 struct i40e_pf *pf = vsi->back; in i40e_set_num_rings_in_vsi() local
11432 vsi->alloc_queue_pairs = pf->num_lan_qps; in i40e_set_num_rings_in_vsi()
11439 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_set_num_rings_in_vsi()
11440 vsi->num_q_vectors = pf->num_lan_msix; in i40e_set_num_rings_in_vsi()
11452 vsi->num_q_vectors = pf->num_fdsb_msix; in i40e_set_num_rings_in_vsi()
11456 vsi->alloc_queue_pairs = pf->num_vmdq_qps; in i40e_set_num_rings_in_vsi()
11463 vsi->num_q_vectors = pf->num_vmdq_msix; in i40e_set_num_rings_in_vsi()
11467 vsi->alloc_queue_pairs = pf->num_vf_qps; in i40e_set_num_rings_in_vsi()
11533 * i40e_vsi_mem_alloc - Allocates the next available struct vsi in the PF
11534 * @pf: board private structure
11538 * On success: returns vsi index in PF (positive)
11540 static int i40e_vsi_mem_alloc(struct i40e_pf *pf, enum i40e_vsi_type type) in i40e_vsi_mem_alloc() argument
11547 /* Need to protect the allocation of the VSIs at the PF level */ in i40e_vsi_mem_alloc()
11548 mutex_lock(&pf->switch_mutex); in i40e_vsi_mem_alloc()
11556 i = pf->next_vsi; in i40e_vsi_mem_alloc()
11557 while (i < pf->num_alloc_vsi && pf->vsi[i]) in i40e_vsi_mem_alloc()
11559 if (i >= pf->num_alloc_vsi) { in i40e_vsi_mem_alloc()
11561 while (i < pf->next_vsi && pf->vsi[i]) in i40e_vsi_mem_alloc()
11565 if (i < pf->num_alloc_vsi && !pf->vsi[i]) { in i40e_vsi_mem_alloc()
11571 pf->next_vsi = ++i; in i40e_vsi_mem_alloc()
11579 vsi->back = pf; in i40e_vsi_mem_alloc()
11585 pf->rss_table_size : 64; in i40e_vsi_mem_alloc()
11592 vsi->af_xdp_zc_qps = bitmap_zalloc(pf->num_lan_qps, GFP_KERNEL); in i40e_vsi_mem_alloc()
11610 pf->vsi[vsi_idx] = vsi; in i40e_vsi_mem_alloc()
11616 pf->next_vsi = i - 1; in i40e_vsi_mem_alloc()
11619 mutex_unlock(&pf->switch_mutex); in i40e_vsi_mem_alloc()
11667 struct i40e_pf *pf; in i40e_vsi_clear() local
11674 pf = vsi->back; in i40e_vsi_clear()
11676 mutex_lock(&pf->switch_mutex); in i40e_vsi_clear()
11677 if (!pf->vsi[vsi->idx]) { in i40e_vsi_clear()
11678 dev_err(&pf->pdev->dev, "pf->vsi[%d] is NULL, just free vsi[%d](type %d)\n", in i40e_vsi_clear()
11683 if (pf->vsi[vsi->idx] != vsi) { in i40e_vsi_clear()
11684 dev_err(&pf->pdev->dev, in i40e_vsi_clear()
11685 "pf->vsi[%d](type %d) != vsi[%d](type %d): no free!\n", in i40e_vsi_clear()
11686 pf->vsi[vsi->idx]->idx, in i40e_vsi_clear()
11687 pf->vsi[vsi->idx]->type, in i40e_vsi_clear()
11692 /* updates the PF for this cleared vsi */ in i40e_vsi_clear()
11693 i40e_put_lump(pf->qp_pile, vsi->base_queue, vsi->idx); in i40e_vsi_clear()
11694 i40e_put_lump(pf->irq_pile, vsi->base_vector, vsi->idx); in i40e_vsi_clear()
11700 pf->vsi[vsi->idx] = NULL; in i40e_vsi_clear()
11701 if (vsi->idx < pf->next_vsi) in i40e_vsi_clear()
11702 pf->next_vsi = vsi->idx; in i40e_vsi_clear()
11705 mutex_unlock(&pf->switch_mutex); in i40e_vsi_clear()
11738 struct i40e_pf *pf = vsi->back; in i40e_alloc_rings() local
11753 ring->dev = &pf->pdev->dev; in i40e_alloc_rings()
11759 ring->itr_setting = pf->tx_itr_default; in i40e_alloc_rings()
11770 ring->dev = &pf->pdev->dev; in i40e_alloc_rings()
11777 ring->itr_setting = pf->tx_itr_default; in i40e_alloc_rings()
11786 ring->dev = &pf->pdev->dev; in i40e_alloc_rings()
11790 ring->itr_setting = pf->rx_itr_default; in i40e_alloc_rings()
11803 * @pf: board private structure
11808 static int i40e_reserve_msix_vectors(struct i40e_pf *pf, int vectors) in i40e_reserve_msix_vectors() argument
11810 vectors = pci_enable_msix_range(pf->pdev, pf->msix_entries, in i40e_reserve_msix_vectors()
11813 dev_info(&pf->pdev->dev, in i40e_reserve_msix_vectors()
11823 * @pf: board private structure
11829 static int i40e_init_msix(struct i40e_pf *pf) in i40e_init_msix() argument
11831 struct i40e_hw *hw = &pf->hw; in i40e_init_msix()
11838 if (!test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_init_msix()
11865 /* reserve some vectors for the main PF traffic queues. Initially we in i40e_init_msix()
11873 pf->num_lan_msix = min_t(int, cpus, vectors_left / 2); in i40e_init_msix()
11874 vectors_left -= pf->num_lan_msix; in i40e_init_msix()
11877 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) { in i40e_init_msix()
11879 pf->num_fdsb_msix = 1; in i40e_init_msix()
11883 pf->num_fdsb_msix = 0; in i40e_init_msix()
11888 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_init_msix()
11889 iwarp_requested = pf->num_iwarp_msix; in i40e_init_msix()
11892 pf->num_iwarp_msix = 0; in i40e_init_msix()
11893 else if (vectors_left < pf->num_iwarp_msix) in i40e_init_msix()
11894 pf->num_iwarp_msix = 1; in i40e_init_msix()
11895 v_budget += pf->num_iwarp_msix; in i40e_init_msix()
11896 vectors_left -= pf->num_iwarp_msix; in i40e_init_msix()
11900 if (test_bit(I40E_FLAG_VMDQ_ENA, pf->flags)) { in i40e_init_msix()
11902 pf->num_vmdq_msix = 0; in i40e_init_msix()
11903 pf->num_vmdq_qps = 0; in i40e_init_msix()
11906 pf->num_vmdq_vsis * pf->num_vmdq_qps; in i40e_init_msix()
11913 * queues/vectors used by the PF later with the ethtool in i40e_init_msix()
11917 pf->num_vmdq_qps = 1; in i40e_init_msix()
11918 vmdq_vecs_wanted = pf->num_vmdq_vsis; in i40e_init_msix()
11923 pf->num_vmdq_msix = pf->num_vmdq_qps; in i40e_init_msix()
11939 extra_vectors = min_t(int, cpus - pf->num_lan_msix, vectors_left); in i40e_init_msix()
11940 pf->num_lan_msix += extra_vectors; in i40e_init_msix()
11946 v_budget += pf->num_lan_msix; in i40e_init_msix()
11947 pf->msix_entries = kcalloc(v_budget, sizeof(struct msix_entry), in i40e_init_msix()
11949 if (!pf->msix_entries) in i40e_init_msix()
11953 pf->msix_entries[i].entry = i; in i40e_init_msix()
11954 v_actual = i40e_reserve_msix_vectors(pf, v_budget); in i40e_init_msix()
11957 clear_bit(I40E_FLAG_MSIX_ENA, pf->flags); in i40e_init_msix()
11958 kfree(pf->msix_entries); in i40e_init_msix()
11959 pf->msix_entries = NULL; in i40e_init_msix()
11960 pci_disable_msix(pf->pdev); in i40e_init_msix()
11965 pf->num_vmdq_vsis = 0; in i40e_init_msix()
11966 pf->num_vmdq_qps = 0; in i40e_init_msix()
11967 pf->num_lan_qps = 1; in i40e_init_msix()
11968 pf->num_lan_msix = 1; in i40e_init_msix()
11978 dev_info(&pf->pdev->dev, in i40e_init_msix()
11985 pf->num_vmdq_msix = 1; /* force VMDqs to only one vector */ in i40e_init_msix()
11986 pf->num_vmdq_vsis = 1; in i40e_init_msix()
11987 pf->num_vmdq_qps = 1; in i40e_init_msix()
11992 pf->num_lan_msix = 1; in i40e_init_msix()
11995 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_init_msix()
11996 pf->num_lan_msix = 1; in i40e_init_msix()
11997 pf->num_iwarp_msix = 1; in i40e_init_msix()
11999 pf->num_lan_msix = 2; in i40e_init_msix()
12003 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_init_msix()
12004 pf->num_iwarp_msix = min_t(int, (vec / 3), in i40e_init_msix()
12006 pf->num_vmdq_vsis = min_t(int, (vec / 3), in i40e_init_msix()
12009 pf->num_vmdq_vsis = min_t(int, (vec / 2), in i40e_init_msix()
12012 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) { in i40e_init_msix()
12013 pf->num_fdsb_msix = 1; in i40e_init_msix()
12016 pf->num_lan_msix = min_t(int, in i40e_init_msix()
12017 (vec - (pf->num_iwarp_msix + pf->num_vmdq_vsis)), in i40e_init_msix()
12018 pf->num_lan_msix); in i40e_init_msix()
12019 pf->num_lan_qps = pf->num_lan_msix; in i40e_init_msix()
12024 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) && pf->num_fdsb_msix == 0) { in i40e_init_msix()
12025 dev_info(&pf->pdev->dev, "Sideband Flowdir disabled, not enough MSI-X vectors\n"); in i40e_init_msix()
12026 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_init_msix()
12027 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_init_msix()
12029 if (test_bit(I40E_FLAG_VMDQ_ENA, pf->flags) && pf->num_vmdq_msix == 0) { in i40e_init_msix()
12030 dev_info(&pf->pdev->dev, "VMDq disabled, not enough MSI-X vectors\n"); in i40e_init_msix()
12031 clear_bit(I40E_FLAG_VMDQ_ENA, pf->flags); in i40e_init_msix()
12034 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags) && in i40e_init_msix()
12035 pf->num_iwarp_msix == 0) { in i40e_init_msix()
12036 dev_info(&pf->pdev->dev, "IWARP disabled, not enough MSI-X vectors\n"); in i40e_init_msix()
12037 clear_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_init_msix()
12039 i40e_debug(&pf->hw, I40E_DEBUG_INIT, in i40e_init_msix()
12040 "MSI-X vector distribution: PF %d, VMDq %d, FDSB %d, iWARP %d\n", in i40e_init_msix()
12041 pf->num_lan_msix, in i40e_init_msix()
12042 pf->num_vmdq_msix * pf->num_vmdq_vsis, in i40e_init_msix()
12043 pf->num_fdsb_msix, in i40e_init_msix()
12044 pf->num_iwarp_msix); in i40e_init_msix()
12087 struct i40e_pf *pf = vsi->back; in i40e_vsi_alloc_q_vectors() local
12091 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_vsi_alloc_q_vectors()
12115 * @pf: board private structure to initialize
12117 static int i40e_init_interrupt_scheme(struct i40e_pf *pf) in i40e_init_interrupt_scheme() argument
12122 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_init_interrupt_scheme()
12123 vectors = i40e_init_msix(pf); in i40e_init_interrupt_scheme()
12125 clear_bit(I40E_FLAG_MSIX_ENA, pf->flags); in i40e_init_interrupt_scheme()
12126 clear_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_init_interrupt_scheme()
12127 clear_bit(I40E_FLAG_RSS_ENA, pf->flags); in i40e_init_interrupt_scheme()
12128 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_init_interrupt_scheme()
12129 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_init_interrupt_scheme()
12130 clear_bit(I40E_FLAG_SRIOV_ENA, pf->flags); in i40e_init_interrupt_scheme()
12131 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_init_interrupt_scheme()
12132 clear_bit(I40E_FLAG_FD_ATR_ENA, pf->flags); in i40e_init_interrupt_scheme()
12133 clear_bit(I40E_FLAG_VMDQ_ENA, pf->flags); in i40e_init_interrupt_scheme()
12134 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_init_interrupt_scheme()
12137 i40e_determine_queue_usage(pf); in i40e_init_interrupt_scheme()
12141 if (!test_bit(I40E_FLAG_MSIX_ENA, pf->flags) && in i40e_init_interrupt_scheme()
12142 test_bit(I40E_FLAG_MSI_ENA, pf->flags)) { in i40e_init_interrupt_scheme()
12143 dev_info(&pf->pdev->dev, "MSI-X not available, trying MSI\n"); in i40e_init_interrupt_scheme()
12144 vectors = pci_enable_msi(pf->pdev); in i40e_init_interrupt_scheme()
12146 dev_info(&pf->pdev->dev, "MSI init failed - %d\n", in i40e_init_interrupt_scheme()
12148 clear_bit(I40E_FLAG_MSI_ENA, pf->flags); in i40e_init_interrupt_scheme()
12153 if (!test_bit(I40E_FLAG_MSI_ENA, pf->flags) && in i40e_init_interrupt_scheme()
12154 !test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_init_interrupt_scheme()
12155 dev_info(&pf->pdev->dev, "MSI-X and MSI not available, falling back to Legacy IRQ\n"); in i40e_init_interrupt_scheme()
12159 pf->irq_pile = kzalloc(size, GFP_KERNEL); in i40e_init_interrupt_scheme()
12160 if (!pf->irq_pile) in i40e_init_interrupt_scheme()
12163 pf->irq_pile->num_entries = vectors; in i40e_init_interrupt_scheme()
12166 (void)i40e_get_lump(pf, pf->irq_pile, 1, I40E_PILE_VALID_BIT - 1); in i40e_init_interrupt_scheme()
12173 * @pf: private board data structure
12179 static int i40e_restore_interrupt_scheme(struct i40e_pf *pf) in i40e_restore_interrupt_scheme() argument
12188 set_bit(I40E_FLAG_MSI_ENA, pf->flags); in i40e_restore_interrupt_scheme()
12189 set_bit(I40E_FLAG_MSIX_ENA, pf->flags); in i40e_restore_interrupt_scheme()
12191 err = i40e_init_interrupt_scheme(pf); in i40e_restore_interrupt_scheme()
12198 i40e_pf_for_each_vsi(pf, i, vsi) { in i40e_restore_interrupt_scheme()
12206 err = i40e_setup_misc_vector(pf); in i40e_restore_interrupt_scheme()
12210 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) in i40e_restore_interrupt_scheme()
12211 i40e_client_update_msix_info(pf); in i40e_restore_interrupt_scheme()
12217 if (pf->vsi[i]) in i40e_restore_interrupt_scheme()
12218 i40e_vsi_free_q_vectors(pf->vsi[i]); in i40e_restore_interrupt_scheme()
12227 * @pf: board private structure
12234 static int i40e_setup_misc_vector_for_recovery_mode(struct i40e_pf *pf) in i40e_setup_misc_vector_for_recovery_mode() argument
12238 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_setup_misc_vector_for_recovery_mode()
12239 err = i40e_setup_misc_vector(pf); in i40e_setup_misc_vector_for_recovery_mode()
12242 dev_info(&pf->pdev->dev, in i40e_setup_misc_vector_for_recovery_mode()
12248 u32 flags = test_bit(I40E_FLAG_MSI_ENA, pf->flags) ? 0 : IRQF_SHARED; in i40e_setup_misc_vector_for_recovery_mode()
12250 err = request_irq(pf->pdev->irq, i40e_intr, flags, in i40e_setup_misc_vector_for_recovery_mode()
12251 pf->int_name, pf); in i40e_setup_misc_vector_for_recovery_mode()
12254 dev_info(&pf->pdev->dev, in i40e_setup_misc_vector_for_recovery_mode()
12259 i40e_enable_misc_int_causes(pf); in i40e_setup_misc_vector_for_recovery_mode()
12260 i40e_irq_dynamic_enable_icr0(pf); in i40e_setup_misc_vector_for_recovery_mode()
12268 * @pf: board private structure
12274 static int i40e_setup_misc_vector(struct i40e_pf *pf) in i40e_setup_misc_vector() argument
12276 struct i40e_hw *hw = &pf->hw; in i40e_setup_misc_vector()
12280 if (!test_and_set_bit(__I40E_MISC_IRQ_REQUESTED, pf->state)) { in i40e_setup_misc_vector()
12281 err = request_irq(pf->msix_entries[0].vector, in i40e_setup_misc_vector()
12282 i40e_intr, 0, pf->int_name, pf); in i40e_setup_misc_vector()
12284 clear_bit(__I40E_MISC_IRQ_REQUESTED, pf->state); in i40e_setup_misc_vector()
12285 dev_info(&pf->pdev->dev, in i40e_setup_misc_vector()
12287 pf->int_name, err); in i40e_setup_misc_vector()
12292 i40e_enable_misc_int_causes(pf); in i40e_setup_misc_vector()
12300 i40e_irq_dynamic_enable_icr0(pf); in i40e_setup_misc_vector()
12317 struct i40e_pf *pf = vsi->back; in i40e_get_rss_aq() local
12318 struct i40e_hw *hw = &pf->hw; in i40e_get_rss_aq()
12325 dev_info(&pf->pdev->dev, in i40e_get_rss_aq()
12328 i40e_aq_str(&pf->hw, in i40e_get_rss_aq()
12329 pf->hw.aq.asq_last_status)); in i40e_get_rss_aq()
12339 dev_info(&pf->pdev->dev, in i40e_get_rss_aq()
12342 i40e_aq_str(&pf->hw, in i40e_get_rss_aq()
12343 pf->hw.aq.asq_last_status)); in i40e_get_rss_aq()
12363 struct i40e_pf *pf = vsi->back; in i40e_config_rss_reg() local
12364 struct i40e_hw *hw = &pf->hw; in i40e_config_rss_reg()
12379 dev_err(&pf->pdev->dev, "Cannot set RSS seed - invalid VSI type\n"); in i40e_config_rss_reg()
12397 dev_err(&pf->pdev->dev, "Cannot set RSS LUT - invalid VSI type\n"); in i40e_config_rss_reg()
12417 struct i40e_pf *pf = vsi->back; in i40e_get_rss_reg() local
12418 struct i40e_hw *hw = &pf->hw; in i40e_get_rss_reg()
12450 struct i40e_pf *pf = vsi->back; in i40e_config_rss() local
12452 if (test_bit(I40E_HW_CAP_RSS_AQ, pf->hw.caps)) in i40e_config_rss()
12469 struct i40e_pf *pf = vsi->back; in i40e_get_rss() local
12471 if (test_bit(I40E_HW_CAP_RSS_AQ, pf->hw.caps)) in i40e_get_rss()
12479 * @pf: Pointer to board private structure
12484 void i40e_fill_rss_lut(struct i40e_pf *pf, u8 *lut, in i40e_fill_rss_lut() argument
12495 * @pf: board private structure
12497 static int i40e_pf_config_rss(struct i40e_pf *pf) in i40e_pf_config_rss() argument
12499 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_pf_config_rss()
12502 struct i40e_hw *hw = &pf->hw; in i40e_pf_config_rss()
12510 hena |= i40e_pf_get_default_rss_hena(pf); in i40e_pf_config_rss()
12517 reg_val = (pf->rss_table_size == 512) ? in i40e_pf_config_rss()
12532 vsi->rss_size = min_t(int, pf->alloc_rss_size, qcount); in i40e_pf_config_rss()
12545 i40e_fill_rss_lut(pf, lut, vsi->rss_table_size, vsi->rss_size); in i40e_pf_config_rss()
12562 * @pf: board private structure
12569 int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count) in i40e_reconfig_rss_queues() argument
12571 struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); in i40e_reconfig_rss_queues()
12574 if (!test_bit(I40E_FLAG_RSS_ENA, pf->flags)) in i40e_reconfig_rss_queues()
12578 new_rss_size = min_t(int, queue_count, pf->rss_size_max); in i40e_reconfig_rss_queues()
12584 i40e_prep_for_reset(pf); in i40e_reconfig_rss_queues()
12585 if (test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_reconfig_rss_queues()
12586 return pf->alloc_rss_size; in i40e_reconfig_rss_queues()
12588 pf->alloc_rss_size = new_rss_size; in i40e_reconfig_rss_queues()
12590 i40e_reset_and_rebuild(pf, true, true); in i40e_reconfig_rss_queues()
12597 dev_dbg(&pf->pdev->dev, in i40e_reconfig_rss_queues()
12603 vsi->rss_size = min_t(int, pf->alloc_rss_size, qcount); in i40e_reconfig_rss_queues()
12605 i40e_pf_config_rss(pf); in i40e_reconfig_rss_queues()
12607 dev_info(&pf->pdev->dev, "User requested queue count/HW max RSS count: %d/%d\n", in i40e_reconfig_rss_queues()
12608 vsi->req_queue_pairs, pf->rss_size_max); in i40e_reconfig_rss_queues()
12609 return pf->alloc_rss_size; in i40e_reconfig_rss_queues()
12613 * i40e_get_partition_bw_setting - Retrieve BW settings for this PF partition
12614 * @pf: board private structure
12616 int i40e_get_partition_bw_setting(struct i40e_pf *pf) in i40e_get_partition_bw_setting() argument
12622 status = i40e_read_bw_from_alt_ram(&pf->hw, &max_bw, &min_bw, in i40e_get_partition_bw_setting()
12627 pf->min_bw = min_bw; in i40e_get_partition_bw_setting()
12629 pf->max_bw = max_bw; in i40e_get_partition_bw_setting()
12636 * i40e_set_partition_bw_setting - Set BW settings for this PF partition
12637 * @pf: board private structure
12639 int i40e_set_partition_bw_setting(struct i40e_pf *pf) in i40e_set_partition_bw_setting() argument
12646 /* Set the valid bit for this PF */ in i40e_set_partition_bw_setting()
12647 bw_data.pf_valid_bits = cpu_to_le16(BIT(pf->hw.pf_id)); in i40e_set_partition_bw_setting()
12648 bw_data.max_bw[pf->hw.pf_id] = pf->max_bw & I40E_ALT_BW_VALUE_MASK; in i40e_set_partition_bw_setting()
12649 bw_data.min_bw[pf->hw.pf_id] = pf->min_bw & I40E_ALT_BW_VALUE_MASK; in i40e_set_partition_bw_setting()
12652 status = i40e_aq_configure_partition_bw(&pf->hw, &bw_data, NULL); in i40e_set_partition_bw_setting()
12659 * if total port shutdown feature is enabled for this PF
12660 * @pf: board private structure
12662 static bool i40e_is_total_port_shutdown_enabled(struct i40e_pf *pf) in i40e_is_total_port_shutdown_enabled() argument
12677 read_status = i40e_read_nvm_word(&pf->hw, in i40e_is_total_port_shutdown_enabled()
12682 read_status = i40e_read_nvm_word(&pf->hw, in i40e_is_total_port_shutdown_enabled()
12689 read_status = i40e_read_nvm_module_data(&pf->hw, in i40e_is_total_port_shutdown_enabled()
12697 link_behavior >>= (pf->hw.port * I40E_LINK_BEHAVIOR_PORT_BIT_LENGTH); in i40e_is_total_port_shutdown_enabled()
12703 dev_warn(&pf->pdev->dev, in i40e_is_total_port_shutdown_enabled()
12711 * @pf: board private structure to initialize
12717 static int i40e_sw_init(struct i40e_pf *pf) in i40e_sw_init() argument
12724 bitmap_zero(pf->flags, I40E_PF_FLAGS_NBITS); in i40e_sw_init()
12725 set_bit(I40E_FLAG_MSI_ENA, pf->flags); in i40e_sw_init()
12726 set_bit(I40E_FLAG_MSIX_ENA, pf->flags); in i40e_sw_init()
12729 pf->rx_itr_default = I40E_ITR_RX_DEF; in i40e_sw_init()
12730 pf->tx_itr_default = I40E_ITR_TX_DEF; in i40e_sw_init()
12732 /* Depending on PF configurations, it is possible that the RSS in i40e_sw_init()
12735 pf->rss_size_max = BIT(pf->hw.func_caps.rss_table_entry_width); in i40e_sw_init()
12736 pf->alloc_rss_size = 1; in i40e_sw_init()
12737 pf->rss_table_size = pf->hw.func_caps.rss_table_size; in i40e_sw_init()
12738 pf->rss_size_max = min_t(int, pf->rss_size_max, in i40e_sw_init()
12739 pf->hw.func_caps.num_tx_qp); in i40e_sw_init()
12743 pf->rss_size_max = min_t(int, pf->rss_size_max, pow); in i40e_sw_init()
12745 if (pf->hw.func_caps.rss) { in i40e_sw_init()
12746 set_bit(I40E_FLAG_RSS_ENA, pf->flags); in i40e_sw_init()
12747 pf->alloc_rss_size = min_t(int, pf->rss_size_max, in i40e_sw_init()
12752 if (pf->hw.func_caps.npar_enable || pf->hw.func_caps.flex10_enable) { in i40e_sw_init()
12753 set_bit(I40E_FLAG_MFP_ENA, pf->flags); in i40e_sw_init()
12754 dev_info(&pf->pdev->dev, "MFP mode Enabled\n"); in i40e_sw_init()
12755 if (i40e_get_partition_bw_setting(pf)) { in i40e_sw_init()
12756 dev_warn(&pf->pdev->dev, in i40e_sw_init()
12759 dev_info(&pf->pdev->dev, in i40e_sw_init()
12761 pf->min_bw, pf->max_bw); in i40e_sw_init()
12764 i40e_set_partition_bw_setting(pf); in i40e_sw_init()
12768 if ((pf->hw.func_caps.fd_filters_guaranteed > 0) || in i40e_sw_init()
12769 (pf->hw.func_caps.fd_filters_best_effort > 0)) { in i40e_sw_init()
12770 set_bit(I40E_FLAG_FD_ATR_ENA, pf->flags); in i40e_sw_init()
12771 if (test_bit(I40E_FLAG_MFP_ENA, pf->flags) && in i40e_sw_init()
12772 pf->hw.num_partitions > 1) in i40e_sw_init()
12773 dev_info(&pf->pdev->dev, in i40e_sw_init()
12776 set_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_sw_init()
12777 pf->fdir_pf_filter_count = in i40e_sw_init()
12778 pf->hw.func_caps.fd_filters_guaranteed; in i40e_sw_init()
12779 pf->hw.fdir_shared_filter_count = in i40e_sw_init()
12780 pf->hw.func_caps.fd_filters_best_effort; in i40e_sw_init()
12784 if (test_bit(I40E_HW_CAP_ATR_EVICT, pf->hw.caps)) in i40e_sw_init()
12785 set_bit(I40E_FLAG_HW_ATR_EVICT_ENA, pf->flags); in i40e_sw_init()
12787 if (pf->hw.func_caps.vmdq && num_online_cpus() != 1) { in i40e_sw_init()
12788 pf->num_vmdq_vsis = I40E_DEFAULT_NUM_VMDQ_VSI; in i40e_sw_init()
12789 set_bit(I40E_FLAG_VMDQ_ENA, pf->flags); in i40e_sw_init()
12790 pf->num_vmdq_qps = i40e_default_queues_per_vmdq(pf); in i40e_sw_init()
12793 if (pf->hw.func_caps.iwarp && num_online_cpus() != 1) { in i40e_sw_init()
12794 set_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_sw_init()
12796 pf->num_iwarp_msix = (int)num_online_cpus() + 1; in i40e_sw_init()
12803 if (pf->hw.mac.type == I40E_MAC_XL710 && in i40e_sw_init()
12804 pf->hw.func_caps.npar_enable) in i40e_sw_init()
12805 clear_bit(I40E_HW_CAP_FW_LLDP_STOPPABLE, pf->hw.caps); in i40e_sw_init()
12808 if (pf->hw.func_caps.num_vfs && pf->hw.partition_id == 1) { in i40e_sw_init()
12809 pf->num_vf_qps = I40E_DEFAULT_QUEUES_PER_VF; in i40e_sw_init()
12810 set_bit(I40E_FLAG_SRIOV_ENA, pf->flags); in i40e_sw_init()
12811 pf->num_req_vfs = min_t(int, in i40e_sw_init()
12812 pf->hw.func_caps.num_vfs, in i40e_sw_init()
12816 pf->lan_veb = I40E_NO_VEB; in i40e_sw_init()
12817 pf->lan_vsi = I40E_NO_VSI; in i40e_sw_init()
12820 clear_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags); in i40e_sw_init()
12824 + (sizeof(u16) * pf->hw.func_caps.num_tx_qp); in i40e_sw_init()
12825 pf->qp_pile = kzalloc(size, GFP_KERNEL); in i40e_sw_init()
12826 if (!pf->qp_pile) { in i40e_sw_init()
12830 pf->qp_pile->num_entries = pf->hw.func_caps.num_tx_qp; in i40e_sw_init()
12832 pf->tx_timeout_recovery_level = 1; in i40e_sw_init()
12834 if (pf->hw.mac.type != I40E_MAC_X722 && in i40e_sw_init()
12835 i40e_is_total_port_shutdown_enabled(pf)) { in i40e_sw_init()
12839 set_bit(I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags); in i40e_sw_init()
12840 set_bit(I40E_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags); in i40e_sw_init()
12841 dev_info(&pf->pdev->dev, in i40e_sw_init()
12844 mutex_init(&pf->switch_mutex); in i40e_sw_init()
12852 * @pf: board private structure to initialize
12857 bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features) in i40e_set_ntuple() argument
12866 if (!test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) in i40e_set_ntuple()
12871 if (pf->num_fdsb_msix > 0 && !pf->num_cloud_filters) { in i40e_set_ntuple()
12872 set_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_set_ntuple()
12873 clear_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_set_ntuple()
12877 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) { in i40e_set_ntuple()
12879 i40e_fdir_filter_exit(pf); in i40e_set_ntuple()
12881 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_set_ntuple()
12882 clear_bit(__I40E_FD_SB_AUTO_DISABLED, pf->state); in i40e_set_ntuple()
12883 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_set_ntuple()
12886 pf->fd_add_err = 0; in i40e_set_ntuple()
12887 pf->fd_atr_cnt = 0; in i40e_set_ntuple()
12889 if (test_and_clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state)) in i40e_set_ntuple()
12890 if (test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags) && in i40e_set_ntuple()
12891 (I40E_DEBUG_FD & pf->hw.debug_mask)) in i40e_set_ntuple()
12892 dev_info(&pf->pdev->dev, "ATR re-enabled.\n"); in i40e_set_ntuple()
12903 struct i40e_pf *pf = vsi->back; in i40e_clear_rss_lut() local
12904 struct i40e_hw *hw = &pf->hw; in i40e_clear_rss_lut()
12915 dev_err(&pf->pdev->dev, "Cannot set RSS LUT - invalid VSI type\n"); in i40e_clear_rss_lut()
12920 * i40e_set_loopback - turn on/off loopback mode on underlying PF
12953 struct i40e_pf *pf = vsi->back; in i40e_set_features() local
12957 i40e_pf_config_rss(pf); in i40e_set_features()
12968 (netdev->features & NETIF_F_HW_TC) && pf->num_cloud_filters) { in i40e_set_features()
12969 dev_err(&pf->pdev->dev, in i40e_set_features()
12977 need_reset = i40e_set_ntuple(pf, features); in i40e_set_features()
12980 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_set_features()
13036 struct i40e_pf *pf = np->vsi->back; in i40e_get_phys_port_id() local
13037 struct i40e_hw *hw = &pf->hw; in i40e_get_phys_port_id()
13039 if (!test_bit(I40E_HW_CAP_PORT_ID_VALID, pf->hw.caps)) in i40e_get_phys_port_id()
13066 struct i40e_pf *pf = np->vsi->back; in i40e_ndo_fdb_add() local
13069 if (!test_bit(I40E_FLAG_SRIOV_ENA, pf->flags)) in i40e_ndo_fdb_add()
13109 * is to change the mode then that requires a PF reset to
13122 struct i40e_pf *pf = vsi->back; in i40e_ndo_bridge_setlink() local
13127 /* Only for PF VSI for now */ in i40e_ndo_bridge_setlink()
13131 /* Find the HW bridge for PF VSI */ in i40e_ndo_bridge_setlink()
13132 veb = i40e_pf_get_veb_by_seid(pf, vsi->uplink_seid); in i40e_ndo_bridge_setlink()
13147 veb = i40e_veb_setup(pf, vsi->uplink_seid, vsi->seid, in i40e_ndo_bridge_setlink()
13162 set_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags); in i40e_ndo_bridge_setlink()
13164 clear_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags); in i40e_ndo_bridge_setlink()
13165 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); in i40e_ndo_bridge_setlink()
13192 struct i40e_pf *pf = vsi->back; in i40e_ndo_bridge_getlink() local
13195 /* Only for PF VSI for now */ in i40e_ndo_bridge_getlink()
13199 /* Find the HW bridge for the PF VSI */ in i40e_ndo_bridge_getlink()
13200 veb = i40e_pf_get_veb_by_seid(pf, vsi->uplink_seid); in i40e_ndo_bridge_getlink()
13276 struct i40e_pf *pf = vsi->back; in i40e_xdp_setup() local
13282 if (prog && test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_xdp_setup()
13294 i40e_prep_for_reset(pf); in i40e_xdp_setup()
13304 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 (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) 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 (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { 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 (!test_bit(I40E_HW_CAP_OUTER_UDP_CSUM, pf->hw.caps)) in i40e_config_netdev()
13705 netdev->udp_tunnel_nic_info = &pf->udp_tunnel_nic; in i40e_config_netdev()
13738 if (!test_bit(I40E_FLAG_MFP_ENA, pf->flags)) in i40e_config_netdev()
13749 SET_NETDEV_DEV(netdev, &pf->pdev->dev); in i40e_config_netdev()
13777 struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); in i40e_config_netdev()
13852 struct i40e_pf *pf = vsi->back; in i40e_is_vsi_uplink_mode_veb() local
13858 veb = pf->veb[vsi->veb_idx]; in i40e_is_vsi_uplink_mode_veb()
13860 dev_info(&pf->pdev->dev, in i40e_is_vsi_uplink_mode_veb()
13887 struct i40e_pf *pf = vsi->back; in i40e_add_vsi() local
13888 struct i40e_hw *hw = &pf->hw; in i40e_add_vsi()
13900 /* The PF's main VSI is already setup as part of the in i40e_add_vsi()
13905 ctxt.seid = pf->main_vsi_seid; in i40e_add_vsi()
13906 ctxt.pf_num = pf->hw.pf_id; in i40e_add_vsi()
13908 ret = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL); in i40e_add_vsi()
13911 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13912 "couldn't get PF vsi config, err %pe aq_err %s\n", in i40e_add_vsi()
13914 i40e_aq_str(&pf->hw, in i40e_add_vsi()
13915 pf->hw.aq.asq_last_status)); in i40e_add_vsi()
13924 enabled_tc = i40e_pf_get_tc_map(pf); in i40e_add_vsi()
13930 if (test_bit(I40E_FLAG_SOURCE_PRUNING_DIS, pf->flags)) { in i40e_add_vsi()
13932 ctxt.seid = pf->main_vsi_seid; in i40e_add_vsi()
13933 ctxt.pf_num = pf->hw.pf_id; in i40e_add_vsi()
13941 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13944 i40e_aq_str(&pf->hw, in i40e_add_vsi()
13945 pf->hw.aq.asq_last_status)); in i40e_add_vsi()
13952 if (test_bit(I40E_FLAG_MFP_ENA, pf->flags) && in i40e_add_vsi()
13953 !(pf->hw.func_caps.iscsi)) { /* NIC type PF */ in i40e_add_vsi()
13955 ctxt.seid = pf->main_vsi_seid; in i40e_add_vsi()
13956 ctxt.pf_num = pf->hw.pf_id; in i40e_add_vsi()
13961 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13964 i40e_aq_str(&pf->hw, in i40e_add_vsi()
13965 pf->hw.aq.asq_last_status)); in i40e_add_vsi()
13976 * For MFP case the iSCSI PF would use this in i40e_add_vsi()
13984 dev_info(&pf->pdev->dev, in i40e_add_vsi()
13988 i40e_aq_str(&pf->hw, in i40e_add_vsi()
13989 pf->hw.aq.asq_last_status)); in i40e_add_vsi()
14000 if (test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags) && in i40e_add_vsi()
14058 if (pf->vf[vsi->vf_id].spoofchk) { in i40e_add_vsi()
14083 i40e_aq_str(&pf->hw, in i40e_add_vsi()
14084 pf->hw.aq.asq_last_status)); in i40e_add_vsi()
14106 set_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state); in i40e_add_vsi()
14112 dev_info(&pf->pdev->dev, in i40e_add_vsi()
14115 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_add_vsi()
14135 struct i40e_pf *pf; in i40e_vsi_release() local
14139 pf = vsi->back; in i40e_vsi_release()
14143 dev_info(&pf->pdev->dev, "VSI %d has existing VEB %d\n", in i40e_vsi_release()
14147 if (vsi->type == I40E_VSI_MAIN && !test_bit(__I40E_DOWN, pf->state)) { in i40e_vsi_release()
14148 dev_info(&pf->pdev->dev, "Can't remove PF VSI\n"); in i40e_vsi_release()
14168 i40e_devlink_destroy_port(pf); in i40e_vsi_release()
14203 veb = i40e_pf_get_veb_by_seid(pf, uplink_seid); in i40e_vsi_release()
14208 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_vsi_release()
14236 struct i40e_pf *pf = vsi->back; in i40e_vsi_setup_vectors() local
14239 dev_info(&pf->pdev->dev, "VSI %d has existing q_vectors\n", in i40e_vsi_setup_vectors()
14245 dev_info(&pf->pdev->dev, "VSI %d has non-zero base vector %d\n", in i40e_vsi_setup_vectors()
14252 dev_info(&pf->pdev->dev, in i40e_vsi_setup_vectors()
14262 if (!test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_vsi_setup_vectors()
14265 vsi->base_vector = i40e_get_lump(pf, pf->irq_pile, in i40e_vsi_setup_vectors()
14268 dev_info(&pf->pdev->dev, in i40e_vsi_setup_vectors()
14293 struct i40e_pf *pf; in i40e_vsi_reinit_setup() local
14299 pf = vsi->back; in i40e_vsi_reinit_setup()
14301 i40e_put_lump(pf->qp_pile, vsi->base_queue, vsi->idx); in i40e_vsi_reinit_setup()
14313 ret = i40e_get_lump(pf, pf->qp_pile, alloc_queue_pairs, vsi->idx); in i40e_vsi_reinit_setup()
14315 dev_info(&pf->pdev->dev, in i40e_vsi_reinit_setup()
14325 main_vsi = i40e_pf_get_main_vsi(pf); in i40e_vsi_reinit_setup()
14326 main_vsi->seid = pf->main_vsi_seid; in i40e_vsi_reinit_setup()
14330 i40e_rm_default_mac_filter(vsi, pf->hw.mac.perm_addr); in i40e_vsi_reinit_setup()
14350 i40e_devlink_destroy_port(pf); in i40e_vsi_reinit_setup()
14351 i40e_aq_delete_element(&pf->hw, vsi->seid, NULL); in i40e_vsi_reinit_setup()
14359 * @pf: board private structure
14370 struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type, in i40e_vsi_setup() argument
14380 * - the PF's port seid in i40e_vsi_setup()
14381 * no VEB is needed because this is the PF in i40e_vsi_setup()
14387 * - seid of the PF VSI, which is what creates the first VEB in i40e_vsi_setup()
14392 veb = i40e_pf_get_veb_by_seid(pf, uplink_seid); in i40e_vsi_setup()
14393 if (!veb && uplink_seid != pf->mac_seid) { in i40e_vsi_setup()
14394 vsi = i40e_pf_get_vsi_by_seid(pf, uplink_seid); in i40e_vsi_setup()
14396 dev_info(&pf->pdev->dev, "no such uplink_seid %d\n", in i40e_vsi_setup()
14401 if (vsi->uplink_seid == pf->mac_seid) in i40e_vsi_setup()
14402 veb = i40e_veb_setup(pf, pf->mac_seid, vsi->seid, in i40e_vsi_setup()
14405 veb = i40e_veb_setup(pf, vsi->uplink_seid, vsi->seid, in i40e_vsi_setup()
14417 if (!test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags)) { in i40e_vsi_setup()
14419 clear_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags); in i40e_vsi_setup()
14423 veb = i40e_pf_get_veb_by_seid(pf, vsi->uplink_seid); in i40e_vsi_setup()
14425 dev_info(&pf->pdev->dev, "couldn't add VEB\n"); in i40e_vsi_setup()
14434 v_idx = i40e_vsi_mem_alloc(pf, type); in i40e_vsi_setup()
14437 vsi = pf->vsi[v_idx]; in i40e_vsi_setup()
14444 pf->lan_vsi = v_idx; in i40e_vsi_setup()
14451 ret = i40e_get_lump(pf, pf->qp_pile, alloc_queue_pairs, vsi->idx); in i40e_vsi_setup()
14453 dev_info(&pf->pdev->dev, in i40e_vsi_setup()
14477 ret = i40e_devlink_create_port(pf); in i40e_vsi_setup()
14480 SET_NETDEV_DEVLINK_PORT(vsi->netdev, &pf->devlink_port); in i40e_vsi_setup()
14512 if (test_bit(I40E_HW_CAP_RSS_AQ, pf->hw.caps) && in i40e_vsi_setup()
14533 i40e_devlink_destroy_port(pf); in i40e_vsi_setup()
14535 i40e_aq_delete_element(&pf->hw, vsi->seid, NULL); in i40e_vsi_setup()
14552 struct i40e_pf *pf = veb->pf; in i40e_veb_get_bw_info() local
14553 struct i40e_hw *hw = &pf->hw; in i40e_veb_get_bw_info()
14561 dev_info(&pf->pdev->dev, in i40e_veb_get_bw_info()
14564 i40e_aq_str(&pf->hw, hw->aq.asq_last_status)); in i40e_veb_get_bw_info()
14571 dev_info(&pf->pdev->dev, in i40e_veb_get_bw_info()
14574 i40e_aq_str(&pf->hw, hw->aq.asq_last_status)); in i40e_veb_get_bw_info()
14596 * i40e_veb_mem_alloc - Allocates the next available struct veb in the PF
14597 * @pf: board private structure
14600 * On success: returns vsi index in PF (positive)
14602 static int i40e_veb_mem_alloc(struct i40e_pf *pf) in i40e_veb_mem_alloc() argument
14608 /* Need to protect the allocation of switch elements at the PF level */ in i40e_veb_mem_alloc()
14609 mutex_lock(&pf->switch_mutex); in i40e_veb_mem_alloc()
14618 while ((i < I40E_MAX_VEB) && (pf->veb[i] != NULL)) in i40e_veb_mem_alloc()
14630 veb->pf = pf; in i40e_veb_mem_alloc()
14634 pf->veb[i] = veb; in i40e_veb_mem_alloc()
14637 mutex_unlock(&pf->switch_mutex); in i40e_veb_mem_alloc()
14650 struct i40e_pf *pf = branch->pf; in i40e_switch_branch_release() local
14658 i40e_pf_for_each_veb(pf, i, veb) in i40e_switch_branch_release()
14667 i40e_pf_for_each_vsi(pf, i, vsi) in i40e_switch_branch_release()
14677 if (pf->veb[veb_idx]) in i40e_switch_branch_release()
14678 i40e_veb_release(pf->veb[veb_idx]); in i40e_switch_branch_release()
14690 if (veb->pf) { in i40e_veb_clear()
14691 struct i40e_pf *pf = veb->pf; in i40e_veb_clear() local
14693 mutex_lock(&pf->switch_mutex); in i40e_veb_clear()
14694 if (pf->veb[veb->idx] == veb) in i40e_veb_clear()
14695 pf->veb[veb->idx] = NULL; in i40e_veb_clear()
14696 mutex_unlock(&pf->switch_mutex); in i40e_veb_clear()
14709 struct i40e_pf *pf; in i40e_veb_release() local
14712 pf = veb->pf; in i40e_veb_release()
14715 i40e_pf_for_each_vsi(pf, i, vsi_it) in i40e_veb_release()
14726 dev_info(&pf->pdev->dev, in i40e_veb_release()
14739 i40e_aq_delete_element(&pf->hw, veb->seid, NULL); in i40e_veb_release()
14750 struct i40e_pf *pf = veb->pf; in i40e_add_veb() local
14751 bool enable_stats = !!test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags); in i40e_add_veb()
14754 ret = i40e_aq_add_veb(&pf->hw, veb->uplink_seid, vsi ? vsi->seid : 0, in i40e_add_veb()
14760 dev_info(&pf->pdev->dev, in i40e_add_veb()
14763 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_add_veb()
14768 ret = i40e_aq_get_veb_parameters(&pf->hw, veb->seid, NULL, NULL, in i40e_add_veb()
14771 dev_info(&pf->pdev->dev, in i40e_add_veb()
14774 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_add_veb()
14779 dev_info(&pf->pdev->dev, in i40e_add_veb()
14782 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_add_veb()
14783 i40e_aq_delete_element(&pf->hw, veb->seid, NULL); in i40e_add_veb()
14798 * @pf: board private structure
14811 struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 uplink_seid, in i40e_veb_setup() argument
14822 dev_info(&pf->pdev->dev, in i40e_veb_setup()
14830 vsi = i40e_pf_get_vsi_by_seid(pf, vsi_seid); in i40e_veb_setup()
14832 dev_err(&pf->pdev->dev, "vsi seid %d not found\n", in i40e_veb_setup()
14839 veb_idx = i40e_veb_mem_alloc(pf); in i40e_veb_setup()
14842 veb = pf->veb[veb_idx]; in i40e_veb_setup()
14851 if (vsi && vsi->idx == pf->lan_vsi) in i40e_veb_setup()
14852 pf->lan_veb = veb->idx; in i40e_veb_setup()
14863 * i40e_setup_pf_switch_element - set PF vars based on switch type
14864 * @pf: board private structure
14871 static void i40e_setup_pf_switch_element(struct i40e_pf *pf, in i40e_setup_pf_switch_element() argument
14882 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch_element()
14888 pf->mac_seid = seid; in i40e_setup_pf_switch_element()
14892 if (uplink_seid != pf->mac_seid) in i40e_setup_pf_switch_element()
14894 veb = i40e_pf_get_main_veb(pf); in i40e_setup_pf_switch_element()
14899 veb = i40e_pf_get_veb_by_seid(pf, seid); in i40e_setup_pf_switch_element()
14901 pf->lan_veb = veb->idx; in i40e_setup_pf_switch_element()
14903 v = i40e_veb_mem_alloc(pf); in i40e_setup_pf_switch_element()
14906 pf->lan_veb = v; in i40e_setup_pf_switch_element()
14910 /* Try to get again main VEB as pf->lan_veb may have changed */ in i40e_setup_pf_switch_element()
14911 veb = i40e_pf_get_main_veb(pf); in i40e_setup_pf_switch_element()
14916 veb->uplink_seid = pf->mac_seid; in i40e_setup_pf_switch_element()
14917 veb->pf = pf; in i40e_setup_pf_switch_element()
14923 * the PF's VSI in i40e_setup_pf_switch_element()
14925 pf->mac_seid = uplink_seid; in i40e_setup_pf_switch_element()
14926 pf->main_vsi_seid = seid; in i40e_setup_pf_switch_element()
14928 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch_element()
14930 downlink_seid, pf->main_vsi_seid); in i40e_setup_pf_switch_element()
14941 dev_info(&pf->pdev->dev, "unknown element type=%d seid=%d\n", in i40e_setup_pf_switch_element()
14949 * @pf: board private structure
14955 int i40e_fetch_switch_configuration(struct i40e_pf *pf, bool printconfig) in i40e_fetch_switch_configuration() argument
14971 ret = i40e_aq_get_switch_config(&pf->hw, sw_config, in i40e_fetch_switch_configuration()
14975 dev_info(&pf->pdev->dev, in i40e_fetch_switch_configuration()
14978 i40e_aq_str(&pf->hw, in i40e_fetch_switch_configuration()
14979 pf->hw.aq.asq_last_status)); in i40e_fetch_switch_configuration()
14988 dev_info(&pf->pdev->dev, in i40e_fetch_switch_configuration()
14996 i40e_setup_pf_switch_element(pf, ele, num_reported, in i40e_fetch_switch_configuration()
15007 * @pf: board private structure
15013 static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired) in i40e_setup_pf_switch() argument
15020 ret = i40e_fetch_switch_configuration(pf, false); in i40e_setup_pf_switch()
15022 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch()
15025 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_setup_pf_switch()
15028 i40e_pf_reset_stats(pf); in i40e_setup_pf_switch()
15036 if ((pf->hw.pf_id == 0) && in i40e_setup_pf_switch()
15037 !test_bit(I40E_FLAG_TRUE_PROMISC_ENA, pf->flags)) { in i40e_setup_pf_switch()
15039 pf->last_sw_conf_flags = flags; in i40e_setup_pf_switch()
15042 if (pf->hw.pf_id == 0) { in i40e_setup_pf_switch()
15046 ret = i40e_aq_set_switch_config(&pf->hw, flags, valid_flags, 0, in i40e_setup_pf_switch()
15048 if (ret && pf->hw.aq.asq_last_status != I40E_AQ_RC_ESRCH) { in i40e_setup_pf_switch()
15049 dev_info(&pf->pdev->dev, in i40e_setup_pf_switch()
15052 i40e_aq_str(&pf->hw, in i40e_setup_pf_switch()
15053 pf->hw.aq.asq_last_status)); in i40e_setup_pf_switch()
15056 pf->last_sw_conf_valid_flags = valid_flags; in i40e_setup_pf_switch()
15060 main_vsi = i40e_pf_get_main_vsi(pf); in i40e_setup_pf_switch()
15065 /* Set up the PF VSI associated with the PF's main VSI in i40e_setup_pf_switch()
15068 veb = i40e_pf_get_main_veb(pf); in i40e_setup_pf_switch()
15072 uplink_seid = pf->mac_seid; in i40e_setup_pf_switch()
15074 main_vsi = i40e_vsi_setup(pf, I40E_VSI_MAIN, in i40e_setup_pf_switch()
15079 dev_info(&pf->pdev->dev, "setup of MAIN VSI failed\n"); in i40e_setup_pf_switch()
15080 i40e_cloud_filter_exit(pf); in i40e_setup_pf_switch()
15081 i40e_fdir_teardown(pf); in i40e_setup_pf_switch()
15086 main_vsi->seid = pf->main_vsi_seid; in i40e_setup_pf_switch()
15091 i40e_fdir_sb_setup(pf); in i40e_setup_pf_switch()
15093 /* Setup static PF queue filter control settings */ in i40e_setup_pf_switch()
15094 ret = i40e_setup_pf_filter_control(pf); in i40e_setup_pf_switch()
15096 dev_info(&pf->pdev->dev, "setup_pf_filter_control failed: %d\n", in i40e_setup_pf_switch()
15104 if (test_bit(I40E_FLAG_RSS_ENA, pf->flags)) in i40e_setup_pf_switch()
15105 i40e_pf_config_rss(pf); in i40e_setup_pf_switch()
15108 i40e_link_event(pf); in i40e_setup_pf_switch()
15110 i40e_ptp_init(pf); in i40e_setup_pf_switch()
15126 * @pf: board private structure
15128 static void i40e_determine_queue_usage(struct i40e_pf *pf) in i40e_determine_queue_usage() argument
15133 pf->num_lan_qps = 0; in i40e_determine_queue_usage()
15139 queues_left = pf->hw.func_caps.num_tx_qp; in i40e_determine_queue_usage()
15142 !test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_determine_queue_usage()
15143 /* one qp for PF, no queues for anything else */ in i40e_determine_queue_usage()
15145 pf->alloc_rss_size = pf->num_lan_qps = 1; in i40e_determine_queue_usage()
15148 clear_bit(I40E_FLAG_RSS_ENA, pf->flags); in i40e_determine_queue_usage()
15149 clear_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_determine_queue_usage()
15150 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_determine_queue_usage()
15151 clear_bit(I40E_FLAG_FD_ATR_ENA, pf->flags); in i40e_determine_queue_usage()
15152 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_determine_queue_usage()
15153 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_determine_queue_usage()
15154 clear_bit(I40E_FLAG_SRIOV_ENA, pf->flags); in i40e_determine_queue_usage()
15155 clear_bit(I40E_FLAG_VMDQ_ENA, pf->flags); in i40e_determine_queue_usage()
15156 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_determine_queue_usage()
15157 } else if (!test_bit(I40E_FLAG_RSS_ENA, pf->flags) && in i40e_determine_queue_usage()
15158 !test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) && in i40e_determine_queue_usage()
15159 !test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags) && in i40e_determine_queue_usage()
15160 !test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags)) { in i40e_determine_queue_usage()
15161 /* one qp for PF */ in i40e_determine_queue_usage()
15162 pf->alloc_rss_size = pf->num_lan_qps = 1; in i40e_determine_queue_usage()
15163 queues_left -= pf->num_lan_qps; in i40e_determine_queue_usage()
15165 clear_bit(I40E_FLAG_RSS_ENA, pf->flags); in i40e_determine_queue_usage()
15166 clear_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_determine_queue_usage()
15167 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_determine_queue_usage()
15168 clear_bit(I40E_FLAG_FD_ATR_ENA, pf->flags); in i40e_determine_queue_usage()
15169 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_determine_queue_usage()
15170 clear_bit(I40E_FLAG_VMDQ_ENA, pf->flags); in i40e_determine_queue_usage()
15171 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_determine_queue_usage()
15174 if (test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags) && in i40e_determine_queue_usage()
15176 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_determine_queue_usage()
15177 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_determine_queue_usage()
15178 dev_info(&pf->pdev->dev, "not enough queues for DCB. DCB is disabled.\n"); in i40e_determine_queue_usage()
15182 q_max = max_t(int, pf->rss_size_max, num_online_cpus()); in i40e_determine_queue_usage()
15183 q_max = min_t(int, q_max, pf->hw.func_caps.num_tx_qp); in i40e_determine_queue_usage()
15184 q_max = min_t(int, q_max, pf->hw.func_caps.num_msix_vectors); in i40e_determine_queue_usage()
15185 pf->num_lan_qps = q_max; in i40e_determine_queue_usage()
15187 queues_left -= pf->num_lan_qps; in i40e_determine_queue_usage()
15190 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) { in i40e_determine_queue_usage()
15194 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); in i40e_determine_queue_usage()
15195 set_bit(I40E_FLAG_FD_SB_INACTIVE, pf->flags); in i40e_determine_queue_usage()
15196 …dev_info(&pf->pdev->dev, "not enough queues for Flow Director. Flow Director feature is disabled\n… in i40e_determine_queue_usage()
15200 if (test_bit(I40E_FLAG_SRIOV_ENA, pf->flags) && in i40e_determine_queue_usage()
15201 pf->num_vf_qps && pf->num_req_vfs && queues_left) { in i40e_determine_queue_usage()
15202 pf->num_req_vfs = min_t(int, pf->num_req_vfs, in i40e_determine_queue_usage()
15203 (queues_left / pf->num_vf_qps)); in i40e_determine_queue_usage()
15204 queues_left -= (pf->num_req_vfs * pf->num_vf_qps); in i40e_determine_queue_usage()
15207 if (test_bit(I40E_FLAG_VMDQ_ENA, pf->flags) && in i40e_determine_queue_usage()
15208 pf->num_vmdq_vsis && pf->num_vmdq_qps && queues_left) { in i40e_determine_queue_usage()
15209 pf->num_vmdq_vsis = min_t(int, pf->num_vmdq_vsis, in i40e_determine_queue_usage()
15210 (queues_left / pf->num_vmdq_qps)); in i40e_determine_queue_usage()
15211 queues_left -= (pf->num_vmdq_vsis * pf->num_vmdq_qps); in i40e_determine_queue_usage()
15214 pf->queues_left = queues_left; in i40e_determine_queue_usage()
15215 dev_dbg(&pf->pdev->dev, in i40e_determine_queue_usage()
15217 pf->hw.func_caps.num_tx_qp, in i40e_determine_queue_usage()
15218 !!test_bit(I40E_FLAG_FD_SB_ENA, pf->flags), in i40e_determine_queue_usage()
15219 pf->num_lan_qps, pf->alloc_rss_size, pf->num_req_vfs, in i40e_determine_queue_usage()
15220 pf->num_vf_qps, pf->num_vmdq_vsis, pf->num_vmdq_qps, in i40e_determine_queue_usage()
15225 * i40e_setup_pf_filter_control - Setup PF static filter control
15226 * @pf: PF to be setup
15228 * i40e_setup_pf_filter_control sets up a PF's initial filter control
15229 * settings. If PE/FCoE are enabled then it will also set the per PF
15231 * ethertype and macvlan type filter settings for the pf.
15235 static int i40e_setup_pf_filter_control(struct i40e_pf *pf) in i40e_setup_pf_filter_control() argument
15237 struct i40e_filter_control_settings *settings = &pf->filter_settings; in i40e_setup_pf_filter_control()
15242 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags) || in i40e_setup_pf_filter_control()
15243 test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags)) in i40e_setup_pf_filter_control()
15246 /* Ethtype and MACVLAN filters enabled for PF */ in i40e_setup_pf_filter_control()
15250 if (i40e_set_filter_control(&pf->hw, settings)) in i40e_setup_pf_filter_control()
15258 static void i40e_print_features(struct i40e_pf *pf) in i40e_print_features() argument
15260 struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); in i40e_print_features()
15261 struct i40e_hw *hw = &pf->hw; in i40e_print_features()
15269 i = snprintf(buf, INFO_STRING_LEN, "Features: PF-id[%d]", hw->pf_id); in i40e_print_features()
15271 i += scnprintf(&buf[i], REMAIN(i), " VFs: %d", pf->num_req_vfs); in i40e_print_features()
15274 pf->hw.func_caps.num_vsis, main_vsi->num_queue_pairs); in i40e_print_features()
15275 if (test_bit(I40E_FLAG_RSS_ENA, pf->flags)) in i40e_print_features()
15277 if (test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags)) in i40e_print_features()
15279 if (test_bit(I40E_FLAG_FD_SB_ENA, pf->flags)) { in i40e_print_features()
15283 if (test_bit(I40E_FLAG_DCB_CAPABLE, pf->flags)) in i40e_print_features()
15287 if (test_bit(I40E_FLAG_PTP_ENA, pf->flags)) in i40e_print_features()
15289 if (test_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags)) in i40e_print_features()
15294 dev_info(&pf->pdev->dev, "%s\n", buf); in i40e_print_features()
15302 * @pf: board private structure
15309 static void i40e_get_platform_mac_addr(struct pci_dev *pdev, struct i40e_pf *pf) in i40e_get_platform_mac_addr() argument
15311 if (eth_platform_get_mac_address(&pdev->dev, pf->hw.mac.addr)) in i40e_get_platform_mac_addr()
15312 i40e_get_mac_addr(&pf->hw, pf->hw.mac.addr); in i40e_get_platform_mac_addr()
15344 * @pf: board private structure
15351 static bool i40e_check_recovery_mode(struct i40e_pf *pf) in i40e_check_recovery_mode() argument
15353 u32 val = rd32(&pf->hw, I40E_GL_FWSTS); in i40e_check_recovery_mode()
15356 dev_crit(&pf->pdev->dev, "Firmware recovery mode detected. Limiting functionality.\n"); in i40e_check_recovery_mode()
15357 …dev_crit(&pf->pdev->dev, "Refer to the Intel(R) Ethernet Adapters and Devices User Guide for detai… in i40e_check_recovery_mode()
15358 set_bit(__I40E_RECOVERY_MODE, pf->state); in i40e_check_recovery_mode()
15362 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_check_recovery_mode()
15363 …dev_info(&pf->pdev->dev, "Please do Power-On Reset to initialize adapter in normal mode with full … in i40e_check_recovery_mode()
15370 * @pf: board private structure
15379 * state is to issue a series of pf-resets and check a return value.
15380 * If a PF reset returns success then the firmware could be in recovery
15389 static int i40e_pf_loop_reset(struct i40e_pf *pf) in i40e_pf_loop_reset() argument
15391 /* wait max 10 seconds for PF reset to succeed */ in i40e_pf_loop_reset()
15393 struct i40e_hw *hw = &pf->hw; in i40e_pf_loop_reset()
15403 pf->pfr_count++; in i40e_pf_loop_reset()
15405 dev_info(&pf->pdev->dev, "PF reset failed: %d\n", ret); in i40e_pf_loop_reset()
15412 * @pf: board private structure
15421 static bool i40e_check_fw_empr(struct i40e_pf *pf) in i40e_check_fw_empr() argument
15423 const u32 fw_sts = rd32(&pf->hw, I40E_GL_FWSTS) & in i40e_check_fw_empr()
15430 * i40e_handle_resets - handle EMP resets and PF resets
15431 * @pf: board private structure
15433 * Handle both EMP resets and PF resets and conclude whether there are
15440 static int i40e_handle_resets(struct i40e_pf *pf) in i40e_handle_resets() argument
15442 const int pfr = i40e_pf_loop_reset(pf); in i40e_handle_resets()
15443 const bool is_empr = i40e_check_fw_empr(pf); in i40e_handle_resets()
15446 …dev_crit(&pf->pdev->dev, "Entering recovery mode due to repeated FW resets. This may take several … in i40e_handle_resets()
15453 * @pf: board private structure
15461 static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw) in i40e_init_recovery_mode() argument
15467 pci_set_drvdata(pf->pdev, pf); in i40e_init_recovery_mode()
15468 pci_save_state(pf->pdev); in i40e_init_recovery_mode()
15471 timer_setup(&pf->service_timer, i40e_service_timer, 0); in i40e_init_recovery_mode()
15472 pf->service_timer_period = HZ; in i40e_init_recovery_mode()
15474 INIT_WORK(&pf->service_task, i40e_service_task); in i40e_init_recovery_mode()
15475 clear_bit(__I40E_SERVICE_SCHED, pf->state); in i40e_init_recovery_mode()
15477 err = i40e_init_interrupt_scheme(pf); in i40e_init_recovery_mode()
15486 if (pf->hw.func_caps.num_vsis < I40E_MIN_VSI_ALLOC) in i40e_init_recovery_mode()
15487 pf->num_alloc_vsi = I40E_MIN_VSI_ALLOC; in i40e_init_recovery_mode()
15489 pf->num_alloc_vsi = pf->hw.func_caps.num_vsis; in i40e_init_recovery_mode()
15491 /* Set up the vsi struct and our local tracking of the MAIN PF vsi. */ in i40e_init_recovery_mode()
15492 pf->vsi = kcalloc(pf->num_alloc_vsi, sizeof(struct i40e_vsi *), in i40e_init_recovery_mode()
15494 if (!pf->vsi) { in i40e_init_recovery_mode()
15502 v_idx = i40e_vsi_mem_alloc(pf, I40E_VSI_MAIN); in i40e_init_recovery_mode()
15507 pf->lan_vsi = v_idx; in i40e_init_recovery_mode()
15508 vsi = pf->vsi[v_idx]; in i40e_init_recovery_mode()
15521 i40e_dbg_pf_init(pf); in i40e_init_recovery_mode()
15523 err = i40e_setup_misc_vector_for_recovery_mode(pf); in i40e_init_recovery_mode()
15528 i40e_send_version(pf); in i40e_init_recovery_mode()
15531 mod_timer(&pf->service_timer, in i40e_init_recovery_mode()
15532 round_jiffies(jiffies + pf->service_timer_period)); in i40e_init_recovery_mode()
15537 i40e_reset_interrupt_capability(pf); in i40e_init_recovery_mode()
15538 timer_shutdown_sync(&pf->service_timer); in i40e_init_recovery_mode()
15541 pci_release_mem_regions(pf->pdev); in i40e_init_recovery_mode()
15542 pci_disable_device(pf->pdev); in i40e_init_recovery_mode()
15543 i40e_free_pf(pf); in i40e_init_recovery_mode()
15557 struct i40e_pf *pf = i40e_hw_to_pf(hw); in i40e_set_subsystem_device_id() local
15559 hw->subsystem_device_id = pf->pdev->subsystem_device ? in i40e_set_subsystem_device_id()
15560 pf->pdev->subsystem_device : in i40e_set_subsystem_device_id()
15569 * i40e_probe initializes a PF identified by a pci_dev structure.
15570 * The OS initialization, configuring of the PF private structure,
15582 struct i40e_pf *pf; in i40e_probe() local
15620 pf = i40e_alloc_pf(&pdev->dev); in i40e_probe()
15621 if (!pf) { in i40e_probe()
15625 pf->next_vsi = 0; in i40e_probe()
15626 pf->pdev = pdev; in i40e_probe()
15627 set_bit(__I40E_DOWN, pf->state); in i40e_probe()
15629 hw = &pf->hw; in i40e_probe()
15631 pf->ioremap_len = min_t(int, pci_resource_len(pdev, 0), in i40e_probe()
15638 if (pf->ioremap_len < I40E_GLGEN_STAT_CLEAR) { in i40e_probe()
15640 pf->ioremap_len); in i40e_probe()
15644 hw->hw_addr = ioremap(pci_resource_start(pdev, 0), pf->ioremap_len); in i40e_probe()
15649 pf->ioremap_len, err); in i40e_probe()
15668 INIT_LIST_HEAD(&pf->l3_flex_pit_list); in i40e_probe()
15669 INIT_LIST_HEAD(&pf->l4_flex_pit_list); in i40e_probe()
15670 INIT_LIST_HEAD(&pf->ddp_old_prof); in i40e_probe()
15678 pf->msg_enable = netif_msg_init(debug, in i40e_probe()
15683 pf->hw.debug_mask = debug; in i40e_probe()
15691 pf->corer_count++; in i40e_probe()
15696 /* Reset here to make sure all is clean and to define PF 'n' */ in i40e_probe()
15706 err = i40e_handle_resets(pf); in i40e_probe()
15710 i40e_check_recovery_mode(pf); in i40e_probe()
15722 snprintf(pf->int_name, sizeof(pf->int_name) - 1, in i40e_probe()
15724 dev_driver_string(&pf->pdev->dev), dev_name(&pdev->dev)); in i40e_probe()
15734 pf->hw.fc.requested_mode = I40E_FC_NONE; in i40e_probe()
15778 i40e_verify_eeprom(pf); in i40e_probe()
15786 err = i40e_get_capabilities(pf, i40e_aqc_opc_list_func_capabilities); in i40e_probe()
15790 err = i40e_sw_init(pf); in i40e_probe()
15796 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_probe()
15797 return i40e_init_recovery_mode(pf, hw); in i40e_probe()
15817 if (test_bit(I40E_HW_CAP_STOP_FW_LLDP, pf->hw.caps)) { in i40e_probe()
15823 i40e_get_platform_mac_addr(pdev, pf); in i40e_probe()
15834 set_bit(I40E_HW_CAP_PORT_ID_VALID, pf->hw.caps); in i40e_probe()
15836 i40e_ptp_alloc_pins(pf); in i40e_probe()
15837 pci_set_drvdata(pdev, pf); in i40e_probe()
15841 status = i40e_get_fw_lldp_status(&pf->hw, &lldp_status); in i40e_probe()
15844 (clear_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags)) : in i40e_probe()
15845 (set_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags)); in i40e_probe()
15847 test_bit(I40E_FLAG_FW_LLDP_DIS, pf->flags) ? in i40e_probe()
15854 err = i40e_init_pf_dcb(pf); in i40e_probe()
15857 clear_bit(I40E_FLAG_DCB_CAPABLE, pf->flags); in i40e_probe()
15858 clear_bit(I40E_FLAG_DCB_ENA, pf->flags); in i40e_probe()
15864 timer_setup(&pf->service_timer, i40e_service_timer, 0); in i40e_probe()
15865 pf->service_timer_period = HZ; in i40e_probe()
15867 INIT_WORK(&pf->service_task, i40e_service_task); in i40e_probe()
15868 clear_bit(__I40E_SERVICE_SCHED, pf->state); in i40e_probe()
15873 pf->wol_en = false; in i40e_probe()
15875 pf->wol_en = true; in i40e_probe()
15876 device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en); in i40e_probe()
15879 i40e_determine_queue_usage(pf); in i40e_probe()
15880 err = i40e_init_interrupt_scheme(pf); in i40e_probe()
15886 * pairs than MSI-X vectors (pf->num_lan_msix) exist. Thus in i40e_probe()
15887 * vsi->num_queue_pairs will be equal to pf->num_lan_msix, i.e., 1. in i40e_probe()
15890 pf->num_lan_msix = 1; in i40e_probe()
15892 pf->udp_tunnel_nic.set_port = i40e_udp_tunnel_set_port; in i40e_probe()
15893 pf->udp_tunnel_nic.unset_port = i40e_udp_tunnel_unset_port; in i40e_probe()
15894 pf->udp_tunnel_nic.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP; in i40e_probe()
15895 pf->udp_tunnel_nic.shared = &pf->udp_tunnel_shared; in i40e_probe()
15896 pf->udp_tunnel_nic.tables[0].n_entries = I40E_MAX_PF_UDP_OFFLOAD_PORTS; in i40e_probe()
15897 pf->udp_tunnel_nic.tables[0].tunnel_types = UDP_TUNNEL_TYPE_VXLAN | in i40e_probe()
15905 if (pf->hw.func_caps.num_vsis < I40E_MIN_VSI_ALLOC) in i40e_probe()
15906 pf->num_alloc_vsi = I40E_MIN_VSI_ALLOC; in i40e_probe()
15908 pf->num_alloc_vsi = pf->hw.func_caps.num_vsis; in i40e_probe()
15909 if (pf->num_alloc_vsi > UDP_TUNNEL_NIC_MAX_SHARING_DEVICES) { in i40e_probe()
15910 dev_warn(&pf->pdev->dev, in i40e_probe()
15912 pf->num_alloc_vsi, UDP_TUNNEL_NIC_MAX_SHARING_DEVICES); in i40e_probe()
15913 pf->num_alloc_vsi = UDP_TUNNEL_NIC_MAX_SHARING_DEVICES; in i40e_probe()
15916 /* Set up the *vsi struct and our local tracking of the MAIN PF vsi. */ in i40e_probe()
15917 pf->vsi = kcalloc(pf->num_alloc_vsi, sizeof(struct i40e_vsi *), in i40e_probe()
15919 if (!pf->vsi) { in i40e_probe()
15926 if (test_bit(I40E_FLAG_SRIOV_ENA, pf->flags) && in i40e_probe()
15927 test_bit(I40E_FLAG_MSIX_ENA, pf->flags) && in i40e_probe()
15928 !test_bit(__I40E_BAD_EEPROM, pf->state)) { in i40e_probe()
15930 set_bit(I40E_FLAG_VEB_MODE_ENA, pf->flags); in i40e_probe()
15933 err = i40e_setup_pf_switch(pf, false, false); in i40e_probe()
15939 vsi = i40e_pf_get_main_vsi(pf); in i40e_probe()
15943 vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR); in i40e_probe()
15950 err = i40e_aq_set_phy_int_mask(&pf->hw, in i40e_probe()
15955 dev_info(&pf->pdev->dev, "set phy mask fail, err %pe aq_err %s\n", in i40e_probe()
15957 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_probe()
15960 ratelimit_state_init(&pf->mdd_message_rate_limit, 1 * HZ, 1); in i40e_probe()
15973 if (test_bit(I40E_HW_CAP_RESTART_AUTONEG, pf->hw.caps)) { in i40e_probe()
15975 err = i40e_aq_set_link_restart_an(&pf->hw, true, NULL); in i40e_probe()
15977 dev_info(&pf->pdev->dev, "link restart failed, err %pe aq_err %s\n", in i40e_probe()
15979 i40e_aq_str(&pf->hw, in i40e_probe()
15980 pf->hw.aq.asq_last_status)); in i40e_probe()
15986 clear_bit(__I40E_DOWN, pf->state); in i40e_probe()
15993 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { in i40e_probe()
15994 err = i40e_setup_misc_vector(pf); in i40e_probe()
15998 i40e_cloud_filter_exit(pf); in i40e_probe()
15999 i40e_fdir_teardown(pf); in i40e_probe()
16006 if (test_bit(I40E_FLAG_SRIOV_ENA, pf->flags) && in i40e_probe()
16007 test_bit(I40E_FLAG_MSIX_ENA, pf->flags) && in i40e_probe()
16008 !test_bit(__I40E_BAD_EEPROM, pf->state)) { in i40e_probe()
16018 err = i40e_alloc_vfs(pf, pci_num_vf(pdev)); in i40e_probe()
16027 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_probe()
16028 pf->iwarp_base_vector = i40e_get_lump(pf, pf->irq_pile, in i40e_probe()
16029 pf->num_iwarp_msix, in i40e_probe()
16031 if (pf->iwarp_base_vector < 0) { in i40e_probe()
16034 pf->num_iwarp_msix, pf->iwarp_base_vector); in i40e_probe()
16035 clear_bit(I40E_FLAG_IWARP_ENA, pf->flags); in i40e_probe()
16039 i40e_dbg_pf_init(pf); in i40e_probe()
16042 i40e_send_version(pf); in i40e_probe()
16045 mod_timer(&pf->service_timer, in i40e_probe()
16046 round_jiffies(jiffies + pf->service_timer_period)); in i40e_probe()
16048 /* add this PF to client device list and launch a client service task */ in i40e_probe()
16049 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_probe()
16050 err = i40e_lan_add_device(pf); in i40e_probe()
16052 dev_info(&pdev->dev, "Failed to add PF to client API service list: %d\n", in i40e_probe()
16062 if (!test_bit(I40E_HW_CAP_NO_PCI_LINK_CHECK, pf->hw.caps)) { in i40e_probe()
16069 pcie_capability_read_word(pf->pdev, PCI_EXP_LNKSTA, in i40e_probe()
16110 dev_dbg(&pf->pdev->dev, "get requested speeds ret = %pe last_status = %s\n", in i40e_probe()
16112 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_probe()
16113 pf->hw.phy.link_info.requested_speeds = abilities.link_speed; in i40e_probe()
16116 i40e_set_fec_in_flags(abilities.fec_cfg_curr_mod_ext_info, pf->flags); in i40e_probe()
16121 dev_dbg(&pf->pdev->dev, "get supported phy types ret = %pe last_status = %s\n", in i40e_probe()
16123 i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); in i40e_probe()
16128 rd32(&pf->hw, I40E_PRTGL_SAH)); in i40e_probe()
16131 pf->hw.port, val, MAX_FRAME_SIZE_DEFAULT); in i40e_probe()
16136 * PF/VF VSIs. in i40e_probe()
16139 i40e_add_filter_to_drop_tx_flow_control_frames(&pf->hw, in i40e_probe()
16140 pf->main_vsi_seid); in i40e_probe()
16142 if ((pf->hw.device_id == I40E_DEV_ID_10G_BASE_T) || in i40e_probe()
16143 (pf->hw.device_id == I40E_DEV_ID_10G_BASE_T4)) in i40e_probe()
16144 set_bit(I40E_HW_CAP_PHY_CONTROLS_LEDS, pf->hw.caps); in i40e_probe()
16145 if (pf->hw.device_id == I40E_DEV_ID_SFP_I_X722) in i40e_probe()
16146 set_bit(I40E_HW_CAP_CRT_RETIMER, pf->hw.caps); in i40e_probe()
16148 i40e_print_features(pf); in i40e_probe()
16150 i40e_devlink_register(pf); in i40e_probe()
16156 set_bit(__I40E_DOWN, pf->state); in i40e_probe()
16157 i40e_clear_interrupt_scheme(pf); in i40e_probe()
16158 kfree(pf->vsi); in i40e_probe()
16160 i40e_reset_interrupt_capability(pf); in i40e_probe()
16161 timer_shutdown_sync(&pf->service_timer); in i40e_probe()
16166 kfree(pf->qp_pile); in i40e_probe()
16172 i40e_free_pf(pf); in i40e_probe()
16192 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_remove() local
16193 struct i40e_hw *hw = &pf->hw; in i40e_remove()
16199 i40e_devlink_unregister(pf); in i40e_remove()
16201 i40e_dbg_pf_exit(pf); in i40e_remove()
16203 i40e_ptp_stop(pf); in i40e_remove()
16213 while (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, pf->state)) in i40e_remove()
16215 set_bit(__I40E_IN_REMOVE, pf->state); in i40e_remove()
16217 if (test_bit(I40E_FLAG_SRIOV_ENA, pf->flags)) { in i40e_remove()
16218 set_bit(__I40E_VF_RESETS_DISABLED, pf->state); in i40e_remove()
16219 i40e_free_vfs(pf); in i40e_remove()
16220 clear_bit(I40E_FLAG_SRIOV_ENA, pf->flags); in i40e_remove()
16223 set_bit(__I40E_SUSPENDED, pf->state); in i40e_remove()
16224 set_bit(__I40E_DOWN, pf->state); in i40e_remove()
16225 if (pf->service_timer.function) in i40e_remove()
16226 timer_shutdown_sync(&pf->service_timer); in i40e_remove()
16227 if (pf->service_task.func) in i40e_remove()
16228 cancel_work_sync(&pf->service_task); in i40e_remove()
16230 if (test_bit(__I40E_RECOVERY_MODE, pf->state)) { in i40e_remove()
16231 struct i40e_vsi *vsi = pf->vsi[0]; in i40e_remove()
16233 /* We know that we have allocated only one vsi for this PF, in i40e_remove()
16246 i40e_notify_client_of_netdev_close(pf, false); in i40e_remove()
16248 i40e_fdir_teardown(pf); in i40e_remove()
16251 * This will leave only the PF's VSI remaining. in i40e_remove()
16253 i40e_pf_for_each_veb(pf, i, veb) in i40e_remove()
16254 if (veb->uplink_seid == pf->mac_seid || in i40e_remove()
16258 /* Now we can shutdown the PF's VSIs, just before we kill in i40e_remove()
16261 i40e_pf_for_each_vsi(pf, i, vsi) { in i40e_remove()
16264 pf->vsi[i] = NULL; in i40e_remove()
16267 i40e_cloud_filter_exit(pf); in i40e_remove()
16270 if (test_bit(I40E_FLAG_IWARP_ENA, pf->flags)) { in i40e_remove()
16271 ret_code = i40e_lan_del_device(pf); in i40e_remove()
16288 if (test_bit(__I40E_RECOVERY_MODE, pf->state) && in i40e_remove()
16289 !test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_remove()
16290 free_irq(pf->pdev->irq, pf); in i40e_remove()
16301 i40e_clear_interrupt_scheme(pf); in i40e_remove()
16302 i40e_pf_for_each_vsi(pf, i, vsi) { in i40e_remove()
16303 if (!test_bit(__I40E_RECOVERY_MODE, pf->state)) in i40e_remove()
16307 pf->vsi[i] = NULL; in i40e_remove()
16311 i40e_pf_for_each_veb(pf, i, veb) { in i40e_remove()
16313 pf->veb[i] = NULL; in i40e_remove()
16316 kfree(pf->qp_pile); in i40e_remove()
16317 kfree(pf->vsi); in i40e_remove()
16320 i40e_free_pf(pf); in i40e_remove()
16329 * @pf: pointer to i40e_pf struct
16331 static void i40e_enable_mc_magic_wake(struct i40e_pf *pf) in i40e_enable_mc_magic_wake() argument
16333 struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); in i40e_enable_mc_magic_wake()
16334 struct i40e_hw *hw = &pf->hw; in i40e_enable_mc_magic_wake()
16343 dev_err(&pf->pdev->dev, in i40e_enable_mc_magic_wake()
16359 dev_err(&pf->pdev->dev, in i40e_enable_mc_magic_wake()
16369 dev_err(&pf->pdev->dev, in i40e_enable_mc_magic_wake()
16375 * @pf: pointer to i40e_pf struct
16378 static int i40e_io_suspend(struct i40e_pf *pf) in i40e_io_suspend() argument
16380 struct i40e_hw *hw = &pf->hw; in i40e_io_suspend()
16382 set_bit(__I40E_DOWN, pf->state); in i40e_io_suspend()
16385 del_timer_sync(&pf->service_timer); in i40e_io_suspend()
16386 cancel_work_sync(&pf->service_task); in i40e_io_suspend()
16391 i40e_notify_client_of_netdev_close(pf, false); in i40e_io_suspend()
16393 if (test_bit(I40E_HW_CAP_WOL_MC_MAGIC_PKT_WAKE, pf->hw.caps) && in i40e_io_suspend()
16394 pf->wol_en) in i40e_io_suspend()
16395 i40e_enable_mc_magic_wake(pf); in i40e_io_suspend()
16403 i40e_prep_for_reset(pf); in i40e_io_suspend()
16405 wr32(hw, I40E_PFPM_APM, (pf->wol_en ? I40E_PFPM_APM_APME_MASK : 0)); in i40e_io_suspend()
16406 wr32(hw, I40E_PFPM_WUFC, (pf->wol_en ? I40E_PFPM_WUFC_MAG_MASK : 0)); in i40e_io_suspend()
16413 i40e_clear_interrupt_scheme(pf); in i40e_io_suspend()
16422 * @pf: pointer to i40e_pf struct
16425 static int i40e_io_resume(struct i40e_pf *pf) in i40e_io_resume() argument
16427 struct device *dev = &pf->pdev->dev; in i40e_io_resume()
16438 err = i40e_restore_interrupt_scheme(pf); in i40e_io_resume()
16444 clear_bit(__I40E_DOWN, pf->state); in i40e_io_resume()
16445 i40e_reset_and_rebuild(pf, false, true); in i40e_io_resume()
16450 clear_bit(__I40E_SUSPENDED, pf->state); in i40e_io_resume()
16453 mod_timer(&pf->service_timer, in i40e_io_resume()
16454 round_jiffies(jiffies + pf->service_timer_period)); in i40e_io_resume()
16471 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_detected() local
16475 if (!pf) { in i40e_pci_error_detected()
16482 if (!test_bit(__I40E_SUSPENDED, pf->state)) in i40e_pci_error_detected()
16483 i40e_io_suspend(pf); in i40e_pci_error_detected()
16500 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_slot_reset() local
16516 reg = rd32(&pf->hw, I40E_GLGEN_RTRIG); in i40e_pci_error_slot_reset()
16532 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_reset_prepare() local
16534 i40e_prep_for_reset(pf); in i40e_pci_error_reset_prepare()
16543 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_reset_done() local
16545 if (test_bit(__I40E_IN_REMOVE, pf->state)) in i40e_pci_error_reset_done()
16548 i40e_reset_and_rebuild(pf, false, false); in i40e_pci_error_reset_done()
16563 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_pci_error_resume() local
16566 if (test_bit(__I40E_SUSPENDED, pf->state)) in i40e_pci_error_resume()
16569 i40e_io_resume(pf); in i40e_pci_error_resume()
16578 struct i40e_pf *pf = pci_get_drvdata(pdev); in i40e_shutdown() local
16579 struct i40e_hw *hw = &pf->hw; in i40e_shutdown()
16581 set_bit(__I40E_SUSPENDED, pf->state); in i40e_shutdown()
16582 set_bit(__I40E_DOWN, pf->state); in i40e_shutdown()
16584 del_timer_sync(&pf->service_timer); in i40e_shutdown()
16585 cancel_work_sync(&pf->service_task); in i40e_shutdown()
16586 i40e_cloud_filter_exit(pf); in i40e_shutdown()
16587 i40e_fdir_teardown(pf); in i40e_shutdown()
16592 i40e_notify_client_of_netdev_close(pf, false); in i40e_shutdown()
16594 if (test_bit(I40E_HW_CAP_WOL_MC_MAGIC_PKT_WAKE, pf->hw.caps) && in i40e_shutdown()
16595 pf->wol_en) in i40e_shutdown()
16596 i40e_enable_mc_magic_wake(pf); in i40e_shutdown()
16598 i40e_prep_for_reset(pf); in i40e_shutdown()
16601 (pf->wol_en ? I40E_PFPM_APM_APME_MASK : 0)); in i40e_shutdown()
16603 (pf->wol_en ? I40E_PFPM_WUFC_MAG_MASK : 0)); in i40e_shutdown()
16606 if (test_bit(__I40E_RECOVERY_MODE, pf->state) && in i40e_shutdown()
16607 !test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) in i40e_shutdown()
16608 free_irq(pf->pdev->irq, pf); in i40e_shutdown()
16615 i40e_clear_interrupt_scheme(pf); in i40e_shutdown()
16619 pci_wake_from_d3(pdev, pf->wol_en); in i40e_shutdown()
16630 struct i40e_pf *pf = dev_get_drvdata(dev); in i40e_suspend() local
16633 if (test_and_set_bit(__I40E_SUSPENDED, pf->state)) in i40e_suspend()
16635 return i40e_io_suspend(pf); in i40e_suspend()
16644 struct i40e_pf *pf = dev_get_drvdata(dev); in i40e_resume() local
16647 if (!test_bit(__I40E_SUSPENDED, pf->state)) in i40e_resume()
16649 return i40e_io_resume(pf); in i40e_resume()