Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

octeontx2-pf: cn10k: Use LMTST lines for NPA/NIX operations

This patch adds support to use new LMTST lines for NPA batch free
and burst SQE flush. Adds new dev_hw_ops structure to hold platform
specific functions and create new files cn10k.c and cn10k.h.

Signed-off-by: Geetha sowjanya <gakula@marvell.com>
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Geetha sowjanya and committed by
David S. Miller
4c236d5d 6e8ad438

+336 -135
+1 -1
drivers/net/ethernet/marvell/octeontx2/nic/Makefile
··· 7 7 obj-$(CONFIG_OCTEONTX2_VF) += rvu_nicvf.o 8 8 9 9 rvu_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o \ 10 - otx2_ptp.o otx2_flows.o 10 + otx2_ptp.o otx2_flows.o cn10k.o 11 11 rvu_nicvf-y := otx2_vf.o 12 12 13 13 ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af
+181
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Marvell OcteonTx2 RVU Physcial Function ethernet driver 3 + * 4 + * Copyright (C) 2020 Marvell. 5 + */ 6 + 7 + #include "cn10k.h" 8 + #include "otx2_reg.h" 9 + #include "otx2_struct.h" 10 + 11 + static struct dev_hw_ops otx2_hw_ops = { 12 + .sq_aq_init = otx2_sq_aq_init, 13 + .sqe_flush = otx2_sqe_flush, 14 + .aura_freeptr = otx2_aura_freeptr, 15 + .refill_pool_ptrs = otx2_refill_pool_ptrs, 16 + }; 17 + 18 + static struct dev_hw_ops cn10k_hw_ops = { 19 + .sq_aq_init = cn10k_sq_aq_init, 20 + .sqe_flush = cn10k_sqe_flush, 21 + .aura_freeptr = cn10k_aura_freeptr, 22 + .refill_pool_ptrs = cn10k_refill_pool_ptrs, 23 + }; 24 + 25 + int cn10k_pf_lmtst_init(struct otx2_nic *pf) 26 + { 27 + int size, num_lines; 28 + u64 base; 29 + 30 + if (!test_bit(CN10K_LMTST, &pf->hw.cap_flag)) { 31 + pf->hw_ops = &otx2_hw_ops; 32 + return 0; 33 + } 34 + 35 + pf->hw_ops = &cn10k_hw_ops; 36 + base = pci_resource_start(pf->pdev, PCI_MBOX_BAR_NUM) + 37 + (MBOX_SIZE * (pf->total_vfs + 1)); 38 + 39 + size = pci_resource_len(pf->pdev, PCI_MBOX_BAR_NUM) - 40 + (MBOX_SIZE * (pf->total_vfs + 1)); 41 + 42 + pf->hw.lmt_base = ioremap(base, size); 43 + 44 + if (!pf->hw.lmt_base) { 45 + dev_err(pf->dev, "Unable to map PF LMTST region\n"); 46 + return -ENOMEM; 47 + } 48 + 49 + /* FIXME: Get the num of LMTST lines from LMT table */ 50 + pf->tot_lmt_lines = size / LMT_LINE_SIZE; 51 + num_lines = (pf->tot_lmt_lines - NIX_LMTID_BASE) / 52 + pf->hw.tx_queues; 53 + /* Number of LMT lines per SQ queues */ 54 + pf->nix_lmt_lines = num_lines > 32 ? 32 : num_lines; 55 + 56 + pf->nix_lmt_size = pf->nix_lmt_lines * LMT_LINE_SIZE; 57 + return 0; 58 + } 59 + 60 + int cn10k_vf_lmtst_init(struct otx2_nic *vf) 61 + { 62 + int size, num_lines; 63 + 64 + if (!test_bit(CN10K_LMTST, &vf->hw.cap_flag)) { 65 + vf->hw_ops = &otx2_hw_ops; 66 + return 0; 67 + } 68 + 69 + vf->hw_ops = &cn10k_hw_ops; 70 + size = pci_resource_len(vf->pdev, PCI_MBOX_BAR_NUM); 71 + vf->hw.lmt_base = ioremap_wc(pci_resource_start(vf->pdev, 72 + PCI_MBOX_BAR_NUM), 73 + size); 74 + if (!vf->hw.lmt_base) { 75 + dev_err(vf->dev, "Unable to map VF LMTST region\n"); 76 + return -ENOMEM; 77 + } 78 + 79 + vf->tot_lmt_lines = size / LMT_LINE_SIZE; 80 + /* LMTST lines per SQ */ 81 + num_lines = (vf->tot_lmt_lines - NIX_LMTID_BASE) / 82 + vf->hw.tx_queues; 83 + vf->nix_lmt_lines = num_lines > 32 ? 32 : num_lines; 84 + vf->nix_lmt_size = vf->nix_lmt_lines * LMT_LINE_SIZE; 85 + return 0; 86 + } 87 + EXPORT_SYMBOL(cn10k_vf_lmtst_init); 88 + 89 + int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura) 90 + { 91 + struct nix_cn10k_aq_enq_req *aq; 92 + struct otx2_nic *pfvf = dev; 93 + struct otx2_snd_queue *sq; 94 + 95 + sq = &pfvf->qset.sq[qidx]; 96 + sq->lmt_addr = (__force u64 *)((u64)pfvf->hw.nix_lmt_base + 97 + (qidx * pfvf->nix_lmt_size)); 98 + 99 + /* Get memory to put this msg */ 100 + aq = otx2_mbox_alloc_msg_nix_cn10k_aq_enq(&pfvf->mbox); 101 + if (!aq) 102 + return -ENOMEM; 103 + 104 + aq->sq.cq = pfvf->hw.rx_queues + qidx; 105 + aq->sq.max_sqe_size = NIX_MAXSQESZ_W16; /* 128 byte */ 106 + aq->sq.cq_ena = 1; 107 + aq->sq.ena = 1; 108 + /* Only one SMQ is allocated, map all SQ's to that SMQ */ 109 + aq->sq.smq = pfvf->hw.txschq_list[NIX_TXSCH_LVL_SMQ][0]; 110 + /* FIXME: set based on NIX_AF_DWRR_RPM_MTU*/ 111 + aq->sq.smq_rr_weight = OTX2_MAX_MTU; 112 + aq->sq.default_chan = pfvf->hw.tx_chan_base; 113 + aq->sq.sqe_stype = NIX_STYPE_STF; /* Cache SQB */ 114 + aq->sq.sqb_aura = sqb_aura; 115 + aq->sq.sq_int_ena = NIX_SQINT_BITS; 116 + aq->sq.qint_idx = 0; 117 + /* Due pipelining impact minimum 2000 unused SQ CQE's 118 + * need to maintain to avoid CQ overflow. 119 + */ 120 + aq->sq.cq_limit = ((SEND_CQ_SKID * 256) / (pfvf->qset.sqe_cnt)); 121 + 122 + /* Fill AQ info */ 123 + aq->qidx = qidx; 124 + aq->ctype = NIX_AQ_CTYPE_SQ; 125 + aq->op = NIX_AQ_INSTOP_INIT; 126 + 127 + return otx2_sync_mbox_msg(&pfvf->mbox); 128 + } 129 + 130 + #define NPA_MAX_BURST 16 131 + void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq) 132 + { 133 + struct otx2_nic *pfvf = dev; 134 + u64 ptrs[NPA_MAX_BURST]; 135 + int num_ptrs = 1; 136 + dma_addr_t bufptr; 137 + 138 + /* Refill pool with new buffers */ 139 + while (cq->pool_ptrs) { 140 + if (otx2_alloc_buffer(pfvf, cq, &bufptr)) { 141 + if (num_ptrs--) 142 + __cn10k_aura_freeptr(pfvf, cq->cq_idx, ptrs, 143 + num_ptrs, 144 + cq->rbpool->lmt_addr); 145 + break; 146 + } 147 + cq->pool_ptrs--; 148 + ptrs[num_ptrs] = (u64)bufptr + OTX2_HEAD_ROOM; 149 + num_ptrs++; 150 + if (num_ptrs == NPA_MAX_BURST || cq->pool_ptrs == 0) { 151 + __cn10k_aura_freeptr(pfvf, cq->cq_idx, ptrs, 152 + num_ptrs, 153 + cq->rbpool->lmt_addr); 154 + num_ptrs = 1; 155 + } 156 + } 157 + } 158 + 159 + void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, int size, int qidx) 160 + { 161 + struct otx2_nic *pfvf = dev; 162 + int lmt_id = NIX_LMTID_BASE + (qidx * pfvf->nix_lmt_lines); 163 + u64 val = 0, tar_addr = 0; 164 + 165 + /* FIXME: val[0:10] LMT_ID. 166 + * [12:15] no of LMTST - 1 in the burst. 167 + * [19:63] data size of each LMTST in the burst except first. 168 + */ 169 + val = (lmt_id & 0x7FF); 170 + /* Target address for LMTST flush tells HW how many 128bit 171 + * words are present. 172 + * tar_addr[6:4] size of first LMTST - 1 in units of 128b. 173 + */ 174 + tar_addr |= sq->io_addr | (((size / 16) - 1) & 0x7) << 4; 175 + dma_wmb(); 176 + memcpy(sq->lmt_addr, sq->sqe_base, size); 177 + cn10k_lmt_flush(val, tar_addr); 178 + 179 + sq->head++; 180 + sq->head &= (sq->sqe_cnt - 1); 181 + }
+17
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 2 + * Marvell OcteonTx2 RVU Ethernet driver 3 + * 4 + * Copyright (C) 2020 Marvell. 5 + */ 6 + 7 + #ifndef CN10K_H 8 + #define CN10K_H 9 + 10 + #include "otx2_common.h" 11 + 12 + void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq); 13 + void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, int size, int qidx); 14 + int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura); 15 + int cn10k_pf_lmtst_init(struct otx2_nic *pf); 16 + int cn10k_vf_lmtst_init(struct otx2_nic *vf); 17 + #endif /* CN10K_H */
+36 -48
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
··· 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) ··· 527 526 return ret; 528 527 } 529 528 529 + int otx2_alloc_buffer(struct otx2_nic *pfvf, struct otx2_cq_queue *cq, 530 + dma_addr_t *dma) 531 + { 532 + if (unlikely(__otx2_alloc_rbuf(pfvf, cq->rbpool, dma))) { 533 + struct refill_work *work; 534 + struct delayed_work *dwork; 535 + 536 + work = &pfvf->refill_wrk[cq->cq_idx]; 537 + dwork = &work->pool_refill_work; 538 + /* Schedule a task if no other task is running */ 539 + if (!cq->refill_task_sched) { 540 + cq->refill_task_sched = true; 541 + schedule_delayed_work(dwork, 542 + msecs_to_jiffies(100)); 543 + } 544 + return -ENOMEM; 545 + } 546 + return 0; 547 + } 548 + 530 549 void otx2_tx_timeout(struct net_device *netdev, unsigned int txq) 531 550 { 532 551 struct otx2_nic *pfvf = netdev_priv(netdev); ··· 749 728 #define RQ_PASS_LVL_AURA (255 - ((95 * 256) / 100)) /* RED when 95% is full */ 750 729 #define RQ_DROP_LVL_AURA (255 - ((99 * 256) / 100)) /* Drop when 99% is full */ 751 730 752 - /* Send skid of 2000 packets required for CQ size of 4K CQEs. */ 753 - #define SEND_CQ_SKID 2000 754 - 755 731 static int otx2_rq_init(struct otx2_nic *pfvf, u16 qidx, u16 lpb_aura) 756 732 { 757 733 struct otx2_qset *qset = &pfvf->qset; ··· 782 764 return otx2_sync_mbox_msg(&pfvf->mbox); 783 765 } 784 766 785 - static int cn10k_sq_aq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura) 767 + int otx2_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura) 786 768 { 787 - struct nix_cn10k_aq_enq_req *aq; 788 - 789 - /* Get memory to put this msg */ 790 - aq = otx2_mbox_alloc_msg_nix_cn10k_aq_enq(&pfvf->mbox); 791 - if (!aq) 792 - return -ENOMEM; 793 - 794 - aq->sq.cq = pfvf->hw.rx_queues + qidx; 795 - aq->sq.max_sqe_size = NIX_MAXSQESZ_W16; /* 128 byte */ 796 - aq->sq.cq_ena = 1; 797 - aq->sq.ena = 1; 798 - /* Only one SMQ is allocated, map all SQ's to that SMQ */ 799 - aq->sq.smq = pfvf->hw.txschq_list[NIX_TXSCH_LVL_SMQ][0]; 800 - /* FIXME: set based on NIX_AF_DWRR_RPM_MTU*/ 801 - aq->sq.smq_rr_weight = OTX2_MAX_MTU; 802 - aq->sq.default_chan = pfvf->hw.tx_chan_base; 803 - aq->sq.sqe_stype = NIX_STYPE_STF; /* Cache SQB */ 804 - aq->sq.sqb_aura = sqb_aura; 805 - aq->sq.sq_int_ena = NIX_SQINT_BITS; 806 - aq->sq.qint_idx = 0; 807 - /* Due pipelining impact minimum 2000 unused SQ CQE's 808 - * need to maintain to avoid CQ overflow. 809 - */ 810 - aq->sq.cq_limit = ((SEND_CQ_SKID * 256) / (pfvf->qset.sqe_cnt)); 811 - 812 - /* Fill AQ info */ 813 - aq->qidx = qidx; 814 - aq->ctype = NIX_AQ_CTYPE_SQ; 815 - aq->op = NIX_AQ_INSTOP_INIT; 816 - 817 - return otx2_sync_mbox_msg(&pfvf->mbox); 818 - } 819 - 820 - static int otx2_sq_aq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura) 821 - { 769 + struct otx2_nic *pfvf = dev; 770 + struct otx2_snd_queue *sq; 822 771 struct nix_aq_enq_req *aq; 823 772 773 + sq = &pfvf->qset.sq[qidx]; 774 + sq->lmt_addr = (__force u64 *)(pfvf->reg_base + LMT_LF_LMTLINEX(qidx)); 824 775 /* Get memory to put this msg */ 825 776 aq = otx2_mbox_alloc_msg_nix_aq_enq(&pfvf->mbox); 826 777 if (!aq) ··· 860 873 sq->sqe_thresh = ((sq->num_sqbs * sq->sqe_per_sqb) * 10) / 100; 861 874 sq->aura_id = sqb_aura; 862 875 sq->aura_fc_addr = pool->fc_addr->base; 863 - sq->lmt_addr = (__force u64 *)(pfvf->reg_base + LMT_LF_LMTLINEX(qidx)); 864 876 sq->io_addr = (__force u64)otx2_get_regaddr(pfvf, NIX_LF_OP_SENDX(0)); 865 877 866 878 sq->stats.bytes = 0; 867 879 sq->stats.pkts = 0; 868 880 869 - if (is_dev_otx2(pfvf->pdev)) 870 - return otx2_sq_aq_init(pfvf, qidx, sqb_aura); 871 - else 872 - return cn10k_sq_aq_init(pfvf, qidx, sqb_aura); 881 + return pfvf->hw_ops->sq_aq_init(pfvf, qidx, sqb_aura); 873 882 874 883 } 875 884 ··· 970 987 } 971 988 return; 972 989 } 973 - otx2_aura_freeptr(pfvf, qidx, bufptr + OTX2_HEAD_ROOM); 990 + pfvf->hw_ops->aura_freeptr(pfvf, qidx, bufptr + OTX2_HEAD_ROOM); 974 991 cq->pool_ptrs--; 975 992 } 976 993 cq->refill_task_sched = false; ··· 1214 1231 1215 1232 pool->rbsize = buf_size; 1216 1233 1234 + /* Set LMTST addr for NPA batch free */ 1235 + if (test_bit(CN10K_LMTST, &pfvf->hw.cap_flag)) 1236 + pool->lmt_addr = (__force u64 *)((u64)pfvf->hw.npa_lmt_base + 1237 + (pool_id * LMT_LINE_SIZE)); 1238 + 1217 1239 /* Initialize this pool's context via AF */ 1218 1240 aq = otx2_mbox_alloc_msg_npa_aq_enq(&pfvf->mbox); 1219 1241 if (!aq) { ··· 1307 1319 for (ptr = 0; ptr < num_sqbs; ptr++) { 1308 1320 if (otx2_alloc_rbuf(pfvf, pool, &bufptr)) 1309 1321 return -ENOMEM; 1310 - otx2_aura_freeptr(pfvf, pool_id, bufptr); 1322 + pfvf->hw_ops->aura_freeptr(pfvf, pool_id, bufptr); 1311 1323 sq->sqb_ptrs[sq->sqb_count++] = (u64)bufptr; 1312 1324 } 1313 1325 } ··· 1357 1369 for (ptr = 0; ptr < num_ptrs; ptr++) { 1358 1370 if (otx2_alloc_rbuf(pfvf, pool, &bufptr)) 1359 1371 return -ENOMEM; 1360 - otx2_aura_freeptr(pfvf, pool_id, 1361 - bufptr + OTX2_HEAD_ROOM); 1372 + pfvf->hw_ops->aura_freeptr(pfvf, pool_id, 1373 + bufptr + OTX2_HEAD_ROOM); 1362 1374 } 1363 1375 } 1364 1376
+63 -5
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
··· 50 50 #define NIX_LF_ERR_VEC 0x81 51 51 #define NIX_LF_POISON_VEC 0x82 52 52 53 + /* Send skid of 2000 packets required for CQ size of 4K CQEs. */ 54 + #define SEND_CQ_SKID 2000 55 + 53 56 /* RSS configuration */ 54 57 struct otx2_rss_ctx { 55 58 u8 ind_tbl[MAX_RSS_INDIR_TBL_SIZE]; ··· 278 275 struct list_head flow_list; 279 276 }; 280 277 278 + struct dev_hw_ops { 279 + int (*sq_aq_init)(void *dev, u16 qidx, u16 sqb_aura); 280 + void (*sqe_flush)(void *dev, struct otx2_snd_queue *sq, 281 + int size, int qidx); 282 + void (*refill_pool_ptrs)(void *dev, struct otx2_cq_queue *cq); 283 + void (*aura_freeptr)(void *dev, int aura, u64 buf); 284 + }; 285 + 281 286 struct otx2_nic { 282 287 void __iomem *reg_base; 283 288 struct net_device *netdev; 289 + struct dev_hw_ops *hw_ops; 284 290 void *iommu_domain; 285 291 u16 max_frs; 286 292 u16 rbsize; /* Receive buffer size */ ··· 519 507 } 520 508 521 509 #else 522 - #define otx2_write128(lo, hi, addr) 510 + #define otx2_write128(lo, hi, addr) writeq((hi) | (lo), addr) 523 511 #define otx2_atomic64_add(incr, ptr) ({ *ptr += incr; }) 524 512 #endif 513 + 514 + static inline void __cn10k_aura_freeptr(struct otx2_nic *pfvf, u64 aura, 515 + u64 *ptrs, u64 num_ptrs, 516 + u64 *lmt_addr) 517 + { 518 + u64 size = 0, count_eot = 0; 519 + u64 tar_addr, val = 0; 520 + 521 + tar_addr = (__force u64)otx2_get_regaddr(pfvf, NPA_LF_AURA_BATCH_FREE0); 522 + /* LMTID is same as AURA Id */ 523 + val = (aura & 0x7FF) | BIT_ULL(63); 524 + /* Set if [127:64] of last 128bit word has a valid pointer */ 525 + count_eot = (num_ptrs % 2) ? 0ULL : 1ULL; 526 + /* Set AURA ID to free pointer */ 527 + ptrs[0] = (count_eot << 32) | (aura & 0xFFFFF); 528 + /* Target address for LMTST flush tells HW how many 128bit 529 + * words are valid from NPA_LF_AURA_BATCH_FREE0. 530 + * 531 + * tar_addr[6:4] is LMTST size-1 in units of 128b. 532 + */ 533 + if (num_ptrs > 2) { 534 + size = (sizeof(u64) * num_ptrs) / 16; 535 + if (!count_eot) 536 + size++; 537 + tar_addr |= ((size - 1) & 0x7) << 4; 538 + } 539 + memcpy(lmt_addr, ptrs, sizeof(u64) * num_ptrs); 540 + /* Perform LMTST flush */ 541 + cn10k_lmt_flush(val, tar_addr); 542 + } 543 + 544 + static inline void cn10k_aura_freeptr(void *dev, int aura, u64 buf) 545 + { 546 + struct otx2_nic *pfvf = dev; 547 + struct otx2_pool *pool; 548 + u64 ptrs[2]; 549 + 550 + pool = &pfvf->qset.pool[aura]; 551 + ptrs[1] = buf; 552 + __cn10k_aura_freeptr(pfvf, aura, ptrs, 2, pool->lmt_addr); 553 + } 525 554 526 555 /* Alloc pointer from pool/aura */ 527 556 static inline u64 otx2_aura_allocptr(struct otx2_nic *pfvf, int aura) ··· 575 522 } 576 523 577 524 /* Free pointer to a pool/aura */ 578 - static inline void otx2_aura_freeptr(struct otx2_nic *pfvf, 579 - int aura, u64 buf) 525 + static inline void otx2_aura_freeptr(void *dev, int aura, u64 buf) 580 526 { 581 - otx2_write128(buf, (u64)aura | BIT_ULL(63), 582 - otx2_get_regaddr(pfvf, NPA_LF_AURA_OP_FREE0)); 527 + struct otx2_nic *pfvf = dev; 528 + void __iomem *addr = otx2_get_regaddr(pfvf, NPA_LF_AURA_OP_FREE0); 529 + 530 + otx2_write128(buf, (u64)aura | BIT_ULL(63), addr); 583 531 } 584 532 585 533 static inline int otx2_get_pool_idx(struct otx2_nic *pfvf, int type, int idx) ··· 735 681 int otx2_nix_config_bp(struct otx2_nic *pfvf, bool enable); 736 682 void otx2_cleanup_rx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq); 737 683 void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq); 684 + int otx2_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura); 685 + int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura); 686 + int otx2_alloc_buffer(struct otx2_nic *pfvf, struct otx2_cq_queue *cq, 687 + dma_addr_t *dma); 738 688 739 689 /* RSS configuration APIs*/ 740 690 int otx2_rss_init(struct otx2_nic *pfvf);
+2 -34
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
··· 22 22 #include "otx2_txrx.h" 23 23 #include "otx2_struct.h" 24 24 #include "otx2_ptp.h" 25 + #include "cn10k.h" 25 26 #include <rvu_trace.h> 26 27 27 28 #define DRV_NAME "rvu_nicpf" ··· 46 45 47 46 static int otx2_config_hw_tx_tstamp(struct otx2_nic *pfvf, bool enable); 48 47 static int otx2_config_hw_rx_tstamp(struct otx2_nic *pfvf, bool enable); 49 - 50 - static int cn10k_lmtst_init(struct otx2_nic *pf) 51 - { 52 - int size, num_lines; 53 - u64 base; 54 - 55 - if (!test_bit(CN10K_LMTST, &pf->hw.cap_flag)) 56 - return 0; 57 - 58 - base = pci_resource_start(pf->pdev, PCI_MBOX_BAR_NUM) + 59 - (MBOX_SIZE * (pf->total_vfs + 1)); 60 - 61 - size = pci_resource_len(pf->pdev, PCI_MBOX_BAR_NUM) - 62 - (MBOX_SIZE * (pf->total_vfs + 1)); 63 - 64 - pf->hw.lmt_base = ioremap(base, size); 65 - 66 - if (!pf->hw.lmt_base) { 67 - dev_err(pf->dev, "Unable to map PF LMTST region\n"); 68 - return -ENOMEM; 69 - } 70 - 71 - /* FIXME: Get the num of LMTST lines from LMT table */ 72 - pf->tot_lmt_lines = size / LMT_LINE_SIZE; 73 - num_lines = (pf->tot_lmt_lines - NIX_LMTID_BASE) / 74 - pf->hw.tx_queues; 75 - /* Number of LMT lines per SQ queues */ 76 - pf->nix_lmt_lines = num_lines > 32 ? 32 : num_lines; 77 - 78 - pf->nix_lmt_size = pf->nix_lmt_lines * LMT_LINE_SIZE; 79 - 80 - return 0; 81 - } 82 48 83 49 static int otx2_change_mtu(struct net_device *netdev, int new_mtu) 84 50 { ··· 2372 2404 if (err) 2373 2405 goto err_detach_rsrc; 2374 2406 2375 - err = cn10k_lmtst_init(pf); 2407 + err = cn10k_pf_lmtst_init(pf); 2376 2408 if (err) 2377 2409 goto err_detach_rsrc; 2378 2410
+1
drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h
··· 94 94 #define NPA_LF_QINTX_INT_W1S(a) (NPA_LFBASE | 0x318 | (a) << 12) 95 95 #define NPA_LF_QINTX_ENA_W1S(a) (NPA_LFBASE | 0x320 | (a) << 12) 96 96 #define NPA_LF_QINTX_ENA_W1C(a) (NPA_LFBASE | 0x330 | (a) << 12) 97 + #define NPA_LF_AURA_BATCH_FREE0 (NPA_LFBASE | 0x400) 97 98 98 99 /* NIX LF registers */ 99 100 #define NIX_LFBASE (BLKTYPE_NIX << RVU_FUNC_BLKADDR_SHIFT)
+18 -21
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
··· 17 17 #include "otx2_struct.h" 18 18 #include "otx2_txrx.h" 19 19 #include "otx2_ptp.h" 20 + #include "cn10k.h" 20 21 21 22 #define CQE_ADDR(CQ, idx) ((CQ)->cqe_base + ((CQ)->cqe_size * (idx))) 22 23 ··· 200 199 sg = (struct nix_rx_sg_s *)start; 201 200 seg_addr = &sg->seg_addr; 202 201 for (seg = 0; seg < sg->segs; seg++, seg_addr++) 203 - otx2_aura_freeptr(pfvf, qidx, *seg_addr & ~0x07ULL); 202 + pfvf->hw_ops->aura_freeptr(pfvf, qidx, 203 + *seg_addr & ~0x07ULL); 204 204 start += sizeof(*sg); 205 205 } 206 206 } ··· 306 304 { 307 305 struct nix_cqe_rx_s *cqe; 308 306 int processed_cqe = 0; 309 - dma_addr_t bufptr; 310 307 311 308 while (likely(processed_cqe < budget)) { 312 309 cqe = (struct nix_cqe_rx_s *)CQE_ADDR(cq, cq->cq_head); ··· 331 330 332 331 if (unlikely(!cq->pool_ptrs)) 333 332 return 0; 334 - 335 333 /* Refill pool with new buffers */ 336 - while (cq->pool_ptrs) { 337 - if (unlikely(__otx2_alloc_rbuf(pfvf, cq->rbpool, &bufptr))) { 338 - struct refill_work *work; 339 - struct delayed_work *dwork; 334 + pfvf->hw_ops->refill_pool_ptrs(pfvf, cq); 340 335 341 - work = &pfvf->refill_wrk[cq->cq_idx]; 342 - dwork = &work->pool_refill_work; 343 - /* Schedule a task if no other task is running */ 344 - if (!cq->refill_task_sched) { 345 - cq->refill_task_sched = true; 346 - schedule_delayed_work(dwork, 347 - msecs_to_jiffies(100)); 348 - } 336 + return processed_cqe; 337 + } 338 + 339 + void otx2_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq) 340 + { 341 + struct otx2_nic *pfvf = dev; 342 + dma_addr_t bufptr; 343 + 344 + while (cq->pool_ptrs) { 345 + if (otx2_alloc_buffer(pfvf, cq, &bufptr)) 349 346 break; 350 - } 351 347 otx2_aura_freeptr(pfvf, cq->cq_idx, bufptr + OTX2_HEAD_ROOM); 352 348 cq->pool_ptrs--; 353 349 } 354 - 355 - return processed_cqe; 356 350 } 357 351 358 352 static int otx2_tx_napi_handler(struct otx2_nic *pfvf, ··· 434 438 return workdone; 435 439 } 436 440 437 - static void otx2_sqe_flush(struct otx2_snd_queue *sq, int size) 441 + void otx2_sqe_flush(void *dev, struct otx2_snd_queue *sq, 442 + int size, int qidx) 438 443 { 439 444 u64 status; 440 445 ··· 793 796 sqe_hdr->sizem1 = (offset / 16) - 1; 794 797 795 798 /* Flush SQE to HW */ 796 - otx2_sqe_flush(sq, offset); 799 + pfvf->hw_ops->sqe_flush(pfvf, sq, offset, qidx); 797 800 } 798 801 } 799 802 ··· 912 915 netdev_tx_sent_queue(txq, skb->len); 913 916 914 917 /* Flush SQE to HW */ 915 - otx2_sqe_flush(sq, offset); 918 + pfvf->hw_ops->sqe_flush(pfvf, sq, offset, qidx); 916 919 917 920 return true; 918 921 }
+7
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h
··· 114 114 struct otx2_pool { 115 115 struct qmem *stack; 116 116 struct qmem *fc_addr; 117 + u64 *lmt_addr; 117 118 u16 rbsize; 118 119 }; 119 120 ··· 157 156 int otx2_napi_handler(struct napi_struct *napi, int budget); 158 157 bool otx2_sq_append_skb(struct net_device *netdev, struct otx2_snd_queue *sq, 159 158 struct sk_buff *skb, u16 qidx); 159 + void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, 160 + int size, int qidx); 161 + void otx2_sqe_flush(void *dev, struct otx2_snd_queue *sq, 162 + int size, int qidx); 163 + void otx2_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq); 164 + void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq); 160 165 #endif /* OTX2_TXRX_H */
+2 -26
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
··· 7 7 8 8 #include "otx2_common.h" 9 9 #include "otx2_reg.h" 10 + #include "cn10k.h" 10 11 11 12 #define DRV_NAME "rvu_nicvf" 12 13 #define DRV_STRING "Marvell RVU NIC Virtual Function Driver" ··· 27 26 enum { 28 27 RVU_VF_INT_VEC_MBOX = 0x0, 29 28 }; 30 - 31 - static int cn10k_lmtst_init(struct otx2_nic *vf) 32 - { 33 - int size, num_lines; 34 - 35 - if (!test_bit(CN10K_LMTST, &vf->hw.cap_flag)) 36 - return 0; 37 - 38 - size = pci_resource_len(vf->pdev, PCI_MBOX_BAR_NUM); 39 - vf->hw.lmt_base = ioremap_wc(pci_resource_start(vf->pdev, 40 - PCI_MBOX_BAR_NUM), 41 - size); 42 - if (!vf->hw.lmt_base) { 43 - dev_err(vf->dev, "Unable to map VF LMTST region\n"); 44 - return -ENOMEM; 45 - } 46 - 47 - vf->tot_lmt_lines = size / LMT_LINE_SIZE; 48 - /* LMTST lines per SQ */ 49 - num_lines = (vf->tot_lmt_lines - NIX_LMTID_BASE) / 50 - vf->hw.tx_queues; 51 - vf->nix_lmt_lines = num_lines > 32 ? 32 : num_lines; 52 - vf->nix_lmt_size = vf->nix_lmt_lines * LMT_LINE_SIZE; 53 - return 0; 54 - } 55 29 56 30 static void otx2vf_process_vfaf_mbox_msg(struct otx2_nic *vf, 57 31 struct mbox_msghdr *msg) ··· 561 585 if (err) 562 586 goto err_detach_rsrc; 563 587 564 - err = cn10k_lmtst_init(vf); 588 + err = cn10k_vf_lmtst_init(vf); 565 589 if (err) 566 590 goto err_detach_rsrc; 567 591
+8
include/linux/soc/marvell/octeontx2/asm.h
··· 22 22 : [rs]"r" (ioaddr)); \ 23 23 (result); \ 24 24 }) 25 + #define cn10k_lmt_flush(val, addr) \ 26 + ({ \ 27 + __asm__ volatile(".cpu generic+lse\n" \ 28 + "steor %x[rf],[%[rs]]" \ 29 + : [rf]"+r"(val) \ 30 + : [rs]"r"(addr)); \ 31 + }) 25 32 #else 26 33 #define otx2_lmt_flush(ioaddr) ({ 0; }) 34 + #define cn10k_lmt_flush(val, addr) ({ addr = val; }) 27 35 #endif 28 36 29 37 #endif /* __SOC_OTX2_ASM_H */