Skip to content

Commit 0ca683f

Browse files
jacob-kellergregkh
authored andcommitted
ice: pass VSI pointer into ice_vc_isvalid_q_id
commit a216059 upstream. 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 <jacob.e.keller@intel.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3a7ac49 commit 0ca683f

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
@@ -547,17 +547,15 @@ bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id)
547547

548548
/**
549549
* ice_vc_isvalid_q_id
550-
* @vf: pointer to the VF info
551-
* @vsi_id: VSI ID
550+
* @vsi: VSI to check queue ID against
552551
* @qid: VSI relative queue ID
553552
*
554553
* check for the valid queue ID
555554
*/
556-
static bool ice_vc_isvalid_q_id(struct ice_vf *vf, u16 vsi_id, u8 qid)
555+
static bool ice_vc_isvalid_q_id(struct ice_vsi *vsi, u8 qid)
557556
{
558-
struct ice_vsi *vsi = ice_find_vsi(vf->pf, vsi_id);
559557
/* allocated Tx and Rx queues should be always equal for VF VSI */
560-
return (vsi && (qid < vsi->alloc_txq));
558+
return qid < vsi->alloc_txq;
561559
}
562560

563561
/**
@@ -1257,7 +1255,7 @@ static int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg)
12571255
*/
12581256
q_map = vqs->rx_queues;
12591257
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1260-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1258+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
12611259
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
12621260
goto error_param;
12631261
}
@@ -1279,7 +1277,7 @@ static int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg)
12791277

12801278
q_map = vqs->tx_queues;
12811279
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1282-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1280+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
12831281
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
12841282
goto error_param;
12851283
}
@@ -1384,7 +1382,7 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)
13841382
q_map = vqs->tx_queues;
13851383

13861384
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1387-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1385+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
13881386
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
13891387
goto error_param;
13901388
}
@@ -1410,7 +1408,7 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)
14101408
bitmap_zero(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF);
14111409
} else if (q_map) {
14121410
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1413-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1411+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
14141412
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
14151413
goto error_param;
14161414
}
@@ -1466,7 +1464,7 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
14661464
for_each_set_bit(vsi_q_id_idx, &qmap, ICE_MAX_RSS_QS_PER_VF) {
14671465
vsi_q_id = vsi_q_id_idx;
14681466

1469-
if (!ice_vc_isvalid_q_id(vf, vsi->vsi_num, vsi_q_id))
1467+
if (!ice_vc_isvalid_q_id(vsi, vsi_q_id))
14701468
return VIRTCHNL_STATUS_ERR_PARAM;
14711469

14721470
q_vector->num_ring_rx++;
@@ -1480,7 +1478,7 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
14801478
for_each_set_bit(vsi_q_id_idx, &qmap, ICE_MAX_RSS_QS_PER_VF) {
14811479
vsi_q_id = vsi_q_id_idx;
14821480

1483-
if (!ice_vc_isvalid_q_id(vf, vsi->vsi_num, vsi_q_id))
1481+
if (!ice_vc_isvalid_q_id(vsi, vsi_q_id))
14841482
return VIRTCHNL_STATUS_ERR_PARAM;
14851483

14861484
q_vector->num_ring_tx++;
@@ -1629,7 +1627,7 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
16291627
qpi->txq.headwb_enabled ||
16301628
!ice_vc_isvalid_ring_len(qpi->txq.ring_len) ||
16311629
!ice_vc_isvalid_ring_len(qpi->rxq.ring_len) ||
1632-
!ice_vc_isvalid_q_id(vf, qci->vsi_id, qpi->txq.queue_id)) {
1630+
!ice_vc_isvalid_q_id(vsi, qpi->txq.queue_id)) {
16331631
goto error_param;
16341632
}
16351633

0 commit comments

Comments
 (0)