Skip to content

Commit 424a4f5

Browse files
committed
Merge branch 'hns3-fixes'
Guangbin Huang says: ==================== net: hns3: add some fixes for -net This series adds some fixes for the HNS3 ethernet driver. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 440ffcd + 630a673 commit 424a4f5

File tree

10 files changed

+90
-65
lines changed

10 files changed

+90
-65
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ struct hnae3_ae_ops {
568568
u32 *auto_neg, u32 *rx_en, u32 *tx_en);
569569
int (*set_pauseparam)(struct hnae3_handle *handle,
570570
u32 auto_neg, u32 rx_en, u32 tx_en);
571+
int (*restore_pauseparam)(struct hnae3_handle *handle);
571572

572573
int (*set_autoneg)(struct hnae3_handle *handle, bool enable);
573574
int (*get_autoneg)(struct hnae3_handle *handle);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
137137
.name = "uc",
138138
.cmd = HNAE3_DBG_CMD_MAC_UC,
139139
.dentry = HNS3_DBG_DENTRY_MAC,
140-
.buf_len = HNS3_DBG_READ_LEN,
140+
.buf_len = HNS3_DBG_READ_LEN_128KB,
141141
.init = hns3_dbg_common_file_init,
142142
},
143143
{
@@ -256,7 +256,7 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
256256
.name = "tqp",
257257
.cmd = HNAE3_DBG_CMD_REG_TQP,
258258
.dentry = HNS3_DBG_DENTRY_REG,
259-
.buf_len = HNS3_DBG_READ_LEN,
259+
.buf_len = HNS3_DBG_READ_LEN_128KB,
260260
.init = hns3_dbg_common_file_init,
261261
},
262262
{
@@ -298,7 +298,7 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
298298
.name = "fd_tcam",
299299
.cmd = HNAE3_DBG_CMD_FD_TCAM,
300300
.dentry = HNS3_DBG_DENTRY_FD,
301-
.buf_len = HNS3_DBG_READ_LEN,
301+
.buf_len = HNS3_DBG_READ_LEN_1MB,
302302
.init = hns3_dbg_common_file_init,
303303
},
304304
{
@@ -462,7 +462,7 @@ static const struct hns3_dbg_item rx_queue_info_items[] = {
462462
{ "TAIL", 2 },
463463
{ "HEAD", 2 },
464464
{ "FBDNUM", 2 },
465-
{ "PKTNUM", 2 },
465+
{ "PKTNUM", 5 },
466466
{ "COPYBREAK", 2 },
467467
{ "RING_EN", 2 },
468468
{ "RX_RING_EN", 2 },
@@ -565,7 +565,7 @@ static const struct hns3_dbg_item tx_queue_info_items[] = {
565565
{ "HEAD", 2 },
566566
{ "FBDNUM", 2 },
567567
{ "OFFSET", 2 },
568-
{ "PKTNUM", 2 },
568+
{ "PKTNUM", 5 },
569569
{ "RING_EN", 2 },
570570
{ "TX_RING_EN", 2 },
571571
{ "BASE_ADDR", 10 },
@@ -790,13 +790,13 @@ static int hns3_dbg_rx_bd_info(struct hns3_dbg_data *d, char *buf, int len)
790790
}
791791

792792
static const struct hns3_dbg_item tx_bd_info_items[] = {
793-
{ "BD_IDX", 5 },
794-
{ "ADDRESS", 2 },
793+
{ "BD_IDX", 2 },
794+
{ "ADDRESS", 13 },
795795
{ "VLAN_TAG", 2 },
796796
{ "SIZE", 2 },
797797
{ "T_CS_VLAN_TSO", 2 },
798798
{ "OT_VLAN_TAG", 3 },
799-
{ "TV", 2 },
799+
{ "TV", 5 },
800800
{ "OLT_VLAN_LEN", 2 },
801801
{ "PAYLEN_OL4CS", 2 },
802802
{ "BD_FE_SC_VLD", 2 },

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

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,26 @@ static int hns3_check_ksettings_param(const struct net_device *netdev,
824824
return 0;
825825
}
826826

827+
static int hns3_set_phy_link_ksettings(struct net_device *netdev,
828+
const struct ethtool_link_ksettings *cmd)
829+
{
830+
struct hnae3_handle *handle = hns3_get_handle(netdev);
831+
const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
832+
int ret;
833+
834+
if (cmd->base.speed == SPEED_1000 &&
835+
cmd->base.autoneg == AUTONEG_DISABLE)
836+
return -EINVAL;
837+
838+
if (cmd->base.autoneg == AUTONEG_DISABLE && ops->restore_pauseparam) {
839+
ret = ops->restore_pauseparam(handle);
840+
if (ret)
841+
return ret;
842+
}
843+
844+
return phy_ethtool_ksettings_set(netdev->phydev, cmd);
845+
}
846+
827847
static int hns3_set_link_ksettings(struct net_device *netdev,
828848
const struct ethtool_link_ksettings *cmd)
829849
{
@@ -842,16 +862,11 @@ static int hns3_set_link_ksettings(struct net_device *netdev,
842862
cmd->base.autoneg, cmd->base.speed, cmd->base.duplex);
843863

844864
/* Only support ksettings_set for netdev with phy attached for now */
845-
if (netdev->phydev) {
846-
if (cmd->base.speed == SPEED_1000 &&
847-
cmd->base.autoneg == AUTONEG_DISABLE)
848-
return -EINVAL;
849-
850-
return phy_ethtool_ksettings_set(netdev->phydev, cmd);
851-
} else if (test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, ae_dev->caps) &&
852-
ops->set_phy_link_ksettings) {
865+
if (netdev->phydev)
866+
return hns3_set_phy_link_ksettings(netdev, cmd);
867+
else if (test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, ae_dev->caps) &&
868+
ops->set_phy_link_ksettings)
853869
return ops->set_phy_link_ksettings(handle, cmd);
854-
}
855870

856871
if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2)
857872
return -EOPNOTSUPP;

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ static int hclge_dbg_dump_mac(struct hclge_dev *hdev, char *buf, int len)
391391
static int hclge_dbg_dump_dcb_qset(struct hclge_dev *hdev, char *buf, int len,
392392
int *pos)
393393
{
394-
struct hclge_dbg_bitmap_cmd *bitmap;
394+
struct hclge_dbg_bitmap_cmd req;
395395
struct hclge_desc desc;
396396
u16 qset_id, qset_num;
397397
int ret;
@@ -408,12 +408,12 @@ static int hclge_dbg_dump_dcb_qset(struct hclge_dev *hdev, char *buf, int len,
408408
if (ret)
409409
return ret;
410410

411-
bitmap = (struct hclge_dbg_bitmap_cmd *)&desc.data[1];
411+
req.bitmap = (u8)le32_to_cpu(desc.data[1]);
412412

413413
*pos += scnprintf(buf + *pos, len - *pos,
414414
"%04u %#x %#x %#x %#x\n",
415-
qset_id, bitmap->bit0, bitmap->bit1,
416-
bitmap->bit2, bitmap->bit3);
415+
qset_id, req.bit0, req.bit1, req.bit2,
416+
req.bit3);
417417
}
418418

419419
return 0;
@@ -422,7 +422,7 @@ static int hclge_dbg_dump_dcb_qset(struct hclge_dev *hdev, char *buf, int len,
422422
static int hclge_dbg_dump_dcb_pri(struct hclge_dev *hdev, char *buf, int len,
423423
int *pos)
424424
{
425-
struct hclge_dbg_bitmap_cmd *bitmap;
425+
struct hclge_dbg_bitmap_cmd req;
426426
struct hclge_desc desc;
427427
u8 pri_id, pri_num;
428428
int ret;
@@ -439,12 +439,11 @@ static int hclge_dbg_dump_dcb_pri(struct hclge_dev *hdev, char *buf, int len,
439439
if (ret)
440440
return ret;
441441

442-
bitmap = (struct hclge_dbg_bitmap_cmd *)&desc.data[1];
442+
req.bitmap = (u8)le32_to_cpu(desc.data[1]);
443443

444444
*pos += scnprintf(buf + *pos, len - *pos,
445445
"%03u %#x %#x %#x\n",
446-
pri_id, bitmap->bit0, bitmap->bit1,
447-
bitmap->bit2);
446+
pri_id, req.bit0, req.bit1, req.bit2);
448447
}
449448

450449
return 0;
@@ -453,7 +452,7 @@ static int hclge_dbg_dump_dcb_pri(struct hclge_dev *hdev, char *buf, int len,
453452
static int hclge_dbg_dump_dcb_pg(struct hclge_dev *hdev, char *buf, int len,
454453
int *pos)
455454
{
456-
struct hclge_dbg_bitmap_cmd *bitmap;
455+
struct hclge_dbg_bitmap_cmd req;
457456
struct hclge_desc desc;
458457
u8 pg_id;
459458
int ret;
@@ -466,12 +465,11 @@ static int hclge_dbg_dump_dcb_pg(struct hclge_dev *hdev, char *buf, int len,
466465
if (ret)
467466
return ret;
468467

469-
bitmap = (struct hclge_dbg_bitmap_cmd *)&desc.data[1];
468+
req.bitmap = (u8)le32_to_cpu(desc.data[1]);
470469

471470
*pos += scnprintf(buf + *pos, len - *pos,
472471
"%03u %#x %#x %#x\n",
473-
pg_id, bitmap->bit0, bitmap->bit1,
474-
bitmap->bit2);
472+
pg_id, req.bit0, req.bit1, req.bit2);
475473
}
476474

477475
return 0;
@@ -511,7 +509,7 @@ static int hclge_dbg_dump_dcb_queue(struct hclge_dev *hdev, char *buf, int len,
511509
static int hclge_dbg_dump_dcb_port(struct hclge_dev *hdev, char *buf, int len,
512510
int *pos)
513511
{
514-
struct hclge_dbg_bitmap_cmd *bitmap;
512+
struct hclge_dbg_bitmap_cmd req;
515513
struct hclge_desc desc;
516514
u8 port_id = 0;
517515
int ret;
@@ -521,12 +519,12 @@ static int hclge_dbg_dump_dcb_port(struct hclge_dev *hdev, char *buf, int len,
521519
if (ret)
522520
return ret;
523521

524-
bitmap = (struct hclge_dbg_bitmap_cmd *)&desc.data[1];
522+
req.bitmap = (u8)le32_to_cpu(desc.data[1]);
525523

526524
*pos += scnprintf(buf + *pos, len - *pos, "port_mask: %#x\n",
527-
bitmap->bit0);
525+
req.bit0);
528526
*pos += scnprintf(buf + *pos, len - *pos, "port_shaping_pass: %#x\n",
529-
bitmap->bit1);
527+
req.bit1);
530528

531529
return 0;
532530
}

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

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,33 +2847,29 @@ static void hclge_mbx_task_schedule(struct hclge_dev *hdev)
28472847
{
28482848
if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) &&
28492849
!test_and_set_bit(HCLGE_STATE_MBX_SERVICE_SCHED, &hdev->state))
2850-
mod_delayed_work_on(cpumask_first(&hdev->affinity_mask),
2851-
hclge_wq, &hdev->service_task, 0);
2850+
mod_delayed_work(hclge_wq, &hdev->service_task, 0);
28522851
}
28532852

28542853
static void hclge_reset_task_schedule(struct hclge_dev *hdev)
28552854
{
28562855
if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) &&
2856+
test_bit(HCLGE_STATE_SERVICE_INITED, &hdev->state) &&
28572857
!test_and_set_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state))
2858-
mod_delayed_work_on(cpumask_first(&hdev->affinity_mask),
2859-
hclge_wq, &hdev->service_task, 0);
2858+
mod_delayed_work(hclge_wq, &hdev->service_task, 0);
28602859
}
28612860

28622861
static void hclge_errhand_task_schedule(struct hclge_dev *hdev)
28632862
{
28642863
if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) &&
28652864
!test_and_set_bit(HCLGE_STATE_ERR_SERVICE_SCHED, &hdev->state))
2866-
mod_delayed_work_on(cpumask_first(&hdev->affinity_mask),
2867-
hclge_wq, &hdev->service_task, 0);
2865+
mod_delayed_work(hclge_wq, &hdev->service_task, 0);
28682866
}
28692867

28702868
void hclge_task_schedule(struct hclge_dev *hdev, unsigned long delay_time)
28712869
{
28722870
if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) &&
28732871
!test_bit(HCLGE_STATE_RST_FAIL, &hdev->state))
2874-
mod_delayed_work_on(cpumask_first(&hdev->affinity_mask),
2875-
hclge_wq, &hdev->service_task,
2876-
delay_time);
2872+
mod_delayed_work(hclge_wq, &hdev->service_task, delay_time);
28772873
}
28782874

28792875
static int hclge_get_mac_link_status(struct hclge_dev *hdev, int *link_status)
@@ -3491,33 +3487,14 @@ static void hclge_get_misc_vector(struct hclge_dev *hdev)
34913487
hdev->num_msi_used += 1;
34923488
}
34933489

3494-
static void hclge_irq_affinity_notify(struct irq_affinity_notify *notify,
3495-
const cpumask_t *mask)
3496-
{
3497-
struct hclge_dev *hdev = container_of(notify, struct hclge_dev,
3498-
affinity_notify);
3499-
3500-
cpumask_copy(&hdev->affinity_mask, mask);
3501-
}
3502-
3503-
static void hclge_irq_affinity_release(struct kref *ref)
3504-
{
3505-
}
3506-
35073490
static void hclge_misc_affinity_setup(struct hclge_dev *hdev)
35083491
{
35093492
irq_set_affinity_hint(hdev->misc_vector.vector_irq,
35103493
&hdev->affinity_mask);
3511-
3512-
hdev->affinity_notify.notify = hclge_irq_affinity_notify;
3513-
hdev->affinity_notify.release = hclge_irq_affinity_release;
3514-
irq_set_affinity_notifier(hdev->misc_vector.vector_irq,
3515-
&hdev->affinity_notify);
35163494
}
35173495

35183496
static void hclge_misc_affinity_teardown(struct hclge_dev *hdev)
35193497
{
3520-
irq_set_affinity_notifier(hdev->misc_vector.vector_irq, NULL);
35213498
irq_set_affinity_hint(hdev->misc_vector.vector_irq, NULL);
35223499
}
35233500

@@ -11021,6 +10998,35 @@ static int hclge_set_pauseparam(struct hnae3_handle *handle, u32 auto_neg,
1102110998
return -EOPNOTSUPP;
1102210999
}
1102311000

11001+
static int hclge_restore_pauseparam(struct hnae3_handle *handle)
11002+
{
11003+
struct hclge_vport *vport = hclge_get_vport(handle);
11004+
struct hclge_dev *hdev = vport->back;
11005+
u32 auto_neg, rx_pause, tx_pause;
11006+
int ret;
11007+
11008+
hclge_get_pauseparam(handle, &auto_neg, &rx_pause, &tx_pause);
11009+
/* when autoneg is disabled, the pause setting of phy has no effect
11010+
* unless the link goes down.
11011+
*/
11012+
ret = phy_suspend(hdev->hw.mac.phydev);
11013+
if (ret)
11014+
return ret;
11015+
11016+
phy_set_asym_pause(hdev->hw.mac.phydev, rx_pause, tx_pause);
11017+
11018+
ret = phy_resume(hdev->hw.mac.phydev);
11019+
if (ret)
11020+
return ret;
11021+
11022+
ret = hclge_mac_pause_setup_hw(hdev);
11023+
if (ret)
11024+
dev_err(&hdev->pdev->dev,
11025+
"restore pauseparam error, ret = %d.\n", ret);
11026+
11027+
return ret;
11028+
}
11029+
1102411030
static void hclge_get_ksettings_an_result(struct hnae3_handle *handle,
1102511031
u8 *auto_neg, u32 *speed, u8 *duplex)
1102611032
{
@@ -12984,6 +12990,7 @@ static const struct hnae3_ae_ops hclge_ops = {
1298412990
.halt_autoneg = hclge_halt_autoneg,
1298512991
.get_pauseparam = hclge_get_pauseparam,
1298612992
.set_pauseparam = hclge_set_pauseparam,
12993+
.restore_pauseparam = hclge_restore_pauseparam,
1298712994
.set_mtu = hclge_set_mtu,
1298812995
.reset_queue = hclge_reset_tqp,
1298912996
.get_stats = hclge_get_stats,
@@ -13052,7 +13059,7 @@ static int hclge_init(void)
1305213059
{
1305313060
pr_info("%s is initializing\n", HCLGE_NAME);
1305413061

13055-
hclge_wq = alloc_workqueue("%s", 0, 0, HCLGE_NAME);
13062+
hclge_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, HCLGE_NAME);
1305613063
if (!hclge_wq) {
1305713064
pr_err("%s: failed to create workqueue\n", HCLGE_NAME);
1305813065
return -ENOMEM;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,6 @@ struct hclge_dev {
944944

945945
/* affinity mask and notify for misc interrupt */
946946
cpumask_t affinity_mask;
947-
struct irq_affinity_notify affinity_notify;
948947
struct hclge_ptp *ptp;
949948
struct devlink *devlink;
950949
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ static int hclge_bp_setup_hw(struct hclge_dev *hdev, u8 tc)
14351435
return 0;
14361436
}
14371437

1438-
static int hclge_mac_pause_setup_hw(struct hclge_dev *hdev)
1438+
int hclge_mac_pause_setup_hw(struct hclge_dev *hdev)
14391439
{
14401440
bool tx_en, rx_en;
14411441

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ int hclge_tm_get_pri_weight(struct hclge_dev *hdev, u8 pri_id, u8 *weight);
244244
int hclge_tm_get_pri_shaper(struct hclge_dev *hdev, u8 pri_id,
245245
enum hclge_opcode_type cmd,
246246
struct hclge_tm_shaper_para *para);
247+
int hclge_mac_pause_setup_hw(struct hclge_dev *hdev);
247248
int hclge_tm_get_q_to_qs_map(struct hclge_dev *hdev, u16 q_id, u16 *qset_id);
248249
int hclge_tm_get_q_to_tc(struct hclge_dev *hdev, u16 q_id, u8 *tc_id);
249250
int hclge_tm_get_pg_to_pri_map(struct hclge_dev *hdev, u8 pg_id,

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,7 @@ static void hclgevf_get_misc_vector(struct hclgevf_dev *hdev)
22322232
void hclgevf_reset_task_schedule(struct hclgevf_dev *hdev)
22332233
{
22342234
if (!test_bit(HCLGEVF_STATE_REMOVING, &hdev->state) &&
2235+
test_bit(HCLGEVF_STATE_SERVICE_INITED, &hdev->state) &&
22352236
!test_and_set_bit(HCLGEVF_STATE_RST_SERVICE_SCHED,
22362237
&hdev->state))
22372238
mod_delayed_work(hclgevf_wq, &hdev->service_task, 0);
@@ -3449,6 +3450,8 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
34493450

34503451
hclgevf_init_rxd_adv_layout(hdev);
34513452

3453+
set_bit(HCLGEVF_STATE_SERVICE_INITED, &hdev->state);
3454+
34523455
hdev->last_reset_time = jiffies;
34533456
dev_info(&hdev->pdev->dev, "finished initializing %s driver\n",
34543457
HCLGEVF_DRIVER_NAME);
@@ -3899,7 +3902,7 @@ static int hclgevf_init(void)
38993902
{
39003903
pr_info("%s is initializing\n", HCLGEVF_NAME);
39013904

3902-
hclgevf_wq = alloc_workqueue("%s", 0, 0, HCLGEVF_NAME);
3905+
hclgevf_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, HCLGEVF_NAME);
39033906
if (!hclgevf_wq) {
39043907
pr_err("%s: failed to create workqueue\n", HCLGEVF_NAME);
39053908
return -ENOMEM;

0 commit comments

Comments
 (0)