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_CN98xx_A0 BIT_ULL(16)
22 #define ROC_MODEL_CN106XX BIT_ULL(20)
23 #define ROC_MODEL_CNF105XX BIT_ULL(21)
24 #define ROC_MODEL_CNF105XXN BIT_ULL(22)
27 #define ROC_MODEL_STR_LEN_MAX 128
28 char name[ROC_MODEL_STR_LEN_MAX];
29 } __plt_cache_aligned;
31 #define ROC_MODEL_CN96xx_Ax (ROC_MODEL_CN96xx_A0 | ROC_MODEL_CN96xx_B0)
32 #define ROC_MODEL_CN9K \
33 (ROC_MODEL_CN96xx_Ax | ROC_MODEL_CN96xx_C0 | ROC_MODEL_CNF95xx_A0 | \
34 ROC_MODEL_CNF95xx_B0 | ROC_MODEL_CNF95XXMM_A0 | \
35 ROC_MODEL_CNF95XXO_A0 | ROC_MODEL_CNF95XXN_A0 | ROC_MODEL_CN98xx_A0)
37 #define ROC_MODEL_CN10K \
38 (ROC_MODEL_CN106XX | ROC_MODEL_CNF105XX | ROC_MODEL_CNF105XXN)
40 /* Runtime variants */
41 static inline uint64_t
42 roc_model_runtime_is_cn9k(void)
44 return (roc_model->flag & (ROC_MODEL_CN9K));
47 static inline uint64_t
48 roc_model_runtime_is_cn10k(void)
50 return (roc_model->flag & (ROC_MODEL_CN10K));
53 /* Compile time variants */
54 #ifdef ROC_PLATFORM_CN9K
55 #define roc_model_constant_is_cn9k() 1
56 #define roc_model_constant_is_cn10k() 0
58 #define roc_model_constant_is_cn9k() 0
59 #define roc_model_constant_is_cn10k() 1
63 * Compile time variants to enable optimized version check when the library
64 * configured for specific platform version else to fallback to runtime.
66 static inline uint64_t
67 roc_model_is_cn9k(void)
69 #ifdef ROC_PLATFORM_CN9K
72 #ifdef ROC_PLATFORM_CN10K
75 return roc_model_runtime_is_cn9k();
78 static inline uint64_t
79 roc_model_is_cn10k(void)
81 #ifdef ROC_PLATFORM_CN10K
84 #ifdef ROC_PLATFORM_CN9K
87 return roc_model_runtime_is_cn10k();
90 static inline uint64_t
91 roc_model_is_cn96_A0(void)
93 return roc_model->flag & ROC_MODEL_CN96xx_A0;
96 static inline uint64_t
97 roc_model_is_cn96_Ax(void)
99 return (roc_model->flag & ROC_MODEL_CN96xx_Ax);
102 static inline uint64_t
103 roc_model_is_cn95_A0(void)
105 return roc_model->flag & ROC_MODEL_CNF95xx_A0;
108 static inline uint64_t
109 roc_model_is_cn10ka(void)
111 return roc_model->flag & ROC_MODEL_CN106XX;
114 static inline uint64_t
115 roc_model_is_cnf10ka(void)
117 return roc_model->flag & ROC_MODEL_CNF105XX;
120 static inline uint64_t
121 roc_model_is_cnf10kb(void)
123 return roc_model->flag & ROC_MODEL_CNF105XXN;
126 int roc_model_init(struct roc_model *model);