examples/pipeline: fix build
[dpdk.git] / drivers / common / cnxk / roc_model.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #ifndef _ROC_MODEL_H_
6 #define _ROC_MODEL_H_
7
8 #include <stdbool.h>
9
10 extern struct roc_model *roc_model;
11
12 struct roc_model {
13 #define ROC_MODEL_CN96xx_A0    BIT_ULL(0)
14 #define ROC_MODEL_CN96xx_B0    BIT_ULL(1)
15 #define ROC_MODEL_CN96xx_C0    BIT_ULL(2)
16 #define ROC_MODEL_CNF95xx_A0   BIT_ULL(4)
17 #define ROC_MODEL_CNF95xx_B0   BIT_ULL(6)
18 #define ROC_MODEL_CNF95xxMM_A0 BIT_ULL(8)
19 #define ROC_MODEL_CNF95xxN_A0  BIT_ULL(12)
20 #define ROC_MODEL_CNF95xxO_A0  BIT_ULL(13)
21 #define ROC_MODEL_CNF95xxN_A1  BIT_ULL(14)
22 #define ROC_MODEL_CNF95xxN_B0  BIT_ULL(15)
23 #define ROC_MODEL_CN98xx_A0    BIT_ULL(16)
24 #define ROC_MODEL_CN106xx_A0   BIT_ULL(20)
25 #define ROC_MODEL_CNF105xx_A0  BIT_ULL(21)
26 #define ROC_MODEL_CNF105xxN_A0 BIT_ULL(22)
27 #define ROC_MODEL_CN103xx_A0   BIT_ULL(23)
28 /* Following flags describe platform code is running on */
29 #define ROC_ENV_HW   BIT_ULL(61)
30 #define ROC_ENV_EMUL BIT_ULL(62)
31 #define ROC_ENV_ASIM BIT_ULL(63)
32
33         uint64_t flag;
34 #define ROC_MODEL_STR_LEN_MAX 128
35         char name[ROC_MODEL_STR_LEN_MAX];
36         char env[ROC_MODEL_STR_LEN_MAX];
37 } __plt_cache_aligned;
38
39 #define ROC_MODEL_CN96xx_Ax (ROC_MODEL_CN96xx_A0 | ROC_MODEL_CN96xx_B0)
40 #define ROC_MODEL_CN9K                                                         \
41         (ROC_MODEL_CN96xx_Ax | ROC_MODEL_CN96xx_C0 | ROC_MODEL_CNF95xx_A0 |    \
42          ROC_MODEL_CNF95xx_B0 | ROC_MODEL_CNF95xxMM_A0 |                       \
43          ROC_MODEL_CNF95xxO_A0 | ROC_MODEL_CNF95xxN_A0 | ROC_MODEL_CN98xx_A0 | \
44          ROC_MODEL_CNF95xxN_A1 | ROC_MODEL_CNF95xxN_B0)
45 #define ROC_MODEL_CNF9K                                                        \
46         (ROC_MODEL_CNF95xx_A0 | ROC_MODEL_CNF95xx_B0 |                         \
47          ROC_MODEL_CNF95xxMM_A0 | ROC_MODEL_CNF95xxO_A0 |                      \
48          ROC_MODEL_CNF95xxN_A0 | ROC_MODEL_CNF95xxN_A1 |                       \
49          ROC_MODEL_CNF95xxN_B0)
50
51 #define ROC_MODEL_CN106xx   (ROC_MODEL_CN106xx_A0)
52 #define ROC_MODEL_CNF105xx  (ROC_MODEL_CNF105xx_A0)
53 #define ROC_MODEL_CNF105xxN (ROC_MODEL_CNF105xxN_A0)
54 #define ROC_MODEL_CN103xx   (ROC_MODEL_CN103xx_A0)
55 #define ROC_MODEL_CN10K                                                        \
56         (ROC_MODEL_CN106xx | ROC_MODEL_CNF105xx | ROC_MODEL_CNF105xxN |        \
57          ROC_MODEL_CN103xx)
58 #define ROC_MODEL_CNF10K (ROC_MODEL_CNF105xx | ROC_MODEL_CNF105xxN)
59
60 /* Runtime variants */
61 static inline uint64_t
62 roc_model_runtime_is_cn9k(void)
63 {
64         return (roc_model->flag & (ROC_MODEL_CN9K));
65 }
66
67 static inline uint64_t
68 roc_model_runtime_is_cn10k(void)
69 {
70         return (roc_model->flag & (ROC_MODEL_CN10K));
71 }
72
73 /* Compile time variants */
74 #ifdef ROC_PLATFORM_CN9K
75 #define roc_model_constant_is_cn9k()  1
76 #define roc_model_constant_is_cn10k() 0
77 #else
78 #define roc_model_constant_is_cn9k()  0
79 #define roc_model_constant_is_cn10k() 1
80 #endif
81
82 /*
83  * Compile time variants to enable optimized version check when the library
84  * configured for specific platform version else to fallback to runtime.
85  */
86 static inline uint64_t
87 roc_model_is_cn9k(void)
88 {
89 #ifdef ROC_PLATFORM_CN9K
90         return 1;
91 #endif
92 #ifdef ROC_PLATFORM_CN10K
93         return 0;
94 #endif
95         return roc_model_runtime_is_cn9k();
96 }
97
98 static inline uint64_t
99 roc_model_is_cn10k(void)
100 {
101 #ifdef ROC_PLATFORM_CN10K
102         return 1;
103 #endif
104 #ifdef ROC_PLATFORM_CN9K
105         return 0;
106 #endif
107         return roc_model_runtime_is_cn10k();
108 }
109
110 static inline uint64_t
111 roc_model_is_cn98xx(void)
112 {
113         return (roc_model->flag & ROC_MODEL_CN98xx_A0);
114 }
115
116 static inline uint64_t
117 roc_model_is_cn96_a0(void)
118 {
119         return roc_model->flag & ROC_MODEL_CN96xx_A0;
120 }
121
122 static inline uint64_t
123 roc_model_is_cn96_ax(void)
124 {
125         return (roc_model->flag & ROC_MODEL_CN96xx_Ax);
126 }
127
128 static inline uint64_t
129 roc_model_is_cn96_cx(void)
130 {
131         return (roc_model->flag & ROC_MODEL_CN96xx_C0);
132 }
133
134 static inline uint64_t
135 roc_model_is_cn95_a0(void)
136 {
137         return roc_model->flag & ROC_MODEL_CNF95xx_A0;
138 }
139
140 static inline uint64_t
141 roc_model_is_cn10ka(void)
142 {
143         return roc_model->flag & ROC_MODEL_CN106xx;
144 }
145
146 static inline uint64_t
147 roc_model_is_cnf10ka(void)
148 {
149         return roc_model->flag & ROC_MODEL_CNF105xx;
150 }
151
152 static inline uint64_t
153 roc_model_is_cnf10kb(void)
154 {
155         return roc_model->flag & ROC_MODEL_CNF105xxN;
156 }
157
158 static inline uint64_t
159 roc_model_is_cn10kb_a0(void)
160 {
161         return roc_model->flag & ROC_MODEL_CN103xx_A0;
162 }
163
164 static inline uint64_t
165 roc_model_is_cn10ka_a0(void)
166 {
167         return roc_model->flag & ROC_MODEL_CN106xx_A0;
168 }
169
170 static inline uint64_t
171 roc_model_is_cnf10ka_a0(void)
172 {
173         return roc_model->flag & ROC_MODEL_CNF105xx_A0;
174 }
175
176 static inline uint64_t
177 roc_model_is_cnf10kb_a0(void)
178 {
179         return roc_model->flag & ROC_MODEL_CNF105xxN_A0;
180 }
181
182 static inline bool
183 roc_env_is_hw(void)
184 {
185         return roc_model->flag & ROC_ENV_HW;
186 }
187
188 static inline bool
189 roc_env_is_emulator(void)
190 {
191         return roc_model->flag & ROC_ENV_EMUL;
192 }
193
194 static inline bool
195 roc_env_is_asim(void)
196 {
197         return roc_model->flag & ROC_ENV_ASIM;
198 }
199
200 static inline const char *
201 roc_env_get(void)
202 {
203         return roc_model->env;
204 }
205
206 int roc_model_init(struct roc_model *model);
207
208 #endif