@@ -909,7 +909,7 @@ static void ice_set_dflt_vsi_ctx(struct ice_hw *hw, struct ice_vsi_ctx *ctxt)
909
909
* @vsi: the VSI being configured
910
910
* @ctxt: VSI context structure
911
911
*/
912
- static void ice_vsi_setup_q_map (struct ice_vsi * vsi , struct ice_vsi_ctx * ctxt )
912
+ static int ice_vsi_setup_q_map (struct ice_vsi * vsi , struct ice_vsi_ctx * ctxt )
913
913
{
914
914
u16 offset = 0 , qmap = 0 , tx_count = 0 , pow = 0 ;
915
915
u16 num_txq_per_tc , num_rxq_per_tc ;
@@ -982,7 +982,18 @@ static void ice_vsi_setup_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt)
982
982
else
983
983
vsi -> num_rxq = num_rxq_per_tc ;
984
984
985
+ if (vsi -> num_rxq > vsi -> alloc_rxq ) {
986
+ dev_err (ice_pf_to_dev (vsi -> back ), "Trying to use more Rx queues (%u), than were allocated (%u)!\n" ,
987
+ vsi -> num_rxq , vsi -> alloc_rxq );
988
+ return - EINVAL ;
989
+ }
990
+
985
991
vsi -> num_txq = tx_count ;
992
+ if (vsi -> num_txq > vsi -> alloc_txq ) {
993
+ dev_err (ice_pf_to_dev (vsi -> back ), "Trying to use more Tx queues (%u), than were allocated (%u)!\n" ,
994
+ vsi -> num_txq , vsi -> alloc_txq );
995
+ return - EINVAL ;
996
+ }
986
997
987
998
if (vsi -> type == ICE_VSI_VF && vsi -> num_txq != vsi -> num_rxq ) {
988
999
dev_dbg (ice_pf_to_dev (vsi -> back ), "VF VSI should have same number of Tx and Rx queues. Hence making them equal\n" );
@@ -1000,6 +1011,8 @@ static void ice_vsi_setup_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt)
1000
1011
*/
1001
1012
ctxt -> info .q_mapping [0 ] = cpu_to_le16 (vsi -> rxq_map [0 ]);
1002
1013
ctxt -> info .q_mapping [1 ] = cpu_to_le16 (vsi -> num_rxq );
1014
+
1015
+ return 0 ;
1003
1016
}
1004
1017
1005
1018
/**
@@ -1187,7 +1200,10 @@ static int ice_vsi_init(struct ice_vsi *vsi, bool init_vsi)
1187
1200
if (vsi -> type == ICE_VSI_CHNL ) {
1188
1201
ice_chnl_vsi_setup_q_map (vsi , ctxt );
1189
1202
} else {
1190
- ice_vsi_setup_q_map (vsi , ctxt );
1203
+ ret = ice_vsi_setup_q_map (vsi , ctxt );
1204
+ if (ret )
1205
+ goto out ;
1206
+
1191
1207
if (!init_vsi ) /* means VSI being updated */
1192
1208
/* must to indicate which section of VSI context are
1193
1209
* being modified
@@ -3464,7 +3480,7 @@ void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc)
3464
3480
*
3465
3481
* Prepares VSI tc_config to have queue configurations based on MQPRIO options.
3466
3482
*/
3467
- static void
3483
+ static int
3468
3484
ice_vsi_setup_q_map_mqprio (struct ice_vsi * vsi , struct ice_vsi_ctx * ctxt ,
3469
3485
u8 ena_tc )
3470
3486
{
@@ -3513,7 +3529,18 @@ ice_vsi_setup_q_map_mqprio(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt,
3513
3529
3514
3530
/* Set actual Tx/Rx queue pairs */
3515
3531
vsi -> num_txq = offset + qcount_tx ;
3532
+ if (vsi -> num_txq > vsi -> alloc_txq ) {
3533
+ dev_err (ice_pf_to_dev (vsi -> back ), "Trying to use more Tx queues (%u), than were allocated (%u)!\n" ,
3534
+ vsi -> num_txq , vsi -> alloc_txq );
3535
+ return - EINVAL ;
3536
+ }
3537
+
3516
3538
vsi -> num_rxq = offset + qcount_rx ;
3539
+ if (vsi -> num_rxq > vsi -> alloc_rxq ) {
3540
+ dev_err (ice_pf_to_dev (vsi -> back ), "Trying to use more Rx queues (%u), than were allocated (%u)!\n" ,
3541
+ vsi -> num_rxq , vsi -> alloc_rxq );
3542
+ return - EINVAL ;
3543
+ }
3517
3544
3518
3545
/* Setup queue TC[0].qmap for given VSI context */
3519
3546
ctxt -> info .tc_mapping [0 ] = cpu_to_le16 (qmap );
@@ -3531,6 +3558,8 @@ ice_vsi_setup_q_map_mqprio(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt,
3531
3558
dev_dbg (ice_pf_to_dev (vsi -> back ), "vsi->num_rxq = %d\n" , vsi -> num_rxq );
3532
3559
dev_dbg (ice_pf_to_dev (vsi -> back ), "all_numtc %u, all_enatc: 0x%04x, tc_cfg.numtc %u\n" ,
3533
3560
vsi -> all_numtc , vsi -> all_enatc , vsi -> tc_cfg .numtc );
3561
+
3562
+ return 0 ;
3534
3563
}
3535
3564
3536
3565
/**
@@ -3580,9 +3609,12 @@ int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc)
3580
3609
3581
3610
if (vsi -> type == ICE_VSI_PF &&
3582
3611
test_bit (ICE_FLAG_TC_MQPRIO , pf -> flags ))
3583
- ice_vsi_setup_q_map_mqprio (vsi , ctx , ena_tc );
3612
+ ret = ice_vsi_setup_q_map_mqprio (vsi , ctx , ena_tc );
3584
3613
else
3585
- ice_vsi_setup_q_map (vsi , ctx );
3614
+ ret = ice_vsi_setup_q_map (vsi , ctx );
3615
+
3616
+ if (ret )
3617
+ goto out ;
3586
3618
3587
3619
/* must to indicate which section of VSI context are being modified */
3588
3620
ctx -> info .valid_sections = cpu_to_le16 (ICE_AQ_VSI_PROP_RXQ_MAP_VALID );
0 commit comments