Skip to content

Commit 9751e8e

Browse files
CCX-Stingraydavem330
authored andcommitted
bnxt_en: reduce timeout on initial HWRM calls
Testing with DIM enabled on older kernels indicated that firmware calls were slower than expected. More detailed analysis indicated that the default 25us delay was higher than necessary. Reducing the time spend in usleep_range() for the first several calls would reduce the overall latency of firmware calls on newer Intel processors. Signed-off-by: Andy Gospodarek <gospo@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 05abe4d commit 9751e8e

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3495,15 +3495,29 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
34953495

34963496
if (!timeout)
34973497
timeout = DFLT_HWRM_CMD_TIMEOUT;
3498+
/* convert timeout to usec */
3499+
timeout *= 1000;
34983500

34993501
i = 0;
3500-
tmo_count = timeout * 40;
3502+
/* Short timeout for the first few iterations:
3503+
* number of loops = number of loops for short timeout +
3504+
* number of loops for standard timeout.
3505+
*/
3506+
tmo_count = HWRM_SHORT_TIMEOUT_COUNTER;
3507+
timeout = timeout - HWRM_SHORT_MIN_TIMEOUT * HWRM_SHORT_TIMEOUT_COUNTER;
3508+
tmo_count += DIV_ROUND_UP(timeout, HWRM_MIN_TIMEOUT);
35013509
resp_len = bp->hwrm_cmd_resp_addr + HWRM_RESP_LEN_OFFSET;
35023510
if (intr_process) {
35033511
/* Wait until hwrm response cmpl interrupt is processed */
35043512
while (bp->hwrm_intr_seq_id != HWRM_SEQ_ID_INVALID &&
35053513
i++ < tmo_count) {
3506-
usleep_range(25, 40);
3514+
/* on first few passes, just barely sleep */
3515+
if (i < HWRM_SHORT_TIMEOUT_COUNTER)
3516+
usleep_range(HWRM_SHORT_MIN_TIMEOUT,
3517+
HWRM_SHORT_MAX_TIMEOUT);
3518+
else
3519+
usleep_range(HWRM_MIN_TIMEOUT,
3520+
HWRM_MAX_TIMEOUT);
35073521
}
35083522

35093523
if (bp->hwrm_intr_seq_id != HWRM_SEQ_ID_INVALID) {
@@ -3521,7 +3535,13 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
35213535
HWRM_RESP_LEN_SFT;
35223536
if (len)
35233537
break;
3524-
usleep_range(25, 40);
3538+
/* on first few passes, just barely sleep */
3539+
if (i < DFLT_HWRM_CMD_TIMEOUT)
3540+
usleep_range(HWRM_SHORT_MIN_TIMEOUT,
3541+
HWRM_SHORT_MAX_TIMEOUT);
3542+
else
3543+
usleep_range(HWRM_MIN_TIMEOUT,
3544+
HWRM_MAX_TIMEOUT);
35253545
}
35263546

35273547
if (i >= tmo_count) {

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,12 @@ struct rx_tpa_end_cmp_ext {
532532
#define BNXT_HWRM_REQ_MAX_SIZE 128
533533
#define BNXT_HWRM_REQS_PER_PAGE (BNXT_PAGE_SIZE / \
534534
BNXT_HWRM_REQ_MAX_SIZE)
535+
#define HWRM_SHORT_MIN_TIMEOUT 3
536+
#define HWRM_SHORT_MAX_TIMEOUT 10
537+
#define HWRM_SHORT_TIMEOUT_COUNTER 5
538+
539+
#define HWRM_MIN_TIMEOUT 25
540+
#define HWRM_MAX_TIMEOUT 40
535541

536542
#define BNXT_RX_EVENT 1
537543
#define BNXT_AGG_EVENT 2

0 commit comments

Comments
 (0)