1
2
3
4
5
6
7#ifndef __FSL_QBMAN_PORTAL_H
8#define __FSL_QBMAN_PORTAL_H
9
10#include <soc/fsl/dpaa2-fd.h>
11
12#define QMAN_REV_4000 0x04000000
13#define QMAN_REV_4100 0x04010000
14#define QMAN_REV_4101 0x04010001
15#define QMAN_REV_5000 0x05000000
16
17#define QMAN_REV_MASK 0xffff0000
18
19struct dpaa2_dq;
20struct qbman_swp;
21
22
23struct qbman_swp_desc {
24 void *cena_bar;
25 void __iomem *cinh_bar;
26 u32 qman_version;
27};
28
29#define QBMAN_SWP_INTERRUPT_EQRI 0x01
30#define QBMAN_SWP_INTERRUPT_EQDI 0x02
31#define QBMAN_SWP_INTERRUPT_DQRI 0x04
32#define QBMAN_SWP_INTERRUPT_RCRI 0x08
33#define QBMAN_SWP_INTERRUPT_RCDI 0x10
34#define QBMAN_SWP_INTERRUPT_VDCI 0x20
35
36
37struct qbman_pull_desc {
38 u8 verb;
39 u8 numf;
40 u8 tok;
41 u8 reserved;
42 __le32 dq_src;
43 __le64 rsp_addr;
44 u64 rsp_addr_virt;
45 u8 padding[40];
46};
47
48enum qbman_pull_type_e {
49
50 qbman_pull_type_prio = 1,
51
52 qbman_pull_type_active,
53
54 qbman_pull_type_active_noics
55};
56
57
58#define QBMAN_RESULT_MASK 0x7f
59#define QBMAN_RESULT_DQ 0x60
60#define QBMAN_RESULT_FQRN 0x21
61#define QBMAN_RESULT_FQRNI 0x22
62#define QBMAN_RESULT_FQPN 0x24
63#define QBMAN_RESULT_FQDAN 0x25
64#define QBMAN_RESULT_CDAN 0x26
65#define QBMAN_RESULT_CSCN_MEM 0x27
66#define QBMAN_RESULT_CGCU 0x28
67#define QBMAN_RESULT_BPSCN 0x29
68#define QBMAN_RESULT_CSCN_WQ 0x2a
69
70
71#define QBMAN_FQ_SCHEDULE 0x48
72#define QBMAN_FQ_FORCE 0x49
73#define QBMAN_FQ_XON 0x4d
74#define QBMAN_FQ_XOFF 0x4e
75
76
77struct qbman_eq_desc {
78 u8 verb;
79 u8 dca;
80 __le16 seqnum;
81 __le16 orpid;
82 __le16 reserved1;
83 __le32 tgtid;
84 __le32 tag;
85 __le16 qdbin;
86 u8 qpri;
87 u8 reserved[3];
88 u8 wae;
89 u8 rspid;
90 __le64 rsp_addr;
91};
92
93struct qbman_eq_desc_with_fd {
94 struct qbman_eq_desc desc;
95 u8 fd[32];
96};
97
98
99struct qbman_release_desc {
100 u8 verb;
101 u8 reserved;
102 __le16 bpid;
103 __le32 reserved2;
104 __le64 buf[7];
105};
106
107
108#define QBMAN_MC_RSLT_OK 0xf0
109
110#define CODE_CDAN_WE_EN 0x1
111#define CODE_CDAN_WE_CTX 0x4
112
113
114struct qbman_swp {
115 const struct qbman_swp_desc *desc;
116 void *addr_cena;
117 void __iomem *addr_cinh;
118
119
120 struct {
121 u32 valid_bit;
122 } mc;
123
124
125 struct {
126 u32 valid_bit;
127 } mr;
128
129
130 u32 sdq;
131
132
133 struct {
134 atomic_t available;
135 u32 valid_bit;
136 struct dpaa2_dq *storage;
137 } vdq;
138
139
140 struct {
141 u32 next_idx;
142 u32 valid_bit;
143 u8 dqrr_size;
144 int reset_bug;
145 } dqrr;
146
147 struct {
148 u32 pi;
149 u32 pi_vb;
150 u32 pi_ring_size;
151 u32 pi_ci_mask;
152 u32 ci;
153 int available;
154 u32 pend;
155 u32 no_pfdr;
156 } eqcr;
157
158 spinlock_t access_spinlock;
159};
160
161
162extern
163int (*qbman_swp_enqueue_ptr)(struct qbman_swp *s,
164 const struct qbman_eq_desc *d,
165 const struct dpaa2_fd *fd);
166extern
167int (*qbman_swp_enqueue_multiple_ptr)(struct qbman_swp *s,
168 const struct qbman_eq_desc *d,
169 const struct dpaa2_fd *fd,
170 uint32_t *flags,
171 int num_frames);
172extern
173int (*qbman_swp_enqueue_multiple_desc_ptr)(struct qbman_swp *s,
174 const struct qbman_eq_desc *d,
175 const struct dpaa2_fd *fd,
176 int num_frames);
177extern
178int (*qbman_swp_pull_ptr)(struct qbman_swp *s, struct qbman_pull_desc *d);
179extern
180const struct dpaa2_dq *(*qbman_swp_dqrr_next_ptr)(struct qbman_swp *s);
181extern
182int (*qbman_swp_release_ptr)(struct qbman_swp *s,
183 const struct qbman_release_desc *d,
184 const u64 *buffers,
185 unsigned int num_buffers);
186
187
188struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d);
189void qbman_swp_finish(struct qbman_swp *p);
190u32 qbman_swp_interrupt_read_status(struct qbman_swp *p);
191void qbman_swp_interrupt_clear_status(struct qbman_swp *p, u32 mask);
192u32 qbman_swp_interrupt_get_trigger(struct qbman_swp *p);
193void qbman_swp_interrupt_set_trigger(struct qbman_swp *p, u32 mask);
194int qbman_swp_interrupt_get_inhibit(struct qbman_swp *p);
195void qbman_swp_interrupt_set_inhibit(struct qbman_swp *p, int inhibit);
196
197void qbman_swp_push_get(struct qbman_swp *p, u8 channel_idx, int *enabled);
198void qbman_swp_push_set(struct qbman_swp *p, u8 channel_idx, int enable);
199
200void qbman_pull_desc_clear(struct qbman_pull_desc *d);
201void qbman_pull_desc_set_storage(struct qbman_pull_desc *d,
202 struct dpaa2_dq *storage,
203 dma_addr_t storage_phys,
204 int stash);
205void qbman_pull_desc_set_numframes(struct qbman_pull_desc *d, u8 numframes);
206void qbman_pull_desc_set_fq(struct qbman_pull_desc *d, u32 fqid);
207void qbman_pull_desc_set_wq(struct qbman_pull_desc *d, u32 wqid,
208 enum qbman_pull_type_e dct);
209void qbman_pull_desc_set_channel(struct qbman_pull_desc *d, u32 chid,
210 enum qbman_pull_type_e dct);
211
212void qbman_swp_dqrr_consume(struct qbman_swp *s, const struct dpaa2_dq *dq);
213
214int qbman_result_has_new_result(struct qbman_swp *p, const struct dpaa2_dq *dq);
215
216void qbman_eq_desc_clear(struct qbman_eq_desc *d);
217void qbman_eq_desc_set_no_orp(struct qbman_eq_desc *d, int respond_success);
218void qbman_eq_desc_set_token(struct qbman_eq_desc *d, u8 token);
219void qbman_eq_desc_set_fq(struct qbman_eq_desc *d, u32 fqid);
220void qbman_eq_desc_set_qd(struct qbman_eq_desc *d, u32 qdid,
221 u32 qd_bin, u32 qd_prio);
222
223
224void qbman_release_desc_clear(struct qbman_release_desc *d);
225void qbman_release_desc_set_bpid(struct qbman_release_desc *d, u16 bpid);
226void qbman_release_desc_set_rcdi(struct qbman_release_desc *d, int enable);
227
228int qbman_swp_acquire(struct qbman_swp *s, u16 bpid, u64 *buffers,
229 unsigned int num_buffers);
230int qbman_swp_alt_fq_state(struct qbman_swp *s, u32 fqid,
231 u8 alt_fq_verb);
232int qbman_swp_CDAN_set(struct qbman_swp *s, u16 channelid,
233 u8 we_mask, u8 cdan_en,
234 u64 ctx);
235
236void *qbman_swp_mc_start(struct qbman_swp *p);
237void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, u8 cmd_verb);
238void *qbman_swp_mc_result(struct qbman_swp *p);
239
240
241
242
243
244
245
246
247
248static inline int
249qbman_swp_enqueue(struct qbman_swp *s, const struct qbman_eq_desc *d,
250 const struct dpaa2_fd *fd)
251{
252 return qbman_swp_enqueue_ptr(s, d, fd);
253}
254
255
256
257
258
259
260
261
262
263
264
265
266static inline int
267qbman_swp_enqueue_multiple(struct qbman_swp *s,
268 const struct qbman_eq_desc *d,
269 const struct dpaa2_fd *fd,
270 uint32_t *flags,
271 int num_frames)
272{
273 return qbman_swp_enqueue_multiple_ptr(s, d, fd, flags, num_frames);
274}
275
276
277
278
279
280
281
282
283
284
285
286static inline int
287qbman_swp_enqueue_multiple_desc(struct qbman_swp *s,
288 const struct qbman_eq_desc *d,
289 const struct dpaa2_fd *fd,
290 int num_frames)
291{
292 return qbman_swp_enqueue_multiple_desc_ptr(s, d, fd, num_frames);
293}
294
295
296
297
298
299
300
301static inline int qbman_result_is_DQ(const struct dpaa2_dq *dq)
302{
303 return ((dq->dq.verb & QBMAN_RESULT_MASK) == QBMAN_RESULT_DQ);
304}
305
306
307
308
309
310
311static inline int qbman_result_is_SCN(const struct dpaa2_dq *dq)
312{
313 return !qbman_result_is_DQ(dq);
314}
315
316
317static inline int qbman_result_is_FQDAN(const struct dpaa2_dq *dq)
318{
319 return ((dq->dq.verb & QBMAN_RESULT_MASK) == QBMAN_RESULT_FQDAN);
320}
321
322
323static inline int qbman_result_is_CDAN(const struct dpaa2_dq *dq)
324{
325 return ((dq->dq.verb & QBMAN_RESULT_MASK) == QBMAN_RESULT_CDAN);
326}
327
328
329static inline int qbman_result_is_CSCN(const struct dpaa2_dq *dq)
330{
331 return ((dq->dq.verb & QBMAN_RESULT_MASK) == QBMAN_RESULT_CSCN_WQ);
332}
333
334
335static inline int qbman_result_is_BPSCN(const struct dpaa2_dq *dq)
336{
337 return ((dq->dq.verb & QBMAN_RESULT_MASK) == QBMAN_RESULT_BPSCN);
338}
339
340
341static inline int qbman_result_is_CGCU(const struct dpaa2_dq *dq)
342{
343 return ((dq->dq.verb & QBMAN_RESULT_MASK) == QBMAN_RESULT_CGCU);
344}
345
346
347static inline int qbman_result_is_FQRN(const struct dpaa2_dq *dq)
348{
349 return ((dq->dq.verb & QBMAN_RESULT_MASK) == QBMAN_RESULT_FQRN);
350}
351
352
353static inline int qbman_result_is_FQRNI(const struct dpaa2_dq *dq)
354{
355 return ((dq->dq.verb & QBMAN_RESULT_MASK) == QBMAN_RESULT_FQRNI);
356}
357
358
359static inline int qbman_result_is_FQPN(const struct dpaa2_dq *dq)
360{
361 return ((dq->dq.verb & QBMAN_RESULT_MASK) == QBMAN_RESULT_FQPN);
362}
363
364
365
366
367static inline u8 qbman_result_SCN_state(const struct dpaa2_dq *scn)
368{
369 return scn->scn.state;
370}
371
372#define SCN_RID_MASK 0x00FFFFFF
373
374
375
376
377static inline u32 qbman_result_SCN_rid(const struct dpaa2_dq *scn)
378{
379 return le32_to_cpu(scn->scn.rid_tok) & SCN_RID_MASK;
380}
381
382
383
384
385static inline u64 qbman_result_SCN_ctx(const struct dpaa2_dq *scn)
386{
387 return le64_to_cpu(scn->scn.ctx);
388}
389
390
391
392
393
394
395
396
397
398
399
400static inline int qbman_swp_fq_schedule(struct qbman_swp *s, u32 fqid)
401{
402 return qbman_swp_alt_fq_state(s, fqid, QBMAN_FQ_SCHEDULE);
403}
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418static inline int qbman_swp_fq_force(struct qbman_swp *s, u32 fqid)
419{
420 return qbman_swp_alt_fq_state(s, fqid, QBMAN_FQ_FORCE);
421}
422
423
424
425
426
427
428
429
430
431
432static inline int qbman_swp_fq_xon(struct qbman_swp *s, u32 fqid)
433{
434 return qbman_swp_alt_fq_state(s, fqid, QBMAN_FQ_XON);
435}
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452static inline int qbman_swp_fq_xoff(struct qbman_swp *s, u32 fqid)
453{
454 return qbman_swp_alt_fq_state(s, fqid, QBMAN_FQ_XOFF);
455}
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478static inline int qbman_swp_CDAN_set_context(struct qbman_swp *s, u16 channelid,
479 u64 ctx)
480{
481 return qbman_swp_CDAN_set(s, channelid,
482 CODE_CDAN_WE_CTX,
483 0, ctx);
484}
485
486
487
488
489
490
491
492
493static inline int qbman_swp_CDAN_enable(struct qbman_swp *s, u16 channelid)
494{
495 return qbman_swp_CDAN_set(s, channelid,
496 CODE_CDAN_WE_EN,
497 1, 0);
498}
499
500
501
502
503
504
505
506
507static inline int qbman_swp_CDAN_disable(struct qbman_swp *s, u16 channelid)
508{
509 return qbman_swp_CDAN_set(s, channelid,
510 CODE_CDAN_WE_EN,
511 0, 0);
512}
513
514
515
516
517
518
519
520
521
522static inline int qbman_swp_CDAN_set_context_enable(struct qbman_swp *s,
523 u16 channelid,
524 u64 ctx)
525{
526 return qbman_swp_CDAN_set(s, channelid,
527 CODE_CDAN_WE_EN | CODE_CDAN_WE_CTX,
528 1, ctx);
529}
530
531
532static inline void *qbman_swp_mc_complete(struct qbman_swp *swp, void *cmd,
533 u8 cmd_verb)
534{
535 int loopvar = 2000;
536
537 qbman_swp_mc_submit(swp, cmd, cmd_verb);
538
539 do {
540 cmd = qbman_swp_mc_result(swp);
541 } while (!cmd && loopvar--);
542
543 WARN_ON(!loopvar);
544
545 return cmd;
546}
547
548
549struct qbman_fq_query_np_rslt {
550 u8 verb;
551 u8 rslt;
552 u8 st1;
553 u8 st2;
554 u8 reserved[2];
555 __le16 od1_sfdr;
556 __le16 od2_sfdr;
557 __le16 od3_sfdr;
558 __le16 ra1_sfdr;
559 __le16 ra2_sfdr;
560 __le32 pfdr_hptr;
561 __le32 pfdr_tptr;
562 __le32 frm_cnt;
563 __le32 byte_cnt;
564 __le16 ics_surp;
565 u8 is;
566 u8 reserved2[29];
567};
568
569int qbman_fq_query_state(struct qbman_swp *s, u32 fqid,
570 struct qbman_fq_query_np_rslt *r);
571u32 qbman_fq_state_frame_count(const struct qbman_fq_query_np_rslt *r);
572u32 qbman_fq_state_byte_count(const struct qbman_fq_query_np_rslt *r);
573
574struct qbman_bp_query_rslt {
575 u8 verb;
576 u8 rslt;
577 u8 reserved[4];
578 u8 bdi;
579 u8 state;
580 __le32 fill;
581 __le32 hdotr;
582 __le16 swdet;
583 __le16 swdxt;
584 __le16 hwdet;
585 __le16 hwdxt;
586 __le16 swset;
587 __le16 swsxt;
588 __le16 vbpid;
589 __le16 icid;
590 __le64 bpscn_addr;
591 __le64 bpscn_ctx;
592 __le16 hw_targ;
593 u8 dbe;
594 u8 reserved2;
595 u8 sdcnt;
596 u8 hdcnt;
597 u8 sscnt;
598 u8 reserved3[9];
599};
600
601int qbman_bp_query(struct qbman_swp *s, u16 bpid,
602 struct qbman_bp_query_rslt *r);
603
604u32 qbman_bp_info_num_free_bufs(struct qbman_bp_query_rslt *a);
605
606
607
608
609
610
611
612
613
614
615static inline int qbman_swp_release(struct qbman_swp *s,
616 const struct qbman_release_desc *d,
617 const u64 *buffers,
618 unsigned int num_buffers)
619{
620 return qbman_swp_release_ptr(s, d, buffers, num_buffers);
621}
622
623
624
625
626
627
628
629
630
631
632static inline int qbman_swp_pull(struct qbman_swp *s,
633 struct qbman_pull_desc *d)
634{
635 return qbman_swp_pull_ptr(s, d);
636}
637
638
639
640
641
642
643
644
645
646static inline const struct dpaa2_dq *qbman_swp_dqrr_next(struct qbman_swp *s)
647{
648 return qbman_swp_dqrr_next_ptr(s);
649}
650
651#endif
652