1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Marvell RVU Ethernet driver
4 * Copyright (C) 2020 Marvell.
11 #include <linux/ethtool.h>
12 #include <linux/pci.h>
13 #include <linux/iommu.h>
14 #include <linux/net_tstamp.h>
15 #include <linux/ptp_clock_kernel.h>
16 #include <linux/timecounter.h>
17 #include <linux/soc/marvell/octeontx2/asm.h>
18 #include <net/pkt_cls.h>
19 #include <net/devlink.h>
24 #include "otx2_txrx.h"
25 #include "otx2_devlink.h"
26 #include <rvu_trace.h>
29 #define PCI_DEVID_OCTEONTX2_RVU_PF 0xA063
30 #define PCI_DEVID_OCTEONTX2_RVU_VF 0xA064
31 #define PCI_DEVID_OCTEONTX2_RVU_AFVF 0xA0F8
33 #define PCI_SUBSYS_DEVID_96XX_RVU_PFVF 0xB200
36 #define PCI_CFG_REG_BAR_NUM 2
37 #define PCI_MBOX_BAR_NUM 4
41 enum arua_mapped_qtypes {
46 /* NIX LF interrupts range*/
47 #define NIX_LF_QINT_VEC_START 0x00
48 #define NIX_LF_CINT_VEC_START 0x40
49 #define NIX_LF_GINT_VEC 0x80
50 #define NIX_LF_ERR_VEC 0x81
51 #define NIX_LF_POISON_VEC 0x82
53 /* Send skid of 2000 packets required for CQ size of 4K CQEs. */
54 #define SEND_CQ_SKID 2000
56 struct otx2_lmt_info {
60 /* RSS configuration */
62 u8 ind_tbl[MAX_RSS_INDIR_TBL_SIZE];
65 struct otx2_rss_info {
69 #define RSS_HASH_KEY_SIZE 44 /* 352 bit key */
70 u8 key[RSS_HASH_KEY_SIZE];
71 struct otx2_rss_ctx *rss_ctx[MAX_RSS_GROUPS];
74 /* NIX (or NPC) RX errors */
85 NPC_ERRLVL_NIX = 0x0F,
88 enum otx2_errcodes_re {
89 /* NPC_ERRLVL_RE errcodes */
91 ERRCODE_FCS_RCV = 0x8,
92 ERRCODE_UNDERSIZE = 0x10,
93 ERRCODE_OVERSIZE = 0x11,
94 ERRCODE_OL2_LEN_MISMATCH = 0x12,
95 /* NPC_ERRLVL_NIX errcodes */
96 ERRCODE_OL3_LEN = 0x10,
97 ERRCODE_OL4_LEN = 0x11,
98 ERRCODE_OL4_CSUM = 0x12,
99 ERRCODE_IL3_LEN = 0x20,
100 ERRCODE_IL4_LEN = 0x21,
101 ERRCODE_IL4_CSUM = 0x22,
105 enum nix_stat_lf_tx {
115 enum nix_stat_lf_rx {
126 RX_DRP_L3BCAST = 0xa,
127 RX_DRP_L3MCAST = 0xb,
131 struct otx2_dev_stats {
147 /* Driver counted stats */
148 struct otx2_drv_stats {
149 atomic_t rx_fcs_errs;
150 atomic_t rx_oversize_errs;
151 atomic_t rx_undersize_errs;
152 atomic_t rx_csum_errs;
153 atomic_t rx_len_errs;
154 atomic_t rx_other_errs;
158 struct otx2_mbox mbox;
159 struct work_struct mbox_wrk;
160 struct otx2_mbox mbox_up;
161 struct work_struct mbox_up_wrk;
162 struct otx2_nic *pfvf;
163 void *bbuf_base; /* Bounce buffer for mbox memory */
164 struct mutex lock; /* serialize mailbox access */
165 int num_msgs; /* mbox number of messages */
166 int up_num_msgs; /* mbox_up number of messages */
170 struct pci_dev *pdev;
171 struct otx2_rss_info rss_info;
180 u32 stack_pg_ptrs; /* No of ptrs per stack page */
181 u32 stack_pg_bytes; /* Size of stack page */
185 u8 txschq_link_cfg_lvl;
186 u16 txschq_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
187 u16 matchall_ipolicer;
190 /* HW settings, coalescing etc */
208 u8 cint_cnt; /* CQ interrupt count */
209 u16 npa_msixoff; /* Offset of NPA vectors */
210 u16 nix_msixoff; /* Offset of NIX vectors */
212 cpumask_var_t *affinity_mask;
215 struct otx2_dev_stats dev_stats;
216 struct otx2_drv_stats drv_stats;
217 u64 cgx_rx_stats[CGX_RX_STATS_COUNT];
218 u64 cgx_tx_stats[CGX_TX_STATS_COUNT];
219 u64 cgx_fec_corr_blks;
220 u64 cgx_fec_uncorr_blks;
221 u8 cgx_links; /* No. of CGX links present in HW */
222 u8 lbk_links; /* No. of LBK links present in HW */
223 u8 tx_link; /* Transmit channel link number */
226 #define CN10K_LMTST 2
227 unsigned long cap_flag;
229 #define LMT_LINE_SIZE 128
230 #define LMT_BURST_SIZE 32 /* 32 LMTST lines for burst SQE flush */
232 struct otx2_lmt_info __percpu *lmt_info;
240 struct otx2_vf_config {
242 struct delayed_work link_event_work;
243 bool intf_down; /* interface was either configured or not */
251 struct work_struct work;
256 struct delayed_work pool_refill_work;
261 struct ptp_clock_info ptp_info;
262 struct ptp_clock *ptp_clock;
263 struct otx2_nic *nic;
265 struct cyclecounter cycle_counter;
266 struct timecounter time_counter;
269 #define OTX2_HW_TIMESTAMP_LEN 8
271 struct otx2_mac_table {
277 struct otx2_flow_config {
281 #define OTX2_DEFAULT_FLOWCOUNT 16
282 #define OTX2_MAX_UNICAST_FLOWS 8
283 #define OTX2_MAX_VLAN_FLOWS 1
284 #define OTX2_MAX_TC_FLOWS OTX2_DEFAULT_FLOWCOUNT
285 #define OTX2_MCAM_COUNT (OTX2_DEFAULT_FLOWCOUNT + \
286 OTX2_MAX_UNICAST_FLOWS + \
291 #define OTX2_PER_VF_VLAN_FLOWS 2 /* Rx + Tx per VF */
292 #define OTX2_VF_VLAN_RX_INDEX 0
293 #define OTX2_VF_VLAN_TX_INDEX 1
295 u8 dmacflt_max_flows;
296 u8 *bmap_to_dmacindex;
297 unsigned long dmacflt_bmap;
298 struct list_head flow_list;
301 struct otx2_tc_info {
302 /* hash table to store TC offloaded flows */
303 struct rhashtable flow_table;
304 struct rhashtable_params flow_ht_params;
305 unsigned long *tc_entries_bitmap;
309 int (*sq_aq_init)(void *dev, u16 qidx, u16 sqb_aura);
310 void (*sqe_flush)(void *dev, struct otx2_snd_queue *sq,
312 void (*refill_pool_ptrs)(void *dev, struct otx2_cq_queue *cq);
313 void (*aura_freeptr)(void *dev, int aura, u64 buf);
317 void __iomem *reg_base;
318 struct net_device *netdev;
319 struct dev_hw_ops *hw_ops;
322 u16 rbsize; /* Receive buffer size */
324 #define OTX2_FLAG_RX_TSTAMP_ENABLED BIT_ULL(0)
325 #define OTX2_FLAG_TX_TSTAMP_ENABLED BIT_ULL(1)
326 #define OTX2_FLAG_INTF_DOWN BIT_ULL(2)
327 #define OTX2_FLAG_MCAM_ENTRIES_ALLOC BIT_ULL(3)
328 #define OTX2_FLAG_NTUPLE_SUPPORT BIT_ULL(4)
329 #define OTX2_FLAG_UCAST_FLTR_SUPPORT BIT_ULL(5)
330 #define OTX2_FLAG_RX_VLAN_SUPPORT BIT_ULL(6)
331 #define OTX2_FLAG_VF_VLAN_SUPPORT BIT_ULL(7)
332 #define OTX2_FLAG_PF_SHUTDOWN BIT_ULL(8)
333 #define OTX2_FLAG_RX_PAUSE_ENABLED BIT_ULL(9)
334 #define OTX2_FLAG_TX_PAUSE_ENABLED BIT_ULL(10)
335 #define OTX2_FLAG_TC_FLOWER_SUPPORT BIT_ULL(11)
336 #define OTX2_FLAG_TC_MATCHALL_EGRESS_ENABLED BIT_ULL(12)
337 #define OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED BIT_ULL(13)
338 #define OTX2_FLAG_DMACFLTR_SUPPORT BIT_ULL(14)
342 struct otx2_qset qset;
344 struct pci_dev *pdev;
349 struct mbox *mbox_pfvf;
350 struct workqueue_struct *mbox_wq;
351 struct workqueue_struct *mbox_pfvf_wq;
354 u16 pcifunc; /* RVU PF_FUNC */
355 u16 bpid[NIX_MAX_BPID_CHAN];
356 struct otx2_vf_config *vf_configs;
357 struct cgx_link_user_info linfo;
360 struct otx2_flow_config *flow_cfg;
361 struct otx2_mac_table *mac_table;
362 struct otx2_tc_info tc_info;
365 struct work_struct reset_task;
366 struct workqueue_struct *flr_wq;
367 struct flr_work *flr_wrk;
368 struct refill_work *refill_wrk;
369 struct workqueue_struct *otx2_wq;
370 struct work_struct rx_mode_work;
375 /* Block address of NIX either BLKADDR_NIX0 or BLKADDR_NIX1 */
377 /* LMTST Lines info */
378 struct qmem *dync_lmt;
383 struct otx2_ptp *ptp;
384 struct hwtstamp_config tstamp;
386 unsigned long rq_bmap;
389 struct otx2_devlink *dl;
392 static inline bool is_otx2_lbkvf(struct pci_dev *pdev)
394 return pdev->device == PCI_DEVID_OCTEONTX2_RVU_AFVF;
397 static inline bool is_96xx_A0(struct pci_dev *pdev)
399 return (pdev->revision == 0x00) &&
400 (pdev->subsystem_device == PCI_SUBSYS_DEVID_96XX_RVU_PFVF);
403 static inline bool is_96xx_B0(struct pci_dev *pdev)
405 return (pdev->revision == 0x01) &&
406 (pdev->subsystem_device == PCI_SUBSYS_DEVID_96XX_RVU_PFVF);
409 /* REVID for PCIe devices.
410 * Bits 0..1: minor pass, bit 3..2: major pass
413 #define PCI_REVISION_ID_96XX 0x00
414 #define PCI_REVISION_ID_95XX 0x10
415 #define PCI_REVISION_ID_95XXN 0x20
416 #define PCI_REVISION_ID_98XX 0x30
417 #define PCI_REVISION_ID_95XXMM 0x40
418 #define PCI_REVISION_ID_95XXO 0xE0
420 static inline bool is_dev_otx2(struct pci_dev *pdev)
422 u8 midr = pdev->revision & 0xF0;
424 return (midr == PCI_REVISION_ID_96XX || midr == PCI_REVISION_ID_95XX ||
425 midr == PCI_REVISION_ID_95XXN || midr == PCI_REVISION_ID_98XX ||
426 midr == PCI_REVISION_ID_95XXMM || midr == PCI_REVISION_ID_95XXO);
429 static inline void otx2_setup_dev_hw_settings(struct otx2_nic *pfvf)
431 struct otx2_hw *hw = &pfvf->hw;
433 pfvf->hw.cq_time_wait = CQ_TIMER_THRESH_DEFAULT;
434 pfvf->hw.cq_ecount_wait = CQ_CQE_THRESH_DEFAULT;
435 pfvf->hw.cq_qcount_wait = CQ_QCOUNT_DEFAULT;
437 __set_bit(HW_TSO, &hw->cap_flag);
439 if (is_96xx_A0(pfvf->pdev)) {
440 __clear_bit(HW_TSO, &hw->cap_flag);
442 /* Time based irq coalescing is not supported */
443 pfvf->hw.cq_qcount_wait = 0x0;
445 /* Due to HW issue previous silicons required minimum
446 * 600 unused CQE to avoid CQ overflow.
448 pfvf->hw.rq_skid = 600;
449 pfvf->qset.rqe_cnt = Q_COUNT(Q_SIZE_1K);
451 if (is_96xx_B0(pfvf->pdev))
452 __clear_bit(HW_TSO, &hw->cap_flag);
454 if (!is_dev_otx2(pfvf->pdev)) {
455 __set_bit(CN10K_MBOX, &hw->cap_flag);
456 __set_bit(CN10K_LMTST, &hw->cap_flag);
460 /* Register read/write APIs */
461 static inline void __iomem *otx2_get_regaddr(struct otx2_nic *nic, u64 offset)
465 switch ((offset >> RVU_FUNC_BLKADDR_SHIFT) & RVU_FUNC_BLKADDR_MASK) {
467 blkaddr = nic->nix_blkaddr;
470 blkaddr = BLKADDR_NPA;
473 blkaddr = BLKADDR_RVUM;
477 offset &= ~(RVU_FUNC_BLKADDR_MASK << RVU_FUNC_BLKADDR_SHIFT);
478 offset |= (blkaddr << RVU_FUNC_BLKADDR_SHIFT);
480 return nic->reg_base + offset;
483 static inline void otx2_write64(struct otx2_nic *nic, u64 offset, u64 val)
485 void __iomem *addr = otx2_get_regaddr(nic, offset);
490 static inline u64 otx2_read64(struct otx2_nic *nic, u64 offset)
492 void __iomem *addr = otx2_get_regaddr(nic, offset);
497 /* Mbox bounce buffer APIs */
498 static inline int otx2_mbox_bbuf_init(struct mbox *mbox, struct pci_dev *pdev)
500 struct otx2_mbox *otx2_mbox;
501 struct otx2_mbox_dev *mdev;
503 mbox->bbuf_base = devm_kmalloc(&pdev->dev, MBOX_SIZE, GFP_KERNEL);
504 if (!mbox->bbuf_base)
507 /* Overwrite mbox mbase to point to bounce buffer, so that PF/VF
508 * prepare all mbox messages in bounce buffer instead of directly
511 otx2_mbox = &mbox->mbox;
512 mdev = &otx2_mbox->dev[0];
513 mdev->mbase = mbox->bbuf_base;
515 otx2_mbox = &mbox->mbox_up;
516 mdev = &otx2_mbox->dev[0];
517 mdev->mbase = mbox->bbuf_base;
521 static inline void otx2_sync_mbox_bbuf(struct otx2_mbox *mbox, int devid)
523 u16 msgs_offset = ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN);
524 void *hw_mbase = mbox->hwbase + (devid * MBOX_SIZE);
525 struct otx2_mbox_dev *mdev = &mbox->dev[devid];
526 struct mbox_hdr *hdr;
529 if (mdev->mbase == hw_mbase)
532 hdr = hw_mbase + mbox->rx_start;
533 msg_size = hdr->msg_size;
535 if (msg_size > mbox->rx_size - msgs_offset)
536 msg_size = mbox->rx_size - msgs_offset;
538 /* Copy mbox messages from mbox memory to bounce buffer */
539 memcpy(mdev->mbase + mbox->rx_start,
540 hw_mbase + mbox->rx_start, msg_size + msgs_offset);
543 /* With the absence of API for 128-bit IO memory access for arm64,
544 * implement required operations at place.
546 #if defined(CONFIG_ARM64)
547 static inline void otx2_write128(u64 lo, u64 hi, void __iomem *addr)
549 __asm__ volatile("stp %x[x0], %x[x1], [%x[p1],#0]!"
550 ::[x0]"r"(lo), [x1]"r"(hi), [p1]"r"(addr));
553 static inline u64 otx2_atomic64_add(u64 incr, u64 *ptr)
557 __asm__ volatile(".cpu generic+lse\n"
558 "ldadd %x[i], %x[r], [%[b]]"
559 : [r]"=r"(result), "+m"(*ptr)
560 : [i]"r"(incr), [b]"r"(ptr)
566 #define otx2_write128(lo, hi, addr) writeq((hi) | (lo), addr)
567 #define otx2_atomic64_add(incr, ptr) ({ *ptr += incr; })
570 static inline void __cn10k_aura_freeptr(struct otx2_nic *pfvf, u64 aura,
571 u64 *ptrs, u64 num_ptrs)
573 struct otx2_lmt_info *lmt_info;
574 u64 size = 0, count_eot = 0;
575 u64 tar_addr, val = 0;
577 lmt_info = per_cpu_ptr(pfvf->hw.lmt_info, smp_processor_id());
578 tar_addr = (__force u64)otx2_get_regaddr(pfvf, NPA_LF_AURA_BATCH_FREE0);
579 /* LMTID is same as AURA Id */
580 val = (lmt_info->lmt_id & 0x7FF) | BIT_ULL(63);
581 /* Set if [127:64] of last 128bit word has a valid pointer */
582 count_eot = (num_ptrs % 2) ? 0ULL : 1ULL;
583 /* Set AURA ID to free pointer */
584 ptrs[0] = (count_eot << 32) | (aura & 0xFFFFF);
585 /* Target address for LMTST flush tells HW how many 128bit
586 * words are valid from NPA_LF_AURA_BATCH_FREE0.
588 * tar_addr[6:4] is LMTST size-1 in units of 128b.
591 size = (sizeof(u64) * num_ptrs) / 16;
594 tar_addr |= ((size - 1) & 0x7) << 4;
597 memcpy((u64 *)lmt_info->lmt_addr, ptrs, sizeof(u64) * num_ptrs);
598 /* Perform LMTST flush */
599 cn10k_lmt_flush(val, tar_addr);
602 static inline void cn10k_aura_freeptr(void *dev, int aura, u64 buf)
604 struct otx2_nic *pfvf = dev;
608 /* Free only one buffer at time during init and teardown */
609 __cn10k_aura_freeptr(pfvf, aura, ptrs, 2);
612 /* Alloc pointer from pool/aura */
613 static inline u64 otx2_aura_allocptr(struct otx2_nic *pfvf, int aura)
615 u64 *ptr = (u64 *)otx2_get_regaddr(pfvf,
616 NPA_LF_AURA_OP_ALLOCX(0));
617 u64 incr = (u64)aura | BIT_ULL(63);
619 return otx2_atomic64_add(incr, ptr);
622 /* Free pointer to a pool/aura */
623 static inline void otx2_aura_freeptr(void *dev, int aura, u64 buf)
625 struct otx2_nic *pfvf = dev;
626 void __iomem *addr = otx2_get_regaddr(pfvf, NPA_LF_AURA_OP_FREE0);
628 otx2_write128(buf, (u64)aura | BIT_ULL(63), addr);
631 static inline int otx2_get_pool_idx(struct otx2_nic *pfvf, int type, int idx)
633 if (type == AURA_NIX_SQ)
634 return pfvf->hw.rqpool_cnt + idx;
641 static inline int otx2_sync_mbox_msg(struct mbox *mbox)
645 if (!otx2_mbox_nonempty(&mbox->mbox, 0))
647 otx2_mbox_msg_send(&mbox->mbox, 0);
648 err = otx2_mbox_wait_for_rsp(&mbox->mbox, 0);
652 return otx2_mbox_check_rsp_msgs(&mbox->mbox, 0);
655 static inline int otx2_sync_mbox_up_msg(struct mbox *mbox, int devid)
659 if (!otx2_mbox_nonempty(&mbox->mbox_up, devid))
661 otx2_mbox_msg_send(&mbox->mbox_up, devid);
662 err = otx2_mbox_wait_for_rsp(&mbox->mbox_up, devid);
666 return otx2_mbox_check_rsp_msgs(&mbox->mbox_up, devid);
669 /* Use this API to send mbox msgs in atomic context
670 * where sleeping is not allowed
672 static inline int otx2_sync_mbox_msg_busy_poll(struct mbox *mbox)
676 if (!otx2_mbox_nonempty(&mbox->mbox, 0))
678 otx2_mbox_msg_send(&mbox->mbox, 0);
679 err = otx2_mbox_busy_poll_for_rsp(&mbox->mbox, 0);
683 return otx2_mbox_check_rsp_msgs(&mbox->mbox, 0);
686 #define M(_name, _id, _fn_name, _req_type, _rsp_type) \
687 static struct _req_type __maybe_unused \
688 *otx2_mbox_alloc_msg_ ## _fn_name(struct mbox *mbox) \
690 struct _req_type *req; \
692 req = (struct _req_type *)otx2_mbox_alloc_msg_rsp( \
693 &mbox->mbox, 0, sizeof(struct _req_type), \
694 sizeof(struct _rsp_type)); \
697 req->hdr.sig = OTX2_MBOX_REQ_SIG; \
699 trace_otx2_msg_alloc(mbox->mbox.pdev, _id, sizeof(*req)); \
706 #define M(_name, _id, _fn_name, _req_type, _rsp_type) \
708 otx2_mbox_up_handler_ ## _fn_name(struct otx2_nic *pfvf, \
709 struct _req_type *req, \
710 struct _rsp_type *rsp); \
715 /* Time to wait before watchdog kicks off */
716 #define OTX2_TX_TIMEOUT (100 * HZ)
718 #define RVU_PFVF_PF_SHIFT 10
719 #define RVU_PFVF_PF_MASK 0x3F
720 #define RVU_PFVF_FUNC_SHIFT 0
721 #define RVU_PFVF_FUNC_MASK 0x3FF
723 static inline bool is_otx2_vf(u16 pcifunc)
725 return !!(pcifunc & RVU_PFVF_FUNC_MASK);
728 static inline int rvu_get_pf(u16 pcifunc)
730 return (pcifunc >> RVU_PFVF_PF_SHIFT) & RVU_PFVF_PF_MASK;
733 static inline dma_addr_t otx2_dma_map_page(struct otx2_nic *pfvf,
735 size_t offset, size_t size,
736 enum dma_data_direction dir)
740 iova = dma_map_page_attrs(pfvf->dev, page,
741 offset, size, dir, DMA_ATTR_SKIP_CPU_SYNC);
742 if (unlikely(dma_mapping_error(pfvf->dev, iova)))
743 return (dma_addr_t)NULL;
747 static inline void otx2_dma_unmap_page(struct otx2_nic *pfvf,
748 dma_addr_t addr, size_t size,
749 enum dma_data_direction dir)
751 dma_unmap_page_attrs(pfvf->dev, addr, size,
752 dir, DMA_ATTR_SKIP_CPU_SYNC);
756 void otx2_free_cints(struct otx2_nic *pfvf, int n);
757 void otx2_set_cints_affinity(struct otx2_nic *pfvf);
758 int otx2_set_mac_address(struct net_device *netdev, void *p);
759 int otx2_hw_set_mtu(struct otx2_nic *pfvf, int mtu);
760 void otx2_tx_timeout(struct net_device *netdev, unsigned int txq);
761 void otx2_get_mac_from_af(struct net_device *netdev);
762 void otx2_config_irq_coalescing(struct otx2_nic *pfvf, int qidx);
763 int otx2_config_pause_frm(struct otx2_nic *pfvf);
764 void otx2_setup_segmentation(struct otx2_nic *pfvf);
766 /* RVU block related APIs */
767 int otx2_attach_npa_nix(struct otx2_nic *pfvf);
768 int otx2_detach_resources(struct mbox *mbox);
769 int otx2_config_npa(struct otx2_nic *pfvf);
770 int otx2_sq_aura_pool_init(struct otx2_nic *pfvf);
771 int otx2_rq_aura_pool_init(struct otx2_nic *pfvf);
772 void otx2_aura_pool_free(struct otx2_nic *pfvf);
773 void otx2_free_aura_ptr(struct otx2_nic *pfvf, int type);
774 void otx2_sq_free_sqbs(struct otx2_nic *pfvf);
775 int otx2_config_nix(struct otx2_nic *pfvf);
776 int otx2_config_nix_queues(struct otx2_nic *pfvf);
777 int otx2_txschq_config(struct otx2_nic *pfvf, int lvl);
778 int otx2_txsch_alloc(struct otx2_nic *pfvf);
779 int otx2_txschq_stop(struct otx2_nic *pfvf);
780 void otx2_sqb_flush(struct otx2_nic *pfvf);
781 int __otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool,
783 int otx2_rxtx_enable(struct otx2_nic *pfvf, bool enable);
784 void otx2_ctx_disable(struct mbox *mbox, int type, bool npa);
785 int otx2_nix_config_bp(struct otx2_nic *pfvf, bool enable);
786 void otx2_cleanup_rx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq);
787 void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq);
788 int otx2_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura);
789 int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura);
790 int otx2_alloc_buffer(struct otx2_nic *pfvf, struct otx2_cq_queue *cq,
793 /* RSS configuration APIs*/
794 int otx2_rss_init(struct otx2_nic *pfvf);
795 int otx2_set_flowkey_cfg(struct otx2_nic *pfvf);
796 void otx2_set_rss_key(struct otx2_nic *pfvf);
797 int otx2_set_rss_table(struct otx2_nic *pfvf, int ctx_id);
800 void mbox_handler_msix_offset(struct otx2_nic *pfvf,
801 struct msix_offset_rsp *rsp);
802 void mbox_handler_npa_lf_alloc(struct otx2_nic *pfvf,
803 struct npa_lf_alloc_rsp *rsp);
804 void mbox_handler_nix_lf_alloc(struct otx2_nic *pfvf,
805 struct nix_lf_alloc_rsp *rsp);
806 void mbox_handler_nix_txsch_alloc(struct otx2_nic *pf,
807 struct nix_txsch_alloc_rsp *rsp);
808 void mbox_handler_cgx_stats(struct otx2_nic *pfvf,
809 struct cgx_stats_rsp *rsp);
810 void mbox_handler_cgx_fec_stats(struct otx2_nic *pfvf,
811 struct cgx_fec_stats_rsp *rsp);
812 void otx2_set_fec_stats_count(struct otx2_nic *pfvf);
813 void mbox_handler_nix_bp_enable(struct otx2_nic *pfvf,
814 struct nix_bp_cfg_rsp *rsp);
816 /* Device stats APIs */
817 void otx2_get_dev_stats(struct otx2_nic *pfvf);
818 void otx2_get_stats64(struct net_device *netdev,
819 struct rtnl_link_stats64 *stats);
820 void otx2_update_lmac_stats(struct otx2_nic *pfvf);
821 void otx2_update_lmac_fec_stats(struct otx2_nic *pfvf);
822 int otx2_update_rq_stats(struct otx2_nic *pfvf, int qidx);
823 int otx2_update_sq_stats(struct otx2_nic *pfvf, int qidx);
824 void otx2_set_ethtool_ops(struct net_device *netdev);
825 void otx2vf_set_ethtool_ops(struct net_device *netdev);
827 int otx2_open(struct net_device *netdev);
828 int otx2_stop(struct net_device *netdev);
829 int otx2_set_real_num_queues(struct net_device *netdev,
830 int tx_queues, int rx_queues);
831 /* MCAM filter related APIs */
832 int otx2_mcam_flow_init(struct otx2_nic *pf);
833 int otx2vf_mcam_flow_init(struct otx2_nic *pfvf);
834 int otx2_alloc_mcam_entries(struct otx2_nic *pfvf, u16 count);
835 void otx2_mcam_flow_del(struct otx2_nic *pf);
836 int otx2_destroy_ntuple_flows(struct otx2_nic *pf);
837 int otx2_destroy_mcam_flows(struct otx2_nic *pfvf);
838 int otx2_get_flow(struct otx2_nic *pfvf,
839 struct ethtool_rxnfc *nfc, u32 location);
840 int otx2_get_all_flows(struct otx2_nic *pfvf,
841 struct ethtool_rxnfc *nfc, u32 *rule_locs);
842 int otx2_add_flow(struct otx2_nic *pfvf,
843 struct ethtool_rxnfc *nfc);
844 int otx2_remove_flow(struct otx2_nic *pfvf, u32 location);
845 int otx2_get_maxflows(struct otx2_flow_config *flow_cfg);
846 void otx2_rss_ctx_flow_del(struct otx2_nic *pfvf, int ctx_id);
847 int otx2_del_macfilter(struct net_device *netdev, const u8 *mac);
848 int otx2_add_macfilter(struct net_device *netdev, const u8 *mac);
849 int otx2_enable_rxvlan(struct otx2_nic *pf, bool enable);
850 int otx2_install_rxvlan_offload_flow(struct otx2_nic *pfvf);
851 u16 otx2_get_max_mtu(struct otx2_nic *pfvf);
853 int otx2_init_tc(struct otx2_nic *nic);
854 void otx2_shutdown_tc(struct otx2_nic *nic);
855 int otx2_setup_tc(struct net_device *netdev, enum tc_setup_type type,
857 int otx2_tc_alloc_ent_bitmap(struct otx2_nic *nic);
858 /* CGX/RPM DMAC filters support */
859 int otx2_dmacflt_get_max_cnt(struct otx2_nic *pf);
860 int otx2_dmacflt_add(struct otx2_nic *pf, const u8 *mac, u8 bit_pos);
861 int otx2_dmacflt_remove(struct otx2_nic *pf, const u8 *mac, u8 bit_pos);
862 int otx2_dmacflt_update(struct otx2_nic *pf, u8 *mac, u8 bit_pos);
863 void otx2_dmacflt_reinstall_flows(struct otx2_nic *pf);
864 void otx2_dmacflt_update_pfmac_flow(struct otx2_nic *pfvf);
865 #endif /* OTX2_COMMON_H */