|
15 | 15 | #include "otx2_reg.h"
|
16 | 16 | #include "otx2_common.h"
|
17 | 17 | #include "otx2_struct.h"
|
| 18 | +#include "cn10k.h" |
18 | 19 |
|
19 | 20 | static void otx2_nix_rq_op_stats(struct queue_stats *stats,
|
20 | 21 | struct otx2_nic *pfvf, int qidx)
|
@@ -526,6 +527,26 @@ static int otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool,
|
526 | 527 | return ret;
|
527 | 528 | }
|
528 | 529 |
|
| 530 | +int otx2_alloc_buffer(struct otx2_nic *pfvf, struct otx2_cq_queue *cq, |
| 531 | + dma_addr_t *dma) |
| 532 | +{ |
| 533 | + if (unlikely(__otx2_alloc_rbuf(pfvf, cq->rbpool, dma))) { |
| 534 | + struct refill_work *work; |
| 535 | + struct delayed_work *dwork; |
| 536 | + |
| 537 | + work = &pfvf->refill_wrk[cq->cq_idx]; |
| 538 | + dwork = &work->pool_refill_work; |
| 539 | + /* Schedule a task if no other task is running */ |
| 540 | + if (!cq->refill_task_sched) { |
| 541 | + cq->refill_task_sched = true; |
| 542 | + schedule_delayed_work(dwork, |
| 543 | + msecs_to_jiffies(100)); |
| 544 | + } |
| 545 | + return -ENOMEM; |
| 546 | + } |
| 547 | + return 0; |
| 548 | +} |
| 549 | + |
529 | 550 | void otx2_tx_timeout(struct net_device *netdev, unsigned int txq)
|
530 | 551 | {
|
531 | 552 | struct otx2_nic *pfvf = netdev_priv(netdev);
|
@@ -728,9 +749,6 @@ void otx2_sqb_flush(struct otx2_nic *pfvf)
|
728 | 749 | #define RQ_PASS_LVL_AURA (255 - ((95 * 256) / 100)) /* RED when 95% is full */
|
729 | 750 | #define RQ_DROP_LVL_AURA (255 - ((99 * 256) / 100)) /* Drop when 99% is full */
|
730 | 751 |
|
731 |
| -/* Send skid of 2000 packets required for CQ size of 4K CQEs. */ |
732 |
| -#define SEND_CQ_SKID 2000 |
733 |
| - |
734 | 752 | static int otx2_rq_init(struct otx2_nic *pfvf, u16 qidx, u16 lpb_aura)
|
735 | 753 | {
|
736 | 754 | struct otx2_qset *qset = &pfvf->qset;
|
@@ -764,45 +782,14 @@ static int otx2_rq_init(struct otx2_nic *pfvf, u16 qidx, u16 lpb_aura)
|
764 | 782 | return otx2_sync_mbox_msg(&pfvf->mbox);
|
765 | 783 | }
|
766 | 784 |
|
767 |
| -static int cn10k_sq_aq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura) |
768 |
| -{ |
769 |
| - struct nix_cn10k_aq_enq_req *aq; |
770 |
| - |
771 |
| - /* Get memory to put this msg */ |
772 |
| - aq = otx2_mbox_alloc_msg_nix_cn10k_aq_enq(&pfvf->mbox); |
773 |
| - if (!aq) |
774 |
| - return -ENOMEM; |
775 |
| - |
776 |
| - aq->sq.cq = pfvf->hw.rx_queues + qidx; |
777 |
| - aq->sq.max_sqe_size = NIX_MAXSQESZ_W16; /* 128 byte */ |
778 |
| - aq->sq.cq_ena = 1; |
779 |
| - aq->sq.ena = 1; |
780 |
| - /* Only one SMQ is allocated, map all SQ's to that SMQ */ |
781 |
| - aq->sq.smq = pfvf->hw.txschq_list[NIX_TXSCH_LVL_SMQ][0]; |
782 |
| - /* FIXME: set based on NIX_AF_DWRR_RPM_MTU*/ |
783 |
| - aq->sq.smq_rr_weight = OTX2_MAX_MTU; |
784 |
| - aq->sq.default_chan = pfvf->hw.tx_chan_base; |
785 |
| - aq->sq.sqe_stype = NIX_STYPE_STF; /* Cache SQB */ |
786 |
| - aq->sq.sqb_aura = sqb_aura; |
787 |
| - aq->sq.sq_int_ena = NIX_SQINT_BITS; |
788 |
| - aq->sq.qint_idx = 0; |
789 |
| - /* Due pipelining impact minimum 2000 unused SQ CQE's |
790 |
| - * need to maintain to avoid CQ overflow. |
791 |
| - */ |
792 |
| - aq->sq.cq_limit = ((SEND_CQ_SKID * 256) / (pfvf->qset.sqe_cnt)); |
793 |
| - |
794 |
| - /* Fill AQ info */ |
795 |
| - aq->qidx = qidx; |
796 |
| - aq->ctype = NIX_AQ_CTYPE_SQ; |
797 |
| - aq->op = NIX_AQ_INSTOP_INIT; |
798 |
| - |
799 |
| - return otx2_sync_mbox_msg(&pfvf->mbox); |
800 |
| -} |
801 |
| - |
802 |
| -static int otx2_sq_aq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura) |
| 785 | +int otx2_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura) |
803 | 786 | {
|
| 787 | + struct otx2_nic *pfvf = dev; |
| 788 | + struct otx2_snd_queue *sq; |
804 | 789 | struct nix_aq_enq_req *aq;
|
805 | 790 |
|
| 791 | + sq = &pfvf->qset.sq[qidx]; |
| 792 | + sq->lmt_addr = (__force u64 *)(pfvf->reg_base + LMT_LF_LMTLINEX(qidx)); |
806 | 793 | /* Get memory to put this msg */
|
807 | 794 | aq = otx2_mbox_alloc_msg_nix_aq_enq(&pfvf->mbox);
|
808 | 795 | if (!aq)
|
@@ -873,16 +860,12 @@ static int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)
|
873 | 860 | sq->sqe_thresh = ((sq->num_sqbs * sq->sqe_per_sqb) * 10) / 100;
|
874 | 861 | sq->aura_id = sqb_aura;
|
875 | 862 | sq->aura_fc_addr = pool->fc_addr->base;
|
876 |
| - sq->lmt_addr = (__force u64 *)(pfvf->reg_base + LMT_LF_LMTLINEX(qidx)); |
877 | 863 | sq->io_addr = (__force u64)otx2_get_regaddr(pfvf, NIX_LF_OP_SENDX(0));
|
878 | 864 |
|
879 | 865 | sq->stats.bytes = 0;
|
880 | 866 | sq->stats.pkts = 0;
|
881 | 867 |
|
882 |
| - if (is_dev_otx2(pfvf->pdev)) |
883 |
| - return otx2_sq_aq_init(pfvf, qidx, sqb_aura); |
884 |
| - else |
885 |
| - return cn10k_sq_aq_init(pfvf, qidx, sqb_aura); |
| 868 | + return pfvf->hw_ops->sq_aq_init(pfvf, qidx, sqb_aura); |
886 | 869 |
|
887 | 870 | }
|
888 | 871 |
|
@@ -987,7 +970,7 @@ static void otx2_pool_refill_task(struct work_struct *work)
|
987 | 970 | }
|
988 | 971 | return;
|
989 | 972 | }
|
990 |
| - otx2_aura_freeptr(pfvf, qidx, bufptr + OTX2_HEAD_ROOM); |
| 973 | + pfvf->hw_ops->aura_freeptr(pfvf, qidx, bufptr + OTX2_HEAD_ROOM); |
991 | 974 | cq->pool_ptrs--;
|
992 | 975 | }
|
993 | 976 | cq->refill_task_sched = false;
|
@@ -1231,6 +1214,11 @@ static int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id,
|
1231 | 1214 |
|
1232 | 1215 | pool->rbsize = buf_size;
|
1233 | 1216 |
|
| 1217 | + /* Set LMTST addr for NPA batch free */ |
| 1218 | + if (test_bit(CN10K_LMTST, &pfvf->hw.cap_flag)) |
| 1219 | + pool->lmt_addr = (__force u64 *)((u64)pfvf->hw.npa_lmt_base + |
| 1220 | + (pool_id * LMT_LINE_SIZE)); |
| 1221 | + |
1234 | 1222 | /* Initialize this pool's context via AF */
|
1235 | 1223 | aq = otx2_mbox_alloc_msg_npa_aq_enq(&pfvf->mbox);
|
1236 | 1224 | if (!aq) {
|
@@ -1319,7 +1307,7 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf)
|
1319 | 1307 | for (ptr = 0; ptr < num_sqbs; ptr++) {
|
1320 | 1308 | if (otx2_alloc_rbuf(pfvf, pool, &bufptr))
|
1321 | 1309 | return -ENOMEM;
|
1322 |
| - otx2_aura_freeptr(pfvf, pool_id, bufptr); |
| 1310 | + pfvf->hw_ops->aura_freeptr(pfvf, pool_id, bufptr); |
1323 | 1311 | sq->sqb_ptrs[sq->sqb_count++] = (u64)bufptr;
|
1324 | 1312 | }
|
1325 | 1313 | }
|
@@ -1369,8 +1357,8 @@ int otx2_rq_aura_pool_init(struct otx2_nic *pfvf)
|
1369 | 1357 | for (ptr = 0; ptr < num_ptrs; ptr++) {
|
1370 | 1358 | if (otx2_alloc_rbuf(pfvf, pool, &bufptr))
|
1371 | 1359 | return -ENOMEM;
|
1372 |
| - otx2_aura_freeptr(pfvf, pool_id, |
1373 |
| - bufptr + OTX2_HEAD_ROOM); |
| 1360 | + pfvf->hw_ops->aura_freeptr(pfvf, pool_id, |
| 1361 | + bufptr + OTX2_HEAD_ROOM); |
1374 | 1362 | }
|
1375 | 1363 | }
|
1376 | 1364 |
|
|
0 commit comments