1131a75b6SHemant Agrawal /* SPDX-License-Identifier: BSD-3-Clause
2531b17a7SHemant Agrawal *
3531b17a7SHemant Agrawal * Copyright (C) 2014 Freescale Semiconductor, Inc.
4b3bd7a50SNipun Gupta * Copyright 2015-2020 NXP
5531b17a7SHemant Agrawal *
6531b17a7SHemant Agrawal */
7531b17a7SHemant Agrawal #ifndef _FSL_QBMAN_PORTAL_H
8531b17a7SHemant Agrawal #define _FSL_QBMAN_PORTAL_H
9531b17a7SHemant Agrawal
10c9da6cfaSHemant Agrawal #include <rte_compat.h>
11531b17a7SHemant Agrawal #include <fsl_qbman_base.h>
12531b17a7SHemant Agrawal
1363d5d0afSNipun Gupta #define SVR_LS1080A 0x87030000
1463d5d0afSNipun Gupta #define SVR_LS2080A 0x87010000
1563d5d0afSNipun Gupta #define SVR_LS2088A 0x87090000
1663d5d0afSNipun Gupta #define SVR_LX2160A 0x87360000
1763d5d0afSNipun Gupta
1863d5d0afSNipun Gupta /* Variable to store DPAA2 platform type */
1963d5d0afSNipun Gupta extern uint32_t dpaa2_svr_family;
2063d5d0afSNipun Gupta
21531b17a7SHemant Agrawal /**
22531b17a7SHemant Agrawal * DOC - QBMan portal APIs to implement the following functions:
23531b17a7SHemant Agrawal * - Initialize and destroy Software portal object.
24531b17a7SHemant Agrawal * - Read and write Software portal interrupt registers.
25531b17a7SHemant Agrawal * - Enqueue, including setting the enqueue descriptor, and issuing enqueue
26531b17a7SHemant Agrawal * command etc.
27531b17a7SHemant Agrawal * - Dequeue, including setting the dequeue descriptor, issuing dequeue command,
28a1f42a9dSThierry Herbelot * parsing the dequeue response in DQRR and memory, parsing the state change
29531b17a7SHemant Agrawal * notifications etc.
30531b17a7SHemant Agrawal * - Release, including setting the release descriptor, and issuing the buffer
31531b17a7SHemant Agrawal * release command.
32531b17a7SHemant Agrawal * - Acquire, acquire the buffer from the given buffer pool.
33531b17a7SHemant Agrawal * - FQ management.
34531b17a7SHemant Agrawal * - Channel management, enable/disable CDAN with or without context.
35531b17a7SHemant Agrawal */
36531b17a7SHemant Agrawal
37531b17a7SHemant Agrawal /**
38531b17a7SHemant Agrawal * qbman_swp_init() - Create a functional object representing the given
39531b17a7SHemant Agrawal * QBMan portal descriptor.
40531b17a7SHemant Agrawal * @d: the given qbman swp descriptor
41531b17a7SHemant Agrawal *
42531b17a7SHemant Agrawal * Return qbman_swp portal object for success, NULL if the object cannot
43531b17a7SHemant Agrawal * be created.
44531b17a7SHemant Agrawal */
45531b17a7SHemant Agrawal struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d);
46531b17a7SHemant Agrawal
47531b17a7SHemant Agrawal /**
48b3bd7a50SNipun Gupta * qbman_swp_update() - Update portal cacheability attributes.
49b3bd7a50SNipun Gupta * @p: the given qbman swp portal
50b3bd7a50SNipun Gupta */
51b3bd7a50SNipun Gupta int qbman_swp_update(struct qbman_swp *p, int stash_off);
52b3bd7a50SNipun Gupta
53b3bd7a50SNipun Gupta /**
54531b17a7SHemant Agrawal * qbman_swp_finish() - Create and destroy a functional object representing
55531b17a7SHemant Agrawal * the given QBMan portal descriptor.
56531b17a7SHemant Agrawal * @p: the qbman_swp object to be destroyed.
57531b17a7SHemant Agrawal *
58531b17a7SHemant Agrawal */
59531b17a7SHemant Agrawal void qbman_swp_finish(struct qbman_swp *p);
60531b17a7SHemant Agrawal
61531b17a7SHemant Agrawal /**
62293c0ca9SNipun Gupta * qbman_swp_invalidate() - Invalidate the cache enabled area of the QBMan
63293c0ca9SNipun Gupta * portal. This is required to be called if a portal moved to another core
64293c0ca9SNipun Gupta * because the QBMan portal area is non coherent
65293c0ca9SNipun Gupta * @p: the qbman_swp object to be invalidated
66293c0ca9SNipun Gupta *
67293c0ca9SNipun Gupta */
68293c0ca9SNipun Gupta void qbman_swp_invalidate(struct qbman_swp *p);
69293c0ca9SNipun Gupta
70293c0ca9SNipun Gupta /**
71531b17a7SHemant Agrawal * qbman_swp_get_desc() - Get the descriptor of the given portal object.
72531b17a7SHemant Agrawal * @p: the given portal object.
73531b17a7SHemant Agrawal *
74531b17a7SHemant Agrawal * Return the descriptor for this portal.
75531b17a7SHemant Agrawal */
76531b17a7SHemant Agrawal const struct qbman_swp_desc *qbman_swp_get_desc(struct qbman_swp *p);
77531b17a7SHemant Agrawal
78531b17a7SHemant Agrawal /**************/
79531b17a7SHemant Agrawal /* Interrupts */
80531b17a7SHemant Agrawal /**************/
81531b17a7SHemant Agrawal
82531b17a7SHemant Agrawal /* EQCR ring interrupt */
83531b17a7SHemant Agrawal #define QBMAN_SWP_INTERRUPT_EQRI ((uint32_t)0x00000001)
84531b17a7SHemant Agrawal /* Enqueue command dispatched interrupt */
85531b17a7SHemant Agrawal #define QBMAN_SWP_INTERRUPT_EQDI ((uint32_t)0x00000002)
86531b17a7SHemant Agrawal /* DQRR non-empty interrupt */
87531b17a7SHemant Agrawal #define QBMAN_SWP_INTERRUPT_DQRI ((uint32_t)0x00000004)
88531b17a7SHemant Agrawal /* RCR ring interrupt */
89531b17a7SHemant Agrawal #define QBMAN_SWP_INTERRUPT_RCRI ((uint32_t)0x00000008)
90531b17a7SHemant Agrawal /* Release command dispatched interrupt */
91531b17a7SHemant Agrawal #define QBMAN_SWP_INTERRUPT_RCDI ((uint32_t)0x00000010)
92531b17a7SHemant Agrawal /* Volatile dequeue command interrupt */
93531b17a7SHemant Agrawal #define QBMAN_SWP_INTERRUPT_VDCI ((uint32_t)0x00000020)
94531b17a7SHemant Agrawal
95531b17a7SHemant Agrawal /**
96531b17a7SHemant Agrawal * qbman_swp_interrupt_get_vanish() - Get the data in software portal
97531b17a7SHemant Agrawal * interrupt status disable register.
98531b17a7SHemant Agrawal * @p: the given software portal object.
99531b17a7SHemant Agrawal *
100531b17a7SHemant Agrawal * Return the settings in SWP_ISDR register.
101531b17a7SHemant Agrawal */
102531b17a7SHemant Agrawal uint32_t qbman_swp_interrupt_get_vanish(struct qbman_swp *p);
103531b17a7SHemant Agrawal
104531b17a7SHemant Agrawal /**
105531b17a7SHemant Agrawal * qbman_swp_interrupt_set_vanish() - Set the data in software portal
106531b17a7SHemant Agrawal * interrupt status disable register.
107531b17a7SHemant Agrawal * @p: the given software portal object.
108531b17a7SHemant Agrawal * @mask: The value to set in SWP_IDSR register.
109531b17a7SHemant Agrawal */
110531b17a7SHemant Agrawal void qbman_swp_interrupt_set_vanish(struct qbman_swp *p, uint32_t mask);
111531b17a7SHemant Agrawal
112531b17a7SHemant Agrawal /**
113531b17a7SHemant Agrawal * qbman_swp_interrupt_read_status() - Get the data in software portal
114531b17a7SHemant Agrawal * interrupt status register.
115531b17a7SHemant Agrawal * @p: the given software portal object.
116531b17a7SHemant Agrawal *
117531b17a7SHemant Agrawal * Return the settings in SWP_ISR register.
118531b17a7SHemant Agrawal */
119531b17a7SHemant Agrawal uint32_t qbman_swp_interrupt_read_status(struct qbman_swp *p);
120531b17a7SHemant Agrawal
121531b17a7SHemant Agrawal /**
122531b17a7SHemant Agrawal * qbman_swp_interrupt_clear_status() - Set the data in software portal
123531b17a7SHemant Agrawal * interrupt status register.
124531b17a7SHemant Agrawal * @p: the given software portal object.
125531b17a7SHemant Agrawal * @mask: The value to set in SWP_ISR register.
126531b17a7SHemant Agrawal */
127c9da6cfaSHemant Agrawal __rte_internal
128531b17a7SHemant Agrawal void qbman_swp_interrupt_clear_status(struct qbman_swp *p, uint32_t mask);
129531b17a7SHemant Agrawal
130531b17a7SHemant Agrawal /**
1319ccb76b2SNipun Gupta * qbman_swp_dqrr_thrshld_read_status() - Get the data in software portal
1329ccb76b2SNipun Gupta * DQRR interrupt threshold register.
1339ccb76b2SNipun Gupta * @p: the given software portal object.
1349ccb76b2SNipun Gupta */
1359ccb76b2SNipun Gupta uint32_t qbman_swp_dqrr_thrshld_read_status(struct qbman_swp *p);
1369ccb76b2SNipun Gupta
1379ccb76b2SNipun Gupta /**
1389ccb76b2SNipun Gupta * qbman_swp_dqrr_thrshld_write() - Set the data in software portal
1399ccb76b2SNipun Gupta * DQRR interrupt threshold register.
1409ccb76b2SNipun Gupta * @p: the given software portal object.
1419ccb76b2SNipun Gupta * @mask: The value to set in SWP_DQRR_ITR register.
1429ccb76b2SNipun Gupta */
1439ccb76b2SNipun Gupta void qbman_swp_dqrr_thrshld_write(struct qbman_swp *p, uint32_t mask);
1449ccb76b2SNipun Gupta
1459ccb76b2SNipun Gupta /**
1469ccb76b2SNipun Gupta * qbman_swp_intr_timeout_read_status() - Get the data in software portal
1479ccb76b2SNipun Gupta * Interrupt Time-Out period register.
1489ccb76b2SNipun Gupta * @p: the given software portal object.
1499ccb76b2SNipun Gupta */
1509ccb76b2SNipun Gupta uint32_t qbman_swp_intr_timeout_read_status(struct qbman_swp *p);
1519ccb76b2SNipun Gupta
1529ccb76b2SNipun Gupta /**
1539ccb76b2SNipun Gupta * qbman_swp_intr_timeout_write() - Set the data in software portal
1549ccb76b2SNipun Gupta * Interrupt Time-Out period register.
1559ccb76b2SNipun Gupta * @p: the given software portal object.
1569ccb76b2SNipun Gupta * @mask: The value to set in SWP_ITPR register.
1579ccb76b2SNipun Gupta */
1589ccb76b2SNipun Gupta void qbman_swp_intr_timeout_write(struct qbman_swp *p, uint32_t mask);
1599ccb76b2SNipun Gupta
1609ccb76b2SNipun Gupta /**
161531b17a7SHemant Agrawal * qbman_swp_interrupt_get_trigger() - Get the data in software portal
162531b17a7SHemant Agrawal * interrupt enable register.
163531b17a7SHemant Agrawal * @p: the given software portal object.
164531b17a7SHemant Agrawal *
165531b17a7SHemant Agrawal * Return the settings in SWP_IER register.
166531b17a7SHemant Agrawal */
167531b17a7SHemant Agrawal uint32_t qbman_swp_interrupt_get_trigger(struct qbman_swp *p);
168531b17a7SHemant Agrawal
169531b17a7SHemant Agrawal /**
170531b17a7SHemant Agrawal * qbman_swp_interrupt_set_trigger() - Set the data in software portal
171531b17a7SHemant Agrawal * interrupt enable register.
172531b17a7SHemant Agrawal * @p: the given software portal object.
173531b17a7SHemant Agrawal * @mask: The value to set in SWP_IER register.
174531b17a7SHemant Agrawal */
175531b17a7SHemant Agrawal void qbman_swp_interrupt_set_trigger(struct qbman_swp *p, uint32_t mask);
176531b17a7SHemant Agrawal
177531b17a7SHemant Agrawal /**
178531b17a7SHemant Agrawal * qbman_swp_interrupt_get_inhibit() - Get the data in software portal
179531b17a7SHemant Agrawal * interrupt inhibit register.
180531b17a7SHemant Agrawal * @p: the given software portal object.
181531b17a7SHemant Agrawal *
182531b17a7SHemant Agrawal * Return the settings in SWP_IIR register.
183531b17a7SHemant Agrawal */
184531b17a7SHemant Agrawal int qbman_swp_interrupt_get_inhibit(struct qbman_swp *p);
185531b17a7SHemant Agrawal
186531b17a7SHemant Agrawal /**
187531b17a7SHemant Agrawal * qbman_swp_interrupt_set_inhibit() - Set the data in software portal
188531b17a7SHemant Agrawal * interrupt inhibit register.
189531b17a7SHemant Agrawal * @p: the given software portal object.
190531b17a7SHemant Agrawal * @mask: The value to set in SWP_IIR register.
191531b17a7SHemant Agrawal */
192531b17a7SHemant Agrawal void qbman_swp_interrupt_set_inhibit(struct qbman_swp *p, int inhibit);
193531b17a7SHemant Agrawal
194531b17a7SHemant Agrawal /************/
195531b17a7SHemant Agrawal /* Dequeues */
196531b17a7SHemant Agrawal /************/
197531b17a7SHemant Agrawal
198531b17a7SHemant Agrawal /**
199531b17a7SHemant Agrawal * struct qbman_result - structure for qbman dequeue response and/or
200531b17a7SHemant Agrawal * notification.
201293c0ca9SNipun Gupta * @dont_manipulate_directly: the 16 32bit data to represent the whole
202531b17a7SHemant Agrawal * possible qbman dequeue result.
203531b17a7SHemant Agrawal */
204531b17a7SHemant Agrawal struct qbman_result {
20569293c77SHemant Agrawal union {
20669293c77SHemant Agrawal struct common {
20769293c77SHemant Agrawal uint8_t verb;
20869293c77SHemant Agrawal uint8_t reserved[63];
20969293c77SHemant Agrawal } common;
21069293c77SHemant Agrawal struct dq {
21169293c77SHemant Agrawal uint8_t verb;
21269293c77SHemant Agrawal uint8_t stat;
21369293c77SHemant Agrawal __le16 seqnum;
21469293c77SHemant Agrawal __le16 oprid;
21569293c77SHemant Agrawal uint8_t reserved;
21669293c77SHemant Agrawal uint8_t tok;
21769293c77SHemant Agrawal __le32 fqid;
21869293c77SHemant Agrawal uint32_t reserved2;
21969293c77SHemant Agrawal __le32 fq_byte_cnt;
22069293c77SHemant Agrawal __le32 fq_frm_cnt;
22169293c77SHemant Agrawal __le64 fqd_ctx;
22269293c77SHemant Agrawal uint8_t fd[32];
22369293c77SHemant Agrawal } dq;
22469293c77SHemant Agrawal struct scn {
22569293c77SHemant Agrawal uint8_t verb;
22669293c77SHemant Agrawal uint8_t stat;
22769293c77SHemant Agrawal uint8_t state;
22869293c77SHemant Agrawal uint8_t reserved;
22969293c77SHemant Agrawal __le32 rid_tok;
23069293c77SHemant Agrawal __le64 ctx;
23169293c77SHemant Agrawal } scn;
23216c4a3c4SNipun Gupta struct eq_resp {
23316c4a3c4SNipun Gupta uint8_t verb;
23416c4a3c4SNipun Gupta uint8_t dca;
23516c4a3c4SNipun Gupta __le16 seqnum;
23616c4a3c4SNipun Gupta __le16 oprid;
23716c4a3c4SNipun Gupta uint8_t reserved;
23816c4a3c4SNipun Gupta uint8_t rc;
23916c4a3c4SNipun Gupta __le32 tgtid;
24016c4a3c4SNipun Gupta __le32 tag;
24116c4a3c4SNipun Gupta uint16_t qdbin;
24216c4a3c4SNipun Gupta uint8_t qpri;
24316c4a3c4SNipun Gupta uint8_t reserved1;
24416c4a3c4SNipun Gupta __le32 fqid:24;
24516c4a3c4SNipun Gupta __le32 rspid:8;
24616c4a3c4SNipun Gupta __le64 rsp_addr;
24716c4a3c4SNipun Gupta uint8_t fd[32];
24816c4a3c4SNipun Gupta } eq_resp;
24969293c77SHemant Agrawal };
250531b17a7SHemant Agrawal };
251531b17a7SHemant Agrawal
252531b17a7SHemant Agrawal /* TODO:
253531b17a7SHemant Agrawal *A DQRI interrupt can be generated when there are dequeue results on the
254531b17a7SHemant Agrawal * portal's DQRR (this mechanism does not deal with "pull" dequeues to
255531b17a7SHemant Agrawal * user-supplied 'storage' addresses). There are two parameters to this
256531b17a7SHemant Agrawal * interrupt source, one is a threshold and the other is a timeout. The
257531b17a7SHemant Agrawal * interrupt will fire if either the fill-level of the ring exceeds 'thresh', or
258531b17a7SHemant Agrawal * if the ring has been non-empty for been longer than 'timeout' nanoseconds.
259531b17a7SHemant Agrawal * For timeout, an approximation to the desired nanosecond-granularity value is
260531b17a7SHemant Agrawal * made, so there are get and set APIs to allow the user to see what actual
261531b17a7SHemant Agrawal * timeout is set (compared to the timeout that was requested).
262531b17a7SHemant Agrawal */
263531b17a7SHemant Agrawal int qbman_swp_dequeue_thresh(struct qbman_swp *s, unsigned int thresh);
264531b17a7SHemant Agrawal int qbman_swp_dequeue_set_timeout(struct qbman_swp *s, unsigned int timeout);
265531b17a7SHemant Agrawal int qbman_swp_dequeue_get_timeout(struct qbman_swp *s, unsigned int *timeout);
266531b17a7SHemant Agrawal
267531b17a7SHemant Agrawal /* ------------------- */
268531b17a7SHemant Agrawal /* Push-mode dequeuing */
269531b17a7SHemant Agrawal /* ------------------- */
270531b17a7SHemant Agrawal
271531b17a7SHemant Agrawal /* The user of a portal can enable and disable push-mode dequeuing of up to 16
272531b17a7SHemant Agrawal * channels independently. It does not specify this toggling by channel IDs, but
273531b17a7SHemant Agrawal * rather by specifying the index (from 0 to 15) that has been mapped to the
274531b17a7SHemant Agrawal * desired channel.
275531b17a7SHemant Agrawal */
276531b17a7SHemant Agrawal
277531b17a7SHemant Agrawal /**
278531b17a7SHemant Agrawal * qbman_swp_push_get() - Get the push dequeue setup.
279531b17a7SHemant Agrawal * @s: the software portal object.
280531b17a7SHemant Agrawal * @channel_idx: the channel index to query.
281531b17a7SHemant Agrawal * @enabled: returned boolean to show whether the push dequeue is enabled for
282531b17a7SHemant Agrawal * the given channel.
283531b17a7SHemant Agrawal */
284531b17a7SHemant Agrawal void qbman_swp_push_get(struct qbman_swp *s, uint8_t channel_idx, int *enabled);
285531b17a7SHemant Agrawal
286531b17a7SHemant Agrawal /**
287531b17a7SHemant Agrawal * qbman_swp_push_set() - Enable or disable push dequeue.
288531b17a7SHemant Agrawal * @s: the software portal object.
289531b17a7SHemant Agrawal * @channel_idx: the channel index..
290531b17a7SHemant Agrawal * @enable: enable or disable push dequeue.
291531b17a7SHemant Agrawal *
292531b17a7SHemant Agrawal * The user of a portal can enable and disable push-mode dequeuing of up to 16
293531b17a7SHemant Agrawal * channels independently. It does not specify this toggling by channel IDs, but
294531b17a7SHemant Agrawal * rather by specifying the index (from 0 to 15) that has been mapped to the
295531b17a7SHemant Agrawal * desired channel.
296531b17a7SHemant Agrawal */
297c9da6cfaSHemant Agrawal __rte_internal
298531b17a7SHemant Agrawal void qbman_swp_push_set(struct qbman_swp *s, uint8_t channel_idx, int enable);
299531b17a7SHemant Agrawal
300531b17a7SHemant Agrawal /* ------------------- */
301531b17a7SHemant Agrawal /* Pull-mode dequeuing */
302531b17a7SHemant Agrawal /* ------------------- */
303531b17a7SHemant Agrawal
304531b17a7SHemant Agrawal /**
305531b17a7SHemant Agrawal * struct qbman_pull_desc - the structure for pull dequeue descriptor
306531b17a7SHemant Agrawal */
307531b17a7SHemant Agrawal struct qbman_pull_desc {
30869293c77SHemant Agrawal union {
309293c0ca9SNipun Gupta uint32_t dont_manipulate_directly[16];
31069293c77SHemant Agrawal struct pull {
31169293c77SHemant Agrawal uint8_t verb;
31269293c77SHemant Agrawal uint8_t numf;
31369293c77SHemant Agrawal uint8_t tok;
31469293c77SHemant Agrawal uint8_t reserved;
31569293c77SHemant Agrawal uint32_t dq_src;
31669293c77SHemant Agrawal uint64_t rsp_addr;
31769293c77SHemant Agrawal uint64_t rsp_addr_virt;
31869293c77SHemant Agrawal uint8_t padding[40];
31969293c77SHemant Agrawal } pull;
32069293c77SHemant Agrawal };
321531b17a7SHemant Agrawal };
322531b17a7SHemant Agrawal
323531b17a7SHemant Agrawal enum qbman_pull_type_e {
324531b17a7SHemant Agrawal /* dequeue with priority precedence, respect intra-class scheduling */
325531b17a7SHemant Agrawal qbman_pull_type_prio = 1,
326531b17a7SHemant Agrawal /* dequeue with active FQ precedence, respect ICS */
327531b17a7SHemant Agrawal qbman_pull_type_active,
328531b17a7SHemant Agrawal /* dequeue with active FQ precedence, no ICS */
329531b17a7SHemant Agrawal qbman_pull_type_active_noics
330531b17a7SHemant Agrawal };
331531b17a7SHemant Agrawal
332531b17a7SHemant Agrawal /**
333531b17a7SHemant Agrawal * qbman_pull_desc_clear() - Clear the contents of a descriptor to
334531b17a7SHemant Agrawal * default/starting state.
335531b17a7SHemant Agrawal * @d: the pull dequeue descriptor to be cleared.
336531b17a7SHemant Agrawal */
337c9da6cfaSHemant Agrawal __rte_internal
338531b17a7SHemant Agrawal void qbman_pull_desc_clear(struct qbman_pull_desc *d);
339531b17a7SHemant Agrawal
340531b17a7SHemant Agrawal /**
341531b17a7SHemant Agrawal * qbman_pull_desc_set_storage()- Set the pull dequeue storage
342531b17a7SHemant Agrawal * @d: the pull dequeue descriptor to be set.
343531b17a7SHemant Agrawal * @storage: the pointer of the memory to store the dequeue result.
344531b17a7SHemant Agrawal * @storage_phys: the physical address of the storage memory.
345531b17a7SHemant Agrawal * @stash: to indicate whether write allocate is enabled.
346531b17a7SHemant Agrawal *
347531b17a7SHemant Agrawal * If not called, or if called with 'storage' as NULL, the result pull dequeues
348531b17a7SHemant Agrawal * will produce results to DQRR. If 'storage' is non-NULL, then results are
349531b17a7SHemant Agrawal * produced to the given memory location (using the physical/DMA address which
350531b17a7SHemant Agrawal * the caller provides in 'storage_phys'), and 'stash' controls whether or not
351531b17a7SHemant Agrawal * those writes to main-memory express a cache-warming attribute.
352531b17a7SHemant Agrawal */
353c9da6cfaSHemant Agrawal __rte_internal
354531b17a7SHemant Agrawal void qbman_pull_desc_set_storage(struct qbman_pull_desc *d,
355531b17a7SHemant Agrawal struct qbman_result *storage,
356d95bdc09SHemant Agrawal uint64_t storage_phys,
357531b17a7SHemant Agrawal int stash);
358531b17a7SHemant Agrawal /**
359531b17a7SHemant Agrawal * qbman_pull_desc_set_numframes() - Set the number of frames to be dequeued.
360531b17a7SHemant Agrawal * @d: the pull dequeue descriptor to be set.
361531b17a7SHemant Agrawal * @numframes: number of frames to be set, must be between 1 and 16, inclusive.
362531b17a7SHemant Agrawal */
363c9da6cfaSHemant Agrawal __rte_internal
364531b17a7SHemant Agrawal void qbman_pull_desc_set_numframes(struct qbman_pull_desc *d,
365531b17a7SHemant Agrawal uint8_t numframes);
366531b17a7SHemant Agrawal /**
367531b17a7SHemant Agrawal * qbman_pull_desc_set_token() - Set dequeue token for pull command
368531b17a7SHemant Agrawal * @d: the dequeue descriptor
369531b17a7SHemant Agrawal * @token: the token to be set
370531b17a7SHemant Agrawal *
371531b17a7SHemant Agrawal * token is the value that shows up in the dequeue response that can be used to
372531b17a7SHemant Agrawal * detect when the results have been published. The easiest technique is to zero
373531b17a7SHemant Agrawal * result "storage" before issuing a dequeue, and use any non-zero 'token' value
374531b17a7SHemant Agrawal */
375531b17a7SHemant Agrawal void qbman_pull_desc_set_token(struct qbman_pull_desc *d, uint8_t token);
376531b17a7SHemant Agrawal
377531b17a7SHemant Agrawal /* Exactly one of the following descriptor "actions" should be set. (Calling any
378531b17a7SHemant Agrawal * one of these will replace the effect of any prior call to one of these.)
379531b17a7SHemant Agrawal * - pull dequeue from the given frame queue (FQ)
380531b17a7SHemant Agrawal * - pull dequeue from any FQ in the given work queue (WQ)
381531b17a7SHemant Agrawal * - pull dequeue from any FQ in any WQ in the given channel
382531b17a7SHemant Agrawal */
383531b17a7SHemant Agrawal /**
384531b17a7SHemant Agrawal * qbman_pull_desc_set_fq() - Set fqid from which the dequeue command dequeues.
385531b17a7SHemant Agrawal * @fqid: the frame queue index of the given FQ.
386531b17a7SHemant Agrawal */
387c9da6cfaSHemant Agrawal __rte_internal
388531b17a7SHemant Agrawal void qbman_pull_desc_set_fq(struct qbman_pull_desc *d, uint32_t fqid);
389531b17a7SHemant Agrawal
390531b17a7SHemant Agrawal /**
391531b17a7SHemant Agrawal * qbman_pull_desc_set_wq() - Set wqid from which the dequeue command dequeues.
392531b17a7SHemant Agrawal * @wqid: composed of channel id and wqid within the channel.
393531b17a7SHemant Agrawal * @dct: the dequeue command type.
394531b17a7SHemant Agrawal */
395531b17a7SHemant Agrawal void qbman_pull_desc_set_wq(struct qbman_pull_desc *d, uint32_t wqid,
396531b17a7SHemant Agrawal enum qbman_pull_type_e dct);
397531b17a7SHemant Agrawal
398531b17a7SHemant Agrawal /* qbman_pull_desc_set_channel() - Set channelid from which the dequeue command
399531b17a7SHemant Agrawal * dequeues.
400531b17a7SHemant Agrawal * @chid: the channel id to be dequeued.
401531b17a7SHemant Agrawal * @dct: the dequeue command type.
402531b17a7SHemant Agrawal */
403531b17a7SHemant Agrawal void qbman_pull_desc_set_channel(struct qbman_pull_desc *d, uint32_t chid,
404531b17a7SHemant Agrawal enum qbman_pull_type_e dct);
405531b17a7SHemant Agrawal
406531b17a7SHemant Agrawal /**
407293c0ca9SNipun Gupta * qbman_pull_desc_set_rad() - Decide whether reschedule the fq after dequeue
408293c0ca9SNipun Gupta *
409293c0ca9SNipun Gupta * @rad: 1 = Reschedule the FQ after dequeue.
410293c0ca9SNipun Gupta * 0 = Allow the FQ to remain active after dequeue.
411293c0ca9SNipun Gupta */
412293c0ca9SNipun Gupta void qbman_pull_desc_set_rad(struct qbman_pull_desc *d, int rad);
413293c0ca9SNipun Gupta
414293c0ca9SNipun Gupta /**
415531b17a7SHemant Agrawal * qbman_swp_pull() - Issue the pull dequeue command
416531b17a7SHemant Agrawal * @s: the software portal object.
417531b17a7SHemant Agrawal * @d: the software portal descriptor which has been configured with
418531b17a7SHemant Agrawal * the set of qbman_pull_desc_set_*() calls.
419531b17a7SHemant Agrawal *
420531b17a7SHemant Agrawal * Return 0 for success, and -EBUSY if the software portal is not ready
421531b17a7SHemant Agrawal * to do pull dequeue.
422531b17a7SHemant Agrawal */
423c9da6cfaSHemant Agrawal __rte_internal
424531b17a7SHemant Agrawal int qbman_swp_pull(struct qbman_swp *s, struct qbman_pull_desc *d);
425531b17a7SHemant Agrawal
426531b17a7SHemant Agrawal /* -------------------------------- */
427531b17a7SHemant Agrawal /* Polling DQRR for dequeue results */
428531b17a7SHemant Agrawal /* -------------------------------- */
429531b17a7SHemant Agrawal
430531b17a7SHemant Agrawal /**
431531b17a7SHemant Agrawal * qbman_swp_dqrr_next() - Get an valid DQRR entry.
432531b17a7SHemant Agrawal * @s: the software portal object.
433531b17a7SHemant Agrawal *
434531b17a7SHemant Agrawal * Return NULL if there are no unconsumed DQRR entries. Return a DQRR entry
435531b17a7SHemant Agrawal * only once, so repeated calls can return a sequence of DQRR entries, without
436531b17a7SHemant Agrawal * requiring they be consumed immediately or in any particular order.
437531b17a7SHemant Agrawal */
438c9da6cfaSHemant Agrawal __rte_internal
439531b17a7SHemant Agrawal const struct qbman_result *qbman_swp_dqrr_next(struct qbman_swp *p);
440531b17a7SHemant Agrawal
441531b17a7SHemant Agrawal /**
4428a7833e1SNipun Gupta * qbman_swp_prefetch_dqrr_next() - prefetch the next DQRR entry.
4438a7833e1SNipun Gupta * @s: the software portal object.
4448a7833e1SNipun Gupta */
445c9da6cfaSHemant Agrawal __rte_internal
4468a7833e1SNipun Gupta void qbman_swp_prefetch_dqrr_next(struct qbman_swp *s);
4478a7833e1SNipun Gupta
4488a7833e1SNipun Gupta /**
449531b17a7SHemant Agrawal * qbman_swp_dqrr_consume() - Consume DQRR entries previously returned from
450531b17a7SHemant Agrawal * qbman_swp_dqrr_next().
451531b17a7SHemant Agrawal * @s: the software portal object.
452531b17a7SHemant Agrawal * @dq: the DQRR entry to be consumed.
453531b17a7SHemant Agrawal */
454c9da6cfaSHemant Agrawal __rte_internal
455531b17a7SHemant Agrawal void qbman_swp_dqrr_consume(struct qbman_swp *s, const struct qbman_result *dq);
456531b17a7SHemant Agrawal
457531b17a7SHemant Agrawal /**
4584170dbe2SNipun Gupta * qbman_swp_dqrr_idx_consume() - Given the DQRR index consume the DQRR entry
4594170dbe2SNipun Gupta * @s: the software portal object.
4604170dbe2SNipun Gupta * @dqrr_index: the DQRR index entry to be consumed.
4614170dbe2SNipun Gupta */
462c9da6cfaSHemant Agrawal __rte_internal
4634170dbe2SNipun Gupta void qbman_swp_dqrr_idx_consume(struct qbman_swp *s, uint8_t dqrr_index);
4644170dbe2SNipun Gupta
4654170dbe2SNipun Gupta /**
466531b17a7SHemant Agrawal * qbman_get_dqrr_idx() - Get dqrr index from the given dqrr
467531b17a7SHemant Agrawal * @dqrr: the given dqrr object.
468531b17a7SHemant Agrawal *
469531b17a7SHemant Agrawal * Return dqrr index.
470531b17a7SHemant Agrawal */
471c9da6cfaSHemant Agrawal __rte_internal
4726070ce43SNipun Gupta uint8_t qbman_get_dqrr_idx(const struct qbman_result *dqrr);
473531b17a7SHemant Agrawal
474531b17a7SHemant Agrawal /**
475531b17a7SHemant Agrawal * qbman_get_dqrr_from_idx() - Use index to get the dqrr entry from the
476531b17a7SHemant Agrawal * given portal
477531b17a7SHemant Agrawal * @s: the given portal.
478531b17a7SHemant Agrawal * @idx: the dqrr index.
479531b17a7SHemant Agrawal *
480531b17a7SHemant Agrawal * Return dqrr entry object.
481531b17a7SHemant Agrawal */
482c9da6cfaSHemant Agrawal __rte_internal
483531b17a7SHemant Agrawal struct qbman_result *qbman_get_dqrr_from_idx(struct qbman_swp *s, uint8_t idx);
484531b17a7SHemant Agrawal
485531b17a7SHemant Agrawal /* ------------------------------------------------- */
486531b17a7SHemant Agrawal /* Polling user-provided storage for dequeue results */
487531b17a7SHemant Agrawal /* ------------------------------------------------- */
488531b17a7SHemant Agrawal
489531b17a7SHemant Agrawal /**
490531b17a7SHemant Agrawal * qbman_result_has_new_result() - Check and get the dequeue response from the
491531b17a7SHemant Agrawal * dq storage memory set in pull dequeue command
492531b17a7SHemant Agrawal * @s: the software portal object.
493531b17a7SHemant Agrawal * @dq: the dequeue result read from the memory.
494531b17a7SHemant Agrawal *
495531b17a7SHemant Agrawal * Only used for user-provided storage of dequeue results, not DQRR. For
496531b17a7SHemant Agrawal * efficiency purposes, the driver will perform any required endianness
497531b17a7SHemant Agrawal * conversion to ensure that the user's dequeue result storage is in host-endian
498531b17a7SHemant Agrawal * format (whether or not that is the same as the little-endian format that
499531b17a7SHemant Agrawal * hardware DMA'd to the user's storage). As such, once the user has called
500531b17a7SHemant Agrawal * qbman_result_has_new_result() and been returned a valid dequeue result,
501531b17a7SHemant Agrawal * they should not call it again on the same memory location (except of course
502531b17a7SHemant Agrawal * if another dequeue command has been executed to produce a new result to that
503531b17a7SHemant Agrawal * location).
504531b17a7SHemant Agrawal *
505531b17a7SHemant Agrawal * Return 1 for getting a valid dequeue result, or 0 for not getting a valid
506531b17a7SHemant Agrawal * dequeue result.
507531b17a7SHemant Agrawal */
508c9da6cfaSHemant Agrawal __rte_internal
509531b17a7SHemant Agrawal int qbman_result_has_new_result(struct qbman_swp *s,
51069293c77SHemant Agrawal struct qbman_result *dq);
51169293c77SHemant Agrawal
51269293c77SHemant Agrawal /**
513*7be78d02SJosh Soref * qbman_check_command_complete() - Check if the previous issued dq command
51469293c77SHemant Agrawal * is completed and results are available in memory.
51569293c77SHemant Agrawal * @s: the software portal object.
51669293c77SHemant Agrawal * @dq: the dequeue result read from the memory.
51769293c77SHemant Agrawal *
51869293c77SHemant Agrawal * Return 1 for getting a valid dequeue result, or 0 for not getting a valid
51969293c77SHemant Agrawal * dequeue result.
52069293c77SHemant Agrawal */
521c9da6cfaSHemant Agrawal __rte_internal
52269293c77SHemant Agrawal int qbman_check_command_complete(struct qbman_result *dq);
52369293c77SHemant Agrawal
524c9da6cfaSHemant Agrawal __rte_internal
52569293c77SHemant Agrawal int qbman_check_new_result(struct qbman_result *dq);
526531b17a7SHemant Agrawal
527531b17a7SHemant Agrawal /* -------------------------------------------------------- */
528531b17a7SHemant Agrawal /* Parsing dequeue entries (DQRR and user-provided storage) */
529531b17a7SHemant Agrawal /* -------------------------------------------------------- */
530531b17a7SHemant Agrawal
531531b17a7SHemant Agrawal /**
532531b17a7SHemant Agrawal * qbman_result_is_DQ() - check the dequeue result is a dequeue response or not
533531b17a7SHemant Agrawal * @dq: the dequeue result to be checked.
534531b17a7SHemant Agrawal *
535531b17a7SHemant Agrawal * DQRR entries may contain non-dequeue results, ie. notifications
536531b17a7SHemant Agrawal */
537531b17a7SHemant Agrawal int qbman_result_is_DQ(const struct qbman_result *dq);
538531b17a7SHemant Agrawal
539531b17a7SHemant Agrawal /**
540531b17a7SHemant Agrawal * qbman_result_is_SCN() - Check the dequeue result is notification or not
541531b17a7SHemant Agrawal * @dq: the dequeue result to be checked.
542531b17a7SHemant Agrawal *
543531b17a7SHemant Agrawal * All the non-dequeue results (FQDAN/CDAN/CSCN/...) are "state change
544531b17a7SHemant Agrawal * notifications" of one type or another. Some APIs apply to all of them, of the
545531b17a7SHemant Agrawal * form qbman_result_SCN_***().
546531b17a7SHemant Agrawal */
qbman_result_is_SCN(const struct qbman_result * dq)547531b17a7SHemant Agrawal static inline int qbman_result_is_SCN(const struct qbman_result *dq)
548531b17a7SHemant Agrawal {
549531b17a7SHemant Agrawal return !qbman_result_is_DQ(dq);
550531b17a7SHemant Agrawal }
551531b17a7SHemant Agrawal
552531b17a7SHemant Agrawal /* Recognise different notification types, only required if the user allows for
553531b17a7SHemant Agrawal * these to occur, and cares about them when they do.
554531b17a7SHemant Agrawal */
555531b17a7SHemant Agrawal
556531b17a7SHemant Agrawal /**
557531b17a7SHemant Agrawal * qbman_result_is_FQDAN() - Check for FQ Data Availability
558531b17a7SHemant Agrawal * @dq: the qbman_result object.
559531b17a7SHemant Agrawal *
560531b17a7SHemant Agrawal * Return 1 if this is FQDAN.
561531b17a7SHemant Agrawal */
562531b17a7SHemant Agrawal int qbman_result_is_FQDAN(const struct qbman_result *dq);
563531b17a7SHemant Agrawal
564531b17a7SHemant Agrawal /**
565531b17a7SHemant Agrawal * qbman_result_is_CDAN() - Check for Channel Data Availability
566531b17a7SHemant Agrawal * @dq: the qbman_result object to check.
567531b17a7SHemant Agrawal *
568531b17a7SHemant Agrawal * Return 1 if this is CDAN.
569531b17a7SHemant Agrawal */
570531b17a7SHemant Agrawal int qbman_result_is_CDAN(const struct qbman_result *dq);
571531b17a7SHemant Agrawal
572531b17a7SHemant Agrawal /**
573531b17a7SHemant Agrawal * qbman_result_is_CSCN() - Check for Congestion State Change
574531b17a7SHemant Agrawal * @dq: the qbman_result object to check.
575531b17a7SHemant Agrawal *
576531b17a7SHemant Agrawal * Return 1 if this is CSCN.
577531b17a7SHemant Agrawal */
578531b17a7SHemant Agrawal int qbman_result_is_CSCN(const struct qbman_result *dq);
579531b17a7SHemant Agrawal
580531b17a7SHemant Agrawal /**
581531b17a7SHemant Agrawal * qbman_result_is_BPSCN() - Check for Buffer Pool State Change.
582531b17a7SHemant Agrawal * @dq: the qbman_result object to check.
583531b17a7SHemant Agrawal *
584531b17a7SHemant Agrawal * Return 1 if this is BPSCN.
585531b17a7SHemant Agrawal */
586531b17a7SHemant Agrawal int qbman_result_is_BPSCN(const struct qbman_result *dq);
587531b17a7SHemant Agrawal
588531b17a7SHemant Agrawal /**
589531b17a7SHemant Agrawal * qbman_result_is_CGCU() - Check for Congestion Group Count Update.
590531b17a7SHemant Agrawal * @dq: the qbman_result object to check.
591531b17a7SHemant Agrawal *
592531b17a7SHemant Agrawal * Return 1 if this is CGCU.
593531b17a7SHemant Agrawal */
594531b17a7SHemant Agrawal int qbman_result_is_CGCU(const struct qbman_result *dq);
595531b17a7SHemant Agrawal
596531b17a7SHemant Agrawal /* Frame queue state change notifications; (FQDAN in theory counts too as it
597531b17a7SHemant Agrawal * leaves a FQ parked, but it is primarily a data availability notification)
598531b17a7SHemant Agrawal */
599531b17a7SHemant Agrawal
600531b17a7SHemant Agrawal /**
601531b17a7SHemant Agrawal * qbman_result_is_FQRN() - Check for FQ Retirement Notification.
602531b17a7SHemant Agrawal * @dq: the qbman_result object to check.
603531b17a7SHemant Agrawal *
604531b17a7SHemant Agrawal * Return 1 if this is FQRN.
605531b17a7SHemant Agrawal */
606531b17a7SHemant Agrawal int qbman_result_is_FQRN(const struct qbman_result *dq);
607531b17a7SHemant Agrawal
608531b17a7SHemant Agrawal /**
609531b17a7SHemant Agrawal * qbman_result_is_FQRNI() - Check for FQ Retirement Immediate
610531b17a7SHemant Agrawal * @dq: the qbman_result object to check.
611531b17a7SHemant Agrawal *
612531b17a7SHemant Agrawal * Return 1 if this is FQRNI.
613531b17a7SHemant Agrawal */
614531b17a7SHemant Agrawal int qbman_result_is_FQRNI(const struct qbman_result *dq);
615531b17a7SHemant Agrawal
616531b17a7SHemant Agrawal /**
617531b17a7SHemant Agrawal * qbman_result_is_FQPN() - Check for FQ Park Notification
618531b17a7SHemant Agrawal * @dq: the qbman_result object to check.
619531b17a7SHemant Agrawal *
620531b17a7SHemant Agrawal * Return 1 if this is FQPN.
621531b17a7SHemant Agrawal */
622531b17a7SHemant Agrawal int qbman_result_is_FQPN(const struct qbman_result *dq);
623531b17a7SHemant Agrawal
624531b17a7SHemant Agrawal /* Parsing frame dequeue results (qbman_result_is_DQ() must be TRUE)
625531b17a7SHemant Agrawal */
626531b17a7SHemant Agrawal /* FQ empty */
627531b17a7SHemant Agrawal #define QBMAN_DQ_STAT_FQEMPTY 0x80
628531b17a7SHemant Agrawal /* FQ held active */
629531b17a7SHemant Agrawal #define QBMAN_DQ_STAT_HELDACTIVE 0x40
630531b17a7SHemant Agrawal /* FQ force eligible */
631531b17a7SHemant Agrawal #define QBMAN_DQ_STAT_FORCEELIGIBLE 0x20
632531b17a7SHemant Agrawal /* Valid frame */
633531b17a7SHemant Agrawal #define QBMAN_DQ_STAT_VALIDFRAME 0x10
634531b17a7SHemant Agrawal /* FQ ODP enable */
635531b17a7SHemant Agrawal #define QBMAN_DQ_STAT_ODPVALID 0x04
636531b17a7SHemant Agrawal /* Volatile dequeue */
637531b17a7SHemant Agrawal #define QBMAN_DQ_STAT_VOLATILE 0x02
638531b17a7SHemant Agrawal /* volatile dequeue command is expired */
639531b17a7SHemant Agrawal #define QBMAN_DQ_STAT_EXPIRED 0x01
640531b17a7SHemant Agrawal
641496324d2SNipun Gupta #define QBMAN_EQCR_DCA_IDXMASK 0x0f
642496324d2SNipun Gupta #define QBMAN_ENQUEUE_FLAG_DCA (1ULL << 31)
643496324d2SNipun Gupta
644531b17a7SHemant Agrawal /**
645531b17a7SHemant Agrawal * qbman_result_DQ_flags() - Get the STAT field of dequeue response
646531b17a7SHemant Agrawal * @dq: the dequeue result.
647531b17a7SHemant Agrawal *
648531b17a7SHemant Agrawal * Return the state field.
649531b17a7SHemant Agrawal */
650c9da6cfaSHemant Agrawal __rte_internal
65169293c77SHemant Agrawal uint8_t qbman_result_DQ_flags(const struct qbman_result *dq);
652531b17a7SHemant Agrawal
653531b17a7SHemant Agrawal /**
654531b17a7SHemant Agrawal * qbman_result_DQ_is_pull() - Check whether the dq response is from a pull
655531b17a7SHemant Agrawal * command.
656531b17a7SHemant Agrawal * @dq: the dequeue result.
657531b17a7SHemant Agrawal *
658531b17a7SHemant Agrawal * Return 1 for volatile(pull) dequeue, 0 for static dequeue.
659531b17a7SHemant Agrawal */
qbman_result_DQ_is_pull(const struct qbman_result * dq)660531b17a7SHemant Agrawal static inline int qbman_result_DQ_is_pull(const struct qbman_result *dq)
661531b17a7SHemant Agrawal {
662531b17a7SHemant Agrawal return (int)(qbman_result_DQ_flags(dq) & QBMAN_DQ_STAT_VOLATILE);
663531b17a7SHemant Agrawal }
664531b17a7SHemant Agrawal
665531b17a7SHemant Agrawal /**
666531b17a7SHemant Agrawal * qbman_result_DQ_is_pull_complete() - Check whether the pull command is
667531b17a7SHemant Agrawal * completed.
668531b17a7SHemant Agrawal * @dq: the dequeue result.
669531b17a7SHemant Agrawal *
670531b17a7SHemant Agrawal * Return boolean.
671531b17a7SHemant Agrawal */
qbman_result_DQ_is_pull_complete(const struct qbman_result * dq)672531b17a7SHemant Agrawal static inline int qbman_result_DQ_is_pull_complete(
673531b17a7SHemant Agrawal const struct qbman_result *dq)
674531b17a7SHemant Agrawal {
675531b17a7SHemant Agrawal return (int)(qbman_result_DQ_flags(dq) & QBMAN_DQ_STAT_EXPIRED);
676531b17a7SHemant Agrawal }
677531b17a7SHemant Agrawal
678531b17a7SHemant Agrawal /**
679531b17a7SHemant Agrawal * qbman_result_DQ_seqnum() - Get the seqnum field in dequeue response
680531b17a7SHemant Agrawal * seqnum is valid only if VALIDFRAME flag is TRUE
681531b17a7SHemant Agrawal * @dq: the dequeue result.
682531b17a7SHemant Agrawal *
683531b17a7SHemant Agrawal * Return seqnum.
684531b17a7SHemant Agrawal */
685c9da6cfaSHemant Agrawal __rte_internal
686531b17a7SHemant Agrawal uint16_t qbman_result_DQ_seqnum(const struct qbman_result *dq);
687531b17a7SHemant Agrawal
688531b17a7SHemant Agrawal /**
689531b17a7SHemant Agrawal * qbman_result_DQ_odpid() - Get the seqnum field in dequeue response
690*7be78d02SJosh Soref * odpid is valid only if ODPVALID flag is TRUE.
691531b17a7SHemant Agrawal * @dq: the dequeue result.
692531b17a7SHemant Agrawal *
693531b17a7SHemant Agrawal * Return odpid.
694531b17a7SHemant Agrawal */
695c9da6cfaSHemant Agrawal __rte_internal
696531b17a7SHemant Agrawal uint16_t qbman_result_DQ_odpid(const struct qbman_result *dq);
697531b17a7SHemant Agrawal
698531b17a7SHemant Agrawal /**
699531b17a7SHemant Agrawal * qbman_result_DQ_fqid() - Get the fqid in dequeue response
700531b17a7SHemant Agrawal * @dq: the dequeue result.
701531b17a7SHemant Agrawal *
702531b17a7SHemant Agrawal * Return fqid.
703531b17a7SHemant Agrawal */
704531b17a7SHemant Agrawal uint32_t qbman_result_DQ_fqid(const struct qbman_result *dq);
705531b17a7SHemant Agrawal
706531b17a7SHemant Agrawal /**
707531b17a7SHemant Agrawal * qbman_result_DQ_byte_count() - Get the byte count in dequeue response
708531b17a7SHemant Agrawal * @dq: the dequeue result.
709531b17a7SHemant Agrawal *
710531b17a7SHemant Agrawal * Return the byte count remaining in the FQ.
711531b17a7SHemant Agrawal */
712531b17a7SHemant Agrawal uint32_t qbman_result_DQ_byte_count(const struct qbman_result *dq);
713531b17a7SHemant Agrawal
714531b17a7SHemant Agrawal /**
715531b17a7SHemant Agrawal * qbman_result_DQ_frame_count - Get the frame count in dequeue response
716531b17a7SHemant Agrawal * @dq: the dequeue result.
717531b17a7SHemant Agrawal *
718531b17a7SHemant Agrawal * Return the frame count remaining in the FQ.
719531b17a7SHemant Agrawal */
720531b17a7SHemant Agrawal uint32_t qbman_result_DQ_frame_count(const struct qbman_result *dq);
721531b17a7SHemant Agrawal
722531b17a7SHemant Agrawal /**
723531b17a7SHemant Agrawal * qbman_result_DQ_fqd_ctx() - Get the frame queue context in dequeue response
724531b17a7SHemant Agrawal * @dq: the dequeue result.
725531b17a7SHemant Agrawal *
726531b17a7SHemant Agrawal * Return the frame queue context.
727531b17a7SHemant Agrawal */
728c9da6cfaSHemant Agrawal __rte_internal
729531b17a7SHemant Agrawal uint64_t qbman_result_DQ_fqd_ctx(const struct qbman_result *dq);
730531b17a7SHemant Agrawal
731531b17a7SHemant Agrawal /**
732531b17a7SHemant Agrawal * qbman_result_DQ_fd() - Get the frame descriptor in dequeue response
733531b17a7SHemant Agrawal * @dq: the dequeue result.
734531b17a7SHemant Agrawal *
735531b17a7SHemant Agrawal * Return the frame descriptor.
736531b17a7SHemant Agrawal */
737c9da6cfaSHemant Agrawal __rte_internal
738531b17a7SHemant Agrawal const struct qbman_fd *qbman_result_DQ_fd(const struct qbman_result *dq);
739531b17a7SHemant Agrawal
740531b17a7SHemant Agrawal /* State-change notifications (FQDAN/CDAN/CSCN/...). */
741531b17a7SHemant Agrawal
742531b17a7SHemant Agrawal /**
743531b17a7SHemant Agrawal * qbman_result_SCN_state() - Get the state field in State-change notification
744531b17a7SHemant Agrawal * @scn: the state change notification.
745531b17a7SHemant Agrawal *
746*7be78d02SJosh Soref * Return the state in the notification.
747531b17a7SHemant Agrawal */
748c9da6cfaSHemant Agrawal __rte_internal
749531b17a7SHemant Agrawal uint8_t qbman_result_SCN_state(const struct qbman_result *scn);
750531b17a7SHemant Agrawal
751531b17a7SHemant Agrawal /**
752531b17a7SHemant Agrawal * qbman_result_SCN_rid() - Get the resource id from the notification
753531b17a7SHemant Agrawal * @scn: the state change notification.
754531b17a7SHemant Agrawal *
755531b17a7SHemant Agrawal * Return the resource id.
756531b17a7SHemant Agrawal */
757531b17a7SHemant Agrawal uint32_t qbman_result_SCN_rid(const struct qbman_result *scn);
758531b17a7SHemant Agrawal
759531b17a7SHemant Agrawal /**
760531b17a7SHemant Agrawal * qbman_result_SCN_ctx() - get the context from the notification
761531b17a7SHemant Agrawal * @scn: the state change notification.
762531b17a7SHemant Agrawal *
763531b17a7SHemant Agrawal * Return the context.
764531b17a7SHemant Agrawal */
765531b17a7SHemant Agrawal uint64_t qbman_result_SCN_ctx(const struct qbman_result *scn);
766531b17a7SHemant Agrawal
767531b17a7SHemant Agrawal /* Type-specific "resource IDs". Mainly for illustration purposes, though it
768531b17a7SHemant Agrawal * also gives the appropriate type widths.
769531b17a7SHemant Agrawal */
770531b17a7SHemant Agrawal /* Get the FQID from the FQDAN */
771531b17a7SHemant Agrawal #define qbman_result_FQDAN_fqid(dq) qbman_result_SCN_rid(dq)
772531b17a7SHemant Agrawal /* Get the FQID from the FQRN */
773531b17a7SHemant Agrawal #define qbman_result_FQRN_fqid(dq) qbman_result_SCN_rid(dq)
774531b17a7SHemant Agrawal /* Get the FQID from the FQRNI */
775531b17a7SHemant Agrawal #define qbman_result_FQRNI_fqid(dq) qbman_result_SCN_rid(dq)
776531b17a7SHemant Agrawal /* Get the FQID from the FQPN */
777531b17a7SHemant Agrawal #define qbman_result_FQPN_fqid(dq) qbman_result_SCN_rid(dq)
778531b17a7SHemant Agrawal /* Get the channel ID from the CDAN */
779531b17a7SHemant Agrawal #define qbman_result_CDAN_cid(dq) ((uint16_t)qbman_result_SCN_rid(dq))
780531b17a7SHemant Agrawal /* Get the CGID from the CSCN */
781531b17a7SHemant Agrawal #define qbman_result_CSCN_cgid(dq) ((uint16_t)qbman_result_SCN_rid(dq))
782531b17a7SHemant Agrawal
783531b17a7SHemant Agrawal /**
784531b17a7SHemant Agrawal * qbman_result_bpscn_bpid() - Get the bpid from BPSCN
785531b17a7SHemant Agrawal * @scn: the state change notification.
786531b17a7SHemant Agrawal *
787531b17a7SHemant Agrawal * Return the buffer pool id.
788531b17a7SHemant Agrawal */
789531b17a7SHemant Agrawal uint16_t qbman_result_bpscn_bpid(const struct qbman_result *scn);
790531b17a7SHemant Agrawal
791531b17a7SHemant Agrawal /**
792531b17a7SHemant Agrawal * qbman_result_bpscn_has_free_bufs() - Check whether there are free
793531b17a7SHemant Agrawal * buffers in the pool from BPSCN.
794531b17a7SHemant Agrawal * @scn: the state change notification.
795531b17a7SHemant Agrawal *
796531b17a7SHemant Agrawal * Return the number of free buffers.
797531b17a7SHemant Agrawal */
798531b17a7SHemant Agrawal int qbman_result_bpscn_has_free_bufs(const struct qbman_result *scn);
799531b17a7SHemant Agrawal
800531b17a7SHemant Agrawal /**
801531b17a7SHemant Agrawal * qbman_result_bpscn_is_depleted() - Check BPSCN to see whether the
802531b17a7SHemant Agrawal * buffer pool is depleted.
803531b17a7SHemant Agrawal * @scn: the state change notification.
804531b17a7SHemant Agrawal *
805531b17a7SHemant Agrawal * Return the status of buffer pool depletion.
806531b17a7SHemant Agrawal */
807531b17a7SHemant Agrawal int qbman_result_bpscn_is_depleted(const struct qbman_result *scn);
808531b17a7SHemant Agrawal
809531b17a7SHemant Agrawal /**
810531b17a7SHemant Agrawal * qbman_result_bpscn_is_surplus() - Check BPSCN to see whether the buffer
811531b17a7SHemant Agrawal * pool is surplus or not.
812531b17a7SHemant Agrawal * @scn: the state change notification.
813531b17a7SHemant Agrawal *
814531b17a7SHemant Agrawal * Return the status of buffer pool surplus.
815531b17a7SHemant Agrawal */
816531b17a7SHemant Agrawal int qbman_result_bpscn_is_surplus(const struct qbman_result *scn);
817531b17a7SHemant Agrawal
818531b17a7SHemant Agrawal /**
819531b17a7SHemant Agrawal * qbman_result_bpscn_ctx() - Get the BPSCN CTX from BPSCN message
820531b17a7SHemant Agrawal * @scn: the state change notification.
821531b17a7SHemant Agrawal *
822531b17a7SHemant Agrawal * Return the BPSCN context.
823531b17a7SHemant Agrawal */
824531b17a7SHemant Agrawal uint64_t qbman_result_bpscn_ctx(const struct qbman_result *scn);
825531b17a7SHemant Agrawal
826531b17a7SHemant Agrawal /* Parsing CGCU */
827531b17a7SHemant Agrawal /**
828*7be78d02SJosh Soref * qbman_result_cgcu_cgid() - Check CGCU resource id, i.e. cgid
829531b17a7SHemant Agrawal * @scn: the state change notification.
830531b17a7SHemant Agrawal *
831531b17a7SHemant Agrawal * Return the CGCU resource id.
832531b17a7SHemant Agrawal */
833531b17a7SHemant Agrawal uint16_t qbman_result_cgcu_cgid(const struct qbman_result *scn);
834531b17a7SHemant Agrawal
835531b17a7SHemant Agrawal /**
836531b17a7SHemant Agrawal * qbman_result_cgcu_icnt() - Get the I_CNT from CGCU
837531b17a7SHemant Agrawal * @scn: the state change notification.
838531b17a7SHemant Agrawal *
839531b17a7SHemant Agrawal * Return instantaneous count in the CGCU notification.
840531b17a7SHemant Agrawal */
841531b17a7SHemant Agrawal uint64_t qbman_result_cgcu_icnt(const struct qbman_result *scn);
842531b17a7SHemant Agrawal
843531b17a7SHemant Agrawal /************/
844531b17a7SHemant Agrawal /* Enqueues */
845531b17a7SHemant Agrawal /************/
84669293c77SHemant Agrawal /* struct qbman_eq_desc - structure of enqueue descriptor */
847531b17a7SHemant Agrawal struct qbman_eq_desc {
84869293c77SHemant Agrawal union {
849293c0ca9SNipun Gupta uint32_t dont_manipulate_directly[8];
85069293c77SHemant Agrawal struct eq {
85169293c77SHemant Agrawal uint8_t verb;
85269293c77SHemant Agrawal uint8_t dca;
85369293c77SHemant Agrawal uint16_t seqnum;
85469293c77SHemant Agrawal uint16_t orpid;
85569293c77SHemant Agrawal uint16_t reserved1;
85669293c77SHemant Agrawal uint32_t tgtid;
85769293c77SHemant Agrawal uint32_t tag;
85869293c77SHemant Agrawal uint16_t qdbin;
85969293c77SHemant Agrawal uint8_t qpri;
86069293c77SHemant Agrawal uint8_t reserved[3];
86169293c77SHemant Agrawal uint8_t wae;
86269293c77SHemant Agrawal uint8_t rspid;
86369293c77SHemant Agrawal uint64_t rsp_addr;
86469293c77SHemant Agrawal } eq;
86569293c77SHemant Agrawal };
866531b17a7SHemant Agrawal };
867531b17a7SHemant Agrawal
868531b17a7SHemant Agrawal /**
869531b17a7SHemant Agrawal * struct qbman_eq_response - structure of enqueue response
870293c0ca9SNipun Gupta * @dont_manipulate_directly: the 16 32bit data to represent the whole
871531b17a7SHemant Agrawal * enqueue response.
872531b17a7SHemant Agrawal */
873531b17a7SHemant Agrawal struct qbman_eq_response {
874293c0ca9SNipun Gupta uint32_t dont_manipulate_directly[16];
875531b17a7SHemant Agrawal };
876531b17a7SHemant Agrawal
877531b17a7SHemant Agrawal /**
878531b17a7SHemant Agrawal * qbman_eq_desc_clear() - Clear the contents of a descriptor to
879531b17a7SHemant Agrawal * default/starting state.
880531b17a7SHemant Agrawal * @d: the given enqueue descriptor.
881531b17a7SHemant Agrawal */
882c9da6cfaSHemant Agrawal __rte_internal
883531b17a7SHemant Agrawal void qbman_eq_desc_clear(struct qbman_eq_desc *d);
884531b17a7SHemant Agrawal
885531b17a7SHemant Agrawal /* Exactly one of the following descriptor "actions" should be set. (Calling
886531b17a7SHemant Agrawal * any one of these will replace the effect of any prior call to one of these.)
887531b17a7SHemant Agrawal * - enqueue without order-restoration
888531b17a7SHemant Agrawal * - enqueue with order-restoration
889531b17a7SHemant Agrawal * - fill a hole in the order-restoration sequence, without any enqueue
890531b17a7SHemant Agrawal * - advance NESN (Next Expected Sequence Number), without any enqueue
891531b17a7SHemant Agrawal * 'respond_success' indicates whether an enqueue response should be DMA'd
892531b17a7SHemant Agrawal * after success (otherwise a response is DMA'd only after failure).
893531b17a7SHemant Agrawal * 'incomplete' indicates that other fragments of the same 'seqnum' are yet to
894531b17a7SHemant Agrawal * be enqueued.
895531b17a7SHemant Agrawal */
896531b17a7SHemant Agrawal
897531b17a7SHemant Agrawal /**
898531b17a7SHemant Agrawal * qbman_eq_desc_set_no_orp() - Set enqueue descriptor without orp
899531b17a7SHemant Agrawal * @d: the enqueue descriptor.
900531b17a7SHemant Agrawal * @response_success: 1 = enqueue with response always; 0 = enqueue with
901531b17a7SHemant Agrawal * rejections returned on a FQ.
902531b17a7SHemant Agrawal */
903c9da6cfaSHemant Agrawal __rte_internal
904531b17a7SHemant Agrawal void qbman_eq_desc_set_no_orp(struct qbman_eq_desc *d, int respond_success);
905531b17a7SHemant Agrawal /**
906*7be78d02SJosh Soref * qbman_eq_desc_set_orp() - Set order-restoration in the enqueue descriptor
907531b17a7SHemant Agrawal * @d: the enqueue descriptor.
908531b17a7SHemant Agrawal * @response_success: 1 = enqueue with response always; 0 = enqueue with
909531b17a7SHemant Agrawal * rejections returned on a FQ.
910531b17a7SHemant Agrawal * @opr_id: the order point record id.
911531b17a7SHemant Agrawal * @seqnum: the order restoration sequence number.
912*7be78d02SJosh Soref * @incomplete: indicates whether this is the last fragments using the same
913*7be78d02SJosh Soref * sequence number.
914531b17a7SHemant Agrawal */
915c9da6cfaSHemant Agrawal __rte_internal
916531b17a7SHemant Agrawal void qbman_eq_desc_set_orp(struct qbman_eq_desc *d, int respond_success,
91769293c77SHemant Agrawal uint16_t opr_id, uint16_t seqnum, int incomplete);
918531b17a7SHemant Agrawal
919531b17a7SHemant Agrawal /**
920531b17a7SHemant Agrawal * qbman_eq_desc_set_orp_hole() - fill a hole in the order-restoration sequence
921531b17a7SHemant Agrawal * without any enqueue
922531b17a7SHemant Agrawal * @d: the enqueue descriptor.
923531b17a7SHemant Agrawal * @opr_id: the order point record id.
924531b17a7SHemant Agrawal * @seqnum: the order restoration sequence number.
925531b17a7SHemant Agrawal */
92669293c77SHemant Agrawal void qbman_eq_desc_set_orp_hole(struct qbman_eq_desc *d, uint16_t opr_id,
92769293c77SHemant Agrawal uint16_t seqnum);
928531b17a7SHemant Agrawal
929531b17a7SHemant Agrawal /**
930531b17a7SHemant Agrawal * qbman_eq_desc_set_orp_nesn() - advance NESN (Next Expected Sequence Number)
931531b17a7SHemant Agrawal * without any enqueue
932531b17a7SHemant Agrawal * @d: the enqueue descriptor.
933531b17a7SHemant Agrawal * @opr_id: the order point record id.
934531b17a7SHemant Agrawal * @seqnum: the order restoration sequence number.
935531b17a7SHemant Agrawal */
93669293c77SHemant Agrawal void qbman_eq_desc_set_orp_nesn(struct qbman_eq_desc *d, uint16_t opr_id,
93769293c77SHemant Agrawal uint16_t seqnum);
938531b17a7SHemant Agrawal /**
939531b17a7SHemant Agrawal * qbman_eq_desc_set_response() - Set the enqueue response info.
940531b17a7SHemant Agrawal * @d: the enqueue descriptor
941531b17a7SHemant Agrawal * @storage_phys: the physical address of the enqueue response in memory.
942531b17a7SHemant Agrawal * @stash: indicate that the write allocation enabled or not.
943531b17a7SHemant Agrawal *
944531b17a7SHemant Agrawal * In the case where an enqueue response is DMA'd, this determines where that
945531b17a7SHemant Agrawal * response should go. (The physical/DMA address is given for hardware's
946531b17a7SHemant Agrawal * benefit, but software should interpret it as a "struct qbman_eq_response"
947531b17a7SHemant Agrawal * data structure.) 'stash' controls whether or not the write to main-memory
948531b17a7SHemant Agrawal * expresses a cache-warming attribute.
949531b17a7SHemant Agrawal */
950c9da6cfaSHemant Agrawal __rte_internal
951531b17a7SHemant Agrawal void qbman_eq_desc_set_response(struct qbman_eq_desc *d,
952d95bdc09SHemant Agrawal uint64_t storage_phys,
953531b17a7SHemant Agrawal int stash);
954531b17a7SHemant Agrawal
955531b17a7SHemant Agrawal /**
956531b17a7SHemant Agrawal * qbman_eq_desc_set_token() - Set token for the enqueue command
957531b17a7SHemant Agrawal * @d: the enqueue descriptor
958531b17a7SHemant Agrawal * @token: the token to be set.
959531b17a7SHemant Agrawal *
960531b17a7SHemant Agrawal * token is the value that shows up in an enqueue response that can be used to
961531b17a7SHemant Agrawal * detect when the results have been published. The easiest technique is to zero
962531b17a7SHemant Agrawal * result "storage" before issuing an enqueue, and use any non-zero 'token'
963531b17a7SHemant Agrawal * value.
964531b17a7SHemant Agrawal */
965c9da6cfaSHemant Agrawal __rte_internal
966531b17a7SHemant Agrawal void qbman_eq_desc_set_token(struct qbman_eq_desc *d, uint8_t token);
967531b17a7SHemant Agrawal
968531b17a7SHemant Agrawal /**
969531b17a7SHemant Agrawal * Exactly one of the following descriptor "targets" should be set. (Calling any
970531b17a7SHemant Agrawal * one of these will replace the effect of any prior call to one of these.)
971531b17a7SHemant Agrawal * - enqueue to a frame queue
972531b17a7SHemant Agrawal * - enqueue to a queuing destination
973531b17a7SHemant Agrawal * Note, that none of these will have any affect if the "action" type has been
974531b17a7SHemant Agrawal * set to "orp_hole" or "orp_nesn".
975531b17a7SHemant Agrawal */
976531b17a7SHemant Agrawal /**
977531b17a7SHemant Agrawal * qbman_eq_desc_set_fq() - Set Frame Queue id for the enqueue command
978531b17a7SHemant Agrawal * @d: the enqueue descriptor
979531b17a7SHemant Agrawal * @fqid: the id of the frame queue to be enqueued.
980531b17a7SHemant Agrawal */
981c9da6cfaSHemant Agrawal __rte_internal
982531b17a7SHemant Agrawal void qbman_eq_desc_set_fq(struct qbman_eq_desc *d, uint32_t fqid);
983531b17a7SHemant Agrawal
984531b17a7SHemant Agrawal /**
985531b17a7SHemant Agrawal * qbman_eq_desc_set_qd() - Set Queuing Destination for the enqueue command.
986531b17a7SHemant Agrawal * @d: the enqueue descriptor
987531b17a7SHemant Agrawal * @qdid: the id of the queuing destination to be enqueued.
988531b17a7SHemant Agrawal * @qd_bin: the queuing destination bin
989531b17a7SHemant Agrawal * @qd_prio: the queuing destination priority.
990531b17a7SHemant Agrawal */
991c9da6cfaSHemant Agrawal __rte_internal
992531b17a7SHemant Agrawal void qbman_eq_desc_set_qd(struct qbman_eq_desc *d, uint32_t qdid,
99369293c77SHemant Agrawal uint16_t qd_bin, uint8_t qd_prio);
994531b17a7SHemant Agrawal
995531b17a7SHemant Agrawal /**
996531b17a7SHemant Agrawal * qbman_eq_desc_set_eqdi() - enable/disable EQDI interrupt
997531b17a7SHemant Agrawal * @d: the enqueue descriptor
998531b17a7SHemant Agrawal * @enable: boolean to enable/disable EQDI
999531b17a7SHemant Agrawal *
1000531b17a7SHemant Agrawal * Determines whether or not the portal's EQDI interrupt source should be
1001531b17a7SHemant Agrawal * asserted after the enqueue command is completed.
1002531b17a7SHemant Agrawal */
1003531b17a7SHemant Agrawal void qbman_eq_desc_set_eqdi(struct qbman_eq_desc *d, int enable);
1004531b17a7SHemant Agrawal
1005531b17a7SHemant Agrawal /**
1006531b17a7SHemant Agrawal * qbman_eq_desc_set_dca() - Set DCA mode in the enqueue command.
1007531b17a7SHemant Agrawal * @d: the enqueue descriptor.
1008531b17a7SHemant Agrawal * @enable: enabled/disable DCA mode.
1009531b17a7SHemant Agrawal * @dqrr_idx: DCAP_CI, the DCAP consumer index.
1010531b17a7SHemant Agrawal * @park: determine the whether park the FQ or not
1011531b17a7SHemant Agrawal *
1012531b17a7SHemant Agrawal * Determines whether or not a portal DQRR entry should be consumed once the
1013531b17a7SHemant Agrawal * enqueue command is completed. (And if so, and the DQRR entry corresponds to a
1014531b17a7SHemant Agrawal * held-active (order-preserving) FQ, whether the FQ should be parked instead of
1015531b17a7SHemant Agrawal * being rescheduled.)
1016531b17a7SHemant Agrawal */
1017c9da6cfaSHemant Agrawal __rte_internal
1018531b17a7SHemant Agrawal void qbman_eq_desc_set_dca(struct qbman_eq_desc *d, int enable,
101969293c77SHemant Agrawal uint8_t dqrr_idx, int park);
1020531b17a7SHemant Agrawal
1021531b17a7SHemant Agrawal /**
102216c4a3c4SNipun Gupta * qbman_result_eqresp_fd() - Get fd from enqueue response.
102316c4a3c4SNipun Gupta * @eqresp: enqueue response.
102416c4a3c4SNipun Gupta *
102516c4a3c4SNipun Gupta * Return the fd pointer.
102616c4a3c4SNipun Gupta */
1027c9da6cfaSHemant Agrawal __rte_internal
102816c4a3c4SNipun Gupta struct qbman_fd *qbman_result_eqresp_fd(struct qbman_result *eqresp);
102916c4a3c4SNipun Gupta
103016c4a3c4SNipun Gupta /**
103116c4a3c4SNipun Gupta * qbman_result_eqresp_set_rspid() - Set the response id in enqueue response.
103216c4a3c4SNipun Gupta * @eqresp: enqueue response.
103316c4a3c4SNipun Gupta * @val: values to set into the response id.
103416c4a3c4SNipun Gupta *
103516c4a3c4SNipun Gupta * This value is set into the response id before the enqueue command, which,
103616c4a3c4SNipun Gupta * get overwritten by qbman once the enqueue command is complete.
103716c4a3c4SNipun Gupta */
1038c9da6cfaSHemant Agrawal __rte_internal
103916c4a3c4SNipun Gupta void qbman_result_eqresp_set_rspid(struct qbman_result *eqresp, uint8_t val);
104016c4a3c4SNipun Gupta
104116c4a3c4SNipun Gupta /**
104216c4a3c4SNipun Gupta * qbman_result_eqresp_rspid() - Get the response id.
104316c4a3c4SNipun Gupta * @eqresp: enqueue response.
104416c4a3c4SNipun Gupta *
104516c4a3c4SNipun Gupta * Return the response id.
104616c4a3c4SNipun Gupta *
104716c4a3c4SNipun Gupta * At the time of enqueue user provides the response id. Response id gets
104816c4a3c4SNipun Gupta * copied into the enqueue response to determine if the command has been
104916c4a3c4SNipun Gupta * completed, and response has been updated.
105016c4a3c4SNipun Gupta */
1051c9da6cfaSHemant Agrawal __rte_internal
105216c4a3c4SNipun Gupta uint8_t qbman_result_eqresp_rspid(struct qbman_result *eqresp);
105316c4a3c4SNipun Gupta
105416c4a3c4SNipun Gupta /**
1055*7be78d02SJosh Soref * qbman_result_eqresp_rc() - determines if enqueue command is successful.
105616c4a3c4SNipun Gupta * @eqresp: enqueue response.
105716c4a3c4SNipun Gupta *
1058*7be78d02SJosh Soref * Return 0 when command is successful.
105916c4a3c4SNipun Gupta */
1060c9da6cfaSHemant Agrawal __rte_internal
106116c4a3c4SNipun Gupta uint8_t qbman_result_eqresp_rc(struct qbman_result *eqresp);
106216c4a3c4SNipun Gupta
106316c4a3c4SNipun Gupta /**
1064531b17a7SHemant Agrawal * qbman_swp_enqueue() - Issue an enqueue command.
1065531b17a7SHemant Agrawal * @s: the software portal used for enqueue.
1066531b17a7SHemant Agrawal * @d: the enqueue descriptor.
1067531b17a7SHemant Agrawal * @fd: the frame descriptor to be enqueued.
1068531b17a7SHemant Agrawal *
1069531b17a7SHemant Agrawal * Please note that 'fd' should only be NULL if the "action" of the
1070531b17a7SHemant Agrawal * descriptor is "orp_hole" or "orp_nesn".
1071531b17a7SHemant Agrawal *
1072531b17a7SHemant Agrawal * Return 0 for a successful enqueue, -EBUSY if the EQCR is not ready.
1073531b17a7SHemant Agrawal */
1074531b17a7SHemant Agrawal int qbman_swp_enqueue(struct qbman_swp *s, const struct qbman_eq_desc *d,
1075531b17a7SHemant Agrawal const struct qbman_fd *fd);
107633ae0a29SNipun Gupta /**
107743f7ff9dSHaiying Wang * qbman_swp_enqueue_multiple() - Enqueue multiple frames with same
107843f7ff9dSHaiying Wang eq descriptor
107933ae0a29SNipun Gupta * @s: the software portal used for enqueue.
108043f7ff9dSHaiying Wang * @d: the enqueue descriptor.
108133ae0a29SNipun Gupta * @fd: the frame descriptor to be enqueued.
1082293c0ca9SNipun Gupta * @flags: bit-mask of QBMAN_ENQUEUE_FLAG_*** options
108333ae0a29SNipun Gupta * @num_frames: the number of the frames to be enqueued.
108433ae0a29SNipun Gupta *
108533ae0a29SNipun Gupta * Return the number of enqueued frames, -EBUSY if the EQCR is not ready.
108633ae0a29SNipun Gupta */
1087c9da6cfaSHemant Agrawal __rte_internal
108843f7ff9dSHaiying Wang int qbman_swp_enqueue_multiple(struct qbman_swp *s,
108943f7ff9dSHaiying Wang const struct qbman_eq_desc *d,
109043f7ff9dSHaiying Wang const struct qbman_fd *fd,
1091496324d2SNipun Gupta uint32_t *flags,
109243f7ff9dSHaiying Wang int num_frames);
1093a3a997f0SHemant Agrawal
1094a3a997f0SHemant Agrawal /**
1095a3a997f0SHemant Agrawal * qbman_swp_enqueue_multiple_fd() - Enqueue multiple frames with same
1096a3a997f0SHemant Agrawal eq descriptor
1097a3a997f0SHemant Agrawal * @s: the software portal used for enqueue.
1098a3a997f0SHemant Agrawal * @d: the enqueue descriptor.
1099a3a997f0SHemant Agrawal * @fd: the frame descriptor to be enqueued.
1100a3a997f0SHemant Agrawal * @flags: bit-mask of QBMAN_ENQUEUE_FLAG_*** options
1101a3a997f0SHemant Agrawal * @num_frames: the number of the frames to be enqueued.
1102a3a997f0SHemant Agrawal *
1103a3a997f0SHemant Agrawal * Return the number of enqueued frames, -EBUSY if the EQCR is not ready.
1104a3a997f0SHemant Agrawal */
1105c9da6cfaSHemant Agrawal __rte_internal
1106a3a997f0SHemant Agrawal int qbman_swp_enqueue_multiple_fd(struct qbman_swp *s,
1107a3a997f0SHemant Agrawal const struct qbman_eq_desc *d,
1108a3a997f0SHemant Agrawal struct qbman_fd **fd,
1109a3a997f0SHemant Agrawal uint32_t *flags,
1110a3a997f0SHemant Agrawal int num_frames);
1111a3a997f0SHemant Agrawal
111243f7ff9dSHaiying Wang /**
111343f7ff9dSHaiying Wang * qbman_swp_enqueue_multiple_desc() - Enqueue multiple frames with
111443f7ff9dSHaiying Wang * individual eq descriptor.
111543f7ff9dSHaiying Wang * @s: the software portal used for enqueue.
111643f7ff9dSHaiying Wang * @d: the enqueue descriptor.
111743f7ff9dSHaiying Wang * @fd: the frame descriptor to be enqueued.
111843f7ff9dSHaiying Wang * @num_frames: the number of the frames to be enqueued.
111943f7ff9dSHaiying Wang *
112043f7ff9dSHaiying Wang * Return the number of enqueued frames, -EBUSY if the EQCR is not ready.
112143f7ff9dSHaiying Wang */
1122c9da6cfaSHemant Agrawal __rte_internal
112343f7ff9dSHaiying Wang int qbman_swp_enqueue_multiple_desc(struct qbman_swp *s,
112433ae0a29SNipun Gupta const struct qbman_eq_desc *d,
112533ae0a29SNipun Gupta const struct qbman_fd *fd,
112633ae0a29SNipun Gupta int num_frames);
1127531b17a7SHemant Agrawal
1128531b17a7SHemant Agrawal /* TODO:
1129531b17a7SHemant Agrawal * qbman_swp_enqueue_thresh() - Set threshold for EQRI interrupt.
1130531b17a7SHemant Agrawal * @s: the software portal.
1131531b17a7SHemant Agrawal * @thresh: the threshold to trigger the EQRI interrupt.
1132531b17a7SHemant Agrawal *
1133531b17a7SHemant Agrawal * An EQRI interrupt can be generated when the fill-level of EQCR falls below
1134531b17a7SHemant Agrawal * the 'thresh' value set here. Setting thresh==0 (the default) disables.
1135531b17a7SHemant Agrawal */
1136531b17a7SHemant Agrawal int qbman_swp_enqueue_thresh(struct qbman_swp *s, unsigned int thresh);
1137531b17a7SHemant Agrawal
1138531b17a7SHemant Agrawal /*******************/
1139531b17a7SHemant Agrawal /* Buffer releases */
1140531b17a7SHemant Agrawal /*******************/
1141531b17a7SHemant Agrawal /**
1142531b17a7SHemant Agrawal * struct qbman_release_desc - The structure for buffer release descriptor
1143293c0ca9SNipun Gupta * @dont_manipulate_directly: the 32bit data to represent the whole
1144531b17a7SHemant Agrawal * possible settings of qbman release descriptor.
1145531b17a7SHemant Agrawal */
1146531b17a7SHemant Agrawal struct qbman_release_desc {
114769293c77SHemant Agrawal union {
1148293c0ca9SNipun Gupta uint32_t dont_manipulate_directly[16];
114969293c77SHemant Agrawal struct br {
115069293c77SHemant Agrawal uint8_t verb;
115169293c77SHemant Agrawal uint8_t reserved;
115269293c77SHemant Agrawal uint16_t bpid;
115369293c77SHemant Agrawal uint32_t reserved2;
115469293c77SHemant Agrawal uint64_t buf[7];
115569293c77SHemant Agrawal } br;
115669293c77SHemant Agrawal };
1157531b17a7SHemant Agrawal };
1158531b17a7SHemant Agrawal
1159531b17a7SHemant Agrawal /**
1160531b17a7SHemant Agrawal * qbman_release_desc_clear() - Clear the contents of a descriptor to
1161531b17a7SHemant Agrawal * default/starting state.
1162531b17a7SHemant Agrawal * @d: the qbman release descriptor.
1163531b17a7SHemant Agrawal */
1164c9da6cfaSHemant Agrawal __rte_internal
1165531b17a7SHemant Agrawal void qbman_release_desc_clear(struct qbman_release_desc *d);
1166531b17a7SHemant Agrawal
1167531b17a7SHemant Agrawal /**
1168531b17a7SHemant Agrawal * qbman_release_desc_set_bpid() - Set the ID of the buffer pool to release to
1169531b17a7SHemant Agrawal * @d: the qbman release descriptor.
1170531b17a7SHemant Agrawal */
1171c9da6cfaSHemant Agrawal __rte_internal
117269293c77SHemant Agrawal void qbman_release_desc_set_bpid(struct qbman_release_desc *d, uint16_t bpid);
1173531b17a7SHemant Agrawal
1174531b17a7SHemant Agrawal /**
1175531b17a7SHemant Agrawal * qbman_release_desc_set_rcdi() - Determines whether or not the portal's RCDI
1176531b17a7SHemant Agrawal * interrupt source should be asserted after the release command is completed.
1177531b17a7SHemant Agrawal * @d: the qbman release descriptor.
1178531b17a7SHemant Agrawal */
1179531b17a7SHemant Agrawal void qbman_release_desc_set_rcdi(struct qbman_release_desc *d, int enable);
1180531b17a7SHemant Agrawal
1181531b17a7SHemant Agrawal /**
1182531b17a7SHemant Agrawal * qbman_swp_release() - Issue a buffer release command.
1183531b17a7SHemant Agrawal * @s: the software portal object.
1184531b17a7SHemant Agrawal * @d: the release descriptor.
1185531b17a7SHemant Agrawal * @buffers: a pointer pointing to the buffer address to be released.
1186531b17a7SHemant Agrawal * @num_buffers: number of buffers to be released, must be less than 8.
1187531b17a7SHemant Agrawal *
1188531b17a7SHemant Agrawal * Return 0 for success, -EBUSY if the release command ring is not ready.
1189531b17a7SHemant Agrawal */
1190c9da6cfaSHemant Agrawal __rte_internal
1191531b17a7SHemant Agrawal int qbman_swp_release(struct qbman_swp *s, const struct qbman_release_desc *d,
1192531b17a7SHemant Agrawal const uint64_t *buffers, unsigned int num_buffers);
1193531b17a7SHemant Agrawal
1194531b17a7SHemant Agrawal /* TODO:
1195531b17a7SHemant Agrawal * qbman_swp_release_thresh() - Set threshold for RCRI interrupt
1196531b17a7SHemant Agrawal * @s: the software portal.
1197531b17a7SHemant Agrawal * @thresh: the threshold.
1198531b17a7SHemant Agrawal * An RCRI interrupt can be generated when the fill-level of RCR falls below
1199531b17a7SHemant Agrawal * the 'thresh' value set here. Setting thresh==0 (the default) disables.
1200531b17a7SHemant Agrawal */
1201531b17a7SHemant Agrawal int qbman_swp_release_thresh(struct qbman_swp *s, unsigned int thresh);
1202531b17a7SHemant Agrawal
1203531b17a7SHemant Agrawal /*******************/
1204531b17a7SHemant Agrawal /* Buffer acquires */
1205531b17a7SHemant Agrawal /*******************/
1206531b17a7SHemant Agrawal /**
1207531b17a7SHemant Agrawal * qbman_swp_acquire() - Issue a buffer acquire command.
1208531b17a7SHemant Agrawal * @s: the software portal object.
1209531b17a7SHemant Agrawal * @bpid: the buffer pool index.
1210531b17a7SHemant Agrawal * @buffers: a pointer pointing to the acquired buffer address|es.
1211531b17a7SHemant Agrawal * @num_buffers: number of buffers to be acquired, must be less than 8.
1212531b17a7SHemant Agrawal *
1213531b17a7SHemant Agrawal * Return 0 for success, or negative error code if the acquire command
1214531b17a7SHemant Agrawal * fails.
1215531b17a7SHemant Agrawal */
1216c9da6cfaSHemant Agrawal __rte_internal
121769293c77SHemant Agrawal int qbman_swp_acquire(struct qbman_swp *s, uint16_t bpid, uint64_t *buffers,
1218531b17a7SHemant Agrawal unsigned int num_buffers);
1219531b17a7SHemant Agrawal
1220531b17a7SHemant Agrawal /*****************/
1221531b17a7SHemant Agrawal /* FQ management */
1222531b17a7SHemant Agrawal /*****************/
1223531b17a7SHemant Agrawal /**
1224531b17a7SHemant Agrawal * qbman_swp_fq_schedule() - Move the fq to the scheduled state.
1225531b17a7SHemant Agrawal * @s: the software portal object.
1226531b17a7SHemant Agrawal * @fqid: the index of frame queue to be scheduled.
1227531b17a7SHemant Agrawal *
1228531b17a7SHemant Agrawal * There are a couple of different ways that a FQ can end up parked state,
1229531b17a7SHemant Agrawal * This schedules it.
1230531b17a7SHemant Agrawal *
1231531b17a7SHemant Agrawal * Return 0 for success, or negative error code for failure.
1232531b17a7SHemant Agrawal */
1233531b17a7SHemant Agrawal int qbman_swp_fq_schedule(struct qbman_swp *s, uint32_t fqid);
1234531b17a7SHemant Agrawal
1235531b17a7SHemant Agrawal /**
1236531b17a7SHemant Agrawal * qbman_swp_fq_force() - Force the FQ to fully scheduled state.
1237531b17a7SHemant Agrawal * @s: the software portal object.
1238531b17a7SHemant Agrawal * @fqid: the index of frame queue to be forced.
1239531b17a7SHemant Agrawal *
1240531b17a7SHemant Agrawal * Force eligible will force a tentatively-scheduled FQ to be fully-scheduled
1241531b17a7SHemant Agrawal * and thus be available for selection by any channel-dequeuing behaviour (push
1242531b17a7SHemant Agrawal * or pull). If the FQ is subsequently "dequeued" from the channel and is still
1243531b17a7SHemant Agrawal * empty at the time this happens, the resulting dq_entry will have no FD.
1244531b17a7SHemant Agrawal * (qbman_result_DQ_fd() will return NULL.)
1245531b17a7SHemant Agrawal *
1246531b17a7SHemant Agrawal * Return 0 for success, or negative error code for failure.
1247531b17a7SHemant Agrawal */
1248531b17a7SHemant Agrawal int qbman_swp_fq_force(struct qbman_swp *s, uint32_t fqid);
1249531b17a7SHemant Agrawal
1250531b17a7SHemant Agrawal /**
1251531b17a7SHemant Agrawal * These functions change the FQ flow-control stuff between XON/XOFF. (The
1252531b17a7SHemant Agrawal * default is XON.) This setting doesn't affect enqueues to the FQ, just
1253*7be78d02SJosh Soref * dequeues. XOFF FQs will remain in the tentatively-scheduled state, even when
1254531b17a7SHemant Agrawal * non-empty, meaning they won't be selected for scheduled dequeuing. If a FQ is
1255531b17a7SHemant Agrawal * changed to XOFF after it had already become truly-scheduled to a channel, and
1256531b17a7SHemant Agrawal * a pull dequeue of that channel occurs that selects that FQ for dequeuing,
1257531b17a7SHemant Agrawal * then the resulting dq_entry will have no FD. (qbman_result_DQ_fd() will
1258531b17a7SHemant Agrawal * return NULL.)
1259531b17a7SHemant Agrawal */
1260531b17a7SHemant Agrawal /**
1261531b17a7SHemant Agrawal * qbman_swp_fq_xon() - XON the frame queue.
1262531b17a7SHemant Agrawal * @s: the software portal object.
1263531b17a7SHemant Agrawal * @fqid: the index of frame queue.
1264531b17a7SHemant Agrawal *
1265531b17a7SHemant Agrawal * Return 0 for success, or negative error code for failure.
1266531b17a7SHemant Agrawal */
1267531b17a7SHemant Agrawal int qbman_swp_fq_xon(struct qbman_swp *s, uint32_t fqid);
1268531b17a7SHemant Agrawal /**
1269531b17a7SHemant Agrawal * qbman_swp_fq_xoff() - XOFF the frame queue.
1270531b17a7SHemant Agrawal * @s: the software portal object.
1271531b17a7SHemant Agrawal * @fqid: the index of frame queue.
1272531b17a7SHemant Agrawal *
1273531b17a7SHemant Agrawal * Return 0 for success, or negative error code for failure.
1274531b17a7SHemant Agrawal */
1275531b17a7SHemant Agrawal int qbman_swp_fq_xoff(struct qbman_swp *s, uint32_t fqid);
1276531b17a7SHemant Agrawal
1277531b17a7SHemant Agrawal /**********************/
1278531b17a7SHemant Agrawal /* Channel management */
1279531b17a7SHemant Agrawal /**********************/
1280531b17a7SHemant Agrawal
1281531b17a7SHemant Agrawal /**
1282531b17a7SHemant Agrawal * If the user has been allocated a channel object that is going to generate
1283531b17a7SHemant Agrawal * CDANs to another channel, then these functions will be necessary.
1284531b17a7SHemant Agrawal * CDAN-enabled channels only generate a single CDAN notification, after which
1285531b17a7SHemant Agrawal * it they need to be reenabled before they'll generate another. (The idea is
1286531b17a7SHemant Agrawal * that pull dequeuing will occur in reaction to the CDAN, followed by a
1287531b17a7SHemant Agrawal * reenable step.) Each function generates a distinct command to hardware, so a
1288531b17a7SHemant Agrawal * combination function is provided if the user wishes to modify the "context"
1289531b17a7SHemant Agrawal * (which shows up in each CDAN message) each time they reenable, as a single
1290531b17a7SHemant Agrawal * command to hardware.
1291531b17a7SHemant Agrawal */
1292531b17a7SHemant Agrawal
1293531b17a7SHemant Agrawal /**
1294531b17a7SHemant Agrawal * qbman_swp_CDAN_set_context() - Set CDAN context
1295531b17a7SHemant Agrawal * @s: the software portal object.
1296531b17a7SHemant Agrawal * @channelid: the channel index.
1297531b17a7SHemant Agrawal * @ctx: the context to be set in CDAN.
1298531b17a7SHemant Agrawal *
1299531b17a7SHemant Agrawal * Return 0 for success, or negative error code for failure.
1300531b17a7SHemant Agrawal */
1301531b17a7SHemant Agrawal int qbman_swp_CDAN_set_context(struct qbman_swp *s, uint16_t channelid,
1302531b17a7SHemant Agrawal uint64_t ctx);
1303531b17a7SHemant Agrawal
1304531b17a7SHemant Agrawal /**
1305531b17a7SHemant Agrawal * qbman_swp_CDAN_enable() - Enable CDAN for the channel.
1306531b17a7SHemant Agrawal * @s: the software portal object.
1307531b17a7SHemant Agrawal * @channelid: the index of the channel to generate CDAN.
1308531b17a7SHemant Agrawal *
1309531b17a7SHemant Agrawal * Return 0 for success, or negative error code for failure.
1310531b17a7SHemant Agrawal */
1311531b17a7SHemant Agrawal int qbman_swp_CDAN_enable(struct qbman_swp *s, uint16_t channelid);
1312531b17a7SHemant Agrawal
1313531b17a7SHemant Agrawal /**
1314531b17a7SHemant Agrawal * qbman_swp_CDAN_disable() - disable CDAN for the channel.
1315531b17a7SHemant Agrawal * @s: the software portal object.
1316531b17a7SHemant Agrawal * @channelid: the index of the channel to generate CDAN.
1317531b17a7SHemant Agrawal *
1318531b17a7SHemant Agrawal * Return 0 for success, or negative error code for failure.
1319531b17a7SHemant Agrawal */
1320531b17a7SHemant Agrawal int qbman_swp_CDAN_disable(struct qbman_swp *s, uint16_t channelid);
1321531b17a7SHemant Agrawal
1322531b17a7SHemant Agrawal /**
1323531b17a7SHemant Agrawal * qbman_swp_CDAN_set_context_enable() - Set CDAN contest and enable CDAN
1324531b17a7SHemant Agrawal * @s: the software portal object.
1325531b17a7SHemant Agrawal * @channelid: the index of the channel to generate CDAN.
1326531b17a7SHemant Agrawal * @ctx: the context set in CDAN.
1327531b17a7SHemant Agrawal *
1328531b17a7SHemant Agrawal * Return 0 for success, or negative error code for failure.
1329531b17a7SHemant Agrawal */
1330531b17a7SHemant Agrawal int qbman_swp_CDAN_set_context_enable(struct qbman_swp *s, uint16_t channelid,
1331531b17a7SHemant Agrawal uint64_t ctx);
1332531b17a7SHemant Agrawal #endif /* !_FSL_QBMAN_PORTAL_H */
1333