developer | 02e6591 | 2023-08-17 16:33:10 +0800 | [diff] [blame] | 1 | /* adapter_global_cs_init.c |
| 2 | * |
| 3 | * Initialize Global Classification Control functionality. |
| 4 | */ |
| 5 | |
| 6 | /***************************************************************************** |
| 7 | * Copyright (c) 2011-2021 by Rambus, Inc. and/or its subsidiaries. |
| 8 | * |
| 9 | * This program is free software: you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation, either version 2 of the License, or |
| 12 | * any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | *****************************************************************************/ |
| 22 | |
| 23 | /*---------------------------------------------------------------------------- |
| 24 | * This module implements (provides) the following interface(s): |
| 25 | */ |
| 26 | |
| 27 | #include "adapter_global_cs_init.h" |
| 28 | |
| 29 | |
| 30 | /*---------------------------------------------------------------------------- |
| 31 | * This module uses (requires) the following interface(s): |
| 32 | */ |
| 33 | |
| 34 | // Default configuration |
| 35 | #include "c_adapter_cs.h" |
| 36 | |
| 37 | // Global Control API |
| 38 | #include "api_global_eip97.h" |
| 39 | |
| 40 | // Global Control Classification API |
| 41 | #include "api_global_eip207.h" |
| 42 | |
| 43 | // Driver Framework Basic Definitions API |
| 44 | #include "basic_defs.h" // uint8_t, uint32_t, bool |
| 45 | |
| 46 | // Driver Framework C Library API |
| 47 | #include "clib.h" // memcpy, ZEROINIT |
| 48 | |
| 49 | #include "device_types.h" // Device_Handle_t |
| 50 | #include "device_mgmt.h" // Device_find |
| 51 | #include "log.h" // Log API |
| 52 | |
| 53 | |
| 54 | /*---------------------------------------------------------------------------- |
| 55 | * Definitions and macros |
| 56 | */ |
| 57 | |
| 58 | |
| 59 | /*---------------------------------------------------------------------------- |
| 60 | * Local variables |
| 61 | */ |
| 62 | |
| 63 | static const uint32_t Global_IV_Data[4] = ADAPTER_CS_IV; |
| 64 | |
| 65 | |
| 66 | /*---------------------------------------------------------------------------- |
| 67 | * YesNo |
| 68 | * |
| 69 | * Convert boolean value to string. |
| 70 | */ |
| 71 | static const char * |
| 72 | YesNo( |
| 73 | const bool b) |
| 74 | { |
| 75 | if (b) |
| 76 | return "YES"; |
| 77 | else |
| 78 | return "no"; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | /*---------------------------------------------------------------------------- |
| 83 | * Adapter_Global_Cs_StatusReport() |
| 84 | * |
| 85 | * Obtain all available global status information from the Global Classification |
| 86 | * hardware and report it. |
| 87 | */ |
| 88 | static void |
| 89 | Adapter_Global_Cs_StatusReport(void) |
| 90 | { |
| 91 | GlobalControl207_Error_t rc; |
| 92 | unsigned int i; |
| 93 | unsigned int NofCEs; |
| 94 | |
| 95 | LOG_INFO("\n\t\t Adapter_Global_Cs_StatusReport \n"); |
| 96 | |
| 97 | LOG_CRIT("Global Classification Control Status\n"); |
| 98 | GlobalControl97_Interfaces_Get(&NofCEs, NULL, NULL, NULL); |
| 99 | |
| 100 | for (i = 0; i < NofCEs; i++) |
| 101 | { |
| 102 | GlobalControl207_Status_t CE_Status; |
| 103 | GlobalControl207_GlobalStats_t CE_GlobalStats; |
| 104 | GlobalControl207_Clock_t CE_Clock; |
| 105 | |
| 106 | ZEROINIT(CE_Status); |
| 107 | ZEROINIT(CE_GlobalStats); |
| 108 | ZEROINIT(CE_Clock); |
| 109 | |
| 110 | LOG_CRIT("Classification Engine %d status\n", i); |
| 111 | |
| 112 | rc = GlobalControl207_Status_Get(i, &CE_Status); |
| 113 | if (rc != EIP207_GLOBAL_CONTROL_NO_ERROR) |
| 114 | LOG_CRIT("%s: GlobalControl207_Status_Get() failed\n", __func__); |
| 115 | else |
| 116 | { |
| 117 | if (CE_Status.ICE.fPUE_EccCorr || |
| 118 | CE_Status.ICE.fPUE_EccDerr || |
| 119 | CE_Status.ICE.fFPP_EccCorr || |
| 120 | CE_Status.ICE.fFPP_EccDerr || |
| 121 | CE_Status.ICE.fTimerOverflow || |
| 122 | CE_Status.OCE.fPUE_EccCorr || |
| 123 | CE_Status.OCE.fPUE_EccDerr || |
| 124 | CE_Status.OCE.fFPP_EccCorr || |
| 125 | CE_Status.OCE.fFPP_EccDerr || |
| 126 | CE_Status.OCE.fTimerOverflow || |
| 127 | CE_Status.FLUE.Error1 != 0 || |
| 128 | CE_Status.FLUE.Error2 != 0 || |
| 129 | CE_Status.FRC[0].fDMAReadError || |
| 130 | CE_Status.FRC[0].fDMAWriteError || |
| 131 | CE_Status.FRC[0].fDataEccOflo || |
| 132 | CE_Status.FRC[0].fDataEccErr || |
| 133 | CE_Status.FRC[0].fAdminEccErr || |
| 134 | CE_Status.TRC[0].fDMAReadError || |
| 135 | CE_Status.TRC[0].fDMAWriteError || |
| 136 | CE_Status.TRC[0].fDataEccOflo || |
| 137 | CE_Status.TRC[0].fDataEccErr || |
| 138 | CE_Status.TRC[0].fAdminEccErr || |
| 139 | CE_Status.ARC4RC[0].fDMAReadError || |
| 140 | CE_Status.ARC4RC[0].fDMAWriteError || |
| 141 | CE_Status.ARC4RC[0].fDataEccOflo || |
| 142 | CE_Status.ARC4RC[0].fDataEccErr || |
| 143 | CE_Status.ARC4RC[0].fAdminEccErr) |
| 144 | { |
| 145 | LOG_CRIT("%s: error(s) detected\n", __func__); |
| 146 | LOG_CRIT( |
| 147 | "\tICE Pull-Up ECC Correctable Err: %s\n" |
| 148 | "\tICE Pull-Up ECC Non-Corr Err: %s\n" |
| 149 | "\tICE Post-Processor ECC Correctable Err: %s\n" |
| 150 | "\tICE Post-Processor ECC Non-Corr Err: %s\n" |
| 151 | "\tICE Timer ovf detected: %s\n" |
| 152 | "\tOCE Pull-Up ECC Correctable Err: %s\n" |
| 153 | "\tOCE Pull-Up ECC Non-Corr Err: %s\n" |
| 154 | "\tOCE Post-Processor ECC Correctable Err: %s\n" |
| 155 | "\tOCE Post-Processor ECC Non-Corr Err: %s\n" |
| 156 | "\tOCE Timer ovf detected: %s\n" |
| 157 | "\tFLUE Err 1: %s (mask=0x%08x)\n" |
| 158 | "\tFLUE Err 2: %s (mask=0x%08x)\n" |
| 159 | "\tFRC#0 DMA Read Err: %s\n" |
| 160 | "\tFRC#0 DMA Write Err: %s\n" |
| 161 | "\tFRC#0 Data RAM ECC Non-Corr Ovf Err: %s\n" |
| 162 | "\tFRC#0 Data RAM ECC Non-Corr Err: %s\n" |
| 163 | "\tFRC#0 Admin RAM ECC Non-Corr Err: %s\n" |
| 164 | "\tTRC#0 DMA Read Err: %s\n" |
| 165 | "\tTRC#0 DMA Write Err: %s\n" |
| 166 | "\tTRC#0 Data RAM ECC Non-Corr Ovf Err: %s\n" |
| 167 | "\tTRC#0 Data RAM ECC Non-Corr Err: %s\n" |
| 168 | "\tTRC#0 Admin RAM ECC Non-Corr Err: %s\n" |
| 169 | "\tARC4RC#0 DMA Read Err: %s\n" |
| 170 | "\tARC4RC#0 DMA Write Err: %s\n" |
| 171 | "\tARC4RC#0 Data RAM ECC Non-Corr Ovf Err: %s\n" |
| 172 | "\tARC4RC#0 Data RAM ECC Non-Corr Err: %s\n" |
| 173 | "\tARC4RC#0 Admin RAM ECC Non-Corr Err: %s\n\n", |
| 174 | YesNo(CE_Status.ICE.fPUE_EccCorr), |
| 175 | YesNo(CE_Status.ICE.fPUE_EccDerr), |
| 176 | YesNo(CE_Status.ICE.fFPP_EccCorr), |
| 177 | YesNo(CE_Status.ICE.fFPP_EccDerr), |
| 178 | YesNo(CE_Status.ICE.fTimerOverflow), |
| 179 | YesNo(CE_Status.OCE.fPUE_EccCorr), |
| 180 | YesNo(CE_Status.OCE.fPUE_EccDerr), |
| 181 | YesNo(CE_Status.OCE.fFPP_EccCorr), |
| 182 | YesNo(CE_Status.OCE.fFPP_EccDerr), |
| 183 | YesNo(CE_Status.OCE.fTimerOverflow), |
| 184 | YesNo(CE_Status.FLUE.Error1 != 0), |
| 185 | CE_Status.FLUE.Error1, |
| 186 | YesNo(CE_Status.FLUE.Error2 != 0), |
| 187 | CE_Status.FLUE.Error2, |
| 188 | YesNo(CE_Status.FRC[0].fDMAReadError), |
| 189 | YesNo(CE_Status.FRC[0].fDMAWriteError), |
| 190 | YesNo(CE_Status.FRC[0].fDataEccOflo), |
| 191 | YesNo(CE_Status.FRC[0].fDataEccErr), |
| 192 | YesNo(CE_Status.FRC[0].fAdminEccErr), |
| 193 | YesNo(CE_Status.TRC[0].fDMAReadError), |
| 194 | YesNo(CE_Status.TRC[0].fDMAWriteError), |
| 195 | YesNo(CE_Status.TRC[0].fDataEccOflo), |
| 196 | YesNo(CE_Status.TRC[0].fDataEccErr), |
| 197 | YesNo(CE_Status.TRC[0].fAdminEccErr), |
| 198 | YesNo(CE_Status.ARC4RC[0].fDMAReadError), |
| 199 | YesNo(CE_Status.ARC4RC[0].fDMAWriteError), |
| 200 | YesNo(CE_Status.ARC4RC[0].fDataEccOflo), |
| 201 | YesNo(CE_Status.ARC4RC[0].fDataEccErr), |
| 202 | YesNo(CE_Status.ARC4RC[0].fAdminEccErr)); |
| 203 | } |
| 204 | else |
| 205 | LOG_CRIT("%s: all OK\n", __func__); |
| 206 | if (CE_Status.FRCStats[0].PrefetchExec || |
| 207 | CE_Status.FRCStats[0].PrefetchBlock || |
| 208 | CE_Status.FRCStats[0].PrefetchDMA || |
| 209 | CE_Status.FRCStats[0].SelectOps || |
| 210 | CE_Status.FRCStats[0].SelectDMA || |
| 211 | CE_Status.FRCStats[0].IntDMAWrite || |
| 212 | CE_Status.FRCStats[0].ExtDMAWrite || |
| 213 | CE_Status.FRCStats[0].InvalidateOps) |
| 214 | { |
| 215 | LOG_CRIT("FRC statistics:\n" |
| 216 | "\tPrefetches executed: %u\n" |
| 217 | "\tPrefetches blocked: %u\n" |
| 218 | "\tPrefetches with DMA: %u\n" |
| 219 | "\tSelect ops: %u\n" |
| 220 | "\tSelect ops with DMA: %u\n" |
| 221 | "\tInternal DMA writes: %u\n" |
| 222 | "\tExternal DMA writes: %u\n" |
| 223 | "\tInvalidate ops: %u\n" |
| 224 | "\tDMA err flags 0x%x\n" |
| 225 | "\tRead DMA errs: %u\n" |
| 226 | "\tWrite DMA errs: %u\n" |
| 227 | "\tECC invalidates: %u\n" |
| 228 | "\tECC Data RAM Corr: %u\n" |
| 229 | "\tECC Admin RAM Corr: %u\n", |
| 230 | (uint32_t)CE_Status.FRCStats[0].PrefetchExec, |
| 231 | (uint32_t)CE_Status.FRCStats[0].PrefetchBlock, |
| 232 | (uint32_t)CE_Status.FRCStats[0].PrefetchDMA, |
| 233 | (uint32_t)CE_Status.FRCStats[0].SelectOps, |
| 234 | (uint32_t)CE_Status.FRCStats[0].SelectDMA, |
| 235 | (uint32_t)CE_Status.FRCStats[0].IntDMAWrite, |
| 236 | (uint32_t)CE_Status.FRCStats[0].ExtDMAWrite, |
| 237 | (uint32_t)CE_Status.FRCStats[0].InvalidateOps, |
| 238 | (uint32_t)CE_Status.FRCStats[0].ReadDMAErrFlags, |
| 239 | (uint32_t)CE_Status.FRCStats[0].ReadDMAErrors, |
| 240 | (uint32_t)CE_Status.FRCStats[0].WriteDMAErrors, |
| 241 | (uint32_t)CE_Status.FRCStats[0].InvalidateECC, |
| 242 | (uint32_t)CE_Status.FRCStats[0].DataECCCorr, |
| 243 | (uint32_t)CE_Status.FRCStats[0].AdminECCCorr); |
| 244 | } |
| 245 | if (CE_Status.TRCStats[0].PrefetchExec || |
| 246 | CE_Status.TRCStats[0].PrefetchBlock || |
| 247 | CE_Status.TRCStats[0].PrefetchDMA || |
| 248 | CE_Status.TRCStats[0].SelectOps || |
| 249 | CE_Status.TRCStats[0].SelectDMA || |
| 250 | CE_Status.TRCStats[0].IntDMAWrite || |
| 251 | CE_Status.TRCStats[0].ExtDMAWrite || |
| 252 | CE_Status.TRCStats[0].InvalidateOps) |
| 253 | { |
| 254 | LOG_CRIT("TRC statistics:\n" |
| 255 | "\tPrefetches executed: %u\n" |
| 256 | "\tPrefetches blocked: %u\n" |
| 257 | "\tPrefetches with DMA: %u\n" |
| 258 | "\tSelect ops: %u\n" |
| 259 | "\tSelect ops with DMA: %u\n" |
| 260 | "\tInternal DMA writes: %u\n" |
| 261 | "\tExternal DMA writes: %u\n" |
| 262 | "\tInvalidate ops: %u\n" |
| 263 | "\tDMA err flags 0x%x\n" |
| 264 | "\tRead DMA errs: %u\n" |
| 265 | "\tWrite DMA errs: %u\n" |
| 266 | "\tECC invalidates: %u\n" |
| 267 | "\tECC Data RAM Corr: %u\n" |
| 268 | "\tECC Admin RAM Corr: %u\n", |
| 269 | (uint32_t)CE_Status.TRCStats[0].PrefetchExec, |
| 270 | (uint32_t)CE_Status.TRCStats[0].PrefetchBlock, |
| 271 | (uint32_t)CE_Status.TRCStats[0].PrefetchDMA, |
| 272 | (uint32_t)CE_Status.TRCStats[0].SelectOps, |
| 273 | (uint32_t)CE_Status.TRCStats[0].SelectDMA, |
| 274 | (uint32_t)CE_Status.TRCStats[0].IntDMAWrite, |
| 275 | (uint32_t)CE_Status.TRCStats[0].ExtDMAWrite, |
| 276 | (uint32_t)CE_Status.TRCStats[0].InvalidateOps, |
| 277 | (uint32_t)CE_Status.TRCStats[0].ReadDMAErrFlags, |
| 278 | (uint32_t)CE_Status.TRCStats[0].ReadDMAErrors, |
| 279 | (uint32_t)CE_Status.TRCStats[0].WriteDMAErrors, |
| 280 | (uint32_t)CE_Status.TRCStats[0].InvalidateECC, |
| 281 | (uint32_t)CE_Status.TRCStats[0].DataECCCorr, |
| 282 | (uint32_t)CE_Status.TRCStats[0].AdminECCCorr); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | rc = GlobalControl207_GlobalStats_Get(i, &CE_GlobalStats); |
| 287 | if (rc != EIP207_GLOBAL_CONTROL_NO_ERROR) |
| 288 | LOG_CRIT("Adapter_Global_Cs_StatusReport: " |
| 289 | "GlobalControl207_GlobalStats_Get() failed\n"); |
| 290 | else |
| 291 | LOG_CRIT( |
| 292 | "\tICE Dropped Packets Counter (low 32-bits): 0x%08x\n" |
| 293 | "\tICE Dropped Packets Counter (high 32-bits): 0x%08x\n" |
| 294 | "\tICE Inbound Packets Counter: 0x%08x\n" |
| 295 | "\tICE Outbound Packets Counter: 0x%08x\n" |
| 296 | "\tICE Inbound Octets Counter (low 32-bits): 0x%08x\n" |
| 297 | "\tICE Inbound Octets Counter (high 32-bits): 0x%08x\n" |
| 298 | "\tICE Outbound Octets Counter (low 32-bits): 0x%08x\n" |
| 299 | "\tICE Outbound Octets Counter (high 32-bits): 0x%08x\n" |
| 300 | "\tOCE Dropped Packets Counter (low 32-bits): 0x%08x\n" |
| 301 | "\tOCE Dropped Packets Counter (high 32-bits): 0x%08x\n\n", |
| 302 | CE_GlobalStats.ICE.DroppedPacketsCounter.Value64_Lo, |
| 303 | CE_GlobalStats.ICE.DroppedPacketsCounter.Value64_Hi, |
| 304 | CE_GlobalStats.ICE.InboundPacketsCounter, |
| 305 | CE_GlobalStats.ICE.OutboundPacketCounter, |
| 306 | CE_GlobalStats.ICE.InboundOctetsCounter.Value64_Lo, |
| 307 | CE_GlobalStats.ICE.InboundOctetsCounter.Value64_Hi, |
| 308 | CE_GlobalStats.ICE.OutboundOctetsCounter.Value64_Lo, |
| 309 | CE_GlobalStats.ICE.OutboundOctetsCounter.Value64_Hi, |
| 310 | CE_GlobalStats.OCE.DroppedPacketsCounter.Value64_Lo, |
| 311 | CE_GlobalStats.OCE.DroppedPacketsCounter.Value64_Hi); |
| 312 | |
| 313 | rc = GlobalControl207_ClockCount_Get(i, &CE_Clock); |
| 314 | if (rc != EIP207_GLOBAL_CONTROL_NO_ERROR) |
| 315 | LOG_CRIT("Adapter_Global_Cs_StatusReport: " |
| 316 | "GlobalControl207_ClockCount_Get() failed\n"); |
| 317 | else |
| 318 | LOG_CRIT( |
| 319 | "\tICE Clock Count (low 32-bits): 0x%08x\n" |
| 320 | "\tICE Clock Count (high 32-bits): 0x%08x\n" |
| 321 | "\tOCE Clock Count (low 32-bits): 0x%08x\n" |
| 322 | "\tOCE Clock Count (high 32-bits): 0x%08x\n\n", |
| 323 | CE_Clock.ICE.Value64_Lo, |
| 324 | CE_Clock.ICE.Value64_Hi, |
| 325 | CE_Clock.OCE.Value64_Lo, |
| 326 | CE_Clock.OCE.Value64_Hi); |
| 327 | } // for |
| 328 | } |
| 329 | |
| 330 | |
| 331 | /*---------------------------------------------------------------------------- |
| 332 | * Adapter_Global_Cs_Init() |
| 333 | * |
| 334 | */ |
| 335 | bool |
| 336 | Adapter_Global_Cs_Init(void) |
| 337 | { |
| 338 | GlobalControl207_Error_t rc; |
| 339 | GlobalControl207_Capabilities_t Capabilities; |
| 340 | GlobalControl207_IV_t Data; |
| 341 | |
| 342 | LOG_INFO("\n\t\t Adapter_Global_Cs_Init \n"); |
| 343 | |
| 344 | Data.IV[0] = Global_IV_Data[0]; |
| 345 | Data.IV[1] = Global_IV_Data[1]; |
| 346 | Data.IV[2] = Global_IV_Data[2]; |
| 347 | Data.IV[3] = Global_IV_Data[3]; |
| 348 | |
| 349 | // Request the classification firmware download during the initialization |
| 350 | rc = GlobalControl207_Init(true, &Data); |
| 351 | if (rc != EIP207_GLOBAL_CONTROL_NO_ERROR) |
| 352 | { |
| 353 | LOG_CRIT("Adaptar_Global_Init: Classification initialization failed\n"); |
| 354 | return false; |
| 355 | } |
| 356 | |
| 357 | Capabilities.szTextDescription[0] = 0; |
| 358 | |
| 359 | GlobalControl207_Capabilities_Get(&Capabilities); |
| 360 | |
| 361 | LOG_CRIT("Global Classification capabilities: %s\n", |
| 362 | Capabilities.szTextDescription); |
| 363 | |
| 364 | Adapter_Global_Cs_StatusReport(); |
| 365 | |
| 366 | return true; |
| 367 | } |
| 368 | |
| 369 | |
| 370 | /*---------------------------------------------------------------------------- |
| 371 | * Adapter_Global_Cs_UnInit() |
| 372 | * |
| 373 | */ |
| 374 | void |
| 375 | Adapter_Global_Cs_UnInit(void) |
| 376 | { |
| 377 | LOG_INFO("\n\t\t Adapter_Global_Cs_UnInit \n"); |
| 378 | |
| 379 | Adapter_Global_Cs_StatusReport(); |
| 380 | |
| 381 | GlobalControl207_UnInit(); |
| 382 | } |
| 383 | |
| 384 | |
| 385 | /* end of file adapter_global_cs_init.c */ |