Skip to content

Commit 6b45d5f

Browse files
Jijie Shaodavem330
authored andcommitted
net: hns3: fix reset timeout when enable full VF
The timeout of the cmdq reset command has been increased to resolve the reset timeout issue in the full VF scenario. The timeout of other cmdq commands remains unchanged. Fixes: 8d307f8 ("net: hns3: create new set of unified hclge_comm_cmd_send APIs") Signed-off-by: Jijie Shao <[email protected]> Signed-off-by: Hao Lan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 814d0c7 commit 6b45d5f

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,25 @@ static int hclge_comm_cmd_csq_done(struct hclge_comm_hw *hw)
331331
return head == hw->cmq.csq.next_to_use;
332332
}
333333

334-
static void hclge_comm_wait_for_resp(struct hclge_comm_hw *hw,
334+
static u32 hclge_get_cmdq_tx_timeout(u16 opcode, u32 tx_timeout)
335+
{
336+
static const struct hclge_cmdq_tx_timeout_map cmdq_tx_timeout_map[] = {
337+
{HCLGE_OPC_CFG_RST_TRIGGER, HCLGE_COMM_CMDQ_TX_TIMEOUT_500MS},
338+
};
339+
u32 i;
340+
341+
for (i = 0; i < ARRAY_SIZE(cmdq_tx_timeout_map); i++)
342+
if (cmdq_tx_timeout_map[i].opcode == opcode)
343+
return cmdq_tx_timeout_map[i].tx_timeout;
344+
345+
return tx_timeout;
346+
}
347+
348+
static void hclge_comm_wait_for_resp(struct hclge_comm_hw *hw, u16 opcode,
335349
bool *is_completed)
336350
{
351+
u32 cmdq_tx_timeout = hclge_get_cmdq_tx_timeout(opcode,
352+
hw->cmq.tx_timeout);
337353
u32 timeout = 0;
338354

339355
do {
@@ -343,7 +359,7 @@ static void hclge_comm_wait_for_resp(struct hclge_comm_hw *hw,
343359
}
344360
udelay(1);
345361
timeout++;
346-
} while (timeout < hw->cmq.tx_timeout);
362+
} while (timeout < cmdq_tx_timeout);
347363
}
348364

349365
static int hclge_comm_cmd_convert_err_code(u16 desc_ret)
@@ -407,7 +423,8 @@ static int hclge_comm_cmd_check_result(struct hclge_comm_hw *hw,
407423
* if multi descriptors to be sent, use the first one to check
408424
*/
409425
if (HCLGE_COMM_SEND_SYNC(le16_to_cpu(desc->flag)))
410-
hclge_comm_wait_for_resp(hw, &is_completed);
426+
hclge_comm_wait_for_resp(hw, le16_to_cpu(desc->opcode),
427+
&is_completed);
411428

412429
if (!is_completed)
413430
ret = -EBADE;
@@ -529,7 +546,7 @@ int hclge_comm_cmd_queue_init(struct pci_dev *pdev, struct hclge_comm_hw *hw)
529546
cmdq->crq.desc_num = HCLGE_COMM_NIC_CMQ_DESC_NUM;
530547

531548
/* Setup Tx write back timeout */
532-
cmdq->tx_timeout = HCLGE_COMM_CMDQ_TX_TIMEOUT;
549+
cmdq->tx_timeout = HCLGE_COMM_CMDQ_TX_TIMEOUT_DEFAULT;
533550

534551
/* Setup queue rings */
535552
ret = hclge_comm_alloc_cmd_queue(hw, HCLGE_COMM_TYPE_CSQ);

drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
#define HCLGE_COMM_NIC_SW_RST_RDY BIT(HCLGE_COMM_NIC_SW_RST_RDY_B)
5555
#define HCLGE_COMM_NIC_CMQ_DESC_NUM_S 3
5656
#define HCLGE_COMM_NIC_CMQ_DESC_NUM 1024
57-
#define HCLGE_COMM_CMDQ_TX_TIMEOUT 30000
57+
#define HCLGE_COMM_CMDQ_TX_TIMEOUT_DEFAULT 30000
58+
#define HCLGE_COMM_CMDQ_TX_TIMEOUT_500MS 500000
5859

5960
enum hclge_opcode_type {
6061
/* Generic commands */
@@ -360,6 +361,11 @@ struct hclge_comm_caps_bit_map {
360361
u16 local_bit;
361362
};
362363

364+
struct hclge_cmdq_tx_timeout_map {
365+
u32 opcode;
366+
u32 tx_timeout;
367+
};
368+
363369
struct hclge_comm_firmware_compat_cmd {
364370
__le32 compat;
365371
u8 rsv[20];

0 commit comments

Comments
 (0)