New upstream version 18.11-rc1
[deb_dpdk.git] / drivers / mempool / dpaa / dpaa_mempool.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  *   Copyright 2017 NXP
4  *
5  */
6 #ifndef __DPAA_MEMPOOL_H__
7 #define __DPAA_MEMPOOL_H__
8
9 /* System headers */
10 #include <stdio.h>
11 #include <stdbool.h>
12 #include <inttypes.h>
13 #include <unistd.h>
14
15 #include <rte_mempool.h>
16
17 #include <rte_dpaa_bus.h>
18 #include <rte_dpaa_logs.h>
19
20 #include <fsl_usd.h>
21 #include <fsl_bman.h>
22
23 #define CPU_SPIN_BACKOFF_CYCLES               512
24
25 /* total number of bpools on SoC */
26 #define DPAA_MAX_BPOOLS 256
27
28 /* Maximum release/acquire from BMAN */
29 #define DPAA_MBUF_MAX_ACQ_REL  8
30
31 /* Buffers are allocated from single mem segment i.e. phys contiguous */
32 #define DPAA_MPOOL_SINGLE_SEGMENT  0x01
33
34 struct dpaa_bp_info {
35         struct rte_mempool *mp;
36         struct bman_pool *bp;
37         uint32_t bpid;
38         uint32_t size;
39         uint32_t meta_data_size;
40         int32_t dpaa_ops_index;
41         int64_t ptov_off;
42         uint8_t flags;
43 };
44
45 static inline void *
46 DPAA_MEMPOOL_PTOV(struct dpaa_bp_info *bp_info __rte_unused, uint64_t addr)
47 {
48         return rte_dpaa_mem_ptov(addr);
49 }
50
51 #define DPAA_MEMPOOL_TO_POOL_INFO(__mp) \
52         ((struct dpaa_bp_info *)__mp->pool_data)
53
54 #define DPAA_MEMPOOL_TO_BPID(__mp) \
55         (((struct dpaa_bp_info *)__mp->pool_data)->bpid)
56
57 extern struct dpaa_bp_info rte_dpaa_bpid_info[DPAA_MAX_BPOOLS];
58
59 #define DPAA_BPID_TO_POOL_INFO(__bpid) (&rte_dpaa_bpid_info[__bpid])
60
61 #endif