Skip to contentSkip to conversation

net/i40e: fix negative check on unsigned queue pairs

PATCH Applied Kevin Traynor 3 participants 6 messages Mar 5, 2019 – Mar 11, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 net/i40e: fix negative check on unsigned queue pairs

Fix the check and associated log. Also, fix a typo in other log.

Fixes 03d478e9609d ("net/i40e: support PF respond VF request more queues")
---
 drivers/net/i40e/i40e_pf.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_pf.c +4 -6
index 585b21cbc..0c4bdbcd1 100644
@@ -1251,9 +1251,7 @@ i40e_pf_host_process_cmd_request_queues(struct i40e_pf_vf *vf, uint8_t *msg)
 	pf = vf->pf;
 
-	if (req_pairs <= 0) {
-		PMD_DRV_LOG(ERR,
-			    "VF %d tried to request %d queues. Ignoring.\n",
-			    vf->vf_idx,
-			    I40E_MAX_QP_NUM_PER_VF);
+	if (req_pairs == 0) {
+		PMD_DRV_LOG(ERR, "VF %d tried to request 0 queues. Ignoring.\n",
+			    vf->vf_idx);
 	} else if (req_pairs > I40E_MAX_QP_NUM_PER_VF) {
 		PMD_DRV_LOG(ERR,
@@ -1264,5 +1262,5 @@ i40e_pf_host_process_cmd_request_queues(struct i40e_pf_vf *vf, uint8_t *msg)
 	} else if (req_pairs > cur_pairs + pf->qp_pool.num_free) {
 		PMD_DRV_LOG(ERR,
-			    "VF %d requested %d more queues, but noly %d left\n",
+			    "VF %d requested %d more queues, but only %d left\n",
 			    vf->vf_idx,
 			    req_pairs - cur_pairs,
Signature · 1 line
2.20.1
#1 lore raw

RFC 2/2 net/i40e: update requested queue pair num check for rounding

Since rounding up the requested queue pairs to allow the vf to request a non-aligned number was added, it may happen that the requested number is less than the available num of queues but the rounded up number is greater. In this case, it is not caught with the usual checks but later when there is a reset and failed setup.

By rounding earlier the checks can be done before a failed reset occurs, and a rounded max amount of available queues can be returned to the vf.

---
 drivers/net/i40e/i40e_pf.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/net/i40e/i40e_pf.c +11 -9
index 0c4bdbcd1..651c56bb2 100644
@@ -1251,4 +1251,7 @@ i40e_pf_host_process_cmd_request_queues(struct i40e_pf_vf *vf, uint8_t *msg)
 	pf = vf->pf;
 
+	if (!rte_is_power_of_2(req_pairs))
+		req_pairs = i40e_align_floor(req_pairs) << 1;
+
 	if (req_pairs == 0) {
 		PMD_DRV_LOG(ERR, "VF %d tried to request 0 queues. Ignoring.\n",
@@ -1261,17 +1264,16 @@ i40e_pf_host_process_cmd_request_queues(struct i40e_pf_vf *vf, uint8_t *msg)
 		vfres->num_queue_pairs = I40E_MAX_QP_NUM_PER_VF;
 	} else if (req_pairs > cur_pairs + pf->qp_pool.num_free) {
-		PMD_DRV_LOG(ERR,
-			    "VF %d requested %d more queues, but only %d left\n",
+		PMD_DRV_LOG(ERR, "VF %d requested %d queues (rounded to %d) "
+			         "but only %d available\n",
 			    vf->vf_idx,
-			    req_pairs - cur_pairs,
-			    pf->qp_pool.num_free);
-		vfres->num_queue_pairs = pf->qp_pool.num_free + cur_pairs;
+			    vfres->num_queue_pairs,
+			    req_pairs,
+			    cur_pairs + pf->qp_pool.num_free);
+		vfres->num_queue_pairs = i40e_align_floor(pf->qp_pool.num_free +
+			                                  cur_pairs);
 	} else {
 		i40e_vc_notify_vf_reset(vf);
 		vf->vsi->nb_qps = req_pairs;
-		if (rte_is_power_of_2(req_pairs))
-			pf->vf_nb_qps = req_pairs;
-		else
-			pf->vf_nb_qps = i40e_align_floor(req_pairs) << 1;
+		pf->vf_nb_qps = req_pairs;
 		i40e_pf_host_process_cmd_reset_vf(vf);
 
Signature · 1 line
2.20.1
Acked-by on v1 2/2 Applied
#2 lore raw

Re: [RFC 2/2] net/i40e: update requested queue pair num check for rounding

Quoted 17 lines

-----Original Message-----
From: Kevin Traynor [mailto:[email protected]]
Sent: Wednesday, March 6, 2019 12:31 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; Kevin Traynor <[email protected]>; Yan, Zhirun <[email protected]>
Subject: [RFC 2/2] net/i40e: update requested queue pair num check for rounding

Since rounding up the requested queue pairs to allow the vf to request a non-aligned number was added, it may happen that the requested number is less than the available num of queues but the rounded up number is greater. In this case, it is not caught with the usual checks but later when there is a reset and failed setup.

Quoted 5 lines

By rounding earlier the checks can be done before a failed reset occurs, and a rounded max amount of available queues can be returned to the vf.

Applied to dpdk-next-net-intel.

Thanks
Qi

#3 lore raw

Re: [RFC 2/2] net/i40e: update requested queue pair num check for rounding

Quoted 20 lines · Qi Z
Quoted 20 lines

-----Original Message-----
From: Kevin Traynor [mailto:[email protected]]
Sent: Wednesday, March 6, 2019 12:31 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; Kevin Traynor <[email protected]>; Yan, Zhirun <[email protected]>
Subject: [RFC 2/2] net/i40e: update requested queue pair num check for rounding

Since rounding up the requested queue pairs to allow the vf to request a non-aligned number was added, it may happen that the requested number is less than the available num of queues but the rounded up number is greater. In this case, it is not caught with the usual checks but later when there is a reset and failed setup.

By rounding earlier the checks can be done before a failed reset occurs, and a rounded max amount of available queues can be returned to the vf.

Quoted 7 lines
Quoted 2 lines

Applied to dpdk-next-net-intel.

These were checkpatch warnings because of whitespace (spaces before tabs), fixed while merging to next-net.

#4 lore raw

Re: [RFC 2/2] net/i40e: update requested queue pair num check for rounding

Quoted 24 lines · Ferruh Yigit
Quoted 23 lines · Qi Z
Quoted 22 lines

-----Original Message-----
From: Kevin Traynor [mailto:[email protected]]
Sent: Wednesday, March 6, 2019 12:31 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; Kevin Traynor <[email protected]>; Yan, Zhirun <[email protected]>
Subject: [RFC 2/2] net/i40e: update requested queue pair num check for rounding

Since rounding up the requested queue pairs to allow the vf to request a non-aligned number was added, it may happen that the requested number is less than the available num of queues but the rounded up number is greater. In this case, it is not caught with the usual checks but later when there is a reset and failed setup.

By rounding earlier the checks can be done before a failed reset occurs, and a rounded max amount of available queues can be returned to the vf.

Quoted 8 lines
Quoted 4 lines

Applied to dpdk-next-net-intel.

These were checkpatch warnings because of whitespace (spaces before tabs), fixed while merging to next-net.

Thanks Ferruh. Not spaces before tabs, but using spaces for alignment where there was room for an additional tab. I misinterpreted "spaces for alignment" in the CS note. Maybe it's clear for others, but I'll send a small clarification so I'll remember next time :-)

Acked-by on v1 1/2 Applied
#5 lore raw
In reply to Kevin Traynor
Quoted 10 lines

-----Original Message-----
From: Kevin Traynor [mailto:[email protected]]
Sent: Wednesday, March 6, 2019 12:31 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; Kevin Traynor <[email protected]>; [email protected]; Yan, Zhirun <[email protected]>
Subject: [PATCH 1/2] net/i40e: fix negative check on unsigned queue pairs

Quoted 7 lines

Fix the check and associated log. Also, fix a typo in other log.

Fixes 03d478e9609d ("net/i40e: support PF respond VF request more queues")

Applied to dpdk-next-net-intel.

Thanks
Qi