@@ -1872,6 +1872,7 @@ static int hclge_alloc_vport(struct hclge_dev *hdev)
1872
1872
vport -> vf_info .link_state = IFLA_VF_LINK_STATE_AUTO ;
1873
1873
vport -> mps = HCLGE_MAC_DEFAULT_FRAME ;
1874
1874
vport -> port_base_vlan_cfg .state = HNAE3_PORT_BASE_VLAN_DISABLE ;
1875
+ vport -> port_base_vlan_cfg .tbl_sta = true;
1875
1876
vport -> rxvlan_cfg .rx_vlan_offload_en = true;
1876
1877
vport -> req_vlan_fltr_en = true;
1877
1878
INIT_LIST_HEAD (& vport -> vlan_list );
@@ -8438,12 +8439,11 @@ int hclge_rm_uc_addr_common(struct hclge_vport *vport,
8438
8439
hnae3_set_bit (req .entry_type , HCLGE_MAC_VLAN_BIT0_EN_B , 0 );
8439
8440
hclge_prepare_mac_addr (& req , addr , false);
8440
8441
ret = hclge_remove_mac_vlan_tbl (vport , & req );
8441
- if (!ret ) {
8442
+ if (!ret || ret == - ENOENT ) {
8442
8443
mutex_lock (& hdev -> vport_lock );
8443
8444
hclge_update_umv_space (vport , true);
8444
8445
mutex_unlock (& hdev -> vport_lock );
8445
- } else if (ret == - ENOENT ) {
8446
- ret = 0 ;
8446
+ return 0 ;
8447
8447
}
8448
8448
8449
8449
return ret ;
@@ -8993,11 +8993,16 @@ static int hclge_set_vf_mac(struct hnae3_handle *handle, int vf,
8993
8993
8994
8994
ether_addr_copy (vport -> vf_info .mac , mac_addr );
8995
8995
8996
+ /* there is a timewindow for PF to know VF unalive, it may
8997
+ * cause send mailbox fail, but it doesn't matter, VF will
8998
+ * query it when reinit.
8999
+ */
8996
9000
if (test_bit (HCLGE_VPORT_STATE_ALIVE , & vport -> state )) {
8997
9001
dev_info (& hdev -> pdev -> dev ,
8998
9002
"MAC of VF %d has been set to %s, and it will be reinitialized!\n" ,
8999
9003
vf , format_mac_addr );
9000
- return hclge_inform_reset_assert_to_vf (vport );
9004
+ (void )hclge_inform_reset_assert_to_vf (vport );
9005
+ return 0 ;
9001
9006
}
9002
9007
9003
9008
dev_info (& hdev -> pdev -> dev , "MAC of VF %d has been set to %s\n" ,
@@ -9818,19 +9823,28 @@ static void hclge_add_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
9818
9823
bool writen_to_tbl )
9819
9824
{
9820
9825
struct hclge_vport_vlan_cfg * vlan , * tmp ;
9826
+ struct hclge_dev * hdev = vport -> back ;
9821
9827
9822
- list_for_each_entry_safe (vlan , tmp , & vport -> vlan_list , node )
9823
- if (vlan -> vlan_id == vlan_id )
9828
+ mutex_lock (& hdev -> vport_lock );
9829
+
9830
+ list_for_each_entry_safe (vlan , tmp , & vport -> vlan_list , node ) {
9831
+ if (vlan -> vlan_id == vlan_id ) {
9832
+ mutex_unlock (& hdev -> vport_lock );
9824
9833
return ;
9834
+ }
9835
+ }
9825
9836
9826
9837
vlan = kzalloc (sizeof (* vlan ), GFP_KERNEL );
9827
- if (!vlan )
9838
+ if (!vlan ) {
9839
+ mutex_unlock (& hdev -> vport_lock );
9828
9840
return ;
9841
+ }
9829
9842
9830
9843
vlan -> hd_tbl_status = writen_to_tbl ;
9831
9844
vlan -> vlan_id = vlan_id ;
9832
9845
9833
9846
list_add_tail (& vlan -> node , & vport -> vlan_list );
9847
+ mutex_unlock (& hdev -> vport_lock );
9834
9848
}
9835
9849
9836
9850
static int hclge_add_vport_all_vlan_table (struct hclge_vport * vport )
@@ -9839,6 +9853,8 @@ static int hclge_add_vport_all_vlan_table(struct hclge_vport *vport)
9839
9853
struct hclge_dev * hdev = vport -> back ;
9840
9854
int ret ;
9841
9855
9856
+ mutex_lock (& hdev -> vport_lock );
9857
+
9842
9858
list_for_each_entry_safe (vlan , tmp , & vport -> vlan_list , node ) {
9843
9859
if (!vlan -> hd_tbl_status ) {
9844
9860
ret = hclge_set_vlan_filter_hw (hdev , htons (ETH_P_8021Q ),
@@ -9848,12 +9864,16 @@ static int hclge_add_vport_all_vlan_table(struct hclge_vport *vport)
9848
9864
dev_err (& hdev -> pdev -> dev ,
9849
9865
"restore vport vlan list failed, ret=%d\n" ,
9850
9866
ret );
9867
+
9868
+ mutex_unlock (& hdev -> vport_lock );
9851
9869
return ret ;
9852
9870
}
9853
9871
}
9854
9872
vlan -> hd_tbl_status = true;
9855
9873
}
9856
9874
9875
+ mutex_unlock (& hdev -> vport_lock );
9876
+
9857
9877
return 0 ;
9858
9878
}
9859
9879
@@ -9863,6 +9883,8 @@ static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
9863
9883
struct hclge_vport_vlan_cfg * vlan , * tmp ;
9864
9884
struct hclge_dev * hdev = vport -> back ;
9865
9885
9886
+ mutex_lock (& hdev -> vport_lock );
9887
+
9866
9888
list_for_each_entry_safe (vlan , tmp , & vport -> vlan_list , node ) {
9867
9889
if (vlan -> vlan_id == vlan_id ) {
9868
9890
if (is_write_tbl && vlan -> hd_tbl_status )
@@ -9877,13 +9899,17 @@ static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
9877
9899
break ;
9878
9900
}
9879
9901
}
9902
+
9903
+ mutex_unlock (& hdev -> vport_lock );
9880
9904
}
9881
9905
9882
9906
void hclge_rm_vport_all_vlan_table (struct hclge_vport * vport , bool is_del_list )
9883
9907
{
9884
9908
struct hclge_vport_vlan_cfg * vlan , * tmp ;
9885
9909
struct hclge_dev * hdev = vport -> back ;
9886
9910
9911
+ mutex_lock (& hdev -> vport_lock );
9912
+
9887
9913
list_for_each_entry_safe (vlan , tmp , & vport -> vlan_list , node ) {
9888
9914
if (vlan -> hd_tbl_status )
9889
9915
hclge_set_vlan_filter_hw (hdev ,
@@ -9899,6 +9925,7 @@ void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list)
9899
9925
}
9900
9926
}
9901
9927
clear_bit (vport -> vport_id , hdev -> vf_vlan_full );
9928
+ mutex_unlock (& hdev -> vport_lock );
9902
9929
}
9903
9930
9904
9931
void hclge_uninit_vport_vlan_table (struct hclge_dev * hdev )
@@ -9907,44 +9934,70 @@ void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev)
9907
9934
struct hclge_vport * vport ;
9908
9935
int i ;
9909
9936
9937
+ mutex_lock (& hdev -> vport_lock );
9938
+
9910
9939
for (i = 0 ; i < hdev -> num_alloc_vport ; i ++ ) {
9911
9940
vport = & hdev -> vport [i ];
9912
9941
list_for_each_entry_safe (vlan , tmp , & vport -> vlan_list , node ) {
9913
9942
list_del (& vlan -> node );
9914
9943
kfree (vlan );
9915
9944
}
9916
9945
}
9946
+
9947
+ mutex_unlock (& hdev -> vport_lock );
9917
9948
}
9918
9949
9919
- void hclge_restore_vport_vlan_table (struct hclge_vport * vport )
9950
+ void hclge_restore_vport_port_base_vlan_config (struct hclge_dev * hdev )
9920
9951
{
9921
- struct hclge_vport_vlan_cfg * vlan , * tmp ;
9922
- struct hclge_dev * hdev = vport -> back ;
9952
+ struct hclge_vlan_info * vlan_info ;
9953
+ struct hclge_vport * vport ;
9923
9954
u16 vlan_proto ;
9924
9955
u16 vlan_id ;
9925
9956
u16 state ;
9957
+ int vf_id ;
9926
9958
int ret ;
9927
9959
9928
- vlan_proto = vport -> port_base_vlan_cfg .vlan_info .vlan_proto ;
9929
- vlan_id = vport -> port_base_vlan_cfg .vlan_info .vlan_tag ;
9930
- state = vport -> port_base_vlan_cfg .state ;
9960
+ /* PF should restore all vfs port base vlan */
9961
+ for (vf_id = 0 ; vf_id < hdev -> num_alloc_vfs ; vf_id ++ ) {
9962
+ vport = & hdev -> vport [vf_id + HCLGE_VF_VPORT_START_NUM ];
9963
+ vlan_info = vport -> port_base_vlan_cfg .tbl_sta ?
9964
+ & vport -> port_base_vlan_cfg .vlan_info :
9965
+ & vport -> port_base_vlan_cfg .old_vlan_info ;
9931
9966
9932
- if (state != HNAE3_PORT_BASE_VLAN_DISABLE ) {
9933
- clear_bit (vport -> vport_id , hdev -> vlan_table [vlan_id ]);
9934
- hclge_set_vlan_filter_hw (hdev , htons (vlan_proto ),
9935
- vport -> vport_id , vlan_id ,
9936
- false);
9937
- return ;
9967
+ vlan_id = vlan_info -> vlan_tag ;
9968
+ vlan_proto = vlan_info -> vlan_proto ;
9969
+ state = vport -> port_base_vlan_cfg .state ;
9970
+
9971
+ if (state != HNAE3_PORT_BASE_VLAN_DISABLE ) {
9972
+ clear_bit (vport -> vport_id , hdev -> vlan_table [vlan_id ]);
9973
+ ret = hclge_set_vlan_filter_hw (hdev , htons (vlan_proto ),
9974
+ vport -> vport_id ,
9975
+ vlan_id , false);
9976
+ vport -> port_base_vlan_cfg .tbl_sta = ret == 0 ;
9977
+ }
9938
9978
}
9979
+ }
9939
9980
9940
- list_for_each_entry_safe (vlan , tmp , & vport -> vlan_list , node ) {
9941
- ret = hclge_set_vlan_filter_hw (hdev , htons (ETH_P_8021Q ),
9942
- vport -> vport_id ,
9943
- vlan -> vlan_id , false);
9944
- if (ret )
9945
- break ;
9946
- vlan -> hd_tbl_status = true;
9981
+ void hclge_restore_vport_vlan_table (struct hclge_vport * vport )
9982
+ {
9983
+ struct hclge_vport_vlan_cfg * vlan , * tmp ;
9984
+ struct hclge_dev * hdev = vport -> back ;
9985
+ int ret ;
9986
+
9987
+ mutex_lock (& hdev -> vport_lock );
9988
+
9989
+ if (vport -> port_base_vlan_cfg .state == HNAE3_PORT_BASE_VLAN_DISABLE ) {
9990
+ list_for_each_entry_safe (vlan , tmp , & vport -> vlan_list , node ) {
9991
+ ret = hclge_set_vlan_filter_hw (hdev , htons (ETH_P_8021Q ),
9992
+ vport -> vport_id ,
9993
+ vlan -> vlan_id , false);
9994
+ if (ret )
9995
+ break ;
9996
+ vlan -> hd_tbl_status = true;
9997
+ }
9947
9998
}
9999
+
10000
+ mutex_unlock (& hdev -> vport_lock );
9948
10001
}
9949
10002
9950
10003
/* For global reset and imp reset, hardware will clear the mac table,
@@ -9984,6 +10037,7 @@ static void hclge_restore_hw_table(struct hclge_dev *hdev)
9984
10037
struct hnae3_handle * handle = & vport -> nic ;
9985
10038
9986
10039
hclge_restore_mac_table_common (vport );
10040
+ hclge_restore_vport_port_base_vlan_config (hdev );
9987
10041
hclge_restore_vport_vlan_table (vport );
9988
10042
set_bit (HCLGE_STATE_FD_USER_DEF_CHANGED , & hdev -> state );
9989
10043
hclge_restore_fd_entries (handle );
@@ -10040,6 +10094,8 @@ static int hclge_update_vlan_filter_entries(struct hclge_vport *vport,
10040
10094
false);
10041
10095
}
10042
10096
10097
+ vport -> port_base_vlan_cfg .tbl_sta = false;
10098
+
10043
10099
/* force add VLAN 0 */
10044
10100
ret = hclge_set_vf_vlan_common (hdev , vport -> vport_id , false, 0 );
10045
10101
if (ret )
@@ -10129,7 +10185,9 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
10129
10185
else
10130
10186
nic -> port_base_vlan_state = HNAE3_PORT_BASE_VLAN_ENABLE ;
10131
10187
10188
+ vport -> port_base_vlan_cfg .old_vlan_info = * old_vlan_info ;
10132
10189
vport -> port_base_vlan_cfg .vlan_info = * vlan_info ;
10190
+ vport -> port_base_vlan_cfg .tbl_sta = true;
10133
10191
hclge_set_vport_vlan_fltr_change (vport );
10134
10192
10135
10193
return 0 ;
@@ -10197,14 +10255,17 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle *handle, int vfid,
10197
10255
return ret ;
10198
10256
}
10199
10257
10200
- /* for DEVICE_VERSION_V3, vf doesn't need to know about the port based
10258
+ /* there is a timewindow for PF to know VF unalive, it may
10259
+ * cause send mailbox fail, but it doesn't matter, VF will
10260
+ * query it when reinit.
10261
+ * for DEVICE_VERSION_V3, vf doesn't need to know about the port based
10201
10262
* VLAN state.
10202
10263
*/
10203
10264
if (ae_dev -> dev_version < HNAE3_DEVICE_VERSION_V3 &&
10204
10265
test_bit (HCLGE_VPORT_STATE_ALIVE , & vport -> state ))
10205
- hclge_push_vf_port_base_vlan_info (& hdev -> vport [0 ],
10206
- vport -> vport_id , state ,
10207
- & vlan_info );
10266
+ ( void ) hclge_push_vf_port_base_vlan_info (& hdev -> vport [0 ],
10267
+ vport -> vport_id ,
10268
+ state , & vlan_info );
10208
10269
10209
10270
return 0 ;
10210
10271
}
@@ -11838,8 +11899,8 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev)
11838
11899
hclge_misc_irq_uninit (hdev );
11839
11900
hclge_devlink_uninit (hdev );
11840
11901
hclge_pci_uninit (hdev );
11841
- mutex_destroy (& hdev -> vport_lock );
11842
11902
hclge_uninit_vport_vlan_table (hdev );
11903
+ mutex_destroy (& hdev -> vport_lock );
11843
11904
ae_dev -> priv = NULL ;
11844
11905
}
11845
11906
0 commit comments