octeontx2-pf: cn10k: Use LMTST lines for NPA/NIX operations
Subsystems (4)
Geetha sowjanya
maintainerPATCH 7/14 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 <[email protected]>
Signed-off-by Sunil Goutham <[email protected]>
--- .../net/ethernet/marvell/octeontx2/nic/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c | 182 +++++++++++++++++++++ drivers/net/ethernet/marvell/octeontx2/nic/cn10k.h | 17 ++ .../ethernet/marvell/octeontx2/nic/otx2_common.c | 81 ++++----- .../ethernet/marvell/octeontx2/nic/otx2_common.h | 61 ++++++- .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 36 +--- .../net/ethernet/marvell/octeontx2/nic/otx2_reg.h | 1 + .../net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 38 ++--- .../net/ethernet/marvell/octeontx2/nic/otx2_txrx.h | 7 + .../net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 28 +--- include/linux/soc/marvell/octeontx2/asm.h | 8 + 11 files changed, 330 insertions(+), 131 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/cn10k.h
drivers/net/ethernet/marvell/octeontx2/nic/Makefile +1 -1
@@ -7,7 +7,7 @@ obj-$(CONFIG_OCTEONTX2_PF) += octeontx2_nicpf.o obj-$(CONFIG_OCTEONTX2_VF) += octeontx2_nicvf.o octeontx2_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o \ - otx2_ptp.o otx2_flows.o + otx2_ptp.o otx2_flows.o cn10k.o octeontx2_nicvf-y := otx2_vf.o ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c new file +182 -0
182 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 +* Marvell OcteonTx2 RVU Ethernet driver +* +* Copyright (C) 2020 Marvell. +*/ + +#ifndef CN10K_H +#define CN10K_H + +#include "otx2_common.h" + +void cn10k_refill_pool_ptrs (void *dev,struct otx2_cq_queue *cq); +void cn10k_sqe_flush (void *dev,struct otx2_snd_queue *sq,int size,int qidx); +int cn10k_sq_aq_init (void *dev,u16 qidx,u16 sqb_aura); +int cn10k_pf_lmtst_init (struct otx2_nic *pf); +int cn10k_vf_lmtst_init (struct otx2_nic *vf); +#endif /* CN10K_H */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +34 -47
137 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +59 -2
95 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +2 -34
@@ -22,6 +22,7 @@#include "otx2_txrx.h" #include "otx2_struct.h" #include "otx2_ptp.h" +#include "cn10k.h" #include <rvu_trace.h> #define DRV_NAME "RVU-nicpf"
@@ -46,39 +47,6 @@ enum {static int otx2_config_hw_tx_tstamp (struct otx2_nic *pfvf,bool enable);static int otx2_config_hw_rx_tstamp (struct otx2_nic *pfvf,bool enable); -static int cn10k_lmtst_init (struct otx2_nic *pf) -{ -int size, num_lines; -u64 base; - -if (!test_bit (CN10K_LMTST , &pf->hw.cap_flag)) -return 0 ; - - base =pci_resource_start (pf->pdev,PCI_MBOX_BAR_NUM ) + - (MBOX_SIZE * (pf->total_vfs +1 )); - - size =pci_resource_len (pf->pdev,PCI_MBOX_BAR_NUM ) - - (MBOX_SIZE * (pf->total_vfs +1 )); - - pf->hw.lmt_base =ioremap (base, size); - -if (!pf->hw.lmt_base) { -dev_err (pf->dev,"Unable to map PF LMTST region\n" ); -return -ENOMEM ; - } - -/* FIXME: Get the num of LMTST lines from LMT table */ - pf->tot_lmt_lines = size /LMT_LINE_SIZE ; - num_lines = (pf->tot_lmt_lines -NIX_LMTID_BASE ) / - pf->hw.tx_queues; -/* Number of LMT lines per SQ queues */ - pf->nix_lmt_lines = num_lines >32 ?32 : num_lines; - - pf->nix_lmt_size = pf->nix_lmt_lines *LMT_LINE_SIZE ; - -return 0 ; -} -static int otx2_change_mtu (struct net_device *netdev,int new_mtu) {bool if_up =netif_running (netdev);
@@ -2401,7 +2369,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_detach_rsrc; - err =cn10k_lmtst_init (pf); + err =cn10k_pf_lmtst_init (pf);if (err) goto err_detach_rsrc;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h +1 -0
@@ -94,6 +94,7 @@#define NPA_LF_QINTX_INT_W1S (a) (NPA_LFBASE | 0x318 | (a) << 12)#define NPA_LF_QINTX_ENA_W1S (a) (NPA_LFBASE | 0x320 | (a) << 12)#define NPA_LF_QINTX_ENA_W1C (a) (NPA_LFBASE | 0x330 | (a) << 12) +#define NPA_LF_AURA_BATCH_FREE0 (NPA_LFBASE | 0x400)/* NIX LF registers */ #define NIX_LFBASE (BLKTYPE_NIX << RVU_FUNC_BLKADDR_SHIFT)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +17 -21
@@ -17,6 +17,7 @@#include "otx2_struct.h" #include "otx2_txrx.h" #include "otx2_ptp.h" +#include "cn10k.h" #define CQE_ADDR (CQ , idx) ((CQ)->cqe_base + ((CQ)->cqe_size * (idx)))
@@ -199,7 +200,7 @@ static void otx2_free_rcv_seg(struct otx2_nic *pfvf, struct nix_cqe_rx_s *cqe, sg = (struct nix_rx_sg_s *)start; seg_addr = &sg->seg_addr;for (seg =0 ; seg < sg->segs; seg++, seg_addr++) -otx2_aura_freeptr (pfvf, qidx, *seg_addr & ~0x07ULL ); + pfvf->hw_ops->aura_freeptr (pfvf, qidx, *seg_addr & ~0x07ULL ); start +=sizeof (*sg); } }
@@ -304,7 +305,6 @@ static int otx2_rx_napi_handler(struct otx2_nic *pfvf, {struct nix_cqe_rx_s *cqe;int processed_cqe =0 ; -s64 bufptr;while (likely (processed_cqe < budget)) { cqe = (struct nix_cqe_rx_s *)CQE_ADDR (cq, cq->cq_head);
@@ -330,29 +330,24 @@ static int otx2_rx_napi_handler(struct otx2_nic *pfvf,if (unlikely (!cq->pool_ptrs))return 0 ; + pfvf->hw_ops->refill_pool_ptrs (pfvf, cq); + +return processed_cqe; +} + +void otx2_refill_pool_ptrs (void *dev,struct otx2_cq_queue *cq) +{ +struct otx2_nic *pfvf = dev; +s64 bufptr;/* Refill pool with new buffers */ while (cq->pool_ptrs) { - bufptr =__otx2_alloc_rbuf (pfvf, cq->rbpool); -if (unlikely (bufptr <=0 )) { -struct refill_work *work; -struct delayed_work *dwork; - - work = &pfvf->refill_wrk[cq->cq_idx]; - dwork = &work->pool_refill_work; -/* Schedule a task if no other task is running */ -if (!cq->refill_task_sched) { - cq->refill_task_sched = true; -schedule_delayed_work (dwork, -msecs_to_jiffies (100 )); - } + bufptr =otx2_alloc_buffer (pfvf, cq); +if (unlikely (bufptr <=0 ))break ; - }otx2_aura_freeptr (pfvf, cq->cq_idx, bufptr +OTX2_HEAD_ROOM ); cq->pool_ptrs--; } - -return processed_cqe; } static int otx2_tx_napi_handler(struct otx2_nic *pfvf,
@@ -439,7 +434,8 @@ int otx2_napi_handler(struct napi_struct *napi, int budget)return workdone; } -static void otx2_sqe_flush (struct otx2_snd_queue *sq,int size) +void otx2_sqe_flush (void *dev,struct otx2_snd_queue *sq, +int size,int qidx) {u64 status;
@@ -797,7 +793,7 @@ static void otx2_sq_append_tso(struct otx2_nic *pfvf, struct otx2_snd_queue *sq, sqe_hdr->sizem1 = (offset /16 ) -1 ;/* Flush SQE to HW */ -otx2_sqe_flush (sq, offset); + pfvf->hw_ops->sqe_flush (pfvf, sq, offset, qidx); } }
@@ -916,7 +912,7 @@ bool otx2_sq_append_skb(struct net_device *netdev, struct otx2_snd_queue *sq,netdev_tx_sent_queue (txq, skb->len);/* Flush SQE to HW */ -otx2_sqe_flush (sq, offset); + pfvf->hw_ops->sqe_flush (pfvf, sq, offset, qidx);return true; }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +7 -0
@@ -114,6 +114,7 @@ struct otx2_cq_poll {struct otx2_pool {struct qmem *stack;struct qmem *fc_addr; +u64 *lmt_addr;u16 rbsize; };
@@ -156,4 +157,10 @@ static inline u64 otx2_iova_to_phys(void *iommu_domain, dma_addr_t dma_addr)int otx2_napi_handler (struct napi_struct *napi,int budget);bool otx2_sq_append_skb (struct net_device *netdev,struct otx2_snd_queue *sq,struct sk_buff *skb,u16 qidx); +void cn10k_sqe_flush (void *dev,struct otx2_snd_queue *sq, +int size,int qidx); +void otx2_sqe_flush (void *dev,struct otx2_snd_queue *sq, +int size,int qidx); +void otx2_refill_pool_ptrs (void *dev,struct otx2_cq_queue *cq); +void cn10k_refill_pool_ptrs (void *dev,struct otx2_cq_queue *cq);#endif /* OTX2_TXRX_H */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +2 -26
@@ -7,6 +7,7 @@#include "otx2_common.h" #include "otx2_reg.h" +#include "cn10k.h" #define DRV_NAME "RVU-nicvf"#define DRV_STRING "Marvell RVU NIC Virtual Function Driver"
@@ -27,31 +28,6 @@ enum { RVU_VF_INT_VEC_MBOX = 0x0, }; -static int cn10k_lmtst_init (struct otx2_nic *vf) -{ -int size, num_lines; - -if (!test_bit (CN10K_LMTST , &vf->hw.cap_flag)) -return 0 ; - - size =pci_resource_len (vf->pdev,PCI_MBOX_BAR_NUM ); - vf->hw.lmt_base =ioremap_wc (pci_resource_start (vf->pdev, -PCI_MBOX_BAR_NUM ), - size); -if (!vf->hw.lmt_base) { -dev_err (vf->dev,"Unable to map VF LMTST region\n" ); -return -ENOMEM ; - } - - vf->tot_lmt_lines = size /LMT_LINE_SIZE ; -/* LMTST lines per SQ */ - num_lines = (vf->tot_lmt_lines -NIX_LMTID_BASE ) / - vf->hw.tx_queues; - vf->nix_lmt_lines = num_lines >32 ?32 : num_lines; - vf->nix_lmt_size = vf->nix_lmt_lines *LMT_LINE_SIZE ; -return 0 ; -} -static void otx2vf_process_vfaf_mbox_msg (struct otx2_nic *vf,struct mbox_msghdr *msg) {
@@ -585,7 +561,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_detach_rsrc; - err =cn10k_lmtst_init (vf); + err =cn10k_vf_lmtst_init (vf);if (err) goto err_detach_rsrc;
include/linux/soc/marvell/octeontx2/asm.h +8 -0
@@ -22,8 +22,16 @@ : [rs]"r" (ioaddr)); \ (result); \ }) +#define cn10k_lmt_flush (val, addr) \ +({ \ + __asm__ volatile(".cpu generic+lse\n" \ + "steor %x[rf],[%[rs]]" \ + : [rf]"+r"(val) \ + : [rs]"r"(addr)); \ +})#else #define otx2_lmt_flush (ioaddr) ({ 0; }) +#define cn10k_lmt_flush (val, addr) ({ 0; })#endif #endif /* __SOC_OTX2_ASM_H */
Signature · 1 line
2.7.4