forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 958e46acc8e900e8569dd467c1af9b8d2d019394
kernel/drivers/infiniband/hw/bnxt_re/qplib_fp.c
....@@ -36,12 +36,16 @@
3636 * Description: Fast Path Operators
3737 */
3838
39
+#define dev_fmt(fmt) "QPLIB: " fmt
40
+
3941 #include <linux/interrupt.h>
4042 #include <linux/spinlock.h>
4143 #include <linux/sched.h>
4244 #include <linux/slab.h>
4345 #include <linux/pci.h>
46
+#include <linux/delay.h>
4447 #include <linux/prefetch.h>
48
+#include <linux/if_ether.h>
4549
4650 #include "roce_hsi.h"
4751
....@@ -50,9 +54,7 @@
5054 #include "qplib_sp.h"
5155 #include "qplib_fp.h"
5256
53
-static void bnxt_qplib_arm_cq_enable(struct bnxt_qplib_cq *cq);
5457 static void __clean_cq(struct bnxt_qplib_cq *cq, u64 qp);
55
-static void bnxt_qplib_arm_srq(struct bnxt_qplib_srq *srq, u32 arm_type);
5658
5759 static void bnxt_qplib_cancel_phantom_processing(struct bnxt_qplib_qp *qp)
5860 {
....@@ -71,8 +73,7 @@
7173
7274 if (!qp->sq.flushed) {
7375 dev_dbg(&scq->hwq.pdev->dev,
74
- "QPLIB: FP: Adding to SQ Flush list = %p",
75
- qp);
76
+ "FP: Adding to SQ Flush list = %p\n", qp);
7677 bnxt_qplib_cancel_phantom_processing(qp);
7778 list_add_tail(&qp->sq_flush, &scq->sqf_head);
7879 qp->sq.flushed = true;
....@@ -80,8 +81,7 @@
8081 if (!qp->srq) {
8182 if (!qp->rq.flushed) {
8283 dev_dbg(&rcq->hwq.pdev->dev,
83
- "QPLIB: FP: Adding to RQ Flush list = %p",
84
- qp);
84
+ "FP: Adding to RQ Flush list = %p\n", qp);
8585 list_add_tail(&qp->rq_flush, &rcq->rqf_head);
8686 qp->rq.flushed = true;
8787 }
....@@ -178,11 +178,11 @@
178178
179179 if (qp->rq_hdr_buf)
180180 dma_free_coherent(&res->pdev->dev,
181
- rq->hwq.max_elements * qp->rq_hdr_buf_size,
181
+ rq->max_wqe * qp->rq_hdr_buf_size,
182182 qp->rq_hdr_buf, qp->rq_hdr_buf_map);
183183 if (qp->sq_hdr_buf)
184184 dma_free_coherent(&res->pdev->dev,
185
- sq->hwq.max_elements * qp->sq_hdr_buf_size,
185
+ sq->max_wqe * qp->sq_hdr_buf_size,
186186 qp->sq_hdr_buf, qp->sq_hdr_buf_map);
187187 qp->rq_hdr_buf = NULL;
188188 qp->sq_hdr_buf = NULL;
....@@ -199,29 +199,28 @@
199199 struct bnxt_qplib_q *sq = &qp->sq;
200200 int rc = 0;
201201
202
- if (qp->sq_hdr_buf_size && sq->hwq.max_elements) {
202
+ if (qp->sq_hdr_buf_size && sq->max_wqe) {
203203 qp->sq_hdr_buf = dma_alloc_coherent(&res->pdev->dev,
204
- sq->hwq.max_elements *
205
- qp->sq_hdr_buf_size,
204
+ sq->max_wqe * qp->sq_hdr_buf_size,
206205 &qp->sq_hdr_buf_map, GFP_KERNEL);
207206 if (!qp->sq_hdr_buf) {
208207 rc = -ENOMEM;
209208 dev_err(&res->pdev->dev,
210
- "QPLIB: Failed to create sq_hdr_buf");
209
+ "Failed to create sq_hdr_buf\n");
211210 goto fail;
212211 }
213212 }
214213
215
- if (qp->rq_hdr_buf_size && rq->hwq.max_elements) {
214
+ if (qp->rq_hdr_buf_size && rq->max_wqe) {
216215 qp->rq_hdr_buf = dma_alloc_coherent(&res->pdev->dev,
217
- rq->hwq.max_elements *
216
+ rq->max_wqe *
218217 qp->rq_hdr_buf_size,
219218 &qp->rq_hdr_buf_map,
220219 GFP_KERNEL);
221220 if (!qp->rq_hdr_buf) {
222221 rc = -ENOMEM;
223222 dev_err(&res->pdev->dev,
224
- "QPLIB: Failed to create rq_hdr_buf");
223
+ "Failed to create rq_hdr_buf\n");
225224 goto fail;
226225 }
227226 }
....@@ -232,19 +231,16 @@
232231 return rc;
233232 }
234233
235
-static void bnxt_qplib_service_nq(unsigned long data)
234
+static void clean_nq(struct bnxt_qplib_nq *nq, struct bnxt_qplib_cq *cq)
236235 {
237
- struct bnxt_qplib_nq *nq = (struct bnxt_qplib_nq *)data;
238236 struct bnxt_qplib_hwq *hwq = &nq->hwq;
239237 struct nq_base *nqe, **nq_ptr;
240
- struct bnxt_qplib_cq *cq;
241
- int num_cqne_processed = 0;
242
- int num_srqne_processed = 0;
243
- u32 sw_cons, raw_cons;
244
- u16 type;
245238 int budget = nq->budget;
239
+ u32 sw_cons, raw_cons;
246240 uintptr_t q_handle;
241
+ u16 type;
247242
243
+ spin_lock_bh(&hwq->lock);
248244 /* Service the NQ until empty */
249245 raw_cons = hwq->cons;
250246 while (budget--) {
....@@ -269,36 +265,108 @@
269265 q_handle = le32_to_cpu(nqcne->cq_handle_low);
270266 q_handle |= (u64)le32_to_cpu(nqcne->cq_handle_high)
271267 << 32;
268
+ if ((unsigned long)cq == q_handle) {
269
+ nqcne->cq_handle_low = 0;
270
+ nqcne->cq_handle_high = 0;
271
+ cq->cnq_events++;
272
+ }
273
+ break;
274
+ }
275
+ default:
276
+ break;
277
+ }
278
+ raw_cons++;
279
+ }
280
+ spin_unlock_bh(&hwq->lock);
281
+}
282
+
283
+/* Wait for receiving all NQEs for this CQ and clean the NQEs associated with
284
+ * this CQ.
285
+ */
286
+static void __wait_for_all_nqes(struct bnxt_qplib_cq *cq, u16 cnq_events)
287
+{
288
+ u32 retry_cnt = 100;
289
+
290
+ while (retry_cnt--) {
291
+ if (cnq_events == cq->cnq_events)
292
+ return;
293
+ usleep_range(50, 100);
294
+ clean_nq(cq->nq, cq);
295
+ }
296
+}
297
+
298
+static void bnxt_qplib_service_nq(struct tasklet_struct *t)
299
+{
300
+ struct bnxt_qplib_nq *nq = from_tasklet(nq, t, nq_tasklet);
301
+ struct bnxt_qplib_hwq *hwq = &nq->hwq;
302
+ int num_srqne_processed = 0;
303
+ int num_cqne_processed = 0;
304
+ struct bnxt_qplib_cq *cq;
305
+ int budget = nq->budget;
306
+ u32 sw_cons, raw_cons;
307
+ struct nq_base *nqe;
308
+ uintptr_t q_handle;
309
+ u16 type;
310
+
311
+ spin_lock_bh(&hwq->lock);
312
+ /* Service the NQ until empty */
313
+ raw_cons = hwq->cons;
314
+ while (budget--) {
315
+ sw_cons = HWQ_CMP(raw_cons, hwq);
316
+ nqe = bnxt_qplib_get_qe(hwq, sw_cons, NULL);
317
+ if (!NQE_CMP_VALID(nqe, raw_cons, hwq->max_elements))
318
+ break;
319
+
320
+ /*
321
+ * The valid test of the entry must be done first before
322
+ * reading any further.
323
+ */
324
+ dma_rmb();
325
+
326
+ type = le16_to_cpu(nqe->info10_type) & NQ_BASE_TYPE_MASK;
327
+ switch (type) {
328
+ case NQ_BASE_TYPE_CQ_NOTIFICATION:
329
+ {
330
+ struct nq_cn *nqcne = (struct nq_cn *)nqe;
331
+
332
+ q_handle = le32_to_cpu(nqcne->cq_handle_low);
333
+ q_handle |= (u64)le32_to_cpu(nqcne->cq_handle_high)
334
+ << 32;
272335 cq = (struct bnxt_qplib_cq *)(unsigned long)q_handle;
273
- bnxt_qplib_arm_cq_enable(cq);
336
+ if (!cq)
337
+ break;
338
+ bnxt_qplib_armen_db(&cq->dbinfo,
339
+ DBC_DBC_TYPE_CQ_ARMENA);
274340 spin_lock_bh(&cq->compl_lock);
275341 atomic_set(&cq->arm_state, 0);
276342 if (!nq->cqn_handler(nq, (cq)))
277343 num_cqne_processed++;
278344 else
279345 dev_warn(&nq->pdev->dev,
280
- "QPLIB: cqn - type 0x%x not handled",
281
- type);
346
+ "cqn - type 0x%x not handled\n", type);
347
+ cq->cnq_events++;
282348 spin_unlock_bh(&cq->compl_lock);
283349 break;
284350 }
285351 case NQ_BASE_TYPE_SRQ_EVENT:
286352 {
353
+ struct bnxt_qplib_srq *srq;
287354 struct nq_srq_event *nqsrqe =
288355 (struct nq_srq_event *)nqe;
289356
290357 q_handle = le32_to_cpu(nqsrqe->srq_handle_low);
291358 q_handle |= (u64)le32_to_cpu(nqsrqe->srq_handle_high)
292359 << 32;
293
- bnxt_qplib_arm_srq((struct bnxt_qplib_srq *)q_handle,
294
- DBR_DBR_TYPE_SRQ_ARMENA);
360
+ srq = (struct bnxt_qplib_srq *)q_handle;
361
+ bnxt_qplib_armen_db(&srq->dbinfo,
362
+ DBC_DBC_TYPE_SRQ_ARMENA);
295363 if (!nq->srqn_handler(nq,
296364 (struct bnxt_qplib_srq *)q_handle,
297365 nqsrqe->event))
298366 num_srqne_processed++;
299367 else
300368 dev_warn(&nq->pdev->dev,
301
- "QPLIB: SRQ event 0x%x not handled",
369
+ "SRQ event 0x%x not handled\n",
302370 nqsrqe->event);
303371 break;
304372 }
....@@ -306,48 +374,46 @@
306374 break;
307375 default:
308376 dev_warn(&nq->pdev->dev,
309
- "QPLIB: nqe with type = 0x%x not handled",
310
- type);
377
+ "nqe with type = 0x%x not handled\n", type);
311378 break;
312379 }
313380 raw_cons++;
314381 }
315382 if (hwq->cons != raw_cons) {
316383 hwq->cons = raw_cons;
317
- NQ_DB_REARM(nq->bar_reg_iomem, hwq->cons, hwq->max_elements);
384
+ bnxt_qplib_ring_nq_db(&nq->nq_db.dbinfo, nq->res->cctx, true);
318385 }
386
+ spin_unlock_bh(&hwq->lock);
319387 }
320388
321389 static irqreturn_t bnxt_qplib_nq_irq(int irq, void *dev_instance)
322390 {
323391 struct bnxt_qplib_nq *nq = dev_instance;
324392 struct bnxt_qplib_hwq *hwq = &nq->hwq;
325
- struct nq_base **nq_ptr;
326393 u32 sw_cons;
327394
328395 /* Prefetch the NQ element */
329396 sw_cons = HWQ_CMP(hwq->cons, hwq);
330
- nq_ptr = (struct nq_base **)nq->hwq.pbl_ptr;
331
- prefetch(&nq_ptr[NQE_PG(sw_cons)][NQE_IDX(sw_cons)]);
397
+ prefetch(bnxt_qplib_get_qe(hwq, sw_cons, NULL));
332398
333399 /* Fan out to CPU affinitized kthreads? */
334
- tasklet_schedule(&nq->worker);
400
+ tasklet_schedule(&nq->nq_tasklet);
335401
336402 return IRQ_HANDLED;
337403 }
338404
339405 void bnxt_qplib_nq_stop_irq(struct bnxt_qplib_nq *nq, bool kill)
340406 {
341
- tasklet_disable(&nq->worker);
407
+ tasklet_disable(&nq->nq_tasklet);
342408 /* Mask h/w interrupt */
343
- NQ_DB(nq->bar_reg_iomem, nq->hwq.cons, nq->hwq.max_elements);
409
+ bnxt_qplib_ring_nq_db(&nq->nq_db.dbinfo, nq->res->cctx, false);
344410 /* Sync with last running IRQ handler */
345
- synchronize_irq(nq->vector);
411
+ synchronize_irq(nq->msix_vec);
346412 if (kill)
347
- tasklet_kill(&nq->worker);
413
+ tasklet_kill(&nq->nq_tasklet);
348414 if (nq->requested) {
349
- irq_set_affinity_hint(nq->vector, NULL);
350
- free_irq(nq->vector, nq);
415
+ irq_set_affinity_hint(nq->msix_vec, NULL);
416
+ free_irq(nq->msix_vec, nq);
351417 nq->requested = false;
352418 }
353419 }
....@@ -360,16 +426,16 @@
360426 }
361427
362428 /* Make sure the HW is stopped! */
363
- if (nq->requested)
364
- bnxt_qplib_nq_stop_irq(nq, true);
429
+ bnxt_qplib_nq_stop_irq(nq, true);
365430
366
- if (nq->bar_reg_iomem)
367
- iounmap(nq->bar_reg_iomem);
368
- nq->bar_reg_iomem = NULL;
431
+ if (nq->nq_db.reg.bar_reg) {
432
+ iounmap(nq->nq_db.reg.bar_reg);
433
+ nq->nq_db.reg.bar_reg = NULL;
434
+ }
369435
370436 nq->cqn_handler = NULL;
371437 nq->srqn_handler = NULL;
372
- nq->vector = 0;
438
+ nq->msix_vec = 0;
373439 }
374440
375441 int bnxt_qplib_nq_start_irq(struct bnxt_qplib_nq *nq, int nq_indx,
....@@ -380,71 +446,92 @@
380446 if (nq->requested)
381447 return -EFAULT;
382448
383
- nq->vector = msix_vector;
449
+ nq->msix_vec = msix_vector;
384450 if (need_init)
385
- tasklet_init(&nq->worker, bnxt_qplib_service_nq,
386
- (unsigned long)nq);
451
+ tasklet_setup(&nq->nq_tasklet, bnxt_qplib_service_nq);
387452 else
388
- tasklet_enable(&nq->worker);
453
+ tasklet_enable(&nq->nq_tasklet);
389454
390455 snprintf(nq->name, sizeof(nq->name), "bnxt_qplib_nq-%d", nq_indx);
391
- rc = request_irq(nq->vector, bnxt_qplib_nq_irq, 0, nq->name, nq);
456
+ rc = request_irq(nq->msix_vec, bnxt_qplib_nq_irq, 0, nq->name, nq);
392457 if (rc)
393458 return rc;
394459
395460 cpumask_clear(&nq->mask);
396461 cpumask_set_cpu(nq_indx, &nq->mask);
397
- rc = irq_set_affinity_hint(nq->vector, &nq->mask);
462
+ rc = irq_set_affinity_hint(nq->msix_vec, &nq->mask);
398463 if (rc) {
399464 dev_warn(&nq->pdev->dev,
400
- "QPLIB: set affinity failed; vector: %d nq_idx: %d\n",
401
- nq->vector, nq_indx);
465
+ "set affinity failed; vector: %d nq_idx: %d\n",
466
+ nq->msix_vec, nq_indx);
402467 }
403468 nq->requested = true;
404
- NQ_DB_REARM(nq->bar_reg_iomem, nq->hwq.cons, nq->hwq.max_elements);
469
+ bnxt_qplib_ring_nq_db(&nq->nq_db.dbinfo, nq->res->cctx, true);
405470
471
+ return rc;
472
+}
473
+
474
+static int bnxt_qplib_map_nq_db(struct bnxt_qplib_nq *nq, u32 reg_offt)
475
+{
476
+ resource_size_t reg_base;
477
+ struct bnxt_qplib_nq_db *nq_db;
478
+ struct pci_dev *pdev;
479
+ int rc = 0;
480
+
481
+ pdev = nq->pdev;
482
+ nq_db = &nq->nq_db;
483
+
484
+ nq_db->reg.bar_id = NQ_CONS_PCI_BAR_REGION;
485
+ nq_db->reg.bar_base = pci_resource_start(pdev, nq_db->reg.bar_id);
486
+ if (!nq_db->reg.bar_base) {
487
+ dev_err(&pdev->dev, "QPLIB: NQ BAR region %d resc start is 0!",
488
+ nq_db->reg.bar_id);
489
+ rc = -ENOMEM;
490
+ goto fail;
491
+ }
492
+
493
+ reg_base = nq_db->reg.bar_base + reg_offt;
494
+ /* Unconditionally map 8 bytes to support 57500 series */
495
+ nq_db->reg.len = 8;
496
+ nq_db->reg.bar_reg = ioremap(reg_base, nq_db->reg.len);
497
+ if (!nq_db->reg.bar_reg) {
498
+ dev_err(&pdev->dev, "QPLIB: NQ BAR region %d mapping failed",
499
+ nq_db->reg.bar_id);
500
+ rc = -ENOMEM;
501
+ goto fail;
502
+ }
503
+
504
+ nq_db->dbinfo.db = nq_db->reg.bar_reg;
505
+ nq_db->dbinfo.hwq = &nq->hwq;
506
+ nq_db->dbinfo.xid = nq->ring_id;
507
+fail:
406508 return rc;
407509 }
408510
409511 int bnxt_qplib_enable_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq,
410512 int nq_idx, int msix_vector, int bar_reg_offset,
411
- int (*cqn_handler)(struct bnxt_qplib_nq *nq,
412
- struct bnxt_qplib_cq *),
413
- int (*srqn_handler)(struct bnxt_qplib_nq *nq,
414
- struct bnxt_qplib_srq *,
415
- u8 event))
513
+ cqn_handler_t cqn_handler,
514
+ srqn_handler_t srqn_handler)
416515 {
417
- resource_size_t nq_base;
418516 int rc = -1;
419517
420
- if (cqn_handler)
421
- nq->cqn_handler = cqn_handler;
422
-
423
- if (srqn_handler)
424
- nq->srqn_handler = srqn_handler;
518
+ nq->pdev = pdev;
519
+ nq->cqn_handler = cqn_handler;
520
+ nq->srqn_handler = srqn_handler;
425521
426522 /* Have a task to schedule CQ notifiers in post send case */
427523 nq->cqn_wq = create_singlethread_workqueue("bnxt_qplib_nq");
428524 if (!nq->cqn_wq)
429525 return -ENOMEM;
430526
431
- nq->bar_reg = NQ_CONS_PCI_BAR_REGION;
432
- nq->bar_reg_off = bar_reg_offset;
433
- nq_base = pci_resource_start(pdev, nq->bar_reg);
434
- if (!nq_base) {
435
- rc = -ENOMEM;
527
+ rc = bnxt_qplib_map_nq_db(nq, bar_reg_offset);
528
+ if (rc)
436529 goto fail;
437
- }
438
- nq->bar_reg_iomem = ioremap_nocache(nq_base + nq->bar_reg_off, 4);
439
- if (!nq->bar_reg_iomem) {
440
- rc = -ENOMEM;
441
- goto fail;
442
- }
443530
444531 rc = bnxt_qplib_nq_start_irq(nq, nq_idx, msix_vector, true);
445532 if (rc) {
446533 dev_err(&nq->pdev->dev,
447
- "QPLIB: Failed to request irq for nq-idx %d", nq_idx);
534
+ "Failed to request irq for nq-idx %d\n", nq_idx);
448535 goto fail;
449536 }
450537
....@@ -457,50 +544,39 @@
457544 void bnxt_qplib_free_nq(struct bnxt_qplib_nq *nq)
458545 {
459546 if (nq->hwq.max_elements) {
460
- bnxt_qplib_free_hwq(nq->pdev, &nq->hwq);
547
+ bnxt_qplib_free_hwq(nq->res, &nq->hwq);
461548 nq->hwq.max_elements = 0;
462549 }
463550 }
464551
465
-int bnxt_qplib_alloc_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq)
552
+int bnxt_qplib_alloc_nq(struct bnxt_qplib_res *res, struct bnxt_qplib_nq *nq)
466553 {
467
- nq->pdev = pdev;
554
+ struct bnxt_qplib_hwq_attr hwq_attr = {};
555
+ struct bnxt_qplib_sg_info sginfo = {};
556
+
557
+ nq->pdev = res->pdev;
558
+ nq->res = res;
468559 if (!nq->hwq.max_elements ||
469560 nq->hwq.max_elements > BNXT_QPLIB_NQE_MAX_CNT)
470561 nq->hwq.max_elements = BNXT_QPLIB_NQE_MAX_CNT;
471562
472
- if (bnxt_qplib_alloc_init_hwq(nq->pdev, &nq->hwq, NULL, 0,
473
- &nq->hwq.max_elements,
474
- BNXT_QPLIB_MAX_NQE_ENTRY_SIZE, 0,
475
- PAGE_SIZE, HWQ_TYPE_L2_CMPL))
563
+ sginfo.pgsize = PAGE_SIZE;
564
+ sginfo.pgshft = PAGE_SHIFT;
565
+ hwq_attr.res = res;
566
+ hwq_attr.sginfo = &sginfo;
567
+ hwq_attr.depth = nq->hwq.max_elements;
568
+ hwq_attr.stride = sizeof(struct nq_base);
569
+ hwq_attr.type = bnxt_qplib_get_hwq_type(nq->res);
570
+ if (bnxt_qplib_alloc_init_hwq(&nq->hwq, &hwq_attr)) {
571
+ dev_err(&nq->pdev->dev, "FP NQ allocation failed");
476572 return -ENOMEM;
477
-
573
+ }
478574 nq->budget = 8;
479575 return 0;
480576 }
481577
482578 /* SRQ */
483
-static void bnxt_qplib_arm_srq(struct bnxt_qplib_srq *srq, u32 arm_type)
484
-{
485
- struct bnxt_qplib_hwq *srq_hwq = &srq->hwq;
486
- struct dbr_dbr db_msg = { 0 };
487
- void __iomem *db;
488
- u32 sw_prod = 0;
489
-
490
- /* Ring DB */
491
- sw_prod = (arm_type == DBR_DBR_TYPE_SRQ_ARM) ? srq->threshold :
492
- HWQ_CMP(srq_hwq->prod, srq_hwq);
493
- db_msg.index = cpu_to_le32((sw_prod << DBR_DBR_INDEX_SFT) &
494
- DBR_DBR_INDEX_MASK);
495
- db_msg.type_xid = cpu_to_le32(((srq->id << DBR_DBR_XID_SFT) &
496
- DBR_DBR_XID_MASK) | arm_type);
497
- db = (arm_type == DBR_DBR_TYPE_SRQ_ARMENA) ?
498
- srq->dbr_base : srq->dpi->dbr;
499
- wmb(); /* barrier before db ring */
500
- __iowrite64_copy(db, &db_msg, sizeof(db_msg) / sizeof(u64));
501
-}
502
-
503
-int bnxt_qplib_destroy_srq(struct bnxt_qplib_res *res,
579
+void bnxt_qplib_destroy_srq(struct bnxt_qplib_res *res,
504580 struct bnxt_qplib_srq *srq)
505581 {
506582 struct bnxt_qplib_rcfw *rcfw = res->rcfw;
....@@ -514,31 +590,32 @@
514590 /* Configure the request */
515591 req.srq_cid = cpu_to_le32(srq->id);
516592
517
- rc = bnxt_qplib_rcfw_send_message(rcfw, (void *)&req,
518
- (void *)&resp, NULL, 0);
519
- if (rc)
520
- return rc;
521
-
522
- bnxt_qplib_free_hwq(res->pdev, &srq->hwq);
593
+ rc = bnxt_qplib_rcfw_send_message(rcfw, (struct cmdq_base *)&req,
594
+ (struct creq_base *)&resp, NULL, 0);
523595 kfree(srq->swq);
524
- return 0;
596
+ if (rc)
597
+ return;
598
+ bnxt_qplib_free_hwq(res, &srq->hwq);
525599 }
526600
527601 int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,
528602 struct bnxt_qplib_srq *srq)
529603 {
530604 struct bnxt_qplib_rcfw *rcfw = res->rcfw;
531
- struct cmdq_create_srq req;
605
+ struct bnxt_qplib_hwq_attr hwq_attr = {};
532606 struct creq_create_srq_resp resp;
607
+ struct cmdq_create_srq req;
533608 struct bnxt_qplib_pbl *pbl;
534609 u16 cmd_flags = 0;
610
+ u16 pg_sz_lvl;
535611 int rc, idx;
536612
537
- srq->hwq.max_elements = srq->max_wqe;
538
- rc = bnxt_qplib_alloc_init_hwq(res->pdev, &srq->hwq, srq->sglist,
539
- srq->nmap, &srq->hwq.max_elements,
540
- BNXT_QPLIB_MAX_RQE_ENTRY_SIZE, 0,
541
- PAGE_SIZE, HWQ_TYPE_QUEUE);
613
+ hwq_attr.res = res;
614
+ hwq_attr.sginfo = &srq->sg_info;
615
+ hwq_attr.depth = srq->max_wqe;
616
+ hwq_attr.stride = srq->wqe_size;
617
+ hwq_attr.type = HWQ_TYPE_QUEUE;
618
+ rc = bnxt_qplib_alloc_init_hwq(&srq->hwq, &hwq_attr);
542619 if (rc)
543620 goto exit;
544621
....@@ -557,22 +634,11 @@
557634
558635 req.srq_size = cpu_to_le16((u16)srq->hwq.max_elements);
559636 pbl = &srq->hwq.pbl[PBL_LVL_0];
560
- req.pg_size_lvl = cpu_to_le16((((u16)srq->hwq.level &
561
- CMDQ_CREATE_SRQ_LVL_MASK) <<
562
- CMDQ_CREATE_SRQ_LVL_SFT) |
563
- (pbl->pg_size == ROCE_PG_SIZE_4K ?
564
- CMDQ_CREATE_SRQ_PG_SIZE_PG_4K :
565
- pbl->pg_size == ROCE_PG_SIZE_8K ?
566
- CMDQ_CREATE_SRQ_PG_SIZE_PG_8K :
567
- pbl->pg_size == ROCE_PG_SIZE_64K ?
568
- CMDQ_CREATE_SRQ_PG_SIZE_PG_64K :
569
- pbl->pg_size == ROCE_PG_SIZE_2M ?
570
- CMDQ_CREATE_SRQ_PG_SIZE_PG_2M :
571
- pbl->pg_size == ROCE_PG_SIZE_8M ?
572
- CMDQ_CREATE_SRQ_PG_SIZE_PG_8M :
573
- pbl->pg_size == ROCE_PG_SIZE_1G ?
574
- CMDQ_CREATE_SRQ_PG_SIZE_PG_1G :
575
- CMDQ_CREATE_SRQ_PG_SIZE_PG_4K));
637
+ pg_sz_lvl = ((u16)bnxt_qplib_base_pg_size(&srq->hwq) <<
638
+ CMDQ_CREATE_SRQ_PG_SIZE_SFT);
639
+ pg_sz_lvl |= (srq->hwq.level & CMDQ_CREATE_SRQ_LVL_MASK) <<
640
+ CMDQ_CREATE_SRQ_LVL_SFT;
641
+ req.pg_size_lvl = cpu_to_le16(pg_sz_lvl);
576642 req.pbl = cpu_to_le64(pbl->pg_map_arr[0]);
577643 req.pd_id = cpu_to_le32(srq->pd->id);
578644 req.eventq_id = cpu_to_le16(srq->eventq_hw_ring_id);
....@@ -590,14 +656,18 @@
590656 srq->swq[srq->last_idx].next_idx = -1;
591657
592658 srq->id = le32_to_cpu(resp.xid);
593
- srq->dbr_base = res->dpi_tbl.dbr_bar_reg_iomem;
659
+ srq->dbinfo.hwq = &srq->hwq;
660
+ srq->dbinfo.xid = srq->id;
661
+ srq->dbinfo.db = srq->dpi->dbr;
662
+ srq->dbinfo.max_slot = 1;
663
+ srq->dbinfo.priv_db = res->dpi_tbl.dbr_bar_reg_iomem;
594664 if (srq->threshold)
595
- bnxt_qplib_arm_srq(srq, DBR_DBR_TYPE_SRQ_ARMENA);
665
+ bnxt_qplib_armen_db(&srq->dbinfo, DBC_DBC_TYPE_SRQ_ARMENA);
596666 srq->arm_req = false;
597667
598668 return 0;
599669 fail:
600
- bnxt_qplib_free_hwq(res->pdev, &srq->hwq);
670
+ bnxt_qplib_free_hwq(res, &srq->hwq);
601671 kfree(srq->swq);
602672 exit:
603673 return rc;
....@@ -616,7 +686,7 @@
616686 srq_hwq->max_elements - sw_cons + sw_prod;
617687 if (count > srq->threshold) {
618688 srq->arm_req = false;
619
- bnxt_qplib_arm_srq(srq, DBR_DBR_TYPE_SRQ_ARM);
689
+ bnxt_qplib_srq_arm_db(&srq->dbinfo, srq->threshold);
620690 } else {
621691 /* Deferred arming */
622692 srq->arm_req = true;
....@@ -657,15 +727,15 @@
657727 struct bnxt_qplib_swqe *wqe)
658728 {
659729 struct bnxt_qplib_hwq *srq_hwq = &srq->hwq;
660
- struct rq_wqe *srqe, **srqe_ptr;
730
+ struct rq_wqe *srqe;
661731 struct sq_sge *hw_sge;
662732 u32 sw_prod, sw_cons, count = 0;
663733 int i, rc = 0, next;
664734
665735 spin_lock(&srq_hwq->lock);
666736 if (srq->start_idx == srq->last_idx) {
667
- dev_err(&srq_hwq->pdev->dev, "QPLIB: FP: SRQ (0x%x) is full!",
668
- srq->id);
737
+ dev_err(&srq_hwq->pdev->dev,
738
+ "FP: SRQ (0x%x) is full!\n", srq->id);
669739 rc = -EINVAL;
670740 spin_unlock(&srq_hwq->lock);
671741 goto done;
....@@ -675,9 +745,8 @@
675745 spin_unlock(&srq_hwq->lock);
676746
677747 sw_prod = HWQ_CMP(srq_hwq->prod, srq_hwq);
678
- srqe_ptr = (struct rq_wqe **)srq_hwq->pbl_ptr;
679
- srqe = &srqe_ptr[RQE_PG(sw_prod)][RQE_IDX(sw_prod)];
680
- memset(srqe, 0, BNXT_QPLIB_MAX_RQE_ENTRY_SIZE);
748
+ srqe = bnxt_qplib_get_qe(srq_hwq, sw_prod, NULL);
749
+ memset(srqe, 0, srq->wqe_size);
681750 /* Calculate wqe_size16 and data_len */
682751 for (i = 0, hw_sge = (struct sq_sge *)srqe->data;
683752 i < wqe->num_sge; i++, hw_sge++) {
....@@ -705,27 +774,52 @@
705774 srq_hwq->max_elements - sw_cons + sw_prod;
706775 spin_unlock(&srq_hwq->lock);
707776 /* Ring DB */
708
- bnxt_qplib_arm_srq(srq, DBR_DBR_TYPE_SRQ);
777
+ bnxt_qplib_ring_prod_db(&srq->dbinfo, DBC_DBC_TYPE_SRQ);
709778 if (srq->arm_req == true && count > srq->threshold) {
710779 srq->arm_req = false;
711
- bnxt_qplib_arm_srq(srq, DBR_DBR_TYPE_SRQ_ARM);
780
+ bnxt_qplib_srq_arm_db(&srq->dbinfo, srq->threshold);
712781 }
713782 done:
714783 return rc;
715784 }
716785
717786 /* QP */
787
+
788
+static int bnxt_qplib_alloc_init_swq(struct bnxt_qplib_q *que)
789
+{
790
+ int rc = 0;
791
+ int indx;
792
+
793
+ que->swq = kcalloc(que->max_wqe, sizeof(*que->swq), GFP_KERNEL);
794
+ if (!que->swq) {
795
+ rc = -ENOMEM;
796
+ goto out;
797
+ }
798
+
799
+ que->swq_start = 0;
800
+ que->swq_last = que->max_wqe - 1;
801
+ for (indx = 0; indx < que->max_wqe; indx++)
802
+ que->swq[indx].next_idx = indx + 1;
803
+ que->swq[que->swq_last].next_idx = 0; /* Make it circular */
804
+ que->swq_last = 0;
805
+out:
806
+ return rc;
807
+}
808
+
718809 int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
719810 {
811
+ struct bnxt_qplib_hwq_attr hwq_attr = {};
720812 struct bnxt_qplib_rcfw *rcfw = res->rcfw;
721
- struct cmdq_create_qp1 req;
722
- struct creq_create_qp1_resp resp;
723
- struct bnxt_qplib_pbl *pbl;
724813 struct bnxt_qplib_q *sq = &qp->sq;
725814 struct bnxt_qplib_q *rq = &qp->rq;
726
- int rc;
815
+ struct creq_create_qp1_resp resp;
816
+ struct cmdq_create_qp1 req;
817
+ struct bnxt_qplib_pbl *pbl;
727818 u16 cmd_flags = 0;
728819 u32 qp_flags = 0;
820
+ u8 pg_sz_lvl;
821
+ u32 tbl_indx;
822
+ int rc;
729823
730824 RCFW_CMD_PREP(req, CREATE_QP1, cmd_flags);
731825
....@@ -735,98 +829,65 @@
735829 req.qp_handle = cpu_to_le64(qp->qp_handle);
736830
737831 /* SQ */
738
- sq->hwq.max_elements = sq->max_wqe;
739
- rc = bnxt_qplib_alloc_init_hwq(res->pdev, &sq->hwq, NULL, 0,
740
- &sq->hwq.max_elements,
741
- BNXT_QPLIB_MAX_SQE_ENTRY_SIZE, 0,
742
- PAGE_SIZE, HWQ_TYPE_QUEUE);
832
+ hwq_attr.res = res;
833
+ hwq_attr.sginfo = &sq->sg_info;
834
+ hwq_attr.stride = sizeof(struct sq_sge);
835
+ hwq_attr.depth = bnxt_qplib_get_depth(sq);
836
+ hwq_attr.type = HWQ_TYPE_QUEUE;
837
+ rc = bnxt_qplib_alloc_init_hwq(&sq->hwq, &hwq_attr);
743838 if (rc)
744839 goto exit;
745840
746
- sq->swq = kcalloc(sq->hwq.max_elements, sizeof(*sq->swq), GFP_KERNEL);
747
- if (!sq->swq) {
748
- rc = -ENOMEM;
841
+ rc = bnxt_qplib_alloc_init_swq(sq);
842
+ if (rc)
749843 goto fail_sq;
750
- }
844
+
845
+ req.sq_size = cpu_to_le32(bnxt_qplib_set_sq_size(sq, qp->wqe_mode));
751846 pbl = &sq->hwq.pbl[PBL_LVL_0];
752847 req.sq_pbl = cpu_to_le64(pbl->pg_map_arr[0]);
753
- req.sq_pg_size_sq_lvl =
754
- ((sq->hwq.level & CMDQ_CREATE_QP1_SQ_LVL_MASK)
755
- << CMDQ_CREATE_QP1_SQ_LVL_SFT) |
756
- (pbl->pg_size == ROCE_PG_SIZE_4K ?
757
- CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_4K :
758
- pbl->pg_size == ROCE_PG_SIZE_8K ?
759
- CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_8K :
760
- pbl->pg_size == ROCE_PG_SIZE_64K ?
761
- CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_64K :
762
- pbl->pg_size == ROCE_PG_SIZE_2M ?
763
- CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_2M :
764
- pbl->pg_size == ROCE_PG_SIZE_8M ?
765
- CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_8M :
766
- pbl->pg_size == ROCE_PG_SIZE_1G ?
767
- CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_1G :
768
- CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_4K);
769
-
770
- if (qp->scq)
771
- req.scq_cid = cpu_to_le32(qp->scq->id);
772
-
773
- qp_flags |= CMDQ_CREATE_QP1_QP_FLAGS_RESERVED_LKEY_ENABLE;
848
+ pg_sz_lvl = (bnxt_qplib_base_pg_size(&sq->hwq) <<
849
+ CMDQ_CREATE_QP1_SQ_PG_SIZE_SFT);
850
+ pg_sz_lvl |= (sq->hwq.level & CMDQ_CREATE_QP1_SQ_LVL_MASK);
851
+ req.sq_pg_size_sq_lvl = pg_sz_lvl;
852
+ req.sq_fwo_sq_sge =
853
+ cpu_to_le16((sq->max_sge & CMDQ_CREATE_QP1_SQ_SGE_MASK) <<
854
+ CMDQ_CREATE_QP1_SQ_SGE_SFT);
855
+ req.scq_cid = cpu_to_le32(qp->scq->id);
774856
775857 /* RQ */
776858 if (rq->max_wqe) {
777
- rq->hwq.max_elements = qp->rq.max_wqe;
778
- rc = bnxt_qplib_alloc_init_hwq(res->pdev, &rq->hwq, NULL, 0,
779
- &rq->hwq.max_elements,
780
- BNXT_QPLIB_MAX_RQE_ENTRY_SIZE, 0,
781
- PAGE_SIZE, HWQ_TYPE_QUEUE);
859
+ hwq_attr.res = res;
860
+ hwq_attr.sginfo = &rq->sg_info;
861
+ hwq_attr.stride = sizeof(struct sq_sge);
862
+ hwq_attr.depth = bnxt_qplib_get_depth(rq);
863
+ hwq_attr.type = HWQ_TYPE_QUEUE;
864
+ rc = bnxt_qplib_alloc_init_hwq(&rq->hwq, &hwq_attr);
782865 if (rc)
783
- goto fail_sq;
784
-
785
- rq->swq = kcalloc(rq->hwq.max_elements, sizeof(*rq->swq),
786
- GFP_KERNEL);
787
- if (!rq->swq) {
788
- rc = -ENOMEM;
866
+ goto sq_swq;
867
+ rc = bnxt_qplib_alloc_init_swq(rq);
868
+ if (rc)
789869 goto fail_rq;
790
- }
870
+ req.rq_size = cpu_to_le32(rq->max_wqe);
791871 pbl = &rq->hwq.pbl[PBL_LVL_0];
792872 req.rq_pbl = cpu_to_le64(pbl->pg_map_arr[0]);
793
- req.rq_pg_size_rq_lvl =
794
- ((rq->hwq.level & CMDQ_CREATE_QP1_RQ_LVL_MASK) <<
795
- CMDQ_CREATE_QP1_RQ_LVL_SFT) |
796
- (pbl->pg_size == ROCE_PG_SIZE_4K ?
797
- CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_4K :
798
- pbl->pg_size == ROCE_PG_SIZE_8K ?
799
- CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_8K :
800
- pbl->pg_size == ROCE_PG_SIZE_64K ?
801
- CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_64K :
802
- pbl->pg_size == ROCE_PG_SIZE_2M ?
803
- CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_2M :
804
- pbl->pg_size == ROCE_PG_SIZE_8M ?
805
- CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_8M :
806
- pbl->pg_size == ROCE_PG_SIZE_1G ?
807
- CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_1G :
808
- CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_4K);
809
- if (qp->rcq)
810
- req.rcq_cid = cpu_to_le32(qp->rcq->id);
873
+ pg_sz_lvl = (bnxt_qplib_base_pg_size(&rq->hwq) <<
874
+ CMDQ_CREATE_QP1_RQ_PG_SIZE_SFT);
875
+ pg_sz_lvl |= (rq->hwq.level & CMDQ_CREATE_QP1_RQ_LVL_MASK);
876
+ req.rq_pg_size_rq_lvl = pg_sz_lvl;
877
+ req.rq_fwo_rq_sge =
878
+ cpu_to_le16((rq->max_sge &
879
+ CMDQ_CREATE_QP1_RQ_SGE_MASK) <<
880
+ CMDQ_CREATE_QP1_RQ_SGE_SFT);
811881 }
812
-
882
+ req.rcq_cid = cpu_to_le32(qp->rcq->id);
813883 /* Header buffer - allow hdr_buf pass in */
814884 rc = bnxt_qplib_alloc_qp_hdr_buf(res, qp);
815885 if (rc) {
816886 rc = -ENOMEM;
817
- goto fail;
887
+ goto rq_rwq;
818888 }
889
+ qp_flags |= CMDQ_CREATE_QP1_QP_FLAGS_RESERVED_LKEY_ENABLE;
819890 req.qp_flags = cpu_to_le32(qp_flags);
820
- req.sq_size = cpu_to_le32(sq->hwq.max_elements);
821
- req.rq_size = cpu_to_le32(rq->hwq.max_elements);
822
-
823
- req.sq_fwo_sq_sge =
824
- cpu_to_le16((sq->max_sge & CMDQ_CREATE_QP1_SQ_SGE_MASK) <<
825
- CMDQ_CREATE_QP1_SQ_SGE_SFT);
826
- req.rq_fwo_rq_sge =
827
- cpu_to_le16((rq->max_sge & CMDQ_CREATE_QP1_RQ_SGE_MASK) <<
828
- CMDQ_CREATE_QP1_RQ_SGE_SFT);
829
-
830891 req.pd_id = cpu_to_le32(qp->pd->id);
831892
832893 rc = bnxt_qplib_rcfw_send_message(rcfw, (void *)&req,
....@@ -836,38 +897,72 @@
836897
837898 qp->id = le32_to_cpu(resp.xid);
838899 qp->cur_qp_state = CMDQ_MODIFY_QP_NEW_STATE_RESET;
839
- rcfw->qp_tbl[qp->id].qp_id = qp->id;
840
- rcfw->qp_tbl[qp->id].qp_handle = (void *)qp;
900
+ qp->cctx = res->cctx;
901
+ sq->dbinfo.hwq = &sq->hwq;
902
+ sq->dbinfo.xid = qp->id;
903
+ sq->dbinfo.db = qp->dpi->dbr;
904
+ sq->dbinfo.max_slot = bnxt_qplib_set_sq_max_slot(qp->wqe_mode);
905
+ if (rq->max_wqe) {
906
+ rq->dbinfo.hwq = &rq->hwq;
907
+ rq->dbinfo.xid = qp->id;
908
+ rq->dbinfo.db = qp->dpi->dbr;
909
+ rq->dbinfo.max_slot = bnxt_qplib_set_rq_max_slot(rq->wqe_size);
910
+ }
911
+ tbl_indx = map_qp_id_to_tbl_indx(qp->id, rcfw);
912
+ rcfw->qp_tbl[tbl_indx].qp_id = qp->id;
913
+ rcfw->qp_tbl[tbl_indx].qp_handle = (void *)qp;
841914
842915 return 0;
843916
844917 fail:
845918 bnxt_qplib_free_qp_hdr_buf(res, qp);
846
-fail_rq:
847
- bnxt_qplib_free_hwq(res->pdev, &rq->hwq);
919
+rq_rwq:
848920 kfree(rq->swq);
849
-fail_sq:
850
- bnxt_qplib_free_hwq(res->pdev, &sq->hwq);
921
+fail_rq:
922
+ bnxt_qplib_free_hwq(res, &rq->hwq);
923
+sq_swq:
851924 kfree(sq->swq);
925
+fail_sq:
926
+ bnxt_qplib_free_hwq(res, &sq->hwq);
852927 exit:
853928 return rc;
929
+}
930
+
931
+static void bnxt_qplib_init_psn_ptr(struct bnxt_qplib_qp *qp, int size)
932
+{
933
+ struct bnxt_qplib_hwq *hwq;
934
+ struct bnxt_qplib_q *sq;
935
+ u64 fpsne, psn_pg;
936
+ u16 indx_pad = 0;
937
+
938
+ sq = &qp->sq;
939
+ hwq = &sq->hwq;
940
+ /* First psn entry */
941
+ fpsne = (u64)bnxt_qplib_get_qe(hwq, hwq->depth, &psn_pg);
942
+ if (!IS_ALIGNED(fpsne, PAGE_SIZE))
943
+ indx_pad = (fpsne & ~PAGE_MASK) / size;
944
+ hwq->pad_pgofft = indx_pad;
945
+ hwq->pad_pg = (u64 *)psn_pg;
946
+ hwq->pad_stride = size;
854947 }
855948
856949 int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
857950 {
858951 struct bnxt_qplib_rcfw *rcfw = res->rcfw;
859
- struct sq_send *hw_sq_send_hdr, **hw_sq_send_ptr;
860
- struct cmdq_create_qp req;
861
- struct creq_create_qp_resp resp;
862
- struct bnxt_qplib_pbl *pbl;
863
- struct sq_psn_search **psn_search_ptr;
864
- unsigned long int psn_search, poff = 0;
952
+ struct bnxt_qplib_hwq_attr hwq_attr = {};
953
+ struct bnxt_qplib_sg_info sginfo = {};
865954 struct bnxt_qplib_q *sq = &qp->sq;
866955 struct bnxt_qplib_q *rq = &qp->rq;
956
+ struct creq_create_qp_resp resp;
957
+ int rc, req_size, psn_sz = 0;
867958 struct bnxt_qplib_hwq *xrrq;
868
- int i, rc, req_size, psn_sz;
869
- u16 cmd_flags = 0, max_ssge;
870
- u32 sw_prod, qp_flags = 0;
959
+ struct bnxt_qplib_pbl *pbl;
960
+ struct cmdq_create_qp req;
961
+ u16 cmd_flags = 0;
962
+ u32 qp_flags = 0;
963
+ u8 pg_sz_lvl;
964
+ u32 tbl_indx;
965
+ u16 nsge;
871966
872967 RCFW_CMD_PREP(req, CREATE_QP, cmd_flags);
873968
....@@ -877,142 +972,86 @@
877972 req.qp_handle = cpu_to_le64(qp->qp_handle);
878973
879974 /* SQ */
880
- psn_sz = (qp->type == CMDQ_CREATE_QP_TYPE_RC) ?
881
- sizeof(struct sq_psn_search) : 0;
882
- sq->hwq.max_elements = sq->max_wqe;
883
- rc = bnxt_qplib_alloc_init_hwq(res->pdev, &sq->hwq, sq->sglist,
884
- sq->nmap, &sq->hwq.max_elements,
885
- BNXT_QPLIB_MAX_SQE_ENTRY_SIZE,
886
- psn_sz,
887
- PAGE_SIZE, HWQ_TYPE_QUEUE);
975
+ if (qp->type == CMDQ_CREATE_QP_TYPE_RC) {
976
+ psn_sz = bnxt_qplib_is_chip_gen_p5(res->cctx) ?
977
+ sizeof(struct sq_psn_search_ext) :
978
+ sizeof(struct sq_psn_search);
979
+ }
980
+
981
+ hwq_attr.res = res;
982
+ hwq_attr.sginfo = &sq->sg_info;
983
+ hwq_attr.stride = sizeof(struct sq_sge);
984
+ hwq_attr.depth = bnxt_qplib_get_depth(sq);
985
+ hwq_attr.aux_stride = psn_sz;
986
+ hwq_attr.aux_depth = bnxt_qplib_set_sq_size(sq, qp->wqe_mode);
987
+ hwq_attr.type = HWQ_TYPE_QUEUE;
988
+ rc = bnxt_qplib_alloc_init_hwq(&sq->hwq, &hwq_attr);
888989 if (rc)
889990 goto exit;
890991
891
- sq->swq = kcalloc(sq->hwq.max_elements, sizeof(*sq->swq), GFP_KERNEL);
892
- if (!sq->swq) {
893
- rc = -ENOMEM;
992
+ rc = bnxt_qplib_alloc_init_swq(sq);
993
+ if (rc)
894994 goto fail_sq;
895
- }
896
- hw_sq_send_ptr = (struct sq_send **)sq->hwq.pbl_ptr;
897
- if (psn_sz) {
898
- psn_search_ptr = (struct sq_psn_search **)
899
- &hw_sq_send_ptr[get_sqe_pg
900
- (sq->hwq.max_elements)];
901
- psn_search = (unsigned long int)
902
- &hw_sq_send_ptr[get_sqe_pg(sq->hwq.max_elements)]
903
- [get_sqe_idx(sq->hwq.max_elements)];
904
- if (psn_search & ~PAGE_MASK) {
905
- /* If the psn_search does not start on a page boundary,
906
- * then calculate the offset
907
- */
908
- poff = (psn_search & ~PAGE_MASK) /
909
- BNXT_QPLIB_MAX_PSNE_ENTRY_SIZE;
910
- }
911
- for (i = 0; i < sq->hwq.max_elements; i++)
912
- sq->swq[i].psn_search =
913
- &psn_search_ptr[get_psne_pg(i + poff)]
914
- [get_psne_idx(i + poff)];
915
- }
995
+
996
+ if (psn_sz)
997
+ bnxt_qplib_init_psn_ptr(qp, psn_sz);
998
+
999
+ req.sq_size = cpu_to_le32(bnxt_qplib_set_sq_size(sq, qp->wqe_mode));
9161000 pbl = &sq->hwq.pbl[PBL_LVL_0];
9171001 req.sq_pbl = cpu_to_le64(pbl->pg_map_arr[0]);
918
- req.sq_pg_size_sq_lvl =
919
- ((sq->hwq.level & CMDQ_CREATE_QP_SQ_LVL_MASK)
920
- << CMDQ_CREATE_QP_SQ_LVL_SFT) |
921
- (pbl->pg_size == ROCE_PG_SIZE_4K ?
922
- CMDQ_CREATE_QP_SQ_PG_SIZE_PG_4K :
923
- pbl->pg_size == ROCE_PG_SIZE_8K ?
924
- CMDQ_CREATE_QP_SQ_PG_SIZE_PG_8K :
925
- pbl->pg_size == ROCE_PG_SIZE_64K ?
926
- CMDQ_CREATE_QP_SQ_PG_SIZE_PG_64K :
927
- pbl->pg_size == ROCE_PG_SIZE_2M ?
928
- CMDQ_CREATE_QP_SQ_PG_SIZE_PG_2M :
929
- pbl->pg_size == ROCE_PG_SIZE_8M ?
930
- CMDQ_CREATE_QP_SQ_PG_SIZE_PG_8M :
931
- pbl->pg_size == ROCE_PG_SIZE_1G ?
932
- CMDQ_CREATE_QP_SQ_PG_SIZE_PG_1G :
933
- CMDQ_CREATE_QP_SQ_PG_SIZE_PG_4K);
1002
+ pg_sz_lvl = (bnxt_qplib_base_pg_size(&sq->hwq) <<
1003
+ CMDQ_CREATE_QP_SQ_PG_SIZE_SFT);
1004
+ pg_sz_lvl |= (sq->hwq.level & CMDQ_CREATE_QP_SQ_LVL_MASK);
1005
+ req.sq_pg_size_sq_lvl = pg_sz_lvl;
1006
+ req.sq_fwo_sq_sge =
1007
+ cpu_to_le16(((sq->max_sge & CMDQ_CREATE_QP_SQ_SGE_MASK) <<
1008
+ CMDQ_CREATE_QP_SQ_SGE_SFT) | 0);
1009
+ req.scq_cid = cpu_to_le32(qp->scq->id);
9341010
935
- /* initialize all SQ WQEs to LOCAL_INVALID (sq prep for hw fetch) */
936
- hw_sq_send_ptr = (struct sq_send **)sq->hwq.pbl_ptr;
937
- for (sw_prod = 0; sw_prod < sq->hwq.max_elements; sw_prod++) {
938
- hw_sq_send_hdr = &hw_sq_send_ptr[get_sqe_pg(sw_prod)]
939
- [get_sqe_idx(sw_prod)];
940
- hw_sq_send_hdr->wqe_type = SQ_BASE_WQE_TYPE_LOCAL_INVALID;
1011
+ /* RQ */
1012
+ if (!qp->srq) {
1013
+ hwq_attr.res = res;
1014
+ hwq_attr.sginfo = &rq->sg_info;
1015
+ hwq_attr.stride = sizeof(struct sq_sge);
1016
+ hwq_attr.depth = bnxt_qplib_get_depth(rq);
1017
+ hwq_attr.aux_stride = 0;
1018
+ hwq_attr.aux_depth = 0;
1019
+ hwq_attr.type = HWQ_TYPE_QUEUE;
1020
+ rc = bnxt_qplib_alloc_init_hwq(&rq->hwq, &hwq_attr);
1021
+ if (rc)
1022
+ goto sq_swq;
1023
+ rc = bnxt_qplib_alloc_init_swq(rq);
1024
+ if (rc)
1025
+ goto fail_rq;
1026
+
1027
+ req.rq_size = cpu_to_le32(rq->max_wqe);
1028
+ pbl = &rq->hwq.pbl[PBL_LVL_0];
1029
+ req.rq_pbl = cpu_to_le64(pbl->pg_map_arr[0]);
1030
+ pg_sz_lvl = (bnxt_qplib_base_pg_size(&rq->hwq) <<
1031
+ CMDQ_CREATE_QP_RQ_PG_SIZE_SFT);
1032
+ pg_sz_lvl |= (rq->hwq.level & CMDQ_CREATE_QP_RQ_LVL_MASK);
1033
+ req.rq_pg_size_rq_lvl = pg_sz_lvl;
1034
+ nsge = (qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
1035
+ 6 : rq->max_sge;
1036
+ req.rq_fwo_rq_sge =
1037
+ cpu_to_le16(((nsge &
1038
+ CMDQ_CREATE_QP_RQ_SGE_MASK) <<
1039
+ CMDQ_CREATE_QP_RQ_SGE_SFT) | 0);
1040
+ } else {
1041
+ /* SRQ */
1042
+ qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_SRQ_USED;
1043
+ req.srq_cid = cpu_to_le32(qp->srq->id);
9411044 }
942
-
943
- if (qp->scq)
944
- req.scq_cid = cpu_to_le32(qp->scq->id);
1045
+ req.rcq_cid = cpu_to_le32(qp->rcq->id);
9451046
9461047 qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_RESERVED_LKEY_ENABLE;
9471048 qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_FR_PMR_ENABLED;
9481049 if (qp->sig_type)
9491050 qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_FORCE_COMPLETION;
950
-
951
- /* RQ */
952
- if (rq->max_wqe) {
953
- rq->hwq.max_elements = rq->max_wqe;
954
- rc = bnxt_qplib_alloc_init_hwq(res->pdev, &rq->hwq, rq->sglist,
955
- rq->nmap, &rq->hwq.max_elements,
956
- BNXT_QPLIB_MAX_RQE_ENTRY_SIZE, 0,
957
- PAGE_SIZE, HWQ_TYPE_QUEUE);
958
- if (rc)
959
- goto fail_sq;
960
-
961
- rq->swq = kcalloc(rq->hwq.max_elements, sizeof(*rq->swq),
962
- GFP_KERNEL);
963
- if (!rq->swq) {
964
- rc = -ENOMEM;
965
- goto fail_rq;
966
- }
967
- pbl = &rq->hwq.pbl[PBL_LVL_0];
968
- req.rq_pbl = cpu_to_le64(pbl->pg_map_arr[0]);
969
- req.rq_pg_size_rq_lvl =
970
- ((rq->hwq.level & CMDQ_CREATE_QP_RQ_LVL_MASK) <<
971
- CMDQ_CREATE_QP_RQ_LVL_SFT) |
972
- (pbl->pg_size == ROCE_PG_SIZE_4K ?
973
- CMDQ_CREATE_QP_RQ_PG_SIZE_PG_4K :
974
- pbl->pg_size == ROCE_PG_SIZE_8K ?
975
- CMDQ_CREATE_QP_RQ_PG_SIZE_PG_8K :
976
- pbl->pg_size == ROCE_PG_SIZE_64K ?
977
- CMDQ_CREATE_QP_RQ_PG_SIZE_PG_64K :
978
- pbl->pg_size == ROCE_PG_SIZE_2M ?
979
- CMDQ_CREATE_QP_RQ_PG_SIZE_PG_2M :
980
- pbl->pg_size == ROCE_PG_SIZE_8M ?
981
- CMDQ_CREATE_QP_RQ_PG_SIZE_PG_8M :
982
- pbl->pg_size == ROCE_PG_SIZE_1G ?
983
- CMDQ_CREATE_QP_RQ_PG_SIZE_PG_1G :
984
- CMDQ_CREATE_QP_RQ_PG_SIZE_PG_4K);
985
- } else {
986
- /* SRQ */
987
- if (qp->srq) {
988
- qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_SRQ_USED;
989
- req.srq_cid = cpu_to_le32(qp->srq->id);
990
- }
991
- }
992
-
993
- if (qp->rcq)
994
- req.rcq_cid = cpu_to_le32(qp->rcq->id);
1051
+ if (qp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE)
1052
+ qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_VARIABLE_SIZED_WQE_ENABLED;
9951053 req.qp_flags = cpu_to_le32(qp_flags);
996
- req.sq_size = cpu_to_le32(sq->hwq.max_elements);
997
- req.rq_size = cpu_to_le32(rq->hwq.max_elements);
998
- qp->sq_hdr_buf = NULL;
999
- qp->rq_hdr_buf = NULL;
10001054
1001
- rc = bnxt_qplib_alloc_qp_hdr_buf(res, qp);
1002
- if (rc)
1003
- goto fail_rq;
1004
-
1005
- /* CTRL-22434: Irrespective of the requested SGE count on the SQ
1006
- * always create the QP with max send sges possible if the requested
1007
- * inline size is greater than 0.
1008
- */
1009
- max_ssge = qp->max_inline_data ? 6 : sq->max_sge;
1010
- req.sq_fwo_sq_sge = cpu_to_le16(
1011
- ((max_ssge & CMDQ_CREATE_QP_SQ_SGE_MASK)
1012
- << CMDQ_CREATE_QP_SQ_SGE_SFT) | 0);
1013
- req.rq_fwo_rq_sge = cpu_to_le16(
1014
- ((rq->max_sge & CMDQ_CREATE_QP_RQ_SGE_MASK)
1015
- << CMDQ_CREATE_QP_RQ_SGE_SFT) | 0);
10161055 /* ORRQ and IRRQ */
10171056 if (psn_sz) {
10181057 xrrq = &qp->orrq;
....@@ -1021,12 +1060,19 @@
10211060 req_size = xrrq->max_elements *
10221061 BNXT_QPLIB_MAX_ORRQE_ENTRY_SIZE + PAGE_SIZE - 1;
10231062 req_size &= ~(PAGE_SIZE - 1);
1024
- rc = bnxt_qplib_alloc_init_hwq(res->pdev, xrrq, NULL, 0,
1025
- &xrrq->max_elements,
1026
- BNXT_QPLIB_MAX_ORRQE_ENTRY_SIZE,
1027
- 0, req_size, HWQ_TYPE_CTX);
1063
+ sginfo.pgsize = req_size;
1064
+ sginfo.pgshft = PAGE_SHIFT;
1065
+
1066
+ hwq_attr.res = res;
1067
+ hwq_attr.sginfo = &sginfo;
1068
+ hwq_attr.depth = xrrq->max_elements;
1069
+ hwq_attr.stride = BNXT_QPLIB_MAX_ORRQE_ENTRY_SIZE;
1070
+ hwq_attr.aux_stride = 0;
1071
+ hwq_attr.aux_depth = 0;
1072
+ hwq_attr.type = HWQ_TYPE_CTX;
1073
+ rc = bnxt_qplib_alloc_init_hwq(xrrq, &hwq_attr);
10281074 if (rc)
1029
- goto fail_buf_free;
1075
+ goto rq_swq;
10301076 pbl = &xrrq->pbl[PBL_LVL_0];
10311077 req.orrq_addr = cpu_to_le64(pbl->pg_map_arr[0]);
10321078
....@@ -1036,11 +1082,10 @@
10361082 req_size = xrrq->max_elements *
10371083 BNXT_QPLIB_MAX_IRRQE_ENTRY_SIZE + PAGE_SIZE - 1;
10381084 req_size &= ~(PAGE_SIZE - 1);
1039
-
1040
- rc = bnxt_qplib_alloc_init_hwq(res->pdev, xrrq, NULL, 0,
1041
- &xrrq->max_elements,
1042
- BNXT_QPLIB_MAX_IRRQE_ENTRY_SIZE,
1043
- 0, req_size, HWQ_TYPE_CTX);
1085
+ sginfo.pgsize = req_size;
1086
+ hwq_attr.depth = xrrq->max_elements;
1087
+ hwq_attr.stride = BNXT_QPLIB_MAX_IRRQE_ENTRY_SIZE;
1088
+ rc = bnxt_qplib_alloc_init_hwq(xrrq, &hwq_attr);
10441089 if (rc)
10451090 goto fail_orrq;
10461091
....@@ -1058,25 +1103,34 @@
10581103 qp->cur_qp_state = CMDQ_MODIFY_QP_NEW_STATE_RESET;
10591104 INIT_LIST_HEAD(&qp->sq_flush);
10601105 INIT_LIST_HEAD(&qp->rq_flush);
1061
- rcfw->qp_tbl[qp->id].qp_id = qp->id;
1062
- rcfw->qp_tbl[qp->id].qp_handle = (void *)qp;
1106
+ qp->cctx = res->cctx;
1107
+ sq->dbinfo.hwq = &sq->hwq;
1108
+ sq->dbinfo.xid = qp->id;
1109
+ sq->dbinfo.db = qp->dpi->dbr;
1110
+ sq->dbinfo.max_slot = bnxt_qplib_set_sq_max_slot(qp->wqe_mode);
1111
+ if (rq->max_wqe) {
1112
+ rq->dbinfo.hwq = &rq->hwq;
1113
+ rq->dbinfo.xid = qp->id;
1114
+ rq->dbinfo.db = qp->dpi->dbr;
1115
+ rq->dbinfo.max_slot = bnxt_qplib_set_rq_max_slot(rq->wqe_size);
1116
+ }
1117
+ tbl_indx = map_qp_id_to_tbl_indx(qp->id, rcfw);
1118
+ rcfw->qp_tbl[tbl_indx].qp_id = qp->id;
1119
+ rcfw->qp_tbl[tbl_indx].qp_handle = (void *)qp;
10631120
10641121 return 0;
1065
-
10661122 fail:
1067
- if (qp->irrq.max_elements)
1068
- bnxt_qplib_free_hwq(res->pdev, &qp->irrq);
1123
+ bnxt_qplib_free_hwq(res, &qp->irrq);
10691124 fail_orrq:
1070
- if (qp->orrq.max_elements)
1071
- bnxt_qplib_free_hwq(res->pdev, &qp->orrq);
1072
-fail_buf_free:
1073
- bnxt_qplib_free_qp_hdr_buf(res, qp);
1074
-fail_rq:
1075
- bnxt_qplib_free_hwq(res->pdev, &rq->hwq);
1125
+ bnxt_qplib_free_hwq(res, &qp->orrq);
1126
+rq_swq:
10761127 kfree(rq->swq);
1077
-fail_sq:
1078
- bnxt_qplib_free_hwq(res->pdev, &sq->hwq);
1128
+fail_rq:
1129
+ bnxt_qplib_free_hwq(res, &rq->hwq);
1130
+sq_swq:
10791131 kfree(sq->swq);
1132
+fail_sq:
1133
+ bnxt_qplib_free_hwq(res, &sq->hwq);
10801134 exit:
10811135 return rc;
10821136 }
....@@ -1326,7 +1380,7 @@
13261380 }
13271381 }
13281382 if (i == res->sgid_tbl.max)
1329
- dev_warn(&res->pdev->dev, "QPLIB: SGID not found??");
1383
+ dev_warn(&res->pdev->dev, "SGID not found??\n");
13301384
13311385 qp->ah.hop_limit = sb->hop_limit;
13321386 qp->ah.traffic_class = sb->traffic_class;
....@@ -1362,12 +1416,11 @@
13621416 static void __clean_cq(struct bnxt_qplib_cq *cq, u64 qp)
13631417 {
13641418 struct bnxt_qplib_hwq *cq_hwq = &cq->hwq;
1365
- struct cq_base *hw_cqe, **hw_cqe_ptr;
1419
+ struct cq_base *hw_cqe;
13661420 int i;
13671421
13681422 for (i = 0; i < cq_hwq->max_elements; i++) {
1369
- hw_cqe_ptr = (struct cq_base **)cq_hwq->pbl_ptr;
1370
- hw_cqe = &hw_cqe_ptr[CQE_PG(i)][CQE_IDX(i)];
1423
+ hw_cqe = bnxt_qplib_get_qe(cq_hwq, i, NULL);
13711424 if (!CQE_CMP_VALID(hw_cqe, i, cq_hwq->max_elements))
13721425 continue;
13731426 /*
....@@ -1408,10 +1461,12 @@
14081461 struct cmdq_destroy_qp req;
14091462 struct creq_destroy_qp_resp resp;
14101463 u16 cmd_flags = 0;
1464
+ u32 tbl_indx;
14111465 int rc;
14121466
1413
- rcfw->qp_tbl[qp->id].qp_id = BNXT_QPLIB_QP_ID_INVALID;
1414
- rcfw->qp_tbl[qp->id].qp_handle = NULL;
1467
+ tbl_indx = map_qp_id_to_tbl_indx(qp->id, rcfw);
1468
+ rcfw->qp_tbl[tbl_indx].qp_id = BNXT_QPLIB_QP_ID_INVALID;
1469
+ rcfw->qp_tbl[tbl_indx].qp_handle = NULL;
14151470
14161471 RCFW_CMD_PREP(req, DESTROY_QP, cmd_flags);
14171472
....@@ -1419,8 +1474,8 @@
14191474 rc = bnxt_qplib_rcfw_send_message(rcfw, (void *)&req,
14201475 (void *)&resp, NULL, 0);
14211476 if (rc) {
1422
- rcfw->qp_tbl[qp->id].qp_id = qp->id;
1423
- rcfw->qp_tbl[qp->id].qp_handle = qp;
1477
+ rcfw->qp_tbl[tbl_indx].qp_id = qp->id;
1478
+ rcfw->qp_tbl[tbl_indx].qp_handle = qp;
14241479 return rc;
14251480 }
14261481
....@@ -1431,16 +1486,16 @@
14311486 struct bnxt_qplib_qp *qp)
14321487 {
14331488 bnxt_qplib_free_qp_hdr_buf(res, qp);
1434
- bnxt_qplib_free_hwq(res->pdev, &qp->sq.hwq);
1489
+ bnxt_qplib_free_hwq(res, &qp->sq.hwq);
14351490 kfree(qp->sq.swq);
14361491
1437
- bnxt_qplib_free_hwq(res->pdev, &qp->rq.hwq);
1492
+ bnxt_qplib_free_hwq(res, &qp->rq.hwq);
14381493 kfree(qp->rq.swq);
14391494
14401495 if (qp->irrq.max_elements)
1441
- bnxt_qplib_free_hwq(res->pdev, &qp->irrq);
1496
+ bnxt_qplib_free_hwq(res, &qp->irrq);
14421497 if (qp->orrq.max_elements)
1443
- bnxt_qplib_free_hwq(res->pdev, &qp->orrq);
1498
+ bnxt_qplib_free_hwq(res, &qp->orrq);
14441499
14451500 }
14461501
....@@ -1453,7 +1508,7 @@
14531508 memset(sge, 0, sizeof(*sge));
14541509
14551510 if (qp->sq_hdr_buf) {
1456
- sw_prod = HWQ_CMP(sq->hwq.prod, &sq->hwq);
1511
+ sw_prod = sq->swq_start;
14571512 sge->addr = (dma_addr_t)(qp->sq_hdr_buf_map +
14581513 sw_prod * qp->sq_hdr_buf_size);
14591514 sge->lkey = 0xFFFFFFFF;
....@@ -1467,7 +1522,7 @@
14671522 {
14681523 struct bnxt_qplib_q *rq = &qp->rq;
14691524
1470
- return HWQ_CMP(rq->hwq.prod, &rq->hwq);
1525
+ return rq->swq_start;
14711526 }
14721527
14731528 dma_addr_t bnxt_qplib_get_qp_buf_from_index(struct bnxt_qplib_qp *qp, u32 index)
....@@ -1484,7 +1539,7 @@
14841539 memset(sge, 0, sizeof(*sge));
14851540
14861541 if (qp->rq_hdr_buf) {
1487
- sw_prod = HWQ_CMP(rq->hwq.prod, &rq->hwq);
1542
+ sw_prod = rq->swq_start;
14881543 sge->addr = (dma_addr_t)(qp->rq_hdr_buf_map +
14891544 sw_prod * qp->rq_hdr_buf_size);
14901545 sge->lkey = 0xFFFFFFFF;
....@@ -1494,144 +1549,264 @@
14941549 return NULL;
14951550 }
14961551
1552
+static void bnxt_qplib_fill_psn_search(struct bnxt_qplib_qp *qp,
1553
+ struct bnxt_qplib_swqe *wqe,
1554
+ struct bnxt_qplib_swq *swq)
1555
+{
1556
+ struct sq_psn_search_ext *psns_ext;
1557
+ struct sq_psn_search *psns;
1558
+ u32 flg_npsn;
1559
+ u32 op_spsn;
1560
+
1561
+ if (!swq->psn_search)
1562
+ return;
1563
+ psns = swq->psn_search;
1564
+ psns_ext = swq->psn_ext;
1565
+
1566
+ op_spsn = ((swq->start_psn << SQ_PSN_SEARCH_START_PSN_SFT) &
1567
+ SQ_PSN_SEARCH_START_PSN_MASK);
1568
+ op_spsn |= ((wqe->type << SQ_PSN_SEARCH_OPCODE_SFT) &
1569
+ SQ_PSN_SEARCH_OPCODE_MASK);
1570
+ flg_npsn = ((swq->next_psn << SQ_PSN_SEARCH_NEXT_PSN_SFT) &
1571
+ SQ_PSN_SEARCH_NEXT_PSN_MASK);
1572
+
1573
+ if (bnxt_qplib_is_chip_gen_p5(qp->cctx)) {
1574
+ psns_ext->opcode_start_psn = cpu_to_le32(op_spsn);
1575
+ psns_ext->flags_next_psn = cpu_to_le32(flg_npsn);
1576
+ psns_ext->start_slot_idx = cpu_to_le16(swq->slot_idx);
1577
+ } else {
1578
+ psns->opcode_start_psn = cpu_to_le32(op_spsn);
1579
+ psns->flags_next_psn = cpu_to_le32(flg_npsn);
1580
+ }
1581
+}
1582
+
1583
+static int bnxt_qplib_put_inline(struct bnxt_qplib_qp *qp,
1584
+ struct bnxt_qplib_swqe *wqe,
1585
+ u16 *idx)
1586
+{
1587
+ struct bnxt_qplib_hwq *hwq;
1588
+ int len, t_len, offt;
1589
+ bool pull_dst = true;
1590
+ void *il_dst = NULL;
1591
+ void *il_src = NULL;
1592
+ int t_cplen, cplen;
1593
+ int indx;
1594
+
1595
+ hwq = &qp->sq.hwq;
1596
+ t_len = 0;
1597
+ for (indx = 0; indx < wqe->num_sge; indx++) {
1598
+ len = wqe->sg_list[indx].size;
1599
+ il_src = (void *)wqe->sg_list[indx].addr;
1600
+ t_len += len;
1601
+ if (t_len > qp->max_inline_data)
1602
+ goto bad;
1603
+ while (len) {
1604
+ if (pull_dst) {
1605
+ pull_dst = false;
1606
+ il_dst = bnxt_qplib_get_prod_qe(hwq, *idx);
1607
+ (*idx)++;
1608
+ t_cplen = 0;
1609
+ offt = 0;
1610
+ }
1611
+ cplen = min_t(int, len, sizeof(struct sq_sge));
1612
+ cplen = min_t(int, cplen,
1613
+ (sizeof(struct sq_sge) - offt));
1614
+ memcpy(il_dst, il_src, cplen);
1615
+ t_cplen += cplen;
1616
+ il_src += cplen;
1617
+ il_dst += cplen;
1618
+ offt += cplen;
1619
+ len -= cplen;
1620
+ if (t_cplen == sizeof(struct sq_sge))
1621
+ pull_dst = true;
1622
+ }
1623
+ }
1624
+
1625
+ return t_len;
1626
+bad:
1627
+ return -ENOMEM;
1628
+}
1629
+
1630
+static u32 bnxt_qplib_put_sges(struct bnxt_qplib_hwq *hwq,
1631
+ struct bnxt_qplib_sge *ssge,
1632
+ u16 nsge, u16 *idx)
1633
+{
1634
+ struct sq_sge *dsge;
1635
+ int indx, len = 0;
1636
+
1637
+ for (indx = 0; indx < nsge; indx++, (*idx)++) {
1638
+ dsge = bnxt_qplib_get_prod_qe(hwq, *idx);
1639
+ dsge->va_or_pa = cpu_to_le64(ssge[indx].addr);
1640
+ dsge->l_key = cpu_to_le32(ssge[indx].lkey);
1641
+ dsge->size = cpu_to_le32(ssge[indx].size);
1642
+ len += ssge[indx].size;
1643
+ }
1644
+
1645
+ return len;
1646
+}
1647
+
1648
+static u16 bnxt_qplib_required_slots(struct bnxt_qplib_qp *qp,
1649
+ struct bnxt_qplib_swqe *wqe,
1650
+ u16 *wqe_sz, u16 *qdf, u8 mode)
1651
+{
1652
+ u32 ilsize, bytes;
1653
+ u16 nsge;
1654
+ u16 slot;
1655
+
1656
+ nsge = wqe->num_sge;
1657
+ /* Adding sq_send_hdr is a misnomer, for rq also hdr size is same. */
1658
+ bytes = sizeof(struct sq_send_hdr) + nsge * sizeof(struct sq_sge);
1659
+ if (wqe->flags & BNXT_QPLIB_SWQE_FLAGS_INLINE) {
1660
+ ilsize = bnxt_qplib_calc_ilsize(wqe, qp->max_inline_data);
1661
+ bytes = ALIGN(ilsize, sizeof(struct sq_sge));
1662
+ bytes += sizeof(struct sq_send_hdr);
1663
+ }
1664
+
1665
+ *qdf = __xlate_qfd(qp->sq.q_full_delta, bytes);
1666
+ slot = bytes >> 4;
1667
+ *wqe_sz = slot;
1668
+ if (mode == BNXT_QPLIB_WQE_MODE_STATIC)
1669
+ slot = 8;
1670
+ return slot;
1671
+}
1672
+
1673
+static void bnxt_qplib_pull_psn_buff(struct bnxt_qplib_q *sq,
1674
+ struct bnxt_qplib_swq *swq)
1675
+{
1676
+ struct bnxt_qplib_hwq *hwq;
1677
+ u32 pg_num, pg_indx;
1678
+ void *buff;
1679
+ u32 tail;
1680
+
1681
+ hwq = &sq->hwq;
1682
+ if (!hwq->pad_pg)
1683
+ return;
1684
+ tail = swq->slot_idx / sq->dbinfo.max_slot;
1685
+ pg_num = (tail + hwq->pad_pgofft) / (PAGE_SIZE / hwq->pad_stride);
1686
+ pg_indx = (tail + hwq->pad_pgofft) % (PAGE_SIZE / hwq->pad_stride);
1687
+ buff = (void *)(hwq->pad_pg[pg_num] + pg_indx * hwq->pad_stride);
1688
+ swq->psn_ext = buff;
1689
+ swq->psn_search = buff;
1690
+}
1691
+
14971692 void bnxt_qplib_post_send_db(struct bnxt_qplib_qp *qp)
14981693 {
14991694 struct bnxt_qplib_q *sq = &qp->sq;
1500
- struct dbr_dbr db_msg = { 0 };
1501
- u32 sw_prod;
15021695
1503
- sw_prod = HWQ_CMP(sq->hwq.prod, &sq->hwq);
1504
-
1505
- db_msg.index = cpu_to_le32((sw_prod << DBR_DBR_INDEX_SFT) &
1506
- DBR_DBR_INDEX_MASK);
1507
- db_msg.type_xid =
1508
- cpu_to_le32(((qp->id << DBR_DBR_XID_SFT) & DBR_DBR_XID_MASK) |
1509
- DBR_DBR_TYPE_SQ);
1510
- /* Flush all the WQE writes to HW */
1511
- wmb();
1512
- __iowrite64_copy(qp->dpi->dbr, &db_msg, sizeof(db_msg) / sizeof(u64));
1696
+ bnxt_qplib_ring_prod_db(&sq->dbinfo, DBC_DBC_TYPE_SQ);
15131697 }
15141698
15151699 int bnxt_qplib_post_send(struct bnxt_qplib_qp *qp,
15161700 struct bnxt_qplib_swqe *wqe)
15171701 {
1518
- struct bnxt_qplib_q *sq = &qp->sq;
1519
- struct bnxt_qplib_swq *swq;
1520
- struct sq_send *hw_sq_send_hdr, **hw_sq_send_ptr;
1521
- struct sq_sge *hw_sge;
15221702 struct bnxt_qplib_nq_work *nq_work = NULL;
1523
- bool sch_handler = false;
1524
- u32 sw_prod;
1525
- u8 wqe_size16;
15261703 int i, rc = 0, data_len = 0, pkt_num = 0;
1704
+ struct bnxt_qplib_q *sq = &qp->sq;
1705
+ struct bnxt_qplib_hwq *hwq;
1706
+ struct bnxt_qplib_swq *swq;
1707
+ bool sch_handler = false;
1708
+ u16 wqe_sz, qdf = 0;
1709
+ void *base_hdr;
1710
+ void *ext_hdr;
15271711 __le32 temp32;
1712
+ u32 wqe_idx;
1713
+ u32 slots;
1714
+ u16 idx;
15281715
1529
- if (qp->state != CMDQ_MODIFY_QP_NEW_STATE_RTS) {
1530
- if (qp->state == CMDQ_MODIFY_QP_NEW_STATE_ERR) {
1531
- sch_handler = true;
1532
- dev_dbg(&sq->hwq.pdev->dev,
1533
- "%s Error QP. Scheduling for poll_cq\n",
1534
- __func__);
1535
- goto queue_err;
1536
- }
1716
+ hwq = &sq->hwq;
1717
+ if (qp->state != CMDQ_MODIFY_QP_NEW_STATE_RTS &&
1718
+ qp->state != CMDQ_MODIFY_QP_NEW_STATE_ERR) {
1719
+ dev_err(&hwq->pdev->dev,
1720
+ "QPLIB: FP: QP (0x%x) is in the 0x%x state",
1721
+ qp->id, qp->state);
1722
+ rc = -EINVAL;
1723
+ goto done;
15371724 }
15381725
1539
- if (bnxt_qplib_queue_full(sq)) {
1540
- dev_err(&sq->hwq.pdev->dev,
1541
- "QPLIB: prod = %#x cons = %#x qdepth = %#x delta = %#x",
1542
- sq->hwq.prod, sq->hwq.cons, sq->hwq.max_elements,
1543
- sq->q_full_delta);
1726
+ slots = bnxt_qplib_required_slots(qp, wqe, &wqe_sz, &qdf, qp->wqe_mode);
1727
+ if (bnxt_qplib_queue_full(sq, slots + qdf)) {
1728
+ dev_err(&hwq->pdev->dev,
1729
+ "prod = %#x cons = %#x qdepth = %#x delta = %#x\n",
1730
+ hwq->prod, hwq->cons, hwq->depth, sq->q_full_delta);
15441731 rc = -ENOMEM;
15451732 goto done;
15461733 }
1547
- sw_prod = HWQ_CMP(sq->hwq.prod, &sq->hwq);
1548
- swq = &sq->swq[sw_prod];
1734
+
1735
+ swq = bnxt_qplib_get_swqe(sq, &wqe_idx);
1736
+ bnxt_qplib_pull_psn_buff(sq, swq);
1737
+
1738
+ idx = 0;
1739
+ swq->slot_idx = hwq->prod;
1740
+ swq->slots = slots;
15491741 swq->wr_id = wqe->wr_id;
15501742 swq->type = wqe->type;
15511743 swq->flags = wqe->flags;
1744
+ swq->start_psn = sq->psn & BTH_PSN_MASK;
15521745 if (qp->sig_type)
15531746 swq->flags |= SQ_SEND_FLAGS_SIGNAL_COMP;
1554
- swq->start_psn = sq->psn & BTH_PSN_MASK;
15551747
1556
- hw_sq_send_ptr = (struct sq_send **)sq->hwq.pbl_ptr;
1557
- hw_sq_send_hdr = &hw_sq_send_ptr[get_sqe_pg(sw_prod)]
1558
- [get_sqe_idx(sw_prod)];
1559
-
1560
- memset(hw_sq_send_hdr, 0, BNXT_QPLIB_MAX_SQE_ENTRY_SIZE);
1561
-
1562
- if (wqe->flags & BNXT_QPLIB_SWQE_FLAGS_INLINE) {
1563
- /* Copy the inline data */
1564
- if (wqe->inline_len > BNXT_QPLIB_SWQE_MAX_INLINE_LENGTH) {
1565
- dev_warn(&sq->hwq.pdev->dev,
1566
- "QPLIB: Inline data length > 96 detected");
1567
- data_len = BNXT_QPLIB_SWQE_MAX_INLINE_LENGTH;
1568
- } else {
1569
- data_len = wqe->inline_len;
1570
- }
1571
- memcpy(hw_sq_send_hdr->data, wqe->inline_data, data_len);
1572
- wqe_size16 = (data_len + 15) >> 4;
1573
- } else {
1574
- for (i = 0, hw_sge = (struct sq_sge *)hw_sq_send_hdr->data;
1575
- i < wqe->num_sge; i++, hw_sge++) {
1576
- hw_sge->va_or_pa = cpu_to_le64(wqe->sg_list[i].addr);
1577
- hw_sge->l_key = cpu_to_le32(wqe->sg_list[i].lkey);
1578
- hw_sge->size = cpu_to_le32(wqe->sg_list[i].size);
1579
- data_len += wqe->sg_list[i].size;
1580
- }
1581
- /* Each SGE entry = 1 WQE size16 */
1582
- wqe_size16 = wqe->num_sge;
1583
- /* HW requires wqe size has room for atleast one SGE even if
1584
- * none was supplied by ULP
1585
- */
1586
- if (!wqe->num_sge)
1587
- wqe_size16++;
1748
+ if (qp->state == CMDQ_MODIFY_QP_NEW_STATE_ERR) {
1749
+ sch_handler = true;
1750
+ dev_dbg(&hwq->pdev->dev,
1751
+ "%s Error QP. Scheduling for poll_cq\n", __func__);
1752
+ goto queue_err;
15881753 }
15891754
1755
+ base_hdr = bnxt_qplib_get_prod_qe(hwq, idx++);
1756
+ ext_hdr = bnxt_qplib_get_prod_qe(hwq, idx++);
1757
+ memset(base_hdr, 0, sizeof(struct sq_sge));
1758
+ memset(ext_hdr, 0, sizeof(struct sq_sge));
1759
+
1760
+ if (wqe->flags & BNXT_QPLIB_SWQE_FLAGS_INLINE)
1761
+ /* Copy the inline data */
1762
+ data_len = bnxt_qplib_put_inline(qp, wqe, &idx);
1763
+ else
1764
+ data_len = bnxt_qplib_put_sges(hwq, wqe->sg_list, wqe->num_sge,
1765
+ &idx);
1766
+ if (data_len < 0)
1767
+ goto queue_err;
15901768 /* Specifics */
15911769 switch (wqe->type) {
15921770 case BNXT_QPLIB_SWQE_TYPE_SEND:
15931771 if (qp->type == CMDQ_CREATE_QP1_TYPE_GSI) {
1772
+ struct sq_send_raweth_qp1_hdr *sqe = base_hdr;
1773
+ struct sq_raw_ext_hdr *ext_sqe = ext_hdr;
15941774 /* Assemble info for Raw Ethertype QPs */
1595
- struct sq_send_raweth_qp1 *sqe =
1596
- (struct sq_send_raweth_qp1 *)hw_sq_send_hdr;
15971775
15981776 sqe->wqe_type = wqe->type;
15991777 sqe->flags = wqe->flags;
1600
- sqe->wqe_size = wqe_size16 +
1601
- ((offsetof(typeof(*sqe), data) + 15) >> 4);
1778
+ sqe->wqe_size = wqe_sz;
16021779 sqe->cfa_action = cpu_to_le16(wqe->rawqp1.cfa_action);
16031780 sqe->lflags = cpu_to_le16(wqe->rawqp1.lflags);
16041781 sqe->length = cpu_to_le32(data_len);
1605
- sqe->cfa_meta = cpu_to_le32((wqe->rawqp1.cfa_meta &
1782
+ ext_sqe->cfa_meta = cpu_to_le32((wqe->rawqp1.cfa_meta &
16061783 SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_MASK) <<
16071784 SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_SFT);
16081785
16091786 break;
16101787 }
1611
- /* fall thru */
1788
+ fallthrough;
16121789 case BNXT_QPLIB_SWQE_TYPE_SEND_WITH_IMM:
16131790 case BNXT_QPLIB_SWQE_TYPE_SEND_WITH_INV:
16141791 {
1615
- struct sq_send *sqe = (struct sq_send *)hw_sq_send_hdr;
1792
+ struct sq_ud_ext_hdr *ext_sqe = ext_hdr;
1793
+ struct sq_send_hdr *sqe = base_hdr;
16161794
16171795 sqe->wqe_type = wqe->type;
16181796 sqe->flags = wqe->flags;
1619
- sqe->wqe_size = wqe_size16 +
1620
- ((offsetof(typeof(*sqe), data) + 15) >> 4);
1621
- sqe->inv_key_or_imm_data = cpu_to_le32(
1622
- wqe->send.inv_key);
1623
- if (qp->type == CMDQ_CREATE_QP_TYPE_UD) {
1797
+ sqe->wqe_size = wqe_sz;
1798
+ sqe->inv_key_or_imm_data = cpu_to_le32(wqe->send.inv_key);
1799
+ if (qp->type == CMDQ_CREATE_QP_TYPE_UD ||
1800
+ qp->type == CMDQ_CREATE_QP_TYPE_GSI) {
16241801 sqe->q_key = cpu_to_le32(wqe->send.q_key);
1625
- sqe->dst_qp = cpu_to_le32(
1626
- wqe->send.dst_qp & SQ_SEND_DST_QP_MASK);
16271802 sqe->length = cpu_to_le32(data_len);
1628
- sqe->avid = cpu_to_le32(wqe->send.avid &
1629
- SQ_SEND_AVID_MASK);
16301803 sq->psn = (sq->psn + 1) & BTH_PSN_MASK;
1804
+ ext_sqe->dst_qp = cpu_to_le32(wqe->send.dst_qp &
1805
+ SQ_SEND_DST_QP_MASK);
1806
+ ext_sqe->avid = cpu_to_le32(wqe->send.avid &
1807
+ SQ_SEND_AVID_MASK);
16311808 } else {
16321809 sqe->length = cpu_to_le32(data_len);
1633
- sqe->dst_qp = 0;
1634
- sqe->avid = 0;
16351810 if (qp->mtu)
16361811 pkt_num = (data_len + qp->mtu - 1) / qp->mtu;
16371812 if (!pkt_num)
....@@ -1644,16 +1819,16 @@
16441819 case BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE_WITH_IMM:
16451820 case BNXT_QPLIB_SWQE_TYPE_RDMA_READ:
16461821 {
1647
- struct sq_rdma *sqe = (struct sq_rdma *)hw_sq_send_hdr;
1822
+ struct sq_rdma_ext_hdr *ext_sqe = ext_hdr;
1823
+ struct sq_rdma_hdr *sqe = base_hdr;
16481824
16491825 sqe->wqe_type = wqe->type;
16501826 sqe->flags = wqe->flags;
1651
- sqe->wqe_size = wqe_size16 +
1652
- ((offsetof(typeof(*sqe), data) + 15) >> 4);
1827
+ sqe->wqe_size = wqe_sz;
16531828 sqe->imm_data = cpu_to_le32(wqe->rdma.inv_key);
16541829 sqe->length = cpu_to_le32((u32)data_len);
1655
- sqe->remote_va = cpu_to_le64(wqe->rdma.remote_va);
1656
- sqe->remote_key = cpu_to_le32(wqe->rdma.r_key);
1830
+ ext_sqe->remote_va = cpu_to_le64(wqe->rdma.remote_va);
1831
+ ext_sqe->remote_key = cpu_to_le32(wqe->rdma.r_key);
16571832 if (qp->mtu)
16581833 pkt_num = (data_len + qp->mtu - 1) / qp->mtu;
16591834 if (!pkt_num)
....@@ -1664,14 +1839,15 @@
16641839 case BNXT_QPLIB_SWQE_TYPE_ATOMIC_CMP_AND_SWP:
16651840 case BNXT_QPLIB_SWQE_TYPE_ATOMIC_FETCH_AND_ADD:
16661841 {
1667
- struct sq_atomic *sqe = (struct sq_atomic *)hw_sq_send_hdr;
1842
+ struct sq_atomic_ext_hdr *ext_sqe = ext_hdr;
1843
+ struct sq_atomic_hdr *sqe = base_hdr;
16681844
16691845 sqe->wqe_type = wqe->type;
16701846 sqe->flags = wqe->flags;
16711847 sqe->remote_key = cpu_to_le32(wqe->atomic.r_key);
16721848 sqe->remote_va = cpu_to_le64(wqe->atomic.remote_va);
1673
- sqe->swap_data = cpu_to_le64(wqe->atomic.swap_data);
1674
- sqe->cmp_data = cpu_to_le64(wqe->atomic.cmp_data);
1849
+ ext_sqe->swap_data = cpu_to_le64(wqe->atomic.swap_data);
1850
+ ext_sqe->cmp_data = cpu_to_le64(wqe->atomic.cmp_data);
16751851 if (qp->mtu)
16761852 pkt_num = (data_len + qp->mtu - 1) / qp->mtu;
16771853 if (!pkt_num)
....@@ -1681,8 +1857,7 @@
16811857 }
16821858 case BNXT_QPLIB_SWQE_TYPE_LOCAL_INV:
16831859 {
1684
- struct sq_localinvalidate *sqe =
1685
- (struct sq_localinvalidate *)hw_sq_send_hdr;
1860
+ struct sq_localinvalidate *sqe = base_hdr;
16861861
16871862 sqe->wqe_type = wqe->type;
16881863 sqe->flags = wqe->flags;
....@@ -1692,7 +1867,8 @@
16921867 }
16931868 case BNXT_QPLIB_SWQE_TYPE_FAST_REG_MR:
16941869 {
1695
- struct sq_fr_pmr *sqe = (struct sq_fr_pmr *)hw_sq_send_hdr;
1870
+ struct sq_fr_pmr_ext_hdr *ext_sqe = ext_hdr;
1871
+ struct sq_fr_pmr_hdr *sqe = base_hdr;
16961872
16971873 sqe->wqe_type = wqe->type;
16981874 sqe->flags = wqe->flags;
....@@ -1716,14 +1892,15 @@
17161892 wqe->frmr.pbl_ptr[i] = cpu_to_le64(
17171893 wqe->frmr.page_list[i] |
17181894 PTU_PTE_VALID);
1719
- sqe->pblptr = cpu_to_le64(wqe->frmr.pbl_dma_ptr);
1720
- sqe->va = cpu_to_le64(wqe->frmr.va);
1895
+ ext_sqe->pblptr = cpu_to_le64(wqe->frmr.pbl_dma_ptr);
1896
+ ext_sqe->va = cpu_to_le64(wqe->frmr.va);
17211897
17221898 break;
17231899 }
17241900 case BNXT_QPLIB_SWQE_TYPE_BIND_MW:
17251901 {
1726
- struct sq_bind *sqe = (struct sq_bind *)hw_sq_send_hdr;
1902
+ struct sq_bind_ext_hdr *ext_sqe = ext_hdr;
1903
+ struct sq_bind_hdr *sqe = base_hdr;
17271904
17281905 sqe->wqe_type = wqe->type;
17291906 sqe->flags = wqe->flags;
....@@ -1732,9 +1909,8 @@
17321909 (wqe->bind.zero_based ? SQ_BIND_ZERO_BASED : 0);
17331910 sqe->parent_l_key = cpu_to_le32(wqe->bind.parent_l_key);
17341911 sqe->l_key = cpu_to_le32(wqe->bind.r_key);
1735
- sqe->va = cpu_to_le64(wqe->bind.va);
1736
- temp32 = cpu_to_le32(wqe->bind.length);
1737
- memcpy(&sqe->length, &temp32, sizeof(wqe->bind.length));
1912
+ ext_sqe->va = cpu_to_le64(wqe->bind.va);
1913
+ ext_sqe->length_lo = cpu_to_le32(wqe->bind.length);
17381914 break;
17391915 }
17401916 default:
....@@ -1743,31 +1919,11 @@
17431919 goto done;
17441920 }
17451921 swq->next_psn = sq->psn & BTH_PSN_MASK;
1746
- if (swq->psn_search) {
1747
- swq->psn_search->opcode_start_psn = cpu_to_le32(
1748
- ((swq->start_psn << SQ_PSN_SEARCH_START_PSN_SFT) &
1749
- SQ_PSN_SEARCH_START_PSN_MASK) |
1750
- ((wqe->type << SQ_PSN_SEARCH_OPCODE_SFT) &
1751
- SQ_PSN_SEARCH_OPCODE_MASK));
1752
- swq->psn_search->flags_next_psn = cpu_to_le32(
1753
- ((swq->next_psn << SQ_PSN_SEARCH_NEXT_PSN_SFT) &
1754
- SQ_PSN_SEARCH_NEXT_PSN_MASK));
1755
- }
1922
+ bnxt_qplib_fill_psn_search(qp, wqe, swq);
17561923 queue_err:
1757
- if (sch_handler) {
1758
- /* Store the ULP info in the software structures */
1759
- sw_prod = HWQ_CMP(sq->hwq.prod, &sq->hwq);
1760
- swq = &sq->swq[sw_prod];
1761
- swq->wr_id = wqe->wr_id;
1762
- swq->type = wqe->type;
1763
- swq->flags = wqe->flags;
1764
- if (qp->sig_type)
1765
- swq->flags |= SQ_SEND_FLAGS_SIGNAL_COMP;
1766
- swq->start_psn = sq->psn & BTH_PSN_MASK;
1767
- }
1768
- sq->hwq.prod++;
1924
+ bnxt_qplib_swq_mod_start(sq, wqe_idx);
1925
+ bnxt_qplib_hwq_incr_prod(hwq, swq->slots);
17691926 qp->wqe_cnt++;
1770
-
17711927 done:
17721928 if (sch_handler) {
17731929 nq_work = kzalloc(sizeof(*nq_work), GFP_ATOMIC);
....@@ -1777,8 +1933,8 @@
17771933 INIT_WORK(&nq_work->work, bnxt_qpn_cqn_sched_task);
17781934 queue_work(qp->scq->nq->cqn_wq, &nq_work->work);
17791935 } else {
1780
- dev_err(&sq->hwq.pdev->dev,
1781
- "QPLIB: FP: Failed to allocate SQ nq_work!");
1936
+ dev_err(&hwq->pdev->dev,
1937
+ "FP: Failed to allocate SQ nq_work!\n");
17821938 rc = -ENOMEM;
17831939 }
17841940 }
....@@ -1788,81 +1944,74 @@
17881944 void bnxt_qplib_post_recv_db(struct bnxt_qplib_qp *qp)
17891945 {
17901946 struct bnxt_qplib_q *rq = &qp->rq;
1791
- struct dbr_dbr db_msg = { 0 };
1792
- u32 sw_prod;
17931947
1794
- sw_prod = HWQ_CMP(rq->hwq.prod, &rq->hwq);
1795
- db_msg.index = cpu_to_le32((sw_prod << DBR_DBR_INDEX_SFT) &
1796
- DBR_DBR_INDEX_MASK);
1797
- db_msg.type_xid =
1798
- cpu_to_le32(((qp->id << DBR_DBR_XID_SFT) & DBR_DBR_XID_MASK) |
1799
- DBR_DBR_TYPE_RQ);
1800
-
1801
- /* Flush the writes to HW Rx WQE before the ringing Rx DB */
1802
- wmb();
1803
- __iowrite64_copy(qp->dpi->dbr, &db_msg, sizeof(db_msg) / sizeof(u64));
1948
+ bnxt_qplib_ring_prod_db(&rq->dbinfo, DBC_DBC_TYPE_RQ);
18041949 }
18051950
18061951 int bnxt_qplib_post_recv(struct bnxt_qplib_qp *qp,
18071952 struct bnxt_qplib_swqe *wqe)
18081953 {
1809
- struct bnxt_qplib_q *rq = &qp->rq;
1810
- struct rq_wqe *rqe, **rqe_ptr;
1811
- struct sq_sge *hw_sge;
18121954 struct bnxt_qplib_nq_work *nq_work = NULL;
1955
+ struct bnxt_qplib_q *rq = &qp->rq;
1956
+ struct rq_wqe_hdr *base_hdr;
1957
+ struct rq_ext_hdr *ext_hdr;
1958
+ struct bnxt_qplib_hwq *hwq;
1959
+ struct bnxt_qplib_swq *swq;
18131960 bool sch_handler = false;
1814
- u32 sw_prod;
1815
- int i, rc = 0;
1961
+ u16 wqe_sz, idx;
1962
+ u32 wqe_idx;
1963
+ int rc = 0;
18161964
1817
- if (qp->state == CMDQ_MODIFY_QP_NEW_STATE_ERR) {
1818
- sch_handler = true;
1819
- dev_dbg(&rq->hwq.pdev->dev,
1820
- "%s Error QP. Scheduling for poll_cq\n",
1821
- __func__);
1822
- goto queue_err;
1823
- }
1824
- if (bnxt_qplib_queue_full(rq)) {
1825
- dev_err(&rq->hwq.pdev->dev,
1826
- "QPLIB: FP: QP (0x%x) RQ is full!", qp->id);
1965
+ hwq = &rq->hwq;
1966
+ if (qp->state == CMDQ_MODIFY_QP_NEW_STATE_RESET) {
1967
+ dev_err(&hwq->pdev->dev,
1968
+ "QPLIB: FP: QP (0x%x) is in the 0x%x state",
1969
+ qp->id, qp->state);
18271970 rc = -EINVAL;
18281971 goto done;
18291972 }
1830
- sw_prod = HWQ_CMP(rq->hwq.prod, &rq->hwq);
1831
- rq->swq[sw_prod].wr_id = wqe->wr_id;
18321973
1833
- rqe_ptr = (struct rq_wqe **)rq->hwq.pbl_ptr;
1834
- rqe = &rqe_ptr[RQE_PG(sw_prod)][RQE_IDX(sw_prod)];
1835
-
1836
- memset(rqe, 0, BNXT_QPLIB_MAX_RQE_ENTRY_SIZE);
1837
-
1838
- /* Calculate wqe_size16 and data_len */
1839
- for (i = 0, hw_sge = (struct sq_sge *)rqe->data;
1840
- i < wqe->num_sge; i++, hw_sge++) {
1841
- hw_sge->va_or_pa = cpu_to_le64(wqe->sg_list[i].addr);
1842
- hw_sge->l_key = cpu_to_le32(wqe->sg_list[i].lkey);
1843
- hw_sge->size = cpu_to_le32(wqe->sg_list[i].size);
1974
+ if (bnxt_qplib_queue_full(rq, rq->dbinfo.max_slot)) {
1975
+ dev_err(&hwq->pdev->dev,
1976
+ "FP: QP (0x%x) RQ is full!\n", qp->id);
1977
+ rc = -EINVAL;
1978
+ goto done;
18441979 }
1845
- rqe->wqe_type = wqe->type;
1846
- rqe->flags = wqe->flags;
1847
- rqe->wqe_size = wqe->num_sge +
1848
- ((offsetof(typeof(*rqe), data) + 15) >> 4);
1849
- /* HW requires wqe size has room for atleast one SGE even if none
1850
- * was supplied by ULP
1851
- */
1852
- if (!wqe->num_sge)
1853
- rqe->wqe_size++;
18541980
1855
- /* Supply the rqe->wr_id index to the wr_id_tbl for now */
1856
- rqe->wr_id[0] = cpu_to_le32(sw_prod);
1981
+ swq = bnxt_qplib_get_swqe(rq, &wqe_idx);
1982
+ swq->wr_id = wqe->wr_id;
1983
+ swq->slots = rq->dbinfo.max_slot;
18571984
1985
+ if (qp->state == CMDQ_MODIFY_QP_NEW_STATE_ERR) {
1986
+ sch_handler = true;
1987
+ dev_dbg(&hwq->pdev->dev,
1988
+ "%s: Error QP. Scheduling for poll_cq\n", __func__);
1989
+ goto queue_err;
1990
+ }
1991
+
1992
+ idx = 0;
1993
+ base_hdr = bnxt_qplib_get_prod_qe(hwq, idx++);
1994
+ ext_hdr = bnxt_qplib_get_prod_qe(hwq, idx++);
1995
+ memset(base_hdr, 0, sizeof(struct sq_sge));
1996
+ memset(ext_hdr, 0, sizeof(struct sq_sge));
1997
+ wqe_sz = (sizeof(struct rq_wqe_hdr) +
1998
+ wqe->num_sge * sizeof(struct sq_sge)) >> 4;
1999
+ bnxt_qplib_put_sges(hwq, wqe->sg_list, wqe->num_sge, &idx);
2000
+ if (!wqe->num_sge) {
2001
+ struct sq_sge *sge;
2002
+
2003
+ sge = bnxt_qplib_get_prod_qe(hwq, idx++);
2004
+ sge->size = 0;
2005
+ wqe_sz++;
2006
+ }
2007
+ base_hdr->wqe_type = wqe->type;
2008
+ base_hdr->flags = wqe->flags;
2009
+ base_hdr->wqe_size = wqe_sz;
2010
+ base_hdr->wr_id[0] = cpu_to_le32(wqe_idx);
18582011 queue_err:
1859
- if (sch_handler) {
1860
- /* Store the ULP info in the software structures */
1861
- sw_prod = HWQ_CMP(rq->hwq.prod, &rq->hwq);
1862
- rq->swq[sw_prod].wr_id = wqe->wr_id;
1863
- }
1864
-
1865
- rq->hwq.prod++;
2012
+ bnxt_qplib_swq_mod_start(rq, wqe_idx);
2013
+ bnxt_qplib_hwq_incr_prod(hwq, swq->slots);
2014
+done:
18662015 if (sch_handler) {
18672016 nq_work = kzalloc(sizeof(*nq_work), GFP_ATOMIC);
18682017 if (nq_work) {
....@@ -1871,62 +2020,33 @@
18712020 INIT_WORK(&nq_work->work, bnxt_qpn_cqn_sched_task);
18722021 queue_work(qp->rcq->nq->cqn_wq, &nq_work->work);
18732022 } else {
1874
- dev_err(&rq->hwq.pdev->dev,
1875
- "QPLIB: FP: Failed to allocate RQ nq_work!");
2023
+ dev_err(&hwq->pdev->dev,
2024
+ "FP: Failed to allocate RQ nq_work!\n");
18762025 rc = -ENOMEM;
18772026 }
18782027 }
1879
-done:
2028
+
18802029 return rc;
18812030 }
18822031
18832032 /* CQ */
1884
-
1885
-/* Spinlock must be held */
1886
-static void bnxt_qplib_arm_cq_enable(struct bnxt_qplib_cq *cq)
1887
-{
1888
- struct dbr_dbr db_msg = { 0 };
1889
-
1890
- db_msg.type_xid =
1891
- cpu_to_le32(((cq->id << DBR_DBR_XID_SFT) & DBR_DBR_XID_MASK) |
1892
- DBR_DBR_TYPE_CQ_ARMENA);
1893
- /* Flush memory writes before enabling the CQ */
1894
- wmb();
1895
- __iowrite64_copy(cq->dbr_base, &db_msg, sizeof(db_msg) / sizeof(u64));
1896
-}
1897
-
1898
-static void bnxt_qplib_arm_cq(struct bnxt_qplib_cq *cq, u32 arm_type)
1899
-{
1900
- struct bnxt_qplib_hwq *cq_hwq = &cq->hwq;
1901
- struct dbr_dbr db_msg = { 0 };
1902
- u32 sw_cons;
1903
-
1904
- /* Ring DB */
1905
- sw_cons = HWQ_CMP(cq_hwq->cons, cq_hwq);
1906
- db_msg.index = cpu_to_le32((sw_cons << DBR_DBR_INDEX_SFT) &
1907
- DBR_DBR_INDEX_MASK);
1908
- db_msg.type_xid =
1909
- cpu_to_le32(((cq->id << DBR_DBR_XID_SFT) & DBR_DBR_XID_MASK) |
1910
- arm_type);
1911
- /* flush memory writes before arming the CQ */
1912
- wmb();
1913
- __iowrite64_copy(cq->dpi->dbr, &db_msg, sizeof(db_msg) / sizeof(u64));
1914
-}
1915
-
19162033 int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
19172034 {
19182035 struct bnxt_qplib_rcfw *rcfw = res->rcfw;
1919
- struct cmdq_create_cq req;
2036
+ struct bnxt_qplib_hwq_attr hwq_attr = {};
19202037 struct creq_create_cq_resp resp;
19212038 struct bnxt_qplib_pbl *pbl;
2039
+ struct cmdq_create_cq req;
19222040 u16 cmd_flags = 0;
2041
+ u32 pg_sz_lvl;
19232042 int rc;
19242043
1925
- cq->hwq.max_elements = cq->max_wqe;
1926
- rc = bnxt_qplib_alloc_init_hwq(res->pdev, &cq->hwq, cq->sghead,
1927
- cq->nmap, &cq->hwq.max_elements,
1928
- BNXT_QPLIB_MAX_CQE_ENTRY_SIZE, 0,
1929
- PAGE_SIZE, HWQ_TYPE_QUEUE);
2044
+ hwq_attr.res = res;
2045
+ hwq_attr.depth = cq->max_wqe;
2046
+ hwq_attr.stride = sizeof(struct cq_base);
2047
+ hwq_attr.type = HWQ_TYPE_QUEUE;
2048
+ hwq_attr.sginfo = &cq->sg_info;
2049
+ rc = bnxt_qplib_alloc_init_hwq(&cq->hwq, &hwq_attr);
19302050 if (rc)
19312051 goto exit;
19322052
....@@ -1934,27 +2054,18 @@
19342054
19352055 if (!cq->dpi) {
19362056 dev_err(&rcfw->pdev->dev,
1937
- "QPLIB: FP: CREATE_CQ failed due to NULL DPI");
2057
+ "FP: CREATE_CQ failed due to NULL DPI\n");
19382058 return -EINVAL;
19392059 }
19402060 req.dpi = cpu_to_le32(cq->dpi->dpi);
19412061 req.cq_handle = cpu_to_le64(cq->cq_handle);
1942
-
19432062 req.cq_size = cpu_to_le32(cq->hwq.max_elements);
19442063 pbl = &cq->hwq.pbl[PBL_LVL_0];
1945
- req.pg_size_lvl = cpu_to_le32(
1946
- ((cq->hwq.level & CMDQ_CREATE_CQ_LVL_MASK) <<
1947
- CMDQ_CREATE_CQ_LVL_SFT) |
1948
- (pbl->pg_size == ROCE_PG_SIZE_4K ? CMDQ_CREATE_CQ_PG_SIZE_PG_4K :
1949
- pbl->pg_size == ROCE_PG_SIZE_8K ? CMDQ_CREATE_CQ_PG_SIZE_PG_8K :
1950
- pbl->pg_size == ROCE_PG_SIZE_64K ? CMDQ_CREATE_CQ_PG_SIZE_PG_64K :
1951
- pbl->pg_size == ROCE_PG_SIZE_2M ? CMDQ_CREATE_CQ_PG_SIZE_PG_2M :
1952
- pbl->pg_size == ROCE_PG_SIZE_8M ? CMDQ_CREATE_CQ_PG_SIZE_PG_8M :
1953
- pbl->pg_size == ROCE_PG_SIZE_1G ? CMDQ_CREATE_CQ_PG_SIZE_PG_1G :
1954
- CMDQ_CREATE_CQ_PG_SIZE_PG_4K));
1955
-
2064
+ pg_sz_lvl = (bnxt_qplib_base_pg_size(&cq->hwq) <<
2065
+ CMDQ_CREATE_CQ_PG_SIZE_SFT);
2066
+ pg_sz_lvl |= (cq->hwq.level & CMDQ_CREATE_CQ_LVL_MASK);
2067
+ req.pg_size_lvl = cpu_to_le32(pg_sz_lvl);
19562068 req.pbl = cpu_to_le64(pbl->pg_map_arr[0]);
1957
-
19582069 req.cq_fco_cnq_id = cpu_to_le32(
19592070 (cq->cnq_hw_ring_id & CMDQ_CREATE_CQ_CNQ_ID_MASK) <<
19602071 CMDQ_CREATE_CQ_CNQ_ID_SFT);
....@@ -1965,7 +2076,6 @@
19652076 goto fail;
19662077
19672078 cq->id = le32_to_cpu(resp.xid);
1968
- cq->dbr_base = res->dpi_tbl.dbr_bar_reg_iomem;
19692079 cq->period = BNXT_QPLIB_QUEUE_START_PERIOD;
19702080 init_waitqueue_head(&cq->waitq);
19712081 INIT_LIST_HEAD(&cq->sqf_head);
....@@ -1973,11 +2083,17 @@
19732083 spin_lock_init(&cq->compl_lock);
19742084 spin_lock_init(&cq->flush_lock);
19752085
1976
- bnxt_qplib_arm_cq_enable(cq);
2086
+ cq->dbinfo.hwq = &cq->hwq;
2087
+ cq->dbinfo.xid = cq->id;
2088
+ cq->dbinfo.db = cq->dpi->dbr;
2089
+ cq->dbinfo.priv_db = res->dpi_tbl.dbr_bar_reg_iomem;
2090
+
2091
+ bnxt_qplib_armen_db(&cq->dbinfo, DBC_DBC_TYPE_CQ_ARMENA);
2092
+
19772093 return 0;
19782094
19792095 fail:
1980
- bnxt_qplib_free_hwq(res->pdev, &cq->hwq);
2096
+ bnxt_qplib_free_hwq(res, &cq->hwq);
19812097 exit:
19822098 return rc;
19832099 }
....@@ -1987,6 +2103,7 @@
19872103 struct bnxt_qplib_rcfw *rcfw = res->rcfw;
19882104 struct cmdq_destroy_cq req;
19892105 struct creq_destroy_cq_resp resp;
2106
+ u16 total_cnq_events;
19902107 u16 cmd_flags = 0;
19912108 int rc;
19922109
....@@ -1997,27 +2114,28 @@
19972114 (void *)&resp, NULL, 0);
19982115 if (rc)
19992116 return rc;
2000
- bnxt_qplib_free_hwq(res->pdev, &cq->hwq);
2117
+ total_cnq_events = le16_to_cpu(resp.total_cnq_events);
2118
+ __wait_for_all_nqes(cq, total_cnq_events);
2119
+ bnxt_qplib_free_hwq(res, &cq->hwq);
20012120 return 0;
20022121 }
20032122
20042123 static int __flush_sq(struct bnxt_qplib_q *sq, struct bnxt_qplib_qp *qp,
20052124 struct bnxt_qplib_cqe **pcqe, int *budget)
20062125 {
2007
- u32 sw_prod, sw_cons;
20082126 struct bnxt_qplib_cqe *cqe;
2127
+ u32 start, last;
20092128 int rc = 0;
20102129
20112130 /* Now complete all outstanding SQEs with FLUSHED_ERR */
2012
- sw_prod = HWQ_CMP(sq->hwq.prod, &sq->hwq);
2131
+ start = sq->swq_start;
20132132 cqe = *pcqe;
20142133 while (*budget) {
2015
- sw_cons = HWQ_CMP(sq->hwq.cons, &sq->hwq);
2016
- if (sw_cons == sw_prod) {
2134
+ last = sq->swq_last;
2135
+ if (start == last)
20172136 break;
2018
- }
20192137 /* Skip the FENCE WQE completions */
2020
- if (sq->swq[sw_cons].wr_id == BNXT_QPLIB_FENCE_WRID) {
2138
+ if (sq->swq[last].wr_id == BNXT_QPLIB_FENCE_WRID) {
20212139 bnxt_qplib_cancel_phantom_processing(qp);
20222140 goto skip_compl;
20232141 }
....@@ -2025,16 +2143,17 @@
20252143 cqe->status = CQ_REQ_STATUS_WORK_REQUEST_FLUSHED_ERR;
20262144 cqe->opcode = CQ_BASE_CQE_TYPE_REQ;
20272145 cqe->qp_handle = (u64)(unsigned long)qp;
2028
- cqe->wr_id = sq->swq[sw_cons].wr_id;
2146
+ cqe->wr_id = sq->swq[last].wr_id;
20292147 cqe->src_qp = qp->id;
2030
- cqe->type = sq->swq[sw_cons].type;
2148
+ cqe->type = sq->swq[last].type;
20312149 cqe++;
20322150 (*budget)--;
20332151 skip_compl:
2034
- sq->hwq.cons++;
2152
+ bnxt_qplib_hwq_incr_cons(&sq->hwq, sq->swq[last].slots);
2153
+ sq->swq_last = sq->swq[last].next_idx;
20352154 }
20362155 *pcqe = cqe;
2037
- if (!(*budget) && HWQ_CMP(sq->hwq.cons, &sq->hwq) != sw_prod)
2156
+ if (!(*budget) && sq->swq_last != start)
20382157 /* Out of budget */
20392158 rc = -EAGAIN;
20402159
....@@ -2045,9 +2164,9 @@
20452164 struct bnxt_qplib_cqe **pcqe, int *budget)
20462165 {
20472166 struct bnxt_qplib_cqe *cqe;
2048
- u32 sw_prod, sw_cons;
2049
- int rc = 0;
2167
+ u32 start, last;
20502168 int opcode = 0;
2169
+ int rc = 0;
20512170
20522171 switch (qp->type) {
20532172 case CMDQ_CREATE_QP1_TYPE_GSI:
....@@ -2057,29 +2176,31 @@
20572176 opcode = CQ_BASE_CQE_TYPE_RES_RC;
20582177 break;
20592178 case CMDQ_CREATE_QP_TYPE_UD:
2179
+ case CMDQ_CREATE_QP_TYPE_GSI:
20602180 opcode = CQ_BASE_CQE_TYPE_RES_UD;
20612181 break;
20622182 }
20632183
20642184 /* Flush the rest of the RQ */
2065
- sw_prod = HWQ_CMP(rq->hwq.prod, &rq->hwq);
2185
+ start = rq->swq_start;
20662186 cqe = *pcqe;
20672187 while (*budget) {
2068
- sw_cons = HWQ_CMP(rq->hwq.cons, &rq->hwq);
2069
- if (sw_cons == sw_prod)
2188
+ last = rq->swq_last;
2189
+ if (last == start)
20702190 break;
20712191 memset(cqe, 0, sizeof(*cqe));
20722192 cqe->status =
20732193 CQ_RES_RC_STATUS_WORK_REQUEST_FLUSHED_ERR;
20742194 cqe->opcode = opcode;
20752195 cqe->qp_handle = (unsigned long)qp;
2076
- cqe->wr_id = rq->swq[sw_cons].wr_id;
2196
+ cqe->wr_id = rq->swq[last].wr_id;
20772197 cqe++;
20782198 (*budget)--;
2079
- rq->hwq.cons++;
2199
+ bnxt_qplib_hwq_incr_cons(&rq->hwq, rq->swq[last].slots);
2200
+ rq->swq_last = rq->swq[last].next_idx;
20802201 }
20812202 *pcqe = cqe;
2082
- if (!*budget && HWQ_CMP(rq->hwq.cons, &rq->hwq) != sw_prod)
2203
+ if (!*budget && rq->swq_last != start)
20832204 /* Out of budget */
20842205 rc = -EAGAIN;
20852206
....@@ -2102,20 +2223,20 @@
21022223 * CQE is track from sw_cq_cons to max_element but valid only if VALID=1
21032224 */
21042225 static int do_wa9060(struct bnxt_qplib_qp *qp, struct bnxt_qplib_cq *cq,
2105
- u32 cq_cons, u32 sw_sq_cons, u32 cqe_sq_cons)
2226
+ u32 cq_cons, u32 swq_last, u32 cqe_sq_cons)
21062227 {
2107
- struct bnxt_qplib_q *sq = &qp->sq;
2108
- struct bnxt_qplib_swq *swq;
21092228 u32 peek_sw_cq_cons, peek_raw_cq_cons, peek_sq_cons_idx;
2110
- struct cq_base *peek_hwcqe, **peek_hw_cqe_ptr;
2229
+ struct bnxt_qplib_q *sq = &qp->sq;
21112230 struct cq_req *peek_req_hwcqe;
21122231 struct bnxt_qplib_qp *peek_qp;
21132232 struct bnxt_qplib_q *peek_sq;
2233
+ struct bnxt_qplib_swq *swq;
2234
+ struct cq_base *peek_hwcqe;
21142235 int i, rc = 0;
21152236
21162237 /* Normal mode */
21172238 /* Check for the psn_search marking before completing */
2118
- swq = &sq->swq[sw_sq_cons];
2239
+ swq = &sq->swq[swq_last];
21192240 if (swq->psn_search &&
21202241 le32_to_cpu(swq->psn_search->flags_next_psn) & 0x80000000) {
21212242 /* Unmark */
....@@ -2124,13 +2245,12 @@
21242245 & ~0x80000000);
21252246 dev_dbg(&cq->hwq.pdev->dev,
21262247 "FP: Process Req cq_cons=0x%x qp=0x%x sq cons sw=0x%x cqe=0x%x marked!\n",
2127
- cq_cons, qp->id, sw_sq_cons, cqe_sq_cons);
2248
+ cq_cons, qp->id, swq_last, cqe_sq_cons);
21282249 sq->condition = true;
21292250 sq->send_phantom = true;
21302251
21312252 /* TODO: Only ARM if the previous SQE is ARMALL */
2132
- bnxt_qplib_arm_cq(cq, DBR_DBR_TYPE_CQ_ARMALL);
2133
-
2253
+ bnxt_qplib_ring_db(&cq->dbinfo, DBC_DBC_TYPE_CQ_ARMALL);
21342254 rc = -EAGAIN;
21352255 goto out;
21362256 }
....@@ -2141,9 +2261,8 @@
21412261 i = cq->hwq.max_elements;
21422262 while (i--) {
21432263 peek_sw_cq_cons = HWQ_CMP((peek_sw_cq_cons), &cq->hwq);
2144
- peek_hw_cqe_ptr = (struct cq_base **)cq->hwq.pbl_ptr;
2145
- peek_hwcqe = &peek_hw_cqe_ptr[CQE_PG(peek_sw_cq_cons)]
2146
- [CQE_IDX(peek_sw_cq_cons)];
2264
+ peek_hwcqe = bnxt_qplib_get_qe(&cq->hwq,
2265
+ peek_sw_cq_cons, NULL);
21472266 /* If the next hwcqe is VALID */
21482267 if (CQE_CMP_VALID(peek_hwcqe, peek_raw_cq_cons,
21492268 cq->hwq.max_elements)) {
....@@ -2163,9 +2282,10 @@
21632282 le64_to_cpu
21642283 (peek_req_hwcqe->qp_handle));
21652284 peek_sq = &peek_qp->sq;
2166
- peek_sq_cons_idx = HWQ_CMP(le16_to_cpu(
2167
- peek_req_hwcqe->sq_cons_idx) - 1
2168
- , &sq->hwq);
2285
+ peek_sq_cons_idx =
2286
+ ((le16_to_cpu(
2287
+ peek_req_hwcqe->sq_cons_idx)
2288
+ - 1) % sq->max_wqe);
21692289 /* If the hwcqe's sq's wr_id matches */
21702290 if (peek_sq == sq &&
21712291 sq->swq[peek_sq_cons_idx].wr_id ==
....@@ -2175,7 +2295,7 @@
21752295 * comes back
21762296 */
21772297 dev_dbg(&cq->hwq.pdev->dev,
2178
- "FP:Got Phantom CQE");
2298
+ "FP: Got Phantom CQE\n");
21792299 sq->condition = false;
21802300 sq->single = true;
21812301 rc = 0;
....@@ -2192,8 +2312,8 @@
21922312 peek_raw_cq_cons++;
21932313 }
21942314 dev_err(&cq->hwq.pdev->dev,
2195
- "Should not have come here! cq_cons=0x%x qp=0x%x sq cons sw=0x%x hw=0x%x",
2196
- cq_cons, qp->id, sw_sq_cons, cqe_sq_cons);
2315
+ "Should not have come here! cq_cons=0x%x qp=0x%x sq cons sw=0x%x hw=0x%x\n",
2316
+ cq_cons, qp->id, swq_last, cqe_sq_cons);
21972317 rc = -EINVAL;
21982318 }
21992319 out:
....@@ -2205,35 +2325,26 @@
22052325 struct bnxt_qplib_cqe **pcqe, int *budget,
22062326 u32 cq_cons, struct bnxt_qplib_qp **lib_qp)
22072327 {
2328
+ struct bnxt_qplib_swq *swq;
2329
+ struct bnxt_qplib_cqe *cqe;
22082330 struct bnxt_qplib_qp *qp;
22092331 struct bnxt_qplib_q *sq;
2210
- struct bnxt_qplib_cqe *cqe;
2211
- u32 sw_sq_cons, cqe_sq_cons;
2212
- struct bnxt_qplib_swq *swq;
2332
+ u32 cqe_sq_cons;
22132333 int rc = 0;
22142334
22152335 qp = (struct bnxt_qplib_qp *)((unsigned long)
22162336 le64_to_cpu(hwcqe->qp_handle));
22172337 if (!qp) {
22182338 dev_err(&cq->hwq.pdev->dev,
2219
- "QPLIB: FP: Process Req qp is NULL");
2339
+ "FP: Process Req qp is NULL\n");
22202340 return -EINVAL;
22212341 }
22222342 sq = &qp->sq;
22232343
2224
- cqe_sq_cons = HWQ_CMP(le16_to_cpu(hwcqe->sq_cons_idx), &sq->hwq);
2225
- if (cqe_sq_cons > sq->hwq.max_elements) {
2226
- dev_err(&cq->hwq.pdev->dev,
2227
- "QPLIB: FP: CQ Process req reported ");
2228
- dev_err(&cq->hwq.pdev->dev,
2229
- "QPLIB: sq_cons_idx 0x%x which exceeded max 0x%x",
2230
- cqe_sq_cons, sq->hwq.max_elements);
2231
- return -EINVAL;
2232
- }
2233
-
2344
+ cqe_sq_cons = le16_to_cpu(hwcqe->sq_cons_idx) % sq->max_wqe;
22342345 if (qp->sq.flushed) {
22352346 dev_dbg(&cq->hwq.pdev->dev,
2236
- "%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
2347
+ "%s: QP in Flush QP = %p\n", __func__, qp);
22372348 goto done;
22382349 }
22392350 /* Require to walk the sq's swq to fabricate CQEs for all previously
....@@ -2242,12 +2353,11 @@
22422353 */
22432354 cqe = *pcqe;
22442355 while (*budget) {
2245
- sw_sq_cons = HWQ_CMP(sq->hwq.cons, &sq->hwq);
2246
- if (sw_sq_cons == cqe_sq_cons)
2356
+ if (sq->swq_last == cqe_sq_cons)
22472357 /* Done */
22482358 break;
22492359
2250
- swq = &sq->swq[sw_sq_cons];
2360
+ swq = &sq->swq[sq->swq_last];
22512361 memset(cqe, 0, sizeof(*cqe));
22522362 cqe->opcode = CQ_BASE_CQE_TYPE_REQ;
22532363 cqe->qp_handle = (u64)(unsigned long)qp;
....@@ -2261,14 +2371,12 @@
22612371 * of the request being signaled or not, it must complete with
22622372 * the hwcqe error status
22632373 */
2264
- if (HWQ_CMP((sw_sq_cons + 1), &sq->hwq) == cqe_sq_cons &&
2374
+ if (swq->next_idx == cqe_sq_cons &&
22652375 hwcqe->status != CQ_REQ_STATUS_OK) {
22662376 cqe->status = hwcqe->status;
22672377 dev_err(&cq->hwq.pdev->dev,
2268
- "QPLIB: FP: CQ Processed Req ");
2269
- dev_err(&cq->hwq.pdev->dev,
2270
- "QPLIB: wr_id[%d] = 0x%llx with status 0x%x",
2271
- sw_sq_cons, cqe->wr_id, cqe->status);
2378
+ "FP: CQ Processed Req wr_id[%d] = 0x%llx with status 0x%x\n",
2379
+ sq->swq_last, cqe->wr_id, cqe->status);
22722380 cqe++;
22732381 (*budget)--;
22742382 bnxt_qplib_mark_qp_error(qp);
....@@ -2276,7 +2384,7 @@
22762384 bnxt_qplib_add_flush_qp(qp);
22772385 } else {
22782386 /* Before we complete, do WA 9060 */
2279
- if (do_wa9060(qp, cq, cq_cons, sw_sq_cons,
2387
+ if (do_wa9060(qp, cq, cq_cons, sq->swq_last,
22802388 cqe_sq_cons)) {
22812389 *lib_qp = qp;
22822390 goto out;
....@@ -2288,13 +2396,14 @@
22882396 }
22892397 }
22902398 skip:
2291
- sq->hwq.cons++;
2399
+ bnxt_qplib_hwq_incr_cons(&sq->hwq, swq->slots);
2400
+ sq->swq_last = swq->next_idx;
22922401 if (sq->single)
22932402 break;
22942403 }
22952404 out:
22962405 *pcqe = cqe;
2297
- if (HWQ_CMP(sq->hwq.cons, &sq->hwq) != cqe_sq_cons) {
2406
+ if (sq->swq_last != cqe_sq_cons) {
22982407 /* Out of budget */
22992408 rc = -EAGAIN;
23002409 goto done;
....@@ -2323,22 +2432,22 @@
23232432 struct bnxt_qplib_cqe **pcqe,
23242433 int *budget)
23252434 {
2326
- struct bnxt_qplib_qp *qp;
2327
- struct bnxt_qplib_q *rq;
23282435 struct bnxt_qplib_srq *srq;
23292436 struct bnxt_qplib_cqe *cqe;
2437
+ struct bnxt_qplib_qp *qp;
2438
+ struct bnxt_qplib_q *rq;
23302439 u32 wr_id_idx;
23312440 int rc = 0;
23322441
23332442 qp = (struct bnxt_qplib_qp *)((unsigned long)
23342443 le64_to_cpu(hwcqe->qp_handle));
23352444 if (!qp) {
2336
- dev_err(&cq->hwq.pdev->dev, "QPLIB: process_cq RC qp is NULL");
2445
+ dev_err(&cq->hwq.pdev->dev, "process_cq RC qp is NULL\n");
23372446 return -EINVAL;
23382447 }
23392448 if (qp->rq.flushed) {
23402449 dev_dbg(&cq->hwq.pdev->dev,
2341
- "%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
2450
+ "%s: QP in Flush QP = %p\n", __func__, qp);
23422451 goto done;
23432452 }
23442453
....@@ -2359,9 +2468,7 @@
23592468 return -EINVAL;
23602469 if (wr_id_idx >= srq->hwq.max_elements) {
23612470 dev_err(&cq->hwq.pdev->dev,
2362
- "QPLIB: FP: CQ Process RC ");
2363
- dev_err(&cq->hwq.pdev->dev,
2364
- "QPLIB: wr_id idx 0x%x exceeded SRQ max 0x%x",
2471
+ "FP: CQ Process RC wr_id idx 0x%x exceeded SRQ max 0x%x\n",
23652472 wr_id_idx, srq->hwq.max_elements);
23662473 return -EINVAL;
23672474 }
....@@ -2371,19 +2478,23 @@
23712478 (*budget)--;
23722479 *pcqe = cqe;
23732480 } else {
2481
+ struct bnxt_qplib_swq *swq;
2482
+
23742483 rq = &qp->rq;
2375
- if (wr_id_idx >= rq->hwq.max_elements) {
2484
+ if (wr_id_idx > (rq->max_wqe - 1)) {
23762485 dev_err(&cq->hwq.pdev->dev,
2377
- "QPLIB: FP: CQ Process RC ");
2378
- dev_err(&cq->hwq.pdev->dev,
2379
- "QPLIB: wr_id idx 0x%x exceeded RQ max 0x%x",
2380
- wr_id_idx, rq->hwq.max_elements);
2486
+ "FP: CQ Process RC wr_id idx 0x%x exceeded RQ max 0x%x\n",
2487
+ wr_id_idx, rq->max_wqe);
23812488 return -EINVAL;
23822489 }
2383
- cqe->wr_id = rq->swq[wr_id_idx].wr_id;
2490
+ if (wr_id_idx != rq->swq_last)
2491
+ return -EINVAL;
2492
+ swq = &rq->swq[rq->swq_last];
2493
+ cqe->wr_id = swq->wr_id;
23842494 cqe++;
23852495 (*budget)--;
2386
- rq->hwq.cons++;
2496
+ bnxt_qplib_hwq_incr_cons(&rq->hwq, swq->slots);
2497
+ rq->swq_last = swq->next_idx;
23872498 *pcqe = cqe;
23882499
23892500 if (hwcqe->status != CQ_RES_RC_STATUS_OK) {
....@@ -2402,32 +2513,34 @@
24022513 struct bnxt_qplib_cqe **pcqe,
24032514 int *budget)
24042515 {
2405
- struct bnxt_qplib_qp *qp;
2406
- struct bnxt_qplib_q *rq;
24072516 struct bnxt_qplib_srq *srq;
24082517 struct bnxt_qplib_cqe *cqe;
2518
+ struct bnxt_qplib_qp *qp;
2519
+ struct bnxt_qplib_q *rq;
24092520 u32 wr_id_idx;
24102521 int rc = 0;
24112522
24122523 qp = (struct bnxt_qplib_qp *)((unsigned long)
24132524 le64_to_cpu(hwcqe->qp_handle));
24142525 if (!qp) {
2415
- dev_err(&cq->hwq.pdev->dev, "QPLIB: process_cq UD qp is NULL");
2526
+ dev_err(&cq->hwq.pdev->dev, "process_cq UD qp is NULL\n");
24162527 return -EINVAL;
24172528 }
24182529 if (qp->rq.flushed) {
24192530 dev_dbg(&cq->hwq.pdev->dev,
2420
- "%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
2531
+ "%s: QP in Flush QP = %p\n", __func__, qp);
24212532 goto done;
24222533 }
24232534 cqe = *pcqe;
24242535 cqe->opcode = hwcqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK;
2425
- cqe->length = le32_to_cpu(hwcqe->length);
2536
+ cqe->length = le16_to_cpu(hwcqe->length) & CQ_RES_UD_LENGTH_MASK;
2537
+ cqe->cfa_meta = le16_to_cpu(hwcqe->cfa_metadata);
24262538 cqe->invrkey = le32_to_cpu(hwcqe->imm_data);
24272539 cqe->flags = le16_to_cpu(hwcqe->flags);
24282540 cqe->status = hwcqe->status;
24292541 cqe->qp_handle = (u64)(unsigned long)qp;
2430
- memcpy(cqe->smac, hwcqe->src_mac, 6);
2542
+ /*FIXME: Endianness fix needed for smace */
2543
+ memcpy(cqe->smac, hwcqe->src_mac, ETH_ALEN);
24312544 wr_id_idx = le32_to_cpu(hwcqe->src_qp_high_srq_or_rq_wr_id)
24322545 & CQ_RES_UD_SRQ_OR_RQ_WR_ID_MASK;
24332546 cqe->src_qp = le16_to_cpu(hwcqe->src_qp_low) |
....@@ -2442,9 +2555,7 @@
24422555
24432556 if (wr_id_idx >= srq->hwq.max_elements) {
24442557 dev_err(&cq->hwq.pdev->dev,
2445
- "QPLIB: FP: CQ Process UD ");
2446
- dev_err(&cq->hwq.pdev->dev,
2447
- "QPLIB: wr_id idx 0x%x exceeded SRQ max 0x%x",
2558
+ "FP: CQ Process UD wr_id idx 0x%x exceeded SRQ max 0x%x\n",
24482559 wr_id_idx, srq->hwq.max_elements);
24492560 return -EINVAL;
24502561 }
....@@ -2454,20 +2565,24 @@
24542565 (*budget)--;
24552566 *pcqe = cqe;
24562567 } else {
2568
+ struct bnxt_qplib_swq *swq;
2569
+
24572570 rq = &qp->rq;
2458
- if (wr_id_idx >= rq->hwq.max_elements) {
2571
+ if (wr_id_idx > (rq->max_wqe - 1)) {
24592572 dev_err(&cq->hwq.pdev->dev,
2460
- "QPLIB: FP: CQ Process UD ");
2461
- dev_err(&cq->hwq.pdev->dev,
2462
- "QPLIB: wr_id idx 0x%x exceeded RQ max 0x%x",
2463
- wr_id_idx, rq->hwq.max_elements);
2573
+ "FP: CQ Process UD wr_id idx 0x%x exceeded RQ max 0x%x\n",
2574
+ wr_id_idx, rq->max_wqe);
24642575 return -EINVAL;
24652576 }
24662577
2467
- cqe->wr_id = rq->swq[wr_id_idx].wr_id;
2578
+ if (rq->swq_last != wr_id_idx)
2579
+ return -EINVAL;
2580
+ swq = &rq->swq[rq->swq_last];
2581
+ cqe->wr_id = swq->wr_id;
24682582 cqe++;
24692583 (*budget)--;
2470
- rq->hwq.cons++;
2584
+ bnxt_qplib_hwq_incr_cons(&rq->hwq, swq->slots);
2585
+ rq->swq_last = swq->next_idx;
24712586 *pcqe = cqe;
24722587
24732588 if (hwcqe->status != CQ_RES_RC_STATUS_OK) {
....@@ -2482,15 +2597,13 @@
24822597
24832598 bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq)
24842599 {
2485
- struct cq_base *hw_cqe, **hw_cqe_ptr;
2600
+ struct cq_base *hw_cqe;
24862601 u32 sw_cons, raw_cons;
24872602 bool rc = true;
24882603
24892604 raw_cons = cq->hwq.cons;
24902605 sw_cons = HWQ_CMP(raw_cons, &cq->hwq);
2491
- hw_cqe_ptr = (struct cq_base **)cq->hwq.pbl_ptr;
2492
- hw_cqe = &hw_cqe_ptr[CQE_PG(sw_cons)][CQE_IDX(sw_cons)];
2493
-
2606
+ hw_cqe = bnxt_qplib_get_qe(&cq->hwq, sw_cons, NULL);
24942607 /* Check for Valid bit. If the CQE is valid, return false */
24952608 rc = !CQE_CMP_VALID(hw_cqe, raw_cons, cq->hwq.max_elements);
24962609 return rc;
....@@ -2511,13 +2624,12 @@
25112624 qp = (struct bnxt_qplib_qp *)((unsigned long)
25122625 le64_to_cpu(hwcqe->qp_handle));
25132626 if (!qp) {
2514
- dev_err(&cq->hwq.pdev->dev,
2515
- "QPLIB: process_cq Raw/QP1 qp is NULL");
2627
+ dev_err(&cq->hwq.pdev->dev, "process_cq Raw/QP1 qp is NULL\n");
25162628 return -EINVAL;
25172629 }
25182630 if (qp->rq.flushed) {
25192631 dev_dbg(&cq->hwq.pdev->dev,
2520
- "%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
2632
+ "%s: QP in Flush QP = %p\n", __func__, qp);
25212633 goto done;
25222634 }
25232635 cqe = *pcqe;
....@@ -2546,14 +2658,12 @@
25462658 srq = qp->srq;
25472659 if (!srq) {
25482660 dev_err(&cq->hwq.pdev->dev,
2549
- "QPLIB: FP: SRQ used but not defined??");
2661
+ "FP: SRQ used but not defined??\n");
25502662 return -EINVAL;
25512663 }
25522664 if (wr_id_idx >= srq->hwq.max_elements) {
25532665 dev_err(&cq->hwq.pdev->dev,
2554
- "QPLIB: FP: CQ Process Raw/QP1 ");
2555
- dev_err(&cq->hwq.pdev->dev,
2556
- "QPLIB: wr_id idx 0x%x exceeded SRQ max 0x%x",
2666
+ "FP: CQ Process Raw/QP1 wr_id idx 0x%x exceeded SRQ max 0x%x\n",
25572667 wr_id_idx, srq->hwq.max_elements);
25582668 return -EINVAL;
25592669 }
....@@ -2563,19 +2673,23 @@
25632673 (*budget)--;
25642674 *pcqe = cqe;
25652675 } else {
2676
+ struct bnxt_qplib_swq *swq;
2677
+
25662678 rq = &qp->rq;
2567
- if (wr_id_idx >= rq->hwq.max_elements) {
2679
+ if (wr_id_idx > (rq->max_wqe - 1)) {
25682680 dev_err(&cq->hwq.pdev->dev,
2569
- "QPLIB: FP: CQ Process Raw/QP1 RQ wr_id ");
2570
- dev_err(&cq->hwq.pdev->dev,
2571
- "QPLIB: ix 0x%x exceeded RQ max 0x%x",
2572
- wr_id_idx, rq->hwq.max_elements);
2681
+ "FP: CQ Process Raw/QP1 RQ wr_id idx 0x%x exceeded RQ max 0x%x\n",
2682
+ wr_id_idx, rq->max_wqe);
25732683 return -EINVAL;
25742684 }
2575
- cqe->wr_id = rq->swq[wr_id_idx].wr_id;
2685
+ if (rq->swq_last != wr_id_idx)
2686
+ return -EINVAL;
2687
+ swq = &rq->swq[rq->swq_last];
2688
+ cqe->wr_id = swq->wr_id;
25762689 cqe++;
25772690 (*budget)--;
2578
- rq->hwq.cons++;
2691
+ bnxt_qplib_hwq_incr_cons(&rq->hwq, swq->slots);
2692
+ rq->swq_last = swq->next_idx;
25792693 *pcqe = cqe;
25802694
25812695 if (hwcqe->status != CQ_RES_RC_STATUS_OK) {
....@@ -2597,20 +2711,20 @@
25972711 struct bnxt_qplib_qp *qp;
25982712 struct bnxt_qplib_q *sq, *rq;
25992713 struct bnxt_qplib_cqe *cqe;
2600
- u32 sw_cons = 0, cqe_cons;
2714
+ u32 swq_last = 0, cqe_cons;
26012715 int rc = 0;
26022716
26032717 /* Check the Status */
26042718 if (hwcqe->status != CQ_TERMINAL_STATUS_OK)
26052719 dev_warn(&cq->hwq.pdev->dev,
2606
- "QPLIB: FP: CQ Process Terminal Error status = 0x%x",
2720
+ "FP: CQ Process Terminal Error status = 0x%x\n",
26072721 hwcqe->status);
26082722
26092723 qp = (struct bnxt_qplib_qp *)((unsigned long)
26102724 le64_to_cpu(hwcqe->qp_handle));
26112725 if (!qp) {
26122726 dev_err(&cq->hwq.pdev->dev,
2613
- "QPLIB: FP: CQ Process terminal qp is NULL");
2727
+ "FP: CQ Process terminal qp is NULL\n");
26142728 return -EINVAL;
26152729 }
26162730
....@@ -2623,19 +2737,11 @@
26232737 cqe_cons = le16_to_cpu(hwcqe->sq_cons_idx);
26242738 if (cqe_cons == 0xFFFF)
26252739 goto do_rq;
2626
-
2627
- if (cqe_cons > sq->hwq.max_elements) {
2628
- dev_err(&cq->hwq.pdev->dev,
2629
- "QPLIB: FP: CQ Process terminal reported ");
2630
- dev_err(&cq->hwq.pdev->dev,
2631
- "QPLIB: sq_cons_idx 0x%x which exceeded max 0x%x",
2632
- cqe_cons, sq->hwq.max_elements);
2633
- goto do_rq;
2634
- }
2740
+ cqe_cons %= sq->max_wqe;
26352741
26362742 if (qp->sq.flushed) {
26372743 dev_dbg(&cq->hwq.pdev->dev,
2638
- "%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
2744
+ "%s: QP in Flush QP = %p\n", __func__, qp);
26392745 goto sq_done;
26402746 }
26412747
....@@ -2645,24 +2751,25 @@
26452751 */
26462752 cqe = *pcqe;
26472753 while (*budget) {
2648
- sw_cons = HWQ_CMP(sq->hwq.cons, &sq->hwq);
2649
- if (sw_cons == cqe_cons)
2754
+ swq_last = sq->swq_last;
2755
+ if (swq_last == cqe_cons)
26502756 break;
2651
- if (sq->swq[sw_cons].flags & SQ_SEND_FLAGS_SIGNAL_COMP) {
2757
+ if (sq->swq[swq_last].flags & SQ_SEND_FLAGS_SIGNAL_COMP) {
26522758 memset(cqe, 0, sizeof(*cqe));
26532759 cqe->status = CQ_REQ_STATUS_OK;
26542760 cqe->opcode = CQ_BASE_CQE_TYPE_REQ;
26552761 cqe->qp_handle = (u64)(unsigned long)qp;
26562762 cqe->src_qp = qp->id;
2657
- cqe->wr_id = sq->swq[sw_cons].wr_id;
2658
- cqe->type = sq->swq[sw_cons].type;
2763
+ cqe->wr_id = sq->swq[swq_last].wr_id;
2764
+ cqe->type = sq->swq[swq_last].type;
26592765 cqe++;
26602766 (*budget)--;
26612767 }
2662
- sq->hwq.cons++;
2768
+ bnxt_qplib_hwq_incr_cons(&sq->hwq, sq->swq[swq_last].slots);
2769
+ sq->swq_last = sq->swq[swq_last].next_idx;
26632770 }
26642771 *pcqe = cqe;
2665
- if (!(*budget) && sw_cons != cqe_cons) {
2772
+ if (!(*budget) && swq_last != cqe_cons) {
26662773 /* Out of budget */
26672774 rc = -EAGAIN;
26682775 goto sq_done;
....@@ -2674,18 +2781,17 @@
26742781 cqe_cons = le16_to_cpu(hwcqe->rq_cons_idx);
26752782 if (cqe_cons == 0xFFFF) {
26762783 goto done;
2677
- } else if (cqe_cons > rq->hwq.max_elements) {
2784
+ } else if (cqe_cons > rq->max_wqe - 1) {
26782785 dev_err(&cq->hwq.pdev->dev,
2679
- "QPLIB: FP: CQ Processed terminal ");
2680
- dev_err(&cq->hwq.pdev->dev,
2681
- "QPLIB: reported rq_cons_idx 0x%x exceeds max 0x%x",
2682
- cqe_cons, rq->hwq.max_elements);
2786
+ "FP: CQ Processed terminal reported rq_cons_idx 0x%x exceeds max 0x%x\n",
2787
+ cqe_cons, rq->max_wqe);
2788
+ rc = -EINVAL;
26832789 goto done;
26842790 }
26852791
26862792 if (qp->rq.flushed) {
26872793 dev_dbg(&cq->hwq.pdev->dev,
2688
- "%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
2794
+ "%s: QP in Flush QP = %p\n", __func__, qp);
26892795 rc = 0;
26902796 goto done;
26912797 }
....@@ -2707,7 +2813,7 @@
27072813 /* Check the Status */
27082814 if (hwcqe->status != CQ_CUTOFF_STATUS_OK) {
27092815 dev_err(&cq->hwq.pdev->dev,
2710
- "QPLIB: FP: CQ Process Cutoff Error status = 0x%x",
2816
+ "FP: CQ Process Cutoff Error status = 0x%x\n",
27112817 hwcqe->status);
27122818 return -EINVAL;
27132819 }
....@@ -2727,16 +2833,12 @@
27272833
27282834 spin_lock_irqsave(&cq->flush_lock, flags);
27292835 list_for_each_entry(qp, &cq->sqf_head, sq_flush) {
2730
- dev_dbg(&cq->hwq.pdev->dev,
2731
- "QPLIB: FP: Flushing SQ QP= %p",
2732
- qp);
2836
+ dev_dbg(&cq->hwq.pdev->dev, "FP: Flushing SQ QP= %p\n", qp);
27332837 __flush_sq(&qp->sq, qp, &cqe, &budget);
27342838 }
27352839
27362840 list_for_each_entry(qp, &cq->rqf_head, rq_flush) {
2737
- dev_dbg(&cq->hwq.pdev->dev,
2738
- "QPLIB: FP: Flushing RQ QP= %p",
2739
- qp);
2841
+ dev_dbg(&cq->hwq.pdev->dev, "FP: Flushing RQ QP= %p\n", qp);
27402842 __flush_rq(&qp->rq, qp, &cqe, &budget);
27412843 }
27422844 spin_unlock_irqrestore(&cq->flush_lock, flags);
....@@ -2747,7 +2849,7 @@
27472849 int bnxt_qplib_poll_cq(struct bnxt_qplib_cq *cq, struct bnxt_qplib_cqe *cqe,
27482850 int num_cqes, struct bnxt_qplib_qp **lib_qp)
27492851 {
2750
- struct cq_base *hw_cqe, **hw_cqe_ptr;
2852
+ struct cq_base *hw_cqe;
27512853 u32 sw_cons, raw_cons;
27522854 int budget, rc = 0;
27532855
....@@ -2756,8 +2858,7 @@
27562858
27572859 while (budget) {
27582860 sw_cons = HWQ_CMP(raw_cons, &cq->hwq);
2759
- hw_cqe_ptr = (struct cq_base **)cq->hwq.pbl_ptr;
2760
- hw_cqe = &hw_cqe_ptr[CQE_PG(sw_cons)][CQE_IDX(sw_cons)];
2861
+ hw_cqe = bnxt_qplib_get_qe(&cq->hwq, sw_cons, NULL);
27612862
27622863 /* Check for Valid bit */
27632864 if (!CQE_CMP_VALID(hw_cqe, raw_cons, cq->hwq.max_elements))
....@@ -2804,7 +2905,7 @@
28042905 goto exit;
28052906 default:
28062907 dev_err(&cq->hwq.pdev->dev,
2807
- "QPLIB: process_cq unknown type 0x%lx",
2908
+ "process_cq unknown type 0x%lx\n",
28082909 hw_cqe->cqe_type_toggle &
28092910 CQ_BASE_CQE_TYPE_MASK);
28102911 rc = -EINVAL;
....@@ -2817,13 +2918,13 @@
28172918 * next one
28182919 */
28192920 dev_err(&cq->hwq.pdev->dev,
2820
- "QPLIB: process_cqe error rc = 0x%x", rc);
2921
+ "process_cqe error rc = 0x%x\n", rc);
28212922 }
28222923 raw_cons++;
28232924 }
28242925 if (cq->hwq.cons != raw_cons) {
28252926 cq->hwq.cons = raw_cons;
2826
- bnxt_qplib_arm_cq(cq, DBR_DBR_TYPE_CQ);
2927
+ bnxt_qplib_ring_db(&cq->dbinfo, DBC_DBC_TYPE_CQ);
28272928 }
28282929 exit:
28292930 return num_cqes - budget;
....@@ -2832,7 +2933,7 @@
28322933 void bnxt_qplib_req_notify_cq(struct bnxt_qplib_cq *cq, u32 arm_type)
28332934 {
28342935 if (arm_type)
2835
- bnxt_qplib_arm_cq(cq, arm_type);
2936
+ bnxt_qplib_ring_db(&cq->dbinfo, arm_type);
28362937 /* Using cq->arm_state variable to track whether to issue cq handler */
28372938 atomic_set(&cq->arm_state, 1);
28382939 }