Skip to content

Commit 7a9212d

Browse files
committed
Merge branch 'hns3-fixes'
Huazhong Tan says: ==================== net: hns3: fixes for -net There are some bugfixes for the HNS3 ethernet driver. patch#1 fixes a desc filling bug, patch#2 fixes a false TX timeout issue, and patch#3~#5 fixes some bugs related to VLAN and FD. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 181964e + b7b5d25 commit 7a9212d

File tree

3 files changed

+52
-39
lines changed

3 files changed

+52
-39
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,16 +1093,8 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
10931093
int k, sizeoflast;
10941094
dma_addr_t dma;
10951095

1096-
if (type == DESC_TYPE_SKB) {
1097-
struct sk_buff *skb = (struct sk_buff *)priv;
1098-
int ret;
1099-
1100-
ret = hns3_fill_skb_desc(ring, skb, desc);
1101-
if (unlikely(ret < 0))
1102-
return ret;
1103-
1104-
dma = dma_map_single(dev, skb->data, size, DMA_TO_DEVICE);
1105-
} else if (type == DESC_TYPE_FRAGLIST_SKB) {
1096+
if (type == DESC_TYPE_FRAGLIST_SKB ||
1097+
type == DESC_TYPE_SKB) {
11061098
struct sk_buff *skb = (struct sk_buff *)priv;
11071099

11081100
dma = dma_map_single(dev, skb->data, size, DMA_TO_DEVICE);
@@ -1439,6 +1431,10 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
14391431

14401432
next_to_use_head = ring->next_to_use;
14411433

1434+
ret = hns3_fill_skb_desc(ring, skb, &ring->desc[ring->next_to_use]);
1435+
if (unlikely(ret < 0))
1436+
goto fill_err;
1437+
14421438
ret = hns3_fill_skb_to_desc(ring, skb, DESC_TYPE_SKB);
14431439
if (unlikely(ret < 0))
14441440
goto fill_err;
@@ -4140,8 +4136,8 @@ static void hns3_link_status_change(struct hnae3_handle *handle, bool linkup)
41404136
return;
41414137

41424138
if (linkup) {
4143-
netif_carrier_on(netdev);
41444139
netif_tx_wake_all_queues(netdev);
4140+
netif_carrier_on(netdev);
41454141
if (netif_msg_link(handle))
41464142
netdev_info(netdev, "link up\n");
41474143
} else {

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5806,9 +5806,9 @@ static int hclge_add_fd_entry(struct hnae3_handle *handle,
58065806
/* to avoid rule conflict, when user configure rule by ethtool,
58075807
* we need to clear all arfs rules
58085808
*/
5809+
spin_lock_bh(&hdev->fd_rule_lock);
58095810
hclge_clear_arfs_rules(handle);
58105811

5811-
spin_lock_bh(&hdev->fd_rule_lock);
58125812
ret = hclge_fd_config_rule(hdev, rule);
58135813

58145814
spin_unlock_bh(&hdev->fd_rule_lock);
@@ -5851,6 +5851,7 @@ static int hclge_del_fd_entry(struct hnae3_handle *handle,
58515851
return ret;
58525852
}
58535853

5854+
/* make sure being called after lock up with fd_rule_lock */
58545855
static void hclge_del_all_fd_entries(struct hnae3_handle *handle,
58555856
bool clear_list)
58565857
{
@@ -5863,7 +5864,6 @@ static void hclge_del_all_fd_entries(struct hnae3_handle *handle,
58635864
if (!hnae3_dev_fd_supported(hdev))
58645865
return;
58655866

5866-
spin_lock_bh(&hdev->fd_rule_lock);
58675867
for_each_set_bit(location, hdev->fd_bmap,
58685868
hdev->fd_cfg.rule_num[HCLGE_FD_STAGE_1])
58695869
hclge_fd_tcam_config(hdev, HCLGE_FD_STAGE_1, true, location,
@@ -5880,8 +5880,6 @@ static void hclge_del_all_fd_entries(struct hnae3_handle *handle,
58805880
bitmap_zero(hdev->fd_bmap,
58815881
hdev->fd_cfg.rule_num[HCLGE_FD_STAGE_1]);
58825882
}
5883-
5884-
spin_unlock_bh(&hdev->fd_rule_lock);
58855883
}
58865884

58875885
static int hclge_restore_fd_entries(struct hnae3_handle *handle)
@@ -6263,7 +6261,7 @@ static int hclge_add_fd_entry_by_arfs(struct hnae3_handle *handle, u16 queue_id,
62636261
u16 flow_id, struct flow_keys *fkeys)
62646262
{
62656263
struct hclge_vport *vport = hclge_get_vport(handle);
6266-
struct hclge_fd_rule_tuples new_tuples;
6264+
struct hclge_fd_rule_tuples new_tuples = {};
62676265
struct hclge_dev *hdev = vport->back;
62686266
struct hclge_fd_rule *rule;
62696267
u16 tmp_queue_id;
@@ -6273,19 +6271,17 @@ static int hclge_add_fd_entry_by_arfs(struct hnae3_handle *handle, u16 queue_id,
62736271
if (!hnae3_dev_fd_supported(hdev))
62746272
return -EOPNOTSUPP;
62756273

6276-
memset(&new_tuples, 0, sizeof(new_tuples));
6277-
hclge_fd_get_flow_tuples(fkeys, &new_tuples);
6278-
6279-
spin_lock_bh(&hdev->fd_rule_lock);
6280-
62816274
/* when there is already fd rule existed add by user,
62826275
* arfs should not work
62836276
*/
6277+
spin_lock_bh(&hdev->fd_rule_lock);
62846278
if (hdev->fd_active_type == HCLGE_FD_EP_ACTIVE) {
62856279
spin_unlock_bh(&hdev->fd_rule_lock);
62866280
return -EOPNOTSUPP;
62876281
}
62886282

6283+
hclge_fd_get_flow_tuples(fkeys, &new_tuples);
6284+
62896285
/* check is there flow director filter existed for this flow,
62906286
* if not, create a new filter for it;
62916287
* if filter exist with different queue id, modify the filter;
@@ -6368,6 +6364,7 @@ static void hclge_rfs_filter_expire(struct hclge_dev *hdev)
63686364
#endif
63696365
}
63706366

6367+
/* make sure being called after lock up with fd_rule_lock */
63716368
static void hclge_clear_arfs_rules(struct hnae3_handle *handle)
63726369
{
63736370
#ifdef CONFIG_RFS_ACCEL
@@ -6420,10 +6417,14 @@ static void hclge_enable_fd(struct hnae3_handle *handle, bool enable)
64206417

64216418
hdev->fd_en = enable;
64226419
clear = hdev->fd_active_type == HCLGE_FD_ARFS_ACTIVE;
6423-
if (!enable)
6420+
6421+
if (!enable) {
6422+
spin_lock_bh(&hdev->fd_rule_lock);
64246423
hclge_del_all_fd_entries(handle, clear);
6425-
else
6424+
spin_unlock_bh(&hdev->fd_rule_lock);
6425+
} else {
64266426
hclge_restore_fd_entries(handle);
6427+
}
64276428
}
64286429

64296430
static void hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable)
@@ -6886,8 +6887,9 @@ static void hclge_ae_stop(struct hnae3_handle *handle)
68866887
int i;
68876888

68886889
set_bit(HCLGE_STATE_DOWN, &hdev->state);
6889-
6890+
spin_lock_bh(&hdev->fd_rule_lock);
68906891
hclge_clear_arfs_rules(handle);
6892+
spin_unlock_bh(&hdev->fd_rule_lock);
68916893

68926894
/* If it is not PF reset, the firmware will disable the MAC,
68936895
* so it only need to stop phy here.
@@ -9040,11 +9042,12 @@ int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto,
90409042
bool writen_to_tbl = false;
90419043
int ret = 0;
90429044

9043-
/* When device is resetting, firmware is unable to handle
9044-
* mailbox. Just record the vlan id, and remove it after
9045+
/* When device is resetting or reset failed, firmware is unable to
9046+
* handle mailbox. Just record the vlan id, and remove it after
90459047
* reset finished.
90469048
*/
9047-
if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) && is_kill) {
9049+
if ((test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) ||
9050+
test_bit(HCLGE_STATE_RST_FAIL, &hdev->state)) && is_kill) {
90489051
set_bit(vlan_id, vport->vlan_del_fail_bmap);
90499052
return -EBUSY;
90509053
}

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

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,11 +1592,12 @@ static int hclgevf_set_vlan_filter(struct hnae3_handle *handle,
15921592
if (proto != htons(ETH_P_8021Q))
15931593
return -EPROTONOSUPPORT;
15941594

1595-
/* When device is resetting, firmware is unable to handle
1596-
* mailbox. Just record the vlan id, and remove it after
1595+
/* When device is resetting or reset failed, firmware is unable to
1596+
* handle mailbox. Just record the vlan id, and remove it after
15971597
* reset finished.
15981598
*/
1599-
if (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state) && is_kill) {
1599+
if ((test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state) ||
1600+
test_bit(HCLGEVF_STATE_RST_FAIL, &hdev->state)) && is_kill) {
16001601
set_bit(vlan_id, hdev->vlan_del_fail_bmap);
16011602
return -EBUSY;
16021603
}
@@ -3439,23 +3440,36 @@ void hclgevf_update_port_base_vlan_info(struct hclgevf_dev *hdev, u16 state,
34393440
{
34403441
struct hnae3_handle *nic = &hdev->nic;
34413442
struct hclge_vf_to_pf_msg send_msg;
3443+
int ret;
34423444

34433445
rtnl_lock();
3444-
hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT);
3445-
rtnl_unlock();
3446+
3447+
if (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state) ||
3448+
test_bit(HCLGEVF_STATE_RST_FAIL, &hdev->state)) {
3449+
dev_warn(&hdev->pdev->dev,
3450+
"is resetting when updating port based vlan info\n");
3451+
rtnl_unlock();
3452+
return;
3453+
}
3454+
3455+
ret = hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT);
3456+
if (ret) {
3457+
rtnl_unlock();
3458+
return;
3459+
}
34463460

34473461
/* send msg to PF and wait update port based vlan info */
34483462
hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_VLAN,
34493463
HCLGE_MBX_PORT_BASE_VLAN_CFG);
34503464
memcpy(send_msg.data, port_base_vlan_info, data_size);
3451-
hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
3452-
3453-
if (state == HNAE3_PORT_BASE_VLAN_DISABLE)
3454-
nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_DISABLE;
3455-
else
3456-
nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_ENABLE;
3465+
ret = hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
3466+
if (!ret) {
3467+
if (state == HNAE3_PORT_BASE_VLAN_DISABLE)
3468+
nic->port_base_vlan_state = state;
3469+
else
3470+
nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_ENABLE;
3471+
}
34573472

3458-
rtnl_lock();
34593473
hclgevf_notify_client(hdev, HNAE3_UP_CLIENT);
34603474
rtnl_unlock();
34613475
}

0 commit comments

Comments
 (0)