@@ -448,7 +448,7 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_id,
448448 (qtype << I40E_QINT_RQCTL_NEXTQ_TYPE_SHIFT ) |
449449 (pf_queue_id << I40E_QINT_RQCTL_NEXTQ_INDX_SHIFT ) |
450450 BIT (I40E_QINT_RQCTL_CAUSE_ENA_SHIFT ) |
451- ( itr_idx << I40E_QINT_RQCTL_ITR_INDX_SHIFT );
451+ FIELD_PREP ( I40E_QINT_RQCTL_ITR_INDX_MASK , itr_idx );
452452 wr32 (hw , reg_idx , reg );
453453 }
454454
@@ -653,6 +653,13 @@ static int i40e_config_vsi_tx_queue(struct i40e_vf *vf, u16 vsi_id,
653653
654654 /* only set the required fields */
655655 tx_ctx .base = info -> dma_ring_addr / 128 ;
656+
657+ /* ring_len has to be multiple of 8 */
658+ if (!IS_ALIGNED (info -> ring_len , 8 ) ||
659+ info -> ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710 ) {
660+ ret = - EINVAL ;
661+ goto error_context ;
662+ }
656663 tx_ctx .qlen = info -> ring_len ;
657664 tx_ctx .rdylist = le16_to_cpu (vsi -> info .qs_handle [0 ]);
658665 tx_ctx .rdylist_act = 0 ;
@@ -716,6 +723,13 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id,
716723
717724 /* only set the required fields */
718725 rx_ctx .base = info -> dma_ring_addr / 128 ;
726+
727+ /* ring_len has to be multiple of 32 */
728+ if (!IS_ALIGNED (info -> ring_len , 32 ) ||
729+ info -> ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710 ) {
730+ ret = - EINVAL ;
731+ goto error_param ;
732+ }
719733 rx_ctx .qlen = info -> ring_len ;
720734
721735 if (info -> splithdr_enabled ) {
@@ -1453,6 +1467,7 @@ static void i40e_trigger_vf_reset(struct i40e_vf *vf, bool flr)
14531467 * functions that may still be running at this point.
14541468 */
14551469 clear_bit (I40E_VF_STATE_INIT , & vf -> vf_states );
1470+ clear_bit (I40E_VF_STATE_RESOURCES_LOADED , & vf -> vf_states );
14561471
14571472 /* In the case of a VFLR, the HW has already reset the VF and we
14581473 * just need to clean up, so don't hit the VFRTRIG register.
@@ -2119,7 +2134,10 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
21192134 size_t len = 0 ;
21202135 int ret ;
21212136
2122- if (!i40e_sync_vf_state (vf , I40E_VF_STATE_INIT )) {
2137+ i40e_sync_vf_state (vf , I40E_VF_STATE_INIT );
2138+
2139+ if (!test_bit (I40E_VF_STATE_INIT , & vf -> vf_states ) ||
2140+ test_bit (I40E_VF_STATE_RESOURCES_LOADED , & vf -> vf_states )) {
21232141 aq_ret = - EINVAL ;
21242142 goto err ;
21252143 }
@@ -2222,6 +2240,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
22222240 vf -> default_lan_addr .addr );
22232241 }
22242242 set_bit (I40E_VF_STATE_ACTIVE , & vf -> vf_states );
2243+ set_bit (I40E_VF_STATE_RESOURCES_LOADED , & vf -> vf_states );
22252244
22262245err :
22272246 /* send the response back to the VF */
@@ -2384,7 +2403,7 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg)
23842403 }
23852404
23862405 if (vf -> adq_enabled ) {
2387- if (idx >= ARRAY_SIZE ( vf -> ch ) ) {
2406+ if (idx >= vf -> num_tc ) {
23882407 aq_ret = - ENODEV ;
23892408 goto error_param ;
23902409 }
@@ -2405,7 +2424,7 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg)
24052424 * to its appropriate VSIs based on TC mapping
24062425 */
24072426 if (vf -> adq_enabled ) {
2408- if (idx >= ARRAY_SIZE ( vf -> ch ) ) {
2427+ if (idx >= vf -> num_tc ) {
24092428 aq_ret = - ENODEV ;
24102429 goto error_param ;
24112430 }
@@ -2455,8 +2474,10 @@ static int i40e_validate_queue_map(struct i40e_vf *vf, u16 vsi_id,
24552474 u16 vsi_queue_id , queue_id ;
24562475
24572476 for_each_set_bit (vsi_queue_id , & queuemap , I40E_MAX_VSI_QP ) {
2458- if (vf -> adq_enabled ) {
2459- vsi_id = vf -> ch [vsi_queue_id / I40E_MAX_VF_VSI ].vsi_id ;
2477+ u16 idx = vsi_queue_id / I40E_MAX_VF_VSI ;
2478+
2479+ if (vf -> adq_enabled && idx < vf -> num_tc ) {
2480+ vsi_id = vf -> ch [idx ].vsi_id ;
24602481 queue_id = (vsi_queue_id % I40E_DEFAULT_QUEUES_PER_VF );
24612482 } else {
24622483 queue_id = vsi_queue_id ;
@@ -3589,7 +3610,7 @@ static int i40e_validate_cloud_filter(struct i40e_vf *vf,
35893610
35903611 /* action_meta is TC number here to which the filter is applied */
35913612 if (!tc_filter -> action_meta ||
3592- tc_filter -> action_meta > vf -> num_tc ) {
3613+ tc_filter -> action_meta >= vf -> num_tc ) {
35933614 dev_info (& pf -> pdev -> dev , "VF %d: Invalid TC number %u\n" ,
35943615 vf -> vf_id , tc_filter -> action_meta );
35953616 goto err ;
@@ -3887,6 +3908,8 @@ static int i40e_vc_del_cloud_filter(struct i40e_vf *vf, u8 *msg)
38873908 aq_ret );
38883909}
38893910
3911+ #define I40E_MAX_VF_CLOUD_FILTER 0xFF00
3912+
38903913/**
38913914 * i40e_vc_add_cloud_filter
38923915 * @vf: pointer to the VF info
@@ -3926,6 +3949,14 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg)
39263949 goto err_out ;
39273950 }
39283951
3952+ if (vf -> num_cloud_filters >= I40E_MAX_VF_CLOUD_FILTER ) {
3953+ dev_warn (& pf -> pdev -> dev ,
3954+ "VF %d: Max number of filters reached, can't apply cloud filter\n" ,
3955+ vf -> vf_id );
3956+ aq_ret = - ENOSPC ;
3957+ goto err_out ;
3958+ }
3959+
39293960 cfilter = kzalloc (sizeof (* cfilter ), GFP_KERNEL );
39303961 if (!cfilter ) {
39313962 aq_ret = - ENOMEM ;
0 commit comments