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_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)
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;
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 #define ROC_MODEL_CNF9K \
44 (ROC_MODEL_CNF95xx_A0 | ROC_MODEL_CNF95xx_B0 | \
45 ROC_MODEL_CNF95xxMM_A0 | ROC_MODEL_CNF95xxO_A0 | \
46 ROC_MODEL_CNF95xxN_A0 | ROC_MODEL_CNF95xxN_A1)
48 #define ROC_MODEL_CN106xx (ROC_MODEL_CN106xx_A0)
49 #define ROC_MODEL_CNF105xx (ROC_MODEL_CNF105xx_A0)
50 #define ROC_MODEL_CNF105xxN (ROC_MODEL_CNF105xxN_A0)
51 #define ROC_MODEL_CN10K \
52 (ROC_MODEL_CN106xx | ROC_MODEL_CNF105xx | ROC_MODEL_CNF105xxN)
53 #define ROC_MODEL_CNF10K (ROC_MODEL_CNF105xx | ROC_MODEL_CNF105xxN)
55 /* Runtime variants */
56 static inline uint64_t
57 roc_model_runtime_is_cn9k(void)
59 return (roc_model->flag & (ROC_MODEL_CN9K));
62 static inline uint64_t
63 roc_model_runtime_is_cn10k(void)
65 return (roc_model->flag & (ROC_MODEL_CN10K));
68 /* Compile time variants */
69 #ifdef ROC_PLATFORM_CN9K
70 #define roc_model_constant_is_cn9k() 1
71 #define roc_model_constant_is_cn10k() 0
73 #define roc_model_constant_is_cn9k() 0
74 #define roc_model_constant_is_cn10k() 1
78 * Compile time variants to enable optimized version check when the library
79 * configured for specific platform version else to fallback to runtime.
81 static inline uint64_t
82 roc_model_is_cn9k(void)
84 #ifdef ROC_PLATFORM_CN9K
87 #ifdef ROC_PLATFORM_CN10K
90 return roc_model_runtime_is_cn9k();
93 static inline uint64_t
94 roc_model_is_cn10k(void)
96 #ifdef ROC_PLATFORM_CN10K
99 #ifdef ROC_PLATFORM_CN9K
102 return roc_model_runtime_is_cn10k();
105 static inline uint64_t
106 roc_model_is_cn98xx(void)
108 return (roc_model->flag & ROC_MODEL_CN98xx_A0);
111 static inline uint64_t
112 roc_model_is_cn96_a0(void)
114 return roc_model->flag & ROC_MODEL_CN96xx_A0;
117 static inline uint64_t
118 roc_model_is_cn96_ax(void)
120 return (roc_model->flag & ROC_MODEL_CN96xx_Ax);
123 static inline uint64_t
124 roc_model_is_cn96_cx(void)
126 return (roc_model->flag & ROC_MODEL_CN96xx_C0);
129 static inline uint64_t
130 roc_model_is_cn95_a0(void)
132 return roc_model->flag & ROC_MODEL_CNF95xx_A0;
135 static inline uint64_t
136 roc_model_is_cn10ka(void)
138 return roc_model->flag & ROC_MODEL_CN106xx;
141 static inline uint64_t
142 roc_model_is_cnf10ka(void)
144 return roc_model->flag & ROC_MODEL_CNF105xx;
147 static inline uint64_t
148 roc_model_is_cnf10kb(void)
150 return roc_model->flag & ROC_MODEL_CNF105xxN;
153 static inline uint64_t
154 roc_model_is_cn10ka_a0(void)
156 return roc_model->flag & ROC_MODEL_CN106xx_A0;
159 static inline uint64_t
160 roc_model_is_cnf10ka_a0(void)
162 return roc_model->flag & ROC_MODEL_CNF105xx_A0;
165 static inline uint64_t
166 roc_model_is_cnf10kb_a0(void)
168 return roc_model->flag & ROC_MODEL_CNF105xxN_A0;
174 return roc_model->flag & ROC_ENV_HW;
178 roc_env_is_emulator(void)
180 return roc_model->flag & ROC_ENV_EMUL;
184 roc_env_is_asim(void)
186 return roc_model->flag & ROC_ENV_ASIM;
189 static inline const char *
192 return roc_model->env;
195 int roc_model_init(struct roc_model *model);