@@ -1948,6 +1948,32 @@ static int i40e_vc_send_resp_to_vf(struct i40e_vf *vf,
19481948 return i40e_vc_send_msg_to_vf (vf , opcode , retval , NULL , 0 );
19491949}
19501950
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+
19511977/**
19521978 * i40e_vc_get_version_msg
19531979 * @vf: pointer to the VF info
@@ -2008,7 +2034,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
20082034 size_t len = 0 ;
20092035 int ret ;
20102036
2011- if (!test_bit ( I40E_VF_STATE_INIT , & vf -> vf_states )) {
2037+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_INIT )) {
20122038 aq_ret = I40E_ERR_PARAM ;
20132039 goto err ;
20142040 }
@@ -2131,7 +2157,7 @@ static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf, u8 *msg)
21312157 bool allmulti = false;
21322158 bool alluni = false;
21332159
2134- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
2160+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
21352161 aq_ret = I40E_ERR_PARAM ;
21362162 goto err_out ;
21372163 }
@@ -2219,7 +2245,7 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg)
22192245 struct i40e_vsi * vsi ;
22202246 u16 num_qps_all = 0 ;
22212247
2222- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
2248+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
22232249 aq_ret = I40E_ERR_PARAM ;
22242250 goto error_param ;
22252251 }
@@ -2368,7 +2394,7 @@ static int i40e_vc_config_irq_map_msg(struct i40e_vf *vf, u8 *msg)
23682394 i40e_status aq_ret = 0 ;
23692395 int i ;
23702396
2371- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
2397+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
23722398 aq_ret = I40E_ERR_PARAM ;
23732399 goto error_param ;
23742400 }
@@ -2540,7 +2566,7 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg)
25402566 struct i40e_pf * pf = vf -> pf ;
25412567 i40e_status aq_ret = 0 ;
25422568
2543- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
2569+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
25442570 aq_ret = I40E_ERR_PARAM ;
25452571 goto error_param ;
25462572 }
@@ -2590,7 +2616,7 @@ static int i40e_vc_request_queues_msg(struct i40e_vf *vf, u8 *msg)
25902616 u8 cur_pairs = vf -> num_queue_pairs ;
25912617 struct i40e_pf * pf = vf -> pf ;
25922618
2593- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ))
2619+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ))
25942620 return - EINVAL ;
25952621
25962622 if (req_pairs > I40E_MAX_VF_QUEUES ) {
@@ -2635,7 +2661,7 @@ static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg)
26352661
26362662 memset (& stats , 0 , sizeof (struct i40e_eth_stats ));
26372663
2638- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
2664+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
26392665 aq_ret = I40E_ERR_PARAM ;
26402666 goto error_param ;
26412667 }
@@ -2752,7 +2778,7 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
27522778 i40e_status ret = 0 ;
27532779 int i ;
27542780
2755- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ) ||
2781+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ) ||
27562782 !i40e_vc_isvalid_vsi_id (vf , al -> vsi_id )) {
27572783 ret = I40E_ERR_PARAM ;
27582784 goto error_param ;
@@ -2824,7 +2850,7 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
28242850 i40e_status ret = 0 ;
28252851 int i ;
28262852
2827- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ) ||
2853+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ) ||
28282854 !i40e_vc_isvalid_vsi_id (vf , al -> vsi_id )) {
28292855 ret = I40E_ERR_PARAM ;
28302856 goto error_param ;
@@ -2968,7 +2994,7 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg)
29682994 i40e_status aq_ret = 0 ;
29692995 int i ;
29702996
2971- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ) ||
2997+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ) ||
29722998 !i40e_vc_isvalid_vsi_id (vf , vfl -> vsi_id )) {
29732999 aq_ret = I40E_ERR_PARAM ;
29743000 goto error_param ;
@@ -3088,9 +3114,9 @@ static int i40e_vc_config_rss_key(struct i40e_vf *vf, u8 *msg)
30883114 struct i40e_vsi * vsi = NULL ;
30893115 i40e_status aq_ret = 0 ;
30903116
3091- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ) ||
3117+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ) ||
30923118 !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 ) {
30943120 aq_ret = I40E_ERR_PARAM ;
30953121 goto err ;
30963122 }
@@ -3119,9 +3145,9 @@ static int i40e_vc_config_rss_lut(struct i40e_vf *vf, u8 *msg)
31193145 i40e_status aq_ret = 0 ;
31203146 u16 i ;
31213147
3122- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states ) ||
3148+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE ) ||
31233149 !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 ) {
31253151 aq_ret = I40E_ERR_PARAM ;
31263152 goto err ;
31273153 }
@@ -3154,7 +3180,7 @@ static int i40e_vc_get_rss_hena(struct i40e_vf *vf, u8 *msg)
31543180 i40e_status aq_ret = 0 ;
31553181 int len = 0 ;
31563182
3157- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3183+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
31583184 aq_ret = I40E_ERR_PARAM ;
31593185 goto err ;
31603186 }
@@ -3190,7 +3216,7 @@ static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg)
31903216 struct i40e_hw * hw = & pf -> hw ;
31913217 i40e_status aq_ret = 0 ;
31923218
3193- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3219+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
31943220 aq_ret = I40E_ERR_PARAM ;
31953221 goto err ;
31963222 }
@@ -3215,7 +3241,7 @@ static int i40e_vc_enable_vlan_stripping(struct i40e_vf *vf, u8 *msg)
32153241 i40e_status aq_ret = 0 ;
32163242 struct i40e_vsi * vsi ;
32173243
3218- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3244+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
32193245 aq_ret = I40E_ERR_PARAM ;
32203246 goto err ;
32213247 }
@@ -3241,7 +3267,7 @@ static int i40e_vc_disable_vlan_stripping(struct i40e_vf *vf, u8 *msg)
32413267 i40e_status aq_ret = 0 ;
32423268 struct i40e_vsi * vsi ;
32433269
3244- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3270+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
32453271 aq_ret = I40E_ERR_PARAM ;
32463272 goto err ;
32473273 }
@@ -3468,7 +3494,7 @@ static int i40e_vc_del_cloud_filter(struct i40e_vf *vf, u8 *msg)
34683494 i40e_status aq_ret = 0 ;
34693495 int i , ret ;
34703496
3471- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3497+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
34723498 aq_ret = I40E_ERR_PARAM ;
34733499 goto err ;
34743500 }
@@ -3599,7 +3625,7 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg)
35993625 i40e_status aq_ret = 0 ;
36003626 int i , ret ;
36013627
3602- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3628+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
36033629 aq_ret = I40E_ERR_PARAM ;
36043630 goto err_out ;
36053631 }
@@ -3708,7 +3734,7 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)
37083734 i40e_status aq_ret = 0 ;
37093735 u64 speed = 0 ;
37103736
3711- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3737+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
37123738 aq_ret = I40E_ERR_PARAM ;
37133739 goto err ;
37143740 }
@@ -3824,7 +3850,7 @@ static int i40e_vc_del_qch_msg(struct i40e_vf *vf, u8 *msg)
38243850 struct i40e_pf * pf = vf -> pf ;
38253851 i40e_status aq_ret = 0 ;
38263852
3827- if (!test_bit ( I40E_VF_STATE_ACTIVE , & vf -> vf_states )) {
3853+ if (!i40e_sync_vf_state ( vf , I40E_VF_STATE_ACTIVE )) {
38283854 aq_ret = I40E_ERR_PARAM ;
38293855 goto err ;
38303856 }
0 commit comments