Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH S23 v4 14/15] ice: Change type for queue counts
Date: Thu, 25 Jul 2019 01:55:40 -0700	[thread overview]
Message-ID: <20190725085541.55104-14-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20190725085541.55104-1-anthony.l.nguyen@intel.com>

From: Pawel Kaminski <pawel.kaminski@intel.com>

These queue variables are being assigned values that are type u16.
Change the local variables to match these types. Since these
represent queue counts, they should never be negative.

Signed-off-by: Pawel Kaminski <pawel.kaminski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
v3: Change type back to u16
    Fix format specifiers and min_t type
    Redo commit message

v2: Change type from u16 to unsigned int
    Reword commit message
---
 .../net/ethernet/intel/ice/ice_virtchnl_pf.c  | 25 ++++++++++---------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
index 8a5bf9730fdf..61cf1c5af928 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
@@ -2337,11 +2337,11 @@ static int ice_vc_request_qs_msg(struct ice_vf *vf, u8 *msg)
 	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
 	struct virtchnl_vf_res_request *vfres =
 		(struct virtchnl_vf_res_request *)msg;
-	int req_queues = vfres->num_queue_pairs;
+	u16 req_queues = vfres->num_queue_pairs;
 	struct ice_pf *pf = vf->pf;
-	int max_allowed_vf_queues;
-	int tx_rx_queue_left;
-	int cur_queues;
+	u16 max_allowed_vf_queues;
+	u16 tx_rx_queue_left;
+	u16 cur_queues;
 
 	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
 		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
@@ -2349,29 +2349,30 @@ static int ice_vc_request_qs_msg(struct ice_vf *vf, u8 *msg)
 	}
 
 	cur_queues = vf->num_vf_qs;
-	tx_rx_queue_left = min_t(int, pf->q_left_tx, pf->q_left_rx);
+	tx_rx_queue_left = min_t(u16, pf->q_left_tx, pf->q_left_rx);
 	max_allowed_vf_queues = tx_rx_queue_left + cur_queues;
-	if (req_queues <= 0) {
+	if (!req_queues) {
 		dev_err(&pf->pdev->dev,
-			"VF %d tried to request %d queues. Ignoring.\n",
-			vf->vf_id, req_queues);
+			"VF %d tried to request 0 queues. Ignoring.\n",
+			vf->vf_id);
 	} else if (req_queues > ICE_MAX_BASE_QS_PER_VF) {
 		dev_err(&pf->pdev->dev,
 			"VF %d tried to request more than %d queues.\n",
 			vf->vf_id, ICE_MAX_BASE_QS_PER_VF);
 		vfres->num_queue_pairs = ICE_MAX_BASE_QS_PER_VF;
-	} else if (req_queues - cur_queues > tx_rx_queue_left) {
+	} else if (req_queues > cur_queues &&
+		   req_queues - cur_queues > tx_rx_queue_left) {
 		dev_warn(&pf->pdev->dev,
-			 "VF %d requested %d more queues, but only %d left.\n",
+			 "VF %d requested %u more queues, but only %u left.\n",
 			 vf->vf_id, req_queues - cur_queues, tx_rx_queue_left);
-		vfres->num_queue_pairs = min_t(int, max_allowed_vf_queues,
+		vfres->num_queue_pairs = min_t(u16, max_allowed_vf_queues,
 					       ICE_MAX_BASE_QS_PER_VF);
 	} else {
 		/* request is successful, then reset VF */
 		vf->num_req_qs = req_queues;
 		ice_vc_dis_vf(vf);
 		dev_info(&pf->pdev->dev,
-			 "VF %d granted request of %d queues.\n",
+			 "VF %d granted request of %u queues.\n",
 			 vf->vf_id, req_queues);
 		return 0;
 	}
-- 
2.20.1


  parent reply	other threads:[~2019-07-25  8:55 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-25  8:55 [Intel-wired-lan] [PATCH S23 v4 01/15] ice: Implement ethtool ops for channels Tony Nguyen
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 02/15] ice: Use the software based tail when checking for hung Tx ring Tony Nguyen
2019-07-31 17:33   ` Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 03/15] ice: Assume that more than one Rx queue is rare in ice_napi_poll Tony Nguyen
2019-07-31 17:34   ` Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 04/15] ice: Restructure VFs initialization flows Tony Nguyen
2019-07-31 17:34   ` Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 05/15] ice: fix set pause param autoneg check Tony Nguyen
2019-07-31 17:35   ` Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 06/15] ice: Set WB_ON_ITR when we don't re-enable interrupts Tony Nguyen
2019-07-31 17:35   ` Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 07/15] ice: Fix kernel hang with DCB reset in CEE mode Tony Nguyen
2019-07-31 17:36   ` Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 08/15] ice: allow empty rx descriptors Tony Nguyen
2019-07-31 17:36   ` Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 09/15] ice: Do not always bring up PF VSI in ice_ena_vsi() Tony Nguyen
2019-07-31 17:37   ` Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 10/15] ice: update GLINT_DYN_CTL and GLINT_VECT2FUNC register access Tony Nguyen
2019-07-31 17:37   ` Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 11/15] ice: Reduce wait times during VF bringup/reset Tony Nguyen
2019-07-31 17:38   ` Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 12/15] ice: Increase size of Mailbox receive queue for many VFs Tony Nguyen
2019-07-31 17:38   ` Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 13/15] ice: Move VF resources definition to SR-IOV specific file Tony Nguyen
2019-07-31 17:39   ` Bowers, AndrewX
2019-07-25  8:55 ` Tony Nguyen [this message]
2019-07-31 17:40   ` [Intel-wired-lan] [PATCH S23 v4 14/15] ice: Change type for queue counts Bowers, AndrewX
2019-07-25  8:55 ` [Intel-wired-lan] [PATCH S23 v4 15/15] ice: improve print for VF's when adding/deleting MAC filters Tony Nguyen
2019-07-31 17:40   ` Bowers, AndrewX
2019-07-31 17:33 ` [Intel-wired-lan] [PATCH S23 v4 01/15] ice: Implement ethtool ops for channels Bowers, AndrewX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190725085541.55104-14-anthony.l.nguyen@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox