All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arkady Gilinsky <arkady.gilinsky@harmonicinc.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH net] i40e/iavf: Fix msg interface between VF and PF
Date: Mon, 4 Nov 2019 05:32:25 +0000	[thread overview]
Message-ID: <1572845537.13810.225.camel@harmonicinc.com> (raw)

From af5ab2aaa51882bb7111b026882fe217ed81c15b Mon Sep 17 00:00:00 2001
From: Arkady Gilinsky <arkady.gilinsky@harmonicinc
.com>
Date: Sun, 3 Nov 2019 20:37:21 +0200
Subject: [PATCH net] i40e/iavf: Fix msg interface between VF and PF

?* The original issue was that iavf driver passing TX/RX queues
???as bitmap in iavf_disable_queues and the i40e driver
???interprets this message as an absolute number in
???i40e_vc_disable_queues_msg, so the validation in the
???latter function always fail.
???This commit reorganize the msg interface between i40e and iavf
???between the iavf_disable_queues and i40e_vc_disable_queues_msg
???functions (also for iavf_enable_queues and i40e_vc_enable_queues_msg).
???Now both drivers operate with number of queues instead of
???bitmap. Also the commit introduces range check in
???i40e_vc_enable_queues_msg function.

Signed-off-by: Arkady Gilinsky <arkady.gilinsky@harmonicinc.com>
---
?drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 23 ++++++++++++++++------
?drivers/net/ethernet/intel/iavf/iavf_virtchnl.c????|??6 ++++--
?2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 3d2440838822..c650eb91982a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -2352,13 +2352,22 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg)
?		goto error_param;
?	}
?
-	/* Use the queue bit map sent by the VF */
-	if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx], vqs->rx_queues,
+	if ((vqs->rx_queues == 0 && vqs->tx_queues == 0) ||
+	????vqs->rx_queues > I40E_MAX_VF_QUEUES ||
+	????vqs->tx_queues > I40E_MAX_VF_QUEUES) {
+		aq_ret = I40E_ERR_PARAM;
+		goto error_param;
+	}
+
+	/* Build the queue bit map from value sent by the VF */
+	if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx],
+				??BIT(vqs->rx_queues) - 1,
?				??true)) {
?		aq_ret = I40E_ERR_TIMEOUT;
?		goto error_param;
?	}
-	if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx], vqs->tx_queues,
+	if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx],
+				??BIT(vqs->tx_queues) - 1,
?				??true)) {
?		aq_ret = I40E_ERR_TIMEOUT;
?		goto error_param;
@@ -2416,13 +2425,15 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg)
?		goto error_param;
?	}
?
-	/* Use the queue bit map sent by the VF */
-	if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx], vqs->tx_queues,
+	/* Build the queue bit map from value sent by the VF */
+	if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx],
+				??BIT(vqs->tx_queues) - 1,
?				??false)) {
?		aq_ret = I40E_ERR_TIMEOUT;
?		goto error_param;
?	}
-	if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx], vqs->rx_queues,
+	if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx],
+				??BIT(vqs->rx_queues) - 1,
?				??false)) {
?		aq_ret = I40E_ERR_TIMEOUT;
?		goto error_param;
diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
index c46770eba320..271f144bf05b 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
@@ -308,7 +308,8 @@ void iavf_enable_queues(struct iavf_adapter *adapter)
?	}
?	adapter->current_op = VIRTCHNL_OP_ENABLE_QUEUES;
?	vqs.vsi_id = adapter->vsi_res->vsi_id;
-	vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
+	/* Send the queues number to PF */
+	vqs.tx_queues = adapter->num_active_queues;
?	vqs.rx_queues = vqs.tx_queues;
?	adapter->aq_required &= ~IAVF_FLAG_AQ_ENABLE_QUEUES;
?	iavf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_QUEUES,
@@ -333,7 +334,8 @@ void iavf_disable_queues(struct iavf_adapter *adapter)
?	}
?	adapter->current_op = VIRTCHNL_OP_DISABLE_QUEUES;
?	vqs.vsi_id = adapter->vsi_res->vsi_id;
-	vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
+	/* Send the queues number to PF */
+	vqs.tx_queues = adapter->num_active_queues;
?	vqs.rx_queues = vqs.tx_queues;
?	adapter->aq_required &= ~IAVF_FLAG_AQ_DISABLE_QUEUES;
?	iavf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_QUEUES,
--?
2.11.0


WARNING: multiple messages have this Message-ID (diff)
From: Arkady Gilinsky <arkady.gilinsky@harmonicinc.com>
To: "intel-wired-lan@lists.osuosl.org"
	<intel-wired-lan@lists.osuosl.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"jeffrey.t.kirsher@intel.com" <jeffrey.t.kirsher@intel.com>
Cc: Arkady Gilinsky <arcadyg@gmail.com>
Subject: [PATCH net] i40e/iavf: Fix msg interface between VF and PF
Date: Mon, 4 Nov 2019 05:32:25 +0000	[thread overview]
Message-ID: <1572845537.13810.225.camel@harmonicinc.com> (raw)

From af5ab2aaa51882bb7111b026882fe217ed81c15b Mon Sep 17 00:00:00 2001
From: Arkady Gilinsky <arkady.gilinsky@harmonicinc
.com>
Date: Sun, 3 Nov 2019 20:37:21 +0200
Subject: [PATCH net] i40e/iavf: Fix msg interface between VF and PF

 * The original issue was that iavf driver passing TX/RX queues
   as bitmap in iavf_disable_queues and the i40e driver
   interprets this message as an absolute number in
   i40e_vc_disable_queues_msg, so the validation in the
   latter function always fail.
   This commit reorganize the msg interface between i40e and iavf
   between the iavf_disable_queues and i40e_vc_disable_queues_msg
   functions (also for iavf_enable_queues and i40e_vc_enable_queues_msg).
   Now both drivers operate with number of queues instead of
   bitmap. Also the commit introduces range check in
   i40e_vc_enable_queues_msg function.

Signed-off-by: Arkady Gilinsky <arkady.gilinsky@harmonicinc.com>
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 23 ++++++++++++++++------
 drivers/net/ethernet/intel/iavf/iavf_virtchnl.c    |  6 ++++--
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 3d2440838822..c650eb91982a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -2352,13 +2352,22 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg)
 		goto error_param;
 	}
 
-	/* Use the queue bit map sent by the VF */
-	if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx], vqs->rx_queues,
+	if ((vqs->rx_queues == 0 && vqs->tx_queues == 0) ||
+	    vqs->rx_queues > I40E_MAX_VF_QUEUES ||
+	    vqs->tx_queues > I40E_MAX_VF_QUEUES) {
+		aq_ret = I40E_ERR_PARAM;
+		goto error_param;
+	}
+
+	/* Build the queue bit map from value sent by the VF */
+	if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx],
+				  BIT(vqs->rx_queues) - 1,
 				  true)) {
 		aq_ret = I40E_ERR_TIMEOUT;
 		goto error_param;
 	}
-	if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx], vqs->tx_queues,
+	if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx],
+				  BIT(vqs->tx_queues) - 1,
 				  true)) {
 		aq_ret = I40E_ERR_TIMEOUT;
 		goto error_param;
@@ -2416,13 +2425,15 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg)
 		goto error_param;
 	}
 
-	/* Use the queue bit map sent by the VF */
-	if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx], vqs->tx_queues,
+	/* Build the queue bit map from value sent by the VF */
+	if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx],
+				  BIT(vqs->tx_queues) - 1,
 				  false)) {
 		aq_ret = I40E_ERR_TIMEOUT;
 		goto error_param;
 	}
-	if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx], vqs->rx_queues,
+	if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx],
+				  BIT(vqs->rx_queues) - 1,
 				  false)) {
 		aq_ret = I40E_ERR_TIMEOUT;
 		goto error_param;
diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
index c46770eba320..271f144bf05b 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
@@ -308,7 +308,8 @@ void iavf_enable_queues(struct iavf_adapter *adapter)
 	}
 	adapter->current_op = VIRTCHNL_OP_ENABLE_QUEUES;
 	vqs.vsi_id = adapter->vsi_res->vsi_id;
-	vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
+	/* Send the queues number to PF */
+	vqs.tx_queues = adapter->num_active_queues;
 	vqs.rx_queues = vqs.tx_queues;
 	adapter->aq_required &= ~IAVF_FLAG_AQ_ENABLE_QUEUES;
 	iavf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_QUEUES,
@@ -333,7 +334,8 @@ void iavf_disable_queues(struct iavf_adapter *adapter)
 	}
 	adapter->current_op = VIRTCHNL_OP_DISABLE_QUEUES;
 	vqs.vsi_id = adapter->vsi_res->vsi_id;
-	vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
+	/* Send the queues number to PF */
+	vqs.tx_queues = adapter->num_active_queues;
 	vqs.rx_queues = vqs.tx_queues;
 	adapter->aq_required &= ~IAVF_FLAG_AQ_DISABLE_QUEUES;
 	iavf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_QUEUES,
-- 
2.11.0


             reply	other threads:[~2019-11-04  5:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04  5:32 Arkady Gilinsky [this message]
2019-11-04  5:32 ` [PATCH net] i40e/iavf: Fix msg interface between VF and PF Arkady Gilinsky
2019-11-04 23:43 ` [Intel-wired-lan] " Creeley, Brett
2019-11-04 23:43   ` Creeley, Brett
2019-11-05  5:23   ` [Intel-wired-lan] [EXTERNAL] " Arkady Gilinsky
2019-11-05  5:23     ` Arkady Gilinsky
2019-11-05 16:55     ` [Intel-wired-lan] " Creeley, Brett
2019-11-05 16:55       ` Creeley, Brett
2019-11-06  5:30       ` [Intel-wired-lan] " Arkady Gilinsky
2019-11-06  5:30         ` Arkady Gilinsky
2019-11-07 19:38         ` [Intel-wired-lan] " Jeff Kirsher
2019-11-07 19:38           ` Jeff Kirsher
2019-11-08 16:43           ` [Intel-wired-lan] " Creeley, Brett
2019-11-08 16:43             ` Creeley, Brett
2019-11-12  7:33             ` [Intel-wired-lan] " Arkady Gilinsky
2019-11-12  7:33               ` Arkady Gilinsky
2019-11-13 18:47               ` [Intel-wired-lan] " Jeff Kirsher
2019-11-13 18:47                 ` Jeff Kirsher

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=1572845537.13810.225.camel@harmonicinc.com \
    --to=arkady.gilinsky@harmonicinc.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.