1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | /* |
3 | * Copyright (C) 2016 Cavium, Inc. |
4 | */ |
5 | |
6 | #ifndef __REQUEST_MANAGER_H |
7 | #define __REQUEST_MANAGER_H |
8 | |
9 | #include "cpt_common.h" |
10 | |
11 | #define TIME_IN_RESET_COUNT 5 |
12 | #define COMPLETION_CODE_SIZE 8 |
13 | #define COMPLETION_CODE_INIT 0 |
14 | #define PENDING_THOLD 100 |
15 | #define MAX_SG_IN_CNT 12 |
16 | #define MAX_SG_OUT_CNT 13 |
17 | #define SG_LIST_HDR_SIZE 8 |
18 | #define MAX_BUF_CNT 16 |
19 | |
20 | union ctrl_info { |
21 | u32 flags; |
22 | struct { |
23 | #if defined(__BIG_ENDIAN_BITFIELD) |
24 | u32 reserved0:26; |
25 | u32 grp:3; /* Group bits */ |
26 | u32 dma_mode:2; /* DMA mode */ |
27 | u32 se_req:1;/* To SE core */ |
28 | #else |
29 | u32 se_req:1; /* To SE core */ |
30 | u32 dma_mode:2; /* DMA mode */ |
31 | u32 grp:3; /* Group bits */ |
32 | u32 reserved0:26; |
33 | #endif |
34 | } s; |
35 | }; |
36 | |
37 | union opcode_info { |
38 | u16 flags; |
39 | struct { |
40 | u8 major; |
41 | u8 minor; |
42 | } s; |
43 | }; |
44 | |
45 | struct cptvf_request { |
46 | union opcode_info opcode; |
47 | u16 param1; |
48 | u16 param2; |
49 | u16 dlen; |
50 | }; |
51 | |
52 | struct buf_ptr { |
53 | u8 *vptr; |
54 | dma_addr_t dma_addr; |
55 | u16 size; |
56 | }; |
57 | |
58 | struct cpt_request_info { |
59 | u8 incnt; /* Number of input buffers */ |
60 | u8 outcnt; /* Number of output buffers */ |
61 | u16 rlen; /* Output length */ |
62 | union ctrl_info ctrl; /* User control information */ |
63 | struct cptvf_request req; /* Request Information (Core specific) */ |
64 | |
65 | bool may_sleep; |
66 | |
67 | struct buf_ptr in[MAX_BUF_CNT]; |
68 | struct buf_ptr out[MAX_BUF_CNT]; |
69 | |
70 | void (*callback)(int, void *); /* Kernel ASYNC request callabck */ |
71 | void *callback_arg; /* Kernel ASYNC request callabck arg */ |
72 | }; |
73 | |
74 | struct sglist_component { |
75 | union { |
76 | u64 len; |
77 | struct { |
78 | __be16 len0; |
79 | __be16 len1; |
80 | __be16 len2; |
81 | __be16 len3; |
82 | } s; |
83 | } u; |
84 | __be64 ptr0; |
85 | __be64 ptr1; |
86 | __be64 ptr2; |
87 | __be64 ptr3; |
88 | }; |
89 | |
90 | struct cpt_info_buffer { |
91 | struct cpt_vf *cptvf; |
92 | unsigned long time_in; |
93 | u8 ; |
94 | |
95 | struct cpt_request_info *req; |
96 | dma_addr_t dptr_baddr; |
97 | u32 dlen; |
98 | dma_addr_t rptr_baddr; |
99 | dma_addr_t comp_baddr; |
100 | u8 *in_buffer; |
101 | u8 *out_buffer; |
102 | u8 *gather_components; |
103 | u8 *scatter_components; |
104 | |
105 | struct pending_entry *pentry; |
106 | volatile u64 *completion_addr; |
107 | volatile u64 *alternate_caddr; |
108 | }; |
109 | |
110 | /* |
111 | * CPT_INST_S software command definitions |
112 | * Words EI (0-3) |
113 | */ |
114 | union vq_cmd_word0 { |
115 | u64 u64; |
116 | struct { |
117 | __be16 opcode; |
118 | __be16 param1; |
119 | __be16 param2; |
120 | __be16 dlen; |
121 | } s; |
122 | }; |
123 | |
124 | union vq_cmd_word3 { |
125 | u64 u64; |
126 | struct { |
127 | #if defined(__BIG_ENDIAN_BITFIELD) |
128 | u64 grp:3; |
129 | u64 cptr:61; |
130 | #else |
131 | u64 cptr:61; |
132 | u64 grp:3; |
133 | #endif |
134 | } s; |
135 | }; |
136 | |
137 | struct cpt_vq_command { |
138 | union vq_cmd_word0 cmd; |
139 | u64 dptr; |
140 | u64 rptr; |
141 | union vq_cmd_word3 cptr; |
142 | }; |
143 | |
144 | void vq_post_process(struct cpt_vf *cptvf, u32 qno); |
145 | int process_request(struct cpt_vf *cptvf, struct cpt_request_info *req); |
146 | #endif /* __REQUEST_MANAGER_H */ |
147 | |