From b89f6deb867f61c8b486a8db79a34cd19a9d2a66 Mon Sep 17 00:00:00 2001 From: Kevin Traynor Date: Tue, 5 Mar 2019 16:30:39 +0000 Subject: [PATCH] net/i40e: update queue number 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. Signed-off-by: Kevin Traynor Acked-by: Qi Zhang --- drivers/net/i40e/i40e_pf.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c index 0c4bdbcd18..91be45027a 100644 --- a/drivers/net/i40e/i40e_pf.c +++ b/drivers/net/i40e/i40e_pf.c @@ -1250,6 +1250,9 @@ 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", vf->vf_idx); @@ -1260,19 +1263,18 @@ i40e_pf_host_process_cmd_request_queues(struct i40e_pf_vf *vf, uint8_t *msg) I40E_MAX_QP_NUM_PER_VF); 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", - vf->vf_idx, - req_pairs - cur_pairs, - pf->qp_pool.num_free); - vfres->num_queue_pairs = pf->qp_pool.num_free + cur_pairs; + PMD_DRV_LOG(ERR, "VF %d requested %d queues (rounded to %d) " + "but only %d available\n", + vf->vf_idx, + 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); return 0; -- 2.20.1