net/mlx5: remove redundant flag in device config
[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_CN98xx_A0    BIT_ULL(16)
23 #define ROC_MODEL_CN106xx_A0   BIT_ULL(20)
24 #define ROC_MODEL_CNF105xx_A0  BIT_ULL(21)
25 #define ROC_MODEL_CNF105xxN_A0 BIT_ULL(22)
26 /* Following flags describe platform code is running on */
27 #define ROC_ENV_HW   BIT_ULL(61)
28 #define ROC_ENV_EMUL BIT_ULL(62)
29 #define ROC_ENV_ASIM BIT_ULL(63)
30
31         uint64_t flag;
32 #define ROC_MODEL_STR_LEN_MAX 128
33         char name[ROC_MODEL_STR_LEN_MAX];
34         char env[ROC_MODEL_STR_LEN_MAX];
35 } __plt_cache_aligned;
36
37 #define ROC_MODEL_CN96xx_Ax (ROC_MODEL_CN96xx_A0 | ROC_MODEL_CN96xx_B0)
38 #define ROC_MODEL_CN9K                                                         \
39         (ROC_MODEL_CN96xx_Ax | ROC_MODEL_CN96xx_C0 | ROC_MODEL_CNF95xx_A0 |    \
40          ROC_MODEL_CNF95xx_B0 | ROC_MODEL_CNF95xxMM_A0 |                       \
41          ROC_MODEL_CNF95xxO_A0 | ROC_MODEL_CNF95xxN_A0 | ROC_MODEL_CN98xx_A0 | \
42          ROC_MODEL_CNF95xxN_A1)
43
44 #define ROC_MODEL_CN106xx   (ROC_MODEL_CN106xx_A0)
45 #define ROC_MODEL_CNF105xx  (ROC_MODEL_CNF105xx_A0)
46 #define ROC_MODEL_CNF105xxN (ROC_MODEL_CNF105xxN_A0)
47 #define ROC_MODEL_CN10K                                                        \
48         (ROC_MODEL_CN106xx | ROC_MODEL_CNF105xx | ROC_MODEL_CNF105xxN)
49
50 /* Runtime variants */
51 static inline uint64_t
52 roc_model_runtime_is_cn9k(void)
53 {
54         return (roc_model->flag & (ROC_MODEL_CN9K));
55 }
56
57 static inline uint64_t
58 roc_model_runtime_is_cn10k(void)
59 {
60         return (roc_model->flag & (ROC_MODEL_CN10K));
61 }
62
63 /* Compile time variants */
64 #ifdef ROC_PLATFORM_CN9K
65 #define roc_model_constant_is_cn9k()  1
66 #define roc_model_constant_is_cn10k() 0
67 #else
68 #define roc_model_constant_is_cn9k()  0
69 #define roc_model_constant_is_cn10k() 1
70 #endif
71
72 /*
73  * Compile time variants to enable optimized version check when the library
74  * configured for specific platform version else to fallback to runtime.
75  */
76 static inline uint64_t
77 roc_model_is_cn9k(void)
78 {
79 #ifdef ROC_PLATFORM_CN9K
80         return 1;
81 #endif
82 #ifdef ROC_PLATFORM_CN10K
83         return 0;
84 #endif
85         return roc_model_runtime_is_cn9k();
86 }
87
88 static inline uint64_t
89 roc_model_is_cn10k(void)
90 {
91 #ifdef ROC_PLATFORM_CN10K
92         return 1;
93 #endif
94 #ifdef ROC_PLATFORM_CN9K
95         return 0;
96 #endif
97         return roc_model_runtime_is_cn10k();
98 }
99
100 static inline uint64_t
101 roc_model_is_cn98xx(void)
102 {
103         return (roc_model->flag & ROC_MODEL_CN98xx_A0);
104 }
105
106 static inline uint64_t
107 roc_model_is_cn96_a0(void)
108 {
109         return roc_model->flag & ROC_MODEL_CN96xx_A0;
110 }
111
112 static inline uint64_t
113 roc_model_is_cn96_ax(void)
114 {
115         return (roc_model->flag & ROC_MODEL_CN96xx_Ax);
116 }
117
118 static inline uint64_t
119 roc_model_is_cn96_cx(void)
120 {
121         return (roc_model->flag & ROC_MODEL_CN96xx_C0);
122 }
123
124 static inline uint64_t
125 roc_model_is_cn95_a0(void)
126 {
127         return roc_model->flag & ROC_MODEL_CNF95xx_A0;
128 }
129
130 static inline uint64_t
131 roc_model_is_cn10ka(void)
132 {
133         return roc_model->flag & ROC_MODEL_CN106xx;
134 }
135
136 static inline uint64_t
137 roc_model_is_cnf10ka(void)
138 {
139         return roc_model->flag & ROC_MODEL_CNF105xx;
140 }
141
142 static inline uint64_t
143 roc_model_is_cnf10kb(void)
144 {
145         return roc_model->flag & ROC_MODEL_CNF105xxN;
146 }
147
148 static inline uint64_t
149 roc_model_is_cn10ka_a0(void)
150 {
151         return roc_model->flag & ROC_MODEL_CN106xx_A0;
152 }
153
154 static inline uint64_t
155 roc_model_is_cnf10ka_a0(void)
156 {
157         return roc_model->flag & ROC_MODEL_CNF105xx_A0;
158 }
159
160 static inline uint64_t
161 roc_model_is_cnf10kb_a0(void)
162 {
163         return roc_model->flag & ROC_MODEL_CNF105xxN_A0;
164 }
165
166 static inline bool
167 roc_env_is_hw(void)
168 {
169         return roc_model->flag & ROC_ENV_HW;
170 }
171
172 static inline bool
173 roc_env_is_emulator(void)
174 {
175         return roc_model->flag & ROC_ENV_EMUL;
176 }
177
178 static inline bool
179 roc_env_is_asim(void)
180 {
181         return roc_model->flag & ROC_ENV_ASIM;
182 }
183
184 static inline const char *
185 roc_env_get(void)
186 {
187         return roc_model->env;
188 }
189
190 int roc_model_init(struct roc_model *model);
191
192 #endif