forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/soc/fsl/dpio/qbman-portal.h
....@@ -1,13 +1,20 @@
11 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
22 /*
33 * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
4
- * Copyright 2016 NXP
4
+ * Copyright 2016-2019 NXP
55 *
66 */
77 #ifndef __FSL_QBMAN_PORTAL_H
88 #define __FSL_QBMAN_PORTAL_H
99
1010 #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
1118
1219 struct dpaa2_dq;
1320 struct qbman_swp;
....@@ -81,6 +88,10 @@
8188 u8 wae;
8289 u8 rspid;
8390 __le64 rsp_addr;
91
+};
92
+
93
+struct qbman_eq_desc_with_fd {
94
+ struct qbman_eq_desc desc;
8495 u8 fd[32];
8596 };
8697
....@@ -110,6 +121,11 @@
110121 u32 valid_bit; /* 0x00 or 0x80 */
111122 } mc;
112123
124
+ /* Management response */
125
+ struct {
126
+ u32 valid_bit; /* 0x00 or 0x80 */
127
+ } mr;
128
+
113129 /* Push dequeues */
114130 u32 sdq;
115131
....@@ -127,8 +143,48 @@
127143 u8 dqrr_size;
128144 int reset_bug; /* indicates dqrr reset workaround is needed */
129145 } 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;
130159 };
131160
161
+/* Function pointers */
162
+extern
163
+int (*qbman_swp_enqueue_ptr)(struct qbman_swp *s,
164
+ const struct qbman_eq_desc *d,
165
+ const struct dpaa2_fd *fd);
166
+extern
167
+int (*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);
172
+extern
173
+int (*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);
177
+extern
178
+int (*qbman_swp_pull_ptr)(struct qbman_swp *s, struct qbman_pull_desc *d);
179
+extern
180
+const struct dpaa2_dq *(*qbman_swp_dqrr_next_ptr)(struct qbman_swp *s);
181
+extern
182
+int (*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
+/* Functions */
132188 struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d);
133189 void qbman_swp_finish(struct qbman_swp *p);
134190 u32 qbman_swp_interrupt_read_status(struct qbman_swp *p);
....@@ -153,9 +209,6 @@
153209 void qbman_pull_desc_set_channel(struct qbman_pull_desc *d, u32 chid,
154210 enum qbman_pull_type_e dct);
155211
156
-int qbman_swp_pull(struct qbman_swp *p, struct qbman_pull_desc *d);
157
-
158
-const struct dpaa2_dq *qbman_swp_dqrr_next(struct qbman_swp *s);
159212 void qbman_swp_dqrr_consume(struct qbman_swp *s, const struct dpaa2_dq *dq);
160213
161214 int qbman_result_has_new_result(struct qbman_swp *p, const struct dpaa2_dq *dq);
....@@ -167,15 +220,11 @@
167220 void qbman_eq_desc_set_qd(struct qbman_eq_desc *d, u32 qdid,
168221 u32 qd_bin, u32 qd_prio);
169222
170
-int qbman_swp_enqueue(struct qbman_swp *p, const struct qbman_eq_desc *d,
171
- const struct dpaa2_fd *fd);
172223
173224 void qbman_release_desc_clear(struct qbman_release_desc *d);
174225 void qbman_release_desc_set_bpid(struct qbman_release_desc *d, u16 bpid);
175226 void qbman_release_desc_set_rcdi(struct qbman_release_desc *d, int enable);
176227
177
-int qbman_swp_release(struct qbman_swp *s, const struct qbman_release_desc *d,
178
- const u64 *buffers, unsigned int num_buffers);
179228 int qbman_swp_acquire(struct qbman_swp *s, u16 bpid, u64 *buffers,
180229 unsigned int num_buffers);
181230 int qbman_swp_alt_fq_state(struct qbman_swp *s, u32 fqid,
....@@ -187,6 +236,61 @@
187236 void *qbman_swp_mc_start(struct qbman_swp *p);
188237 void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, u8 cmd_verb);
189238 void *qbman_swp_mc_result(struct qbman_swp *p);
239
+
240
+/**
241
+ * qbman_swp_enqueue() - Issue an enqueue command
242
+ * @s: the software portal used for enqueue
243
+ * @d: the enqueue descriptor
244
+ * @fd: the frame descriptor to be enqueued
245
+ *
246
+ * Return 0 for successful enqueue, -EBUSY if the EQCR is not ready.
247
+ */
248
+static inline int
249
+qbman_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
+ * qbman_swp_enqueue_multiple() - Issue a multi enqueue command
257
+ * using one enqueue descriptor
258
+ * @s: the software portal used for enqueue
259
+ * @d: the enqueue descriptor
260
+ * @fd: table pointer of frame descriptor table to be enqueued
261
+ * @flags: table pointer of QBMAN_ENQUEUE_FLAG_DCA flags, not used if NULL
262
+ * @num_frames: number of fd to be enqueued
263
+ *
264
+ * Return the number of fd enqueued, or a negative error number.
265
+ */
266
+static inline int
267
+qbman_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
+ * qbman_swp_enqueue_multiple_desc() - Issue a multi enqueue command
278
+ * using multiple enqueue descriptor
279
+ * @s: the software portal used for enqueue
280
+ * @d: table of minimal enqueue descriptor
281
+ * @fd: table pointer of frame descriptor table to be enqueued
282
+ * @num_frames: number of fd to be enqueued
283
+ *
284
+ * Return the number of fd enqueued, or a negative error number.
285
+ */
286
+static inline int
287
+qbman_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
+}
190294
191295 /**
192296 * qbman_result_is_DQ() - check if the dequeue result is a dequeue response
....@@ -428,7 +532,7 @@
428532 static inline void *qbman_swp_mc_complete(struct qbman_swp *swp, void *cmd,
429533 u8 cmd_verb)
430534 {
431
- int loopvar = 1000;
535
+ int loopvar = 2000;
432536
433537 qbman_swp_mc_submit(swp, cmd, cmd_verb);
434538
....@@ -441,4 +545,107 @@
441545 return cmd;
442546 }
443547
548
+/* Query APIs */
549
+struct 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
+
569
+int qbman_fq_query_state(struct qbman_swp *s, u32 fqid,
570
+ struct qbman_fq_query_np_rslt *r);
571
+u32 qbman_fq_state_frame_count(const struct qbman_fq_query_np_rslt *r);
572
+u32 qbman_fq_state_byte_count(const struct qbman_fq_query_np_rslt *r);
573
+
574
+struct 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
+
601
+int qbman_bp_query(struct qbman_swp *s, u16 bpid,
602
+ struct qbman_bp_query_rslt *r);
603
+
604
+u32 qbman_bp_info_num_free_bufs(struct qbman_bp_query_rslt *a);
605
+
606
+/**
607
+ * qbman_swp_release() - Issue a buffer release command
608
+ * @s: the software portal object
609
+ * @d: the release descriptor
610
+ * @buffers: a pointer pointing to the buffer address to be released
611
+ * @num_buffers: number of buffers to be released, must be less than 8
612
+ *
613
+ * Return 0 for success, -EBUSY if the release command ring is not ready.
614
+ */
615
+static 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
+ * qbman_swp_pull() - Issue the pull dequeue command
625
+ * @s: the software portal object
626
+ * @d: the software portal descriptor which has been configured with
627
+ * the set of qbman_pull_desc_set_*() calls
628
+ *
629
+ * Return 0 for success, and -EBUSY if the software portal is not ready
630
+ * to do pull dequeue.
631
+ */
632
+static 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
+ * qbman_swp_dqrr_next() - Get an valid DQRR entry
640
+ * @s: the software portal object
641
+ *
642
+ * Return NULL if there are no unconsumed DQRR entries. Return a DQRR entry
643
+ * only once, so repeated calls can return a sequence of DQRR entries, without
644
+ * requiring they be consumed immediately or in any particular order.
645
+ */
646
+static inline const struct dpaa2_dq *qbman_swp_dqrr_next(struct qbman_swp *s)
647
+{
648
+ return qbman_swp_dqrr_next_ptr(s);
649
+}
650
+
444651 #endif /* __FSL_QBMAN_PORTAL_H */