![]() |
|
|||
0001 /* Copyright 2008 - 2016 Freescale Semiconductor, Inc. 0002 * 0003 * Redistribution and use in source and binary forms, with or without 0004 * modification, are permitted provided that the following conditions are met: 0005 * * Redistributions of source code must retain the above copyright 0006 * notice, this list of conditions and the following disclaimer. 0007 * * Redistributions in binary form must reproduce the above copyright 0008 * notice, this list of conditions and the following disclaimer in the 0009 * documentation and/or other materials provided with the distribution. 0010 * * Neither the name of Freescale Semiconductor nor the 0011 * names of its contributors may be used to endorse or promote products 0012 * derived from this software without specific prior written permission. 0013 * 0014 * ALTERNATIVELY, this software may be distributed under the terms of the 0015 * GNU General Public License ("GPL") as published by the Free Software 0016 * Foundation, either version 2 of that License or (at your option) any 0017 * later version. 0018 * 0019 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY 0020 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 0021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 0022 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY 0023 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 0024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 0025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 0026 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 0028 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0029 */ 0030 0031 #ifndef __FSL_BMAN_H 0032 #define __FSL_BMAN_H 0033 0034 /* wrapper for 48-bit buffers */ 0035 struct bm_buffer { 0036 union { 0037 struct { 0038 __be16 bpid; /* hi 8-bits reserved */ 0039 __be16 hi; /* High 16-bits of 48-bit address */ 0040 __be32 lo; /* Low 32-bits of 48-bit address */ 0041 }; 0042 __be64 data; 0043 }; 0044 } __aligned(8); 0045 /* 0046 * Restore the 48 bit address previously stored in BMan 0047 * hardware pools as a dma_addr_t 0048 */ 0049 static inline dma_addr_t bm_buf_addr(const struct bm_buffer *buf) 0050 { 0051 return be64_to_cpu(buf->data) & 0xffffffffffffLLU; 0052 } 0053 0054 static inline u64 bm_buffer_get64(const struct bm_buffer *buf) 0055 { 0056 return be64_to_cpu(buf->data) & 0xffffffffffffLLU; 0057 } 0058 0059 static inline void bm_buffer_set64(struct bm_buffer *buf, u64 addr) 0060 { 0061 buf->hi = cpu_to_be16(upper_32_bits(addr)); 0062 buf->lo = cpu_to_be32(lower_32_bits(addr)); 0063 } 0064 0065 static inline u8 bm_buffer_get_bpid(const struct bm_buffer *buf) 0066 { 0067 return be16_to_cpu(buf->bpid) & 0xff; 0068 } 0069 0070 static inline void bm_buffer_set_bpid(struct bm_buffer *buf, int bpid) 0071 { 0072 buf->bpid = cpu_to_be16(bpid & 0xff); 0073 } 0074 0075 /* Managed portal, high-level i/face */ 0076 0077 /* Portal and Buffer Pools */ 0078 struct bman_portal; 0079 struct bman_pool; 0080 0081 #define BM_POOL_MAX 64 /* max # of buffer pools */ 0082 0083 /** 0084 * bman_new_pool - Allocates a Buffer Pool object 0085 * 0086 * Creates a pool object, and returns a reference to it or NULL on error. 0087 */ 0088 struct bman_pool *bman_new_pool(void); 0089 0090 /** 0091 * bman_free_pool - Deallocates a Buffer Pool object 0092 * @pool: the pool object to release 0093 */ 0094 void bman_free_pool(struct bman_pool *pool); 0095 0096 /** 0097 * bman_get_bpid - Returns a pool object's BPID. 0098 * @pool: the pool object 0099 * 0100 * The returned value is the index of the encapsulated buffer pool, 0101 * in the range of [0, @BM_POOL_MAX-1]. 0102 */ 0103 int bman_get_bpid(const struct bman_pool *pool); 0104 0105 /** 0106 * bman_release - Release buffer(s) to the buffer pool 0107 * @pool: the buffer pool object to release to 0108 * @bufs: an array of buffers to release 0109 * @num: the number of buffers in @bufs (1-8) 0110 * 0111 * Adds the given buffers to RCR entries. If the RCR ring is unresponsive, 0112 * the function will return -ETIMEDOUT. Otherwise, it returns zero. 0113 */ 0114 int bman_release(struct bman_pool *pool, const struct bm_buffer *bufs, u8 num); 0115 0116 /** 0117 * bman_acquire - Acquire buffer(s) from a buffer pool 0118 * @pool: the buffer pool object to acquire from 0119 * @bufs: array for storing the acquired buffers 0120 * @num: the number of buffers desired (@bufs is at least this big) 0121 * 0122 * Issues an "Acquire" command via the portal's management command interface. 0123 * The return value will be the number of buffers obtained from the pool, or a 0124 * negative error code if a h/w error or pool starvation was encountered. In 0125 * the latter case, the content of @bufs is undefined. 0126 */ 0127 int bman_acquire(struct bman_pool *pool, struct bm_buffer *bufs, u8 num); 0128 0129 /** 0130 * bman_is_probed - Check if bman is probed 0131 * 0132 * Returns 1 if the bman driver successfully probed, -1 if the bman driver 0133 * failed to probe or 0 if the bman driver did not probed yet. 0134 */ 0135 int bman_is_probed(void); 0136 /** 0137 * bman_portals_probed - Check if all cpu bound bman portals are probed 0138 * 0139 * Returns 1 if all the required cpu bound bman portals successfully probed, 0140 * -1 if probe errors appeared or 0 if the bman portals did not yet finished 0141 * probing. 0142 */ 0143 int bman_portals_probed(void); 0144 0145 #endif /* __FSL_BMAN_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |