aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e.h1
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c16
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c110
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h2
4 files changed, 76 insertions, 53 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index 1c8bd7c152c2..33c35d3b7420 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -628,6 +628,7 @@ extern const char i40e_driver_name[];
628extern const char i40e_driver_version_str[]; 628extern const char i40e_driver_version_str[];
629void i40e_do_reset_safe(struct i40e_pf *pf, u32 reset_flags); 629void i40e_do_reset_safe(struct i40e_pf *pf, u32 reset_flags);
630void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags); 630void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags);
631struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id);
631void i40e_update_stats(struct i40e_vsi *vsi); 632void i40e_update_stats(struct i40e_vsi *vsi);
632void i40e_update_eth_stats(struct i40e_vsi *vsi); 633void i40e_update_eth_stats(struct i40e_vsi *vsi);
633struct rtnl_link_stats64 *i40e_get_vsi_stats_struct(struct i40e_vsi *vsi); 634struct rtnl_link_stats64 *i40e_get_vsi_stats_struct(struct i40e_vsi *vsi);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 5e79054f2801..89a2d76a1f69 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -250,6 +250,22 @@ static int i40e_put_lump(struct i40e_lump_tracking *pile, u16 index, u16 id)
250} 250}
251 251
252/** 252/**
253 * i40e_find_vsi_from_id - searches for the vsi with the given id
254 * @pf - the pf structure to search for the vsi
255 * @id - id of the vsi it is searching for
256 **/
257struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id)
258{
259 int i;
260
261 for (i = 0; i < pf->num_alloc_vsi; i++)
262 if (pf->vsi[i] && (pf->vsi[i]->id == id))
263 return pf->vsi[i];
264
265 return NULL;
266}
267
268/**
253 * i40e_service_event_schedule - Schedule the service task to wake up 269 * i40e_service_event_schedule - Schedule the service task to wake up
254 * @pf: board private structure 270 * @pf: board private structure
255 * 271 *
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 184b00390f57..4d69e1f04901 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -53,13 +53,12 @@ static inline void i40e_vc_disable_vf(struct i40e_pf *pf, struct i40e_vf *vf)
53 * 53 *
54 * check for the valid VSI id 54 * check for the valid VSI id
55 **/ 55 **/
56static inline bool i40e_vc_isvalid_vsi_id(struct i40e_vf *vf, u8 vsi_id) 56static inline bool i40e_vc_isvalid_vsi_id(struct i40e_vf *vf, u16 vsi_id)
57{ 57{
58 struct i40e_pf *pf = vf->pf; 58 struct i40e_pf *pf = vf->pf;
59 struct i40e_vsi *vsi = i40e_find_vsi_from_id(pf, vsi_id);
59 60
60 if (vsi_id > pf->num_alloc_vsi) 61 return (vsi && (vsi->vf_id == vf->vf_id));
61 return false;
62 return pf->vsi[vsi_id]->vf_id == vf->vf_id;
63} 62}
64 63
65/** 64/**
@@ -70,12 +69,13 @@ static inline bool i40e_vc_isvalid_vsi_id(struct i40e_vf *vf, u8 vsi_id)
70 * 69 *
71 * check for the valid queue id 70 * check for the valid queue id
72 **/ 71 **/
73static inline bool i40e_vc_isvalid_queue_id(struct i40e_vf *vf, u8 vsi_id, 72static inline bool i40e_vc_isvalid_queue_id(struct i40e_vf *vf, u16 vsi_id,
74 u8 qid) 73 u8 qid)
75{ 74{
76 struct i40e_pf *pf = vf->pf; 75 struct i40e_pf *pf = vf->pf;
76 struct i40e_vsi *vsi = i40e_find_vsi_from_id(pf, vsi_id);
77 77
78 return qid < pf->vsi[vsi_id]->alloc_queue_pairs; 78 return (vsi && (qid < vsi->alloc_queue_pairs));
79} 79}
80 80
81/** 81/**
@@ -97,18 +97,21 @@ static inline bool i40e_vc_isvalid_vector_id(struct i40e_vf *vf, u8 vector_id)
97/** 97/**
98 * i40e_vc_get_pf_queue_id 98 * i40e_vc_get_pf_queue_id
99 * @vf: pointer to the VF info 99 * @vf: pointer to the VF info
100 * @vsi_idx: index of VSI in PF struct 100 * @vsi_id: id of VSI as provided by the FW
101 * @vsi_queue_id: vsi relative queue id 101 * @vsi_queue_id: vsi relative queue id
102 * 102 *
103 * return PF relative queue id 103 * return PF relative queue id
104 **/ 104 **/
105static u16 i40e_vc_get_pf_queue_id(struct i40e_vf *vf, u8 vsi_idx, 105static u16 i40e_vc_get_pf_queue_id(struct i40e_vf *vf, u16 vsi_id,
106 u8 vsi_queue_id) 106 u8 vsi_queue_id)
107{ 107{
108 struct i40e_pf *pf = vf->pf; 108 struct i40e_pf *pf = vf->pf;
109 struct i40e_vsi *vsi = pf->vsi[vsi_idx]; 109 struct i40e_vsi *vsi = i40e_find_vsi_from_id(pf, vsi_id);
110 u16 pf_queue_id = I40E_QUEUE_END_OF_LIST; 110 u16 pf_queue_id = I40E_QUEUE_END_OF_LIST;
111 111
112 if (!vsi)
113 return pf_queue_id;
114
112 if (le16_to_cpu(vsi->info.mapping_flags) & 115 if (le16_to_cpu(vsi->info.mapping_flags) &
113 I40E_AQ_VSI_QUE_MAP_NONCONTIG) 116 I40E_AQ_VSI_QUE_MAP_NONCONTIG)
114 pf_queue_id = 117 pf_queue_id =
@@ -123,12 +126,12 @@ static u16 i40e_vc_get_pf_queue_id(struct i40e_vf *vf, u8 vsi_idx,
123/** 126/**
124 * i40e_config_irq_link_list 127 * i40e_config_irq_link_list
125 * @vf: pointer to the VF info 128 * @vf: pointer to the VF info
126 * @vsi_idx: index of VSI in PF struct 129 * @vsi_id: id of VSI as given by the FW
127 * @vecmap: irq map info 130 * @vecmap: irq map info
128 * 131 *
129 * configure irq link list from the map 132 * configure irq link list from the map
130 **/ 133 **/
131static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_idx, 134static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_id,
132 struct i40e_virtchnl_vector_map *vecmap) 135 struct i40e_virtchnl_vector_map *vecmap)
133{ 136{
134 unsigned long linklistmap = 0, tempmap; 137 unsigned long linklistmap = 0, tempmap;
@@ -173,7 +176,7 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_idx,
173 I40E_VIRTCHNL_SUPPORTED_QTYPES)); 176 I40E_VIRTCHNL_SUPPORTED_QTYPES));
174 vsi_queue_id = next_q/I40E_VIRTCHNL_SUPPORTED_QTYPES; 177 vsi_queue_id = next_q/I40E_VIRTCHNL_SUPPORTED_QTYPES;
175 qtype = next_q%I40E_VIRTCHNL_SUPPORTED_QTYPES; 178 qtype = next_q%I40E_VIRTCHNL_SUPPORTED_QTYPES;
176 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_idx, vsi_queue_id); 179 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id, vsi_queue_id);
177 reg = ((qtype << I40E_VPINT_LNKLSTN_FIRSTQ_TYPE_SHIFT) | pf_queue_id); 180 reg = ((qtype << I40E_VPINT_LNKLSTN_FIRSTQ_TYPE_SHIFT) | pf_queue_id);
178 181
179 wr32(hw, reg_idx, reg); 182 wr32(hw, reg_idx, reg);
@@ -200,7 +203,7 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_idx,
200 (I40E_MAX_VSI_QP * I40E_VIRTCHNL_SUPPORTED_QTYPES)) { 203 (I40E_MAX_VSI_QP * I40E_VIRTCHNL_SUPPORTED_QTYPES)) {
201 vsi_queue_id = next_q / I40E_VIRTCHNL_SUPPORTED_QTYPES; 204 vsi_queue_id = next_q / I40E_VIRTCHNL_SUPPORTED_QTYPES;
202 qtype = next_q % I40E_VIRTCHNL_SUPPORTED_QTYPES; 205 qtype = next_q % I40E_VIRTCHNL_SUPPORTED_QTYPES;
203 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_idx, 206 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id,
204 vsi_queue_id); 207 vsi_queue_id);
205 } else { 208 } else {
206 pf_queue_id = I40E_QUEUE_END_OF_LIST; 209 pf_queue_id = I40E_QUEUE_END_OF_LIST;
@@ -223,24 +226,26 @@ irq_list_done:
223/** 226/**
224 * i40e_config_vsi_tx_queue 227 * i40e_config_vsi_tx_queue
225 * @vf: pointer to the VF info 228 * @vf: pointer to the VF info
226 * @vsi_idx: index of VSI in PF struct 229 * @vsi_id: id of VSI as provided by the FW
227 * @vsi_queue_id: vsi relative queue index 230 * @vsi_queue_id: vsi relative queue index
228 * @info: config. info 231 * @info: config. info
229 * 232 *
230 * configure tx queue 233 * configure tx queue
231 **/ 234 **/
232static int i40e_config_vsi_tx_queue(struct i40e_vf *vf, u16 vsi_idx, 235static int i40e_config_vsi_tx_queue(struct i40e_vf *vf, u16 vsi_id,
233 u16 vsi_queue_id, 236 u16 vsi_queue_id,
234 struct i40e_virtchnl_txq_info *info) 237 struct i40e_virtchnl_txq_info *info)
235{ 238{
236 struct i40e_pf *pf = vf->pf; 239 struct i40e_pf *pf = vf->pf;
237 struct i40e_hw *hw = &pf->hw; 240 struct i40e_hw *hw = &pf->hw;
238 struct i40e_hmc_obj_txq tx_ctx; 241 struct i40e_hmc_obj_txq tx_ctx;
242 struct i40e_vsi *vsi;
239 u16 pf_queue_id; 243 u16 pf_queue_id;
240 u32 qtx_ctl; 244 u32 qtx_ctl;
241 int ret = 0; 245 int ret = 0;
242 246
243 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_idx, vsi_queue_id); 247 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id, vsi_queue_id);
248 vsi = i40e_find_vsi_from_id(pf, vsi_id);
244 249
245 /* clear the context structure first */ 250 /* clear the context structure first */
246 memset(&tx_ctx, 0, sizeof(struct i40e_hmc_obj_txq)); 251 memset(&tx_ctx, 0, sizeof(struct i40e_hmc_obj_txq));
@@ -248,7 +253,7 @@ static int i40e_config_vsi_tx_queue(struct i40e_vf *vf, u16 vsi_idx,
248 /* only set the required fields */ 253 /* only set the required fields */
249 tx_ctx.base = info->dma_ring_addr / 128; 254 tx_ctx.base = info->dma_ring_addr / 128;
250 tx_ctx.qlen = info->ring_len; 255 tx_ctx.qlen = info->ring_len;
251 tx_ctx.rdylist = le16_to_cpu(pf->vsi[vsi_idx]->info.qs_handle[0]); 256 tx_ctx.rdylist = le16_to_cpu(vsi->info.qs_handle[0]);
252 tx_ctx.rdylist_act = 0; 257 tx_ctx.rdylist_act = 0;
253 tx_ctx.head_wb_ena = info->headwb_enabled; 258 tx_ctx.head_wb_ena = info->headwb_enabled;
254 tx_ctx.head_wb_addr = info->dma_headwb_addr; 259 tx_ctx.head_wb_addr = info->dma_headwb_addr;
@@ -290,13 +295,13 @@ error_context:
290/** 295/**
291 * i40e_config_vsi_rx_queue 296 * i40e_config_vsi_rx_queue
292 * @vf: pointer to the VF info 297 * @vf: pointer to the VF info
293 * @vsi_idx: index of VSI in PF struct 298 * @vsi_id: id of VSI as provided by the FW
294 * @vsi_queue_id: vsi relative queue index 299 * @vsi_queue_id: vsi relative queue index
295 * @info: config. info 300 * @info: config. info
296 * 301 *
297 * configure rx queue 302 * configure rx queue
298 **/ 303 **/
299static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_idx, 304static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id,
300 u16 vsi_queue_id, 305 u16 vsi_queue_id,
301 struct i40e_virtchnl_rxq_info *info) 306 struct i40e_virtchnl_rxq_info *info)
302{ 307{
@@ -306,7 +311,7 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_idx,
306 u16 pf_queue_id; 311 u16 pf_queue_id;
307 int ret = 0; 312 int ret = 0;
308 313
309 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_idx, vsi_queue_id); 314 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id, vsi_queue_id);
310 315
311 /* clear the context structure first */ 316 /* clear the context structure first */
312 memset(&rx_ctx, 0, sizeof(struct i40e_hmc_obj_rxq)); 317 memset(&rx_ctx, 0, sizeof(struct i40e_hmc_obj_rxq));
@@ -403,7 +408,7 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type)
403 } 408 }
404 if (type == I40E_VSI_SRIOV) { 409 if (type == I40E_VSI_SRIOV) {
405 u8 brdcast[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 410 u8 brdcast[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
406 vf->lan_vsi_index = vsi->idx; 411 vf->lan_vsi_idx = vsi->idx;
407 vf->lan_vsi_id = vsi->id; 412 vf->lan_vsi_id = vsi->id;
408 /* If the port VLAN has been configured and then the 413 /* If the port VLAN has been configured and then the
409 * VF driver was removed then the VSI port VLAN 414 * VF driver was removed then the VSI port VLAN
@@ -468,8 +473,8 @@ static void i40e_enable_vf_mappings(struct i40e_vf *vf)
468 wr32(hw, I40E_VPLAN_MAPENA(vf->vf_id), reg); 473 wr32(hw, I40E_VPLAN_MAPENA(vf->vf_id), reg);
469 474
470 /* map PF queues to VF queues */ 475 /* map PF queues to VF queues */
471 for (j = 0; j < pf->vsi[vf->lan_vsi_index]->alloc_queue_pairs; j++) { 476 for (j = 0; j < pf->vsi[vf->lan_vsi_idx]->alloc_queue_pairs; j++) {
472 u16 qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_index, j); 477 u16 qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_id, j);
473 reg = (qid & I40E_VPLAN_QTABLE_QINDEX_MASK); 478 reg = (qid & I40E_VPLAN_QTABLE_QINDEX_MASK);
474 wr32(hw, I40E_VPLAN_QTABLE(total_queue_pairs, vf->vf_id), reg); 479 wr32(hw, I40E_VPLAN_QTABLE(total_queue_pairs, vf->vf_id), reg);
475 total_queue_pairs++; 480 total_queue_pairs++;
@@ -477,13 +482,13 @@ static void i40e_enable_vf_mappings(struct i40e_vf *vf)
477 482
478 /* map PF queues to VSI */ 483 /* map PF queues to VSI */
479 for (j = 0; j < 7; j++) { 484 for (j = 0; j < 7; j++) {
480 if (j * 2 >= pf->vsi[vf->lan_vsi_index]->alloc_queue_pairs) { 485 if (j * 2 >= pf->vsi[vf->lan_vsi_idx]->alloc_queue_pairs) {
481 reg = 0x07FF07FF; /* unused */ 486 reg = 0x07FF07FF; /* unused */
482 } else { 487 } else {
483 u16 qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_index, 488 u16 qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_id,
484 j * 2); 489 j * 2);
485 reg = qid; 490 reg = qid;
486 qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_index, 491 qid = i40e_vc_get_pf_queue_id(vf, vf->lan_vsi_id,
487 (j * 2) + 1); 492 (j * 2) + 1);
488 reg |= qid << 16; 493 reg |= qid << 16;
489 } 494 }
@@ -527,9 +532,9 @@ static void i40e_free_vf_res(struct i40e_vf *vf)
527 int i, msix_vf; 532 int i, msix_vf;
528 533
529 /* free vsi & disconnect it from the parent uplink */ 534 /* free vsi & disconnect it from the parent uplink */
530 if (vf->lan_vsi_index) { 535 if (vf->lan_vsi_idx) {
531 i40e_vsi_release(pf->vsi[vf->lan_vsi_index]); 536 i40e_vsi_release(pf->vsi[vf->lan_vsi_idx]);
532 vf->lan_vsi_index = 0; 537 vf->lan_vsi_idx = 0;
533 vf->lan_vsi_id = 0; 538 vf->lan_vsi_id = 0;
534 } 539 }
535 msix_vf = pf->hw.func_caps.num_msix_vectors_vf; 540 msix_vf = pf->hw.func_caps.num_msix_vectors_vf;
@@ -584,7 +589,7 @@ static int i40e_alloc_vf_res(struct i40e_vf *vf)
584 ret = i40e_alloc_vsi_res(vf, I40E_VSI_SRIOV); 589 ret = i40e_alloc_vsi_res(vf, I40E_VSI_SRIOV);
585 if (ret) 590 if (ret)
586 goto error_alloc; 591 goto error_alloc;
587 total_queue_pairs += pf->vsi[vf->lan_vsi_index]->alloc_queue_pairs; 592 total_queue_pairs += pf->vsi[vf->lan_vsi_idx]->alloc_queue_pairs;
588 set_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps); 593 set_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps);
589 594
590 /* store the total qps number for the runtime 595 /* store the total qps number for the runtime
@@ -694,10 +699,10 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr)
694 wr32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id), reg); 699 wr32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id), reg);
695 700
696 /* On initial reset, we won't have any queues */ 701 /* On initial reset, we won't have any queues */
697 if (vf->lan_vsi_index == 0) 702 if (vf->lan_vsi_idx == 0)
698 goto complete_reset; 703 goto complete_reset;
699 704
700 i40e_vsi_control_rings(pf->vsi[vf->lan_vsi_index], false); 705 i40e_vsi_control_rings(pf->vsi[vf->lan_vsi_idx], false);
701complete_reset: 706complete_reset:
702 /* reallocate VF resources to reset the VSI state */ 707 /* reallocate VF resources to reset the VSI state */
703 i40e_free_vf_res(vf); 708 i40e_free_vf_res(vf);
@@ -1018,18 +1023,18 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf)
1018 } 1023 }
1019 1024
1020 vfres->vf_offload_flags = I40E_VIRTCHNL_VF_OFFLOAD_L2; 1025 vfres->vf_offload_flags = I40E_VIRTCHNL_VF_OFFLOAD_L2;
1021 vsi = pf->vsi[vf->lan_vsi_index]; 1026 vsi = pf->vsi[vf->lan_vsi_idx];
1022 if (!vsi->info.pvid) 1027 if (!vsi->info.pvid)
1023 vfres->vf_offload_flags |= I40E_VIRTCHNL_VF_OFFLOAD_VLAN; 1028 vfres->vf_offload_flags |= I40E_VIRTCHNL_VF_OFFLOAD_VLAN;
1024 1029
1025 vfres->num_vsis = num_vsis; 1030 vfres->num_vsis = num_vsis;
1026 vfres->num_queue_pairs = vf->num_queue_pairs; 1031 vfres->num_queue_pairs = vf->num_queue_pairs;
1027 vfres->max_vectors = pf->hw.func_caps.num_msix_vectors_vf; 1032 vfres->max_vectors = pf->hw.func_caps.num_msix_vectors_vf;
1028 if (vf->lan_vsi_index) { 1033 if (vf->lan_vsi_idx) {
1029 vfres->vsi_res[i].vsi_id = vf->lan_vsi_index; 1034 vfres->vsi_res[i].vsi_id = vf->lan_vsi_id;
1030 vfres->vsi_res[i].vsi_type = I40E_VSI_SRIOV; 1035 vfres->vsi_res[i].vsi_type = I40E_VSI_SRIOV;
1031 vfres->vsi_res[i].num_queue_pairs = 1036 vfres->vsi_res[i].num_queue_pairs =
1032 pf->vsi[vf->lan_vsi_index]->alloc_queue_pairs; 1037 pf->vsi[vf->lan_vsi_idx]->alloc_queue_pairs;
1033 memcpy(vfres->vsi_res[i].default_mac_addr, 1038 memcpy(vfres->vsi_res[i].default_mac_addr,
1034 vf->default_lan_addr.addr, ETH_ALEN); 1039 vf->default_lan_addr.addr, ETH_ALEN);
1035 i++; 1040 i++;
@@ -1081,14 +1086,14 @@ static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf,
1081 bool allmulti = false; 1086 bool allmulti = false;
1082 i40e_status aq_ret; 1087 i40e_status aq_ret;
1083 1088
1089 vsi = i40e_find_vsi_from_id(pf, info->vsi_id);
1084 if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) || 1090 if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||
1085 !test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps) || 1091 !test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps) ||
1086 !i40e_vc_isvalid_vsi_id(vf, info->vsi_id) || 1092 !i40e_vc_isvalid_vsi_id(vf, info->vsi_id) ||
1087 (pf->vsi[info->vsi_id]->type != I40E_VSI_FCOE)) { 1093 (vsi->type != I40E_VSI_FCOE)) {
1088 aq_ret = I40E_ERR_PARAM; 1094 aq_ret = I40E_ERR_PARAM;
1089 goto error_param; 1095 goto error_param;
1090 } 1096 }
1091 vsi = pf->vsi[info->vsi_id];
1092 if (info->flags & I40E_FLAG_VF_MULTICAST_PROMISC) 1097 if (info->flags & I40E_FLAG_VF_MULTICAST_PROMISC)
1093 allmulti = true; 1098 allmulti = true;
1094 aq_ret = i40e_aq_set_vsi_multicast_promiscuous(hw, vsi->seid, 1099 aq_ret = i40e_aq_set_vsi_multicast_promiscuous(hw, vsi->seid,
@@ -1150,7 +1155,7 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
1150 } 1155 }
1151 } 1156 }
1152 /* set vsi num_queue_pairs in use to num configured by VF */ 1157 /* set vsi num_queue_pairs in use to num configured by VF */
1153 pf->vsi[vf->lan_vsi_index]->num_queue_pairs = qci->num_queue_pairs; 1158 pf->vsi[vf->lan_vsi_idx]->num_queue_pairs = qci->num_queue_pairs;
1154 1159
1155error_param: 1160error_param:
1156 /* send the response to the VF */ 1161 /* send the response to the VF */
@@ -1251,7 +1256,8 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
1251 aq_ret = I40E_ERR_PARAM; 1256 aq_ret = I40E_ERR_PARAM;
1252 goto error_param; 1257 goto error_param;
1253 } 1258 }
1254 if (i40e_vsi_control_rings(pf->vsi[vsi_id], true)) 1259
1260 if (i40e_vsi_control_rings(pf->vsi[vf->lan_vsi_idx], true))
1255 aq_ret = I40E_ERR_TIMEOUT; 1261 aq_ret = I40E_ERR_TIMEOUT;
1256error_param: 1262error_param:
1257 /* send the response to the VF */ 1263 /* send the response to the VF */
@@ -1273,7 +1279,6 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
1273 struct i40e_virtchnl_queue_select *vqs = 1279 struct i40e_virtchnl_queue_select *vqs =
1274 (struct i40e_virtchnl_queue_select *)msg; 1280 (struct i40e_virtchnl_queue_select *)msg;
1275 struct i40e_pf *pf = vf->pf; 1281 struct i40e_pf *pf = vf->pf;
1276 u16 vsi_id = vqs->vsi_id;
1277 i40e_status aq_ret = 0; 1282 i40e_status aq_ret = 0;
1278 1283
1279 if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states)) { 1284 if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states)) {
@@ -1290,7 +1295,8 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
1290 aq_ret = I40E_ERR_PARAM; 1295 aq_ret = I40E_ERR_PARAM;
1291 goto error_param; 1296 goto error_param;
1292 } 1297 }
1293 if (i40e_vsi_control_rings(pf->vsi[vsi_id], false)) 1298
1299 if (i40e_vsi_control_rings(pf->vsi[vf->lan_vsi_idx], false))
1294 aq_ret = I40E_ERR_TIMEOUT; 1300 aq_ret = I40E_ERR_TIMEOUT;
1295 1301
1296error_param: 1302error_param:
@@ -1328,7 +1334,7 @@ static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
1328 goto error_param; 1334 goto error_param;
1329 } 1335 }
1330 1336
1331 vsi = pf->vsi[vqs->vsi_id]; 1337 vsi = pf->vsi[vf->lan_vsi_idx];
1332 if (!vsi) { 1338 if (!vsi) {
1333 aq_ret = I40E_ERR_PARAM; 1339 aq_ret = I40E_ERR_PARAM;
1334 goto error_param; 1340 goto error_param;
@@ -1406,7 +1412,7 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
1406 if (ret) 1412 if (ret)
1407 goto error_param; 1413 goto error_param;
1408 } 1414 }
1409 vsi = pf->vsi[vsi_id]; 1415 vsi = pf->vsi[vf->lan_vsi_idx];
1410 1416
1411 /* add new addresses to the list */ 1417 /* add new addresses to the list */
1412 for (i = 0; i < al->num_elements; i++) { 1418 for (i = 0; i < al->num_elements; i++) {
@@ -1474,7 +1480,7 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
1474 goto error_param; 1480 goto error_param;
1475 } 1481 }
1476 } 1482 }
1477 vsi = pf->vsi[vsi_id]; 1483 vsi = pf->vsi[vf->lan_vsi_idx];
1478 1484
1479 /* delete addresses from the list */ 1485 /* delete addresses from the list */
1480 for (i = 0; i < al->num_elements; i++) 1486 for (i = 0; i < al->num_elements; i++)
@@ -1524,7 +1530,7 @@ static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
1524 goto error_param; 1530 goto error_param;
1525 } 1531 }
1526 } 1532 }
1527 vsi = pf->vsi[vsi_id]; 1533 vsi = pf->vsi[vf->lan_vsi_idx];
1528 if (vsi->info.pvid) { 1534 if (vsi->info.pvid) {
1529 aq_ret = I40E_ERR_PARAM; 1535 aq_ret = I40E_ERR_PARAM;
1530 goto error_param; 1536 goto error_param;
@@ -1577,7 +1583,7 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
1577 } 1583 }
1578 } 1584 }
1579 1585
1580 vsi = pf->vsi[vsi_id]; 1586 vsi = pf->vsi[vf->lan_vsi_idx];
1581 if (vsi->info.pvid) { 1587 if (vsi->info.pvid) {
1582 aq_ret = I40E_ERR_PARAM; 1588 aq_ret = I40E_ERR_PARAM;
1583 goto error_param; 1589 goto error_param;
@@ -1966,7 +1972,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
1966 } 1972 }
1967 1973
1968 vf = &(pf->vf[vf_id]); 1974 vf = &(pf->vf[vf_id]);
1969 vsi = pf->vsi[vf->lan_vsi_index]; 1975 vsi = pf->vsi[vf->lan_vsi_idx];
1970 if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) { 1976 if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
1971 dev_err(&pf->pdev->dev, 1977 dev_err(&pf->pdev->dev,
1972 "Uninitialized VF %d\n", vf_id); 1978 "Uninitialized VF %d\n", vf_id);
@@ -2040,7 +2046,7 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev,
2040 } 2046 }
2041 2047
2042 vf = &(pf->vf[vf_id]); 2048 vf = &(pf->vf[vf_id]);
2043 vsi = pf->vsi[vf->lan_vsi_index]; 2049 vsi = pf->vsi[vf->lan_vsi_idx];
2044 if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) { 2050 if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
2045 dev_err(&pf->pdev->dev, "Uninitialized VF %d\n", vf_id); 2051 dev_err(&pf->pdev->dev, "Uninitialized VF %d\n", vf_id);
2046 ret = -EINVAL; 2052 ret = -EINVAL;
@@ -2153,7 +2159,7 @@ int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
2153 } 2159 }
2154 2160
2155 vf = &(pf->vf[vf_id]); 2161 vf = &(pf->vf[vf_id]);
2156 vsi = pf->vsi[vf->lan_vsi_index]; 2162 vsi = pf->vsi[vf->lan_vsi_idx];
2157 if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) { 2163 if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
2158 dev_err(&pf->pdev->dev, "Uninitialized VF %d.\n", vf_id); 2164 dev_err(&pf->pdev->dev, "Uninitialized VF %d.\n", vf_id);
2159 ret = -EINVAL; 2165 ret = -EINVAL;
@@ -2227,7 +2233,7 @@ int i40e_ndo_get_vf_config(struct net_device *netdev,
2227 2233
2228 vf = &(pf->vf[vf_id]); 2234 vf = &(pf->vf[vf_id]);
2229 /* first vsi is always the LAN vsi */ 2235 /* first vsi is always the LAN vsi */
2230 vsi = pf->vsi[vf->lan_vsi_index]; 2236 vsi = pf->vsi[vf->lan_vsi_idx];
2231 if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) { 2237 if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
2232 dev_err(&pf->pdev->dev, "Uninitialized VF %d\n", vf_id); 2238 dev_err(&pf->pdev->dev, "Uninitialized VF %d\n", vf_id);
2233 ret = -EINVAL; 2239 ret = -EINVAL;
@@ -2351,7 +2357,7 @@ int i40e_ndo_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool enable)
2351 2357
2352 vf->spoofchk = enable; 2358 vf->spoofchk = enable;
2353 memset(&ctxt, 0, sizeof(ctxt)); 2359 memset(&ctxt, 0, sizeof(ctxt));
2354 ctxt.seid = pf->vsi[vf->lan_vsi_index]->seid; 2360 ctxt.seid = pf->vsi[vf->lan_vsi_idx]->seid;
2355 ctxt.pf_num = pf->hw.pf_id; 2361 ctxt.pf_num = pf->hw.pf_id;
2356 ctxt.info.valid_sections = cpu_to_le16(I40E_AQ_VSI_PROP_SECURITY_VALID); 2362 ctxt.info.valid_sections = cpu_to_le16(I40E_AQ_VSI_PROP_SECURITY_VALID);
2357 if (enable) 2363 if (enable)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
index 9c3a41040835..09043c1aae54 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
@@ -88,7 +88,7 @@ struct i40e_vf {
88 * When assigned, these will be non-zero, because VSI 0 is always 88 * When assigned, these will be non-zero, because VSI 0 is always
89 * the main LAN VSI for the PF. 89 * the main LAN VSI for the PF.
90 */ 90 */
91 u8 lan_vsi_index; /* index into PF struct */ 91 u8 lan_vsi_idx; /* index into PF struct */
92 u8 lan_vsi_id; /* ID as used by firmware */ 92 u8 lan_vsi_id; /* ID as used by firmware */
93 93
94 u8 num_queue_pairs; /* num of qps assigned to VF vsis */ 94 u8 num_queue_pairs; /* num of qps assigned to VF vsis */