Skip to content

Commit 371d1cc

Browse files
committed
Merge branch 'net-hns3-add-some-fixes-for-net'
Guangbin Huang says: ==================== net: hns3: add some fixes for -net This series adds some fixes for the HNS3 ethernet driver. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents afec498 + 190cd8a commit 371d1cc

File tree

3 files changed

+101
-31
lines changed

3 files changed

+101
-31
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 92 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,7 @@ static int hclge_alloc_vport(struct hclge_dev *hdev)
18721872
vport->vf_info.link_state = IFLA_VF_LINK_STATE_AUTO;
18731873
vport->mps = HCLGE_MAC_DEFAULT_FRAME;
18741874
vport->port_base_vlan_cfg.state = HNAE3_PORT_BASE_VLAN_DISABLE;
1875+
vport->port_base_vlan_cfg.tbl_sta = true;
18751876
vport->rxvlan_cfg.rx_vlan_offload_en = true;
18761877
vport->req_vlan_fltr_en = true;
18771878
INIT_LIST_HEAD(&vport->vlan_list);
@@ -8438,12 +8439,11 @@ int hclge_rm_uc_addr_common(struct hclge_vport *vport,
84388439
hnae3_set_bit(req.entry_type, HCLGE_MAC_VLAN_BIT0_EN_B, 0);
84398440
hclge_prepare_mac_addr(&req, addr, false);
84408441
ret = hclge_remove_mac_vlan_tbl(vport, &req);
8441-
if (!ret) {
8442+
if (!ret || ret == -ENOENT) {
84428443
mutex_lock(&hdev->vport_lock);
84438444
hclge_update_umv_space(vport, true);
84448445
mutex_unlock(&hdev->vport_lock);
8445-
} else if (ret == -ENOENT) {
8446-
ret = 0;
8446+
return 0;
84478447
}
84488448

84498449
return ret;
@@ -8993,11 +8993,16 @@ static int hclge_set_vf_mac(struct hnae3_handle *handle, int vf,
89938993

89948994
ether_addr_copy(vport->vf_info.mac, mac_addr);
89958995

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+
*/
89969000
if (test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) {
89979001
dev_info(&hdev->pdev->dev,
89989002
"MAC of VF %d has been set to %s, and it will be reinitialized!\n",
89999003
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;
90019006
}
90029007

90039008
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,
98189823
bool writen_to_tbl)
98199824
{
98209825
struct hclge_vport_vlan_cfg *vlan, *tmp;
9826+
struct hclge_dev *hdev = vport->back;
98219827

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);
98249833
return;
9834+
}
9835+
}
98259836

98269837
vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
9827-
if (!vlan)
9838+
if (!vlan) {
9839+
mutex_unlock(&hdev->vport_lock);
98289840
return;
9841+
}
98299842

98309843
vlan->hd_tbl_status = writen_to_tbl;
98319844
vlan->vlan_id = vlan_id;
98329845

98339846
list_add_tail(&vlan->node, &vport->vlan_list);
9847+
mutex_unlock(&hdev->vport_lock);
98349848
}
98359849

98369850
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)
98399853
struct hclge_dev *hdev = vport->back;
98409854
int ret;
98419855

9856+
mutex_lock(&hdev->vport_lock);
9857+
98429858
list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
98439859
if (!vlan->hd_tbl_status) {
98449860
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)
98489864
dev_err(&hdev->pdev->dev,
98499865
"restore vport vlan list failed, ret=%d\n",
98509866
ret);
9867+
9868+
mutex_unlock(&hdev->vport_lock);
98519869
return ret;
98529870
}
98539871
}
98549872
vlan->hd_tbl_status = true;
98559873
}
98569874

9875+
mutex_unlock(&hdev->vport_lock);
9876+
98579877
return 0;
98589878
}
98599879

@@ -9863,6 +9883,8 @@ static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
98639883
struct hclge_vport_vlan_cfg *vlan, *tmp;
98649884
struct hclge_dev *hdev = vport->back;
98659885

9886+
mutex_lock(&hdev->vport_lock);
9887+
98669888
list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
98679889
if (vlan->vlan_id == vlan_id) {
98689890
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,
98779899
break;
98789900
}
98799901
}
9902+
9903+
mutex_unlock(&hdev->vport_lock);
98809904
}
98819905

98829906
void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list)
98839907
{
98849908
struct hclge_vport_vlan_cfg *vlan, *tmp;
98859909
struct hclge_dev *hdev = vport->back;
98869910

9911+
mutex_lock(&hdev->vport_lock);
9912+
98879913
list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
98889914
if (vlan->hd_tbl_status)
98899915
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)
98999925
}
99009926
}
99019927
clear_bit(vport->vport_id, hdev->vf_vlan_full);
9928+
mutex_unlock(&hdev->vport_lock);
99029929
}
99039930

99049931
void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev)
@@ -9907,44 +9934,70 @@ void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev)
99079934
struct hclge_vport *vport;
99089935
int i;
99099936

9937+
mutex_lock(&hdev->vport_lock);
9938+
99109939
for (i = 0; i < hdev->num_alloc_vport; i++) {
99119940
vport = &hdev->vport[i];
99129941
list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
99139942
list_del(&vlan->node);
99149943
kfree(vlan);
99159944
}
99169945
}
9946+
9947+
mutex_unlock(&hdev->vport_lock);
99179948
}
99189949

9919-
void hclge_restore_vport_vlan_table(struct hclge_vport *vport)
9950+
void hclge_restore_vport_port_base_vlan_config(struct hclge_dev *hdev)
99209951
{
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;
99239954
u16 vlan_proto;
99249955
u16 vlan_id;
99259956
u16 state;
9957+
int vf_id;
99269958
int ret;
99279959

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;
99319966

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+
}
99389978
}
9979+
}
99399980

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+
}
99479998
}
9999+
10000+
mutex_unlock(&hdev->vport_lock);
994810001
}
994910002

995010003
/* 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)
998410037
struct hnae3_handle *handle = &vport->nic;
998510038

998610039
hclge_restore_mac_table_common(vport);
10040+
hclge_restore_vport_port_base_vlan_config(hdev);
998710041
hclge_restore_vport_vlan_table(vport);
998810042
set_bit(HCLGE_STATE_FD_USER_DEF_CHANGED, &hdev->state);
998910043
hclge_restore_fd_entries(handle);
@@ -10040,6 +10094,8 @@ static int hclge_update_vlan_filter_entries(struct hclge_vport *vport,
1004010094
false);
1004110095
}
1004210096

10097+
vport->port_base_vlan_cfg.tbl_sta = false;
10098+
1004310099
/* force add VLAN 0 */
1004410100
ret = hclge_set_vf_vlan_common(hdev, vport->vport_id, false, 0);
1004510101
if (ret)
@@ -10129,7 +10185,9 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
1012910185
else
1013010186
nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_ENABLE;
1013110187

10188+
vport->port_base_vlan_cfg.old_vlan_info = *old_vlan_info;
1013210189
vport->port_base_vlan_cfg.vlan_info = *vlan_info;
10190+
vport->port_base_vlan_cfg.tbl_sta = true;
1013310191
hclge_set_vport_vlan_fltr_change(vport);
1013410192

1013510193
return 0;
@@ -10197,14 +10255,17 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle *handle, int vfid,
1019710255
return ret;
1019810256
}
1019910257

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
1020110262
* VLAN state.
1020210263
*/
1020310264
if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V3 &&
1020410265
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);
1020810269

1020910270
return 0;
1021010271
}
@@ -11838,8 +11899,8 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev)
1183811899
hclge_misc_irq_uninit(hdev);
1183911900
hclge_devlink_uninit(hdev);
1184011901
hclge_pci_uninit(hdev);
11841-
mutex_destroy(&hdev->vport_lock);
1184211902
hclge_uninit_vport_vlan_table(hdev);
11903+
mutex_destroy(&hdev->vport_lock);
1184311904
ae_dev->priv = NULL;
1184411905
}
1184511906

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,9 @@ struct hclge_vlan_info {
985985

986986
struct hclge_port_base_vlan_config {
987987
u16 state;
988+
bool tbl_sta;
988989
struct hclge_vlan_info vlan_info;
990+
struct hclge_vlan_info old_vlan_info;
989991
};
990992

991993
struct hclge_vf_info {
@@ -1031,6 +1033,7 @@ struct hclge_vport {
10311033
spinlock_t mac_list_lock; /* protect mac address need to add/detele */
10321034
struct list_head uc_mac_list; /* Store VF unicast table */
10331035
struct list_head mc_mac_list; /* Store VF multicast table */
1036+
10341037
struct list_head vlan_list; /* Store VF vlan table */
10351038
};
10361039

@@ -1100,6 +1103,7 @@ void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list,
11001103
void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list);
11011104
void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev);
11021105
void hclge_restore_mac_table_common(struct hclge_vport *vport);
1106+
void hclge_restore_vport_port_base_vlan_config(struct hclge_dev *hdev);
11031107
void hclge_restore_vport_vlan_table(struct hclge_vport *vport);
11041108
int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
11051109
struct hclge_vlan_info *vlan_info);

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,6 +2862,11 @@ static int hclgevf_reset_hdev(struct hclgevf_dev *hdev)
28622862
return ret;
28632863
}
28642864

2865+
/* get current port based vlan state from PF */
2866+
ret = hclgevf_get_port_base_vlan_filter_state(hdev);
2867+
if (ret)
2868+
return ret;
2869+
28652870
set_bit(HCLGEVF_STATE_PROMISC_CHANGED, &hdev->state);
28662871

28672872
hclgevf_init_rxd_adv_layout(hdev);

0 commit comments

Comments
 (0)