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 /* Following flags describe platform code is running on */
28 #define ROC_ENV_HW BIT_ULL(61)
29 #define ROC_ENV_EMUL BIT_ULL(62)
30 #define ROC_ENV_ASIM BIT_ULL(63)
33 #define ROC_MODEL_STR_LEN_MAX 128
34 char name[ROC_MODEL_STR_LEN_MAX];
35 char env[ROC_MODEL_STR_LEN_MAX];
36 } __plt_cache_aligned;
38 #define ROC_MODEL_CN96xx_Ax (ROC_MODEL_CN96xx_A0 | ROC_MODEL_CN96xx_B0)
39 #define ROC_MODEL_CN9K \
40 (ROC_MODEL_CN96xx_Ax | ROC_MODEL_CN96xx_C0 | ROC_MODEL_CNF95xx_A0 | \
41 ROC_MODEL_CNF95xx_B0 | ROC_MODEL_CNF95xxMM_A0 | \
42 ROC_MODEL_CNF95xxO_A0 | ROC_MODEL_CNF95xxN_A0 | ROC_MODEL_CN98xx_A0 | \
43 ROC_MODEL_CNF95xxN_A1 | ROC_MODEL_CNF95xxN_B0)
44 #define ROC_MODEL_CNF9K \
45 (ROC_MODEL_CNF95xx_A0 | ROC_MODEL_CNF95xx_B0 | \
46 ROC_MODEL_CNF95xxMM_A0 | ROC_MODEL_CNF95xxO_A0 | \
47 ROC_MODEL_CNF95xxN_A0 | ROC_MODEL_CNF95xxN_A1 | \
48 ROC_MODEL_CNF95xxN_B0)
50 #define ROC_MODEL_CN106xx (ROC_MODEL_CN106xx_A0)
51 #define ROC_MODEL_CNF105xx (ROC_MODEL_CNF105xx_A0)
52 #define ROC_MODEL_CNF105xxN (ROC_MODEL_CNF105xxN_A0)
53 #define ROC_MODEL_CN10K \
54 (ROC_MODEL_CN106xx | ROC_MODEL_CNF105xx | ROC_MODEL_CNF105xxN)
55 #define ROC_MODEL_CNF10K (ROC_MODEL_CNF105xx | ROC_MODEL_CNF105xxN)
57 /* Runtime variants */
58 static inline uint64_t
59 roc_model_runtime_is_cn9k(void)
61 return (roc_model->flag & (ROC_MODEL_CN9K));
64 static inline uint64_t
65 roc_model_runtime_is_cn10k(void)
67 return (roc_model->flag & (ROC_MODEL_CN10K));
70 /* Compile time variants */
71 #ifdef ROC_PLATFORM_CN9K
72 #define roc_model_constant_is_cn9k() 1
73 #define roc_model_constant_is_cn10k() 0
75 #define roc_model_constant_is_cn9k() 0
76 #define roc_model_constant_is_cn10k() 1
80 * Compile time variants to enable optimized version check when the library
81 * configured for specific platform version else to fallback to runtime.
83 static inline uint64_t
84 roc_model_is_cn9k(void)
86 #ifdef ROC_PLATFORM_CN9K
89 #ifdef ROC_PLATFORM_CN10K
92 return roc_model_runtime_is_cn9k();
95 static inline uint64_t
96 roc_model_is_cn10k(void)
98 #ifdef ROC_PLATFORM_CN10K
101 #ifdef ROC_PLATFORM_CN9K
104 return roc_model_runtime_is_cn10k();
107 static inline uint64_t
108 roc_model_is_cn98xx(void)
110 return (roc_model->flag & ROC_MODEL_CN98xx_A0);
113 static inline uint64_t
114 roc_model_is_cn96_a0(void)
116 return roc_model->flag & ROC_MODEL_CN96xx_A0;
119 static inline uint64_t
120 roc_model_is_cn96_ax(void)
122 return (roc_model->flag & ROC_MODEL_CN96xx_Ax);
125 static inline uint64_t
126 roc_model_is_cn96_cx(void)
128 return (roc_model->flag & ROC_MODEL_CN96xx_C0);
131 static inline uint64_t
132 roc_model_is_cn95_a0(void)
134 return roc_model->flag & ROC_MODEL_CNF95xx_A0;
137 static inline uint64_t
138 roc_model_is_cn10ka(void)
140 return roc_model->flag & ROC_MODEL_CN106xx;
143 static inline uint64_t
144 roc_model_is_cnf10ka(void)
146 return roc_model->flag & ROC_MODEL_CNF105xx;
149 static inline uint64_t
150 roc_model_is_cnf10kb(void)
152 return roc_model->flag & ROC_MODEL_CNF105xxN;
155 static inline uint64_t
156 roc_model_is_cn10ka_a0(void)
158 return roc_model->flag & ROC_MODEL_CN106xx_A0;
161 static inline uint64_t
162 roc_model_is_cnf10ka_a0(void)
164 return roc_model->flag & ROC_MODEL_CNF105xx_A0;
167 static inline uint64_t
168 roc_model_is_cnf10kb_a0(void)
170 return roc_model->flag & ROC_MODEL_CNF105xxN_A0;
176 return roc_model->flag & ROC_ENV_HW;
180 roc_env_is_emulator(void)
182 return roc_model->flag & ROC_ENV_EMUL;
186 roc_env_is_asim(void)
188 return roc_model->flag & ROC_ENV_ASIM;
191 static inline const char *
194 return roc_model->env;
197 int roc_model_init(struct roc_model *model);