Skip to content

Commit 7fa6be4

Browse files
Huazhong Tandavem330
authored andcommitted
net: hns3: fix incorrect return value/type of some functions
There are some functions that, when they fail to send the command, need to return the corresponding error value to its caller. Fixes: 46a3df9 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Fixes: 681ec39 ("net: hns3: fix for vlan table lost problem when resetting") Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1c12493 commit 7fa6be4

File tree

6 files changed

+85
-53
lines changed

6 files changed

+85
-53
lines changed

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ struct hnae3_ae_ops {
316316
int (*set_loopback)(struct hnae3_handle *handle,
317317
enum hnae3_loop loop_mode, bool en);
318318

319-
void (*set_promisc_mode)(struct hnae3_handle *handle, bool en_uc_pmc,
320-
bool en_mc_pmc);
319+
int (*set_promisc_mode)(struct hnae3_handle *handle, bool en_uc_pmc,
320+
bool en_mc_pmc);
321321
int (*set_mtu)(struct hnae3_handle *handle, int new_mtu);
322322

323323
void (*get_pauseparam)(struct hnae3_handle *handle,
@@ -391,7 +391,7 @@ struct hnae3_ae_ops {
391391
int vector_num,
392392
struct hnae3_ring_chain_node *vr_chain);
393393

394-
void (*reset_queue)(struct hnae3_handle *handle, u16 queue_id);
394+
int (*reset_queue)(struct hnae3_handle *handle, u16 queue_id);
395395
u32 (*get_fw_version)(struct hnae3_handle *handle);
396396
void (*get_mdix_mode)(struct hnae3_handle *handle,
397397
u8 *tp_mdix_ctrl, u8 *tp_mdix);

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

Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -509,16 +509,18 @@ static void hns3_nic_set_rx_mode(struct net_device *netdev)
509509
h->netdev_flags = new_flags;
510510
}
511511

512-
void hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags)
512+
int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags)
513513
{
514514
struct hns3_nic_priv *priv = netdev_priv(netdev);
515515
struct hnae3_handle *h = priv->ae_handle;
516516

517517
if (h->ae_algo->ops->set_promisc_mode) {
518-
h->ae_algo->ops->set_promisc_mode(h,
519-
promisc_flags & HNAE3_UPE,
520-
promisc_flags & HNAE3_MPE);
518+
return h->ae_algo->ops->set_promisc_mode(h,
519+
promisc_flags & HNAE3_UPE,
520+
promisc_flags & HNAE3_MPE);
521521
}
522+
523+
return 0;
522524
}
523525

524526
void hns3_enable_vlan_filter(struct net_device *netdev, bool enable)
@@ -1494,18 +1496,22 @@ static int hns3_vlan_rx_kill_vid(struct net_device *netdev,
14941496
return ret;
14951497
}
14961498

1497-
static void hns3_restore_vlan(struct net_device *netdev)
1499+
static int hns3_restore_vlan(struct net_device *netdev)
14981500
{
14991501
struct hns3_nic_priv *priv = netdev_priv(netdev);
1502+
int ret = 0;
15001503
u16 vid;
1501-
int ret;
15021504

15031505
for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) {
15041506
ret = hns3_vlan_rx_add_vid(netdev, htons(ETH_P_8021Q), vid);
1505-
if (ret)
1506-
netdev_warn(netdev, "Restore vlan: %d filter, ret:%d\n",
1507-
vid, ret);
1507+
if (ret) {
1508+
netdev_err(netdev, "Restore vlan: %d filter, ret:%d\n",
1509+
vid, ret);
1510+
return ret;
1511+
}
15081512
}
1513+
1514+
return ret;
15091515
}
15101516

15111517
static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
@@ -3257,11 +3263,12 @@ int hns3_uninit_all_ring(struct hns3_nic_priv *priv)
32573263
}
32583264

32593265
/* Set mac addr if it is configured. or leave it to the AE driver */
3260-
static void hns3_init_mac_addr(struct net_device *netdev, bool init)
3266+
static int hns3_init_mac_addr(struct net_device *netdev, bool init)
32613267
{
32623268
struct hns3_nic_priv *priv = netdev_priv(netdev);
32633269
struct hnae3_handle *h = priv->ae_handle;
32643270
u8 mac_addr_temp[ETH_ALEN];
3271+
int ret = 0;
32653272

32663273
if (h->ae_algo->ops->get_mac_addr && init) {
32673274
h->ae_algo->ops->get_mac_addr(h, mac_addr_temp);
@@ -3276,8 +3283,9 @@ static void hns3_init_mac_addr(struct net_device *netdev, bool init)
32763283
}
32773284

32783285
if (h->ae_algo->ops->set_mac_addr)
3279-
h->ae_algo->ops->set_mac_addr(h, netdev->dev_addr, true);
3286+
ret = h->ae_algo->ops->set_mac_addr(h, netdev->dev_addr, true);
32803287

3288+
return ret;
32813289
}
32823290

32833291
static int hns3_restore_fd_rules(struct net_device *netdev)
@@ -3490,20 +3498,29 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
34903498
return ret;
34913499
}
34923500

3493-
static void hns3_recover_hw_addr(struct net_device *ndev)
3501+
static int hns3_recover_hw_addr(struct net_device *ndev)
34943502
{
34953503
struct netdev_hw_addr_list *list;
34963504
struct netdev_hw_addr *ha, *tmp;
3505+
int ret = 0;
34973506

34983507
/* go through and sync uc_addr entries to the device */
34993508
list = &ndev->uc;
3500-
list_for_each_entry_safe(ha, tmp, &list->list, list)
3501-
hns3_nic_uc_sync(ndev, ha->addr);
3509+
list_for_each_entry_safe(ha, tmp, &list->list, list) {
3510+
ret = hns3_nic_uc_sync(ndev, ha->addr);
3511+
if (ret)
3512+
return ret;
3513+
}
35023514

35033515
/* go through and sync mc_addr entries to the device */
35043516
list = &ndev->mc;
3505-
list_for_each_entry_safe(ha, tmp, &list->list, list)
3506-
hns3_nic_mc_sync(ndev, ha->addr);
3517+
list_for_each_entry_safe(ha, tmp, &list->list, list) {
3518+
ret = hns3_nic_mc_sync(ndev, ha->addr);
3519+
if (ret)
3520+
return ret;
3521+
}
3522+
3523+
return ret;
35073524
}
35083525

35093526
static void hns3_remove_hw_addr(struct net_device *netdev)
@@ -3630,7 +3647,10 @@ int hns3_nic_reset_all_ring(struct hnae3_handle *h)
36303647
int ret;
36313648

36323649
for (i = 0; i < h->kinfo.num_tqps; i++) {
3633-
h->ae_algo->ops->reset_queue(h, i);
3650+
ret = h->ae_algo->ops->reset_queue(h, i);
3651+
if (ret)
3652+
return ret;
3653+
36343654
hns3_init_ring_hw(priv->ring_data[i].ring);
36353655

36363656
/* We need to clear tx ring here because self test will
@@ -3722,18 +3742,30 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle)
37223742
bool vlan_filter_enable;
37233743
int ret;
37243744

3725-
hns3_init_mac_addr(netdev, false);
3726-
hns3_recover_hw_addr(netdev);
3727-
hns3_update_promisc_mode(netdev, handle->netdev_flags);
3745+
ret = hns3_init_mac_addr(netdev, false);
3746+
if (ret)
3747+
return ret;
3748+
3749+
ret = hns3_recover_hw_addr(netdev);
3750+
if (ret)
3751+
return ret;
3752+
3753+
ret = hns3_update_promisc_mode(netdev, handle->netdev_flags);
3754+
if (ret)
3755+
return ret;
3756+
37283757
vlan_filter_enable = netdev->flags & IFF_PROMISC ? false : true;
37293758
hns3_enable_vlan_filter(netdev, vlan_filter_enable);
37303759

3731-
37323760
/* Hardware table is only clear when pf resets */
3733-
if (!(handle->flags & HNAE3_SUPPORT_VF))
3734-
hns3_restore_vlan(netdev);
3761+
if (!(handle->flags & HNAE3_SUPPORT_VF)) {
3762+
ret = hns3_restore_vlan(netdev);
3763+
return ret;
3764+
}
37353765

3736-
hns3_restore_fd_rules(netdev);
3766+
ret = hns3_restore_fd_rules(netdev);
3767+
if (ret)
3768+
return ret;
37373769

37383770
/* Carrier off reporting is important to ethtool even BEFORE open */
37393771
netif_carrier_off(netdev);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ void hns3_set_vector_coalesce_rl(struct hns3_enet_tqp_vector *tqp_vector,
640640
u32 rl_value);
641641

642642
void hns3_enable_vlan_filter(struct net_device *netdev, bool enable);
643-
void hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags);
643+
int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags);
644644

645645
#ifdef CONFIG_HNS3_DCB
646646
void hns3_dcbnl_setup(struct hnae3_handle *handle);

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3314,16 +3314,16 @@ void hclge_promisc_param_init(struct hclge_promisc_param *param, bool en_uc,
33143314
param->vf_id = vport_id;
33153315
}
33163316

3317-
static void hclge_set_promisc_mode(struct hnae3_handle *handle, bool en_uc_pmc,
3318-
bool en_mc_pmc)
3317+
static int hclge_set_promisc_mode(struct hnae3_handle *handle, bool en_uc_pmc,
3318+
bool en_mc_pmc)
33193319
{
33203320
struct hclge_vport *vport = hclge_get_vport(handle);
33213321
struct hclge_dev *hdev = vport->back;
33223322
struct hclge_promisc_param param;
33233323

33243324
hclge_promisc_param_init(&param, en_uc_pmc, en_mc_pmc, true,
33253325
vport->vport_id);
3326-
hclge_cmd_set_promisc_mode(hdev, &param);
3326+
return hclge_cmd_set_promisc_mode(hdev, &param);
33273327
}
33283328

33293329
static int hclge_get_fd_mode(struct hclge_dev *hdev, u8 *fd_mode)
@@ -6107,28 +6107,28 @@ static u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle,
61076107
return tqp->index;
61086108
}
61096109

6110-
void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
6110+
int hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
61116111
{
61126112
struct hclge_vport *vport = hclge_get_vport(handle);
61136113
struct hclge_dev *hdev = vport->back;
61146114
int reset_try_times = 0;
61156115
int reset_status;
61166116
u16 queue_gid;
6117-
int ret;
6117+
int ret = 0;
61186118

61196119
queue_gid = hclge_covert_handle_qid_global(handle, queue_id);
61206120

61216121
ret = hclge_tqp_enable(hdev, queue_id, 0, false);
61226122
if (ret) {
6123-
dev_warn(&hdev->pdev->dev, "Disable tqp fail, ret = %d\n", ret);
6124-
return;
6123+
dev_err(&hdev->pdev->dev, "Disable tqp fail, ret = %d\n", ret);
6124+
return ret;
61256125
}
61266126

61276127
ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, true);
61286128
if (ret) {
6129-
dev_warn(&hdev->pdev->dev,
6130-
"Send reset tqp cmd fail, ret = %d\n", ret);
6131-
return;
6129+
dev_err(&hdev->pdev->dev,
6130+
"Send reset tqp cmd fail, ret = %d\n", ret);
6131+
return ret;
61326132
}
61336133

61346134
reset_try_times = 0;
@@ -6141,16 +6141,16 @@ void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
61416141
}
61426142

61436143
if (reset_try_times >= HCLGE_TQP_RESET_TRY_TIMES) {
6144-
dev_warn(&hdev->pdev->dev, "Reset TQP fail\n");
6145-
return;
6144+
dev_err(&hdev->pdev->dev, "Reset TQP fail\n");
6145+
return ret;
61466146
}
61476147

61486148
ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, false);
6149-
if (ret) {
6150-
dev_warn(&hdev->pdev->dev,
6151-
"Deassert the soft reset fail, ret = %d\n", ret);
6152-
return;
6153-
}
6149+
if (ret)
6150+
dev_err(&hdev->pdev->dev,
6151+
"Deassert the soft reset fail, ret = %d\n", ret);
6152+
6153+
return ret;
61546154
}
61556155

61566156
void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ int hclge_rss_init_hw(struct hclge_dev *hdev);
778778
void hclge_rss_indir_init_cfg(struct hclge_dev *hdev);
779779

780780
void hclge_mbx_handler(struct hclge_dev *hdev);
781-
void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id);
781+
int hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id);
782782
void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id);
783783
int hclge_cfg_flowctrl(struct hclge_dev *hdev);
784784
int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id);

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -925,12 +925,12 @@ static int hclgevf_cmd_set_promisc_mode(struct hclgevf_dev *hdev,
925925
return status;
926926
}
927927

928-
static void hclgevf_set_promisc_mode(struct hnae3_handle *handle,
929-
bool en_uc_pmc, bool en_mc_pmc)
928+
static int hclgevf_set_promisc_mode(struct hnae3_handle *handle,
929+
bool en_uc_pmc, bool en_mc_pmc)
930930
{
931931
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
932932

933-
hclgevf_cmd_set_promisc_mode(hdev, en_uc_pmc, en_mc_pmc);
933+
return hclgevf_cmd_set_promisc_mode(hdev, en_uc_pmc, en_mc_pmc);
934934
}
935935

936936
static int hclgevf_tqp_enable(struct hclgevf_dev *hdev, int tqp_id,
@@ -1080,7 +1080,7 @@ static int hclgevf_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable)
10801080
1, false, NULL, 0);
10811081
}
10821082

1083-
static void hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
1083+
static int hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
10841084
{
10851085
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
10861086
u8 msg_data[2];
@@ -1091,10 +1091,10 @@ static void hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
10911091
/* disable vf queue before send queue reset msg to PF */
10921092
ret = hclgevf_tqp_enable(hdev, queue_id, 0, false);
10931093
if (ret)
1094-
return;
1094+
return ret;
10951095

1096-
hclgevf_send_mbx_msg(hdev, HCLGE_MBX_QUEUE_RESET, 0, msg_data,
1097-
2, true, NULL, 0);
1096+
return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_QUEUE_RESET, 0, msg_data,
1097+
2, true, NULL, 0);
10981098
}
10991099

11001100
static int hclgevf_notify_client(struct hclgevf_dev *hdev,

0 commit comments

Comments
 (0)