Skip to content

Commit 830f93f

Browse files
kadesai16rleon
authored andcommitted
RDMA/bnxt_re: optimize the parameters passed to helper functions
Avoid passing arguments like Opcode which can be retrieved from bnxt_qplib_crsqe structure. Signed-off-by: Kashyap Desai <[email protected]> Signed-off-by: Selvin Xavier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent bcfee4c commit 830f93f

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

drivers/infiniband/hw/bnxt_re/qplib_rcfw.c

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ static int bnxt_qplib_map_rc(u8 opcode)
9393
* bnxt_re_is_fw_stalled - Check firmware health
9494
* @rcfw - rcfw channel instance of rdev
9595
* @cookie - cookie to track the command
96-
* @opcode - rcfw submitted for given opcode
97-
* @cbit - bitmap entry of cookie
98-
* @in_used - command is in used or freed
9996
*
10097
* If firmware has not responded any rcfw command within
10198
* rcfw->max_timeout, consider firmware as stalled.
@@ -105,20 +102,22 @@ static int bnxt_qplib_map_rc(u8 opcode)
105102
* -ENODEV if firmware is not responding
106103
*/
107104
static int bnxt_re_is_fw_stalled(struct bnxt_qplib_rcfw *rcfw,
108-
u16 cookie, u8 opcode, bool in_used)
105+
u16 cookie)
109106
{
110107
struct bnxt_qplib_cmdq_ctx *cmdq;
108+
struct bnxt_qplib_crsqe *crsqe;
111109

110+
crsqe = &rcfw->crsqe_tbl[cookie];
112111
cmdq = &rcfw->cmdq;
113112

114113
if (time_after(jiffies, cmdq->last_seen +
115114
(rcfw->max_timeout * HZ))) {
116115
dev_warn_ratelimited(&rcfw->pdev->dev,
117116
"%s: FW STALL Detected. cmdq[%#x]=%#x waited (%d > %d) msec active %d ",
118-
__func__, cookie, opcode,
117+
__func__, cookie, crsqe->opcode,
119118
jiffies_to_msecs(jiffies - cmdq->last_seen),
120119
rcfw->max_timeout * 1000,
121-
in_used);
120+
crsqe->is_in_used);
122121
return -ENODEV;
123122
}
124123

@@ -129,15 +128,14 @@ static int bnxt_re_is_fw_stalled(struct bnxt_qplib_rcfw *rcfw,
129128
* __wait_for_resp - Don't hold the cpu context and wait for response
130129
* @rcfw - rcfw channel instance of rdev
131130
* @cookie - cookie to track the command
132-
* @opcode - rcfw submitted for given opcode
133131
*
134132
* Wait for command completion in sleepable context.
135133
*
136134
* Returns:
137135
* 0 if command is completed by firmware.
138136
* Non zero error code for rest of the case.
139137
*/
140-
static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie, u8 opcode)
138+
static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie)
141139
{
142140
struct bnxt_qplib_cmdq_ctx *cmdq;
143141
struct bnxt_qplib_crsqe *crsqe;
@@ -148,7 +146,7 @@ static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie, u8 opcode)
148146

149147
do {
150148
if (test_bit(ERR_DEVICE_DETACHED, &cmdq->flags))
151-
return bnxt_qplib_map_rc(opcode);
149+
return bnxt_qplib_map_rc(crsqe->opcode);
152150
if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags))
153151
return -ETIMEDOUT;
154152

@@ -165,7 +163,7 @@ static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie, u8 opcode)
165163
if (!crsqe->is_in_used)
166164
return 0;
167165

168-
ret = bnxt_re_is_fw_stalled(rcfw, cookie, opcode, crsqe->is_in_used);
166+
ret = bnxt_re_is_fw_stalled(rcfw, cookie);
169167
if (ret)
170168
return ret;
171169

@@ -176,7 +174,6 @@ static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie, u8 opcode)
176174
* __block_for_resp - hold the cpu context and wait for response
177175
* @rcfw - rcfw channel instance of rdev
178176
* @cookie - cookie to track the command
179-
* @opcode - rcfw submitted for given opcode
180177
*
181178
* This function will hold the cpu (non-sleepable context) and
182179
* wait for command completion. Maximum holding interval is 8 second.
@@ -185,7 +182,7 @@ static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie, u8 opcode)
185182
* -ETIMEOUT if command is not completed in specific time interval.
186183
* 0 if command is completed by firmware.
187184
*/
188-
static int __block_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie, u8 opcode)
185+
static int __block_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie)
189186
{
190187
struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq;
191188
struct bnxt_qplib_crsqe *crsqe;
@@ -196,7 +193,7 @@ static int __block_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie, u8 opcode)
196193

197194
do {
198195
if (test_bit(ERR_DEVICE_DETACHED, &cmdq->flags))
199-
return bnxt_qplib_map_rc(opcode);
196+
return bnxt_qplib_map_rc(crsqe->opcode);
200197
if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags))
201198
return -ETIMEDOUT;
202199

@@ -372,7 +369,6 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw,
372369
* __poll_for_resp - self poll completion for rcfw command
373370
* @rcfw - rcfw channel instance of rdev
374371
* @cookie - cookie to track the command
375-
* @opcode - rcfw submitted for given opcode
376372
*
377373
* It works same as __wait_for_resp except this function will
378374
* do self polling in sort interval since interrupt is disabled.
@@ -382,8 +378,7 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw,
382378
* -ETIMEOUT if command is not completed in specific time interval.
383379
* 0 if command is completed by firmware.
384380
*/
385-
static int __poll_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie,
386-
u8 opcode)
381+
static int __poll_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie)
387382
{
388383
struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq;
389384
struct bnxt_qplib_crsqe *crsqe;
@@ -395,7 +390,7 @@ static int __poll_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie,
395390

396391
do {
397392
if (test_bit(ERR_DEVICE_DETACHED, &cmdq->flags))
398-
return bnxt_qplib_map_rc(opcode);
393+
return bnxt_qplib_map_rc(crsqe->opcode);
399394
if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags))
400395
return -ETIMEDOUT;
401396

@@ -406,21 +401,20 @@ static int __poll_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie,
406401
return 0;
407402
if (jiffies_to_msecs(jiffies - issue_time) >
408403
(rcfw->max_timeout * 1000)) {
409-
ret = bnxt_re_is_fw_stalled(rcfw, cookie, opcode, crsqe->is_in_used);
404+
ret = bnxt_re_is_fw_stalled(rcfw, cookie);
410405
if (ret)
411406
return ret;
412407
}
413408
} while (true);
414409
};
415410

416411
static int __send_message_basic_sanity(struct bnxt_qplib_rcfw *rcfw,
417-
struct bnxt_qplib_cmdqmsg *msg)
412+
struct bnxt_qplib_cmdqmsg *msg,
413+
u8 opcode)
418414
{
419415
struct bnxt_qplib_cmdq_ctx *cmdq;
420-
u32 opcode;
421416

422417
cmdq = &rcfw->cmdq;
423-
opcode = __get_cmdq_base_opcode(msg->req, msg->req_sz);
424418

425419
/* Prevent posting if f/w is not in a state to process */
426420
if (test_bit(ERR_DEVICE_DETACHED, &rcfw->cmdq.flags))
@@ -492,7 +486,7 @@ static int __bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw,
492486

493487
opcode = __get_cmdq_base_opcode(msg->req, msg->req_sz);
494488

495-
rc = __send_message_basic_sanity(rcfw, msg);
489+
rc = __send_message_basic_sanity(rcfw, msg, opcode);
496490
if (rc)
497491
return rc == -ENXIO ? bnxt_qplib_map_rc(opcode) : rc;
498492

@@ -504,11 +498,11 @@ static int __bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw,
504498
& RCFW_MAX_COOKIE_VALUE;
505499

506500
if (msg->block)
507-
rc = __block_for_resp(rcfw, cookie, opcode);
501+
rc = __block_for_resp(rcfw, cookie);
508502
else if (atomic_read(&rcfw->rcfw_intr_enabled))
509-
rc = __wait_for_resp(rcfw, cookie, opcode);
503+
rc = __wait_for_resp(rcfw, cookie);
510504
else
511-
rc = __poll_for_resp(rcfw, cookie, opcode);
505+
rc = __poll_for_resp(rcfw, cookie);
512506
if (rc) {
513507
/* timed out */
514508
dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x timedout (%d)msec\n",

0 commit comments

Comments
 (0)