1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
10 extern struct roc_model *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)
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;
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)
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 | \
58 #define ROC_MODEL_CNF10K (ROC_MODEL_CNF105xx | ROC_MODEL_CNF105xxN)
60 /* Runtime variants */
61 static inline uint64_t
62 roc_model_runtime_is_cn9k(void)
64 return (roc_model->flag & (ROC_MODEL_CN9K));
67 static inline uint64_t
68 roc_model_runtime_is_cn10k(void)
70 return (roc_model->flag & (ROC_MODEL_CN10K));
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
78 #define roc_model_constant_is_cn9k() 0
79 #define roc_model_constant_is_cn10k() 1
83 * Compile time variants to enable optimized version check when the library
84 * configured for specific platform version else to fallback to runtime.
86 static inline uint64_t
87 roc_model_is_cn9k(void)
89 #ifdef ROC_PLATFORM_CN9K
92 #ifdef ROC_PLATFORM_CN10K
95 return roc_model_runtime_is_cn9k();
98 static inline uint64_t
99 roc_model_is_cn10k(void)
101 #ifdef ROC_PLATFORM_CN10K
104 #ifdef ROC_PLATFORM_CN9K
107 return roc_model_runtime_is_cn10k();
110 static inline uint64_t
111 roc_model_is_cn98xx(void)
113 return (roc_model->flag & ROC_MODEL_CN98xx_A0);
116 static inline uint64_t
117 roc_model_is_cn96_a0(void)
119 return roc_model->flag & ROC_MODEL_CN96xx_A0;
122 static inline uint64_t
123 roc_model_is_cn96_ax(void)
125 return (roc_model->flag & ROC_MODEL_CN96xx_Ax);
128 static inline uint64_t
129 roc_model_is_cn96_cx(void)
131 return (roc_model->flag & ROC_MODEL_CN96xx_C0);
134 static inline uint64_t
135 roc_model_is_cn95_a0(void)
137 return roc_model->flag & ROC_MODEL_CNF95xx_A0;
140 static inline uint64_t
141 roc_model_is_cn10ka(void)
143 return roc_model->flag & ROC_MODEL_CN106xx;
146 static inline uint64_t
147 roc_model_is_cnf10ka(void)
149 return roc_model->flag & ROC_MODEL_CNF105xx;
152 static inline uint64_t
153 roc_model_is_cnf10kb(void)
155 return roc_model->flag & ROC_MODEL_CNF105xxN;
158 static inline uint64_t
159 roc_model_is_cn10kb_a0(void)
161 return roc_model->flag & ROC_MODEL_CN103xx_A0;
164 static inline uint64_t
165 roc_model_is_cn10ka_a0(void)
167 return roc_model->flag & ROC_MODEL_CN106xx_A0;
170 static inline uint64_t
171 roc_model_is_cnf10ka_a0(void)
173 return roc_model->flag & ROC_MODEL_CNF105xx_A0;
176 static inline uint64_t
177 roc_model_is_cnf10kb_a0(void)
179 return roc_model->flag & ROC_MODEL_CNF105xxN_A0;
185 return roc_model->flag & ROC_ENV_HW;
189 roc_env_is_emulator(void)
191 return roc_model->flag & ROC_ENV_EMUL;
195 roc_env_is_asim(void)
197 return roc_model->flag & ROC_ENV_ASIM;
200 static inline const char *
203 return roc_model->env;
206 int roc_model_init(struct roc_model *model);