Skip to content

Commit eb21b4e

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 <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d46a546 commit eb21b4e

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

551551
/**
552552
* ice_vc_isvalid_q_id
553-
* @vf: pointer to the VF info
554-
* @vsi_id: VSI ID
553+
* @vsi: VSI to check queue ID against
555554
* @qid: VSI relative queue ID
556555
*
557556
* check for the valid queue ID
558557
*/
559-
static bool ice_vc_isvalid_q_id(struct ice_vf *vf, u16 vsi_id, u8 qid)
558+
static bool ice_vc_isvalid_q_id(struct ice_vsi *vsi, u8 qid)
560559
{
561-
struct ice_vsi *vsi = ice_find_vsi(vf->pf, vsi_id);
562560
/* allocated Tx and Rx queues should be always equal for VF VSI */
563-
return (vsi && (qid < vsi->alloc_txq));
561+
return qid < vsi->alloc_txq;
564562
}
565563

566564
/**
@@ -1318,7 +1316,7 @@ static int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg)
13181316
*/
13191317
q_map = vqs->rx_queues;
13201318
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1321-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1319+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
13221320
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
13231321
goto error_param;
13241322
}
@@ -1340,7 +1338,7 @@ static int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg)
13401338

13411339
q_map = vqs->tx_queues;
13421340
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1343-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1341+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
13441342
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
13451343
goto error_param;
13461344
}
@@ -1445,7 +1443,7 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)
14451443
q_map = vqs->tx_queues;
14461444

14471445
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1448-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1446+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
14491447
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
14501448
goto error_param;
14511449
}
@@ -1471,7 +1469,7 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)
14711469
bitmap_zero(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF);
14721470
} else if (q_map) {
14731471
for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
1474-
if (!ice_vc_isvalid_q_id(vf, vqs->vsi_id, vf_q_id)) {
1472+
if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
14751473
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
14761474
goto error_param;
14771475
}
@@ -1527,7 +1525,7 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
15271525
for_each_set_bit(vsi_q_id_idx, &qmap, ICE_MAX_RSS_QS_PER_VF) {
15281526
vsi_q_id = vsi_q_id_idx;
15291527

1530-
if (!ice_vc_isvalid_q_id(vf, vsi->vsi_num, vsi_q_id))
1528+
if (!ice_vc_isvalid_q_id(vsi, vsi_q_id))
15311529
return VIRTCHNL_STATUS_ERR_PARAM;
15321530

15331531
q_vector->num_ring_rx++;
@@ -1541,7 +1539,7 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
15411539
for_each_set_bit(vsi_q_id_idx, &qmap, ICE_MAX_RSS_QS_PER_VF) {
15421540
vsi_q_id = vsi_q_id_idx;
15431541

1544-
if (!ice_vc_isvalid_q_id(vf, vsi->vsi_num, vsi_q_id))
1542+
if (!ice_vc_isvalid_q_id(vsi, vsi_q_id))
15451543
return VIRTCHNL_STATUS_ERR_PARAM;
15461544

15471545
q_vector->num_ring_tx++;
@@ -1698,7 +1696,7 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
16981696
qpi->txq.headwb_enabled ||
16991697
!ice_vc_isvalid_ring_len(qpi->txq.ring_len) ||
17001698
!ice_vc_isvalid_ring_len(qpi->rxq.ring_len) ||
1701-
!ice_vc_isvalid_q_id(vf, qci->vsi_id, qpi->txq.queue_id)) {
1699+
!ice_vc_isvalid_q_id(vsi, qpi->txq.queue_id)) {
17021700
goto error_param;
17031701
}
17041702

0 commit comments

Comments
 (0)