From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH S56 08/13] ice: Refactor VIRTCHNL_OP_CONFIG_VSI_QUEUES handling
Date: Tue, 2 Mar 2021 10:15:40 -0800 [thread overview]
Message-ID: <20210302181545.51822-8-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20210302181545.51822-1-anthony.l.nguyen@intel.com>
From: Brett Creeley <brett.creeley@intel.com>
Currently, when a VF requests queue configuration via
VIRTCHNL_OP_CONFIG_VSI_QUEUES the PF driver expects that this message
will only be called once and we always assume the queues being
configured start from 0. This is incorrect and is causing issues when
a VF tries to send this message for multiple queue blocks. Fix this by
using the queue_id specified in the virtchnl message and allowing for
individual Rx and/or Tx queues to be configured.
Also, reduce the duplicated for loops for configuring the queues by
moving all the logic into a single for loop.
Signed-off-by: Brett Creeley <brett.creeley@intel.com>
---
drivers/net/ethernet/intel/ice/ice_lib.c | 27 ++++++++++
drivers/net/ethernet/intel/ice/ice_lib.h | 4 ++
.../net/ethernet/intel/ice/ice_virtchnl_pf.c | 51 ++++++++++---------
3 files changed, 59 insertions(+), 23 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 01371b377fbc..ddcbd5bfd058 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -1668,6 +1668,33 @@ ice_write_qrxflxp_cntxt(struct ice_hw *hw, u16 pf_q, u32 rxdid, u32 prio)
wr32(hw, QRXFLXP_CNTXT(pf_q), regval);
}
+int ice_vsi_cfg_single_rxq(struct ice_vsi *vsi, u16 q_idx)
+{
+ if (q_idx >= vsi->num_rxq)
+ return -EINVAL;
+
+ return ice_vsi_cfg_rxq(vsi->rx_rings[q_idx]);
+}
+
+int ice_vsi_cfg_single_txq(struct ice_vsi *vsi, struct ice_ring **tx_rings, u16 q_idx)
+{
+ struct ice_aqc_add_tx_qgrp *qg_buf;
+ int err;
+
+ if (q_idx >= vsi->alloc_txq || !tx_rings || !tx_rings[q_idx])
+ return -EINVAL;
+
+ qg_buf = kzalloc(struct_size(qg_buf, txqs, 1), GFP_KERNEL);
+ if (!qg_buf)
+ return -ENOMEM;
+
+ qg_buf->num_txqs = 1;
+
+ err = ice_vsi_cfg_txq(vsi, tx_rings[q_idx], qg_buf);
+ kfree(qg_buf);
+ return err;
+}
+
/**
* ice_vsi_cfg_rxqs - Configure the VSI for Rx
* @vsi: the VSI being configured
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.h b/drivers/net/ethernet/intel/ice/ice_lib.h
index 3da17895a2b1..4b16394da354 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.h
+++ b/drivers/net/ethernet/intel/ice/ice_lib.h
@@ -12,6 +12,10 @@ bool ice_pf_state_is_nominal(struct ice_pf *pf);
void ice_update_eth_stats(struct ice_vsi *vsi);
+int ice_vsi_cfg_single_rxq(struct ice_vsi *vsi, u16 q_idx);
+
+int ice_vsi_cfg_single_txq(struct ice_vsi *vsi, struct ice_ring **tx_rings, u16 q_idx);
+
int ice_vsi_cfg_rxqs(struct ice_vsi *vsi);
int ice_vsi_cfg_lan_txqs(struct ice_vsi *vsi);
diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
index 7ffad4c8a64e..420fcb58e0d3 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
@@ -3053,10 +3053,9 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
struct virtchnl_vsi_queue_config_info *qci =
(struct virtchnl_vsi_queue_config_info *)msg;
struct virtchnl_queue_pair_info *qpi;
- u16 num_rxq = 0, num_txq = 0;
struct ice_pf *pf = vf->pf;
struct ice_vsi *vsi;
- int i;
+ int i, q_idx;
if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
@@ -3094,18 +3093,31 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
goto error_param;
}
+
+ q_idx = qpi->rxq.queue_id;
+
+ /* make sure selected "q_idx" is in valid range of queues
+ * for selected "vsi"
+ */
+ if (q_idx >= vsi->alloc_txq || q_idx >= vsi->alloc_rxq) {
+ v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+ goto error_param;
+ }
+
/* copy Tx queue info from VF into VSI */
if (qpi->txq.ring_len > 0) {
- num_txq++;
vsi->tx_rings[i]->dma = qpi->txq.dma_ring_addr;
vsi->tx_rings[i]->count = qpi->txq.ring_len;
+ if (ice_vsi_cfg_single_txq(vsi, vsi->tx_rings, q_idx)) {
+ v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+ goto error_param;
+ }
}
/* copy Rx queue info from VF into VSI */
if (qpi->rxq.ring_len > 0) {
u16 max_frame_size = ice_vc_get_max_frame_size(vf);
- num_rxq++;
vsi->rx_rings[i]->dma = qpi->rxq.dma_ring_addr;
vsi->rx_rings[i]->count = qpi->rxq.ring_len;
@@ -3122,27 +3134,20 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
goto error_param;
}
- }
- vsi->max_frame = qpi->rxq.max_pkt_size;
- /* add space for the port VLAN since the VF driver is not
- * expected to account for it in the MTU calculation
- */
- if (vf->port_vlan_info)
- vsi->max_frame += VLAN_HLEN;
- }
-
- /* VF can request to configure less than allocated queues or default
- * allocated queues. So update the VSI with new number
- */
- vsi->num_txq = num_txq;
- vsi->num_rxq = num_rxq;
- /* All queues of VF VSI are in TC 0 */
- vsi->tc_cfg.tc_info[0].qcount_tx = num_txq;
- vsi->tc_cfg.tc_info[0].qcount_rx = num_rxq;
+ vsi->max_frame = qpi->rxq.max_pkt_size;
+ /* add space for the port VLAN since the VF driver is not
+ * expected to account for it in the MTU calculation
+ */
+ if (vf->port_vlan_info)
+ vsi->max_frame += VLAN_HLEN;
- if (ice_vsi_cfg_lan_txqs(vsi) || ice_vsi_cfg_rxqs(vsi))
- v_ret = VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR;
+ if (ice_vsi_cfg_single_rxq(vsi, q_idx)) {
+ v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+ goto error_param;
+ }
+ }
+ }
error_param:
/* send the response to the VF */
--
2.20.1
next prev parent reply other threads:[~2021-03-02 18:15 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 18:15 [Intel-wired-lan] [PATCH S56 01/13] ice: Change ice_vsi_setup_q_map() to not depend on RSS Tony Nguyen
2021-03-02 18:15 ` [Intel-wired-lan] [PATCH S56 02/13] ice: Refactor promiscuous functions Tony Nguyen
2021-03-13 0:04 ` Brelinski, TonyX
2021-04-19 18:51 ` Jankowski, Konrad0
2021-03-02 18:15 ` [Intel-wired-lan] [PATCH S56 03/13] ice: Refactor get/set RSS LUT to use struct parameter Tony Nguyen
2021-03-13 0:05 ` Brelinski, TonyX
2021-03-02 18:15 ` [Intel-wired-lan] [PATCH S56 04/13] ice: Refactor ice_set/get_rss into LUT and key specific functions Tony Nguyen
2021-03-13 0:07 ` Brelinski, TonyX
2021-03-02 18:15 ` [Intel-wired-lan] [PATCH S56 05/13] ice: Consolidate VSI state and flags Tony Nguyen
2021-03-13 0:09 ` Brelinski, TonyX
2021-03-02 18:15 ` [Intel-wired-lan] [PATCH S56 06/13] ice: Drop leading underscores in enum ice_pf_state Tony Nguyen
2021-03-13 0:10 ` Brelinski, TonyX
2021-03-02 18:15 ` [Intel-wired-lan] [PATCH S56 07/13] ice: Add helper function to get the VF's VSI Tony Nguyen
2021-04-21 18:48 ` Jankowski, Konrad0
2021-03-02 18:15 ` Tony Nguyen [this message]
2021-04-21 18:47 ` [Intel-wired-lan] [PATCH S56 08/13] ice: Refactor VIRTCHNL_OP_CONFIG_VSI_QUEUES handling Jankowski, Konrad0
2021-03-02 18:15 ` [Intel-wired-lan] [PATCH S56 09/13] ice: Add new VSI states to track netdev alloc/registration Tony Nguyen
2021-03-13 0:12 ` Brelinski, TonyX
2021-03-02 18:15 ` [Intel-wired-lan] [PATCH S56 10/13] ice: cleanup style issues Tony Nguyen
2021-03-13 0:13 ` Brelinski, TonyX
2021-03-02 18:15 ` [Intel-wired-lan] [PATCH S56 11/13] ice: Correct comment block style Tony Nguyen
2021-03-13 0:16 ` Brelinski, TonyX
2021-03-02 18:15 ` [Intel-wired-lan] [PATCH S56 12/13] ice: Remove unnecessary blank line Tony Nguyen
2021-03-13 0:17 ` Brelinski, TonyX
2021-03-02 18:15 ` [Intel-wired-lan] [PATCH S56 13/13] ice: Fix prototype warnings Tony Nguyen
2021-03-13 0:18 ` Brelinski, TonyX
2021-03-12 0:40 ` [Intel-wired-lan] [PATCH S56 01/13] ice: Change ice_vsi_setup_q_map() to not depend on RSS Brelinski, TonyX
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=20210302181545.51822-8-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