LCOV - code coverage report
Current view: top level - drivers/common/cnxk - roc_model.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 29 0.0 %
Date: 2025-07-01 21:32:37 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 300 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _ROC_MODEL_H_
       6                 :            : #define _ROC_MODEL_H_
       7                 :            : 
       8                 :            : #include <stdbool.h>
       9                 :            : 
      10                 :            : #include "roc_bits.h"
      11                 :            : #include "roc_constants.h"
      12                 :            : 
      13                 :            : extern struct roc_model *roc_model;
      14                 :            : 
      15                 :            : struct roc_model {
      16                 :            : /* CN9k Models*/
      17                 :            : #define ROC_MODEL_CN96xx_A0    BIT_ULL(0)
      18                 :            : #define ROC_MODEL_CN96xx_B0    BIT_ULL(1)
      19                 :            : #define ROC_MODEL_CN96xx_C0    BIT_ULL(2)
      20                 :            : #define ROC_MODEL_CNF95xx_A0   BIT_ULL(4)
      21                 :            : #define ROC_MODEL_CNF95xx_B0   BIT_ULL(6)
      22                 :            : #define ROC_MODEL_CNF95xxMM_A0 BIT_ULL(8)
      23                 :            : #define ROC_MODEL_CNF95xxN_A0  BIT_ULL(12)
      24                 :            : #define ROC_MODEL_CNF95xxO_A0  BIT_ULL(13)
      25                 :            : #define ROC_MODEL_CNF95xxN_A1  BIT_ULL(14)
      26                 :            : #define ROC_MODEL_CNF95xxN_B0  BIT_ULL(15)
      27                 :            : #define ROC_MODEL_CN98xx_A0    BIT_ULL(16)
      28                 :            : #define ROC_MODEL_CN98xx_A1    BIT_ULL(17)
      29                 :            : /* CN10k Models*/
      30                 :            : #define ROC_MODEL_CN106xx_A0   BIT_ULL(20)
      31                 :            : #define ROC_MODEL_CNF105xx_A0  BIT_ULL(21)
      32                 :            : #define ROC_MODEL_CNF105xxN_A0 BIT_ULL(22)
      33                 :            : #define ROC_MODEL_CN103xx_A0   BIT_ULL(23)
      34                 :            : #define ROC_MODEL_CN106xx_A1   BIT_ULL(24)
      35                 :            : #define ROC_MODEL_CNF105xx_A1  BIT_ULL(25)
      36                 :            : #define ROC_MODEL_CN106xx_B0   BIT_ULL(26)
      37                 :            : #define ROC_MODEL_CNF105xxN_B0 BIT_ULL(27)
      38                 :            : /* CN20k Models*/
      39                 :            : #define ROC_MODEL_CN206xx_A0   BIT_ULL(40)
      40                 :            : #define ROC_MODEL_CNF205xxN_A0 BIT_ULL(41)
      41                 :            : 
      42                 :            : /* Following flags describe platform code is running on */
      43                 :            : #define ROC_ENV_HW   BIT_ULL(61)
      44                 :            : #define ROC_ENV_EMUL BIT_ULL(62)
      45                 :            : #define ROC_ENV_ASIM BIT_ULL(63)
      46                 :            : 
      47                 :            :         uint64_t flag;
      48                 :            : #define ROC_MODEL_STR_LEN_MAX 128
      49                 :            :         char name[ROC_MODEL_STR_LEN_MAX];
      50                 :            :         char env[ROC_MODEL_STR_LEN_MAX];
      51                 :            : } __plt_cache_aligned;
      52                 :            : 
      53                 :            : /* CN9K models */
      54                 :            : #define ROC_MODEL_CN96xx_Ax (ROC_MODEL_CN96xx_A0 | ROC_MODEL_CN96xx_B0)
      55                 :            : #define ROC_MODEL_CN98xx_Ax (ROC_MODEL_CN98xx_A0 | ROC_MODEL_CN98xx_A1)
      56                 :            : #define ROC_MODEL_CN9K                                                         \
      57                 :            :         (ROC_MODEL_CN96xx_Ax | ROC_MODEL_CN96xx_C0 | ROC_MODEL_CNF95xx_A0 |    \
      58                 :            :          ROC_MODEL_CNF95xx_B0 | ROC_MODEL_CNF95xxMM_A0 |                       \
      59                 :            :          ROC_MODEL_CNF95xxO_A0 | ROC_MODEL_CNF95xxN_A0 | ROC_MODEL_CN98xx_Ax | \
      60                 :            :          ROC_MODEL_CNF95xxN_A1 | ROC_MODEL_CNF95xxN_B0)
      61                 :            : #define ROC_MODEL_CNF9K                                                        \
      62                 :            :         (ROC_MODEL_CNF95xx_A0 | ROC_MODEL_CNF95xx_B0 |                         \
      63                 :            :          ROC_MODEL_CNF95xxMM_A0 | ROC_MODEL_CNF95xxO_A0 |                      \
      64                 :            :          ROC_MODEL_CNF95xxN_A0 | ROC_MODEL_CNF95xxN_A1 |                       \
      65                 :            :          ROC_MODEL_CNF95xxN_B0)
      66                 :            : 
      67                 :            : /* CN10K models */
      68                 :            : #define ROC_MODEL_CN106xx   (ROC_MODEL_CN106xx_A0 | ROC_MODEL_CN106xx_A1 | ROC_MODEL_CN106xx_B0)
      69                 :            : #define ROC_MODEL_CNF105xx  (ROC_MODEL_CNF105xx_A0 | ROC_MODEL_CNF105xx_A1)
      70                 :            : #define ROC_MODEL_CNF105xxN (ROC_MODEL_CNF105xxN_A0 | ROC_MODEL_CNF105xxN_B0)
      71                 :            : #define ROC_MODEL_CN103xx   (ROC_MODEL_CN103xx_A0)
      72                 :            : #define ROC_MODEL_CN10K                                                        \
      73                 :            :         (ROC_MODEL_CN106xx | ROC_MODEL_CNF105xx | ROC_MODEL_CNF105xxN |        \
      74                 :            :          ROC_MODEL_CN103xx)
      75                 :            : #define ROC_MODEL_CNF10K (ROC_MODEL_CNF105xx | ROC_MODEL_CNF105xxN)
      76                 :            : 
      77                 :            : /* CN20K models */
      78                 :            : #define ROC_MODEL_CN206xx   (ROC_MODEL_CN206xx_A0)
      79                 :            : #define ROC_MODEL_CNF205xxN (ROC_MODEL_CNF205xxN_A0)
      80                 :            : #define ROC_MODEL_CN20K     (ROC_MODEL_CN206xx | ROC_MODEL_CNF205xxN)
      81                 :            : 
      82                 :            : /* Runtime variants */
      83                 :            : static inline uint64_t
      84                 :            : roc_model_runtime_is_cn9k(void)
      85                 :            : {
      86   [ #  #  #  #  :          0 :         return (roc_model->flag & (ROC_MODEL_CN9K));
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
      87                 :            : }
      88                 :            : 
      89                 :            : static inline uint64_t
      90                 :            : roc_model_runtime_is_cn10k(void)
      91                 :            : {
      92   [ #  #  #  #  :          0 :         return (roc_model->flag & (ROC_MODEL_CN10K));
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
      93                 :            : }
      94                 :            : 
      95                 :            : static inline uint64_t
      96                 :            : roc_model_runtime_is_cn20k(void)
      97                 :            : {
      98   [ #  #  #  #  :          0 :         return (roc_model->flag & (ROC_MODEL_CN20K));
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
      99                 :            : }
     100                 :            : 
     101                 :            : /* Compile time variants */
     102                 :            : #ifdef ROC_PLATFORM_CN9K
     103                 :            : #define roc_model_constant_is_cn9k()  1
     104                 :            : #define roc_model_constant_is_cn10k() 0
     105                 :            : #define roc_model_constant_is_cn20k() 0
     106                 :            : #endif
     107                 :            : #ifdef ROC_PLATFORM_CN10K
     108                 :            : #define roc_model_constant_is_cn9k()  0
     109                 :            : #define roc_model_constant_is_cn10k() 1
     110                 :            : #define roc_model_constant_is_cn20k() 0
     111                 :            : #endif
     112                 :            : #ifdef ROC_PLATFORM_CN20K
     113                 :            : #define roc_model_constant_is_cn9k()  0
     114                 :            : #define roc_model_constant_is_cn10k() 0
     115                 :            : #define roc_model_constant_is_cn20k() 1
     116                 :            : #endif
     117                 :            : #if !defined(ROC_PLATFORM_CN9K) && !defined(ROC_PLATFORM_CN10K) && !defined(ROC_PLATFORM_CN20K)
     118                 :            : #define roc_model_constant_is_cn9k()  0
     119                 :            : #define roc_model_constant_is_cn10k() 0
     120                 :            : #define roc_model_constant_is_cn20k() 0
     121                 :            : #endif
     122                 :            : 
     123                 :            : /*
     124                 :            :  * Compile time variants to enable optimized version check when the library
     125                 :            :  * configured for specific platform version else to fallback to runtime.
     126                 :            :  */
     127                 :            : static inline uint64_t
     128                 :            : roc_model_is_cn9k(void)
     129                 :            : {
     130                 :            : #ifdef ROC_PLATFORM_CN9K
     131                 :            :         return 1;
     132                 :            : #endif
     133                 :            : #if defined(ROC_PLATFORM_CN10K) || defined(ROC_PLATFORM_CN20K)
     134                 :            :         return 0;
     135                 :            : #endif
     136                 :            :         return roc_model_runtime_is_cn9k();
     137                 :            : }
     138                 :            : 
     139                 :            : static inline uint64_t
     140                 :            : roc_model_is_cn10k(void)
     141                 :            : {
     142                 :            : #ifdef ROC_PLATFORM_CN10K
     143                 :            :         return 1;
     144                 :            : #endif
     145                 :            : #if defined(ROC_PLATFORM_CN9K) || defined(ROC_PLATFORM_CN20K)
     146                 :            :         return 0;
     147                 :            : #endif
     148                 :            :         return roc_model_runtime_is_cn10k();
     149                 :            : }
     150                 :            : 
     151                 :            : static inline uint64_t
     152                 :            : roc_model_is_cn20k(void)
     153                 :            : {
     154                 :            : #ifdef ROC_PLATFORM_CN20K
     155                 :            :         return 1;
     156                 :            : #endif
     157                 :            : #if defined(ROC_PLATFORM_CN9K) || defined(ROC_PLATFORM_CN10K)
     158                 :            :         return 0;
     159                 :            : #endif
     160                 :            :         return roc_model_runtime_is_cn20k();
     161                 :            : }
     162                 :            : 
     163                 :            : static inline uint16_t
     164                 :            : roc_model_optimal_align_sz(void)
     165                 :            : {
     166   [ #  #  #  # ]:          0 :         if (roc_model_is_cn9k())
     167                 :            :                 return ROC_ALIGN;
     168   [ #  #  #  # ]:          0 :         if (roc_model_is_cn10k())
     169                 :            :                 return ROC_ALIGN;
     170   [ #  #  #  # ]:          0 :         if (roc_model_is_cn20k())
     171                 :          0 :                 return ROC_ALIGN << 1;
     172                 :            :         return 128;
     173                 :            : }
     174                 :            : 
     175                 :            : static inline uint64_t
     176                 :            : roc_model_is_cn98xx(void)
     177                 :            : {
     178   [ #  #  #  # ]:          0 :         return (roc_model->flag & ROC_MODEL_CN98xx_Ax);
     179                 :            : }
     180                 :            : 
     181                 :            : static inline uint64_t
     182                 :            : roc_model_is_cn98xx_a0(void)
     183                 :            : {
     184                 :            :         return (roc_model->flag & ROC_MODEL_CN98xx_A0);
     185                 :            : }
     186                 :            : 
     187                 :            : static inline uint64_t
     188                 :            : roc_model_is_cn98xx_a1(void)
     189                 :            : {
     190                 :            :         return (roc_model->flag & ROC_MODEL_CN98xx_A1);
     191                 :            : }
     192                 :            : 
     193                 :            : static inline uint64_t
     194                 :            : roc_model_is_cn96_a0(void)
     195                 :            : {
     196   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CN96xx_A0;
                   #  # ]
     197                 :            : }
     198                 :            : 
     199                 :            : static inline uint64_t
     200                 :            : roc_model_is_cn96_ax(void)
     201                 :            : {
     202   [ #  #  #  # ]:          0 :         return (roc_model->flag & ROC_MODEL_CN96xx_Ax);
     203                 :            : }
     204                 :            : 
     205                 :            : static inline uint64_t
     206                 :            : roc_model_is_cn96_b0(void)
     207                 :            : {
     208         [ #  # ]:          0 :         return (roc_model->flag & ROC_MODEL_CN96xx_B0);
     209                 :            : }
     210                 :            : 
     211                 :            : static inline uint64_t
     212                 :            : roc_model_is_cn96_cx(void)
     213                 :            : {
     214         [ #  # ]:          0 :         return (roc_model->flag & ROC_MODEL_CN96xx_C0);
     215                 :            : }
     216                 :            : 
     217                 :            : static inline uint64_t
     218                 :            : roc_model_is_cn95_a0(void)
     219                 :            : {
     220   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CNF95xx_A0;
             #  #  #  # ]
     221                 :            : }
     222                 :            : 
     223                 :            : static inline uint64_t
     224                 :            : roc_model_is_cnf95xxn_a0(void)
     225                 :            : {
     226   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CNF95xxN_A0;
                   #  # ]
     227                 :            : }
     228                 :            : 
     229                 :            : static inline uint64_t
     230                 :            : roc_model_is_cnf95xxn_a1(void)
     231                 :            : {
     232   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CNF95xxN_A1;
                   #  # ]
     233                 :            : }
     234                 :            : 
     235                 :            : static inline uint64_t
     236                 :            : roc_model_is_cnf95xxn_b0(void)
     237                 :            : {
     238   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CNF95xxN_B0;
                   #  # ]
     239                 :            : }
     240                 :            : 
     241                 :            : static inline uint64_t
     242                 :            : roc_model_is_cnf95xxo_a0(void)
     243                 :            : {
     244         [ #  # ]:          0 :         return roc_model->flag & ROC_MODEL_CNF95xxO_A0;
     245                 :            : }
     246                 :            : 
     247                 :            : static inline uint16_t
     248                 :            : roc_model_is_cn95xxn_a0(void)
     249                 :            : {
     250                 :            :         return roc_model->flag & ROC_MODEL_CNF95xxN_A0;
     251                 :            : }
     252                 :            : 
     253                 :            : static inline uint64_t
     254                 :            : roc_model_is_cn10ka(void)
     255                 :            : {
     256   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CN106xx;
                   #  # ]
     257                 :            : }
     258                 :            : 
     259                 :            : static inline uint64_t
     260                 :            : roc_model_is_cnf10ka(void)
     261                 :            : {
     262                 :            :         return roc_model->flag & ROC_MODEL_CNF105xx;
     263                 :            : }
     264                 :            : 
     265                 :            : static inline uint64_t
     266                 :            : roc_model_is_cnf10kb(void)
     267                 :            : {
     268   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CNF105xxN;
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     269                 :            : }
     270                 :            : 
     271                 :            : static inline uint64_t
     272                 :            : roc_model_is_cn10kb_a0(void)
     273                 :            : {
     274   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CN103xx_A0;
             #  #  #  # ]
     275                 :            : }
     276                 :            : 
     277                 :            : static inline uint64_t
     278                 :            : roc_model_is_cn10ka_a0(void)
     279                 :            : {
     280   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CN106xx_A0;
          #  #  #  #  #  
                      # ]
     281                 :            : }
     282                 :            : 
     283                 :            : static inline uint64_t
     284                 :            : roc_model_is_cn10ka_a1(void)
     285                 :            : {
     286   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CN106xx_A1;
          #  #  #  #  #  
                      # ]
     287                 :            : }
     288                 :            : 
     289                 :            : static inline uint64_t
     290                 :            : roc_model_is_cn10ka_b0(void)
     291                 :            : {
     292   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CN106xx_B0;
          #  #  #  #  #  
                #  #  # ]
     293                 :            : }
     294                 :            : 
     295                 :            : static inline uint64_t
     296                 :            : roc_model_is_cnf10ka_a0(void)
     297                 :            : {
     298   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CNF105xx_A0;
                   #  # ]
     299                 :            : }
     300                 :            : 
     301                 :            : static inline uint64_t
     302                 :            : roc_model_is_cnf10ka_a1(void)
     303                 :            : {
     304                 :            :         return roc_model->flag & ROC_MODEL_CNF105xx_A1;
     305                 :            : }
     306                 :            : 
     307                 :            : static inline uint64_t
     308                 :            : roc_model_is_cnf10kb_a0(void)
     309                 :            : {
     310   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CNF105xxN_A0;
                   #  # ]
     311                 :            : }
     312                 :            : 
     313                 :            : static inline uint64_t
     314                 :            : roc_model_is_cnf10kb_b0(void)
     315                 :            : {
     316                 :            :         return roc_model->flag & ROC_MODEL_CNF105xxN_B0;
     317                 :            : }
     318                 :            : 
     319                 :            : static inline uint64_t
     320                 :            : roc_model_is_cn10kb(void)
     321                 :            : {
     322   [ #  #  #  #  :          0 :         return roc_model->flag & ROC_MODEL_CN103xx;
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     323                 :            : }
     324                 :            : 
     325                 :            : static inline uint64_t
     326                 :            : roc_model_is_cn20ka(void)
     327                 :            : {
     328                 :            :         return roc_model->flag & ROC_MODEL_CN206xx;
     329                 :            : }
     330                 :            : 
     331                 :            : static inline uint64_t
     332                 :            : roc_model_is_cn20ka_a0(void)
     333                 :            : {
     334                 :            :         return roc_model->flag & ROC_MODEL_CN206xx_A0;
     335                 :            : }
     336                 :            : 
     337                 :            : static inline uint64_t
     338                 :            : roc_model_is_cnf20ka(void)
     339                 :            : {
     340                 :            :         return roc_model->flag & ROC_MODEL_CNF205xxN;
     341                 :            : }
     342                 :            : 
     343                 :            : static inline uint64_t
     344                 :            : roc_model_is_cnf20ka_a0(void)
     345                 :            : {
     346                 :            :         return roc_model->flag & ROC_MODEL_CNF205xxN_A0;
     347                 :            : }
     348                 :            : 
     349                 :            : static inline bool
     350                 :            : roc_env_is_hw(void)
     351                 :            : {
     352   [ #  #  #  # ]:          0 :         return roc_model->flag & ROC_ENV_HW;
     353                 :            : }
     354                 :            : 
     355                 :            : static inline bool
     356                 :            : roc_env_is_emulator(void)
     357                 :            : {
     358   [ #  #  #  # ]:          0 :         return roc_model->flag & ROC_ENV_EMUL;
     359                 :            : }
     360                 :            : 
     361                 :            : static inline bool
     362                 :            : roc_env_is_asim(void)
     363                 :            : {
     364         [ #  # ]:          0 :         return roc_model->flag & ROC_ENV_ASIM;
     365                 :            : }
     366                 :            : 
     367                 :            : static inline const char *
     368                 :            : roc_env_get(void)
     369                 :            : {
     370                 :            :         return roc_model->env;
     371                 :            : }
     372                 :            : 
     373                 :            : int roc_model_init(struct roc_model *model);
     374                 :            : 
     375                 :            : #endif

Generated by: LCOV version 1.14