Blob Blame History Raw
From: Akeem G Abodunrin <akeem.g.abodunrin@intel.com>
Date: Tue, 26 Feb 2019 16:35:19 -0800
Subject: ice: Get VF VSI instances directly via PF
Patch-mainline: v5.2-rc1
Git-commit: f1ef73f50b3ef097569b9bccb66a7b09955ce049
References: jsc#SLE-4803

This patch changes how we get VF VSIs instances. Instead of relying on
mailbox virtual channel message to retrieve VSI, it is more reliable
getting it directly via VF object in PF data structure.

Signed-off-by: Akeem G Abodunrin <akeem.g.abodunrin@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c |   35 +++++++++++++++++------
 1 file changed, 27 insertions(+), 8 deletions(-)

--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
@@ -1390,6 +1390,11 @@ static int ice_vc_get_vf_res_msg(struct
 
 	vfres->vf_cap_flags = VIRTCHNL_VF_OFFLOAD_L2;
 	vsi = pf->vsi[vf->lan_vsi_idx];
+	if (!vsi) {
+		aq_ret = ICE_ERR_PARAM;
+		goto err;
+	}
+
 	if (!vsi->info.pvid)
 		vfres->vf_cap_flags |= VIRTCHNL_VF_OFFLOAD_VLAN;
 
@@ -1523,6 +1528,7 @@ static int ice_vc_config_rss_key(struct
 	struct virtchnl_rss_key *vrk =
 		(struct virtchnl_rss_key *)msg;
 	struct ice_vsi *vsi = NULL;
+	struct ice_pf *pf = vf->pf;
 	enum ice_status aq_ret;
 	int ret;
 
@@ -1536,7 +1542,7 @@ static int ice_vc_config_rss_key(struct
 		goto error_param;
 	}
 
-	vsi = ice_find_vsi_from_id(vf->pf, vrk->vsi_id);
+	vsi = pf->vsi[vf->lan_vsi_idx];
 	if (!vsi) {
 		aq_ret = ICE_ERR_PARAM;
 		goto error_param;
@@ -1570,6 +1576,7 @@ static int ice_vc_config_rss_lut(struct
 {
 	struct virtchnl_rss_lut *vrl = (struct virtchnl_rss_lut *)msg;
 	struct ice_vsi *vsi = NULL;
+	struct ice_pf *pf = vf->pf;
 	enum ice_status aq_ret;
 	int ret;
 
@@ -1583,7 +1590,7 @@ static int ice_vc_config_rss_lut(struct
 		goto error_param;
 	}
 
-	vsi = ice_find_vsi_from_id(vf->pf, vrl->vsi_id);
+	vsi = pf->vsi[vf->lan_vsi_idx];
 	if (!vsi) {
 		aq_ret = ICE_ERR_PARAM;
 		goto error_param;
@@ -1618,6 +1625,7 @@ static int ice_vc_get_stats_msg(struct i
 	struct virtchnl_queue_select *vqs =
 		(struct virtchnl_queue_select *)msg;
 	enum ice_status aq_ret = 0;
+	struct ice_pf *pf = vf->pf;
 	struct ice_eth_stats stats;
 	struct ice_vsi *vsi;
 
@@ -1631,7 +1639,7 @@ static int ice_vc_get_stats_msg(struct i
 		goto error_param;
 	}
 
-	vsi = ice_find_vsi_from_id(vf->pf, vqs->vsi_id);
+	vsi = pf->vsi[vf->lan_vsi_idx];
 	if (!vsi) {
 		aq_ret = ICE_ERR_PARAM;
 		goto error_param;
@@ -1660,6 +1668,7 @@ static int ice_vc_ena_qs_msg(struct ice_
 	struct virtchnl_queue_select *vqs =
 	    (struct virtchnl_queue_select *)msg;
 	enum ice_status aq_ret = 0;
+	struct ice_pf *pf = vf->pf;
 	struct ice_vsi *vsi;
 
 	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
@@ -1677,7 +1686,7 @@ static int ice_vc_ena_qs_msg(struct ice_
 		goto error_param;
 	}
 
-	vsi = ice_find_vsi_from_id(vf->pf, vqs->vsi_id);
+	vsi = pf->vsi[vf->lan_vsi_idx];
 	if (!vsi) {
 		aq_ret = ICE_ERR_PARAM;
 		goto error_param;
@@ -1713,6 +1722,7 @@ static int ice_vc_dis_qs_msg(struct ice_
 	struct virtchnl_queue_select *vqs =
 	    (struct virtchnl_queue_select *)msg;
 	enum ice_status aq_ret = 0;
+	struct ice_pf *pf = vf->pf;
 	struct ice_vsi *vsi;
 
 	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states) &&
@@ -1731,7 +1741,7 @@ static int ice_vc_dis_qs_msg(struct ice_
 		goto error_param;
 	}
 
-	vsi = ice_find_vsi_from_id(vf->pf, vqs->vsi_id);
+	vsi = pf->vsi[vf->lan_vsi_idx];
 	if (!vsi) {
 		aq_ret = ICE_ERR_PARAM;
 		goto error_param;
@@ -1797,7 +1807,7 @@ static int ice_vc_cfg_irq_map_msg(struct
 			goto error_param;
 		}
 
-		vsi = ice_find_vsi_from_id(vf->pf, vsi_id);
+		vsi = pf->vsi[vf->lan_vsi_idx];
 		if (!vsi) {
 			aq_ret = ICE_ERR_PARAM;
 			goto error_param;
@@ -1868,7 +1878,7 @@ static int ice_vc_cfg_qs_msg(struct ice_
 		goto error_param;
 	}
 
-	vsi = ice_find_vsi_from_id(vf->pf, qci->vsi_id);
+	vsi = pf->vsi[vf->lan_vsi_idx];
 	if (!vsi) {
 		aq_ret = ICE_ERR_PARAM;
 		goto error_param;
@@ -1998,6 +2008,10 @@ ice_vc_handle_mac_addr_msg(struct ice_vf
 	}
 
 	vsi = pf->vsi[vf->lan_vsi_idx];
+	if (!vsi) {
+		ret = ICE_ERR_PARAM;
+		goto handle_mac_exit;
+	}
 
 	for (i = 0; i < al->num_elements; i++) {
 		u8 *maddr = al->list[i].addr;
@@ -2291,7 +2305,7 @@ static int ice_vc_process_vlan_msg(struc
 	}
 
 	hw = &pf->hw;
-	vsi = ice_find_vsi_from_id(vf->pf, vfl->vsi_id);
+	vsi = pf->vsi[vf->lan_vsi_idx];
 	if (!vsi) {
 		aq_ret = ICE_ERR_PARAM;
 		goto error_param;
@@ -2452,6 +2466,11 @@ static int ice_vc_dis_vlan_stripping(str
 	}
 
 	vsi = pf->vsi[vf->lan_vsi_idx];
+	if (!vsi) {
+		aq_ret = ICE_ERR_PARAM;
+		goto error_param;
+	}
+
 	if (ice_vsi_manage_vlan_stripping(vsi, false))
 		aq_ret = ICE_ERR_AQ_ERROR;