@@ -1948,6 +1948,32 @@ static int i40e_vc_send_resp_to_vf(struct i40e_vf *vf,
1948
1948
return i40e_vc_send_msg_to_vf (vf , opcode , retval , NULL , 0 );
1949
1949
}
1950
1950
1951
+ /**
1952
+ * i40e_sync_vf_state
1953
+ * @vf: pointer to the VF info
1954
+ * @state: VF state
1955
+ *
1956
+ * Called from a VF message to synchronize the service with a potential
1957
+ * VF reset state
1958
+ **/
1959
+ static bool i40e_sync_vf_state (struct i40e_vf * vf , enum i40e_vf_states state )
1960
+ {
1961
+ int i ;
1962
+
1963
+ /* When handling some messages, it needs VF state to be set.
1964
+ * It is possible that this flag is cleared during VF reset,
1965
+ * so there is a need to wait until the end of the reset to
1966
+ * handle the request message correctly.
1967
+ */
1968
+ for (i = 0 ; i < I40E_VF_STATE_WAIT_COUNT ; i ++ ) {
1969
+ if (test_bit (state , & vf -> vf_states ))
1970
+ return true;
1971
+ usleep_range (10000 , 20000 );
1972
+ }
1973
+
1974
+ return test_bit (state , & vf -> vf_states );
1975
+ }
1976
+
1951
1977
/**
1952
1978
* i40e_vc_get_version_msg
1953
1979
* @vf: pointer to the VF info
@@ -2008,7 +2034,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
2008
2034
size_t len = 0 ;
2009
2035
int ret ;
2010
2036
2011
- if (!test_bit ( I40E_VF_STATE_INIT , & vf -> vf_states )) {
2037
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_INIT )) {
2012
2038
aq_ret = I40E_ERR_PARAM ;
2013
2039
goto err ;
2014
2040
}
@@ -2131,7 +2157,7 @@ static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf, u8 *msg)
2131
2157
bool allmulti = false;
2132
2158
bool alluni = false;
2133
2159
2134
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
2160
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
2135
2161
aq_ret = I40E_ERR_PARAM ;
2136
2162
goto err_out ;
2137
2163
}
@@ -2219,7 +2245,7 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg)
2219
2245
struct i40e_vsi * vsi ;
2220
2246
u16 num_qps_all = 0 ;
2221
2247
2222
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
2248
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
2223
2249
aq_ret = I40E_ERR_PARAM ;
2224
2250
goto error_param ;
2225
2251
}
@@ -2368,7 +2394,7 @@ static int i40e_vc_config_irq_map_msg(struct i40e_vf *vf, u8 *msg)
2368
2394
i40e_status aq_ret = 0 ;
2369
2395
int i ;
2370
2396
2371
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
2397
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
2372
2398
aq_ret = I40E_ERR_PARAM ;
2373
2399
goto error_param ;
2374
2400
}
@@ -2540,7 +2566,7 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg)
2540
2566
struct i40e_pf * pf = vf -> pf ;
2541
2567
i40e_status aq_ret = 0 ;
2542
2568
2543
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
2569
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
2544
2570
aq_ret = I40E_ERR_PARAM ;
2545
2571
goto error_param ;
2546
2572
}
@@ -2590,7 +2616,7 @@ static int i40e_vc_request_queues_msg(struct i40e_vf *vf, u8 *msg)
2590
2616
u8 cur_pairs = vf -> num_queue_pairs ;
2591
2617
struct i40e_pf * pf = vf -> pf ;
2592
2618
2593
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ))
2619
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ))
2594
2620
return - EINVAL ;
2595
2621
2596
2622
if (req_pairs > I40E_MAX_VF_QUEUES ) {
@@ -2635,7 +2661,7 @@ static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg)
2635
2661
2636
2662
memset (& stats , 0 , sizeof (struct i40e_eth_stats ));
2637
2663
2638
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
2664
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
2639
2665
aq_ret = I40E_ERR_PARAM ;
2640
2666
goto error_param ;
2641
2667
}
@@ -2752,7 +2778,7 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
2752
2778
i40e_status ret = 0 ;
2753
2779
int i ;
2754
2780
2755
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ) ||
2781
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ) ||
2756
2782
!i40e_vc_isvalid_vsi_id (vf , al -> vsi_id )) {
2757
2783
ret = I40E_ERR_PARAM ;
2758
2784
goto error_param ;
@@ -2824,7 +2850,7 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
2824
2850
i40e_status ret = 0 ;
2825
2851
int i ;
2826
2852
2827
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ) ||
2853
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ) ||
2828
2854
!i40e_vc_isvalid_vsi_id (vf , al -> vsi_id )) {
2829
2855
ret = I40E_ERR_PARAM ;
2830
2856
goto error_param ;
@@ -2968,7 +2994,7 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg)
2968
2994
i40e_status aq_ret = 0 ;
2969
2995
int i ;
2970
2996
2971
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ) ||
2997
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ) ||
2972
2998
!i40e_vc_isvalid_vsi_id (vf , vfl -> vsi_id )) {
2973
2999
aq_ret = I40E_ERR_PARAM ;
2974
3000
goto error_param ;
@@ -3088,9 +3114,9 @@ static int i40e_vc_config_rss_key(struct i40e_vf *vf, u8 *msg)
3088
3114
struct i40e_vsi * vsi = NULL ;
3089
3115
i40e_status aq_ret = 0 ;
3090
3116
3091
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ) ||
3117
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ) ||
3092
3118
!i40e_vc_isvalid_vsi_id (vf , vrk -> vsi_id ) ||
3093
- ( vrk -> key_len != I40E_HKEY_ARRAY_SIZE ) ) {
3119
+ vrk -> key_len != I40E_HKEY_ARRAY_SIZE ) {
3094
3120
aq_ret = I40E_ERR_PARAM ;
3095
3121
goto err ;
3096
3122
}
@@ -3119,9 +3145,9 @@ static int i40e_vc_config_rss_lut(struct i40e_vf *vf, u8 *msg)
3119
3145
i40e_status aq_ret = 0 ;
3120
3146
u16 i ;
3121
3147
3122
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ) ||
3148
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ) ||
3123
3149
!i40e_vc_isvalid_vsi_id (vf , vrl -> vsi_id ) ||
3124
- ( vrl -> lut_entries != I40E_VF_HLUT_ARRAY_SIZE ) ) {
3150
+ vrl -> lut_entries != I40E_VF_HLUT_ARRAY_SIZE ) {
3125
3151
aq_ret = I40E_ERR_PARAM ;
3126
3152
goto err ;
3127
3153
}
@@ -3154,7 +3180,7 @@ static int i40e_vc_get_rss_hena(struct i40e_vf *vf, u8 *msg)
3154
3180
i40e_status aq_ret = 0 ;
3155
3181
int len = 0 ;
3156
3182
3157
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3183
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
3158
3184
aq_ret = I40E_ERR_PARAM ;
3159
3185
goto err ;
3160
3186
}
@@ -3190,7 +3216,7 @@ static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg)
3190
3216
struct i40e_hw * hw = & pf -> hw ;
3191
3217
i40e_status aq_ret = 0 ;
3192
3218
3193
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3219
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
3194
3220
aq_ret = I40E_ERR_PARAM ;
3195
3221
goto err ;
3196
3222
}
@@ -3215,7 +3241,7 @@ static int i40e_vc_enable_vlan_stripping(struct i40e_vf *vf, u8 *msg)
3215
3241
i40e_status aq_ret = 0 ;
3216
3242
struct i40e_vsi * vsi ;
3217
3243
3218
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3244
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
3219
3245
aq_ret = I40E_ERR_PARAM ;
3220
3246
goto err ;
3221
3247
}
@@ -3241,7 +3267,7 @@ static int i40e_vc_disable_vlan_stripping(struct i40e_vf *vf, u8 *msg)
3241
3267
i40e_status aq_ret = 0 ;
3242
3268
struct i40e_vsi * vsi ;
3243
3269
3244
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3270
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
3245
3271
aq_ret = I40E_ERR_PARAM ;
3246
3272
goto err ;
3247
3273
}
@@ -3468,7 +3494,7 @@ static int i40e_vc_del_cloud_filter(struct i40e_vf *vf, u8 *msg)
3468
3494
i40e_status aq_ret = 0 ;
3469
3495
int i , ret ;
3470
3496
3471
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3497
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
3472
3498
aq_ret = I40E_ERR_PARAM ;
3473
3499
goto err ;
3474
3500
}
@@ -3599,7 +3625,7 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg)
3599
3625
i40e_status aq_ret = 0 ;
3600
3626
int i , ret ;
3601
3627
3602
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3628
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
3603
3629
aq_ret = I40E_ERR_PARAM ;
3604
3630
goto err_out ;
3605
3631
}
@@ -3708,7 +3734,7 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)
3708
3734
i40e_status aq_ret = 0 ;
3709
3735
u64 speed = 0 ;
3710
3736
3711
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3737
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
3712
3738
aq_ret = I40E_ERR_PARAM ;
3713
3739
goto err ;
3714
3740
}
@@ -3797,11 +3823,6 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)
3797
3823
3798
3824
/* set this flag only after making sure all inputs are sane */
3799
3825
vf -> adq_enabled = true;
3800
- /* num_req_queues is set when user changes number of queues via ethtool
3801
- * and this causes issue for default VSI(which depends on this variable)
3802
- * when ADq is enabled, hence reset it.
3803
- */
3804
- vf -> num_req_queues = 0 ;
3805
3826
3806
3827
/* reset the VF in order to allocate resources */
3807
3828
i40e_vc_reset_vf (vf , true);
@@ -3824,7 +3845,7 @@ static int i40e_vc_del_qch_msg(struct i40e_vf *vf, u8 *msg)
3824
3845
struct i40e_pf * pf = vf -> pf ;
3825
3846
i40e_status aq_ret = 0 ;
3826
3847
3827
- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3848
+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
3828
3849
aq_ret = I40E_ERR_PARAM ;
3829
3850
goto err ;
3830
3851
}
0 commit comments