1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2019 Marvell International Ltd.
8 #include "otx2_common.h"
9 #include "otx2_mempool.h"
11 #define DPI_QUEUE_OPEN 0x1
12 #define DPI_QUEUE_CLOSE 0x2
14 /* DPI VF register offsets from VF_BAR0 */
15 #define DPI_VDMA_EN (0x0)
16 #define DPI_VDMA_REQQ_CTL (0x8)
17 #define DPI_VDMA_DBELL (0x10)
18 #define DPI_VDMA_SADDR (0x18)
19 #define DPI_VDMA_COUNTS (0x20)
20 #define DPI_VDMA_NADDR (0x28)
21 #define DPI_VDMA_IWBUSY (0x30)
22 #define DPI_VDMA_CNT (0x38)
23 #define DPI_VF_INT (0x100)
24 #define DPI_VF_INT_W1S (0x108)
25 #define DPI_VF_INT_ENA_W1C (0x110)
26 #define DPI_VF_INT_ENA_W1S (0x118)
29 #define DPI_DMA_CMD_SIZE 64
30 #define DPI_CHUNK_SIZE 1024
31 #define DPI_QUEUE_STOP 0x0
32 #define DPI_QUEUE_START 0x1
34 #define DPI_VDMA_SADDR_REQ_IDLE 63
35 #define DPI_MAX_POINTER 15
36 #define STRM_INC(s) ((s)->tail = ((s)->tail + 1) % (s)->max_cnt)
37 #define DPI_QFINISH_TIMEOUT (10 * 1000)
39 /* DPI Transfer Type, pointer type in DPI_DMA_INSTR_HDR_S[XTYPE] */
40 #define DPI_XTYPE_OUTBOUND (0)
41 #define DPI_XTYPE_INBOUND (1)
42 #define DPI_XTYPE_INTERNAL_ONLY (2)
43 #define DPI_XTYPE_EXTERNAL_ONLY (3)
44 #define DPI_XTYPE_MASK 0x3
45 #define DPI_HDR_PT_ZBW_CA 0x0
46 #define DPI_HDR_PT_ZBW_NC 0x1
47 #define DPI_HDR_PT_WQP 0x2
48 #define DPI_HDR_PT_WQP_NOSTATUS 0x0
49 #define DPI_HDR_PT_WQP_STATUSCA 0x1
50 #define DPI_HDR_PT_WQP_STATUSNC 0x3
51 #define DPI_HDR_PT_CNT 0x3
52 #define DPI_HDR_PT_MASK 0x3
53 #define DPI_W0_TT_MASK 0x3
54 #define DPI_W0_GRP_MASK 0x3FF
55 /* Set Completion data to 0xFF when request submitted,
56 * upon successful request completion engine reset to completion status
58 #define DPI_REQ_CDATA 0xFF
61 struct rte_pci_device *dev;
68 uint16_t pool_size_m1;
72 struct otx2_mbox *mbox;
75 struct dpi_rawdev_conf_s {
79 enum dpi_dma_queue_result_e {
80 DPI_DMA_QUEUE_SUCCESS = 0,
81 DPI_DMA_QUEUE_NO_MEMORY = -1,
82 DPI_DMA_QUEUE_INVALID_PARAM = -2,
85 struct dpi_dma_req_compl_s {
87 void (*compl_cb)(void *dev, void *arg);
96 uint64_t bed:1; /* Big-Endian */
98 uint64_t full_write:1;
104 struct dpi_dma_buf_ptr_s {
105 union dpi_dma_ptr_u *rptr[DPI_MAX_POINTER]; /* Read From pointer list */
106 union dpi_dma_ptr_u *wptr[DPI_MAX_POINTER]; /* Write to pointer list */
109 struct dpi_dma_req_compl_s *comp_ptr;
112 struct dpi_cring_data_s {
113 struct dpi_dma_req_compl_s **compl_data;
119 struct dpi_dma_queue_ctx_s {
122 /* Completion pointer type */
125 /* Completion updated using WQE */
130 /* Valid only for Outbound only mode */
144 struct dpi_cring_data_s *c_ring;
147 /* DPI DMA Instruction Header Format */
148 union dpi_dma_instr_hdr_u {
151 struct dpi_dma_instr_hdr_s_s {
155 uint64_t reserved_44_47:4;
157 uint64_t reserved_52_53:2;
159 uint64_t reserved_58_63:6;
163 uint64_t reserved_76_79:4;
164 uint64_t deallocv:16;
167 uint64_t reserved_98_99:2;
169 uint64_t reserved_102_103:2;
175 uint64_t reserved_109_111:3;
177 uint64_t reserved_114_119:6;
179 uint64_t reserved_122_123:2;
181 uint64_t reserved_126_127:2;
187 uint64_t reserved_192_255:64;
192 int otx2_dpi_queue_open(uint16_t vf_id, uint32_t size, uint32_t gaura);
193 int otx2_dpi_queue_close(uint16_t vf_id);
194 int test_otx2_dma_rawdev(uint16_t val);
196 #endif /* _DPI_RAWDEV_H_ */