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)
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)
50 /* Runtime variants */
51 static inline uint64_t
52 roc_model_runtime_is_cn9k(void)
54 return (roc_model->flag & (ROC_MODEL_CN9K));
57 static inline uint64_t
58 roc_model_runtime_is_cn10k(void)
60 return (roc_model->flag & (ROC_MODEL_CN10K));
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
68 #define roc_model_constant_is_cn9k() 0
69 #define roc_model_constant_is_cn10k() 1
73 * Compile time variants to enable optimized version check when the library
74 * configured for specific platform version else to fallback to runtime.
76 static inline uint64_t
77 roc_model_is_cn9k(void)
79 #ifdef ROC_PLATFORM_CN9K
82 #ifdef ROC_PLATFORM_CN10K
85 return roc_model_runtime_is_cn9k();
88 static inline uint64_t
89 roc_model_is_cn10k(void)
91 #ifdef ROC_PLATFORM_CN10K
94 #ifdef ROC_PLATFORM_CN9K
97 return roc_model_runtime_is_cn10k();
100 static inline uint64_t
101 roc_model_is_cn98xx(void)
103 return (roc_model->flag & ROC_MODEL_CN98xx_A0);
106 static inline uint64_t
107 roc_model_is_cn96_a0(void)
109 return roc_model->flag & ROC_MODEL_CN96xx_A0;
112 static inline uint64_t
113 roc_model_is_cn96_ax(void)
115 return (roc_model->flag & ROC_MODEL_CN96xx_Ax);
118 static inline uint64_t
119 roc_model_is_cn96_cx(void)
121 return (roc_model->flag & ROC_MODEL_CN96xx_C0);
124 static inline uint64_t
125 roc_model_is_cn95_a0(void)
127 return roc_model->flag & ROC_MODEL_CNF95xx_A0;
130 static inline uint64_t
131 roc_model_is_cn10ka(void)
133 return roc_model->flag & ROC_MODEL_CN106xx;
136 static inline uint64_t
137 roc_model_is_cnf10ka(void)
139 return roc_model->flag & ROC_MODEL_CNF105xx;
142 static inline uint64_t
143 roc_model_is_cnf10kb(void)
145 return roc_model->flag & ROC_MODEL_CNF105xxN;
148 static inline uint64_t
149 roc_model_is_cn10ka_a0(void)
151 return roc_model->flag & ROC_MODEL_CN106xx_A0;
154 static inline uint64_t
155 roc_model_is_cnf10ka_a0(void)
157 return roc_model->flag & ROC_MODEL_CNF105xx_A0;
160 static inline uint64_t
161 roc_model_is_cnf10kb_a0(void)
163 return roc_model->flag & ROC_MODEL_CNF105xxN_A0;
169 return roc_model->flag & ROC_ENV_HW;
173 roc_env_is_emulator(void)
175 return roc_model->flag & ROC_ENV_EMUL;
179 roc_env_is_asim(void)
181 return roc_model->flag & ROC_ENV_ASIM;
184 static inline const char *
187 return roc_model->env;
190 int roc_model_init(struct roc_model *model);