Skip to content

Commit 7ad1544

Browse files
bcreeley13anguy11
authored andcommitted
ice: Refactor VIRTCHNL_OP_CONFIG_VSI_QUEUES handling
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 <[email protected]> Tested-by: Konrad Jankowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 43c7f91 commit 7ad1544

File tree

3 files changed

+59
-23
lines changed

3 files changed

+59
-23
lines changed

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,33 @@ ice_write_qrxflxp_cntxt(struct ice_hw *hw, u16 pf_q, u32 rxdid, u32 prio)
16811681
wr32(hw, QRXFLXP_CNTXT(pf_q), regval);
16821682
}
16831683

1684+
int ice_vsi_cfg_single_rxq(struct ice_vsi *vsi, u16 q_idx)
1685+
{
1686+
if (q_idx >= vsi->num_rxq)
1687+
return -EINVAL;
1688+
1689+
return ice_vsi_cfg_rxq(vsi->rx_rings[q_idx]);
1690+
}
1691+
1692+
int ice_vsi_cfg_single_txq(struct ice_vsi *vsi, struct ice_ring **tx_rings, u16 q_idx)
1693+
{
1694+
struct ice_aqc_add_tx_qgrp *qg_buf;
1695+
int err;
1696+
1697+
if (q_idx >= vsi->alloc_txq || !tx_rings || !tx_rings[q_idx])
1698+
return -EINVAL;
1699+
1700+
qg_buf = kzalloc(struct_size(qg_buf, txqs, 1), GFP_KERNEL);
1701+
if (!qg_buf)
1702+
return -ENOMEM;
1703+
1704+
qg_buf->num_txqs = 1;
1705+
1706+
err = ice_vsi_cfg_txq(vsi, tx_rings[q_idx], qg_buf);
1707+
kfree(qg_buf);
1708+
return err;
1709+
}
1710+
16841711
/**
16851712
* ice_vsi_cfg_rxqs - Configure the VSI for Rx
16861713
* @vsi: the VSI being configured

drivers/net/ethernet/intel/ice/ice_lib.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ bool ice_pf_state_is_nominal(struct ice_pf *pf);
1212

1313
void ice_update_eth_stats(struct ice_vsi *vsi);
1414

15+
int ice_vsi_cfg_single_rxq(struct ice_vsi *vsi, u16 q_idx);
16+
17+
int ice_vsi_cfg_single_txq(struct ice_vsi *vsi, struct ice_ring **tx_rings, u16 q_idx);
18+
1519
int ice_vsi_cfg_rxqs(struct ice_vsi *vsi);
1620

1721
int ice_vsi_cfg_lan_txqs(struct ice_vsi *vsi);

drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3537,10 +3537,9 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
35373537
struct virtchnl_vsi_queue_config_info *qci =
35383538
(struct virtchnl_vsi_queue_config_info *)msg;
35393539
struct virtchnl_queue_pair_info *qpi;
3540-
u16 num_rxq = 0, num_txq = 0;
35413540
struct ice_pf *pf = vf->pf;
35423541
struct ice_vsi *vsi;
3543-
int i;
3542+
int i, q_idx;
35443543

35453544
if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
35463545
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
@@ -3578,18 +3577,31 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
35783577
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
35793578
goto error_param;
35803579
}
3580+
3581+
q_idx = qpi->rxq.queue_id;
3582+
3583+
/* make sure selected "q_idx" is in valid range of queues
3584+
* for selected "vsi"
3585+
*/
3586+
if (q_idx >= vsi->alloc_txq || q_idx >= vsi->alloc_rxq) {
3587+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
3588+
goto error_param;
3589+
}
3590+
35813591
/* copy Tx queue info from VF into VSI */
35823592
if (qpi->txq.ring_len > 0) {
3583-
num_txq++;
35843593
vsi->tx_rings[i]->dma = qpi->txq.dma_ring_addr;
35853594
vsi->tx_rings[i]->count = qpi->txq.ring_len;
3595+
if (ice_vsi_cfg_single_txq(vsi, vsi->tx_rings, q_idx)) {
3596+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
3597+
goto error_param;
3598+
}
35863599
}
35873600

35883601
/* copy Rx queue info from VF into VSI */
35893602
if (qpi->rxq.ring_len > 0) {
35903603
u16 max_frame_size = ice_vc_get_max_frame_size(vf);
35913604

3592-
num_rxq++;
35933605
vsi->rx_rings[i]->dma = qpi->rxq.dma_ring_addr;
35943606
vsi->rx_rings[i]->count = qpi->rxq.ring_len;
35953607

@@ -3606,27 +3618,20 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
36063618
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
36073619
goto error_param;
36083620
}
3609-
}
36103621

3611-
vsi->max_frame = qpi->rxq.max_pkt_size;
3612-
/* add space for the port VLAN since the VF driver is not
3613-
* expected to account for it in the MTU calculation
3614-
*/
3615-
if (vf->port_vlan_info)
3616-
vsi->max_frame += VLAN_HLEN;
3617-
}
3618-
3619-
/* VF can request to configure less than allocated queues or default
3620-
* allocated queues. So update the VSI with new number
3621-
*/
3622-
vsi->num_txq = num_txq;
3623-
vsi->num_rxq = num_rxq;
3624-
/* All queues of VF VSI are in TC 0 */
3625-
vsi->tc_cfg.tc_info[0].qcount_tx = num_txq;
3626-
vsi->tc_cfg.tc_info[0].qcount_rx = num_rxq;
3622+
vsi->max_frame = qpi->rxq.max_pkt_size;
3623+
/* add space for the port VLAN since the VF driver is not
3624+
* expected to account for it in the MTU calculation
3625+
*/
3626+
if (vf->port_vlan_info)
3627+
vsi->max_frame += VLAN_HLEN;
36273628

3628-
if (ice_vsi_cfg_lan_txqs(vsi) || ice_vsi_cfg_rxqs(vsi))
3629-
v_ret = VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR;
3629+
if (ice_vsi_cfg_single_rxq(vsi, q_idx)) {
3630+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
3631+
goto error_param;
3632+
}
3633+
}
3634+
}
36303635

36313636
error_param:
36323637
/* send the response to the VF */

0 commit comments

Comments
 (0)