Skip to content

Commit a216059

Browse files
jacob-kelleranguy11
authored andcommitted
ice: pass VSI pointer into ice_vc_isvalid_q_id
The ice_vc_isvalid_q_id() function takes a VSI index and a queue ID. It looks up the VSI from its index, and then validates that the queue number is valid for that VSI. The VSI ID passed is typically a VSI index from the VF. This VSI number is validated by the PF to ensure that it matches the VSI associated with the VF already. In every flow where ice_vc_isvalid_q_id() is called, the PF driver already has a pointer to the VSI associated with the VF. This pointer is obtained using ice_get_vf_vsi(), rather than looking up the VSI using the index sent by the VF. Since we already know which VSI to operate on, we can modify ice_vc_isvalid_q_id() to take a VSI pointer instead of a VSI index. Pass the VSI we found from ice_get_vf_vsi() instead of re-doing the lookup. This removes some unnecessary computation and scanning of the VSI list. It also removes the last place where the driver directly used the VSI number from the VF. This will pave the way for refactoring to communicate relative VSI numbers to the VF instead of absolute numbers from the PF space. Signed-off-by: Jacob Keller <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 09fcde5 commit a216059

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -562,17 +562,15 @@ bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id)
562562

563563
/**
564564
* ice_vc_isvalid_q_id
565-
* @vf: pointer to the VF info
566-
* @vsi_id: VSI ID
565+
* @vsi: VSI to check queue ID against
567566
* @qid: VSI relative queue ID
568567
*
569568
* check for the valid queue ID
570569
*/
571-
static bool ice_vc_isvalid_q_id(struct ice_vf *vf, u16 vsi_id, u8 qid)
570+
static bool ice_vc_isvalid_q_id(struct ice_vsi *vsi, u8 qid)
572571
{
573-
struct ice_vsi *vsi = ice_find_vsi(vf->pf, vsi_id);
574572
/* allocated Tx and Rx queues should be always equal for VF VSI */
575-
return (vsi && (qid < vsi->alloc_txq));
573+
return qid < vsi->alloc_txq;
576574
}
577575

578576
/**
@@ -1330,7 +1328,7 @@ static int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg)
13301328
*/
13311329
q_map = vqs->rx_queues;
13321330
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1333-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1331+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
13341332
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
13351333
goto error_param;
13361334
}
@@ -1352,7 +1350,7 @@ static int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg)
13521350

13531351
q_map = vqs->tx_queues;
13541352
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1355-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1353+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
13561354
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
13571355
goto error_param;
13581356
}
@@ -1457,7 +1455,7 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)
14571455
q_map = vqs->tx_queues;
14581456

14591457
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1460-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1458+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
14611459
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
14621460
goto error_param;
14631461
}
@@ -1483,7 +1481,7 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)
14831481
bitmap_zero(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF);
14841482
} else if (q_map) {
14851483
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1486-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1484+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
14871485
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
14881486
goto error_param;
14891487
}
@@ -1539,7 +1537,7 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
15391537
for_each_set_bit(vsi_q_id_idx, &qmap, ICE_MAX_RSS_QS_PER_VF) {
15401538
vsi_q_id = vsi_q_id_idx;
15411539

1542-
if (!ice_vc_isvalid_q_id(vf, vsi->vsi_num, vsi_q_id))
1540+
if (!ice_vc_isvalid_q_id(vsi, vsi_q_id))
15431541
return VIRTCHNL_STATUS_ERR_PARAM;
15441542

15451543
q_vector->num_ring_rx++;
@@ -1553,7 +1551,7 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
15531551
for_each_set_bit(vsi_q_id_idx, &qmap, ICE_MAX_RSS_QS_PER_VF) {
15541552
vsi_q_id = vsi_q_id_idx;
15551553

1556-
if (!ice_vc_isvalid_q_id(vf, vsi->vsi_num, vsi_q_id))
1554+
if (!ice_vc_isvalid_q_id(vsi, vsi_q_id))
15571555
return VIRTCHNL_STATUS_ERR_PARAM;
15581556

15591557
q_vector->num_ring_tx++;
@@ -1710,7 +1708,7 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
17101708
qpi->txq.headwb_enabled ||
17111709
!ice_vc_isvalid_ring_len(qpi->txq.ring_len) ||
17121710
!ice_vc_isvalid_ring_len(qpi->rxq.ring_len) ||
1713-
!ice_vc_isvalid_q_id(vf, qci->vsi_id, qpi->txq.queue_id)) {
1711+
!ice_vc_isvalid_q_id(vsi, qpi->txq.queue_id)) {
17141712
goto error_param;
17151713
}
17161714

0 commit comments

Comments
 (0)