Skip to content

Commit 3b6db4a

Browse files
Yufeng Modavem330
authored andcommitted
net: hns3: sync rx ring head in echo common pull
When the driver processes rx packets, the head pointer is updated only after the number of received packets reaches 16. However, hardware relies on the head pointer to calculate the number of FBDs. As a result, the hardware calculates the FBD incorrectly. Therefore, the driver proactively updates the head pointer in each common poll to ensure that the number of FBDs calculated by the hardware is correct. Fixes: 68752b2 ("net: hns3: schedule the polling again when allocation fails") Signed-off-by: Yufeng Mo <[email protected]> Signed-off-by: Guangbin Huang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0b653a8 commit 3b6db4a

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4210,6 +4210,13 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget,
42104210
}
42114211

42124212
out:
4213+
/* sync head pointer before exiting, since hardware will calculate
4214+
* FBD number with head pointer
4215+
*/
4216+
if (unused_count > 0)
4217+
failure = failure ||
4218+
hns3_nic_alloc_rx_buffers(ring, unused_count);
4219+
42134220
return failure ? budget : recv_pkts;
42144221
}
42154222

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ static int hclge_firmware_compat_config(struct hclge_dev *hdev, bool en)
483483
if (hnae3_dev_phy_imp_supported(hdev))
484484
hnae3_set_bit(compat, HCLGE_PHY_IMP_EN_B, 1);
485485
hnae3_set_bit(compat, HCLGE_MAC_STATS_EXT_EN_B, 1);
486+
hnae3_set_bit(compat, HCLGE_SYNC_RX_RING_HEAD_EN_B, 1);
486487

487488
req->compat = cpu_to_le32(compat);
488489
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,7 @@ struct hclge_query_ppu_pf_other_int_dfx_cmd {
11511151
#define HCLGE_NCSI_ERROR_REPORT_EN_B 1
11521152
#define HCLGE_PHY_IMP_EN_B 2
11531153
#define HCLGE_MAC_STATS_EXT_EN_B 3
1154+
#define HCLGE_SYNC_RX_RING_HEAD_EN_B 4
11541155
struct hclge_firmware_compat_cmd {
11551156
__le32 compat;
11561157
u8 rsv[20];

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,28 @@ int hclgevf_cmd_queue_init(struct hclgevf_dev *hdev)
434434
return ret;
435435
}
436436

437+
static int hclgevf_firmware_compat_config(struct hclgevf_dev *hdev, bool en)
438+
{
439+
struct hclgevf_firmware_compat_cmd *req;
440+
struct hclgevf_desc desc;
441+
u32 compat = 0;
442+
443+
hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_IMP_COMPAT_CFG, false);
444+
445+
if (en) {
446+
req = (struct hclgevf_firmware_compat_cmd *)desc.data;
447+
448+
hnae3_set_bit(compat, HCLGEVF_SYNC_RX_RING_HEAD_EN_B, 1);
449+
450+
req->compat = cpu_to_le32(compat);
451+
}
452+
453+
return hclgevf_cmd_send(&hdev->hw, &desc, 1);
454+
}
455+
437456
int hclgevf_cmd_init(struct hclgevf_dev *hdev)
438457
{
458+
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev);
439459
int ret;
440460

441461
spin_lock_bh(&hdev->hw.cmq.csq.lock);
@@ -484,6 +504,17 @@ int hclgevf_cmd_init(struct hclgevf_dev *hdev)
484504
hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE0_MASK,
485505
HNAE3_FW_VERSION_BYTE0_SHIFT));
486506

507+
if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3) {
508+
/* ask the firmware to enable some features, driver can work
509+
* without it.
510+
*/
511+
ret = hclgevf_firmware_compat_config(hdev, true);
512+
if (ret)
513+
dev_warn(&hdev->pdev->dev,
514+
"Firmware compatible features not enabled(%d).\n",
515+
ret);
516+
}
517+
487518
return 0;
488519

489520
err_cmd_init:
@@ -508,6 +539,7 @@ static void hclgevf_cmd_uninit_regs(struct hclgevf_hw *hw)
508539

509540
void hclgevf_cmd_uninit(struct hclgevf_dev *hdev)
510541
{
542+
hclgevf_firmware_compat_config(hdev, false);
511543
set_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state);
512544
/* wait to ensure that the firmware completes the possible left
513545
* over commands.

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
struct hclgevf_hw;
1616
struct hclgevf_dev;
1717

18+
#define HCLGEVF_SYNC_RX_RING_HEAD_EN_B 4
19+
struct hclgevf_firmware_compat_cmd {
20+
__le32 compat;
21+
u8 rsv[20];
22+
};
23+
1824
struct hclgevf_desc {
1925
__le16 opcode;
2026
__le16 flag;
@@ -107,6 +113,9 @@ enum hclgevf_opcode_type {
107113
HCLGEVF_OPC_RSS_TC_MODE = 0x0D08,
108114
/* Mailbox cmd */
109115
HCLGEVF_OPC_MBX_VF_TO_PF = 0x2001,
116+
117+
/* IMP stats command */
118+
HCLGEVF_OPC_IMP_COMPAT_CFG = 0x701A,
110119
};
111120

112121
#define HCLGEVF_TQP_REG_OFFSET 0x80000

0 commit comments

Comments
 (0)