10aeed3e9SJustin Hibbits /******************************************************************************
20aeed3e9SJustin Hibbits 
30aeed3e9SJustin Hibbits  � 1995-2003, 2004, 2005-2011 Freescale Semiconductor, Inc.
40aeed3e9SJustin Hibbits  All rights reserved.
50aeed3e9SJustin Hibbits 
60aeed3e9SJustin Hibbits  This is proprietary source code of Freescale Semiconductor Inc.,
70aeed3e9SJustin Hibbits  and its use is subject to the NetComm Device Drivers EULA.
80aeed3e9SJustin Hibbits  The copyright notice above does not evidence any actual or intended
90aeed3e9SJustin Hibbits  publication of such source code.
100aeed3e9SJustin Hibbits 
110aeed3e9SJustin Hibbits  ALTERNATIVELY, redistribution and use in source and binary forms, with
120aeed3e9SJustin Hibbits  or without modification, are permitted provided that the following
130aeed3e9SJustin Hibbits  conditions are met:
140aeed3e9SJustin Hibbits      * Redistributions of source code must retain the above copyright
150aeed3e9SJustin Hibbits        notice, this list of conditions and the following disclaimer.
160aeed3e9SJustin Hibbits      * Redistributions in binary form must reproduce the above copyright
170aeed3e9SJustin Hibbits        notice, this list of conditions and the following disclaimer in the
180aeed3e9SJustin Hibbits        documentation and/or other materials provided with the distribution.
190aeed3e9SJustin Hibbits      * Neither the name of Freescale Semiconductor nor the
200aeed3e9SJustin Hibbits        names of its contributors may be used to endorse or promote products
210aeed3e9SJustin Hibbits        derived from this software without specific prior written permission.
220aeed3e9SJustin Hibbits 
230aeed3e9SJustin Hibbits  THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
240aeed3e9SJustin Hibbits  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
250aeed3e9SJustin Hibbits  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
260aeed3e9SJustin Hibbits  DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
270aeed3e9SJustin Hibbits  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
280aeed3e9SJustin Hibbits  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
290aeed3e9SJustin Hibbits  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
300aeed3e9SJustin Hibbits  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
310aeed3e9SJustin Hibbits  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
320aeed3e9SJustin Hibbits  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
330aeed3e9SJustin Hibbits  *
340aeed3e9SJustin Hibbits 
350aeed3e9SJustin Hibbits  **************************************************************************/
360aeed3e9SJustin Hibbits /******************************************************************************
370aeed3e9SJustin Hibbits  @File          fsl_bman.h
380aeed3e9SJustin Hibbits 
390aeed3e9SJustin Hibbits  @Description   BM header
400aeed3e9SJustin Hibbits *//***************************************************************************/
410aeed3e9SJustin Hibbits #ifndef __FSL_BMAN_H
420aeed3e9SJustin Hibbits #define __FSL_BMAN_H
430aeed3e9SJustin Hibbits 
440aeed3e9SJustin Hibbits #include "std_ext.h"
450aeed3e9SJustin Hibbits 
460aeed3e9SJustin Hibbits 
470aeed3e9SJustin Hibbits /*************************************************/
480aeed3e9SJustin Hibbits /*   BMan s/w corenet portal, low-level i/face   */
490aeed3e9SJustin Hibbits /*************************************************/
500aeed3e9SJustin Hibbits typedef enum {
510aeed3e9SJustin Hibbits     e_BmPortalPCI = 0,          /* PI index, cache-inhibited */
520aeed3e9SJustin Hibbits     e_BmPortalPCE,              /* PI index, cache-enabled */
530aeed3e9SJustin Hibbits     e_BmPortalPVB               /* valid-bit */
540aeed3e9SJustin Hibbits } e_BmPortalProduceMode;
550aeed3e9SJustin Hibbits 
560aeed3e9SJustin Hibbits typedef enum {
570aeed3e9SJustin Hibbits     e_BmPortalRcrCCI = 0,      /* CI index, cache-inhibited */
580aeed3e9SJustin Hibbits     e_BmPortalRcrCCE           /* CI index, cache-enabled */
590aeed3e9SJustin Hibbits } e_BmPortalRcrConsumeMode;
600aeed3e9SJustin Hibbits 
610aeed3e9SJustin Hibbits /* Portal constants */
620aeed3e9SJustin Hibbits #define BM_RCR_SIZE        8
630aeed3e9SJustin Hibbits 
640aeed3e9SJustin Hibbits /* Hardware constants */
650aeed3e9SJustin Hibbits enum bm_isr_reg {
660aeed3e9SJustin Hibbits     bm_isr_status = 0,
670aeed3e9SJustin Hibbits     bm_isr_enable = 1,
680aeed3e9SJustin Hibbits     bm_isr_disable = 2,
690aeed3e9SJustin Hibbits     bm_isr_inhibit = 3
700aeed3e9SJustin Hibbits };
710aeed3e9SJustin Hibbits 
720aeed3e9SJustin Hibbits /* Represents s/w corenet portal mapped data structures */
730aeed3e9SJustin Hibbits struct bm_rcr_entry;    /* RCR (Release Command Ring) entries */
740aeed3e9SJustin Hibbits struct bm_mc_command;    /* MC (Management Command) command */
750aeed3e9SJustin Hibbits struct bm_mc_result;    /* MC result */
760aeed3e9SJustin Hibbits 
770aeed3e9SJustin Hibbits /* This type represents a s/w corenet portal space, and is used for creating the
780aeed3e9SJustin Hibbits  * portal objects within it (RCR, etc) */
790aeed3e9SJustin Hibbits struct bm_portal;
800aeed3e9SJustin Hibbits 
810aeed3e9SJustin Hibbits /* This wrapper represents a bit-array for the depletion state of the 64 Bman
820aeed3e9SJustin Hibbits  * buffer pools. */
830aeed3e9SJustin Hibbits struct bman_depletion {
840aeed3e9SJustin Hibbits     uint32_t __state[2];
850aeed3e9SJustin Hibbits };
860aeed3e9SJustin Hibbits #define __bmdep_word(x) ((x) >> 5)
870aeed3e9SJustin Hibbits #define __bmdep_shift(x) ((x) & 0x1f)
880aeed3e9SJustin Hibbits #define __bmdep_bit(x) (0x80000000 >> __bmdep_shift(x))
bman_depletion_init(struct bman_depletion * c)890aeed3e9SJustin Hibbits static __inline__ void bman_depletion_init(struct bman_depletion *c)
900aeed3e9SJustin Hibbits {
910aeed3e9SJustin Hibbits     c->__state[0] = c->__state[1] = 0;
920aeed3e9SJustin Hibbits }
bman_depletion_fill(struct bman_depletion * c)930aeed3e9SJustin Hibbits static __inline__ void bman_depletion_fill(struct bman_depletion *c)
940aeed3e9SJustin Hibbits {
950aeed3e9SJustin Hibbits     c->__state[0] = c->__state[1] = (uint32_t)~0;
960aeed3e9SJustin Hibbits }
bman_depletion_get(const struct bman_depletion * c,uint8_t bpid)970aeed3e9SJustin Hibbits static __inline__ int bman_depletion_get(const struct bman_depletion *c, uint8_t bpid)
980aeed3e9SJustin Hibbits {
990aeed3e9SJustin Hibbits     return (int)(c->__state[__bmdep_word(bpid)] & __bmdep_bit(bpid));
1000aeed3e9SJustin Hibbits }
bman_depletion_set(struct bman_depletion * c,uint8_t bpid)1010aeed3e9SJustin Hibbits static __inline__ void bman_depletion_set(struct bman_depletion *c, uint8_t bpid)
1020aeed3e9SJustin Hibbits {
1030aeed3e9SJustin Hibbits     c->__state[__bmdep_word(bpid)] |= __bmdep_bit(bpid);
1040aeed3e9SJustin Hibbits }
bman_depletion_unset(struct bman_depletion * c,uint8_t bpid)1050aeed3e9SJustin Hibbits static __inline__ void bman_depletion_unset(struct bman_depletion *c, uint8_t bpid)
1060aeed3e9SJustin Hibbits {
1070aeed3e9SJustin Hibbits     c->__state[__bmdep_word(bpid)] &= ~__bmdep_bit(bpid);
1080aeed3e9SJustin Hibbits }
1090aeed3e9SJustin Hibbits 
1100aeed3e9SJustin Hibbits /* ------------------------------ */
1110aeed3e9SJustin Hibbits /* --- Portal enumeration API --- */
1120aeed3e9SJustin Hibbits 
1130aeed3e9SJustin Hibbits /* ------------------------------ */
1140aeed3e9SJustin Hibbits /* --- Buffer pool allocation --- */
1150aeed3e9SJustin Hibbits #define BM_POOL_THRESH_SW_ENTER 0
1160aeed3e9SJustin Hibbits #define BM_POOL_THRESH_SW_EXIT  1
1170aeed3e9SJustin Hibbits #define BM_POOL_THRESH_HW_ENTER 2
1180aeed3e9SJustin Hibbits #define BM_POOL_THRESH_HW_EXIT  3
1190aeed3e9SJustin Hibbits 
1200aeed3e9SJustin Hibbits /* --------------- */
1210aeed3e9SJustin Hibbits /* --- RCR API --- */
1220aeed3e9SJustin Hibbits 
1230aeed3e9SJustin Hibbits /* Create/destroy */
1240aeed3e9SJustin Hibbits t_Error bm_rcr_init(struct bm_portal *portal,
1250aeed3e9SJustin Hibbits                     e_BmPortalProduceMode pmode,
1260aeed3e9SJustin Hibbits                     e_BmPortalRcrConsumeMode cmode);
1270aeed3e9SJustin Hibbits void bm_rcr_finish(struct bm_portal *portal);
1280aeed3e9SJustin Hibbits 
1290aeed3e9SJustin Hibbits /* Start/abort RCR entry */
1300aeed3e9SJustin Hibbits struct bm_rcr_entry *bm_rcr_start(struct bm_portal *portal);
1310aeed3e9SJustin Hibbits void bm_rcr_abort(struct bm_portal *portal);
1320aeed3e9SJustin Hibbits 
1330aeed3e9SJustin Hibbits /* For PI modes only. This presumes a started but uncommitted RCR entry. If
1340aeed3e9SJustin Hibbits  * there's no more room in the RCR, this function returns NULL. Otherwise it
1350aeed3e9SJustin Hibbits  * returns the next RCR entry and increments an internal PI counter without
1360aeed3e9SJustin Hibbits  * flushing it to h/w. */
1370aeed3e9SJustin Hibbits struct bm_rcr_entry *bm_rcr_pend_and_next(struct bm_portal *portal, uint8_t myverb);
1380aeed3e9SJustin Hibbits 
1390aeed3e9SJustin Hibbits /* Commit RCR entries, including pending ones (aka "write PI") */
1400aeed3e9SJustin Hibbits void bm_rcr_pci_commit(struct bm_portal *portal, uint8_t myverb);
1410aeed3e9SJustin Hibbits void bm_rcr_pce_prefetch(struct bm_portal *portal);
1420aeed3e9SJustin Hibbits void bm_rcr_pce_commit(struct bm_portal *portal, uint8_t myverb);
1430aeed3e9SJustin Hibbits void bm_rcr_pvb_commit(struct bm_portal *portal, uint8_t myverb);
1440aeed3e9SJustin Hibbits 
1450aeed3e9SJustin Hibbits /* Track h/w consumption. Returns non-zero if h/w had consumed previously
1460aeed3e9SJustin Hibbits  * unconsumed RCR entries. */
1470aeed3e9SJustin Hibbits uint8_t bm_rcr_cci_update(struct bm_portal *portal);
1480aeed3e9SJustin Hibbits void bm_rcr_cce_prefetch(struct bm_portal *portal);
1490aeed3e9SJustin Hibbits uint8_t bm_rcr_cce_update(struct bm_portal *portal);
1500aeed3e9SJustin Hibbits /* Returns the number of available RCR entries */
1510aeed3e9SJustin Hibbits uint8_t bm_rcr_get_avail(struct bm_portal *portal);
1520aeed3e9SJustin Hibbits /* Returns the number of unconsumed RCR entries */
1530aeed3e9SJustin Hibbits uint8_t bm_rcr_get_fill(struct bm_portal *portal);
1540aeed3e9SJustin Hibbits 
1550aeed3e9SJustin Hibbits /* Read/write the RCR interrupt threshold */
1560aeed3e9SJustin Hibbits uint8_t bm_rcr_get_ithresh(struct bm_portal *portal);
1570aeed3e9SJustin Hibbits void bm_rcr_set_ithresh(struct bm_portal *portal, uint8_t ithresh);
1580aeed3e9SJustin Hibbits 
1590aeed3e9SJustin Hibbits 
1600aeed3e9SJustin Hibbits /* ------------------------------ */
1610aeed3e9SJustin Hibbits /* --- Management command API --- */
1620aeed3e9SJustin Hibbits 
1630aeed3e9SJustin Hibbits /* Create/destroy */
1640aeed3e9SJustin Hibbits t_Error bm_mc_init(struct bm_portal *portal);
1650aeed3e9SJustin Hibbits void bm_mc_finish(struct bm_portal *portal);
1660aeed3e9SJustin Hibbits 
1670aeed3e9SJustin Hibbits /* Start/abort mgmt command */
1680aeed3e9SJustin Hibbits struct bm_mc_command *bm_mc_start(struct bm_portal *portal);
1690aeed3e9SJustin Hibbits void bm_mc_abort(struct bm_portal *portal);
1700aeed3e9SJustin Hibbits 
1710aeed3e9SJustin Hibbits /* Writes 'verb' with appropriate 'vbit'. Invalidates and pre-fetches the
1720aeed3e9SJustin Hibbits  * response. */
1730aeed3e9SJustin Hibbits void bm_mc_commit(struct bm_portal *portal, uint8_t myverb);
1740aeed3e9SJustin Hibbits 
1750aeed3e9SJustin Hibbits /* Poll for result. If NULL, invalidates and prefetches for the next call. */
1760aeed3e9SJustin Hibbits struct bm_mc_result *bm_mc_result(struct bm_portal *portal);
1770aeed3e9SJustin Hibbits 
1780aeed3e9SJustin Hibbits 
1790aeed3e9SJustin Hibbits /* ------------------------------------- */
1800aeed3e9SJustin Hibbits /* --- Portal interrupt register API --- */
1810aeed3e9SJustin Hibbits 
1820aeed3e9SJustin Hibbits /* For a quick explanation of the Bman interrupt model, see the comments in the
1830aeed3e9SJustin Hibbits  * equivalent section of the qman_portal.h header.
1840aeed3e9SJustin Hibbits  */
1850aeed3e9SJustin Hibbits 
1860aeed3e9SJustin Hibbits /* Create/destroy */
1870aeed3e9SJustin Hibbits t_Error bm_isr_init(struct bm_portal *portal);
1880aeed3e9SJustin Hibbits void bm_isr_finish(struct bm_portal *portal);
1890aeed3e9SJustin Hibbits 
1900aeed3e9SJustin Hibbits /* BSCN masking is a per-portal configuration */
1910aeed3e9SJustin Hibbits void bm_isr_bscn_mask(struct bm_portal *portal, uint8_t bpid, int enable);
1920aeed3e9SJustin Hibbits 
1930aeed3e9SJustin Hibbits /* Used by all portal interrupt registers except 'inhibit' */
1940aeed3e9SJustin Hibbits #define BM_PIRQ_RCRI    0x00000002    /* RCR Ring (below threshold) */
1950aeed3e9SJustin Hibbits #define BM_PIRQ_BSCN    0x00000001    /* Buffer depletion State Change */
1960aeed3e9SJustin Hibbits 
1970aeed3e9SJustin Hibbits /* These are bm_<reg>_<verb>(). So for example, bm_disable_write() means "write
1980aeed3e9SJustin Hibbits  * the disable register" rather than "disable the ability to write". */
1990aeed3e9SJustin Hibbits #define bm_isr_status_read(bm)      __bm_isr_read(bm, bm_isr_status)
2000aeed3e9SJustin Hibbits #define bm_isr_status_clear(bm, m)  __bm_isr_write(bm, bm_isr_status, m)
2010aeed3e9SJustin Hibbits #define bm_isr_enable_read(bm)      __bm_isr_read(bm, bm_isr_enable)
2020aeed3e9SJustin Hibbits #define bm_isr_enable_write(bm, v)  __bm_isr_write(bm, bm_isr_enable, v)
2030aeed3e9SJustin Hibbits #define bm_isr_disable_read(bm)     __bm_isr_read(bm, bm_isr_disable)
2040aeed3e9SJustin Hibbits #define bm_isr_disable_write(bm, v) __bm_isr_write(bm, bm_isr_disable, v)
2050aeed3e9SJustin Hibbits #define bm_isr_inhibit(bm)          __bm_isr_write(bm, bm_isr_inhibit, 1)
2060aeed3e9SJustin Hibbits #define bm_isr_uninhibit(bm)        __bm_isr_write(bm, bm_isr_inhibit, 0)
2070aeed3e9SJustin Hibbits 
2080aeed3e9SJustin Hibbits /* Don't use these, use the wrappers above*/
2090aeed3e9SJustin Hibbits uint32_t __bm_isr_read(struct bm_portal *portal, enum bm_isr_reg n);
2100aeed3e9SJustin Hibbits void __bm_isr_write(struct bm_portal *portal, enum bm_isr_reg n, uint32_t val);
2110aeed3e9SJustin Hibbits 
2120aeed3e9SJustin Hibbits /* ------------------------------------------------------- */
2130aeed3e9SJustin Hibbits /* --- Bman data structures (and associated constants) --- */
2140aeed3e9SJustin Hibbits /* Code-reduction, define a wrapper for 48-bit buffers. In cases where a buffer
2150aeed3e9SJustin Hibbits  * pool id specific to this buffer is needed (BM_RCR_VERB_CMD_BPID_MULTI,
2160aeed3e9SJustin Hibbits  * BM_MCC_VERB_ACQUIRE), the 'bpid' field is used. */
2170aeed3e9SJustin Hibbits 
2180aeed3e9SJustin Hibbits #define BM_RCR_VERB_VBIT                0x80
2190aeed3e9SJustin Hibbits #define BM_RCR_VERB_CMD_MASK            0x70    /* one of two values; */
2200aeed3e9SJustin Hibbits #define BM_RCR_VERB_CMD_BPID_SINGLE     0x20
2210aeed3e9SJustin Hibbits #define BM_RCR_VERB_CMD_BPID_MULTI      0x30
2220aeed3e9SJustin Hibbits #define BM_RCR_VERB_BUFCOUNT_MASK       0x0f    /* values 1..8 */
2230aeed3e9SJustin Hibbits 
2240aeed3e9SJustin Hibbits #define BM_MCC_VERB_VBIT                0x80
2250aeed3e9SJustin Hibbits #define BM_MCC_VERB_CMD_MASK            0x70    /* where the verb contains; */
2260aeed3e9SJustin Hibbits #define BM_MCC_VERB_CMD_ACQUIRE         0x10
2270aeed3e9SJustin Hibbits #define BM_MCC_VERB_CMD_QUERY           0x40
2280aeed3e9SJustin Hibbits #define BM_MCC_VERB_ACQUIRE_BUFCOUNT    0x0f    /* values 1..8 go here */
2290aeed3e9SJustin Hibbits 
2300aeed3e9SJustin Hibbits 
2310aeed3e9SJustin Hibbits #if defined(__MWERKS__) && !defined(__GNUC__)
2320aeed3e9SJustin Hibbits #pragma pack(push,1)
2330aeed3e9SJustin Hibbits #endif /* defined(__MWERKS__) && ... */
2340aeed3e9SJustin Hibbits #define MEM_MAP_START
2350aeed3e9SJustin Hibbits 
2360aeed3e9SJustin Hibbits _Packed struct bm_buffer {
2370aeed3e9SJustin Hibbits     volatile uint8_t reserved1;
2380aeed3e9SJustin Hibbits     volatile uint8_t bpid;
2390aeed3e9SJustin Hibbits     volatile uint16_t hi;    /* High 16-bits of 48-bit address */
2400aeed3e9SJustin Hibbits     volatile uint32_t lo;    /* Low 32-bits of 48-bit address */
2410aeed3e9SJustin Hibbits } _PackedType;
2420aeed3e9SJustin Hibbits 
2430aeed3e9SJustin Hibbits /* See 1.5.3.5.4: "Release Command" */
2440aeed3e9SJustin Hibbits _Packed struct bm_rcr_entry {
2450aeed3e9SJustin Hibbits     _Packed union {
2460aeed3e9SJustin Hibbits         _Packed struct {
2470aeed3e9SJustin Hibbits             volatile uint8_t __dont_write_directly__verb;
2480aeed3e9SJustin Hibbits             volatile uint8_t bpid; /* used with BM_RCR_VERB_CMD_BPID_SINGLE */
2490aeed3e9SJustin Hibbits             volatile uint8_t reserved1[62];
2500aeed3e9SJustin Hibbits         } _PackedType;
2510aeed3e9SJustin Hibbits         volatile struct bm_buffer bufs[8];
2520aeed3e9SJustin Hibbits     } _PackedType;
2530aeed3e9SJustin Hibbits } _PackedType;
2540aeed3e9SJustin Hibbits 
2550aeed3e9SJustin Hibbits /* See 1.5.3.1: "Acquire Command" */
2560aeed3e9SJustin Hibbits /* See 1.5.3.2: "Query Command" */
2570aeed3e9SJustin Hibbits _Packed struct bm_mc_command {
2580aeed3e9SJustin Hibbits     volatile uint8_t __dont_write_directly__verb;
2590aeed3e9SJustin Hibbits     _Packed union {
2600aeed3e9SJustin Hibbits         _Packed struct bm_mcc_acquire {
2610aeed3e9SJustin Hibbits             volatile uint8_t bpid;
2620aeed3e9SJustin Hibbits             volatile uint8_t reserved1[62];
2630aeed3e9SJustin Hibbits         } _PackedType acquire;
2640aeed3e9SJustin Hibbits         _Packed struct bm_mcc_query {
2650aeed3e9SJustin Hibbits             volatile uint8_t reserved1[63];
2660aeed3e9SJustin Hibbits         } _PackedType query;
2670aeed3e9SJustin Hibbits     } _PackedType;
2680aeed3e9SJustin Hibbits } _PackedType;
2690aeed3e9SJustin Hibbits 
2700aeed3e9SJustin Hibbits /* See 1.5.3.3: "Acquire Reponse" */
2710aeed3e9SJustin Hibbits /* See 1.5.3.4: "Query Reponse" */
2720aeed3e9SJustin Hibbits _Packed struct bm_mc_result {
2730aeed3e9SJustin Hibbits     _Packed union {
2740aeed3e9SJustin Hibbits         _Packed struct {
2750aeed3e9SJustin Hibbits             volatile uint8_t verb;
2760aeed3e9SJustin Hibbits             volatile uint8_t reserved1[63];
2770aeed3e9SJustin Hibbits         } _PackedType;
2780aeed3e9SJustin Hibbits         _Packed union {
2790aeed3e9SJustin Hibbits             _Packed struct {
2800aeed3e9SJustin Hibbits                 volatile uint8_t reserved1;
2810aeed3e9SJustin Hibbits                 volatile uint8_t bpid;
2820aeed3e9SJustin Hibbits                 volatile uint8_t reserved2[62];
2830aeed3e9SJustin Hibbits             } _PackedType;
2840aeed3e9SJustin Hibbits             volatile struct bm_buffer bufs[8];
2850aeed3e9SJustin Hibbits         } _PackedType acquire;
2860aeed3e9SJustin Hibbits         _Packed struct {
2870aeed3e9SJustin Hibbits             volatile uint8_t reserved1[32];
2880aeed3e9SJustin Hibbits             /* "availability state" and "depletion state" */
2890aeed3e9SJustin Hibbits             _Packed struct {
2900aeed3e9SJustin Hibbits                 volatile uint8_t reserved1[8];
2910aeed3e9SJustin Hibbits                 /* Access using bman_depletion_***() */
2920aeed3e9SJustin Hibbits                 volatile struct bman_depletion state;
2930aeed3e9SJustin Hibbits             } _PackedType as, ds;
2940aeed3e9SJustin Hibbits         } _PackedType query;
2950aeed3e9SJustin Hibbits     } _PackedType;
2960aeed3e9SJustin Hibbits } _PackedType;
2970aeed3e9SJustin Hibbits 
2980aeed3e9SJustin Hibbits #define MEM_MAP_END
2990aeed3e9SJustin Hibbits #if defined(__MWERKS__) && !defined(__GNUC__)
3000aeed3e9SJustin Hibbits #pragma pack(pop)
3010aeed3e9SJustin Hibbits #endif /* defined(__MWERKS__) && ... */
3020aeed3e9SJustin Hibbits 
3030aeed3e9SJustin Hibbits 
3040aeed3e9SJustin Hibbits #define BM_MCR_VERB_VBIT                0x80
3050aeed3e9SJustin Hibbits #define BM_MCR_VERB_CMD_MASK            BM_MCC_VERB_CMD_MASK
3060aeed3e9SJustin Hibbits #define BM_MCR_VERB_CMD_ACQUIRE         BM_MCC_VERB_CMD_ACQUIRE
3070aeed3e9SJustin Hibbits #define BM_MCR_VERB_CMD_QUERY           BM_MCC_VERB_CMD_QUERY
3080aeed3e9SJustin Hibbits #define BM_MCR_VERB_CMD_ERR_INVALID     0x60
3090aeed3e9SJustin Hibbits #define BM_MCR_VERB_CMD_ERR_ECC         0x70
3100aeed3e9SJustin Hibbits #define BM_MCR_VERB_ACQUIRE_BUFCOUNT    BM_MCC_VERB_ACQUIRE_BUFCOUNT /* 0..8 */
3110aeed3e9SJustin Hibbits /* Determine the "availability state" of pool 'p' from a query result 'r' */
3120aeed3e9SJustin Hibbits #define BM_MCR_QUERY_AVAILABILITY(r,p) bman_depletion_get(&r->query.as.state,p)
3130aeed3e9SJustin Hibbits /* Determine the "depletion state" of pool 'p' from a query result 'r' */
3140aeed3e9SJustin Hibbits #define BM_MCR_QUERY_DEPLETION(r,p) bman_depletion_get(&r->query.ds.state,p)
3150aeed3e9SJustin Hibbits 
3160aeed3e9SJustin Hibbits 
3170aeed3e9SJustin Hibbits /* Portal and Buffer Pools */
3180aeed3e9SJustin Hibbits /* ----------------------- */
3190aeed3e9SJustin Hibbits 
3200aeed3e9SJustin Hibbits /* Flags to bman_create_portal() */
3210aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_IRQ         0x00000001 /* use interrupt handler */
3220aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_IRQ_FAST    0x00000002 /* ... for fast-path too! */
3230aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_COMPACT     0x00000004 /* use compaction algorithm */
3240aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_RECOVER     0x00000008 /* recovery mode */
3250aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_WAIT        0x00000010 /* wait if RCR is full */
3260aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_WAIT_INT    0x00000020 /* if wait, interruptible? */
3270aeed3e9SJustin Hibbits #define BMAN_PORTAL_FLAG_CACHE       0x00000400 /* use cache-able area for rings */
3280aeed3e9SJustin Hibbits 
3290aeed3e9SJustin Hibbits /* Flags to bman_new_pool() */
3300aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_NO_RELEASE    0x00000001 /* can't release to pool */
3310aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_ONLY_RELEASE  0x00000002 /* can only release to pool */
3320aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_DEPLETION     0x00000004 /* track depletion entry/exit */
3330aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_DYNAMIC_BPID  0x00000008 /* (de)allocate bpid */
3340aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_THRESH        0x00000010 /* set depletion thresholds */
3350aeed3e9SJustin Hibbits #define BMAN_POOL_FLAG_STOCKPILE     0x00000020 /* stockpile to reduce hw ops */
3360aeed3e9SJustin Hibbits 
3370aeed3e9SJustin Hibbits /* Flags to bman_release() */
3380aeed3e9SJustin Hibbits #define BMAN_RELEASE_FLAG_WAIT       0x00000001 /* wait if RCR is full */
3390aeed3e9SJustin Hibbits #define BMAN_RELEASE_FLAG_WAIT_INT   0x00000002 /* if we wait, interruptible? */
3400aeed3e9SJustin Hibbits #define BMAN_RELEASE_FLAG_WAIT_SYNC  0x00000004 /* if wait, until consumed? */
3410aeed3e9SJustin Hibbits #define BMAN_RELEASE_FLAG_NOW        0x00000008 /* issue immediate release */
3420aeed3e9SJustin Hibbits 
3430aeed3e9SJustin Hibbits /* Flags to bman_acquire() */
3440aeed3e9SJustin Hibbits #define BMAN_ACQUIRE_FLAG_STOCKPILE  0x00000001 /* no hw op, stockpile only */
3450aeed3e9SJustin Hibbits 
3460aeed3e9SJustin Hibbits 
3470aeed3e9SJustin Hibbits #endif /* __FSL_BMAN_H */
348