1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef __OCTEON_IQ_H__
25#define __OCTEON_IQ_H__
26
27#define IQ_STATUS_RUNNING 1
28
29#define IQ_SEND_OK 0
30#define IQ_SEND_STOP 1
31#define IQ_SEND_FAILED -1
32
33
34
35
36
37#define REQTYPE_NONE 0
38#define REQTYPE_NORESP_NET 1
39#define REQTYPE_NORESP_NET_SG 2
40#define REQTYPE_RESP_NET 3
41#define REQTYPE_RESP_NET_SG 4
42#define REQTYPE_SOFT_COMMAND 5
43#define REQTYPE_LAST 5
44
45struct octeon_request_list {
46 u32 reqtype;
47 void *buf;
48};
49
50
51
52
53struct oct_iq_stats {
54 u64 instr_posted;
55 u64 instr_processed;
56 u64 instr_dropped;
57 u64 bytes_sent;
58 u64 sgentry_sent;
59 u64 tx_done;
60 u64 tx_iq_busy;
61 u64 tx_dropped;
62 u64 tx_tot_bytes;
63 u64 tx_gso;
64 u64 tx_vxlan;
65 u64 tx_dmamap_fail;
66 u64 tx_restart;
67};
68
69#define OCT_IQ_STATS_SIZE (sizeof(struct oct_iq_stats))
70
71
72
73
74
75
76struct octeon_instr_queue {
77 struct octeon_device *oct_dev;
78
79
80 spinlock_t lock;
81
82
83 spinlock_t post_lock;
84
85 u32 pkt_in_done;
86
87
88 spinlock_t iq_flush_running_lock;
89
90
91 u32 iqcmd_64B:1;
92
93
94 union oct_txpciq txpciq;
95
96 u32 rsvd:17;
97
98
99 u32 do_auto_flush:1;
100
101 u32 status:8;
102
103
104 u32 max_count;
105
106
107 u32 host_write_index;
108
109
110
111
112 u32 octeon_read_index;
113
114
115
116
117 u32 flush_index;
118
119
120 atomic_t instr_pending;
121
122 u32 reset_instr_cnt;
123
124
125 u8 *base_addr;
126
127 struct octeon_request_list *request_list;
128
129
130 void __iomem *doorbell_reg;
131
132
133 void __iomem *inst_cnt_reg;
134
135
136 u32 fill_cnt;
137
138
139
140
141 u32 fill_threshold;
142
143
144 u64 last_db_time;
145
146
147
148
149 u32 db_timeout;
150
151
152 struct oct_iq_stats stats;
153
154
155 dma_addr_t base_addr_dma;
156
157
158 void *app_ctx;
159
160
161 int q_index;
162
163
164 int ifidx;
165
166};
167
168
169
170
171
172
173struct octeon_instr_32B {
174
175 u64 dptr;
176
177
178 u64 ih;
179
180
181
182
183 u64 rptr;
184
185
186 u64 irh;
187
188};
189
190#define OCT_32B_INSTR_SIZE (sizeof(struct octeon_instr_32B))
191
192
193
194
195struct octeon_instr2_64B {
196
197 u64 dptr;
198
199
200 u64 ih2;
201
202
203 u64 irh;
204
205
206 u64 ossp[2];
207
208
209 u64 rdp;
210
211
212
213
214 u64 rptr;
215
216 u64 reserved;
217};
218
219struct octeon_instr3_64B {
220
221 u64 dptr;
222
223
224 u64 ih3;
225
226
227 u64 pki_ih3;
228
229
230 u64 irh;
231
232
233 u64 ossp[2];
234
235
236 u64 rdp;
237
238
239
240
241 u64 rptr;
242
243};
244
245union octeon_instr_64B {
246 struct octeon_instr2_64B cmd2;
247 struct octeon_instr3_64B cmd3;
248};
249
250#define OCT_64B_INSTR_SIZE (sizeof(union octeon_instr_64B))
251
252
253
254#define SOFT_COMMAND_BUFFER_SIZE 2048
255
256struct octeon_soft_command {
257
258 struct list_head node;
259 u64 dma_addr;
260 u32 size;
261
262
263 union octeon_instr_64B cmd;
264
265#define COMPLETION_WORD_INIT 0xffffffffffffffffULL
266 u64 *status_word;
267
268
269 void *virtdptr;
270 u64 dmadptr;
271 u32 datasize;
272
273
274 void *virtrptr;
275 u64 dmarptr;
276 u32 rdatasize;
277
278
279 void *ctxptr;
280 u32 ctxsize;
281
282
283 size_t wait_time;
284 size_t timeout;
285 u32 iq_no;
286 void (*callback)(struct octeon_device *, u32, void *);
287 void *callback_arg;
288};
289
290
291
292#define MAX_SOFT_COMMAND_BUFFERS 256
293
294
295
296struct octeon_sc_buffer_pool {
297
298 struct list_head head;
299
300
301 spinlock_t lock;
302
303 atomic_t alloc_buf_count;
304};
305
306#define INCR_INSTRQUEUE_PKT_COUNT(octeon_dev_ptr, iq_no, field, count) \
307 (((octeon_dev_ptr)->instr_queue[iq_no]->stats.field) += count)
308
309int octeon_setup_sc_buffer_pool(struct octeon_device *oct);
310int octeon_free_sc_buffer_pool(struct octeon_device *oct);
311struct octeon_soft_command *
312 octeon_alloc_soft_command(struct octeon_device *oct,
313 u32 datasize, u32 rdatasize,
314 u32 ctxsize);
315void octeon_free_soft_command(struct octeon_device *oct,
316 struct octeon_soft_command *sc);
317
318
319
320
321
322
323
324
325
326
327
328int octeon_init_instr_queue(struct octeon_device *octeon_dev,
329 union oct_txpciq txpciq,
330 u32 num_descs);
331
332
333
334
335
336
337
338
339
340
341
342int octeon_delete_instr_queue(struct octeon_device *octeon_dev, u32 iq_no);
343
344int lio_wait_for_instr_fetch(struct octeon_device *oct);
345
346int
347octeon_register_reqtype_free_fn(struct octeon_device *oct, int reqtype,
348 void (*fn)(void *));
349
350int
351lio_process_iq_request_list(struct octeon_device *oct,
352 struct octeon_instr_queue *iq, u32 napi_budget);
353
354int octeon_send_command(struct octeon_device *oct, u32 iq_no,
355 u32 force_db, void *cmd, void *buf,
356 u32 datasize, u32 reqtype);
357
358void octeon_prepare_soft_command(struct octeon_device *oct,
359 struct octeon_soft_command *sc,
360 u8 opcode, u8 subcode,
361 u32 irh_ossp, u64 ossp0,
362 u64 ossp1);
363
364int octeon_send_soft_command(struct octeon_device *oct,
365 struct octeon_soft_command *sc);
366
367int octeon_setup_iq(struct octeon_device *oct, int ifidx,
368 int q_index, union oct_txpciq iq_no, u32 num_descs,
369 void *app_ctx);
370int
371octeon_flush_iq(struct octeon_device *oct, struct octeon_instr_queue *iq,
372 u32 napi_budget);
373#endif
374