xref: /freebsd/sys/contrib/ncsw/Peripherals/BM/fsl_bman.h (revision 82aa34e6fa1cd5a4ad401383522daf51412ea4b2)
1*0aeed3e9SJustin Hibbits /******************************************************************************
2*0aeed3e9SJustin Hibbits 
3*0aeed3e9SJustin Hibbits  � 1995-2003, 2004, 2005-2011 Freescale Semiconductor, Inc.
4*0aeed3e9SJustin Hibbits  All rights reserved.
5*0aeed3e9SJustin Hibbits 
6*0aeed3e9SJustin Hibbits  This is proprietary source code of Freescale Semiconductor Inc.,
7*0aeed3e9SJustin Hibbits  and its use is subject to the NetComm Device Drivers EULA.
8*0aeed3e9SJustin Hibbits  The copyright notice above does not evidence any actual or intended
9*0aeed3e9SJustin Hibbits  publication of such source code.
10*0aeed3e9SJustin Hibbits 
11*0aeed3e9SJustin Hibbits  ALTERNATIVELY, redistribution and use in source and binary forms, with
12*0aeed3e9SJustin Hibbits  or without modification, are permitted provided that the following
13*0aeed3e9SJustin Hibbits  conditions are met:
14*0aeed3e9SJustin Hibbits      * Redistributions of source code must retain the above copyright
15*0aeed3e9SJustin Hibbits        notice, this list of conditions and the following disclaimer.
16*0aeed3e9SJustin Hibbits      * Redistributions in binary form must reproduce the above copyright
17*0aeed3e9SJustin Hibbits        notice, this list of conditions and the following disclaimer in the
18*0aeed3e9SJustin Hibbits        documentation and/or other materials provided with the distribution.
19*0aeed3e9SJustin Hibbits      * Neither the name of Freescale Semiconductor nor the
20*0aeed3e9SJustin Hibbits        names of its contributors may be used to endorse or promote products
21*0aeed3e9SJustin Hibbits        derived from this software without specific prior written permission.
22*0aeed3e9SJustin Hibbits 
23*0aeed3e9SJustin Hibbits  THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24*0aeed3e9SJustin Hibbits  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25*0aeed3e9SJustin Hibbits  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26*0aeed3e9SJustin Hibbits  DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27*0aeed3e9SJustin Hibbits  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28*0aeed3e9SJustin Hibbits  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29*0aeed3e9SJustin Hibbits  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30*0aeed3e9SJustin Hibbits  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31*0aeed3e9SJustin Hibbits  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32*0aeed3e9SJustin Hibbits  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33*0aeed3e9SJustin Hibbits  *
34*0aeed3e9SJustin Hibbits 
35*0aeed3e9SJustin Hibbits  **************************************************************************/
36*0aeed3e9SJustin Hibbits /******************************************************************************
37*0aeed3e9SJustin Hibbits  @File          fsl_bman.h
38*0aeed3e9SJustin Hibbits 
39*0aeed3e9SJustin Hibbits  @Description   BM header
40*0aeed3e9SJustin Hibbits *//***************************************************************************/
41*0aeed3e9SJustin Hibbits #ifndef __FSL_BMAN_H
42*0aeed3e9SJustin Hibbits #define __FSL_BMAN_H
43*0aeed3e9SJustin Hibbits 
44*0aeed3e9SJustin Hibbits #include "std_ext.h"
45*0aeed3e9SJustin Hibbits 
46*0aeed3e9SJustin Hibbits 
47*0aeed3e9SJustin Hibbits /*************************************************/
48*0aeed3e9SJustin Hibbits /*   BMan s/w corenet portal, low-level i/face   */
49*0aeed3e9SJustin Hibbits /*************************************************/
50*0aeed3e9SJustin Hibbits typedef enum {
51*0aeed3e9SJustin Hibbits     e_BmPortalPCI = 0,          /* PI index, cache-inhibited */
52*0aeed3e9SJustin Hibbits     e_BmPortalPCE,              /* PI index, cache-enabled */
53*0aeed3e9SJustin Hibbits     e_BmPortalPVB               /* valid-bit */
54*0aeed3e9SJustin Hibbits } e_BmPortalProduceMode;
55*0aeed3e9SJustin Hibbits 
56*0aeed3e9SJustin Hibbits typedef enum {
57*0aeed3e9SJustin Hibbits     e_BmPortalRcrCCI = 0,      /* CI index, cache-inhibited */
58*0aeed3e9SJustin Hibbits     e_BmPortalRcrCCE           /* CI index, cache-enabled */
59*0aeed3e9SJustin Hibbits } e_BmPortalRcrConsumeMode;
60*0aeed3e9SJustin Hibbits 
61*0aeed3e9SJustin Hibbits /* Portal constants */
62*0aeed3e9SJustin Hibbits #define BM_RCR_SIZE        8
63*0aeed3e9SJustin Hibbits 
64*0aeed3e9SJustin Hibbits /* Hardware constants */
65*0aeed3e9SJustin Hibbits enum bm_isr_reg {
66*0aeed3e9SJustin Hibbits     bm_isr_status = 0,
67*0aeed3e9SJustin Hibbits     bm_isr_enable = 1,
68*0aeed3e9SJustin Hibbits     bm_isr_disable = 2,
69*0aeed3e9SJustin Hibbits     bm_isr_inhibit = 3
70*0aeed3e9SJustin Hibbits };
71*0aeed3e9SJustin Hibbits 
72*0aeed3e9SJustin Hibbits /* Represents s/w corenet portal mapped data structures */
73*0aeed3e9SJustin Hibbits struct bm_rcr_entry;    /* RCR (Release Command Ring) entries */
74*0aeed3e9SJustin Hibbits struct bm_mc_command;    /* MC (Management Command) command */
75*0aeed3e9SJustin Hibbits struct bm_mc_result;    /* MC result */
76*0aeed3e9SJustin Hibbits 
77*0aeed3e9SJustin Hibbits /* This type represents a s/w corenet portal space, and is used for creating the
78*0aeed3e9SJustin Hibbits  * portal objects within it (RCR, etc) */
79*0aeed3e9SJustin Hibbits struct bm_portal;
80*0aeed3e9SJustin Hibbits 
81*0aeed3e9SJustin Hibbits /* This wrapper represents a bit-array for the depletion state of the 64 Bman
82*0aeed3e9SJustin Hibbits  * buffer pools. */
83*0aeed3e9SJustin Hibbits struct bman_depletion {
84*0aeed3e9SJustin Hibbits     uint32_t __state[2];
85*0aeed3e9SJustin Hibbits };
86*0aeed3e9SJustin Hibbits #define __bmdep_word(x) ((x) >> 5)
87*0aeed3e9SJustin Hibbits #define __bmdep_shift(x) ((x) & 0x1f)
88*0aeed3e9SJustin Hibbits #define __bmdep_bit(x) (0x80000000 >> __bmdep_shift(x))
bman_depletion_init(struct bman_depletion * c)89*0aeed3e9SJustin Hibbits static __inline__ void bman_depletion_init(struct bman_depletion *c)
90*0aeed3e9SJustin Hibbits {
91*0aeed3e9SJustin Hibbits     c->__state[0] = c->__state[1] = 0;
92*0aeed3e9SJustin Hibbits }
bman_depletion_fill(struct bman_depletion * c)93*0aeed3e9SJustin Hibbits static __inline__ void bman_depletion_fill(struct bman_depletion *c)
94*0aeed3e9SJustin Hibbits {
95*0aeed3e9SJustin Hibbits     c->__state[0] = c->__state[1] = (uint32_t)~0;
96*0aeed3e9SJustin Hibbits }
bman_depletion_get(const struct bman_depletion * c,uint8_t bpid)97*0aeed3e9SJustin Hibbits static __inline__ int bman_depletion_get(const struct bman_depletion *c, uint8_t bpid)
98*0aeed3e9SJustin Hibbits {
99*0aeed3e9SJustin Hibbits     return (int)(c->__state[__bmdep_word(bpid)] & __bmdep_bit(bpid));
100*0aeed3e9SJustin Hibbits }
bman_depletion_set(struct bman_depletion * c,uint8_t bpid)101*0aeed3e9SJustin Hibbits static __inline__ void bman_depletion_set(struct bman_depletion *c, uint8_t bpid)
102*0aeed3e9SJustin Hibbits {
103*0aeed3e9SJustin Hibbits     c->__state[__bmdep_word(bpid)] |= __bmdep_bit(bpid);
104*0aeed3e9SJustin Hibbits }
bman_depletion_unset(struct bman_depletion * c,uint8_t bpid)105*0aeed3e9SJustin Hibbits static __inline__ void bman_depletion_unset(struct bman_depletion *c, uint8_t bpid)
106*0aeed3e9SJustin Hibbits {
107*0aeed3e9SJustin Hibbits     c->__state[__bmdep_word(bpid)] &= ~__bmdep_bit(bpid);
108*0aeed3e9SJustin Hibbits }
109*0aeed3e9SJustin Hibbits 
110*0aeed3e9SJustin Hibbits /* ------------------------------ */
111*0aeed3e9SJustin Hibbits /* --- Portal enumeration API --- */
112*0aeed3e9SJustin Hibbits 
113*0aeed3e9SJustin Hibbits /* ------------------------------ */
114*0aeed3e9SJustin Hibbits /* --- Buffer pool allocation --- */
115*0aeed3e9SJustin Hibbits #define BM_POOL_THRESH_SW_ENTER 0
116*0aeed3e9SJustin Hibbits #define BM_POOL_THRESH_SW_EXIT  1
117*0aeed3e9SJustin Hibbits #define BM_POOL_THRESH_HW_ENTER 2
118*0aeed3e9SJustin Hibbits #define BM_POOL_THRESH_HW_EXIT  3
119*0aeed3e9SJustin Hibbits 
120*0aeed3e9SJustin Hibbits /* --------------- */
121*0aeed3e9SJustin Hibbits /* --- RCR API --- */
122*0aeed3e9SJustin Hibbits 
123*0aeed3e9SJustin Hibbits /* Create/destroy */
124*0aeed3e9SJustin Hibbits t_Error bm_rcr_init(struct bm_portal *portal,
125*0aeed3e9SJustin Hibbits                     e_BmPortalProduceMode pmode,
126*0aeed3e9SJustin Hibbits                     e_BmPortalRcrConsumeMode cmode);
127*0aeed3e9SJustin Hibbits void bm_rcr_finish(struct bm_portal *portal);
128*0aeed3e9SJustin Hibbits 
129*0aeed3e9SJustin Hibbits /* Start/abort RCR entry */
130*0aeed3e9SJustin Hibbits struct bm_rcr_entry *bm_rcr_start(struct bm_portal *portal);
131*0aeed3e9SJustin Hibbits void bm_rcr_abort(struct bm_portal *portal);
132*0aeed3e9SJustin Hibbits 
133*0aeed3e9SJustin Hibbits /* For PI modes only. This presumes a started but uncommitted RCR entry. If
134*0aeed3e9SJustin Hibbits  * there's no more room in the RCR, this function returns NULL. Otherwise it
135*0aeed3e9SJustin Hibbits  * returns the next RCR entry and increments an internal PI counter without
136*0aeed3e9SJustin Hibbits  * flushing it to h/w. */
137*0aeed3e9SJustin Hibbits struct bm_rcr_entry *bm_rcr_pend_and_next(struct bm_portal *portal, uint8_t myverb);
138*0aeed3e9SJustin Hibbits 
139*0aeed3e9SJustin Hibbits /* Commit RCR entries, including pending ones (aka "write PI") */
140*0aeed3e9SJustin Hibbits void bm_rcr_pci_commit(struct bm_portal *portal, uint8_t myverb);
141*0aeed3e9SJustin Hibbits void bm_rcr_pce_prefetch(struct bm_portal *portal);
142*0aeed3e9SJustin Hibbits void bm_rcr_pce_commit(struct bm_portal *portal, uint8_t myverb);
143*0aeed3e9SJustin Hibbits void bm_rcr_pvb_commit(struct bm_portal *portal, uint8_t myverb);
144*0aeed3e9SJustin Hibbits 
145*0aeed3e9SJustin Hibbits /* Track h/w consumption. Returns non-zero if h/w had consumed previously
146*0aeed3e9SJustin Hibbits  * unconsumed RCR entries. */
147*0aeed3e9SJustin Hibbits uint8_t bm_rcr_cci_update(struct bm_portal *portal);
148*0aeed3e9SJustin Hibbits void bm_rcr_cce_prefetch(struct bm_portal *portal);
149*0aeed3e9SJustin Hibbits uint8_t bm_rcr_cce_update(struct bm_portal *portal);
150*0aeed3e9SJustin Hibbits /* Returns the number of available RCR entries */
151*0aeed3e9SJustin Hibbits uint8_t bm_rcr_get_avail(struct bm_portal *portal);
152*0aeed3e9SJustin Hibbits /* Returns the number of unconsumed RCR entries */
153*0aeed3e9SJustin Hibbits uint8_t bm_rcr_get_fill(struct bm_portal *portal);
154*0aeed3e9SJustin Hibbits 
155*0aeed3e9SJustin Hibbits /* Read/write the RCR interrupt threshold */
156*0aeed3e9SJustin Hibbits uint8_t bm_rcr_get_ithresh(struct bm_portal *portal);
157*0aeed3e9SJustin Hibbits void bm_rcr_set_ithresh(struct bm_portal *portal, uint8_t ithresh);
158*0aeed3e9SJustin Hibbits 
159*0aeed3e9SJustin Hibbits 
160*0aeed3e9SJustin Hibbits /* ------------------------------ */
161*0aeed3e9SJustin Hibbits /* --- Management command API --- */
162*0aeed3e9SJustin Hibbits 
163*0aeed3e9SJustin Hibbits /* Create/destroy */
164*0aeed3e9SJustin Hibbits t_Error bm_mc_init(struct bm_portal *portal);
165*0aeed3e9SJustin Hibbits void bm_mc_finish(struct bm_portal *portal);
166*0aeed3e9SJustin Hibbits 
167*0aeed3e9SJustin Hibbits /* Start/abort mgmt command */
168*0aeed3e9SJustin Hibbits struct bm_mc_command *bm_mc_start(struct bm_portal *portal);
169*0aeed3e9SJustin Hibbits void bm_mc_abort(struct bm_portal *portal);
170*0aeed3e9SJustin Hibbits 
171*0aeed3e9SJustin Hibbits /* Writes 'verb' with appropriate 'vbit'. Invalidates and pre-fetches the
172*0aeed3e9SJustin Hibbits  * response. */
173*0aeed3e9SJustin Hibbits void bm_mc_commit(struct bm_portal *portal, uint8_t myverb);
174*0aeed3e9SJustin Hibbits 
175*0aeed3e9SJustin Hibbits /* Poll for result. If NULL, invalidates and prefetches for the next call. */
176*0aeed3e9SJustin Hibbits struct bm_mc_result *bm_mc_result(struct bm_portal *portal);
177*0aeed3e9SJustin Hibbits 
178*0aeed3e9SJustin Hibbits 
179*0aeed3e9SJustin Hibbits /* ------------------------------------- */
180*0aeed3e9SJustin Hibbits /* --- Portal interrupt register API --- */
181*0aeed3e9SJustin Hibbits 
182*0aeed3e9SJustin Hibbits /* For a quick explanation of the Bman interrupt model, see the comments in the
183*0aeed3e9SJustin Hibbits  * equivalent section of the qman_portal.h header.
184*0aeed3e9SJustin Hibbits  */
185*0aeed3e9SJustin Hibbits 
186*0aeed3e9SJustin Hibbits /* Create/destroy */
187*0aeed3e9SJustin Hibbits t_Error bm_isr_init(struct bm_portal *portal);
188*0aeed3e9SJustin Hibbits void bm_isr_finish(struct bm_portal *portal);
189*0aeed3e9SJustin Hibbits 
190*0aeed3e9SJustin Hibbits /* BSCN masking is a per-portal configuration */
191*0aeed3e9SJustin Hibbits void bm_isr_bscn_mask(struct bm_portal *portal, uint8_t bpid, int enable);
192*0aeed3e9SJustin Hibbits 
193*0aeed3e9SJustin Hibbits /* Used by all portal interrupt registers except 'inhibit' */
194*0aeed3e9SJustin Hibbits #define BM_PIRQ_RCRI    0x00000002    /* RCR Ring (below threshold) */
195*0aeed3e9SJustin Hibbits #define BM_PIRQ_BSCN    0x00000001    /* Buffer depletion State Change */
196*0aeed3e9SJustin Hibbits 
197*0aeed3e9SJustin Hibbits /* These are bm_<reg>_<verb>(). So for example, bm_disable_write() means "write
198*0aeed3e9SJustin Hibbits  * the disable register" rather than "disable the ability to write". */
199*0aeed3e9SJustin Hibbits #define bm_isr_status_read(bm)      __bm_isr_read(bm, bm_isr_status)
200*0aeed3e9SJustin Hibbits #define bm_isr_status_clear(bm, m)  __bm_isr_write(bm, bm_isr_status, m)
201*0aeed3e9SJustin Hibbits #define bm_isr_enable_read(bm)      __bm_isr_read(bm, bm_isr_enable)
202*0aeed3e9SJustin Hibbits #define bm_isr_enable_write(bm, v)  __bm_isr_write(bm, bm_isr_enable, v)
203*0aeed3e9SJustin Hibbits #define bm_isr_disable_read(bm)     __bm_isr_read(bm, bm_isr_disable)
204*0aeed3e9SJustin Hibbits #define bm_isr_disable_write(bm, v) __bm_isr_write(bm, bm_isr_disable, v)
205*0aeed3e9SJustin Hibbits #define bm_isr_inhibit(bm)          __bm_isr_write(bm, bm_isr_inhibit, 1)
206*0aeed3e9SJustin Hibbits #define bm_isr_uninhibit(bm)        __bm_isr_write(bm, bm_isr_inhibit, 0)
207*0aeed3e9SJustin Hibbits 
208*0aeed3e9SJustin Hibbits /* Don't use these, use the wrappers above*/
209*0aeed3e9SJustin Hibbits uint32_t __bm_isr_read(struct bm_portal *portal, enum bm_isr_reg n);
210*0aeed3e9SJustin Hibbits void __bm_isr_write(struct bm_portal *portal, enum bm_isr_reg n, uint32_t val);
211*0aeed3e9SJustin Hibbits 
212*0aeed3e9SJustin Hibbits /* ------------------------------------------------------- */
213*0aeed3e9SJustin Hibbits /* --- Bman data structures (and associated constants) --- */
214*0aeed3e9SJustin Hibbits /* Code-reduction, define a wrapper for 48-bit buffers. In cases where a buffer
215*0aeed3e9SJustin Hibbits  * pool id specific to this buffer is needed (BM_RCR_VERB_CMD_BPID_MULTI,
216*0aeed3e9SJustin Hibbits  * BM_MCC_VERB_ACQUIRE), the 'bpid' field is used. */
217*0aeed3e9SJustin Hibbits 
218*0aeed3e9SJustin Hibbits #define BM_RCR_VERB_VBIT                0x80
219*0aeed3e9SJustin Hibbits #define BM_RCR_VERB_CMD_MASK            0x70    /* one of two values; */
220*0aeed3e9SJustin Hibbits #define BM_RCR_VERB_CMD_BPID_SINGLE     0x20
221*0aeed3e9SJustin Hibbits #define BM_RCR_VERB_CMD_BPID_MULTI      0x30
222*0aeed3e9SJustin Hibbits #define BM_RCR_VERB_BUFCOUNT_MASK       0x0f    /* values 1..8 */
223*0aeed3e9SJustin Hibbits 
224*0aeed3e9SJustin Hibbits #define BM_MCC_VERB_VBIT                0x80
225*0aeed3e9SJustin Hibbits #define BM_MCC_VERB_CMD_MASK            0x70    /* where the verb contains; */
226*0aeed3e9SJustin Hibbits #define BM_MCC_VERB_CMD_ACQUIRE         0x10
227*0aeed3e9SJustin Hibbits #define BM_MCC_VERB_CMD_QUERY           0x40
228*0aeed3e9SJustin Hibbits #define BM_MCC_VERB_ACQUIRE_BUFCOUNT    0x0f    /* values 1..8 go here */
229*0aeed3e9SJustin Hibbits 
230*0aeed3e9SJustin Hibbits 
231*0aeed3e9SJustin Hibbits #if defined(__MWERKS__) && !defined(__GNUC__)
232*0aeed3e9SJustin Hibbits #pragma pack(push,1)
233*0aeed3e9SJustin Hibbits #endif /* defined(__MWERKS__) && ... */
234*0aeed3e9SJustin Hibbits #define MEM_MAP_START
235*0aeed3e9SJustin Hibbits 
236*0aeed3e9SJustin Hibbits _Packed struct bm_buffer {
237*0aeed3e9SJustin Hibbits     volatile uint8_t reserved1;
238*0aeed3e9SJustin Hibbits     volatile uint8_t bpid;
239*0aeed3e9SJustin Hibbits     volatile uint16_t hi;    /* High 16-bits of 48-bit address */
240*0aeed3e9SJustin Hibbits     volatile uint32_t lo;    /* Low 32-bits of 48-bit address */
241*0aeed3e9SJustin Hibbits } _PackedType;
242*0aeed3e9SJustin Hibbits 
243*0aeed3e9SJustin Hibbits /* See 1.5.3.5.4: "Release Command" */
244*0aeed3e9SJustin Hibbits _Packed struct bm_rcr_entry {
245*0aeed3e9SJustin Hibbits     _Packed union {
246*0aeed3e9SJustin Hibbits         _Packed struct {
247*0aeed3e9SJustin Hibbits             volatile uint8_t __dont_write_directly__verb;
248*0aeed3e9SJustin Hibbits             volatile uint8_t bpid; /* used with BM_RCR_VERB_CMD_BPID_SINGLE */
249*0aeed3e9SJustin Hibbits             volatile uint8_t reserved1[62];
250*0aeed3e9SJustin Hibbits         } _PackedType;
251*0aeed3e9SJustin Hibbits         volatile struct bm_buffer bufs[8];
252*0aeed3e9SJustin Hibbits     } _PackedType;
253*0aeed3e9SJustin Hibbits } _PackedType;
254*0aeed3e9SJustin Hibbits 
255*0aeed3e9SJustin Hibbits /* See 1.5.3.1: "Acquire Command" */
256*0aeed3e9SJustin Hibbits /* See 1.5.3.2: "Query Command" */
257*0aeed3e9SJustin Hibbits _Packed struct bm_mc_command {
258*0aeed3e9SJustin Hibbits     volatile uint8_t __dont_write_directly__verb;
259*0aeed3e9SJustin Hibbits     _Packed union {
260*0aeed3e9SJustin Hibbits         _Packed struct bm_mcc_acquire {
261*0aeed3e9SJustin Hibbits             volatile uint8_t bpid;
262*0aeed3e9SJustin Hibbits             volatile uint8_t reserved1[62];
263*0aeed3e9SJustin Hibbits         } _PackedType acquire;
264*0aeed3e9SJustin Hibbits         _Packed struct bm_mcc_query {
265*0aeed3e9SJustin Hibbits             volatile uint8_t reserved1[63];
266*0aeed3e9SJustin Hibbits         } _PackedType query;
267*0aeed3e9SJustin Hibbits     } _PackedType;
268*0aeed3e9SJustin Hibbits } _PackedType;
269*0aeed3e9SJustin Hibbits 
270*0aeed3e9SJustin Hibbits /* See 1.5.3.3: "Acquire Reponse" */
271*0aeed3e9SJustin Hibbits /* See 1.5.3.4: "Query Reponse" */
272*0aeed3e9SJustin Hibbits _Packed struct bm_mc_result {
273*0aeed3e9SJustin Hibbits     _Packed union {
274*0aeed3e9SJustin Hibbits         _Packed struct {
275*0aeed3e9SJustin Hibbits             volatile uint8_t verb;
276*0aeed3e9SJustin Hibbits             volatile uint8_t reserved1[63];
277*0aeed3e9SJustin Hibbits         } _PackedType;
278*0aeed3e9SJustin Hibbits         _Packed union {
279*0aeed3e9SJustin Hibbits             _Packed struct {
280*0aeed3e9SJustin Hibbits                 volatile uint8_t reserved1;
281*0aeed3e9SJustin Hibbits                 volatile uint8_t bpid;
282*0aeed3e9SJustin Hibbits                 volatile uint8_t reserved2[62];
283*0aeed3e9SJustin Hibbits             } _PackedType;
284*0aeed3e9SJustin Hibbits             volatile struct bm_buffer bufs[8];
285*0aeed3e9SJustin Hibbits         } _PackedType acquire;
286*0aeed3e9SJustin Hibbits         _Packed struct {
287*0aeed3e9SJustin Hibbits             volatile uint8_t reserved1[32];
288*0aeed3e9SJustin Hibbits             /* "availability state" and "depletion state" */
289*0aeed3e9SJustin Hibbits             _Packed struct {
290*0aeed3e9SJustin Hibbits                 volatile uint8_t reserved1[8];
291*0aeed3e9SJustin Hibbits                 /* Access using bman_depletion_***() */
292*0aeed3e9SJustin Hibbits                 volatile struct bman_depletion state;
293*0aeed3e9SJustin Hibbits             } _PackedType as, ds;
294*0aeed3e9SJustin Hibbits         } _PackedType query;
295*0aeed3e9SJustin Hibbits     } _PackedType;
296*0aeed3e9SJustin Hibbits } _PackedType;
297*0aeed3e9SJustin Hibbits 
298*0aeed3e9SJustin Hibbits #define MEM_MAP_END
299*0aeed3e9SJustin Hibbits #if defined(__MWERKS__) && !defined(__GNUC__)
300*0aeed3e9SJustin Hibbits #pragma pack(pop)
301*0aeed3e9SJustin Hibbits #endif /* defined(__MWERKS__) && ... */
302*0aeed3e9SJustin Hibbits 
303*0aeed3e9SJustin Hibbits 
304*0aeed3e9SJustin Hibbits #define BM_MCR_VERB_VBIT                0x80
305*0aeed3e9SJustin Hibbits #define BM_MCR_VERB_CMD_MASK            BM_MCC_VERB_CMD_MASK
306*0aeed3e9SJustin Hibbits #define BM_MCR_VERB_CMD_ACQUIRE         BM_MCC_VERB_CMD_ACQUIRE
307*0aeed3e9SJustin Hibbits #define BM_MCR_VERB_CMD_QUERY           BM_MCC_VERB_CMD_QUERY
308*0aeed3e9SJustin Hibbits #define BM_MCR_VERB_CMD_ERR_INVALID     0x60
309*0aeed3e9SJustin Hibbits #define BM_MCR_VERB_CMD_ERR_ECC         0x70
310*0aeed3e9SJustin Hibbits #define BM_MCR_VERB_ACQUIRE_BUFCOUNT    BM_MCC_VERB_ACQUIRE_BUFCOUNT /* 0..8 */
311*0aeed3e9SJustin Hibbits /* Determine the "availability state" of pool 'p' from a query result 'r' */
312*0aeed3e9SJustin Hibbits #define BM_MCR_QUERY_AVAILABILITY(r,p) bman_depletion_get(&r->query.as.state,p)
313*0aeed3e9SJustin Hibbits /* Determine the "depletion state" of pool 'p' from a query result 'r' */
314*0aeed3e9SJustin Hibbits #define BM_MCR_QUERY_DEPLETION(r,p) bman_depletion_get(&r->query.ds.state,p)
315*0aeed3e9SJustin Hibbits 
316*0aeed3e9SJustin Hibbits 
317*0aeed3e9SJustin Hibbits /* Portal and Buffer Pools */
318*0aeed3e9SJustin Hibbits /* ----------------------- */
319*0aeed3e9SJustin Hibbits 
320*0aeed3e9SJustin Hibbits /* Flags to bman_create_portal() */
321*0aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_IRQ         0x00000001 /* use interrupt handler */
322*0aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_IRQ_FAST    0x00000002 /* ... for fast-path too! */
323*0aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_COMPACT     0x00000004 /* use compaction algorithm */
324*0aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_RECOVER     0x00000008 /* recovery mode */
325*0aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_WAIT        0x00000010 /* wait if RCR is full */
326*0aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_WAIT_INT    0x00000020 /* if wait, interruptible? */
327*0aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_CACHE       0x00000400 /* use cache-able area for rings */
328*0aeed3e9SJustin Hibbits 
329*0aeed3e9SJustin Hibbits /* Flags to bman_new_pool() */
330*0aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_NO_RELEASE    0x00000001 /* can't release to pool */
331*0aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_ONLY_RELEASE  0x00000002 /* can only release to pool */
332*0aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_DEPLETION     0x00000004 /* track depletion entry/exit */
333*0aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_DYNAMIC_BPID  0x00000008 /* (de)allocate bpid */
334*0aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_THRESH        0x00000010 /* set depletion thresholds */
335*0aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_STOCKPILE     0x00000020 /* stockpile to reduce hw ops */
336*0aeed3e9SJustin Hibbits 
337*0aeed3e9SJustin Hibbits /* Flags to bman_release() */
338*0aeed3e9SJustin Hibbits #define BMAN_RELEASE_FLAG_WAIT       0x00000001 /* wait if RCR is full */
339*0aeed3e9SJustin Hibbits #define BMAN_RELEASE_FLAG_WAIT_INT   0x00000002 /* if we wait, interruptible? */
340*0aeed3e9SJustin Hibbits #define BMAN_RELEASE_FLAG_WAIT_SYNC  0x00000004 /* if wait, until consumed? */
341*0aeed3e9SJustin Hibbits #define BMAN_RELEASE_FLAG_NOW        0x00000008 /* issue immediate release */
342*0aeed3e9SJustin Hibbits 
343*0aeed3e9SJustin Hibbits /* Flags to bman_acquire() */
344*0aeed3e9SJustin Hibbits #define BMAN_ACQUIRE_FLAG_STOCKPILE  0x00000001 /* no hw op, stockpile only */
345*0aeed3e9SJustin Hibbits 
346*0aeed3e9SJustin Hibbits 
347*0aeed3e9SJustin Hibbits #endif /* __FSL_BMAN_H */
348