| .. | .. |
|---|
| 1 | 1 | /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * Copyright (C) 2014-2016 Freescale Semiconductor, Inc. |
|---|
| 4 | | - * Copyright 2016 NXP |
|---|
| 4 | + * Copyright 2016-2019 NXP |
|---|
| 5 | 5 | * |
|---|
| 6 | 6 | */ |
|---|
| 7 | 7 | #ifndef __FSL_QBMAN_PORTAL_H |
|---|
| 8 | 8 | #define __FSL_QBMAN_PORTAL_H |
|---|
| 9 | 9 | |
|---|
| 10 | 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 |
|---|
| 11 | 18 | |
|---|
| 12 | 19 | struct dpaa2_dq; |
|---|
| 13 | 20 | struct qbman_swp; |
|---|
| .. | .. |
|---|
| 81 | 88 | u8 wae; |
|---|
| 82 | 89 | u8 rspid; |
|---|
| 83 | 90 | __le64 rsp_addr; |
|---|
| 91 | +}; |
|---|
| 92 | + |
|---|
| 93 | +struct qbman_eq_desc_with_fd { |
|---|
| 94 | + struct qbman_eq_desc desc; |
|---|
| 84 | 95 | u8 fd[32]; |
|---|
| 85 | 96 | }; |
|---|
| 86 | 97 | |
|---|
| .. | .. |
|---|
| 110 | 121 | u32 valid_bit; /* 0x00 or 0x80 */ |
|---|
| 111 | 122 | } mc; |
|---|
| 112 | 123 | |
|---|
| 124 | + /* Management response */ |
|---|
| 125 | + struct { |
|---|
| 126 | + u32 valid_bit; /* 0x00 or 0x80 */ |
|---|
| 127 | + } mr; |
|---|
| 128 | + |
|---|
| 113 | 129 | /* Push dequeues */ |
|---|
| 114 | 130 | u32 sdq; |
|---|
| 115 | 131 | |
|---|
| .. | .. |
|---|
| 127 | 143 | u8 dqrr_size; |
|---|
| 128 | 144 | int reset_bug; /* indicates dqrr reset workaround is needed */ |
|---|
| 129 | 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; |
|---|
| 130 | 159 | }; |
|---|
| 131 | 160 | |
|---|
| 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 */ |
|---|
| 132 | 188 | struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d); |
|---|
| 133 | 189 | void qbman_swp_finish(struct qbman_swp *p); |
|---|
| 134 | 190 | u32 qbman_swp_interrupt_read_status(struct qbman_swp *p); |
|---|
| .. | .. |
|---|
| 153 | 209 | void qbman_pull_desc_set_channel(struct qbman_pull_desc *d, u32 chid, |
|---|
| 154 | 210 | enum qbman_pull_type_e dct); |
|---|
| 155 | 211 | |
|---|
| 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); |
|---|
| 159 | 212 | void qbman_swp_dqrr_consume(struct qbman_swp *s, const struct dpaa2_dq *dq); |
|---|
| 160 | 213 | |
|---|
| 161 | 214 | int qbman_result_has_new_result(struct qbman_swp *p, const struct dpaa2_dq *dq); |
|---|
| .. | .. |
|---|
| 167 | 220 | void qbman_eq_desc_set_qd(struct qbman_eq_desc *d, u32 qdid, |
|---|
| 168 | 221 | u32 qd_bin, u32 qd_prio); |
|---|
| 169 | 222 | |
|---|
| 170 | | -int qbman_swp_enqueue(struct qbman_swp *p, const struct qbman_eq_desc *d, |
|---|
| 171 | | - const struct dpaa2_fd *fd); |
|---|
| 172 | 223 | |
|---|
| 173 | 224 | void qbman_release_desc_clear(struct qbman_release_desc *d); |
|---|
| 174 | 225 | void qbman_release_desc_set_bpid(struct qbman_release_desc *d, u16 bpid); |
|---|
| 175 | 226 | void qbman_release_desc_set_rcdi(struct qbman_release_desc *d, int enable); |
|---|
| 176 | 227 | |
|---|
| 177 | | -int qbman_swp_release(struct qbman_swp *s, const struct qbman_release_desc *d, |
|---|
| 178 | | - const u64 *buffers, unsigned int num_buffers); |
|---|
| 179 | 228 | int qbman_swp_acquire(struct qbman_swp *s, u16 bpid, u64 *buffers, |
|---|
| 180 | 229 | unsigned int num_buffers); |
|---|
| 181 | 230 | int qbman_swp_alt_fq_state(struct qbman_swp *s, u32 fqid, |
|---|
| .. | .. |
|---|
| 187 | 236 | void *qbman_swp_mc_start(struct qbman_swp *p); |
|---|
| 188 | 237 | void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, u8 cmd_verb); |
|---|
| 189 | 238 | 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 | +} |
|---|
| 190 | 294 | |
|---|
| 191 | 295 | /** |
|---|
| 192 | 296 | * qbman_result_is_DQ() - check if the dequeue result is a dequeue response |
|---|
| .. | .. |
|---|
| 428 | 532 | static inline void *qbman_swp_mc_complete(struct qbman_swp *swp, void *cmd, |
|---|
| 429 | 533 | u8 cmd_verb) |
|---|
| 430 | 534 | { |
|---|
| 431 | | - int loopvar = 1000; |
|---|
| 535 | + int loopvar = 2000; |
|---|
| 432 | 536 | |
|---|
| 433 | 537 | qbman_swp_mc_submit(swp, cmd, cmd_verb); |
|---|
| 434 | 538 | |
|---|
| .. | .. |
|---|
| 441 | 545 | return cmd; |
|---|
| 442 | 546 | } |
|---|
| 443 | 547 | |
|---|
| 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 | + |
|---|
| 444 | 651 | #endif /* __FSL_QBMAN_PORTAL_H */ |
|---|