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)
28 #define ROC_MODEL_STR_LEN_MAX 128
29 char name[ROC_MODEL_STR_LEN_MAX];
30 } __plt_cache_aligned;
32 #define ROC_MODEL_CN96xx_Ax (ROC_MODEL_CN96xx_A0 | ROC_MODEL_CN96xx_B0)
33 #define ROC_MODEL_CN9K \
34 (ROC_MODEL_CN96xx_Ax | ROC_MODEL_CN96xx_C0 | ROC_MODEL_CNF95xx_A0 | \
35 ROC_MODEL_CNF95xx_B0 | ROC_MODEL_CNF95xxMM_A0 | \
36 ROC_MODEL_CNF95xxO_A0 | ROC_MODEL_CNF95xxN_A0 | ROC_MODEL_CN98xx_A0 | \
37 ROC_MODEL_CNF95xxN_A1)
39 #define ROC_MODEL_CN106xx (ROC_MODEL_CN106xx_A0)
40 #define ROC_MODEL_CNF105xx (ROC_MODEL_CNF105xx_A0)
41 #define ROC_MODEL_CNF105xxN (ROC_MODEL_CNF105xxN_A0)
42 #define ROC_MODEL_CN10K \
43 (ROC_MODEL_CN106xx | ROC_MODEL_CNF105xx | ROC_MODEL_CNF105xxN)
45 /* Runtime variants */
46 static inline uint64_t
47 roc_model_runtime_is_cn9k(void)
49 return (roc_model->flag & (ROC_MODEL_CN9K));
52 static inline uint64_t
53 roc_model_runtime_is_cn10k(void)
55 return (roc_model->flag & (ROC_MODEL_CN10K));
58 /* Compile time variants */
59 #ifdef ROC_PLATFORM_CN9K
60 #define roc_model_constant_is_cn9k() 1
61 #define roc_model_constant_is_cn10k() 0
63 #define roc_model_constant_is_cn9k() 0
64 #define roc_model_constant_is_cn10k() 1
68 * Compile time variants to enable optimized version check when the library
69 * configured for specific platform version else to fallback to runtime.
71 static inline uint64_t
72 roc_model_is_cn9k(void)
74 #ifdef ROC_PLATFORM_CN9K
77 #ifdef ROC_PLATFORM_CN10K
80 return roc_model_runtime_is_cn9k();
83 static inline uint64_t
84 roc_model_is_cn10k(void)
86 #ifdef ROC_PLATFORM_CN10K
89 #ifdef ROC_PLATFORM_CN9K
92 return roc_model_runtime_is_cn10k();
95 static inline uint64_t
96 roc_model_is_cn98xx(void)
98 return (roc_model->flag & ROC_MODEL_CN98xx_A0);
101 static inline uint64_t
102 roc_model_is_cn96_a0(void)
104 return roc_model->flag & ROC_MODEL_CN96xx_A0;
107 static inline uint64_t
108 roc_model_is_cn96_ax(void)
110 return (roc_model->flag & ROC_MODEL_CN96xx_Ax);
113 static inline uint64_t
114 roc_model_is_cn96_cx(void)
116 return (roc_model->flag & ROC_MODEL_CN96xx_C0);
119 static inline uint64_t
120 roc_model_is_cn95_a0(void)
122 return roc_model->flag & ROC_MODEL_CNF95xx_A0;
125 static inline uint64_t
126 roc_model_is_cn10ka(void)
128 return roc_model->flag & ROC_MODEL_CN106xx;
131 static inline uint64_t
132 roc_model_is_cnf10ka(void)
134 return roc_model->flag & ROC_MODEL_CNF105xx;
137 static inline uint64_t
138 roc_model_is_cnf10kb(void)
140 return roc_model->flag & ROC_MODEL_CNF105xxN;
143 static inline uint64_t
144 roc_model_is_cn10ka_a0(void)
146 return roc_model->flag & ROC_MODEL_CN106xx_A0;
149 static inline uint64_t
150 roc_model_is_cnf10ka_a0(void)
152 return roc_model->flag & ROC_MODEL_CNF105xx_A0;
155 static inline uint64_t
156 roc_model_is_cnf10kb_a0(void)
158 return roc_model->flag & ROC_MODEL_CNF105xxN_A0;
161 int roc_model_init(struct roc_model *model);