Skip to contentSkip to conversation

ice: Add error handling for queue config fail

PATCH Superseded Mateusz Palczewski 4 participants 4 messages May 31, 2022 – Jun 2, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ice: Add error handling for queue config fail

From: Przemyslaw Patynowski <[email protected]>

Disable VF's RX/TX queues, when VIRTCHNL_OP_CONFIG_VSI_QUEUES fail. Not disabling them might lead to scenario, where PF driver leaves VF queues enabled, when VF's VSI failed queue config.
In this scenario VF should not have RX/TX queues enabled. If PF failed to setup VF's queues, VF will reset due to TX timeouts in VF driver.

---
 drivers/net/ethernet/intel/ice/ice_virtchnl.c | 53 +++++++++----------
 1 file changed, 26 insertions(+), 27 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl.c +26 -27
index 1d9b84c..4547bc1 100644
@@ -1569,35 +1569,27 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg)
  */
 static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 {
-	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
 	struct virtchnl_vsi_queue_config_info *qci =
 	    (struct virtchnl_vsi_queue_config_info *)msg;
 	struct virtchnl_queue_pair_info *qpi;
 	struct ice_pf *pf = vf->pf;
 	struct ice_vsi *vsi;
-	int i, q_idx;
+	int i = -1, q_idx;
 
-	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
 		goto error_param;
-	}
 
-	if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id)) {
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id))
 		goto error_param;
-	}
 
 	vsi = ice_get_vf_vsi(vf);
-	if (!vsi) {
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	if (!vsi)
 		goto error_param;
-	}
 
 	if (qci->num_queue_pairs > ICE_MAX_RSS_QS_PER_VF ||
 	    qci->num_queue_pairs > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
 		dev_err(ice_pf_to_dev(pf), "VF-%d requesting more than supported number of queues: %d\n",
 			vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq));
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 		goto error_param;
 	}
 
@@ -1610,7 +1602,6 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 		    !ice_vc_isvalid_ring_len(qpi->txq.ring_len) ||
 		    !ice_vc_isvalid_ring_len(qpi->rxq.ring_len) ||
 		    !ice_vc_isvalid_q_id(vf, qci->vsi_id, qpi->txq.queue_id)) {
-			v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 			goto error_param;
 		}
 
@@ -1620,7 +1611,6 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 		 * for selected "vsi"
 		 */
 		if (q_idx >= vsi->alloc_txq || q_idx >= vsi->alloc_rxq) {
-			v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 			goto error_param;
 		}
 
@@ -1630,14 +1620,13 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 			vsi->tx_rings[i]->count = qpi->txq.ring_len;
 
 			/* Disable any existing queue first */
-			if (ice_vf_vsi_dis_single_txq(vf, vsi, q_idx)) {
-				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+			if (ice_vf_vsi_dis_single_txq(vf, vsi, q_idx))
 				goto error_param;
-			}
 
 			/* Configure a queue with the requested settings */
 			if (ice_vsi_cfg_single_txq(vsi, vsi->tx_rings, q_idx)) {
-				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+				dev_warn(ice_pf_to_dev(pf), "VF-%d failed to configure TX queue %d\n",
+					 vf->vf_id, i);
 				goto error_param;
 			}
 		}
@@ -1651,17 +1640,13 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 
 			if (qpi->rxq.databuffer_size != 0 &&
 			    (qpi->rxq.databuffer_size > ((16 * 1024) - 128) ||
-			     qpi->rxq.databuffer_size < 1024)) {
-				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+			     qpi->rxq.databuffer_size < 1024))
 				goto error_param;
-			}
 			vsi->rx_buf_len = qpi->rxq.databuffer_size;
 			vsi->rx_rings[i]->rx_buf_len = vsi->rx_buf_len;
 			if (qpi->rxq.max_pkt_size > max_frame_size ||
-			    qpi->rxq.max_pkt_size < 64) {
-				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+			    qpi->rxq.max_pkt_size < 64)
 				goto error_param;
-			}
 
 			vsi->max_frame = qpi->rxq.max_pkt_size;
 			/* add space for the port VLAN since the VF driver is
@@ -1672,16 +1657,30 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 				vsi->max_frame += VLAN_HLEN;
 
 			if (ice_vsi_cfg_single_rxq(vsi, q_idx)) {
-				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+				dev_warn(ice_pf_to_dev(pf), "VF-%d failed to configure RX queue %d\n",
+					 vf->vf_id, i);
 				goto error_param;
 			}
 		}
 	}
 
+	/* send the response to the VF */
+	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
+				     VIRTCHNL_STATUS_SUCCESS, NULL, 0);
 error_param:
+	/* disable whatever we can */
+	for (; i >= 0; i--) {
+		if (ice_vsi_ctrl_one_rx_ring(vsi, false, i, true))
+			dev_err(ice_pf_to_dev(pf), "VF-%d could not disable RX queue %d\n",
+				vf->vf_id, i);
+		if (ice_vf_vsi_dis_single_txq(vf, vsi, i))
+			dev_err(ice_pf_to_dev(pf), "VF-%d could not disable TX queue %d\n",
+				vf->vf_id, i);
+	}
+
 	/* send the response to the VF */
-	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES, v_ret,
-				     NULL, 0);
+	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
+				     VIRTCHNL_STATUS_ERR_PARAM, NULL, 0);
 }
 
 /**
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/2 ice: Add error handling for queue config fail

Dear Mateusz, dear Przemyslaw,

Thank you for the patch.

Am 31.05.22 um 15:18 schrieb Mateusz Palczewski:

Quoted 7 lines

From: Przemyslaw Patynowski <[email protected]>

Disable VF's RX/TX queues, when VIRTCHNL_OP_CONFIG_VSI_QUEUES fail. Not disabling them might lead to scenario, where PF driver leaves VF queues enabled, when VF's VSI failed queue config.
In this scenario VF should not have RX/TX queues enabled. If PF failed to setup VF's queues, VF will reset due to TX timeouts in VF driver.

Nit: The verb is spelled with a space: to set up

Quoted 13 lines
---
  drivers/net/ethernet/intel/ice/ice_virtchnl.c | 53 +++++++++----------
  1 file changed, 26 insertions(+), 27 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl.c +0 -0
index 1d9b84c..4547bc1 100644
@@ -1569,35 +1569,27 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg)
   */

drivers/net/ethernet/intel/ice/ice_virtchnl.c static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg) · line 1577

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_virtchnl.c +1 -2
  static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
  {
-	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
  	struct virtchnl_vsi_queue_config_info *qci =
  	    (struct virtchnl_vsi_queue_config_info *)msg;
  	struct virtchnl_queue_pair_info *qpi;
  	struct ice_pf *pf = vf->pf;
  	struct ice_vsi *vsi;
-	int i, q_idx;
+	int i = -1, q_idx;

Could you please add a comment to the commit message, why the for loop variable is initialized to -1. Reading a bit through the diff, it looks like i is not exclusively used as a loop variable. Maybe you could also add a cleanup patch, renaming the variable, or adding another one.

Quoted 90 lines
drivers/net/ethernet/intel/ice/ice_virtchnl.c +10 -23
-	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
  		goto error_param;
-	}
 
-	if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id)) {
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id))
  		goto error_param;
-	}
 
  	vsi = ice_get_vf_vsi(vf);
-	if (!vsi) {
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	if (!vsi)
  		goto error_param;
-	}
 
  	if (qci->num_queue_pairs > ICE_MAX_RSS_QS_PER_VF ||
  	    qci->num_queue_pairs > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
  		dev_err(ice_pf_to_dev(pf), "VF-%d requesting more than supported number of queues: %d\n",
  			vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq));
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
  		goto error_param;
  	}
 
@@ -1610,7 +1602,6 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
  		    !ice_vc_isvalid_ring_len(qpi->txq.ring_len) ||
  		    !ice_vc_isvalid_ring_len(qpi->rxq.ring_len) ||
  		    !ice_vc_isvalid_q_id(vf, qci->vsi_id, qpi->txq.queue_id)) {
-			v_ret = VIRTCHNL_STATUS_ERR_PARAM;
  			goto error_param;
  		}
 
@@ -1620,7 +1611,6 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
  		 * for selected "vsi"
  		 */
  		if (q_idx >= vsi->alloc_txq || q_idx >= vsi->alloc_rxq) {
-			v_ret = VIRTCHNL_STATUS_ERR_PARAM;
  			goto error_param;
  		}
 
@@ -1630,14 +1620,13 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
  			vsi->tx_rings[i]->count = qpi->txq.ring_len;
 
  			/* Disable any existing queue first */
-			if (ice_vf_vsi_dis_single_txq(vf, vsi, q_idx)) {
-				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+			if (ice_vf_vsi_dis_single_txq(vf, vsi, q_idx))
  				goto error_param;
-			}
 
  			/* Configure a queue with the requested settings */
  			if (ice_vsi_cfg_single_txq(vsi, vsi->tx_rings, q_idx)) {
-				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+				dev_warn(ice_pf_to_dev(pf), "VF-%d failed to configure TX queue %d\n",
+					 vf->vf_id, i);
  				goto error_param;
  			}
  		}
@@ -1651,17 +1640,13 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 
  			if (qpi->rxq.databuffer_size != 0 &&
  			    (qpi->rxq.databuffer_size > ((16 * 1024) - 128) ||
-			     qpi->rxq.databuffer_size < 1024)) {
-				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+			     qpi->rxq.databuffer_size < 1024))
  				goto error_param;
-			}
  			vsi->rx_buf_len = qpi->rxq.databuffer_size;
  			vsi->rx_rings[i]->rx_buf_len = vsi->rx_buf_len;
  			if (qpi->rxq.max_pkt_size > max_frame_size ||
-			    qpi->rxq.max_pkt_size < 64) {
-				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+			    qpi->rxq.max_pkt_size < 64)
  				goto error_param;
-			}
 
  			vsi->max_frame = qpi->rxq.max_pkt_size;
  			/* add space for the port VLAN since the VF driver is
@@ -1672,16 +1657,30 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
  				vsi->max_frame += VLAN_HLEN;
 
  			if (ice_vsi_cfg_single_rxq(vsi, q_idx)) {
-				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+				dev_warn(ice_pf_to_dev(pf), "VF-%d failed to configure RX queue %d\n",
+					 vf->vf_id, i);
  				goto error_param;

drivers/net/ethernet/intel/ice/ice_virtchnl.c static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · line 1672

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_virtchnl.c +5 -0
  			}
  		}
  	}
 
+	/* send the response to the VF */
+	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
+				     VIRTCHNL_STATUS_SUCCESS, NULL, 0);
  error_param:
+	/* disable whatever we can */
+	for (; i >= 0; i--) {

With the rename, this could be then

     for (i = new_variable_name; i =>0; i--) {
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_virtchnl.c +6 -0
+		if (ice_vsi_ctrl_one_rx_ring(vsi, false, i, true))
+			dev_err(ice_pf_to_dev(pf), "VF-%d could not disable RX queue %d\n",
+				vf->vf_id, i);
+		if (ice_vf_vsi_dis_single_txq(vf, vsi, i))
+			dev_err(ice_pf_to_dev(pf), "VF-%d could not disable TX queue %d\n",
+				vf->vf_id, i);

drivers/net/ethernet/intel/ice/ice_virtchnl.c static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · line 1686

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_virtchnl.c +4 -2
+	}
+
  	/* send the response to the VF */
-	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES, v_ret,
-				     NULL, 0);
+	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
+				     VIRTCHNL_STATUS_ERR_PARAM, NULL, 0);
  }
 
  /**

Kind regards,

Paul

maintainer
#2 lore raw

PATCH 1/2 ice: Add error handling for queue config fail

In reply to Mateusz Palczewski
Quoted 8 lines · Mateusz Palczewski

From: Przemyslaw Patynowski <[email protected]>

Disable VF's RX/TX queues, when VIRTCHNL_OP_CONFIG_VSI_QUEUES fail. Not disabling them might lead to scenario, where PF driver leaves VF queues enabled, when VF's VSI failed queue config.
In this scenario VF should not have RX/TX queues enabled. If PF failed to setup VF's queues, VF will reset due to TX timeouts in VF driver.

Patches for net need a Fixes tag.

Quoted 12 lines
---
  drivers/net/ethernet/intel/ice/ice_virtchnl.c | 53 +++++++++----------
  1 file changed, 26 insertions(+), 27 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl.c +0 -0
index 1d9b84c..4547bc1 100644

drivers/net/ethernet/intel/ice/ice_virtchnl.c static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg) · line 1572

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_virtchnl.c +0 -1
@@ -1569,35 +1569,27 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg)
   */
  static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
  {
-	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;

This removal seems like a refactor and unrelated to the bug. Please send this change via net-next.

Thanks,
Tony

Quoted 19 lines
drivers/net/ethernet/intel/ice/ice_virtchnl.c +3 -7
  	struct virtchnl_vsi_queue_config_info *qci =
  	    (struct virtchnl_vsi_queue_config_info *)msg;
  	struct virtchnl_queue_pair_info *qpi;
  	struct ice_pf *pf = vf->pf;
  	struct ice_vsi *vsi;
-	int i, q_idx;
+	int i = -1, q_idx;
 
-	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
  		goto error_param;
-	}
 
-	if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id)) {
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id))
  		goto error_param;
-	}
#3 lore raw
Quoted 29 lines

-----Original Message-----
From: Nguyen, Anthony L <[email protected]>
Sent: Tuesday, May 31, 2022 22:41
To: Palczewski, Mateusz <[email protected]>; [email protected]
Cc: Patynowski, PrzemyslawX <[email protected]>; Laba, SlawomirX <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net v1 1/2] ice: Add error handling for queue config fail

Quoted 8 lines · Mateusz Palczewski

From: Przemyslaw Patynowski <[email protected]>

Disable VF's RX/TX queues, when VIRTCHNL_OP_CONFIG_VSI_QUEUES fail. Not disabling them might lead to scenario, where PF driver leaves VF queues enabled, when VF's VSI failed queue config.
In this scenario VF should not have RX/TX queues enabled. If PF failed to setup VF's queues, VF will reset due to TX timeouts in VF driver.

Patches for net need a Fixes tag.

Quoted 8 lines

Signed-off-by: Przemyslaw Patynowski
<[email protected]>

---
  drivers/net/ethernet/intel/ice/ice_virtchnl.c | 53 +++++++++----------
  1 file changed, 26 insertions(+), 27 deletions(-)
Quoted 10 lines

drivers/net/ethernet/intel/ice/ice_virtchnl.c static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg) · line 1572

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_virtchnl.c +0 -1
index 1d9b84c..4547bc1 100644
@@ -1569,35 +1569,27 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg)
   */
  static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
  {
-	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;

We will upload this as fix then, because I believe it actually fixes same scenario as in the 2/2 patch, but it's just harder to trigger this case.

Quoted 20 lines

This removal seems like a refactor and unrelated to the bug. Please send this change via net-next.

Thanks,
Tony

Quoted 14 lines
drivers/net/ethernet/intel/ice/ice_virtchnl.c +2 -4
  	struct virtchnl_vsi_queue_config_info *qci =
  	    (struct virtchnl_vsi_queue_config_info *)msg;
  	struct virtchnl_queue_pair_info *qpi;
  	struct ice_pf *pf = vf->pf;
  	struct ice_vsi *vsi;
-	int i, q_idx;
+	int i = -1, q_idx;
 
-	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
  		goto error_param;
-	}
 
Quoted 7 lines

drivers/net/ethernet/intel/ice/ice_virtchnl.c static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg) · line 1588

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_virtchnl.c +1 -3
-	if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id)) {
-		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id))
  		goto error_param;
-	}

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan