forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c
....@@ -35,6 +35,9 @@
3535 *
3636 * Description: RDMA Controller HW interface
3737 */
38
+
39
+#define dev_fmt(fmt) "QPLIB: " fmt
40
+
3841 #include <linux/interrupt.h>
3942 #include <linux/spinlock.h>
4043 #include <linux/pci.h>
....@@ -47,17 +50,19 @@
4750 #include "qplib_sp.h"
4851 #include "qplib_fp.h"
4952
50
-static void bnxt_qplib_service_creq(unsigned long data);
53
+static void bnxt_qplib_service_creq(struct tasklet_struct *t);
5154
5255 /* Hardware communication channel */
5356 static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie)
5457 {
58
+ struct bnxt_qplib_cmdq_ctx *cmdq;
5559 u16 cbit;
5660 int rc;
5761
58
- cbit = cookie % RCFW_MAX_OUTSTANDING_CMD;
59
- rc = wait_event_timeout(rcfw->waitq,
60
- !test_bit(cbit, rcfw->cmdq_bitmap),
62
+ cmdq = &rcfw->cmdq;
63
+ cbit = cookie % rcfw->cmdq_depth;
64
+ rc = wait_event_timeout(cmdq->waitq,
65
+ !test_bit(cbit, cmdq->cmdq_bitmap),
6166 msecs_to_jiffies(RCFW_CMD_WAIT_TIME_MS));
6267 return rc ? 0 : -ETIMEDOUT;
6368 };
....@@ -65,15 +70,17 @@
6570 static int __block_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie)
6671 {
6772 u32 count = RCFW_BLOCKED_CMD_WAIT_COUNT;
73
+ struct bnxt_qplib_cmdq_ctx *cmdq;
6874 u16 cbit;
6975
70
- cbit = cookie % RCFW_MAX_OUTSTANDING_CMD;
71
- if (!test_bit(cbit, rcfw->cmdq_bitmap))
76
+ cmdq = &rcfw->cmdq;
77
+ cbit = cookie % rcfw->cmdq_depth;
78
+ if (!test_bit(cbit, cmdq->cmdq_bitmap))
7279 goto done;
7380 do {
7481 mdelay(1); /* 1m sec */
75
- bnxt_qplib_service_creq((unsigned long)rcfw);
76
- } while (test_bit(cbit, rcfw->cmdq_bitmap) && --count);
82
+ bnxt_qplib_service_creq(&rcfw->creq.creq_tasklet);
83
+ } while (test_bit(cbit, cmdq->cmdq_bitmap) && --count);
7784 done:
7885 return count ? 0 : -ETIMEDOUT;
7986 };
....@@ -81,58 +88,68 @@
8188 static int __send_message(struct bnxt_qplib_rcfw *rcfw, struct cmdq_base *req,
8289 struct creq_base *resp, void *sb, u8 is_block)
8390 {
84
- struct bnxt_qplib_cmdqe *cmdqe, **cmdq_ptr;
85
- struct bnxt_qplib_hwq *cmdq = &rcfw->cmdq;
86
- struct bnxt_qplib_crsq *crsqe;
91
+ struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq;
92
+ struct bnxt_qplib_hwq *hwq = &cmdq->hwq;
93
+ struct bnxt_qplib_crsqe *crsqe;
94
+ struct bnxt_qplib_cmdqe *cmdqe;
8795 u32 sw_prod, cmdq_prod;
96
+ struct pci_dev *pdev;
8897 unsigned long flags;
8998 u32 size, opcode;
9099 u16 cookie, cbit;
91100 u8 *preq;
92101
102
+ pdev = rcfw->pdev;
103
+
93104 opcode = req->opcode;
94
- if (!test_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags) &&
105
+ if (!test_bit(FIRMWARE_INITIALIZED_FLAG, &cmdq->flags) &&
95106 (opcode != CMDQ_BASE_OPCODE_QUERY_FUNC &&
96107 opcode != CMDQ_BASE_OPCODE_INITIALIZE_FW &&
97108 opcode != CMDQ_BASE_OPCODE_QUERY_VERSION)) {
98
- dev_err(&rcfw->pdev->dev,
99
- "QPLIB: RCFW not initialized, reject opcode 0x%x",
100
- opcode);
109
+ dev_err(&pdev->dev,
110
+ "RCFW not initialized, reject opcode 0x%x\n", opcode);
101111 return -EINVAL;
102112 }
103113
104
- if (test_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags) &&
114
+ if (test_bit(FIRMWARE_INITIALIZED_FLAG, &cmdq->flags) &&
105115 opcode == CMDQ_BASE_OPCODE_INITIALIZE_FW) {
106
- dev_err(&rcfw->pdev->dev, "QPLIB: RCFW already initialized!");
116
+ dev_err(&pdev->dev, "RCFW already initialized!\n");
107117 return -EINVAL;
108118 }
109119
110
- if (test_bit(FIRMWARE_TIMED_OUT, &rcfw->flags))
120
+ if (test_bit(FIRMWARE_TIMED_OUT, &cmdq->flags))
111121 return -ETIMEDOUT;
112122
113123 /* Cmdq are in 16-byte units, each request can consume 1 or more
114124 * cmdqe
115125 */
116
- spin_lock_irqsave(&cmdq->lock, flags);
117
- if (req->cmd_size >= HWQ_FREE_SLOTS(cmdq)) {
118
- dev_err(&rcfw->pdev->dev, "QPLIB: RCFW: CMDQ is full!");
119
- spin_unlock_irqrestore(&cmdq->lock, flags);
126
+ spin_lock_irqsave(&hwq->lock, flags);
127
+ if (req->cmd_size >= HWQ_FREE_SLOTS(hwq)) {
128
+ dev_err(&pdev->dev, "RCFW: CMDQ is full!\n");
129
+ spin_unlock_irqrestore(&hwq->lock, flags);
120130 return -EAGAIN;
121131 }
122132
123133
124
- cookie = rcfw->seq_num & RCFW_MAX_COOKIE_VALUE;
125
- cbit = cookie % RCFW_MAX_OUTSTANDING_CMD;
134
+ cookie = cmdq->seq_num & RCFW_MAX_COOKIE_VALUE;
135
+ cbit = cookie % rcfw->cmdq_depth;
126136 if (is_block)
127137 cookie |= RCFW_CMD_IS_BLOCKING;
128138
129
- set_bit(cbit, rcfw->cmdq_bitmap);
139
+ set_bit(cbit, cmdq->cmdq_bitmap);
130140 req->cookie = cpu_to_le16(cookie);
131141 crsqe = &rcfw->crsqe_tbl[cbit];
132142 if (crsqe->resp) {
133
- spin_unlock_irqrestore(&cmdq->lock, flags);
143
+ spin_unlock_irqrestore(&hwq->lock, flags);
134144 return -EBUSY;
135145 }
146
+
147
+ size = req->cmd_size;
148
+ /* change the cmd_size to the number of 16byte cmdq unit.
149
+ * req->cmd_size is modified here
150
+ */
151
+ bnxt_qplib_set_cmd_slots(req);
152
+
136153 memset(resp, 0, sizeof(*resp));
137154 crsqe->resp = (struct creq_qp_event *)resp;
138155 crsqe->resp->cookie = req->cookie;
....@@ -145,16 +162,14 @@
145162 BNXT_QPLIB_CMDQE_UNITS;
146163 }
147164
148
- cmdq_ptr = (struct bnxt_qplib_cmdqe **)cmdq->pbl_ptr;
149165 preq = (u8 *)req;
150
- size = req->cmd_size * BNXT_QPLIB_CMDQE_UNITS;
151166 do {
152167 /* Locate the next cmdq slot */
153
- sw_prod = HWQ_CMP(cmdq->prod, cmdq);
154
- cmdqe = &cmdq_ptr[get_cmdq_pg(sw_prod)][get_cmdq_idx(sw_prod)];
168
+ sw_prod = HWQ_CMP(hwq->prod, hwq);
169
+ cmdqe = bnxt_qplib_get_qe(hwq, sw_prod, NULL);
155170 if (!cmdqe) {
156
- dev_err(&rcfw->pdev->dev,
157
- "QPLIB: RCFW request failed with no cmdqe!");
171
+ dev_err(&pdev->dev,
172
+ "RCFW request failed with no cmdqe!\n");
158173 goto done;
159174 }
160175 /* Copy a segment of the req cmd to the cmdq */
....@@ -162,31 +177,27 @@
162177 memcpy(cmdqe, preq, min_t(u32, size, sizeof(*cmdqe)));
163178 preq += min_t(u32, size, sizeof(*cmdqe));
164179 size -= min_t(u32, size, sizeof(*cmdqe));
165
- cmdq->prod++;
166
- rcfw->seq_num++;
180
+ hwq->prod++;
167181 } while (size > 0);
182
+ cmdq->seq_num++;
168183
169
- rcfw->seq_num++;
170
-
171
- cmdq_prod = cmdq->prod;
172
- if (test_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags)) {
184
+ cmdq_prod = hwq->prod;
185
+ if (test_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags)) {
173186 /* The very first doorbell write
174187 * is required to set this flag
175188 * which prompts the FW to reset
176189 * its internal pointers
177190 */
178191 cmdq_prod |= BIT(FIRMWARE_FIRST_FLAG);
179
- clear_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags);
192
+ clear_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags);
180193 }
181194
182195 /* ring CMDQ DB */
183196 wmb();
184
- writel(cmdq_prod, rcfw->cmdq_bar_reg_iomem +
185
- rcfw->cmdq_bar_reg_prod_off);
186
- writel(RCFW_CMDQ_TRIG_VAL, rcfw->cmdq_bar_reg_iomem +
187
- rcfw->cmdq_bar_reg_trig_off);
197
+ writel(cmdq_prod, cmdq->cmdq_mbox.prod);
198
+ writel(RCFW_CMDQ_TRIG_VAL, cmdq->cmdq_mbox.db);
188199 done:
189
- spin_unlock_irqrestore(&cmdq->lock, flags);
200
+ spin_unlock_irqrestore(&hwq->lock, flags);
190201 /* Return the CREQ response pointer */
191202 return 0;
192203 }
....@@ -210,7 +221,7 @@
210221
211222 if (!retry_cnt || (rc != -EAGAIN && rc != -EBUSY)) {
212223 /* send failed */
213
- dev_err(&rcfw->pdev->dev, "QPLIB: cmdq[%#x]=%#x send failed",
224
+ dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x send failed\n",
214225 cookie, opcode);
215226 return rc;
216227 }
....@@ -224,15 +235,15 @@
224235 rc = __wait_for_resp(rcfw, cookie);
225236 if (rc) {
226237 /* timed out */
227
- dev_err(&rcfw->pdev->dev, "QPLIB: cmdq[%#x]=%#x timedout (%d)msec",
238
+ dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x timedout (%d)msec\n",
228239 cookie, opcode, RCFW_CMD_WAIT_TIME_MS);
229
- set_bit(FIRMWARE_TIMED_OUT, &rcfw->flags);
240
+ set_bit(FIRMWARE_TIMED_OUT, &rcfw->cmdq.flags);
230241 return rc;
231242 }
232243
233244 if (evnt->status) {
234245 /* failed with status */
235
- dev_err(&rcfw->pdev->dev, "QPLIB: cmdq[%#x]=%#x status %#x",
246
+ dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x status %#x\n",
236247 cookie, opcode, evnt->status);
237248 rc = -EFAULT;
238249 }
....@@ -243,6 +254,8 @@
243254 static int bnxt_qplib_process_func_event(struct bnxt_qplib_rcfw *rcfw,
244255 struct creq_func_event *func_event)
245256 {
257
+ int rc;
258
+
246259 switch (func_event->event) {
247260 case CREQ_FUNC_EVENT_EVENT_TX_WQE_ERROR:
248261 break;
....@@ -276,37 +289,42 @@
276289 default:
277290 return -EINVAL;
278291 }
279
- return 0;
292
+
293
+ rc = rcfw->creq.aeq_handler(rcfw, (void *)func_event, NULL);
294
+ return rc;
280295 }
281296
282297 static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw,
283298 struct creq_qp_event *qp_event)
284299 {
285
- struct bnxt_qplib_hwq *cmdq = &rcfw->cmdq;
286300 struct creq_qp_error_notification *err_event;
287
- struct bnxt_qplib_crsq *crsqe;
288
- unsigned long flags;
301
+ struct bnxt_qplib_hwq *hwq = &rcfw->cmdq.hwq;
302
+ struct bnxt_qplib_crsqe *crsqe;
289303 struct bnxt_qplib_qp *qp;
290304 u16 cbit, blocked = 0;
291
- u16 cookie;
305
+ struct pci_dev *pdev;
306
+ unsigned long flags;
292307 __le16 mcookie;
293
- u32 qp_id;
308
+ u16 cookie;
309
+ int rc = 0;
310
+ u32 qp_id, tbl_indx;
294311
312
+ pdev = rcfw->pdev;
295313 switch (qp_event->event) {
296314 case CREQ_QP_EVENT_EVENT_QP_ERROR_NOTIFICATION:
297315 err_event = (struct creq_qp_error_notification *)qp_event;
298316 qp_id = le32_to_cpu(err_event->xid);
299
- qp = rcfw->qp_tbl[qp_id].qp_handle;
300
- dev_dbg(&rcfw->pdev->dev,
301
- "QPLIB: Received QP error notification");
302
- dev_dbg(&rcfw->pdev->dev,
303
- "QPLIB: qpid 0x%x, req_err=0x%x, resp_err=0x%x\n",
317
+ tbl_indx = map_qp_id_to_tbl_indx(qp_id, rcfw);
318
+ qp = rcfw->qp_tbl[tbl_indx].qp_handle;
319
+ dev_dbg(&pdev->dev, "Received QP error notification\n");
320
+ dev_dbg(&pdev->dev,
321
+ "qpid 0x%x, req_err=0x%x, resp_err=0x%x\n",
304322 qp_id, err_event->req_err_state_reason,
305323 err_event->res_err_state_reason);
306324 if (!qp)
307325 break;
308326 bnxt_qplib_mark_qp_error(qp);
309
- rcfw->aeq_handler(rcfw, qp_event, qp);
327
+ rc = rcfw->creq.aeq_handler(rcfw, qp_event, qp);
310328 break;
311329 default:
312330 /*
....@@ -318,55 +336,57 @@
318336 *
319337 */
320338
321
- spin_lock_irqsave_nested(&cmdq->lock, flags,
339
+ spin_lock_irqsave_nested(&hwq->lock, flags,
322340 SINGLE_DEPTH_NESTING);
323341 cookie = le16_to_cpu(qp_event->cookie);
324342 mcookie = qp_event->cookie;
325343 blocked = cookie & RCFW_CMD_IS_BLOCKING;
326344 cookie &= RCFW_MAX_COOKIE_VALUE;
327
- cbit = cookie % RCFW_MAX_OUTSTANDING_CMD;
345
+ cbit = cookie % rcfw->cmdq_depth;
328346 crsqe = &rcfw->crsqe_tbl[cbit];
329347 if (crsqe->resp &&
330348 crsqe->resp->cookie == mcookie) {
331349 memcpy(crsqe->resp, qp_event, sizeof(*qp_event));
332350 crsqe->resp = NULL;
333351 } else {
334
- dev_err(&rcfw->pdev->dev,
335
- "QPLIB: CMD %s resp->cookie = %#x, evnt->cookie = %#x",
336
- crsqe->resp ? "mismatch" : "collision",
337
- crsqe->resp ? crsqe->resp->cookie : 0, mcookie);
352
+ if (crsqe->resp && crsqe->resp->cookie)
353
+ dev_err(&pdev->dev,
354
+ "CMD %s cookie sent=%#x, recd=%#x\n",
355
+ crsqe->resp ? "mismatch" : "collision",
356
+ crsqe->resp ? crsqe->resp->cookie : 0,
357
+ mcookie);
338358 }
339
- if (!test_and_clear_bit(cbit, rcfw->cmdq_bitmap))
340
- dev_warn(&rcfw->pdev->dev,
341
- "QPLIB: CMD bit %d was not requested", cbit);
342
- cmdq->cons += crsqe->req_size;
359
+ if (!test_and_clear_bit(cbit, rcfw->cmdq.cmdq_bitmap))
360
+ dev_warn(&pdev->dev,
361
+ "CMD bit %d was not requested\n", cbit);
362
+ hwq->cons += crsqe->req_size;
343363 crsqe->req_size = 0;
344364
345365 if (!blocked)
346
- wake_up(&rcfw->waitq);
347
- spin_unlock_irqrestore(&cmdq->lock, flags);
366
+ wake_up(&rcfw->cmdq.waitq);
367
+ spin_unlock_irqrestore(&hwq->lock, flags);
348368 }
349
- return 0;
369
+ return rc;
350370 }
351371
352372 /* SP - CREQ Completion handlers */
353
-static void bnxt_qplib_service_creq(unsigned long data)
373
+static void bnxt_qplib_service_creq(struct tasklet_struct *t)
354374 {
355
- struct bnxt_qplib_rcfw *rcfw = (struct bnxt_qplib_rcfw *)data;
356
- struct bnxt_qplib_hwq *creq = &rcfw->creq;
357
- struct creq_base *creqe, **creq_ptr;
375
+ struct bnxt_qplib_rcfw *rcfw = from_tasklet(rcfw, t, creq.creq_tasklet);
376
+ struct bnxt_qplib_creq_ctx *creq = &rcfw->creq;
377
+ u32 type, budget = CREQ_ENTRY_POLL_BUDGET;
378
+ struct bnxt_qplib_hwq *hwq = &creq->hwq;
379
+ struct creq_base *creqe;
358380 u32 sw_cons, raw_cons;
359381 unsigned long flags;
360
- u32 type, budget = CREQ_ENTRY_POLL_BUDGET;
361382
362383 /* Service the CREQ until budget is over */
363
- spin_lock_irqsave(&creq->lock, flags);
364
- raw_cons = creq->cons;
384
+ spin_lock_irqsave(&hwq->lock, flags);
385
+ raw_cons = hwq->cons;
365386 while (budget > 0) {
366
- sw_cons = HWQ_CMP(raw_cons, creq);
367
- creq_ptr = (struct creq_base **)creq->pbl_ptr;
368
- creqe = &creq_ptr[get_creq_pg(sw_cons)][get_creq_idx(sw_cons)];
369
- if (!CREQ_CMP_VALID(creqe, raw_cons, creq->max_elements))
387
+ sw_cons = HWQ_CMP(raw_cons, hwq);
388
+ creqe = bnxt_qplib_get_qe(hwq, sw_cons, NULL);
389
+ if (!CREQ_CMP_VALID(creqe, raw_cons, hwq->max_elements))
370390 break;
371391 /* The valid test of the entry must be done first before
372392 * reading any further.
....@@ -378,48 +398,49 @@
378398 case CREQ_BASE_TYPE_QP_EVENT:
379399 bnxt_qplib_process_qp_event
380400 (rcfw, (struct creq_qp_event *)creqe);
381
- rcfw->creq_qp_event_processed++;
401
+ creq->stats.creq_qp_event_processed++;
382402 break;
383403 case CREQ_BASE_TYPE_FUNC_EVENT:
384404 if (!bnxt_qplib_process_func_event
385405 (rcfw, (struct creq_func_event *)creqe))
386
- rcfw->creq_func_event_processed++;
406
+ creq->stats.creq_func_event_processed++;
387407 else
388
- dev_warn
389
- (&rcfw->pdev->dev, "QPLIB:aeqe:%#x Not handled",
390
- type);
408
+ dev_warn(&rcfw->pdev->dev,
409
+ "aeqe:%#x Not handled\n", type);
391410 break;
392411 default:
393
- dev_warn(&rcfw->pdev->dev, "QPLIB: creqe with ");
394
- dev_warn(&rcfw->pdev->dev,
395
- "QPLIB: op_event = 0x%x not handled", type);
412
+ if (type != ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT)
413
+ dev_warn(&rcfw->pdev->dev,
414
+ "creqe with event 0x%x not handled\n",
415
+ type);
396416 break;
397417 }
398418 raw_cons++;
399419 budget--;
400420 }
401421
402
- if (creq->cons != raw_cons) {
403
- creq->cons = raw_cons;
404
- CREQ_DB_REARM(rcfw->creq_bar_reg_iomem, raw_cons,
405
- creq->max_elements);
422
+ if (hwq->cons != raw_cons) {
423
+ hwq->cons = raw_cons;
424
+ bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo,
425
+ rcfw->res->cctx, true);
406426 }
407
- spin_unlock_irqrestore(&creq->lock, flags);
427
+ spin_unlock_irqrestore(&hwq->lock, flags);
408428 }
409429
410430 static irqreturn_t bnxt_qplib_creq_irq(int irq, void *dev_instance)
411431 {
412432 struct bnxt_qplib_rcfw *rcfw = dev_instance;
413
- struct bnxt_qplib_hwq *creq = &rcfw->creq;
414
- struct creq_base **creq_ptr;
433
+ struct bnxt_qplib_creq_ctx *creq;
434
+ struct bnxt_qplib_hwq *hwq;
415435 u32 sw_cons;
416436
437
+ creq = &rcfw->creq;
438
+ hwq = &creq->hwq;
417439 /* Prefetch the CREQ element */
418
- sw_cons = HWQ_CMP(creq->cons, creq);
419
- creq_ptr = (struct creq_base **)rcfw->creq.pbl_ptr;
420
- prefetch(&creq_ptr[get_creq_pg(sw_cons)][get_creq_idx(sw_cons)]);
440
+ sw_cons = HWQ_CMP(hwq->cons, hwq);
441
+ prefetch(bnxt_qplib_get_qe(hwq, sw_cons, NULL));
421442
422
- tasklet_schedule(&rcfw->worker);
443
+ tasklet_schedule(&creq->creq_tasklet);
423444
424445 return IRQ_HANDLED;
425446 }
....@@ -438,33 +459,17 @@
438459 if (rc)
439460 return rc;
440461
441
- clear_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags);
462
+ clear_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->cmdq.flags);
442463 return 0;
443
-}
444
-
445
-static int __get_pbl_pg_idx(struct bnxt_qplib_pbl *pbl)
446
-{
447
- return (pbl->pg_size == ROCE_PG_SIZE_4K ?
448
- CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_4K :
449
- pbl->pg_size == ROCE_PG_SIZE_8K ?
450
- CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_8K :
451
- pbl->pg_size == ROCE_PG_SIZE_64K ?
452
- CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_64K :
453
- pbl->pg_size == ROCE_PG_SIZE_2M ?
454
- CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_2M :
455
- pbl->pg_size == ROCE_PG_SIZE_8M ?
456
- CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_8M :
457
- pbl->pg_size == ROCE_PG_SIZE_1G ?
458
- CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_1G :
459
- CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_4K);
460464 }
461465
462466 int bnxt_qplib_init_rcfw(struct bnxt_qplib_rcfw *rcfw,
463467 struct bnxt_qplib_ctx *ctx, int is_virtfn)
464468 {
465
- struct cmdq_initialize_fw req;
466469 struct creq_initialize_fw_resp resp;
467
- u16 cmd_flags = 0, level;
470
+ struct cmdq_initialize_fw req;
471
+ u16 cmd_flags = 0;
472
+ u8 pgsz, lvl;
468473 int rc;
469474
470475 RCFW_CMD_PREP(req, INITIALIZE_FW, cmd_flags);
....@@ -474,38 +479,41 @@
474479 req.log2_dbr_pg_size = cpu_to_le16(PAGE_SHIFT -
475480 RCFW_DBR_BASE_PAGE_SHIFT);
476481 /*
477
- * VFs need not setup the HW context area, PF
482
+ * Gen P5 devices doesn't require this allocation
483
+ * as the L2 driver does the same for RoCE also.
484
+ * Also, VFs need not setup the HW context area, PF
478485 * shall setup this area for VF. Skipping the
479486 * HW programming
480487 */
481488 if (is_virtfn)
482489 goto skip_ctx_setup;
490
+ if (bnxt_qplib_is_chip_gen_p5(rcfw->res->cctx))
491
+ goto config_vf_res;
483492
484
- level = ctx->qpc_tbl.level;
485
- req.qpc_pg_size_qpc_lvl = (level << CMDQ_INITIALIZE_FW_QPC_LVL_SFT) |
486
- __get_pbl_pg_idx(&ctx->qpc_tbl.pbl[level]);
487
- level = ctx->mrw_tbl.level;
488
- req.mrw_pg_size_mrw_lvl = (level << CMDQ_INITIALIZE_FW_MRW_LVL_SFT) |
489
- __get_pbl_pg_idx(&ctx->mrw_tbl.pbl[level]);
490
- level = ctx->srqc_tbl.level;
491
- req.srq_pg_size_srq_lvl = (level << CMDQ_INITIALIZE_FW_SRQ_LVL_SFT) |
492
- __get_pbl_pg_idx(&ctx->srqc_tbl.pbl[level]);
493
- level = ctx->cq_tbl.level;
494
- req.cq_pg_size_cq_lvl = (level << CMDQ_INITIALIZE_FW_CQ_LVL_SFT) |
495
- __get_pbl_pg_idx(&ctx->cq_tbl.pbl[level]);
496
- level = ctx->srqc_tbl.level;
497
- req.srq_pg_size_srq_lvl = (level << CMDQ_INITIALIZE_FW_SRQ_LVL_SFT) |
498
- __get_pbl_pg_idx(&ctx->srqc_tbl.pbl[level]);
499
- level = ctx->cq_tbl.level;
500
- req.cq_pg_size_cq_lvl = (level << CMDQ_INITIALIZE_FW_CQ_LVL_SFT) |
501
- __get_pbl_pg_idx(&ctx->cq_tbl.pbl[level]);
502
- level = ctx->tim_tbl.level;
503
- req.tim_pg_size_tim_lvl = (level << CMDQ_INITIALIZE_FW_TIM_LVL_SFT) |
504
- __get_pbl_pg_idx(&ctx->tim_tbl.pbl[level]);
505
- level = ctx->tqm_pde_level;
506
- req.tqm_pg_size_tqm_lvl = (level << CMDQ_INITIALIZE_FW_TQM_LVL_SFT) |
507
- __get_pbl_pg_idx(&ctx->tqm_pde.pbl[level]);
508
-
493
+ lvl = ctx->qpc_tbl.level;
494
+ pgsz = bnxt_qplib_base_pg_size(&ctx->qpc_tbl);
495
+ req.qpc_pg_size_qpc_lvl = (pgsz << CMDQ_INITIALIZE_FW_QPC_PG_SIZE_SFT) |
496
+ lvl;
497
+ lvl = ctx->mrw_tbl.level;
498
+ pgsz = bnxt_qplib_base_pg_size(&ctx->mrw_tbl);
499
+ req.mrw_pg_size_mrw_lvl = (pgsz << CMDQ_INITIALIZE_FW_QPC_PG_SIZE_SFT) |
500
+ lvl;
501
+ lvl = ctx->srqc_tbl.level;
502
+ pgsz = bnxt_qplib_base_pg_size(&ctx->srqc_tbl);
503
+ req.srq_pg_size_srq_lvl = (pgsz << CMDQ_INITIALIZE_FW_QPC_PG_SIZE_SFT) |
504
+ lvl;
505
+ lvl = ctx->cq_tbl.level;
506
+ pgsz = bnxt_qplib_base_pg_size(&ctx->cq_tbl);
507
+ req.cq_pg_size_cq_lvl = (pgsz << CMDQ_INITIALIZE_FW_QPC_PG_SIZE_SFT) |
508
+ lvl;
509
+ lvl = ctx->tim_tbl.level;
510
+ pgsz = bnxt_qplib_base_pg_size(&ctx->tim_tbl);
511
+ req.tim_pg_size_tim_lvl = (pgsz << CMDQ_INITIALIZE_FW_QPC_PG_SIZE_SFT) |
512
+ lvl;
513
+ lvl = ctx->tqm_ctx.pde.level;
514
+ pgsz = bnxt_qplib_base_pg_size(&ctx->tqm_ctx.pde);
515
+ req.tqm_pg_size_tqm_lvl = (pgsz << CMDQ_INITIALIZE_FW_QPC_PG_SIZE_SFT) |
516
+ lvl;
509517 req.qpc_page_dir =
510518 cpu_to_le64(ctx->qpc_tbl.pbl[PBL_LVL_0].pg_map_arr[0]);
511519 req.mrw_page_dir =
....@@ -517,13 +525,14 @@
517525 req.tim_page_dir =
518526 cpu_to_le64(ctx->tim_tbl.pbl[PBL_LVL_0].pg_map_arr[0]);
519527 req.tqm_page_dir =
520
- cpu_to_le64(ctx->tqm_pde.pbl[PBL_LVL_0].pg_map_arr[0]);
528
+ cpu_to_le64(ctx->tqm_ctx.pde.pbl[PBL_LVL_0].pg_map_arr[0]);
521529
522530 req.number_of_qp = cpu_to_le32(ctx->qpc_tbl.max_elements);
523531 req.number_of_mrw = cpu_to_le32(ctx->mrw_tbl.max_elements);
524532 req.number_of_srq = cpu_to_le32(ctx->srqc_tbl.max_elements);
525533 req.number_of_cq = cpu_to_le32(ctx->cq_tbl.max_elements);
526534
535
+config_vf_res:
527536 req.max_qp_per_vf = cpu_to_le32(ctx->vf_res.max_qp_per_vf);
528537 req.max_mrw_per_vf = cpu_to_le32(ctx->vf_res.max_mrw_per_vf);
529538 req.max_srq_per_vf = cpu_to_le32(ctx->vf_res.max_srq_per_vf);
....@@ -536,50 +545,78 @@
536545 NULL, 0);
537546 if (rc)
538547 return rc;
539
- set_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags);
548
+ set_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->cmdq.flags);
540549 return 0;
541550 }
542551
543552 void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_rcfw *rcfw)
544553 {
554
+ kfree(rcfw->cmdq.cmdq_bitmap);
545555 kfree(rcfw->qp_tbl);
546556 kfree(rcfw->crsqe_tbl);
547
- bnxt_qplib_free_hwq(rcfw->pdev, &rcfw->cmdq);
548
- bnxt_qplib_free_hwq(rcfw->pdev, &rcfw->creq);
557
+ bnxt_qplib_free_hwq(rcfw->res, &rcfw->cmdq.hwq);
558
+ bnxt_qplib_free_hwq(rcfw->res, &rcfw->creq.hwq);
549559 rcfw->pdev = NULL;
550560 }
551561
552
-int bnxt_qplib_alloc_rcfw_channel(struct pci_dev *pdev,
562
+int bnxt_qplib_alloc_rcfw_channel(struct bnxt_qplib_res *res,
553563 struct bnxt_qplib_rcfw *rcfw,
564
+ struct bnxt_qplib_ctx *ctx,
554565 int qp_tbl_sz)
555566 {
556
- rcfw->pdev = pdev;
557
- rcfw->creq.max_elements = BNXT_QPLIB_CREQE_MAX_CNT;
558
- if (bnxt_qplib_alloc_init_hwq(rcfw->pdev, &rcfw->creq, NULL, 0,
559
- &rcfw->creq.max_elements,
560
- BNXT_QPLIB_CREQE_UNITS, 0, PAGE_SIZE,
561
- HWQ_TYPE_L2_CMPL)) {
567
+ struct bnxt_qplib_hwq_attr hwq_attr = {};
568
+ struct bnxt_qplib_sg_info sginfo = {};
569
+ struct bnxt_qplib_cmdq_ctx *cmdq;
570
+ struct bnxt_qplib_creq_ctx *creq;
571
+ u32 bmap_size = 0;
572
+
573
+ rcfw->pdev = res->pdev;
574
+ cmdq = &rcfw->cmdq;
575
+ creq = &rcfw->creq;
576
+ rcfw->res = res;
577
+
578
+ sginfo.pgsize = PAGE_SIZE;
579
+ sginfo.pgshft = PAGE_SHIFT;
580
+
581
+ hwq_attr.sginfo = &sginfo;
582
+ hwq_attr.res = rcfw->res;
583
+ hwq_attr.depth = BNXT_QPLIB_CREQE_MAX_CNT;
584
+ hwq_attr.stride = BNXT_QPLIB_CREQE_UNITS;
585
+ hwq_attr.type = bnxt_qplib_get_hwq_type(res);
586
+
587
+ if (bnxt_qplib_alloc_init_hwq(&creq->hwq, &hwq_attr)) {
562588 dev_err(&rcfw->pdev->dev,
563
- "QPLIB: HW channel CREQ allocation failed");
589
+ "HW channel CREQ allocation failed\n");
564590 goto fail;
565591 }
566
- rcfw->cmdq.max_elements = BNXT_QPLIB_CMDQE_MAX_CNT;
567
- if (bnxt_qplib_alloc_init_hwq(rcfw->pdev, &rcfw->cmdq, NULL, 0,
568
- &rcfw->cmdq.max_elements,
569
- BNXT_QPLIB_CMDQE_UNITS, 0, PAGE_SIZE,
570
- HWQ_TYPE_CTX)) {
592
+ if (ctx->hwrm_intf_ver < HWRM_VERSION_RCFW_CMDQ_DEPTH_CHECK)
593
+ rcfw->cmdq_depth = BNXT_QPLIB_CMDQE_MAX_CNT_256;
594
+ else
595
+ rcfw->cmdq_depth = BNXT_QPLIB_CMDQE_MAX_CNT_8192;
596
+
597
+ sginfo.pgsize = bnxt_qplib_cmdqe_page_size(rcfw->cmdq_depth);
598
+ hwq_attr.depth = rcfw->cmdq_depth;
599
+ hwq_attr.stride = BNXT_QPLIB_CMDQE_UNITS;
600
+ hwq_attr.type = HWQ_TYPE_CTX;
601
+ if (bnxt_qplib_alloc_init_hwq(&cmdq->hwq, &hwq_attr)) {
571602 dev_err(&rcfw->pdev->dev,
572
- "QPLIB: HW channel CMDQ allocation failed");
603
+ "HW channel CMDQ allocation failed\n");
573604 goto fail;
574605 }
575606
576
- rcfw->crsqe_tbl = kcalloc(rcfw->cmdq.max_elements,
607
+ rcfw->crsqe_tbl = kcalloc(cmdq->hwq.max_elements,
577608 sizeof(*rcfw->crsqe_tbl), GFP_KERNEL);
578609 if (!rcfw->crsqe_tbl)
579610 goto fail;
580611
581
- rcfw->qp_tbl_size = qp_tbl_sz;
582
- rcfw->qp_tbl = kcalloc(qp_tbl_sz, sizeof(struct bnxt_qplib_qp_node),
612
+ bmap_size = BITS_TO_LONGS(rcfw->cmdq_depth) * sizeof(unsigned long);
613
+ cmdq->cmdq_bitmap = kzalloc(bmap_size, GFP_KERNEL);
614
+ if (!cmdq->cmdq_bitmap)
615
+ goto fail;
616
+
617
+ /* Allocate one extra to hold the QP1 entries */
618
+ rcfw->qp_tbl_size = qp_tbl_sz + 1;
619
+ rcfw->qp_tbl = kcalloc(rcfw->qp_tbl_size, sizeof(struct bnxt_qplib_qp_node),
583620 GFP_KERNEL);
584621 if (!rcfw->qp_tbl)
585622 goto fail;
....@@ -593,153 +630,209 @@
593630
594631 void bnxt_qplib_rcfw_stop_irq(struct bnxt_qplib_rcfw *rcfw, bool kill)
595632 {
596
- tasklet_disable(&rcfw->worker);
597
- /* Mask h/w interrupts */
598
- CREQ_DB(rcfw->creq_bar_reg_iomem, rcfw->creq.cons,
599
- rcfw->creq.max_elements);
600
- /* Sync with last running IRQ-handler */
601
- synchronize_irq(rcfw->vector);
602
- if (kill)
603
- tasklet_kill(&rcfw->worker);
633
+ struct bnxt_qplib_creq_ctx *creq;
604634
605
- if (rcfw->requested) {
606
- free_irq(rcfw->vector, rcfw);
607
- rcfw->requested = false;
635
+ creq = &rcfw->creq;
636
+ tasklet_disable(&creq->creq_tasklet);
637
+ /* Mask h/w interrupts */
638
+ bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, rcfw->res->cctx, false);
639
+ /* Sync with last running IRQ-handler */
640
+ synchronize_irq(creq->msix_vec);
641
+ if (kill)
642
+ tasklet_kill(&creq->creq_tasklet);
643
+
644
+ if (creq->requested) {
645
+ free_irq(creq->msix_vec, rcfw);
646
+ creq->requested = false;
608647 }
609648 }
610649
611650 void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw)
612651 {
652
+ struct bnxt_qplib_creq_ctx *creq;
653
+ struct bnxt_qplib_cmdq_ctx *cmdq;
613654 unsigned long indx;
614655
656
+ creq = &rcfw->creq;
657
+ cmdq = &rcfw->cmdq;
658
+ /* Make sure the HW channel is stopped! */
615659 bnxt_qplib_rcfw_stop_irq(rcfw, true);
616660
617
- iounmap(rcfw->cmdq_bar_reg_iomem);
618
- iounmap(rcfw->creq_bar_reg_iomem);
661
+ iounmap(cmdq->cmdq_mbox.reg.bar_reg);
662
+ iounmap(creq->creq_db.reg.bar_reg);
619663
620
- indx = find_first_bit(rcfw->cmdq_bitmap, rcfw->bmap_size);
621
- if (indx != rcfw->bmap_size)
664
+ indx = find_first_bit(cmdq->cmdq_bitmap, rcfw->cmdq_depth);
665
+ if (indx != rcfw->cmdq_depth)
622666 dev_err(&rcfw->pdev->dev,
623
- "QPLIB: disabling RCFW with pending cmd-bit %lx", indx);
624
- kfree(rcfw->cmdq_bitmap);
625
- rcfw->bmap_size = 0;
667
+ "disabling RCFW with pending cmd-bit %lx\n", indx);
626668
627
- rcfw->cmdq_bar_reg_iomem = NULL;
628
- rcfw->creq_bar_reg_iomem = NULL;
629
- rcfw->aeq_handler = NULL;
630
- rcfw->vector = 0;
669
+ cmdq->cmdq_mbox.reg.bar_reg = NULL;
670
+ creq->creq_db.reg.bar_reg = NULL;
671
+ creq->aeq_handler = NULL;
672
+ creq->msix_vec = 0;
631673 }
632674
633675 int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector,
634676 bool need_init)
635677 {
678
+ struct bnxt_qplib_creq_ctx *creq;
636679 int rc;
637680
638
- if (rcfw->requested)
681
+ creq = &rcfw->creq;
682
+
683
+ if (creq->requested)
639684 return -EFAULT;
640685
641
- rcfw->vector = msix_vector;
686
+ creq->msix_vec = msix_vector;
642687 if (need_init)
643
- tasklet_init(&rcfw->worker,
644
- bnxt_qplib_service_creq, (unsigned long)rcfw);
688
+ tasklet_setup(&creq->creq_tasklet, bnxt_qplib_service_creq);
645689 else
646
- tasklet_enable(&rcfw->worker);
647
- rc = request_irq(rcfw->vector, bnxt_qplib_creq_irq, 0,
690
+ tasklet_enable(&creq->creq_tasklet);
691
+ rc = request_irq(creq->msix_vec, bnxt_qplib_creq_irq, 0,
648692 "bnxt_qplib_creq", rcfw);
649693 if (rc)
650694 return rc;
651
- rcfw->requested = true;
652
- CREQ_DB_REARM(rcfw->creq_bar_reg_iomem, rcfw->creq.cons,
653
- rcfw->creq.max_elements);
695
+ creq->requested = true;
696
+
697
+ bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, rcfw->res->cctx, true);
654698
655699 return 0;
656700 }
657701
658
-int bnxt_qplib_enable_rcfw_channel(struct pci_dev *pdev,
659
- struct bnxt_qplib_rcfw *rcfw,
702
+static int bnxt_qplib_map_cmdq_mbox(struct bnxt_qplib_rcfw *rcfw, bool is_vf)
703
+{
704
+ struct bnxt_qplib_cmdq_mbox *mbox;
705
+ resource_size_t bar_reg;
706
+ struct pci_dev *pdev;
707
+ u16 prod_offt;
708
+ int rc = 0;
709
+
710
+ pdev = rcfw->pdev;
711
+ mbox = &rcfw->cmdq.cmdq_mbox;
712
+
713
+ mbox->reg.bar_id = RCFW_COMM_PCI_BAR_REGION;
714
+ mbox->reg.len = RCFW_COMM_SIZE;
715
+ mbox->reg.bar_base = pci_resource_start(pdev, mbox->reg.bar_id);
716
+ if (!mbox->reg.bar_base) {
717
+ dev_err(&pdev->dev,
718
+ "QPLIB: CMDQ BAR region %d resc start is 0!\n",
719
+ mbox->reg.bar_id);
720
+ return -ENOMEM;
721
+ }
722
+
723
+ bar_reg = mbox->reg.bar_base + RCFW_COMM_BASE_OFFSET;
724
+ mbox->reg.len = RCFW_COMM_SIZE;
725
+ mbox->reg.bar_reg = ioremap(bar_reg, mbox->reg.len);
726
+ if (!mbox->reg.bar_reg) {
727
+ dev_err(&pdev->dev,
728
+ "QPLIB: CMDQ BAR region %d mapping failed\n",
729
+ mbox->reg.bar_id);
730
+ return -ENOMEM;
731
+ }
732
+
733
+ prod_offt = is_vf ? RCFW_VF_COMM_PROD_OFFSET :
734
+ RCFW_PF_COMM_PROD_OFFSET;
735
+ mbox->prod = (void __iomem *)(mbox->reg.bar_reg + prod_offt);
736
+ mbox->db = (void __iomem *)(mbox->reg.bar_reg + RCFW_COMM_TRIG_OFFSET);
737
+ return rc;
738
+}
739
+
740
+static int bnxt_qplib_map_creq_db(struct bnxt_qplib_rcfw *rcfw, u32 reg_offt)
741
+{
742
+ struct bnxt_qplib_creq_db *creq_db;
743
+ resource_size_t bar_reg;
744
+ struct pci_dev *pdev;
745
+
746
+ pdev = rcfw->pdev;
747
+ creq_db = &rcfw->creq.creq_db;
748
+
749
+ creq_db->reg.bar_id = RCFW_COMM_CONS_PCI_BAR_REGION;
750
+ creq_db->reg.bar_base = pci_resource_start(pdev, creq_db->reg.bar_id);
751
+ if (!creq_db->reg.bar_id)
752
+ dev_err(&pdev->dev,
753
+ "QPLIB: CREQ BAR region %d resc start is 0!",
754
+ creq_db->reg.bar_id);
755
+
756
+ bar_reg = creq_db->reg.bar_base + reg_offt;
757
+ /* Unconditionally map 8 bytes to support 57500 series */
758
+ creq_db->reg.len = 8;
759
+ creq_db->reg.bar_reg = ioremap(bar_reg, creq_db->reg.len);
760
+ if (!creq_db->reg.bar_reg) {
761
+ dev_err(&pdev->dev,
762
+ "QPLIB: CREQ BAR region %d mapping failed",
763
+ creq_db->reg.bar_id);
764
+ return -ENOMEM;
765
+ }
766
+ creq_db->dbinfo.db = creq_db->reg.bar_reg;
767
+ creq_db->dbinfo.hwq = &rcfw->creq.hwq;
768
+ creq_db->dbinfo.xid = rcfw->creq.ring_id;
769
+ return 0;
770
+}
771
+
772
+static void bnxt_qplib_start_rcfw(struct bnxt_qplib_rcfw *rcfw)
773
+{
774
+ struct bnxt_qplib_cmdq_ctx *cmdq;
775
+ struct bnxt_qplib_creq_ctx *creq;
776
+ struct bnxt_qplib_cmdq_mbox *mbox;
777
+ struct cmdq_init init = {0};
778
+
779
+ cmdq = &rcfw->cmdq;
780
+ creq = &rcfw->creq;
781
+ mbox = &cmdq->cmdq_mbox;
782
+
783
+ init.cmdq_pbl = cpu_to_le64(cmdq->hwq.pbl[PBL_LVL_0].pg_map_arr[0]);
784
+ init.cmdq_size_cmdq_lvl =
785
+ cpu_to_le16(((rcfw->cmdq_depth <<
786
+ CMDQ_INIT_CMDQ_SIZE_SFT) &
787
+ CMDQ_INIT_CMDQ_SIZE_MASK) |
788
+ ((cmdq->hwq.level <<
789
+ CMDQ_INIT_CMDQ_LVL_SFT) &
790
+ CMDQ_INIT_CMDQ_LVL_MASK));
791
+ init.creq_ring_id = cpu_to_le16(creq->ring_id);
792
+ /* Write to the Bono mailbox register */
793
+ __iowrite32_copy(mbox->reg.bar_reg, &init, sizeof(init) / 4);
794
+}
795
+
796
+int bnxt_qplib_enable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw,
660797 int msix_vector,
661798 int cp_bar_reg_off, int virt_fn,
662
- int (*aeq_handler)(struct bnxt_qplib_rcfw *,
663
- void *, void *))
799
+ aeq_handler_t aeq_handler)
664800 {
665
- resource_size_t res_base;
666
- struct cmdq_init init;
667
- u16 bmap_size;
801
+ struct bnxt_qplib_cmdq_ctx *cmdq;
802
+ struct bnxt_qplib_creq_ctx *creq;
668803 int rc;
669804
670
- /* General */
671
- rcfw->seq_num = 0;
672
- set_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags);
673
- bmap_size = BITS_TO_LONGS(RCFW_MAX_OUTSTANDING_CMD *
674
- sizeof(unsigned long));
675
- rcfw->cmdq_bitmap = kzalloc(bmap_size, GFP_KERNEL);
676
- if (!rcfw->cmdq_bitmap)
677
- return -ENOMEM;
678
- rcfw->bmap_size = bmap_size;
805
+ cmdq = &rcfw->cmdq;
806
+ creq = &rcfw->creq;
679807
680
- /* CMDQ */
681
- rcfw->cmdq_bar_reg = RCFW_COMM_PCI_BAR_REGION;
682
- res_base = pci_resource_start(pdev, rcfw->cmdq_bar_reg);
683
- if (!res_base)
684
- return -ENOMEM;
808
+ /* Clear to defaults */
685809
686
- rcfw->cmdq_bar_reg_iomem = ioremap_nocache(res_base +
687
- RCFW_COMM_BASE_OFFSET,
688
- RCFW_COMM_SIZE);
689
- if (!rcfw->cmdq_bar_reg_iomem) {
690
- dev_err(&rcfw->pdev->dev,
691
- "QPLIB: CMDQ BAR region %d mapping failed",
692
- rcfw->cmdq_bar_reg);
693
- return -ENOMEM;
694
- }
810
+ cmdq->seq_num = 0;
811
+ set_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags);
812
+ init_waitqueue_head(&cmdq->waitq);
695813
696
- rcfw->cmdq_bar_reg_prod_off = virt_fn ? RCFW_VF_COMM_PROD_OFFSET :
697
- RCFW_PF_COMM_PROD_OFFSET;
814
+ creq->stats.creq_qp_event_processed = 0;
815
+ creq->stats.creq_func_event_processed = 0;
816
+ creq->aeq_handler = aeq_handler;
698817
699
- rcfw->cmdq_bar_reg_trig_off = RCFW_COMM_TRIG_OFFSET;
818
+ rc = bnxt_qplib_map_cmdq_mbox(rcfw, virt_fn);
819
+ if (rc)
820
+ return rc;
700821
701
- /* CREQ */
702
- rcfw->creq_bar_reg = RCFW_COMM_CONS_PCI_BAR_REGION;
703
- res_base = pci_resource_start(pdev, rcfw->creq_bar_reg);
704
- if (!res_base)
705
- dev_err(&rcfw->pdev->dev,
706
- "QPLIB: CREQ BAR region %d resc start is 0!",
707
- rcfw->creq_bar_reg);
708
- rcfw->creq_bar_reg_iomem = ioremap_nocache(res_base + cp_bar_reg_off,
709
- 4);
710
- if (!rcfw->creq_bar_reg_iomem) {
711
- dev_err(&rcfw->pdev->dev,
712
- "QPLIB: CREQ BAR region %d mapping failed",
713
- rcfw->creq_bar_reg);
714
- iounmap(rcfw->cmdq_bar_reg_iomem);
715
- rcfw->cmdq_bar_reg_iomem = NULL;
716
- return -ENOMEM;
717
- }
718
- rcfw->creq_qp_event_processed = 0;
719
- rcfw->creq_func_event_processed = 0;
720
-
721
- if (aeq_handler)
722
- rcfw->aeq_handler = aeq_handler;
723
- init_waitqueue_head(&rcfw->waitq);
822
+ rc = bnxt_qplib_map_creq_db(rcfw, cp_bar_reg_off);
823
+ if (rc)
824
+ return rc;
724825
725826 rc = bnxt_qplib_rcfw_start_irq(rcfw, msix_vector, true);
726827 if (rc) {
727828 dev_err(&rcfw->pdev->dev,
728
- "QPLIB: Failed to request IRQ for CREQ rc = 0x%x", rc);
829
+ "Failed to request IRQ for CREQ rc = 0x%x\n", rc);
729830 bnxt_qplib_disable_rcfw_channel(rcfw);
730831 return rc;
731832 }
732833
733
- init.cmdq_pbl = cpu_to_le64(rcfw->cmdq.pbl[PBL_LVL_0].pg_map_arr[0]);
734
- init.cmdq_size_cmdq_lvl = cpu_to_le16(
735
- ((BNXT_QPLIB_CMDQE_MAX_CNT << CMDQ_INIT_CMDQ_SIZE_SFT) &
736
- CMDQ_INIT_CMDQ_SIZE_MASK) |
737
- ((rcfw->cmdq.level << CMDQ_INIT_CMDQ_LVL_SFT) &
738
- CMDQ_INIT_CMDQ_LVL_MASK));
739
- init.creq_ring_id = cpu_to_le16(rcfw->creq_ring_id);
834
+ bnxt_qplib_start_rcfw(rcfw);
740835
741
- /* Write to the Bono mailbox register */
742
- __iowrite32_copy(rcfw->cmdq_bar_reg_iomem, &init, sizeof(init) / 4);
743836 return 0;
744837 }
745838
....@@ -754,8 +847,8 @@
754847 return NULL;
755848
756849 sbuf->size = size;
757
- sbuf->sb = dma_zalloc_coherent(&rcfw->pdev->dev, sbuf->size,
758
- &sbuf->dma_addr, GFP_ATOMIC);
850
+ sbuf->sb = dma_alloc_coherent(&rcfw->pdev->dev, sbuf->size,
851
+ &sbuf->dma_addr, GFP_ATOMIC);
759852 if (!sbuf->sb)
760853 goto bail;
761854