Skip to content

Commit 35494b0

Browse files
author
Paolo Abeni
committed
Merge branch 'there-are-some-bugfix-for-the-hns3-ethernet-driver'
Jijie Shao says: ==================== There are some bugfix for the HNS3 ethernet driver ==================== Link: https://lore.kernel.org/r/20230906072018.3020671-1-shaojijie@huawei.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2 parents 08c6d8b + 6032663 commit 35494b0

File tree

8 files changed

+39
-37
lines changed

8 files changed

+39
-37
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ struct hnae3_tc_info {
814814
u8 max_tc; /* Total number of TCs */
815815
u8 num_tc; /* Total number of enabled TCs */
816816
bool mqprio_active;
817+
bool dcb_ets_active;
817818
};
818819

819820
#define HNAE3_MAX_DSCP 64

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,7 @@ hns3_dbg_dev_specs(struct hnae3_handle *h, char *buf, int len, int *pos)
10451045
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
10461046
struct hnae3_dev_specs *dev_specs = &ae_dev->dev_specs;
10471047
struct hnae3_knic_private_info *kinfo = &h->kinfo;
1048+
struct net_device *dev = kinfo->netdev;
10481049

10491050
*pos += scnprintf(buf + *pos, len - *pos, "dev_spec:\n");
10501051
*pos += scnprintf(buf + *pos, len - *pos, "MAC entry num: %u\n",
@@ -1087,6 +1088,9 @@ hns3_dbg_dev_specs(struct hnae3_handle *h, char *buf, int len, int *pos)
10871088
dev_specs->mc_mac_size);
10881089
*pos += scnprintf(buf + *pos, len - *pos, "MAC statistics number: %u\n",
10891090
dev_specs->mac_stats_num);
1091+
*pos += scnprintf(buf + *pos, len - *pos,
1092+
"TX timeout threshold: %d seconds\n",
1093+
dev->watchdog_timeo / HZ);
10901094
}
10911095

10921096
static int hns3_dbg_dev_info(struct hnae3_handle *h, char *buf, int len)
@@ -1411,25 +1415,26 @@ int hns3_dbg_init(struct hnae3_handle *handle)
14111415
return 0;
14121416

14131417
out:
1414-
mutex_destroy(&handle->dbgfs_lock);
14151418
debugfs_remove_recursive(handle->hnae3_dbgfs);
14161419
handle->hnae3_dbgfs = NULL;
1420+
mutex_destroy(&handle->dbgfs_lock);
14171421
return ret;
14181422
}
14191423

14201424
void hns3_dbg_uninit(struct hnae3_handle *handle)
14211425
{
14221426
u32 i;
14231427

1428+
debugfs_remove_recursive(handle->hnae3_dbgfs);
1429+
handle->hnae3_dbgfs = NULL;
1430+
14241431
for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++)
14251432
if (handle->dbgfs_buf[i]) {
14261433
kvfree(handle->dbgfs_buf[i]);
14271434
handle->dbgfs_buf[i] = NULL;
14281435
}
14291436

14301437
mutex_destroy(&handle->dbgfs_lock);
1431-
debugfs_remove_recursive(handle->hnae3_dbgfs);
1432-
handle->hnae3_dbgfs = NULL;
14331438
}
14341439

14351440
void hns3_dbg_register_debugfs(const char *debugfs_dir_name)

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,8 +2103,12 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num,
21032103
*/
21042104
if (test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state) && num &&
21052105
!ring->pending_buf && num <= HNS3_MAX_PUSH_BD_NUM && doorbell) {
2106+
/* This smp_store_release() pairs with smp_load_aquire() in
2107+
* hns3_nic_reclaim_desc(). Ensure that the BD valid bit
2108+
* is updated.
2109+
*/
2110+
smp_store_release(&ring->last_to_use, ring->next_to_use);
21062111
hns3_tx_push_bd(ring, num);
2107-
WRITE_ONCE(ring->last_to_use, ring->next_to_use);
21082112
return;
21092113
}
21102114

@@ -2115,14 +2119,18 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num,
21152119
return;
21162120
}
21172121

2122+
/* This smp_store_release() pairs with smp_load_aquire() in
2123+
* hns3_nic_reclaim_desc(). Ensure that the BD valid bit is updated.
2124+
*/
2125+
smp_store_release(&ring->last_to_use, ring->next_to_use);
2126+
21182127
if (ring->tqp->mem_base)
21192128
hns3_tx_mem_doorbell(ring);
21202129
else
21212130
writel(ring->pending_buf,
21222131
ring->tqp->io_base + HNS3_RING_TX_RING_TAIL_REG);
21232132

21242133
ring->pending_buf = 0;
2125-
WRITE_ONCE(ring->last_to_use, ring->next_to_use);
21262134
}
21272135

21282136
static void hns3_tsyn(struct net_device *netdev, struct sk_buff *skb,
@@ -3308,8 +3316,6 @@ static void hns3_set_default_feature(struct net_device *netdev)
33083316

33093317
netdev->priv_flags |= IFF_UNICAST_FLT;
33103318

3311-
netdev->gso_partial_features |= NETIF_F_GSO_GRE_CSUM;
3312-
33133319
netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER |
33143320
NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
33153321
NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_GSO |
@@ -3563,9 +3569,8 @@ static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i)
35633569
static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring,
35643570
int *bytes, int *pkts, int budget)
35653571
{
3566-
/* pair with ring->last_to_use update in hns3_tx_doorbell(),
3567-
* smp_store_release() is not used in hns3_tx_doorbell() because
3568-
* the doorbell operation already have the needed barrier operation.
3572+
/* This smp_load_acquire() pairs with smp_store_release() in
3573+
* hns3_tx_doorbell().
35693574
*/
35703575
int ltu = smp_load_acquire(&ring->last_to_use);
35713576
int ntc = ring->next_to_clean;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,9 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
773773
hns3_get_ksettings(h, cmd);
774774
break;
775775
case HNAE3_MEDIA_TYPE_FIBER:
776-
if (module_type == HNAE3_MODULE_TYPE_CR)
776+
if (module_type == HNAE3_MODULE_TYPE_UNKNOWN)
777+
cmd->base.port = PORT_OTHER;
778+
else if (module_type == HNAE3_MODULE_TYPE_CR)
777779
cmd->base.port = PORT_DA;
778780
else
779781
cmd->base.port = PORT_FIBRE;

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

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
259259
int ret;
260260

261261
if (!(hdev->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) ||
262-
hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE)
262+
h->kinfo.tc_info.mqprio_active)
263263
return -EINVAL;
264264

265265
ret = hclge_ets_validate(hdev, ets, &num_tc, &map_changed);
@@ -275,10 +275,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
275275
}
276276

277277
hclge_tm_schd_info_update(hdev, num_tc);
278-
if (num_tc > 1)
279-
hdev->flag |= HCLGE_FLAG_DCB_ENABLE;
280-
else
281-
hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
278+
h->kinfo.tc_info.dcb_ets_active = num_tc > 1;
282279

283280
ret = hclge_ieee_ets_to_tm_info(hdev, ets);
284281
if (ret)
@@ -487,7 +484,7 @@ static u8 hclge_getdcbx(struct hnae3_handle *h)
487484
struct hclge_vport *vport = hclge_get_vport(h);
488485
struct hclge_dev *hdev = vport->back;
489486

490-
if (hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE)
487+
if (h->kinfo.tc_info.mqprio_active)
491488
return 0;
492489

493490
return hdev->dcbx_cap;
@@ -611,7 +608,8 @@ static int hclge_setup_tc(struct hnae3_handle *h,
611608
if (!test_bit(HCLGE_STATE_NIC_REGISTERED, &hdev->state))
612609
return -EBUSY;
613610

614-
if (hdev->flag & HCLGE_FLAG_DCB_ENABLE)
611+
kinfo = &vport->nic.kinfo;
612+
if (kinfo->tc_info.dcb_ets_active)
615613
return -EINVAL;
616614

617615
ret = hclge_mqprio_qopt_check(hdev, mqprio_qopt);
@@ -625,7 +623,6 @@ static int hclge_setup_tc(struct hnae3_handle *h,
625623
if (ret)
626624
return ret;
627625

628-
kinfo = &vport->nic.kinfo;
629626
memcpy(&old_tc_info, &kinfo->tc_info, sizeof(old_tc_info));
630627
hclge_sync_mqprio_qopt(&kinfo->tc_info, mqprio_qopt);
631628
kinfo->tc_info.mqprio_active = tc > 0;
@@ -634,13 +631,6 @@ static int hclge_setup_tc(struct hnae3_handle *h,
634631
if (ret)
635632
goto err_out;
636633

637-
hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
638-
639-
if (tc > 1)
640-
hdev->flag |= HCLGE_FLAG_MQPRIO_ENABLE;
641-
else
642-
hdev->flag &= ~HCLGE_FLAG_MQPRIO_ENABLE;
643-
644634
return hclge_notify_init_up(hdev);
645635

646636
err_out:

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ static int hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, bool sel_x,
15191519
struct hclge_desc desc[3];
15201520
int pos = 0;
15211521
int ret, i;
1522-
u32 *req;
1522+
__le32 *req;
15231523

15241524
hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_FD_TCAM_OP, true);
15251525
desc[0].flag |= cpu_to_le16(HCLGE_COMM_CMD_FLAG_NEXT);
@@ -1544,22 +1544,22 @@ static int hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, bool sel_x,
15441544
tcam_msg.loc);
15451545

15461546
/* tcam_data0 ~ tcam_data1 */
1547-
req = (u32 *)req1->tcam_data;
1547+
req = (__le32 *)req1->tcam_data;
15481548
for (i = 0; i < 2; i++)
15491549
pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos,
1550-
"%08x\n", *req++);
1550+
"%08x\n", le32_to_cpu(*req++));
15511551

15521552
/* tcam_data2 ~ tcam_data7 */
1553-
req = (u32 *)req2->tcam_data;
1553+
req = (__le32 *)req2->tcam_data;
15541554
for (i = 0; i < 6; i++)
15551555
pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos,
1556-
"%08x\n", *req++);
1556+
"%08x\n", le32_to_cpu(*req++));
15571557

15581558
/* tcam_data8 ~ tcam_data12 */
1559-
req = (u32 *)req3->tcam_data;
1559+
req = (__le32 *)req3->tcam_data;
15601560
for (i = 0; i < 5; i++)
15611561
pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos,
1562-
"%08x\n", *req++);
1562+
"%08x\n", le32_to_cpu(*req++));
15631563

15641564
return ret;
15651565
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11026,6 +11026,7 @@ static void hclge_get_mdix_mode(struct hnae3_handle *handle,
1102611026

1102711027
static void hclge_info_show(struct hclge_dev *hdev)
1102811028
{
11029+
struct hnae3_handle *handle = &hdev->vport->nic;
1102911030
struct device *dev = &hdev->pdev->dev;
1103011031

1103111032
dev_info(dev, "PF info begin:\n");
@@ -11042,9 +11043,9 @@ static void hclge_info_show(struct hclge_dev *hdev)
1104211043
dev_info(dev, "This is %s PF\n",
1104311044
hdev->flag & HCLGE_FLAG_MAIN ? "main" : "not main");
1104411045
dev_info(dev, "DCB %s\n",
11045-
hdev->flag & HCLGE_FLAG_DCB_ENABLE ? "enable" : "disable");
11046+
handle->kinfo.tc_info.dcb_ets_active ? "enable" : "disable");
1104611047
dev_info(dev, "MQPRIO %s\n",
11047-
hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE ? "enable" : "disable");
11048+
handle->kinfo.tc_info.mqprio_active ? "enable" : "disable");
1104811049
dev_info(dev, "Default tx spare buffer size: %u\n",
1104911050
hdev->tx_spare_buf_size);
1105011051

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,6 @@ struct hclge_dev {
919919

920920
#define HCLGE_FLAG_MAIN BIT(0)
921921
#define HCLGE_FLAG_DCB_CAPABLE BIT(1)
922-
#define HCLGE_FLAG_DCB_ENABLE BIT(2)
923-
#define HCLGE_FLAG_MQPRIO_ENABLE BIT(3)
924922
u32 flag;
925923

926924
u32 pkt_buf_size; /* Total pf buf size for tx/rx */

0 commit comments

Comments
 (0)