Lines Matching refs:vf
26 struct i40e_vf *vf = pf->vf; in i40e_vc_vf_broadcast() local
29 for (i = 0; i < pf->num_alloc_vfs; i++, vf++) { in i40e_vc_vf_broadcast()
30 int abs_vf_id = vf->vf_id + (int)hw->func_caps.vf_base_id; in i40e_vc_vf_broadcast()
32 if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states) && in i40e_vc_vf_broadcast()
33 !test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) in i40e_vc_vf_broadcast()
85 static void i40e_set_vf_link_state(struct i40e_vf *vf, in i40e_set_vf_link_state() argument
90 if (vf->link_forced) in i40e_set_vf_link_state()
91 link_status = vf->link_up; in i40e_set_vf_link_state()
93 if (vf->driver_caps & VIRTCHNL_VF_CAP_ADV_LINK_SPEED) { in i40e_set_vf_link_state()
110 static void i40e_vc_notify_vf_link_state(struct i40e_vf *vf) in i40e_vc_notify_vf_link_state() argument
113 struct i40e_pf *pf = vf->pf; in i40e_vc_notify_vf_link_state()
116 int abs_vf_id = vf->vf_id + (int)hw->func_caps.vf_base_id; in i40e_vc_notify_vf_link_state()
121 i40e_set_vf_link_state(vf, &pfe, ls); in i40e_vc_notify_vf_link_state()
138 i40e_vc_notify_vf_link_state(&pf->vf[i]); in i40e_vc_notify_link_state()
189 void i40e_vc_notify_vf_reset(struct i40e_vf *vf) in i40e_vc_notify_vf_reset() argument
195 if (!vf || vf->vf_id >= vf->pf->num_alloc_vfs) in i40e_vc_notify_vf_reset()
199 if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states) && in i40e_vc_notify_vf_reset()
200 !test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) in i40e_vc_notify_vf_reset()
203 abs_vf_id = vf->vf_id + (int)vf->pf->hw.func_caps.vf_base_id; in i40e_vc_notify_vf_reset()
207 i40e_aq_send_msg_to_vf(&vf->pf->hw, abs_vf_id, VIRTCHNL_OP_EVENT, in i40e_vc_notify_vf_reset()
219 static void i40e_vc_reset_vf(struct i40e_vf *vf, bool notify_vf) in i40e_vc_reset_vf() argument
221 struct i40e_pf *pf = vf->pf; in i40e_vc_reset_vf()
225 i40e_vc_notify_vf_reset(vf); in i40e_vc_reset_vf()
238 if (i40e_reset_vf(vf, false)) in i40e_vc_reset_vf()
244 dev_warn(&vf->pf->pdev->dev, in i40e_vc_reset_vf()
246 vf->vf_id); in i40e_vc_reset_vf()
248 dev_dbg(&vf->pf->pdev->dev, in i40e_vc_reset_vf()
250 vf->vf_id); in i40e_vc_reset_vf()
260 static inline bool i40e_vc_isvalid_vsi_id(struct i40e_vf *vf, u16 vsi_id) in i40e_vc_isvalid_vsi_id() argument
262 struct i40e_pf *pf = vf->pf; in i40e_vc_isvalid_vsi_id()
265 return (vsi && (vsi->vf_id == vf->vf_id)); in i40e_vc_isvalid_vsi_id()
276 static inline bool i40e_vc_isvalid_queue_id(struct i40e_vf *vf, u16 vsi_id, in i40e_vc_isvalid_queue_id() argument
279 struct i40e_pf *pf = vf->pf; in i40e_vc_isvalid_queue_id()
292 static inline bool i40e_vc_isvalid_vector_id(struct i40e_vf *vf, u32 vector_id) in i40e_vc_isvalid_vector_id() argument
294 struct i40e_pf *pf = vf->pf; in i40e_vc_isvalid_vector_id()
309 static u16 i40e_vc_get_pf_queue_id(struct i40e_vf *vf, u16 vsi_id, in i40e_vc_get_pf_queue_id() argument
312 struct i40e_pf *pf = vf->pf; in i40e_vc_get_pf_queue_id()
338 static u16 i40e_get_real_pf_qid(struct i40e_vf *vf, u16 vsi_id, u16 queue_id) in i40e_get_real_pf_qid() argument
342 if (vf->adq_enabled) { in i40e_get_real_pf_qid()
347 for (i = 0; i < vf->num_tc; i++) { in i40e_get_real_pf_qid()
348 if (queue_id < vf->ch[i].num_qps) { in i40e_get_real_pf_qid()
349 vsi_id = vf->ch[i].vsi_id; in i40e_get_real_pf_qid()
355 queue_id -= vf->ch[i].num_qps; in i40e_get_real_pf_qid()
359 return i40e_vc_get_pf_queue_id(vf, vsi_id, queue_id); in i40e_get_real_pf_qid()
370 static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_id, in i40e_config_irq_link_list() argument
374 struct i40e_pf *pf = vf->pf; in i40e_config_irq_link_list()
385 reg_idx = I40E_VPINT_LNKLST0(vf->vf_id); in i40e_config_irq_link_list()
388 ((pf->hw.func_caps.num_msix_vectors_vf - 1) * vf->vf_id) + in i40e_config_irq_link_list()
415 pf_queue_id = i40e_get_real_pf_qid(vf, vsi_id, vsi_queue_id); in i40e_config_irq_link_list()
438 pf_queue_id = i40e_get_real_pf_qid(vf, in i40e_config_irq_link_list()
458 if ((vf->driver_caps & VIRTCHNL_VF_OFFLOAD_RX_POLLING) && in i40e_config_irq_link_list()
476 static void i40e_release_rdma_qvlist(struct i40e_vf *vf) in i40e_release_rdma_qvlist() argument
478 struct i40e_pf *pf = vf->pf; in i40e_release_rdma_qvlist()
479 struct virtchnl_rdma_qvlist_info *qvlist_info = vf->qvlist_info; in i40e_release_rdma_qvlist()
483 if (!vf->qvlist_info) in i40e_release_rdma_qvlist()
499 reg_idx = (msix_vf - 1) * vf->vf_id + qv_info->ceq_idx; in i40e_release_rdma_qvlist()
506 reg_idx = ((msix_vf - 1) * vf->vf_id) + (v_idx - 1); in i40e_release_rdma_qvlist()
515 kfree(vf->qvlist_info); in i40e_release_rdma_qvlist()
516 vf->qvlist_info = NULL; in i40e_release_rdma_qvlist()
527 i40e_config_rdma_qvlist(struct i40e_vf *vf, in i40e_config_rdma_qvlist() argument
530 struct i40e_pf *pf = vf->pf; in i40e_config_rdma_qvlist()
550 kfree(vf->qvlist_info); in i40e_config_rdma_qvlist()
551 size = virtchnl_struct_size(vf->qvlist_info, qv_info, in i40e_config_rdma_qvlist()
553 vf->qvlist_info = kzalloc(size, GFP_KERNEL); in i40e_config_rdma_qvlist()
554 if (!vf->qvlist_info) { in i40e_config_rdma_qvlist()
558 vf->qvlist_info->num_vectors = qvlist_info->num_vectors; in i40e_config_rdma_qvlist()
565 if (!i40e_vc_isvalid_vector_id(vf, qv_info->v_idx)) { in i40e_config_rdma_qvlist()
572 vf->qvlist_info->qv_info[i] = *qv_info; in i40e_config_rdma_qvlist()
574 reg_idx = ((msix_vf - 1) * vf->vf_id) + (v_idx - 1); in i40e_config_rdma_qvlist()
586 reg_idx = (msix_vf - 1) * vf->vf_id + qv_info->ceq_idx; in i40e_config_rdma_qvlist()
594 reg_idx = ((msix_vf - 1) * vf->vf_id) + (v_idx - 1); in i40e_config_rdma_qvlist()
607 wr32(hw, I40E_VPINT_AEQCTL(vf->vf_id), reg); in i40e_config_rdma_qvlist()
613 kfree(vf->qvlist_info); in i40e_config_rdma_qvlist()
614 vf->qvlist_info = NULL; in i40e_config_rdma_qvlist()
628 static int i40e_config_vsi_tx_queue(struct i40e_vf *vf, u16 vsi_id, in i40e_config_vsi_tx_queue() argument
632 struct i40e_pf *pf = vf->pf; in i40e_config_vsi_tx_queue()
640 if (!i40e_vc_isvalid_vsi_id(vf, info->vsi_id)) { in i40e_config_vsi_tx_queue()
644 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id, vsi_queue_id); in i40e_config_vsi_tx_queue()
686 vf->vf_id + hw->func_caps.vf_base_id); in i40e_config_vsi_tx_queue()
703 static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id, in i40e_config_vsi_rx_queue() argument
707 u16 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id, vsi_queue_id); in i40e_config_vsi_rx_queue()
708 struct i40e_pf *pf = vf->pf; in i40e_config_vsi_rx_queue()
709 struct i40e_vsi *vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_config_vsi_rx_queue()
795 static int i40e_alloc_vsi_res(struct i40e_vf *vf, u8 idx) in i40e_alloc_vsi_res() argument
799 struct i40e_pf *pf = vf->pf; in i40e_alloc_vsi_res()
804 vsi = i40e_vsi_setup(pf, I40E_VSI_SRIOV, main_vsi->seid, vf->vf_id); in i40e_alloc_vsi_res()
809 vf->vf_id, pf->hw.aq.asq_last_status); in i40e_alloc_vsi_res()
818 vf->lan_vsi_idx = vsi->idx; in i40e_alloc_vsi_res()
819 vf->lan_vsi_id = vsi->id; in i40e_alloc_vsi_res()
826 if (vf->port_vlan_id) in i40e_alloc_vsi_res()
827 i40e_vsi_add_pvid(vsi, vf->port_vlan_id); in i40e_alloc_vsi_res()
830 if (is_valid_ether_addr(vf->default_lan_addr.addr)) { in i40e_alloc_vsi_res()
832 vf->default_lan_addr.addr); in i40e_alloc_vsi_res()
836 vf->default_lan_addr.addr, vf->vf_id); in i40e_alloc_vsi_res()
844 wr32(&pf->hw, I40E_VFQF_HENA1(0, vf->vf_id), (u32)hena); in i40e_alloc_vsi_res()
845 wr32(&pf->hw, I40E_VFQF_HENA1(1, vf->vf_id), (u32)(hena >> 32)); in i40e_alloc_vsi_res()
853 if (vf->adq_enabled) { in i40e_alloc_vsi_res()
854 vf->ch[idx].vsi_idx = vsi->idx; in i40e_alloc_vsi_res()
855 vf->ch[idx].vsi_id = vsi->id; in i40e_alloc_vsi_res()
859 if (vf->tx_rate) { in i40e_alloc_vsi_res()
860 max_tx_rate = vf->tx_rate; in i40e_alloc_vsi_res()
861 } else if (vf->ch[idx].max_tx_rate) { in i40e_alloc_vsi_res()
862 max_tx_rate = vf->ch[idx].max_tx_rate; in i40e_alloc_vsi_res()
871 vf->vf_id, ret); in i40e_alloc_vsi_res()
885 static void i40e_map_pf_queues_to_vsi(struct i40e_vf *vf) in i40e_map_pf_queues_to_vsi() argument
887 struct i40e_pf *pf = vf->pf; in i40e_map_pf_queues_to_vsi()
893 if (vf->adq_enabled) in i40e_map_pf_queues_to_vsi()
894 num_tc = vf->num_tc; in i40e_map_pf_queues_to_vsi()
897 if (vf->adq_enabled) { in i40e_map_pf_queues_to_vsi()
898 qps = vf->ch[i].num_qps; in i40e_map_pf_queues_to_vsi()
899 vsi_id = vf->ch[i].vsi_id; in i40e_map_pf_queues_to_vsi()
901 qps = pf->vsi[vf->lan_vsi_idx]->alloc_queue_pairs; in i40e_map_pf_queues_to_vsi()
902 vsi_id = vf->lan_vsi_id; in i40e_map_pf_queues_to_vsi()
910 u16 qid = i40e_vc_get_pf_queue_id(vf, in i40e_map_pf_queues_to_vsi()
914 qid = i40e_vc_get_pf_queue_id(vf, vsi_id, in i40e_map_pf_queues_to_vsi()
932 static void i40e_map_pf_to_vf_queues(struct i40e_vf *vf) in i40e_map_pf_to_vf_queues() argument
934 struct i40e_pf *pf = vf->pf; in i40e_map_pf_to_vf_queues()
941 if (vf->adq_enabled) in i40e_map_pf_to_vf_queues()
942 num_tc = vf->num_tc; in i40e_map_pf_to_vf_queues()
945 if (vf->adq_enabled) { in i40e_map_pf_to_vf_queues()
946 qps = vf->ch[i].num_qps; in i40e_map_pf_to_vf_queues()
947 vsi_id = vf->ch[i].vsi_id; in i40e_map_pf_to_vf_queues()
949 qps = pf->vsi[vf->lan_vsi_idx]->alloc_queue_pairs; in i40e_map_pf_to_vf_queues()
950 vsi_id = vf->lan_vsi_id; in i40e_map_pf_to_vf_queues()
954 qid = i40e_vc_get_pf_queue_id(vf, vsi_id, j); in i40e_map_pf_to_vf_queues()
957 wr32(hw, I40E_VPLAN_QTABLE(total_qps, vf->vf_id), in i40e_map_pf_to_vf_queues()
970 static void i40e_enable_vf_mappings(struct i40e_vf *vf) in i40e_enable_vf_mappings() argument
972 struct i40e_pf *pf = vf->pf; in i40e_enable_vf_mappings()
980 i40e_write_rx_ctl(hw, I40E_VSILAN_QBASE(vf->lan_vsi_id), in i40e_enable_vf_mappings()
985 wr32(hw, I40E_VPLAN_MAPENA(vf->vf_id), reg); in i40e_enable_vf_mappings()
987 i40e_map_pf_to_vf_queues(vf); in i40e_enable_vf_mappings()
988 i40e_map_pf_queues_to_vsi(vf); in i40e_enable_vf_mappings()
999 static void i40e_disable_vf_mappings(struct i40e_vf *vf) in i40e_disable_vf_mappings() argument
1001 struct i40e_pf *pf = vf->pf; in i40e_disable_vf_mappings()
1006 wr32(hw, I40E_VPLAN_MAPENA(vf->vf_id), 0); in i40e_disable_vf_mappings()
1008 wr32(hw, I40E_VPLAN_QTABLE(i, vf->vf_id), in i40e_disable_vf_mappings()
1019 static void i40e_free_vf_res(struct i40e_vf *vf) in i40e_free_vf_res() argument
1021 struct i40e_pf *pf = vf->pf; in i40e_free_vf_res()
1029 clear_bit(I40E_VF_STATE_INIT, &vf->vf_states); in i40e_free_vf_res()
1034 if (vf->num_queue_pairs > I40E_DEFAULT_QUEUES_PER_VF) { in i40e_free_vf_res()
1035 pf->queues_left += vf->num_queue_pairs - in i40e_free_vf_res()
1040 if (vf->lan_vsi_idx) { in i40e_free_vf_res()
1041 i40e_vsi_release(pf->vsi[vf->lan_vsi_idx]); in i40e_free_vf_res()
1042 vf->lan_vsi_idx = 0; in i40e_free_vf_res()
1043 vf->lan_vsi_id = 0; in i40e_free_vf_res()
1047 if (vf->adq_enabled && vf->ch[0].vsi_idx) { in i40e_free_vf_res()
1048 for (j = 0; j < vf->num_tc; j++) { in i40e_free_vf_res()
1054 i40e_vsi_release(pf->vsi[vf->ch[j].vsi_idx]); in i40e_free_vf_res()
1055 vf->ch[j].vsi_idx = 0; in i40e_free_vf_res()
1056 vf->ch[j].vsi_id = 0; in i40e_free_vf_res()
1065 reg_idx = I40E_VFINT_DYN_CTL0(vf->vf_id); in i40e_free_vf_res()
1068 (vf->vf_id)) in i40e_free_vf_res()
1078 reg_idx = I40E_VPINT_LNKLST0(vf->vf_id); in i40e_free_vf_res()
1081 (vf->vf_id)) in i40e_free_vf_res()
1089 vf->num_queue_pairs = 0; in i40e_free_vf_res()
1090 clear_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states); in i40e_free_vf_res()
1091 clear_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states); in i40e_free_vf_res()
1100 static int i40e_alloc_vf_res(struct i40e_vf *vf) in i40e_alloc_vf_res() argument
1102 struct i40e_pf *pf = vf->pf; in i40e_alloc_vf_res()
1106 if (vf->num_req_queues && in i40e_alloc_vf_res()
1107 vf->num_req_queues <= pf->queues_left + I40E_DEFAULT_QUEUES_PER_VF) in i40e_alloc_vf_res()
1108 pf->num_vf_qps = vf->num_req_queues; in i40e_alloc_vf_res()
1113 ret = i40e_alloc_vsi_res(vf, 0); in i40e_alloc_vf_res()
1116 total_queue_pairs += pf->vsi[vf->lan_vsi_idx]->alloc_queue_pairs; in i40e_alloc_vf_res()
1119 if (vf->adq_enabled) { in i40e_alloc_vf_res()
1123 for (idx = 1; idx < vf->num_tc; idx++) { in i40e_alloc_vf_res()
1124 ret = i40e_alloc_vsi_res(vf, idx); in i40e_alloc_vf_res()
1132 vf->vf_id); in i40e_alloc_vf_res()
1133 vf->adq_enabled = false; in i40e_alloc_vf_res()
1146 if (vf->trusted) in i40e_alloc_vf_res()
1147 set_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps); in i40e_alloc_vf_res()
1149 clear_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps); in i40e_alloc_vf_res()
1154 vf->num_queue_pairs = total_queue_pairs; in i40e_alloc_vf_res()
1157 set_bit(I40E_VF_STATE_INIT, &vf->vf_states); in i40e_alloc_vf_res()
1161 i40e_free_vf_res(vf); in i40e_alloc_vf_res()
1175 static int i40e_quiesce_vf_pci(struct i40e_vf *vf) in i40e_quiesce_vf_pci() argument
1177 struct i40e_pf *pf = vf->pf; in i40e_quiesce_vf_pci()
1182 vf_abs_id = vf->vf_id + hw->func_caps.vf_base_id; in i40e_quiesce_vf_pci()
1274 i40e_set_vsi_promisc(struct i40e_vf *vf, u16 seid, bool multi_enable, in i40e_set_vsi_promisc() argument
1277 struct i40e_pf *pf = vf->pf; in i40e_set_vsi_promisc()
1292 vf->vf_id, in i40e_set_vsi_promisc()
1308 vf->vf_id, in i40e_set_vsi_promisc()
1325 vf->vf_id, in i40e_set_vsi_promisc()
1341 vf->vf_id, in i40e_set_vsi_promisc()
1366 static int i40e_config_vf_promiscuous_mode(struct i40e_vf *vf, in i40e_config_vf_promiscuous_mode() argument
1371 struct i40e_pf *pf = vf->pf; in i40e_config_vf_promiscuous_mode()
1378 if (!i40e_vc_isvalid_vsi_id(vf, vsi_id) || !vsi) in i40e_config_vf_promiscuous_mode()
1381 if (vf->port_vlan_id) { in i40e_config_vf_promiscuous_mode()
1382 aq_ret = i40e_set_vsi_promisc(vf, vsi->seid, allmulti, in i40e_config_vf_promiscuous_mode()
1383 alluni, &vf->port_vlan_id, 1); in i40e_config_vf_promiscuous_mode()
1391 aq_ret = i40e_set_vsi_promisc(vf, vsi->seid, allmulti, alluni, in i40e_config_vf_promiscuous_mode()
1398 aq_ret = i40e_set_vsi_promisc(vf, vsi->seid, allmulti, alluni, in i40e_config_vf_promiscuous_mode()
1438 static void i40e_trigger_vf_reset(struct i40e_vf *vf, bool flr) in i40e_trigger_vf_reset() argument
1440 struct i40e_pf *pf = vf->pf; in i40e_trigger_vf_reset()
1447 vf_active = test_and_clear_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states); in i40e_trigger_vf_reset()
1455 clear_bit(I40E_VF_STATE_INIT, &vf->vf_states); in i40e_trigger_vf_reset()
1462 radq = rd32(hw, I40E_VFINT_ICR0_ENA(vf->vf_id)) & in i40e_trigger_vf_reset()
1466 if (i40e_sync_vfr_reset(hw, vf->vf_id)) in i40e_trigger_vf_reset()
1469 vf->vf_id); in i40e_trigger_vf_reset()
1474 reg = rd32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id)); in i40e_trigger_vf_reset()
1476 wr32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id), reg); in i40e_trigger_vf_reset()
1480 reg_idx = (hw->func_caps.vf_base_id + vf->vf_id) / 32; in i40e_trigger_vf_reset()
1481 bit_idx = (hw->func_caps.vf_base_id + vf->vf_id) % 32; in i40e_trigger_vf_reset()
1485 if (i40e_quiesce_vf_pci(vf)) in i40e_trigger_vf_reset()
1487 vf->vf_id); in i40e_trigger_vf_reset()
1498 static void i40e_cleanup_reset_vf(struct i40e_vf *vf) in i40e_cleanup_reset_vf() argument
1500 struct i40e_pf *pf = vf->pf; in i40e_cleanup_reset_vf()
1505 i40e_config_vf_promiscuous_mode(vf, vf->lan_vsi_id, false, false); in i40e_cleanup_reset_vf()
1508 i40e_free_vf_res(vf); in i40e_cleanup_reset_vf()
1520 reg = rd32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id)); in i40e_cleanup_reset_vf()
1522 wr32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id), reg); in i40e_cleanup_reset_vf()
1525 if (!i40e_alloc_vf_res(vf)) { in i40e_cleanup_reset_vf()
1526 int abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id; in i40e_cleanup_reset_vf()
1527 i40e_enable_vf_mappings(vf); in i40e_cleanup_reset_vf()
1528 set_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states); in i40e_cleanup_reset_vf()
1529 clear_bit(I40E_VF_STATE_DISABLED, &vf->vf_states); in i40e_cleanup_reset_vf()
1532 &vf->vf_states)) in i40e_cleanup_reset_vf()
1534 vf->num_vlan = 0; in i40e_cleanup_reset_vf()
1541 wr32(hw, I40E_VFGEN_RSTAT1(vf->vf_id), VIRTCHNL_VFR_VFACTIVE); in i40e_cleanup_reset_vf()
1552 bool i40e_reset_vf(struct i40e_vf *vf, bool flr) in i40e_reset_vf() argument
1554 struct i40e_pf *pf = vf->pf; in i40e_reset_vf()
1568 if (test_and_set_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) in i40e_reset_vf()
1571 i40e_trigger_vf_reset(vf, flr); in i40e_reset_vf()
1583 reg = rd32(hw, I40E_VPGEN_VFRSTAT(vf->vf_id)); in i40e_reset_vf()
1595 vf->vf_id); in i40e_reset_vf()
1599 if (vf->lan_vsi_idx != 0) in i40e_reset_vf()
1600 i40e_vsi_stop_rings(pf->vsi[vf->lan_vsi_idx]); in i40e_reset_vf()
1602 i40e_cleanup_reset_vf(vf); in i40e_reset_vf()
1606 clear_bit(I40E_VF_STATE_RESETTING, &vf->vf_states); in i40e_reset_vf()
1626 struct i40e_vf *vf; in i40e_reset_all_vfs() local
1639 for (vf = &pf->vf[0]; vf < &pf->vf[pf->num_alloc_vfs]; ++vf) { in i40e_reset_all_vfs()
1641 if (!test_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) in i40e_reset_all_vfs()
1642 i40e_trigger_vf_reset(vf, flr); in i40e_reset_all_vfs()
1651 for (i = 0, vf = &pf->vf[0]; i < 10 && vf < &pf->vf[pf->num_alloc_vfs]; ++i) { in i40e_reset_all_vfs()
1657 while (vf < &pf->vf[pf->num_alloc_vfs]) { in i40e_reset_all_vfs()
1658 if (!test_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) { in i40e_reset_all_vfs()
1659 reg = rd32(hw, I40E_VPGEN_VFRSTAT(vf->vf_id)); in i40e_reset_all_vfs()
1667 ++vf; in i40e_reset_all_vfs()
1677 if (vf < &pf->vf[pf->num_alloc_vfs]) in i40e_reset_all_vfs()
1679 vf->vf_id); in i40e_reset_all_vfs()
1685 for (vf = &pf->vf[0]; vf < &pf->vf[pf->num_alloc_vfs]; ++vf) { in i40e_reset_all_vfs()
1687 if (vf->lan_vsi_idx == 0) in i40e_reset_all_vfs()
1691 if (test_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) in i40e_reset_all_vfs()
1694 i40e_vsi_stop_rings_no_wait(pf->vsi[vf->lan_vsi_idx]); in i40e_reset_all_vfs()
1700 for (vf = &pf->vf[0]; vf < &pf->vf[pf->num_alloc_vfs]; ++vf) { in i40e_reset_all_vfs()
1702 if (vf->lan_vsi_idx == 0) in i40e_reset_all_vfs()
1706 if (test_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) in i40e_reset_all_vfs()
1709 i40e_vsi_wait_queues_disabled(pf->vsi[vf->lan_vsi_idx]); in i40e_reset_all_vfs()
1718 for (vf = &pf->vf[0]; vf < &pf->vf[pf->num_alloc_vfs]; ++vf) { in i40e_reset_all_vfs()
1720 if (test_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) in i40e_reset_all_vfs()
1723 i40e_cleanup_reset_vf(vf); in i40e_reset_all_vfs()
1745 if (!pf->vf) in i40e_free_vfs()
1765 if (test_bit(I40E_VF_STATE_INIT, &pf->vf[i].vf_states)) in i40e_free_vfs()
1768 i40e_vsi_stop_rings_no_wait(pf->vsi[pf->vf[i].lan_vsi_idx]); in i40e_free_vfs()
1772 if (test_bit(I40E_VF_STATE_INIT, &pf->vf[i].vf_states)) in i40e_free_vfs()
1775 i40e_vsi_wait_queues_disabled(pf->vsi[pf->vf[i].lan_vsi_idx]); in i40e_free_vfs()
1782 if (test_bit(I40E_VF_STATE_INIT, &pf->vf[i].vf_states)) in i40e_free_vfs()
1783 i40e_free_vf_res(&pf->vf[i]); in i40e_free_vfs()
1785 i40e_disable_vf_mappings(&pf->vf[i]); in i40e_free_vfs()
1788 kfree(pf->vf); in i40e_free_vfs()
1789 pf->vf = NULL; in i40e_free_vfs()
1840 pf->vf = vfs; in i40e_alloc_vfs()
1974 static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode, in i40e_vc_send_msg_to_vf() argument
1983 if (!vf || vf->vf_id >= vf->pf->num_alloc_vfs) in i40e_vc_send_msg_to_vf()
1986 pf = vf->pf; in i40e_vc_send_msg_to_vf()
1988 abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id; in i40e_vc_send_msg_to_vf()
1995 vf->vf_id, pf->hw.aq.asq_last_status); in i40e_vc_send_msg_to_vf()
2010 static int i40e_vc_send_resp_to_vf(struct i40e_vf *vf, in i40e_vc_send_resp_to_vf() argument
2014 return i40e_vc_send_msg_to_vf(vf, opcode, retval, NULL, 0); in i40e_vc_send_resp_to_vf()
2025 static bool i40e_sync_vf_state(struct i40e_vf *vf, enum i40e_vf_states state) in i40e_sync_vf_state() argument
2035 if (test_bit(state, &vf->vf_states)) in i40e_sync_vf_state()
2040 return test_bit(state, &vf->vf_states); in i40e_sync_vf_state()
2050 static int i40e_vc_get_version_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_get_version_msg() argument
2056 vf->vf_ver = *(struct virtchnl_version_info *)msg; in i40e_vc_get_version_msg()
2058 if (VF_IS_V10(&vf->vf_ver)) in i40e_vc_get_version_msg()
2060 return i40e_vc_send_msg_to_vf(vf, VIRTCHNL_OP_VERSION, in i40e_vc_get_version_msg()
2069 static void i40e_del_qch(struct i40e_vf *vf) in i40e_del_qch() argument
2071 struct i40e_pf *pf = vf->pf; in i40e_del_qch()
2077 for (i = 1; i < vf->num_tc; i++) { in i40e_del_qch()
2078 if (vf->ch[i].vsi_idx) { in i40e_del_qch()
2079 i40e_vsi_release(pf->vsi[vf->ch[i].vsi_idx]); in i40e_del_qch()
2080 vf->ch[i].vsi_idx = 0; in i40e_del_qch()
2081 vf->ch[i].vsi_id = 0; in i40e_del_qch()
2095 static u16 i40e_vc_get_max_frame_size(struct i40e_vf *vf) in i40e_vc_get_max_frame_size() argument
2097 u16 max_frame_size = vf->pf->hw.phy.link_info.max_frame_size; in i40e_vc_get_max_frame_size()
2099 if (vf->port_vlan_id) in i40e_vc_get_max_frame_size()
2112 static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_get_vf_resources_msg() argument
2115 struct i40e_pf *pf = vf->pf; in i40e_vc_get_vf_resources_msg()
2122 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_INIT)) { in i40e_vc_get_vf_resources_msg()
2134 if (VF_IS_V11(&vf->vf_ver)) in i40e_vc_get_vf_resources_msg()
2135 vf->driver_caps = *(u32 *)msg; in i40e_vc_get_vf_resources_msg()
2137 vf->driver_caps = VIRTCHNL_VF_OFFLOAD_L2 | in i40e_vc_get_vf_resources_msg()
2143 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_vc_get_vf_resources_msg()
2147 if (i40e_vf_client_capable(pf, vf->vf_id) && in i40e_vc_get_vf_resources_msg()
2148 (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_RDMA)) { in i40e_vc_get_vf_resources_msg()
2150 set_bit(I40E_VF_STATE_RDMAENA, &vf->vf_states); in i40e_vc_get_vf_resources_msg()
2152 clear_bit(I40E_VF_STATE_RDMAENA, &vf->vf_states); in i40e_vc_get_vf_resources_msg()
2155 if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_RSS_PF) { in i40e_vc_get_vf_resources_msg()
2159 (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_RSS_AQ)) in i40e_vc_get_vf_resources_msg()
2166 if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2) in i40e_vc_get_vf_resources_msg()
2171 if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_ENCAP) in i40e_vc_get_vf_resources_msg()
2175 (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM)) in i40e_vc_get_vf_resources_msg()
2178 if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_RX_POLLING) { in i40e_vc_get_vf_resources_msg()
2182 vf->vf_id); in i40e_vc_get_vf_resources_msg()
2190 if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) in i40e_vc_get_vf_resources_msg()
2195 if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_REQ_QUEUES) in i40e_vc_get_vf_resources_msg()
2198 if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_ADQ) in i40e_vc_get_vf_resources_msg()
2202 vfres->num_queue_pairs = vf->num_queue_pairs; in i40e_vc_get_vf_resources_msg()
2206 vfres->max_mtu = i40e_vc_get_max_frame_size(vf); in i40e_vc_get_vf_resources_msg()
2208 if (vf->lan_vsi_idx) { in i40e_vc_get_vf_resources_msg()
2209 vfres->vsi_res[0].vsi_id = vf->lan_vsi_id; in i40e_vc_get_vf_resources_msg()
2215 if (!(vf->driver_caps & VIRTCHNL_VF_OFFLOAD_USO) && !vf->pf_set_mac) { in i40e_vc_get_vf_resources_msg()
2217 i40e_del_mac_filter(vsi, vf->default_lan_addr.addr); in i40e_vc_get_vf_resources_msg()
2218 eth_zero_addr(vf->default_lan_addr.addr); in i40e_vc_get_vf_resources_msg()
2222 vf->default_lan_addr.addr); in i40e_vc_get_vf_resources_msg()
2224 set_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states); in i40e_vc_get_vf_resources_msg()
2228 ret = i40e_vc_send_msg_to_vf(vf, VIRTCHNL_OP_GET_VF_RESOURCES, in i40e_vc_get_vf_resources_msg()
2243 static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_config_promiscuous_mode_msg() argument
2247 struct i40e_pf *pf = vf->pf; in i40e_vc_config_promiscuous_mode_msg()
2252 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_config_promiscuous_mode_msg()
2256 if (!test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) { in i40e_vc_config_promiscuous_mode_msg()
2259 vf->vf_id); in i40e_vc_config_promiscuous_mode_msg()
2273 if (!i40e_vc_isvalid_vsi_id(vf, info->vsi_id)) { in i40e_vc_config_promiscuous_mode_msg()
2284 aq_ret = i40e_config_vf_promiscuous_mode(vf, info->vsi_id, allmulti, in i40e_vc_config_promiscuous_mode_msg()
2291 &vf->vf_states)) in i40e_vc_config_promiscuous_mode_msg()
2294 vf->vf_id); in i40e_vc_config_promiscuous_mode_msg()
2296 &vf->vf_states)) in i40e_vc_config_promiscuous_mode_msg()
2299 vf->vf_id); in i40e_vc_config_promiscuous_mode_msg()
2303 &vf->vf_states)) in i40e_vc_config_promiscuous_mode_msg()
2306 vf->vf_id); in i40e_vc_config_promiscuous_mode_msg()
2308 &vf->vf_states)) in i40e_vc_config_promiscuous_mode_msg()
2311 vf->vf_id); in i40e_vc_config_promiscuous_mode_msg()
2315 return i40e_vc_send_resp_to_vf(vf, in i40e_vc_config_promiscuous_mode_msg()
2328 static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_config_queues_msg() argument
2334 struct i40e_pf *pf = vf->pf; in i40e_vc_config_queues_msg()
2340 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_config_queues_msg()
2345 if (!i40e_vc_isvalid_vsi_id(vf, qci->vsi_id)) { in i40e_vc_config_queues_msg()
2355 if (vf->adq_enabled) { in i40e_vc_config_queues_msg()
2356 for (i = 0; i < vf->num_tc; i++) in i40e_vc_config_queues_msg()
2357 num_qps_all += vf->ch[i].num_qps; in i40e_vc_config_queues_msg()
2369 if (!vf->adq_enabled) { in i40e_vc_config_queues_msg()
2370 if (!i40e_vc_isvalid_queue_id(vf, vsi_id, in i40e_vc_config_queues_msg()
2386 if (vf->adq_enabled) { in i40e_vc_config_queues_msg()
2387 if (idx >= ARRAY_SIZE(vf->ch)) { in i40e_vc_config_queues_msg()
2391 vsi_id = vf->ch[idx].vsi_id; in i40e_vc_config_queues_msg()
2394 if (i40e_config_vsi_rx_queue(vf, vsi_id, vsi_queue_id, in i40e_vc_config_queues_msg()
2396 i40e_config_vsi_tx_queue(vf, vsi_id, vsi_queue_id, in i40e_vc_config_queues_msg()
2407 if (vf->adq_enabled) { in i40e_vc_config_queues_msg()
2408 if (idx >= ARRAY_SIZE(vf->ch)) { in i40e_vc_config_queues_msg()
2412 if (j == (vf->ch[idx].num_qps - 1)) { in i40e_vc_config_queues_msg()
2423 if (!vf->adq_enabled) { in i40e_vc_config_queues_msg()
2424 pf->vsi[vf->lan_vsi_idx]->num_queue_pairs = in i40e_vc_config_queues_msg()
2427 for (i = 0; i < vf->num_tc; i++) { in i40e_vc_config_queues_msg()
2428 vsi = pf->vsi[vf->ch[i].vsi_idx]; in i40e_vc_config_queues_msg()
2429 vsi->num_queue_pairs = vf->ch[i].num_qps; in i40e_vc_config_queues_msg()
2440 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES, in i40e_vc_config_queues_msg()
2452 static int i40e_validate_queue_map(struct i40e_vf *vf, u16 vsi_id, in i40e_validate_queue_map() argument
2458 if (vf->adq_enabled) { in i40e_validate_queue_map()
2459 vsi_id = vf->ch[vsi_queue_id / I40E_MAX_VF_VSI].vsi_id; in i40e_validate_queue_map()
2465 if (!i40e_vc_isvalid_queue_id(vf, vsi_id, queue_id)) in i40e_validate_queue_map()
2480 static int i40e_vc_config_irq_map_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_config_irq_map_msg() argument
2489 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_config_irq_map_msg()
2495 vf->pf->hw.func_caps.num_msix_vectors_vf) { in i40e_vc_config_irq_map_msg()
2503 if (!i40e_vc_isvalid_vector_id(vf, map->vector_id) || in i40e_vc_config_irq_map_msg()
2504 !i40e_vc_isvalid_vsi_id(vf, map->vsi_id)) { in i40e_vc_config_irq_map_msg()
2510 if (i40e_validate_queue_map(vf, vsi_id, map->rxq_map)) { in i40e_vc_config_irq_map_msg()
2515 if (i40e_validate_queue_map(vf, vsi_id, map->txq_map)) { in i40e_vc_config_irq_map_msg()
2520 i40e_config_irq_link_list(vf, vsi_id, map); in i40e_vc_config_irq_map_msg()
2524 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_CONFIG_IRQ_MAP, in i40e_vc_config_irq_map_msg()
2596 static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_enable_queues_msg() argument
2600 struct i40e_pf *pf = vf->pf; in i40e_vc_enable_queues_msg()
2604 if (vf->is_disabled_from_host) { in i40e_vc_enable_queues_msg()
2608 vf->vf_id); in i40e_vc_enable_queues_msg()
2612 if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { in i40e_vc_enable_queues_msg()
2617 if (!i40e_vc_isvalid_vsi_id(vf, vqs->vsi_id)) { in i40e_vc_enable_queues_msg()
2628 if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx], vqs->rx_queues, in i40e_vc_enable_queues_msg()
2633 if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx], vqs->tx_queues, in i40e_vc_enable_queues_msg()
2640 if (vf->adq_enabled) { in i40e_vc_enable_queues_msg()
2642 for (i = 1; i < vf->num_tc; i++) { in i40e_vc_enable_queues_msg()
2643 if (i40e_vsi_start_rings(pf->vsi[vf->ch[i].vsi_idx])) in i40e_vc_enable_queues_msg()
2650 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_ENABLE_QUEUES, in i40e_vc_enable_queues_msg()
2662 static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_disable_queues_msg() argument
2666 struct i40e_pf *pf = vf->pf; in i40e_vc_disable_queues_msg()
2669 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_disable_queues_msg()
2674 if (!i40e_vc_isvalid_vsi_id(vf, vqs->vsi_id)) { in i40e_vc_disable_queues_msg()
2685 if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx], vqs->tx_queues, in i40e_vc_disable_queues_msg()
2690 if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx], vqs->rx_queues, in i40e_vc_disable_queues_msg()
2697 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DISABLE_QUEUES, in i40e_vc_disable_queues_msg()
2708 static int i40e_check_enough_queue(struct i40e_vf *vf, u16 needed) in i40e_check_enough_queue() argument
2712 struct i40e_pf *pf = vf->pf; in i40e_check_enough_queue()
2715 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_check_enough_queue()
2764 static int i40e_vc_request_queues_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_request_queues_msg() argument
2769 u8 cur_pairs = vf->num_queue_pairs; in i40e_vc_request_queues_msg()
2770 struct i40e_pf *pf = vf->pf; in i40e_vc_request_queues_msg()
2772 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) in i40e_vc_request_queues_msg()
2778 vf->vf_id, in i40e_vc_request_queues_msg()
2784 vf->vf_id, in i40e_vc_request_queues_msg()
2788 } else if (i40e_check_enough_queue(vf, req_pairs) < 0) { in i40e_vc_request_queues_msg()
2791 vf->vf_id, in i40e_vc_request_queues_msg()
2796 vf->num_req_queues = req_pairs; in i40e_vc_request_queues_msg()
2797 i40e_vc_reset_vf(vf, true); in i40e_vc_request_queues_msg()
2801 return i40e_vc_send_msg_to_vf(vf, VIRTCHNL_OP_REQUEST_QUEUES, 0, in i40e_vc_request_queues_msg()
2812 static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_get_stats_msg() argument
2816 struct i40e_pf *pf = vf->pf; in i40e_vc_get_stats_msg()
2823 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_get_stats_msg()
2828 if (!i40e_vc_isvalid_vsi_id(vf, vqs->vsi_id)) { in i40e_vc_get_stats_msg()
2833 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_vc_get_stats_msg()
2843 return i40e_vc_send_msg_to_vf(vf, VIRTCHNL_OP_GET_STATS, aq_ret, in i40e_vc_get_stats_msg()
2853 static bool i40e_can_vf_change_mac(struct i40e_vf *vf) in i40e_can_vf_change_mac() argument
2859 if (vf->pf_set_mac && !vf->trusted) in i40e_can_vf_change_mac()
2897 static inline int i40e_check_vf_permission(struct i40e_vf *vf, in i40e_check_vf_permission() argument
2900 struct i40e_pf *pf = vf->pf; in i40e_check_vf_permission()
2901 struct i40e_vsi *vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_check_vf_permission()
2924 if (!i40e_can_vf_change_mac(vf) && in i40e_check_vf_permission()
2926 !ether_addr_equal(addr, vf->default_lan_addr.addr)) { in i40e_check_vf_permission()
2942 if (!test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) { in i40e_check_vf_permission()
3012 i40e_update_vf_mac_addr(struct i40e_vf *vf, in i40e_update_vf_mac_addr() argument
3025 ether_addr_copy(vf->default_lan_addr.addr, mac_addr); in i40e_update_vf_mac_addr()
3027 if (is_zero_ether_addr(vf->default_lan_addr.addr)) in i40e_update_vf_mac_addr()
3028 ether_addr_copy(vf->default_lan_addr.addr, mac_addr); in i40e_update_vf_mac_addr()
3039 static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_add_mac_addr_msg() argument
3043 struct i40e_pf *pf = vf->pf; in i40e_vc_add_mac_addr_msg()
3048 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) || in i40e_vc_add_mac_addr_msg()
3049 !i40e_vc_isvalid_vsi_id(vf, al->vsi_id)) { in i40e_vc_add_mac_addr_msg()
3054 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_vc_add_mac_addr_msg()
3061 ret = i40e_check_vf_permission(vf, al); in i40e_vc_add_mac_addr_msg()
3078 al->list[i].addr, vf->vf_id); in i40e_vc_add_mac_addr_msg()
3084 i40e_update_vf_mac_addr(vf, &al->list[i]); in i40e_vc_add_mac_addr_msg()
3092 vf->vf_id, ret); in i40e_vc_add_mac_addr_msg()
3096 return i40e_vc_send_msg_to_vf(vf, VIRTCHNL_OP_ADD_ETH_ADDR, in i40e_vc_add_mac_addr_msg()
3107 static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_del_mac_addr_msg() argument
3112 struct i40e_pf *pf = vf->pf; in i40e_vc_del_mac_addr_msg()
3117 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) || in i40e_vc_del_mac_addr_msg()
3118 !i40e_vc_isvalid_vsi_id(vf, al->vsi_id)) { in i40e_vc_del_mac_addr_msg()
3127 al->list[i].addr, vf->vf_id); in i40e_vc_del_mac_addr_msg()
3132 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_vc_del_mac_addr_msg()
3142 if (ether_addr_equal(addr, vf->default_lan_addr.addr)) { in i40e_vc_del_mac_addr_msg()
3143 if (i40e_can_vf_change_mac(vf)) in i40e_vc_del_mac_addr_msg()
3159 eth_zero_addr(vf->default_lan_addr.addr); in i40e_vc_del_mac_addr_msg()
3165 vf->vf_id, ret); in i40e_vc_del_mac_addr_msg()
3167 if (vf->trusted && was_unimac_deleted) { in i40e_vc_del_mac_addr_msg()
3180 ether_addr_copy(vf->default_lan_addr.addr, macaddr); in i40e_vc_del_mac_addr_msg()
3185 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DEL_ETH_ADDR, ret); in i40e_vc_del_mac_addr_msg()
3195 static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_add_vlan_msg() argument
3199 struct i40e_pf *pf = vf->pf; in i40e_vc_add_vlan_msg()
3204 if ((vf->num_vlan >= I40E_VC_MAX_VLAN_PER_VF) && in i40e_vc_add_vlan_msg()
3205 !test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) { in i40e_vc_add_vlan_msg()
3210 if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) || in i40e_vc_add_vlan_msg()
3211 !i40e_vc_isvalid_vsi_id(vf, vfl->vsi_id)) { in i40e_vc_add_vlan_msg()
3224 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_vc_add_vlan_msg()
3235 vf->num_vlan++; in i40e_vc_add_vlan_msg()
3237 if (test_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states)) in i40e_vc_add_vlan_msg()
3242 if (test_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states)) in i40e_vc_add_vlan_msg()
3251 vfl->vlan_id[i], vf->vf_id, ret); in i40e_vc_add_vlan_msg()
3256 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_ADD_VLAN, aq_ret); in i40e_vc_add_vlan_msg()
3266 static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_remove_vlan_msg() argument
3270 struct i40e_pf *pf = vf->pf; in i40e_vc_remove_vlan_msg()
3275 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) || in i40e_vc_remove_vlan_msg()
3276 !i40e_vc_isvalid_vsi_id(vf, vfl->vsi_id)) { in i40e_vc_remove_vlan_msg()
3288 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_vc_remove_vlan_msg()
3297 vf->num_vlan--; in i40e_vc_remove_vlan_msg()
3299 if (test_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states)) in i40e_vc_remove_vlan_msg()
3304 if (test_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states)) in i40e_vc_remove_vlan_msg()
3313 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DEL_VLAN, aq_ret); in i40e_vc_remove_vlan_msg()
3324 static int i40e_vc_rdma_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) in i40e_vc_rdma_msg() argument
3326 struct i40e_pf *pf = vf->pf; in i40e_vc_rdma_msg()
3331 if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) || in i40e_vc_rdma_msg()
3332 !test_bit(I40E_VF_STATE_RDMAENA, &vf->vf_states)) { in i40e_vc_rdma_msg()
3338 abs_vf_id = vf->vf_id + pf->hw.func_caps.vf_base_id; in i40e_vc_rdma_msg()
3343 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_RDMA, in i40e_vc_rdma_msg()
3355 static int i40e_vc_rdma_qvmap_msg(struct i40e_vf *vf, u8 *msg, bool config) in i40e_vc_rdma_qvmap_msg() argument
3361 if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) || in i40e_vc_rdma_qvmap_msg()
3362 !test_bit(I40E_VF_STATE_RDMAENA, &vf->vf_states)) { in i40e_vc_rdma_qvmap_msg()
3368 if (i40e_config_rdma_qvlist(vf, qvlist_info)) in i40e_vc_rdma_qvmap_msg()
3371 i40e_release_rdma_qvlist(vf); in i40e_vc_rdma_qvmap_msg()
3376 return i40e_vc_send_resp_to_vf(vf, in i40e_vc_rdma_qvmap_msg()
3389 static int i40e_vc_config_rss_key(struct i40e_vf *vf, u8 *msg) in i40e_vc_config_rss_key() argument
3393 struct i40e_pf *pf = vf->pf; in i40e_vc_config_rss_key()
3397 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) || in i40e_vc_config_rss_key()
3398 !i40e_vc_isvalid_vsi_id(vf, vrk->vsi_id) || in i40e_vc_config_rss_key()
3404 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_vc_config_rss_key()
3408 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_CONFIG_RSS_KEY, in i40e_vc_config_rss_key()
3419 static int i40e_vc_config_rss_lut(struct i40e_vf *vf, u8 *msg) in i40e_vc_config_rss_lut() argument
3423 struct i40e_pf *pf = vf->pf; in i40e_vc_config_rss_lut()
3428 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) || in i40e_vc_config_rss_lut()
3429 !i40e_vc_isvalid_vsi_id(vf, vrl->vsi_id) || in i40e_vc_config_rss_lut()
3436 if (vrl->lut[i] >= vf->num_queue_pairs) { in i40e_vc_config_rss_lut()
3441 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_vc_config_rss_lut()
3445 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_CONFIG_RSS_LUT, in i40e_vc_config_rss_lut()
3456 static int i40e_vc_get_rss_hena(struct i40e_vf *vf, u8 *msg) in i40e_vc_get_rss_hena() argument
3459 struct i40e_pf *pf = vf->pf; in i40e_vc_get_rss_hena()
3463 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_get_rss_hena()
3478 aq_ret = i40e_vc_send_msg_to_vf(vf, VIRTCHNL_OP_GET_RSS_HENA_CAPS, in i40e_vc_get_rss_hena()
3491 static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg) in i40e_vc_set_rss_hena() argument
3495 struct i40e_pf *pf = vf->pf; in i40e_vc_set_rss_hena()
3499 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_set_rss_hena()
3503 i40e_write_rx_ctl(hw, I40E_VFQF_HENA1(0, vf->vf_id), (u32)vrh->hena); in i40e_vc_set_rss_hena()
3504 i40e_write_rx_ctl(hw, I40E_VFQF_HENA1(1, vf->vf_id), in i40e_vc_set_rss_hena()
3509 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_SET_RSS_HENA, aq_ret); in i40e_vc_set_rss_hena()
3519 static int i40e_vc_enable_vlan_stripping(struct i40e_vf *vf, u8 *msg) in i40e_vc_enable_vlan_stripping() argument
3524 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_enable_vlan_stripping()
3529 vsi = vf->pf->vsi[vf->lan_vsi_idx]; in i40e_vc_enable_vlan_stripping()
3534 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING, in i40e_vc_enable_vlan_stripping()
3545 static int i40e_vc_disable_vlan_stripping(struct i40e_vf *vf, u8 *msg) in i40e_vc_disable_vlan_stripping() argument
3550 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_disable_vlan_stripping()
3555 vsi = vf->pf->vsi[vf->lan_vsi_idx]; in i40e_vc_disable_vlan_stripping()
3560 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING, in i40e_vc_disable_vlan_stripping()
3571 static int i40e_validate_cloud_filter(struct i40e_vf *vf, in i40e_validate_cloud_filter() argument
3576 struct i40e_pf *pf = vf->pf; in i40e_validate_cloud_filter()
3586 vf->vf_id, tc_filter->action); in i40e_validate_cloud_filter()
3592 tc_filter->action_meta > vf->num_tc) { in i40e_validate_cloud_filter()
3594 vf->vf_id, tc_filter->action_meta); in i40e_validate_cloud_filter()
3608 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_validate_cloud_filter()
3614 data.dst_mac, vf->vf_id); in i40e_validate_cloud_filter()
3629 vf->vf_id, ntohs(data.vlan_id)); in i40e_validate_cloud_filter()
3635 if (!test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) { in i40e_validate_cloud_filter()
3638 vf->vf_id); in i40e_validate_cloud_filter()
3647 vf->vf_id, data.dst_mac); in i40e_validate_cloud_filter()
3656 vf->vf_id, data.src_mac); in i40e_validate_cloud_filter()
3664 vf->vf_id); in i40e_validate_cloud_filter()
3672 vf->vf_id); in i40e_validate_cloud_filter()
3680 vf->vf_id); in i40e_validate_cloud_filter()
3687 vf->vf_id); in i40e_validate_cloud_filter()
3702 static struct i40e_vsi *i40e_find_vsi_from_seid(struct i40e_vf *vf, u16 seid) in i40e_find_vsi_from_seid() argument
3704 struct i40e_pf *pf = vf->pf; in i40e_find_vsi_from_seid()
3708 for (i = 0; i < vf->num_tc ; i++) { in i40e_find_vsi_from_seid()
3709 vsi = i40e_find_vsi_from_id(pf, vf->ch[i].vsi_id); in i40e_find_vsi_from_seid()
3722 static void i40e_del_all_cloud_filters(struct i40e_vf *vf) in i40e_del_all_cloud_filters() argument
3725 struct i40e_pf *pf = vf->pf; in i40e_del_all_cloud_filters()
3731 &vf->cloud_filter_list, cloud_node) { in i40e_del_all_cloud_filters()
3732 vsi = i40e_find_vsi_from_seid(vf, cfilter->seid); in i40e_del_all_cloud_filters()
3736 vf->vf_id, cfilter->seid); in i40e_del_all_cloud_filters()
3748 vf->vf_id, ERR_PTR(ret), in i40e_del_all_cloud_filters()
3754 vf->num_cloud_filters--; in i40e_del_all_cloud_filters()
3765 static int i40e_vc_del_cloud_filter(struct i40e_vf *vf, u8 *msg) in i40e_vc_del_cloud_filter() argument
3771 struct i40e_pf *pf = vf->pf; in i40e_vc_del_cloud_filter()
3777 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_del_cloud_filter()
3782 if (!vf->adq_enabled) { in i40e_vc_del_cloud_filter()
3785 vf->vf_id); in i40e_vc_del_cloud_filter()
3790 if (i40e_validate_cloud_filter(vf, vcf)) { in i40e_vc_del_cloud_filter()
3793 vf->vf_id); in i40e_vc_del_cloud_filter()
3835 vf->vf_id); in i40e_vc_del_cloud_filter()
3839 vsi = pf->vsi[vf->ch[vcf->action_meta].vsi_idx]; in i40e_vc_del_cloud_filter()
3851 vf->vf_id, ERR_PTR(ret), in i40e_vc_del_cloud_filter()
3857 &vf->cloud_filter_list, cloud_node) { in i40e_vc_del_cloud_filter()
3882 vf->num_cloud_filters--; in i40e_vc_del_cloud_filter()
3886 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DEL_CLOUD_FILTER, in i40e_vc_del_cloud_filter()
3897 static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg) in i40e_vc_add_cloud_filter() argument
3903 struct i40e_pf *pf = vf->pf; in i40e_vc_add_cloud_filter()
3908 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_add_cloud_filter()
3913 if (!vf->adq_enabled) { in i40e_vc_add_cloud_filter()
3916 vf->vf_id); in i40e_vc_add_cloud_filter()
3921 if (i40e_validate_cloud_filter(vf, vcf)) { in i40e_vc_add_cloud_filter()
3924 vf->vf_id); in i40e_vc_add_cloud_filter()
3971 vf->vf_id); in i40e_vc_add_cloud_filter()
3975 vsi = pf->vsi[vf->ch[vcf->action_meta].vsi_idx]; in i40e_vc_add_cloud_filter()
3987 vf->vf_id, ERR_PTR(aq_ret), in i40e_vc_add_cloud_filter()
3993 hlist_add_head(&cfilter->cloud_node, &vf->cloud_filter_list); in i40e_vc_add_cloud_filter()
3996 vf->num_cloud_filters++; in i40e_vc_add_cloud_filter()
4000 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_ADD_CLOUD_FILTER, in i40e_vc_add_cloud_filter()
4009 static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_add_qch_msg() argument
4013 struct i40e_pf *pf = vf->pf; in i40e_vc_add_qch_msg()
4019 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_add_qch_msg()
4025 if (vf->spoofchk) { in i40e_vc_add_qch_msg()
4032 if (!(vf->driver_caps & VIRTCHNL_VF_OFFLOAD_ADQ)) { in i40e_vc_add_qch_msg()
4035 vf->vf_id); in i40e_vc_add_qch_msg()
4044 vf->vf_id, tci->num_tc, I40E_MAX_VF_VSI); in i40e_vc_add_qch_msg()
4055 vf->vf_id, i, tci->list[i].count, in i40e_vc_add_qch_msg()
4067 vf->vf_id); in i40e_vc_add_qch_msg()
4075 vf->num_queue_pairs = I40E_MAX_VF_QUEUES; in i40e_vc_add_qch_msg()
4088 vf->num_tc = tci->num_tc; in i40e_vc_add_qch_msg()
4089 for (i = 0; i < vf->num_tc; i++) { in i40e_vc_add_qch_msg()
4095 vf->vf_id); in i40e_vc_add_qch_msg()
4099 vf->ch[i].max_tx_rate = in i40e_vc_add_qch_msg()
4103 vf->ch[i].num_qps = tci->list[i].count; in i40e_vc_add_qch_msg()
4107 vf->adq_enabled = true; in i40e_vc_add_qch_msg()
4110 i40e_vc_reset_vf(vf, true); in i40e_vc_add_qch_msg()
4116 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_ENABLE_CHANNELS, in i40e_vc_add_qch_msg()
4125 static int i40e_vc_del_qch_msg(struct i40e_vf *vf, u8 *msg) in i40e_vc_del_qch_msg() argument
4127 struct i40e_pf *pf = vf->pf; in i40e_vc_del_qch_msg()
4130 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { in i40e_vc_del_qch_msg()
4135 if (vf->adq_enabled) { in i40e_vc_del_qch_msg()
4136 i40e_del_all_cloud_filters(vf); in i40e_vc_del_qch_msg()
4137 i40e_del_qch(vf); in i40e_vc_del_qch_msg()
4138 vf->adq_enabled = false; in i40e_vc_del_qch_msg()
4139 vf->num_tc = 0; in i40e_vc_del_qch_msg()
4142 vf->vf_id); in i40e_vc_del_qch_msg()
4145 vf->vf_id); in i40e_vc_del_qch_msg()
4150 i40e_vc_reset_vf(vf, true); in i40e_vc_del_qch_msg()
4155 return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DISABLE_CHANNELS, in i40e_vc_del_qch_msg()
4176 struct i40e_vf *vf; in i40e_vc_process_vf_msg() local
4182 vf = &(pf->vf[local_vf_id]); in i40e_vc_process_vf_msg()
4185 if (test_bit(I40E_VF_STATE_DISABLED, &vf->vf_states)) in i40e_vc_process_vf_msg()
4189 ret = virtchnl_vc_validate_vf_msg(&vf->vf_ver, v_opcode, msg, msglen); in i40e_vc_process_vf_msg()
4192 i40e_vc_send_resp_to_vf(vf, v_opcode, -EINVAL); in i40e_vc_process_vf_msg()
4200 ret = i40e_vc_get_version_msg(vf, msg); in i40e_vc_process_vf_msg()
4203 ret = i40e_vc_get_vf_resources_msg(vf, msg); in i40e_vc_process_vf_msg()
4204 i40e_vc_notify_vf_link_state(vf); in i40e_vc_process_vf_msg()
4207 i40e_vc_reset_vf(vf, false); in i40e_vc_process_vf_msg()
4211 ret = i40e_vc_config_promiscuous_mode_msg(vf, msg); in i40e_vc_process_vf_msg()
4214 ret = i40e_vc_config_queues_msg(vf, msg); in i40e_vc_process_vf_msg()
4217 ret = i40e_vc_config_irq_map_msg(vf, msg); in i40e_vc_process_vf_msg()
4220 ret = i40e_vc_enable_queues_msg(vf, msg); in i40e_vc_process_vf_msg()
4221 i40e_vc_notify_vf_link_state(vf); in i40e_vc_process_vf_msg()
4224 ret = i40e_vc_disable_queues_msg(vf, msg); in i40e_vc_process_vf_msg()
4227 ret = i40e_vc_add_mac_addr_msg(vf, msg); in i40e_vc_process_vf_msg()
4230 ret = i40e_vc_del_mac_addr_msg(vf, msg); in i40e_vc_process_vf_msg()
4233 ret = i40e_vc_add_vlan_msg(vf, msg); in i40e_vc_process_vf_msg()
4236 ret = i40e_vc_remove_vlan_msg(vf, msg); in i40e_vc_process_vf_msg()
4239 ret = i40e_vc_get_stats_msg(vf, msg); in i40e_vc_process_vf_msg()
4242 ret = i40e_vc_rdma_msg(vf, msg, msglen); in i40e_vc_process_vf_msg()
4245 ret = i40e_vc_rdma_qvmap_msg(vf, msg, true); in i40e_vc_process_vf_msg()
4248 ret = i40e_vc_rdma_qvmap_msg(vf, msg, false); in i40e_vc_process_vf_msg()
4251 ret = i40e_vc_config_rss_key(vf, msg); in i40e_vc_process_vf_msg()
4254 ret = i40e_vc_config_rss_lut(vf, msg); in i40e_vc_process_vf_msg()
4257 ret = i40e_vc_get_rss_hena(vf, msg); in i40e_vc_process_vf_msg()
4260 ret = i40e_vc_set_rss_hena(vf, msg); in i40e_vc_process_vf_msg()
4263 ret = i40e_vc_enable_vlan_stripping(vf, msg); in i40e_vc_process_vf_msg()
4266 ret = i40e_vc_disable_vlan_stripping(vf, msg); in i40e_vc_process_vf_msg()
4269 ret = i40e_vc_request_queues_msg(vf, msg); in i40e_vc_process_vf_msg()
4272 ret = i40e_vc_add_qch_msg(vf, msg); in i40e_vc_process_vf_msg()
4275 ret = i40e_vc_del_qch_msg(vf, msg); in i40e_vc_process_vf_msg()
4278 ret = i40e_vc_add_cloud_filter(vf, msg); in i40e_vc_process_vf_msg()
4281 ret = i40e_vc_del_cloud_filter(vf, msg); in i40e_vc_process_vf_msg()
4287 ret = i40e_vc_send_resp_to_vf(vf, v_opcode, in i40e_vc_process_vf_msg()
4306 struct i40e_vf *vf; in i40e_vc_process_vflr_event() local
4327 vf = &pf->vf[vf_id]; in i40e_vc_process_vflr_event()
4331 i40e_reset_vf(vf, true); in i40e_vc_process_vflr_event()
4349 struct i40e_vf *vf; in i40e_validate_vf() local
4358 vf = &pf->vf[vf_id]; in i40e_validate_vf()
4359 vsi = i40e_find_vsi_from_id(pf, vf->lan_vsi_id); in i40e_validate_vf()
4375 static bool i40e_check_vf_init_timeout(struct i40e_vf *vf) in i40e_check_vf_init_timeout() argument
4384 if (test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) in i40e_check_vf_init_timeout()
4389 if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) { in i40e_check_vf_init_timeout()
4390 dev_err(&vf->pf->pdev->dev, in i40e_check_vf_init_timeout()
4391 "VF %d still in reset. Try again.\n", vf->vf_id); in i40e_check_vf_init_timeout()
4412 struct i40e_vf *vf; in i40e_ndo_set_vf_mac() local
4427 vf = &pf->vf[vf_id]; in i40e_ndo_set_vf_mac()
4428 if (!i40e_check_vf_init_timeout(vf)) { in i40e_ndo_set_vf_mac()
4432 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_ndo_set_vf_mac()
4447 if (!is_zero_ether_addr(vf->default_lan_addr.addr)) in i40e_ndo_set_vf_mac()
4448 i40e_del_mac_filter(vsi, vf->default_lan_addr.addr); in i40e_ndo_set_vf_mac()
4464 ether_addr_copy(vf->default_lan_addr.addr, mac); in i40e_ndo_set_vf_mac()
4467 vf->pf_set_mac = false; in i40e_ndo_set_vf_mac()
4470 vf->pf_set_mac = true; in i40e_ndo_set_vf_mac()
4478 i40e_vc_reset_vf(vf, true); in i40e_ndo_set_vf_mac()
4504 struct i40e_vf *vf; in i40e_ndo_set_vf_port_vlan() local
4529 vf = &pf->vf[vf_id]; in i40e_ndo_set_vf_port_vlan()
4530 if (!i40e_check_vf_init_timeout(vf)) { in i40e_ndo_set_vf_port_vlan()
4534 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_ndo_set_vf_port_vlan()
4575 ret = i40e_config_vf_promiscuous_mode(vf, vf->lan_vsi_id, in i40e_ndo_set_vf_port_vlan()
4608 if (test_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states)) in i40e_ndo_set_vf_port_vlan()
4611 if (test_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states)) in i40e_ndo_set_vf_port_vlan()
4625 vf->port_vlan_id = le16_to_cpu(vsi->info.pvid); in i40e_ndo_set_vf_port_vlan()
4627 i40e_vc_reset_vf(vf, true); in i40e_ndo_set_vf_port_vlan()
4629 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_ndo_set_vf_port_vlan()
4631 ret = i40e_config_vf_promiscuous_mode(vf, vsi->id, allmulti, alluni); in i40e_ndo_set_vf_port_vlan()
4659 struct i40e_vf *vf; in i40e_ndo_set_vf_bw() local
4679 vf = &pf->vf[vf_id]; in i40e_ndo_set_vf_bw()
4680 if (!i40e_check_vf_init_timeout(vf)) { in i40e_ndo_set_vf_bw()
4684 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_ndo_set_vf_bw()
4690 vf->tx_rate = max_tx_rate; in i40e_ndo_set_vf_bw()
4710 struct i40e_vf *vf; in i40e_ndo_get_vf_config() local
4723 vf = &pf->vf[vf_id]; in i40e_ndo_get_vf_config()
4725 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_ndo_get_vf_config()
4731 ivi->vf = vf_id; in i40e_ndo_get_vf_config()
4733 ether_addr_copy(ivi->mac, vf->default_lan_addr.addr); in i40e_ndo_get_vf_config()
4735 ivi->max_tx_rate = vf->tx_rate; in i40e_ndo_get_vf_config()
4739 if (vf->link_forced == false) in i40e_ndo_get_vf_config()
4741 else if (vf->link_up == true) in i40e_ndo_get_vf_config()
4745 ivi->spoofchk = vf->spoofchk; in i40e_ndo_get_vf_config()
4746 ivi->trusted = vf->trusted; in i40e_ndo_get_vf_config()
4771 struct i40e_vf *vf; in i40e_ndo_set_vf_link_state() local
4788 vf = &pf->vf[vf_id]; in i40e_ndo_set_vf_link_state()
4789 abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id; in i40e_ndo_set_vf_link_state()
4796 vf->link_forced = false; in i40e_ndo_set_vf_link_state()
4797 vf->is_disabled_from_host = false; in i40e_ndo_set_vf_link_state()
4799 i40e_vc_reset_vf(vf, true); in i40e_ndo_set_vf_link_state()
4800 i40e_set_vf_link_state(vf, &pfe, ls); in i40e_ndo_set_vf_link_state()
4803 vf->link_forced = true; in i40e_ndo_set_vf_link_state()
4804 vf->link_up = true; in i40e_ndo_set_vf_link_state()
4805 vf->is_disabled_from_host = false; in i40e_ndo_set_vf_link_state()
4807 i40e_vc_reset_vf(vf, true); in i40e_ndo_set_vf_link_state()
4808 i40e_set_vf_link_state(vf, &pfe, ls); in i40e_ndo_set_vf_link_state()
4811 vf->link_forced = true; in i40e_ndo_set_vf_link_state()
4812 vf->link_up = false; in i40e_ndo_set_vf_link_state()
4813 i40e_set_vf_link_state(vf, &pfe, ls); in i40e_ndo_set_vf_link_state()
4815 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_ndo_set_vf_link_state()
4818 vf->is_disabled_from_host = true; in i40e_ndo_set_vf_link_state()
4858 struct i40e_vf *vf; in i40e_ndo_set_vf_spoofchk() local
4873 vf = &(pf->vf[vf_id]); in i40e_ndo_set_vf_spoofchk()
4874 if (!i40e_check_vf_init_timeout(vf)) { in i40e_ndo_set_vf_spoofchk()
4879 if (enable == vf->spoofchk) in i40e_ndo_set_vf_spoofchk()
4882 vf->spoofchk = enable; in i40e_ndo_set_vf_spoofchk()
4884 ctxt.seid = pf->vsi[vf->lan_vsi_idx]->seid; in i40e_ndo_set_vf_spoofchk()
4913 struct i40e_vf *vf; in i40e_ndo_set_vf_trust() local
4934 vf = &pf->vf[vf_id]; in i40e_ndo_set_vf_trust()
4936 if (setting == vf->trusted) in i40e_ndo_set_vf_trust()
4939 vf->trusted = setting; in i40e_ndo_set_vf_trust()
4943 pf->vsi[vf->lan_vsi_idx]->flags |= I40E_VSI_FLAG_FILTER_CHANGED; in i40e_ndo_set_vf_trust()
4945 i40e_vc_reset_vf(vf, true); in i40e_ndo_set_vf_trust()
4949 if (vf->adq_enabled) { in i40e_ndo_set_vf_trust()
4950 if (!vf->trusted) { in i40e_ndo_set_vf_trust()
4954 i40e_del_all_cloud_filters(vf); in i40e_ndo_set_vf_trust()
4976 struct i40e_vf *vf; in i40e_get_vf_stats() local
4982 vf = &pf->vf[vf_id]; in i40e_get_vf_stats()
4983 if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) { in i40e_get_vf_stats()
4988 vsi = pf->vsi[vf->lan_vsi_idx]; in i40e_get_vf_stats()