ft_base.c (86736B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: ft_base.c 8 * Purpose: The purpose of this file is to set flow 9 * tracker base methods. 10 * Requires: 11 */ 12 13 #include <bcm_int/esw/flowtracker/ft_group.h> 14 #include <bcm_int/esw/flowtracker/ft_export.h> 15 #include <bcm_int/esw/flowtracker/ft_user.h> 16 17 #if defined(BCM_FLOWTRACKER_SUPPORT) 18 19 #ifdef BCM_WARM_BOOT_SUPPORT 20 21 #include <bcm_int/esw/switch.h> 22 23 24 #define BCM_WB_VERSION_1_1 SOC_SCACHE_VERSION(1,1) 25 #define BCM_WB_DEFAULT_VERSION BCM_WB_VERSION_1_1 26 27 28 /* Base FT state - groups, alus, etc.. */ 29 #define BCM_WB_FT_PART_BASE 0 30 /* Export related FT state */ 31 #define BCM_WB_FT_PART_EXPORT 1 32 33 #endif 34 35 uint8 alu_type_str[5][50] = 36 {{"AluLoadTypeLoad8"}, 37 {"AluLoadTypeLoad16"}, 38 {"AluLoadTypeAlu16"}, 39 {"AluLoadTypeAlu32"}, 40 {"AluLoadTypeNone"}}; 41 42 int ft_initialized[BCM_MAX_NUM_UNITS] = {0}; 43 44 /* Group Sw state. */ 45 extern 46 bcmi_ft_group_sw_info_t **bcmi_ft_group_sw_state[BCM_MAX_NUM_UNITS]; 47 /* Group bitmap. */ 48 extern 49 bcmi_ft_group_bitmap_t bcmi_ft_group_bitmap[BCM_MAX_NUM_UNITS]; 50 /*Alu state for wamboot. */ 51 /* There are 4 different types of memories. */ 52 extern 53 alu_load_index_info_t 54 alu_load_index_info[BCM_MAX_NUM_UNITS][BCMI_FT_ALU_LOAD_MEMS]; 55 56 57 /* Global chip debug state. */ 58 bcmi_ft_chip_debug_t chip_debug_info[BCM_MAX_NUM_UNITS]; 59 60 /* Database for TCP state transtition. */ 61 bcmi_ft_state_transtion_t state_transition_data[] = 62 /* tcp_flags[2], cur_state, next_state, new_flow, bidir, ts. */ 63 64 /* TCP. unidirectional, SYN_RCVD. Inactive to listen */ 65 {{{_bcmFieldFtAluDataTcpFlagsSYN, -1}, 0, 1, 1, 0, 0}, 66 /* TCP. unidirectional, ACK_RCVD. connection established. */ 67 {{_bcmFieldFtAluDataTcpFlagsACK, -1}, 1, 2, 0, 0, 1}, 68 /* TCP. Bidirectional, SYN+ACK_RCVD. Connection Established. */ 69 {{_bcmFieldFtAluDataTcpFlagsSYN, _bcmFieldFtAluDataTcpFlagsACK}, 0, 2, -1, -1, 1}, 70 /* TCP. Bidirectional, SYN+ACK_RCVD. Connection established */ 71 {{_bcmFieldFtAluDataTcpFlagsSYN, _bcmFieldFtAluDataTcpFlagsACK}, 1, 2, -1, -1, 1}, 72 /* Establilshed to CLOSE_WAIT. */ 73 {{_bcmFieldFtAluDataTcpFlagsFIN, -1}, 2, 3, -1, -1, 0}, 74 /* TCP. SYN_WAIT to CLOSED. */ 75 {{_bcmFieldFtAluDataTcpFlagsRST, -1}, 1, 0, -1, -1, 1}, 76 /* TCP. CLOSED_WAIT to CLOSED. */ 77 {{_bcmFieldFtAluDataTcpFlagsFIN, -1}, 3, 0, -1, -1, 1}, 78 /* UDP. Connection Established. */ 79 {{-1, -1}, 0, 1, 1, -1, 0}, 80 /* UDP. Connection Established. */ 81 {{-1, -1}, 1, 0, 1, -1, 0}, 82 /* Last entry to mark the end. */ 83 {{-1, -1}, -1, -1, -1, -1, -1}}; 84 85 86 /* 87 * Function: 88 * bcmi_ft_chip_debug_init 89 * Purpose: 90 * Initialize Chip Debug state for flowtracker. 91 * Parameters: 92 * unit - (IN) BCM device id 93 * 94 * Returns: 95 * BCM_E_XXX 96 */ 97 int 98 bcmi_ft_chip_debug_init(int unit) 99 { 100 101 chip_debug_info[unit].num_debug_info = 0; 102 chip_debug_info[unit].param_info = NULL; 103 104 sal_memset(chip_debug_info[unit].alu32_mem_used, 0, 105 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * sizeof(int)); 106 107 sal_memset(chip_debug_info[unit].alu16_mem_used, 0, 108 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * sizeof(int)); 109 110 sal_memset(chip_debug_info[unit].alu32_ref_count, 0, 111 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * sizeof(int)); 112 113 sal_memset(chip_debug_info[unit].alu16_ref_count, 0, 114 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * sizeof(int)); 115 116 117 return BCM_E_NONE; 118 } 119 120 /* 121 * Function: 122 * bcmi_ft_flow_transition_state_init 123 * Purpose: 124 * Initialize State transition state for flowtracker. 125 * Parameters: 126 * unit - (IN) BCM device id 127 * 128 * Returns: 129 * BCM_E_XXX 130 */ 131 int 132 bcmi_ft_flow_transition_state_init(int unit) 133 { 134 135 uint16 alu_data = 0; /* TCP flags container. */ 136 uint16 alu_data_mask = 0x0; 137 uint32 state_transfmt[1]; 138 uint32 state_trans_maskfmt[1]; 139 /* int running_index = 0; */ 140 uint32 cur_state_mask = 0xFF; 141 int offset, bidirectional, new_flow, cur_state, next_state, ts_enable, i; 142 bsc_dt_flex_state_transition_table_entry_t table_entry; 143 soc_mem_t mem; 144 145 i = offset = bidirectional = new_flow = cur_state = next_state = 0; 146 147 sal_memset(state_transfmt, 0, sizeof(uint32)); 148 sal_memset(state_trans_maskfmt, 0, sizeof(uint32)); 149 mem = BSC_DT_FLEX_STATE_TRANSITION_TABLEm; 150 /* 151 * bidirectional. 152 * 153 * INACTIVE(0) -> SYN+direction => LEARN(1) 154 * LEARN -> SYN_ACK + direction => ESTABLISHED(2). 155 * INACTIVE -> SYN_ACK + direction => ESTABLISHED(2). 156 * ESTABLISHED -> <HIT> => ESTABLISHED. 157 * ESTABLISHED -> FIN => INACTIVE 158 * ESTABLISHED -> RST => INACTIVE 159 * LEARN -> FIN => INACTIVE 160 * LEARN -> RST => INACTIVE 161 */ 162 while (state_transition_data[i].current_state != -1) { 163 164 sal_memset(&table_entry, 0, 165 sizeof(bsc_dt_flex_state_transition_table_entry_t)); 166 alu_data_mask = 0; 167 offset = -1; 168 169 if (state_transition_data[i].tcp_flags[0] != -1) { 170 171 BCM_IF_ERROR_RETURN(_bcm_field_ft_alu_data_config_get(unit, -1, 172 state_transition_data[i].tcp_flags[0], &offset, NULL)); 173 174 alu_data_mask = 0xFFFF; 175 alu_data = (1 << offset); 176 } 177 178 if (state_transition_data[i].tcp_flags[1] != -1) { 179 BCM_IF_ERROR_RETURN(_bcm_field_ft_alu_data_config_get(unit, -1, 180 state_transition_data[i].tcp_flags[1], &offset, NULL)); 181 182 alu_data |= (1 << offset); 183 } 184 185 cur_state = state_transition_data[i].current_state; 186 next_state = state_transition_data[i].next_state; 187 new_flow = state_transition_data[i].new_flow; 188 bidirectional = state_transition_data[i].bidirectional; 189 ts_enable = state_transition_data[i].ts_trigger; 190 191 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 192 "cur_state : %d => next_state : %d\n"), cur_state, next_state)); 193 194 /* Set the common data. */ 195 if (new_flow != -1) { 196 soc_format_field32_set(unit, BSC_DT_FLEX_STATE_TRANSITION_IN_BUSfmt, 197 state_transfmt, NEW_FLOW_LEARNEDf, new_flow); 198 199 soc_format_field32_set(unit, BSC_DT_FLEX_STATE_TRANSITION_IN_BUSfmt, 200 state_trans_maskfmt, NEW_FLOW_LEARNEDf, 1); 201 } 202 203 /* Set bidirectional key and mask. */ 204 if (bidirectional != -1) { 205 soc_format_field32_set(unit, BSC_DT_FLEX_STATE_TRANSITION_IN_BUSfmt, 206 state_transfmt, BIDIRECTIONAL_FLOWf, bidirectional); 207 208 soc_format_field32_set(unit, BSC_DT_FLEX_STATE_TRANSITION_IN_BUSfmt, 209 state_trans_maskfmt, BIDIRECTIONAL_FLOWf, 1); 210 } 211 212 /* Till here mask and actual data is same. */ 213 sal_memcpy(state_trans_maskfmt, state_transfmt, sizeof(uint32)); 214 215 /* Set the data. */ 216 soc_format_field32_set(unit, BSC_DT_FLEX_STATE_TRANSITION_IN_BUSfmt, 217 state_transfmt, CURRENT_STATEf, cur_state); 218 219 soc_format_field32_set(unit, BSC_DT_FLEX_STATE_TRANSITION_IN_BUSfmt, 220 state_transfmt, ALU_DATAf, alu_data); 221 222 223 /* Set the mask. */ 224 soc_format_field32_set(unit, BSC_DT_FLEX_STATE_TRANSITION_IN_BUSfmt, 225 state_trans_maskfmt, CURRENT_STATEf, cur_state_mask); 226 227 soc_format_field32_set(unit, BSC_DT_FLEX_STATE_TRANSITION_IN_BUSfmt, 228 state_trans_maskfmt, ALU_DATAf, alu_data_mask); 229 230 soc_mem_field_set(unit, mem, (uint32 *)&table_entry, KEYf, 231 state_transfmt); 232 soc_mem_field_set(unit, mem, (uint32 *)&table_entry, MASKf, 233 state_trans_maskfmt); 234 235 soc_mem_field32_set(unit, mem, (uint32 *)&table_entry, NEXT_STATEf, 236 next_state); 237 238 if (ts_enable > 0) { 239 if (next_state == 0) { 240 /* Connection reset. */ 241 soc_mem_field32_set(unit, mem, (uint32 *)&table_entry, 242 OPAQUE_TS_1_TRIGGERf, 1); 243 } else { 244 /* Connection established. */ 245 soc_mem_field32_set(unit, mem, (uint32 *)&table_entry, 246 OPAQUE_TS_0_TRIGGERf, 1); 247 } 248 } 249 250 /* set the valid bit for this entry. */ 251 soc_mem_field32_set(unit, mem, (uint32 *)&table_entry, VALIDf, 1); 252 253 /* you may also want to set the export enable here. */ 254 BCM_IF_ERROR_RETURN(WRITE_BSC_DT_FLEX_STATE_TRANSITION_TABLEm 255 (unit, MEM_BLOCK_ANY, i, &table_entry)); 256 257 i++; 258 } 259 260 return BCM_E_NONE; 261 } 262 #if 1 263 /* 264 * Function: 265 * bcmi_ft_flow_direction_init 266 * Purpose: 267 * Initialize Flow direction state for flowtracker. 268 * Parameters: 269 * unit - (IN) BCM device id 270 * 271 * Returns: 272 * BCM_E_XXX 273 */ 274 int 275 bcmi_ft_flow_direction_init(int unit) 276 { 277 278 int syn_offset, ack_offset; 279 bsk_kmap_control_0_entry_t kmap0; 280 bsk_kmap_control_1_entry_t kmap1; 281 bsc_dt_kmap_control_3_entry_t kmap3; 282 soc_mem_t mem; 283 284 sal_memset(&kmap0, 0, sizeof(bsk_kmap_control_0_entry_t)); 285 sal_memset(&kmap1, 0, sizeof(bsk_kmap_control_1_entry_t)); 286 sal_memset(&kmap3, 0, sizeof(bsc_dt_kmap_control_3_entry_t)); 287 288 /* 289 * Replicating Arch settings. 290 * KMAP for Key Swapped 291 * From BSK_KMAP_0_KEY_SWAPPED_IN_BUS format, extract and form 4bit value 292 * bit0 = FTFP_POLICY_OPAQUE_0 = bidirectional Flow 293 * bit1 = SRC_GT_DST_RESULT = src < dst 294 * bit2 = FTFP_POLICY_OPAQUE_0 = bidirectional Flow (dummy) 295 * bit3 = SRC_GT_DST_RESULT = src < dst (dummy) 296 * Key_swapped = 1, for 1111 297 */ 298 mem = BSK_KMAP_CONTROL_0m; 299 soc_mem_field32_set(unit, mem, (uint32 *)&kmap0, KMAP_INPUT_SELECT_0f, 4); 300 soc_mem_field32_set(unit, mem, (uint32 *)&kmap0, KMAP_INPUT_SELECT_1f, 7); 301 soc_mem_field32_set(unit, mem, (uint32 *)&kmap0, KMAP_INPUT_SELECT_2f, 4); 302 soc_mem_field32_set(unit, mem, (uint32 *)&kmap0, KMAP_INPUT_SELECT_3f, 7); 303 304 soc_mem_field32_set(unit, mem, (uint32 *)&kmap0, KMAP_CONTROLf, 0x8000); 305 306 /* Write entry into memory. */ 307 BCM_IF_ERROR_RETURN(WRITE_BSK_KMAP_CONTROL_0m(unit, 308 MEM_BLOCK_ANY, 0, &kmap0)); 309 310 /* 311 * KMAP for Key Direction 312 * From BSK_KMAP_1_KEY_DIRECTION_IN_BUS format, extract and form 4bit value 313 * b0 = bidirectional Flow 314 * b1 = Key Swapped 315 * b2 = SYN 316 * b3 = SYN-ACK 317 * Key_direction = 1, for 1011 & 0101 318 */ 319 320 BCM_IF_ERROR_RETURN(_bcm_field_ft_alu_data_config_get(unit, -1, 321 _bcmFieldFtAluDataTcpFlagsSYN, &syn_offset, NULL)); 322 323 BCM_IF_ERROR_RETURN(_bcm_field_ft_alu_data_config_get(unit, -1, 324 _bcmFieldFtAluDataTcpFlagsACK, &ack_offset, NULL)); 325 326 327 mem = BSK_KMAP_CONTROL_1m; 328 soc_mem_field32_set(unit, mem, (uint32 *)&kmap1, KMAP_INPUT_SELECT_0f, 4); 329 soc_mem_field32_set(unit, mem, (uint32 *)&kmap1, KMAP_INPUT_SELECT_1f, 7); 330 soc_mem_field32_set(unit, mem, (uint32 *)&kmap1, KMAP_INPUT_SELECT_2f, 331 syn_offset); 332 soc_mem_field32_set(unit, mem, (uint32 *)&kmap1, KMAP_INPUT_SELECT_3f, 333 ack_offset); 334 335 soc_mem_field32_set(unit, mem, (uint32 *)&kmap0, KMAP_CONTROLf, 0x820); 336 337 /* Write entry into memory. */ 338 BCM_IF_ERROR_RETURN(WRITE_BSK_KMAP_CONTROL_1m(unit, 339 MEM_BLOCK_ANY, 0, &kmap1)); 340 341 342 /* 343 * KMAP for Flow Direction 344 * From BSC_DT_KMAP_3_FLOW_DIRECTION_IN_BUS format, 345 * extract and form 4bit value 346 * b0 = bidirectional Flow 347 * b1 = Key Direction 348 * b2 = Key Swapped 349 * b3 = Key Swapped (dummy) 350 * Flow direction = 1, for 0011 & 1101 351 */ 352 mem = BSC_DT_KMAP_CONTROL_3m; 353 soc_mem_field32_set(unit, mem, (uint32 *)&kmap3, KMAP_INPUT_SELECT_0f, 4); 354 soc_mem_field32_set(unit, mem, (uint32 *)&kmap3, KMAP_INPUT_SELECT_1f, 7); 355 soc_mem_field32_set(unit, mem, (uint32 *)&kmap3, KMAP_INPUT_SELECT_2f, 6); 356 soc_mem_field32_set(unit, mem, (uint32 *)&kmap3, KMAP_INPUT_SELECT_3f, 6); 357 358 soc_mem_field32_set(unit, mem, (uint32 *)&kmap3, KMAP_CONTROLf, 0x2008); 359 360 /* Write entry into memory. */ 361 BCM_IF_ERROR_RETURN(WRITE_BSC_DT_KMAP_CONTROL_3m(unit, 362 MEM_BLOCK_ANY, 0, &kmap3)); 363 364 return BCM_E_NONE; 365 } 366 #endif 367 368 /* 369 * Function: 370 * bcmi_ft_init 371 * Purpose: 372 * Initialize Flowtracker state. 373 * Parameters: 374 * unit - (IN) BCM device id 375 * 376 * Returns: 377 * None. 378 */ 379 int 380 bcmi_ft_init(int unit) 381 { 382 int result = BCM_E_NONE; 383 ft_key_key_attributes_entry_t ft_key_attributes; 384 385 if(!SOC_WARM_BOOT(unit)) { 386 bcmi_ft_cleanup(unit); 387 } 388 389 /* First initiate the group state. */ 390 result = bcmi_ft_group_state_init(unit); 391 if (BCM_FAILURE(result)) { 392 goto cleanup; 393 } 394 395 result = bcmi_ft_export_init(unit); 396 if (BCM_FAILURE(result)) { 397 goto cleanup; 398 } 399 400 result = bcmi_ft_group_profile_init(unit); 401 if (BCM_FAILURE(result)) { 402 goto cleanup; 403 } 404 405 result = bcmi_ft_alu_hash_init(unit); 406 if (BCM_FAILURE(result)) { 407 goto cleanup; 408 } 409 410 result = bcmi_ft_alu_load_init(unit); 411 if (BCM_FAILURE(result)) { 412 goto cleanup; 413 } 414 415 416 result = bcmi_ft_flowchecker_init(unit); 417 if (BCM_FAILURE(result)) { 418 goto cleanup; 419 } 420 421 result = bcmi_ft_flow_transition_state_init(unit); 422 if (BCM_FAILURE(result)) { 423 goto cleanup; 424 } 425 426 result = bcmi_ft_flow_direction_init(unit); 427 if (BCM_FAILURE(result)) { 428 goto cleanup; 429 } 430 431 result = bcmi_ft_chip_debug_init(unit); 432 if (BCM_FAILURE(result)) { 433 goto cleanup; 434 } 435 436 result = bcmi_ft_user_init(unit); 437 if (BCM_FAILURE(result)) { 438 goto cleanup; 439 } 440 441 sal_memset(&ft_key_attributes, 0, sizeof(ft_key_key_attributes_entry_t)); 442 443 /* Key width for single entry in nibles. */ 444 soc_mem_field32_set(unit, FT_KEY_KEY_ATTRIBUTESm, &ft_key_attributes, 445 KEY_WIDTHf, 46); 446 447 result = soc_mem_write(unit, FT_KEY_KEY_ATTRIBUTESm, MEM_BLOCK_ALL, 0, 448 &ft_key_attributes); 449 450 if (BCM_FAILURE(result)) { 451 goto cleanup; 452 } 453 454 /* Set for double entries also. */ 455 soc_mem_field32_set(unit, FT_KEY_KEY_ATTRIBUTESm, &ft_key_attributes, 456 KEY_BASE_WIDTHf, 0x1); 457 458 result = soc_mem_write(unit, FT_KEY_KEY_ATTRIBUTESm, MEM_BLOCK_ALL, 1, 459 &ft_key_attributes); 460 461 if (BCM_FAILURE(result)) { 462 goto cleanup; 463 } 464 465 if (soc_property_get(unit, spn_FLOWTRACKER_CHIP_DEBUG_ENABLE, 0)) { 466 BCMI_FT_CHIP_DEBUG_ENABLE(unit) = 1; 467 } else { 468 BCMI_FT_CHIP_DEBUG_ENABLE(unit) = 0; 469 } 470 471 ft_initialized[unit] = 1; 472 473 #ifdef BCM_WARM_BOOT_SUPPORT 474 if (SOC_WARM_BOOT(unit)) { 475 /* Now that all the initial state is created, recover the data. */ 476 result = bcmi_ft_recover(unit); 477 } else 478 { 479 result = bcmi_ft_warm_boot_alloc(unit); 480 } 481 482 if (BCM_FAILURE(result)) { 483 goto cleanup; 484 } 485 486 #endif /* BCM_WARM_BOOT_SUPPORT */ 487 488 return result; 489 490 cleanup: 491 bcmi_ft_cleanup(unit); 492 493 return result; 494 } 495 496 /* 497 * Function: 498 * bcmi_ft_cleanup 499 * Purpose: 500 * Cleanup Flowtracker state. 501 * Parameters: 502 * unit - (IN) BCM device id 503 * 504 * Returns: 505 * None. 506 */ 507 int 508 bcmi_ft_cleanup(int unit) 509 { 510 511 _bcm_field_ft_group_invalidate(unit); 512 513 bcmi_ft_alu_load_cleanup(unit); 514 515 bcmi_ft_alu_hash_cleanup(unit); 516 517 bcmi_ft_flowchecker_cleanup(unit); 518 519 bcmi_ft_user_cleanup(unit); 520 521 bcmi_ft_export_cleanup(unit); 522 523 bcmi_ft_group_state_clear(unit); 524 525 ft_initialized[unit] = 0; 526 return BCM_E_NONE; 527 528 } 529 530 #ifdef BCM_WARM_BOOT_SUPPORT 531 532 /* 533 * Function: 534 * bcmi_ft_wb_alloc_size 535 * Purpose: 536 * Allocate persistent info memory for flowtracker module 537 * Parameters: 538 * unit - StrataSwitch unit number. 539 * Returns: 540 * BCM_E_XXX 541 */ 542 void 543 bcmi_ft_wb_alloc_size(int unit, int *size) 544 { 545 int alloc_size = 0; 546 int num_groups = 0, id = 0, i=0, j=0; 547 soc_mem_t mem; 548 bcmi_ft_flowchecker_list_t **head = NULL; 549 int length = 0; 550 int num_flowcheckers = 0; 551 int total_indexes_per_mem = 0; 552 553 mem = BSC_KG_GROUP_TABLEm; 554 555 /* total number of groups. */ 556 num_groups = soc_mem_index_count(unit, mem); 557 558 /* Group Valid bits. */ 559 alloc_size += SHR_BITALLOCSIZE(num_groups); 560 561 562 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 563 " Total flowtracker wb size requested = %d \n"), alloc_size)); 564 565 /* start getting the size of each element of group sw state. */ 566 for(; id<num_groups; id++) { 567 568 if (bcmi_ft_group_is_invalid(unit, id)) { 569 continue; 570 } 571 572 /* Allocate space for bcmi_ft_group_config_t. */ 573 alloc_size += sizeof(int); 574 length = BCMI_FT_GROUP_TRACK_PARAM_NUM(unit, id); 575 576 for (i=0; i<length; i++) { 577 alloc_size += sizeof(uint32); 578 alloc_size += sizeof(bcm_flowtracker_tracking_param_type_t); 579 alloc_size += sizeof(bcm_flowtracker_tracking_param_mask_t); 580 } 581 582 /* allocate space for meter info. */ 583 alloc_size += sizeof(int); 584 alloc_size += sizeof(int); 585 586 /* Allocate space for flowchecker list. */ 587 588 /* Get the head of the list. */ 589 head = &(BCMI_FT_GROUP_FLOWCHECKER_HEAD(unit, id)); 590 591 alloc_size += sizeof(int); 592 /* Get the length of list which is equal to number of checks. */ 593 length = bcmi_ft_flowchecker_list_length_get(unit, head); 594 alloc_size += (length * sizeof(bcm_flowtracker_check_t)); 595 596 /* Template_id */ 597 alloc_size += sizeof(int); 598 /* Collector Id. */ 599 alloc_size += sizeof(int); 600 601 /* Group extraction data */ 602 alloc_size += sizeof(int); 603 604 /* Calculate length for the session data. */ 605 length = BCMI_FT_GROUP_EXT_INFO(unit, id).num_data_info; 606 for (i=0; i<length; i++) { 607 /* Key 1 attributes and element type. */ 608 alloc_size += sizeof(int); 609 610 alloc_size += sizeof(int); 611 612 alloc_size += sizeof(int); 613 614 alloc_size += sizeof(bcm_flowtracker_tracking_param_type_t); 615 616 /* Key 2 attributes and element type. */ 617 alloc_size += sizeof(int); 618 619 alloc_size += sizeof(int); 620 621 alloc_size += sizeof(int); 622 623 alloc_size += sizeof(bcm_flowtracker_tracking_param_type_t); 624 625 626 /* action Key attributes and element type. */ 627 alloc_size += sizeof(int); 628 629 alloc_size += sizeof(int); 630 631 alloc_size += sizeof(int); 632 633 alloc_size += sizeof(bcm_flowtracker_tracking_param_type_t); 634 635 /* Flowchecker id. */ 636 alloc_size += sizeof(bcm_flowtracker_check_t); 637 638 /* Alu managament data. */ 639 alloc_size += sizeof(int); 640 641 alloc_size += sizeof(bcmi_ft_alu_load_type_t); 642 } 643 644 /* Group extraction key. */ 645 alloc_size += sizeof(int); 646 /* Calculate length for the session data. */ 647 length = BCMI_FT_GROUP_EXT_INFO(unit, id).num_key_info; 648 for (i=0; i<length; i++) { 649 /* Key 1 attributes and element type. */ 650 alloc_size += sizeof(int); 651 652 alloc_size += sizeof(int); 653 654 alloc_size += sizeof(int); 655 656 alloc_size += sizeof(bcm_flowtracker_tracking_param_type_t); 657 658 /* Key 2 attributes and element type. */ 659 alloc_size += sizeof(int); 660 661 alloc_size += sizeof(int); 662 663 alloc_size += sizeof(int); 664 665 alloc_size += sizeof(bcm_flowtracker_tracking_param_type_t); 666 667 668 /* action Key attributes and element type. */ 669 alloc_size += sizeof(int); 670 671 alloc_size += sizeof(int); 672 673 alloc_size += sizeof(int); 674 675 alloc_size += sizeof(bcm_flowtracker_tracking_param_type_t); 676 677 /* Flowchecker id. */ 678 alloc_size += sizeof(bcm_flowtracker_check_t); 679 680 /* Alu managament data. */ 681 alloc_size += sizeof(int); 682 683 alloc_size += sizeof(bcmi_ft_alu_load_type_t); 684 } 685 686 /* FT Key mode. */ 687 alloc_size += sizeof(bcmi_ft_group_key_data_mode_t); 688 /* FT Data mode. */ 689 alloc_size += sizeof(bcmi_ft_group_key_data_mode_t); 690 691 /* num_ftfp_entries. */ 692 alloc_size += sizeof(int); 693 /* Direction on this group. */ 694 alloc_size += sizeof(int); 695 696 /* flowtracker control on this group. */ 697 alloc_size += sizeof(int); 698 699 /* New learn control on this group. */ 700 alloc_size += sizeof(int); 701 702 703 /* bcmi_ft_group_ftfp_data_t. key, data and alu_data profile. */ 704 alloc_size += sizeof(uint32); 705 alloc_size += sizeof(uint32); 706 alloc_size += sizeof(uint32); 707 708 /* Now storing PDD entry as it can be read from hardware. */ 709 alloc_size += 710 (BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 711 sizeof(uint32)); 712 alloc_size += (BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) 713 * sizeof(uint32)); 714 715 /* Groups Flags */ 716 alloc_size += sizeof(uint32); 717 718 /* Groups Validated status. */ 719 alloc_size += sizeof(int); 720 721 /* Save Groups timestamp triggers. */ 722 alloc_size += sizeof(uint32); 723 724 725 } /* End of per group sw state */ 726 727 728 /* Allocate state for flowtracker checks. */ 729 /* for now number of flowcheckers is same as groups. */ 730 731 /* Now allocated which group is being used. */ 732 num_flowcheckers = num_groups; 733 734 /* Allocate state for primary and secondary check refcounts. */ 735 alloc_size += ((num_flowcheckers) * sizeof(uint32)); 736 737 /* Allocate space to save indexes for flowcheckers. */ 738 alloc_size += SHR_BITALLOCSIZE(num_flowcheckers); 739 740 for (id=0; id<num_flowcheckers; id++) { 741 if (!(SHR_BITGET(BCMI_FT_FLOWCHECKER_BITMAP(unit), id))) { 742 /* If the particular id is not set then do not save state. */ 743 continue; 744 } 745 /* Allocate space for bcmi_flowtracker_flowchecker_info_t */ 746 747 /* top level Flags */ 748 alloc_size += sizeof(uint32); 749 750 /* Check-1 flags. */ 751 alloc_size += sizeof(uint32); 752 /* Check-1 element. */ 753 alloc_size += sizeof(bcm_flowtracker_export_element_type_t); 754 /* Check-1 min_value. */ 755 alloc_size += sizeof(int); 756 /* Check-1 max_value. */ 757 alloc_size += sizeof(int); 758 /* Check-1 operation. */ 759 alloc_size += sizeof(bcm_flowtracker_check_operation_t); 760 761 /* Check-2 flags. */ 762 alloc_size += sizeof(uint32); 763 /* Check-2 element. */ 764 alloc_size += sizeof(bcm_flowtracker_export_element_type_t); 765 /* Check-2 min_value. */ 766 alloc_size += sizeof(int); 767 /* Check-2 max_value. */ 768 alloc_size += sizeof(int); 769 /* Check-2 operation. */ 770 alloc_size += sizeof(bcm_flowtracker_check_operation_t); 771 772 /* Action element. */ 773 alloc_size += sizeof(bcm_flowtracker_export_element_type_t); 774 /* action. */ 775 alloc_size += sizeof(bcm_flowtracker_check_action_t); 776 777 /* export threshold. */ 778 alloc_size += sizeof(int); 779 /* operation. */ 780 alloc_size += sizeof(bcm_flowtracker_check_operation_t); 781 782 } 783 784 /* Allocate space for alu memory. */ 785 for (i=bcmiFtAluLoadTypeLoad8; i<bcmiFtAluLoadTypeNone; i++) { 786 total_indexes_per_mem = 0; 787 for (j=0; j<alu_load_index_info[unit][i].total_mem_count; j++) { 788 789 790 alu_load_index_info[unit][i].alu_load_info[j].mem_size = 791 soc_mem_index_count( 792 unit, alu_load_index_info[unit][i].alu_load_info[j].mem); 793 794 total_indexes_per_mem += 795 alu_load_index_info[unit][i].alu_load_info[j].mem_size; 796 797 } 798 /* Index bitmap for each alu index. */ 799 alloc_size += SHR_BITALLOCSIZE(total_indexes_per_mem); 800 } 801 802 /* Chip debug Count data. */ 803 /* if feature is enabled. */ 804 alloc_size += sizeof(int); 805 806 if (BCMI_FT_CHIP_DEBUG_ENABLE(unit)) { 807 /* Number of chip debug objects. */ 808 alloc_size += sizeof(int); 809 810 /* memory size of chip debug parameters. */ 811 length = BCMI_FT_CHIP_DEBUG_INFO(unit).num_debug_info; 812 alloc_size += (length * sizeof(bcmi_ft_chip_debug_param_t)); 813 814 /* ALU32 used status. */ 815 alloc_size += 816 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * sizeof(int); 817 818 /* ALU16 used status. */ 819 alloc_size += BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 820 sizeof(int); 821 822 /* ALU32 ref count. */ 823 alloc_size += 824 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * sizeof(int); 825 826 /* ALU16 ref count. */ 827 alloc_size += BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 828 sizeof(int); 829 830 /* Space for installed status of group. */ 831 alloc_size += sizeof(int); 832 } 833 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 834 " Total flowtracker wb size requested = %d \n"), alloc_size)); 835 836 /* Return the calculated size. */ 837 *size = alloc_size; 838 839 return; 840 841 } 842 843 int 844 bcmi_ft_warm_boot_alloc(int unit) 845 { 846 847 soc_scache_handle_t scache_handle; 848 uint8 *ft_scache_ptr; 849 int size = 0; 850 int rv = BCM_E_NONE; 851 852 bcmi_ft_wb_alloc_size(unit, &size); 853 854 SOC_SCACHE_HANDLE_SET(scache_handle, unit, BCM_MODULE_FLOWTRACKER, BCM_WB_FT_PART_BASE); 855 rv = _bcm_esw_scache_ptr_get(unit, scache_handle, TRUE, 856 size, &ft_scache_ptr, 857 BCM_WB_DEFAULT_VERSION, NULL); 858 859 if (BCM_E_NOT_FOUND == rv) { 860 /* Proceed with Level 1 Warm Boot */ 861 rv = BCM_E_NONE; 862 } 863 864 if (BCM_SUCCESS(rv)) { 865 SOC_SCACHE_HANDLE_SET(scache_handle, unit, BCM_MODULE_FLOWTRACKER, BCM_WB_FT_PART_EXPORT); 866 rv = bcmi_ft_export_warmboot_alloc(unit, scache_handle); 867 } 868 869 return rv; 870 871 } 872 873 /* 874 * Function: 875 * bcmi_ft_sync 876 * Purpose: 877 * Sync flowtracker state. 878 * Parameters: 879 * unit - (IN) BCM device id 880 * 881 * Returns: 882 * BCM_E_XXX 883 */ 884 int 885 bcmi_ft_sync(int unit) 886 { 887 888 int size = 0; 889 int num_groups = 0, id = 0, i=0, j=0; 890 soc_mem_t mem; 891 bcmi_ft_flowchecker_list_t **head = NULL; 892 soc_scache_handle_t scache_handle; 893 uint8 *ft_scache_ptr; 894 bcmi_ft_flowchecker_list_t *fc_temp = NULL; 895 int length = 0; 896 int num_flowcheckers = 0; 897 bcmi_ft_group_alu_info_t *temp=NULL; 898 bcm_flowtracker_tracking_param_info_t *t_info=NULL; 899 int total_indexes_per_mem = 0; 900 901 /* Initialize the memory. */ 902 mem = BSC_KG_GROUP_TABLEm; 903 904 /* total number of groups. */ 905 num_groups = soc_mem_index_count(unit, mem); 906 num_flowcheckers = num_groups; 907 908 /* Get the size to save warmboot state. */ 909 bcmi_ft_wb_alloc_size(unit, &size); 910 911 912 SOC_SCACHE_HANDLE_SET(scache_handle, unit, BCM_MODULE_FLOWTRACKER, BCM_WB_FT_PART_BASE); 913 BCM_IF_ERROR_RETURN 914 (_bcm_esw_scache_ptr_get(unit, scache_handle, FALSE, 915 size, &ft_scache_ptr, 916 BCM_WB_DEFAULT_VERSION, NULL)); 917 918 919 /* Do you want to keep some space on top for somethine. */ 920 921 /* start getting the size of each element of group sw state. */ 922 for(; id<num_groups; id++) { 923 924 if (bcmi_ft_group_is_invalid(unit, id)) { 925 continue; 926 } 927 928 /* Save tracking parametrs. */ 929 sal_memcpy(ft_scache_ptr, &(BCMI_FT_GROUP_TRACK_PARAM_NUM(unit, id)), 930 sizeof(int)); 931 ft_scache_ptr += sizeof(int); 932 length = BCMI_FT_GROUP_TRACK_PARAM_NUM(unit, id); 933 t_info = BCMI_FT_GROUP_TRACK_PARAM(unit, id); 934 935 for (i=0; i<length; i++) { 936 sal_memcpy(ft_scache_ptr, &t_info->flags, sizeof(uint32)); 937 ft_scache_ptr += sizeof(uint32); 938 939 sal_memcpy(ft_scache_ptr, &t_info->param, 940 sizeof(bcm_flowtracker_tracking_param_type_t)); 941 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 942 943 sal_memcpy(ft_scache_ptr, &t_info->mask, 944 sizeof(bcm_flowtracker_tracking_param_type_t)); 945 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_mask_t); 946 t_info++; 947 } 948 949 /* Save meter related information. */ 950 sal_memcpy(ft_scache_ptr, 951 &BCMI_FT_GROUP_METER_INFO(unit, id).sw_ckbits_sec, 952 sizeof(uint32)); 953 ft_scache_ptr += sizeof(uint32); 954 955 sal_memcpy(ft_scache_ptr, 956 &BCMI_FT_GROUP_METER_INFO(unit, id).sw_ckbits_burst, 957 sizeof(uint32)); 958 ft_scache_ptr += sizeof(uint32); 959 960 961 /* Save information for flowchecker lists. */ 962 /* Get the head of the list. */ 963 head = &(BCMI_FT_GROUP_FLOWCHECKER_HEAD(unit, id)); 964 965 /* Get the length of list which is equal to number of checks. */ 966 length = bcmi_ft_flowchecker_list_length_get(unit, head); 967 968 sal_memcpy(ft_scache_ptr, &length, sizeof(int)); 969 ft_scache_ptr += sizeof(int); 970 971 /* Put head into local variable for traverse. */ 972 fc_temp = (*head); 973 974 while(fc_temp) { 975 sal_memcpy(ft_scache_ptr, &fc_temp->flowchecker_id, 976 sizeof(bcm_flowtracker_check_t)); 977 ft_scache_ptr += sizeof(bcm_flowtracker_check_t); 978 fc_temp = fc_temp->next; 979 } 980 981 /* Save template id. */ 982 sal_memcpy(ft_scache_ptr, &BCMI_FT_GROUP(unit, id)->template_id, 983 sizeof(uint32)); 984 ft_scache_ptr += sizeof(uint32); 985 986 /* Save collector id. */ 987 sal_memcpy(ft_scache_ptr, &BCMI_FT_GROUP(unit, id)->collector_id, 988 sizeof(uint32)); 989 ft_scache_ptr += sizeof(uint32); 990 991 992 /* Save Groups extraction information. 993 * 994 * Session Data. 995 */ 996 sal_memcpy(ft_scache_ptr, 997 &BCMI_FT_GROUP_EXT_INFO(unit, id).num_data_info, sizeof(int)); 998 ft_scache_ptr += sizeof(int); 999 1000 /* Calculate length for the session data. */ 1001 length = BCMI_FT_GROUP_EXT_INFO(unit, id).num_data_info; 1002 temp = BCMI_FT_GROUP_EXT_DATA_INFO(unit, id); 1003 for (i=0; i<length; i++) { 1004 1005 /* Key 1 attributes and element type. */ 1006 sal_memcpy(ft_scache_ptr, &(temp->key1.location), sizeof(int)); 1007 ft_scache_ptr += sizeof(int); 1008 1009 sal_memcpy(ft_scache_ptr, &(temp->key1.length), sizeof(int)); 1010 ft_scache_ptr += sizeof(int); 1011 1012 sal_memcpy(ft_scache_ptr, &(temp->key1.is_alu), sizeof(int)); 1013 ft_scache_ptr += sizeof(int); 1014 1015 sal_memcpy(ft_scache_ptr, &(temp->element_type1), sizeof(int)); 1016 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1017 1018 /* Key 2 attributes and element type. */ 1019 sal_memcpy(ft_scache_ptr, &(temp->key2.location), sizeof(int)); 1020 ft_scache_ptr += sizeof(int); 1021 1022 sal_memcpy(ft_scache_ptr, &(temp->key2.length), sizeof(int)); 1023 ft_scache_ptr += sizeof(int); 1024 1025 sal_memcpy(ft_scache_ptr, &(temp->key2.is_alu), sizeof(int)); 1026 ft_scache_ptr += sizeof(int); 1027 1028 sal_memcpy(ft_scache_ptr, &(temp->element_type2), sizeof(int)); 1029 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1030 1031 /* action Key attributes and element type. */ 1032 sal_memcpy(ft_scache_ptr, &(temp->action_key.location), 1033 sizeof(int)); 1034 ft_scache_ptr += sizeof(int); 1035 1036 sal_memcpy(ft_scache_ptr, &(temp->action_key.length), sizeof(int)); 1037 ft_scache_ptr += sizeof(int); 1038 1039 sal_memcpy(ft_scache_ptr, &(temp->action_key.is_alu), sizeof(int)); 1040 ft_scache_ptr += sizeof(int); 1041 1042 sal_memcpy(ft_scache_ptr, &(temp->action_element_type), 1043 sizeof(int)); 1044 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1045 1046 /* Flowchecker id. */ 1047 sal_memcpy(ft_scache_ptr, &(temp->flowchecker_id), sizeof(int)); 1048 ft_scache_ptr += sizeof(bcm_flowtracker_check_t); 1049 1050 /* Alu managament data. */ 1051 sal_memcpy(ft_scache_ptr, &(temp->alu_load_index), sizeof(int)); 1052 ft_scache_ptr += sizeof(int); 1053 1054 sal_memcpy(ft_scache_ptr, &(temp->alu_load_type), sizeof(int)); 1055 ft_scache_ptr += sizeof(bcmi_ft_alu_load_type_t); 1056 temp++; 1057 } 1058 1059 /* 1060 * Session key. 1061 */ 1062 1063 sal_memcpy(ft_scache_ptr, 1064 &BCMI_FT_GROUP_EXT_INFO(unit, id).num_key_info, sizeof(int)); 1065 ft_scache_ptr += sizeof(int); 1066 1067 /* Calculate length for the session key. */ 1068 length = BCMI_FT_GROUP_EXT_INFO(unit, id).num_key_info; 1069 temp = BCMI_FT_GROUP_EXT_KEY_INFO(unit, id); 1070 for (i=0; i<length; i++) { 1071 1072 /* Key 1 attributes and element type. */ 1073 sal_memcpy(ft_scache_ptr, &(temp->key1.location), sizeof(int)); 1074 ft_scache_ptr += sizeof(int); 1075 1076 sal_memcpy(ft_scache_ptr, &(temp->key1.length), sizeof(int)); 1077 ft_scache_ptr += sizeof(int); 1078 1079 sal_memcpy(ft_scache_ptr, &(temp->key1.is_alu), sizeof(int)); 1080 ft_scache_ptr += sizeof(int); 1081 1082 sal_memcpy(ft_scache_ptr, &(temp->element_type1), sizeof(int)); 1083 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1084 1085 /* Key 2 attributes and element type. */ 1086 sal_memcpy(ft_scache_ptr, &(temp->key2.location), sizeof(int)); 1087 ft_scache_ptr += sizeof(int); 1088 1089 sal_memcpy(ft_scache_ptr, &(temp->key2.length), sizeof(int)); 1090 ft_scache_ptr += sizeof(int); 1091 1092 sal_memcpy(ft_scache_ptr, &(temp->key2.is_alu), sizeof(int)); 1093 ft_scache_ptr += sizeof(int); 1094 1095 sal_memcpy(ft_scache_ptr, &(temp->element_type2), sizeof(int)); 1096 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1097 1098 /* action Key attributes and element type. */ 1099 sal_memcpy(ft_scache_ptr, &(temp->action_key.location), 1100 sizeof(int)); 1101 ft_scache_ptr += sizeof(int); 1102 1103 sal_memcpy(ft_scache_ptr, &(temp->action_key.length), sizeof(int)); 1104 ft_scache_ptr += sizeof(int); 1105 1106 sal_memcpy(ft_scache_ptr, &(temp->action_key.is_alu), sizeof(int)); 1107 ft_scache_ptr += sizeof(int); 1108 1109 sal_memcpy(ft_scache_ptr, &(temp->action_element_type), 1110 sizeof(int)); 1111 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1112 1113 /* Flowchecker id. */ 1114 sal_memcpy(ft_scache_ptr, &(temp->flowchecker_id), sizeof(int)); 1115 ft_scache_ptr += sizeof(bcm_flowtracker_check_t); 1116 1117 /* Alu managament data. */ 1118 sal_memcpy(ft_scache_ptr, &(temp->alu_load_index), sizeof(int)); 1119 ft_scache_ptr += sizeof(int); 1120 1121 sal_memcpy(ft_scache_ptr, &(temp->alu_load_type), sizeof(int)); 1122 ft_scache_ptr += sizeof(bcmi_ft_alu_load_type_t); 1123 temp++; 1124 } 1125 1126 /* Session key mode. */ 1127 sal_memcpy(ft_scache_ptr, 1128 &BCMI_FT_GROUP_EXT_HW_INFO(unit, id).ft_key_mode, 1129 sizeof(bcmi_ft_group_key_data_mode_t)); 1130 ft_scache_ptr += sizeof(bcmi_ft_group_key_data_mode_t); 1131 1132 /* Session data mode. */ 1133 sal_memcpy(ft_scache_ptr, 1134 &BCMI_FT_GROUP_EXT_HW_INFO(unit, id).ft_data_mode, 1135 sizeof(bcmi_ft_group_key_data_mode_t)); 1136 ft_scache_ptr += sizeof(bcmi_ft_group_key_data_mode_t); 1137 1138 /* Save total ftfp entries on this group. */ 1139 sal_memcpy(ft_scache_ptr, &BCMI_FT_GROUP(unit, id)->num_ftfp_entries, 1140 sizeof(uint32)); 1141 ft_scache_ptr += sizeof(uint32); 1142 1143 /* Direction on this group. */ 1144 sal_memcpy(ft_scache_ptr, &BCMI_FT_GROUP_FTFP_DATA(unit, id).direction, 1145 sizeof(int)); 1146 ft_scache_ptr += sizeof(int); 1147 1148 /* flowtracker control on this group. */ 1149 sal_memcpy(ft_scache_ptr, &BCMI_FT_GROUP_FTFP_DATA(unit, id).flowtrack, 1150 sizeof(int)); 1151 ft_scache_ptr += sizeof(int); 1152 1153 /* New learn control on this group. */ 1154 sal_memcpy(ft_scache_ptr, &BCMI_FT_GROUP_FTFP_DATA(unit, id).new_learn, 1155 sizeof(int)); 1156 ft_scache_ptr += sizeof(int); 1157 1158 /* FTFP Data. Profile indexes. */ 1159 sal_memcpy(ft_scache_ptr, 1160 &BCMI_FT_GROUP_FTFP_DATA(unit, id).profiles.session_key_profile_idx, 1161 sizeof(uint32)); 1162 ft_scache_ptr += sizeof(uint32); 1163 1164 sal_memcpy(ft_scache_ptr, 1165 &BCMI_FT_GROUP_FTFP_DATA(unit, id).profiles.session_data_profile_idx, 1166 sizeof(uint32)); 1167 ft_scache_ptr += sizeof(uint32); 1168 1169 sal_memcpy(ft_scache_ptr, 1170 &BCMI_FT_GROUP_FTFP_DATA(unit, id).profiles.alu_data_profile_idx, 1171 sizeof(uint32)); 1172 ft_scache_ptr += sizeof(uint32); 1173 1174 1175 /* Save the PDD entry here. Read the template head. */ 1176 1177 /* Save Groups ALU allocation status. */ 1178 sal_memcpy(ft_scache_ptr, (BCMI_FT_GROUP(unit, id)->ALU32_MEM_USE), 1179 (BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 1180 sizeof(uint32))); 1181 1182 ft_scache_ptr += 1183 (BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 1184 sizeof(uint32)); 1185 1186 sal_memcpy(ft_scache_ptr, (BCMI_FT_GROUP(unit, id)->ALU16_MEM_USE), 1187 (BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 1188 sizeof(uint32))); 1189 1190 ft_scache_ptr += 1191 (BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 1192 sizeof(uint32)); 1193 1194 /* Save Group Flags */ 1195 sal_memcpy(ft_scache_ptr, &(BCMI_FT_GROUP(unit, id)->flags), 1196 sizeof(uint32)); 1197 ft_scache_ptr += sizeof(uint32); 1198 1199 /* Save Validate */ 1200 sal_memcpy(ft_scache_ptr, &(BCMI_FT_GROUP(unit, id)->validated), 1201 (sizeof(int))); 1202 ft_scache_ptr += sizeof(int); 1203 1204 /* Save Groups timestamp triggers. */ 1205 sal_memcpy(ft_scache_ptr, &(BCMI_FT_GROUP_TS_TRIGGERS(unit, id)), 1206 (sizeof(uint32))); 1207 ft_scache_ptr += sizeof(uint32); 1208 1209 1210 /* Create Template Head list here. */ 1211 1212 1213 } /* Save state for each Group. */ 1214 1215 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, 1216 (BSL_META_U(unit, "Group state Synced. \n"))); 1217 1218 /* Now save state for flowcheckers. */ 1219 1220 /* Save ref-count state. */ 1221 1222 sal_memcpy(ft_scache_ptr, 1223 bcmi_ft_flowchecker_state[unit].fc_idx_refcount, 1224 (num_flowcheckers * sizeof(uint32))); 1225 ft_scache_ptr += (num_flowcheckers * sizeof(uint32)); 1226 1227 /* Allocate space to save indexes for flowcheckers. */ 1228 sal_memcpy(ft_scache_ptr, BCMI_FT_FLOWCHECKER_BITMAP(unit), 1229 SHR_BITALLOCSIZE(num_flowcheckers)); 1230 ft_scache_ptr += SHR_BITALLOCSIZE(num_flowcheckers); 1231 1232 for (id=0; id<num_flowcheckers; id++) { 1233 if (!(SHR_BITGET(BCMI_FT_FLOWCHECKER_BITMAP(unit), id))) { 1234 /* If the particular id is not set then do not save state. */ 1235 continue; 1236 } 1237 1238 sal_memcpy(ft_scache_ptr, 1239 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->flags, 1240 sizeof(uint32)); 1241 ft_scache_ptr += sizeof(uint32); 1242 1243 /* Check-1 info */ 1244 sal_memcpy(ft_scache_ptr, 1245 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->check1.flags, 1246 sizeof(uint32)); 1247 ft_scache_ptr += sizeof(int); 1248 1249 sal_memcpy(ft_scache_ptr, 1250 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->check1.param, 1251 sizeof(bcm_flowtracker_export_element_type_t)); 1252 ft_scache_ptr += sizeof(bcm_flowtracker_export_element_type_t); 1253 1254 sal_memcpy(ft_scache_ptr, 1255 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->check1.min_value, 1256 sizeof(int)); 1257 ft_scache_ptr += sizeof(int); 1258 1259 sal_memcpy(ft_scache_ptr, 1260 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->check1.max_value, 1261 sizeof(int)); 1262 ft_scache_ptr += sizeof(int); 1263 1264 sal_memcpy(ft_scache_ptr, 1265 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->check1.operation, 1266 sizeof(bcm_flowtracker_check_operation_t)); 1267 ft_scache_ptr += sizeof(bcm_flowtracker_check_operation_t); 1268 1269 /* Check-2 Info */ 1270 sal_memcpy(ft_scache_ptr, 1271 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->check2.flags, 1272 sizeof(uint32)); 1273 ft_scache_ptr += sizeof(int); 1274 1275 sal_memcpy(ft_scache_ptr, 1276 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->check2.param, 1277 sizeof(bcm_flowtracker_export_element_type_t)); 1278 ft_scache_ptr += sizeof(bcm_flowtracker_export_element_type_t); 1279 1280 sal_memcpy(ft_scache_ptr, 1281 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->check2.min_value, 1282 sizeof(int)); 1283 ft_scache_ptr += sizeof(int); 1284 1285 sal_memcpy(ft_scache_ptr, 1286 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->check2.max_value, 1287 sizeof(int)); 1288 ft_scache_ptr += sizeof(int); 1289 1290 sal_memcpy(ft_scache_ptr, 1291 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->check2.operation, 1292 sizeof(bcm_flowtracker_check_operation_t)); 1293 ft_scache_ptr += sizeof(bcm_flowtracker_check_operation_t); 1294 1295 /* Action info */ 1296 sal_memcpy(ft_scache_ptr, 1297 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->action_info.param, 1298 sizeof(bcm_flowtracker_export_element_type_t)); 1299 ft_scache_ptr += sizeof(bcm_flowtracker_export_element_type_t); 1300 1301 sal_memcpy(ft_scache_ptr, 1302 &BCMI_FT_FLOWCHECKER_INFO(unit, id)->action_info.action, 1303 sizeof(bcm_flowtracker_check_action_t)); 1304 ft_scache_ptr += sizeof(bcm_flowtracker_check_action_t); 1305 1306 /* Export Info */ 1307 sal_memcpy(ft_scache_ptr, 1308 &(BCMI_FT_FLOWCHECKER_INFO(unit, id)-> 1309 export_info.export_check_threshold), 1310 sizeof(int)); 1311 ft_scache_ptr += sizeof(int); 1312 1313 sal_memcpy(ft_scache_ptr, 1314 &(BCMI_FT_FLOWCHECKER_INFO(unit, id)->export_info.operation), 1315 sizeof(bcm_flowtracker_check_operation_t)); 1316 ft_scache_ptr += sizeof(bcm_flowtracker_check_operation_t); 1317 1318 } 1319 1320 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, 1321 (BSL_META_U(unit, "Flowchecker state synced. \n"))); 1322 1323 for (i=bcmiFtAluLoadTypeLoad8; i<bcmiFtAluLoadTypeNone; i++) { 1324 1325 total_indexes_per_mem = 0; 1326 for (j=0; j<alu_load_index_info[unit][i].total_mem_count; j++) { 1327 1328 1329 alu_load_index_info[unit][i].alu_load_info[j].mem_size = 1330 soc_mem_index_count( 1331 unit, alu_load_index_info[unit][i].alu_load_info[j].mem); 1332 1333 total_indexes_per_mem += 1334 alu_load_index_info[unit][i].alu_load_info[j].mem_size; 1335 1336 } 1337 sal_memcpy(ft_scache_ptr, alu_load_index_info[unit][i].index_bitmap, 1338 SHR_BITALLOCSIZE(total_indexes_per_mem)); 1339 } 1340 1341 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, 1342 (BSL_META_U(unit, "Alu-Load state synced. \n"))); 1343 1344 1345 /* Sync chip debug information. */ 1346 sal_memcpy(ft_scache_ptr, &BCMI_FT_CHIP_DEBUG_ENABLE(unit), 1347 sizeof(int)); 1348 1349 ft_scache_ptr += sizeof(int); 1350 1351 if (BCMI_FT_CHIP_DEBUG_ENABLE(unit)) { 1352 /* Sync chip debug information. */ 1353 sal_memcpy(ft_scache_ptr, &BCMI_FT_CHIP_DEBUG_INFO(unit).num_debug_info, 1354 sizeof(int)); 1355 ft_scache_ptr += sizeof(int); 1356 1357 length = BCMI_FT_CHIP_DEBUG_INFO(unit).num_debug_info; 1358 1359 /* Sync chip debug information. */ 1360 sal_memcpy(ft_scache_ptr, BCMI_FT_CHIP_DEBUG_PARAM_INFO(unit), 1361 length * sizeof(bcmi_ft_chip_debug_param_t)); 1362 1363 ft_scache_ptr += (length * sizeof(bcmi_ft_chip_debug_param_t)); 1364 1365 sal_memcpy(ft_scache_ptr, BCMI_FT_CHIP_DEBUG_INFO(unit).alu32_mem_used, 1366 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 1367 sizeof(int)); 1368 ft_scache_ptr += 1369 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * sizeof(int); 1370 1371 sal_memcpy(ft_scache_ptr, BCMI_FT_CHIP_DEBUG_INFO(unit).alu16_mem_used, 1372 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 1373 sizeof(int)); 1374 ft_scache_ptr += 1375 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 1376 sizeof(int); 1377 1378 sal_memcpy(ft_scache_ptr, BCMI_FT_CHIP_DEBUG_INFO(unit).alu32_ref_count, 1379 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 1380 sizeof(int)); 1381 ft_scache_ptr += 1382 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 1383 sizeof(int); 1384 1385 sal_memcpy(ft_scache_ptr, BCMI_FT_CHIP_DEBUG_INFO(unit).alu16_ref_count, 1386 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 1387 sizeof(int)); 1388 ft_scache_ptr += 1389 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 1390 sizeof(int); 1391 1392 } 1393 1394 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, 1395 (BSL_META_U(unit, "Chip Debug State Synced. \n"))); 1396 1397 /* Export database warmboot */ 1398 SOC_SCACHE_HANDLE_SET(scache_handle, unit, BCM_MODULE_FLOWTRACKER, BCM_WB_FT_PART_EXPORT); 1399 BCM_IF_ERROR_RETURN(bcmi_ft_export_warmboot_sync(unit, scache_handle)); 1400 1401 1402 return BCM_E_NONE; 1403 } 1404 1405 1406 /* 1407 * Function: 1408 * bcmi_ft_group_sw_reinstall 1409 * Purpose: 1410 * Recover Group's Sw state. 1411 * Parameters: 1412 * unit - (IN) BCM device id 1413 * 1414 * Returns: 1415 * BCM_E_XXX 1416 */ 1417 int 1418 bcmi_ft_group_sw_reinstall(int unit, bcm_flowtracker_group_t id) 1419 { 1420 int rv = BCM_E_NONE; 1421 int num_alus_loads = 0, i=0; 1422 bcmi_ft_group_alu_info_t *temp = NULL; 1423 int load16_idz[TOTAL_GROUP_LOAD16_DATA_NUM]; 1424 int load8_idz[TOTAL_GROUP_LOAD8_DATA_NUM]; 1425 int num_load_16=0, num_load_8=0; 1426 bcmi_ft_alu_load_type_t type = bcmiFtAluLoadTypeNone; 1427 int total_load8_mem = TOTAL_GROUP_LOAD8_DATA_NUM; 1428 int total_load16_mem = TOTAL_GROUP_LOAD16_DATA_NUM; 1429 1430 if (!BCMI_FT_GROUP_IS_VALIDATED(unit, id)) { 1431 return BCM_E_NONE; 1432 } 1433 1434 /* Read the group state for the ALU inforamtion. */ 1435 if (!(BCMI_FT_GROUP_EXT_DATA_OR_TS_TRIGGERS_SET(unit, id))) { 1436 return BCM_E_INTERNAL; 1437 } 1438 1439 for (; i<total_load16_mem; i++) { 1440 load16_idz[i] = -1; 1441 1442 if (i<total_load8_mem) { 1443 load8_idz[i] = -1; 1444 } 1445 } 1446 1447 /* assign the ALU memory chunk to local pointer. */ 1448 temp = BCMI_FT_GROUP_EXT_DATA_INFO(unit, id); 1449 /* Get total number of alus in this chunk. */ 1450 num_alus_loads = (BCMI_FT_GROUP_EXT_INFO(unit, id)).num_data_info; 1451 1452 /* allocate the bitmap based on the type, length */ 1453 for (i=0; i<num_alus_loads; i++) { 1454 1455 /* Now get the type of the memory and take action. */ 1456 type = temp->alu_load_type; 1457 1458 1459 if (type == bcmiFtAluLoadTypeLoad16) { 1460 load16_idz[num_load_16] = i; 1461 num_load_16++; 1462 if (num_load_16 > total_load16_mem) { 1463 rv = BCM_E_PARAM; 1464 goto cleanup; 1465 } 1466 temp++; 1467 /* We do not need to do anything here. */ 1468 continue; 1469 } else if (type == bcmiFtAluLoadTypeLoad8 ) { 1470 load8_idz[num_load_8] = i; 1471 num_load_8++; 1472 if (num_load_8 > total_load8_mem) { 1473 rv = BCM_E_PARAM; 1474 goto cleanup; 1475 } 1476 temp++; 1477 /* We do not need to do anything here. */ 1478 continue; 1479 } 1480 /* Configure the ALU memory. */ 1481 rv = bcmi_ft_group_alu_load_wb_recover(unit, id, temp, 1482 NULL, NULL, type); 1483 1484 CLEANUP_ON_ERROR(rv); 1485 1486 /* Set that index into the group table. */ 1487 temp++; 1488 } 1489 1490 /* 1491 * The upper loop has created the ALU indexes and wrote into them. 1492 * Now we need to set the load profiles based on the indices 1493 * that we created above. 1494 * If there is no load information then no need to configure load memories. 1495 */ 1496 if (load16_idz[0] != -1) { 1497 /* Configure the Load16 sw state. */ 1498 rv = bcmi_ft_group_alu_load_wb_recover(unit, id, NULL, 1499 load16_idz, NULL, bcmiFtAluLoadTypeLoad16); 1500 CLEANUP_ON_ERROR(rv); 1501 } 1502 1503 if (load8_idz[0] != -1) { 1504 /* Configure the Load8 sw state. */ 1505 rv = bcmi_ft_group_alu_load_wb_recover(unit, id, NULL, 1506 NULL, load8_idz, bcmiFtAluLoadTypeLoad8); 1507 1508 CLEANUP_ON_ERROR(rv); 1509 1510 } 1511 /* Add the pdd/pde policy entry. */ 1512 rv = bcmi_ft_pdd_policy_profile_recover(unit, id); 1513 CLEANUP_ON_ERROR(rv); 1514 1515 /* Add the pdd/pde policy entry. */ 1516 rv = bcmi_ft_group_profile_recover(unit, id); 1517 CLEANUP_ON_ERROR(rv); 1518 1519 /* Create template information list. */ 1520 rv = bcmi_ft_group_template_data_create(unit, id, load16_idz, load8_idz); 1521 CLEANUP_ON_ERROR(rv); 1522 1523 /* Add the Session profiles entry */ 1524 rv = _bcm_field_ft_session_profiles_recover(unit, id); 1525 CLEANUP_ON_ERROR(rv); 1526 1527 return BCM_E_NONE; 1528 1529 cleanup : 1530 bcmi_ft_group_hw_uninstall(unit, id); 1531 return rv; 1532 } 1533 1534 /* 1535 * Function: 1536 * bcmi_ft_group_profile_recover 1537 * Purpose: 1538 * Recover profile entries of Group. 1539 * Parameters: 1540 * unit - (IN) BCM device id 1541 * id - (IN) FT group id. 1542 * 1543 * Returns: 1544 * BCM_E_XXX 1545 */ 1546 int 1547 bcmi_ft_group_profile_recover( 1548 int unit, bcm_flowtracker_group_t id) 1549 { 1550 uint32 index = 0; 1551 1552 bsc_kg_group_table_entry_t kg_group_entry; 1553 bsc_dg_group_table_entry_t dg_group_entry; 1554 1555 sal_memset(&kg_group_entry, 0, sizeof(bsc_kg_group_table_entry_t)); 1556 sal_memset(&dg_group_entry, 0, sizeof(bsc_dg_group_table_entry_t)); 1557 1558 /* First read the group entry. */ 1559 BCM_IF_ERROR_RETURN (soc_mem_read(unit, BSC_KG_GROUP_TABLEm, 1560 MEM_BLOCK_ANY, id, &kg_group_entry)); 1561 BCM_IF_ERROR_RETURN (soc_mem_read(unit, BSC_DG_GROUP_TABLEm, 1562 MEM_BLOCK_ANY, id, &dg_group_entry)); 1563 1564 /* Recover Age profile. */ 1565 /* Get associated index from the group. */ 1566 index = soc_mem_field32_get(unit, BSC_KG_GROUP_TABLEm, 1567 ((uint32 *)&kg_group_entry), AGE_OUT_PROFILE_IDXf); 1568 1569 BCM_IF_ERROR_RETURN( 1570 bcmi_ft_group_age_profile_refcount_set(unit, index)); 1571 1572 1573 /* Recover Flow limit or exceed profile. */ 1574 /* Get associated index from the group. */ 1575 index = soc_mem_field32_get(unit, BSC_KG_GROUP_TABLEm, 1576 ((uint32 *)&kg_group_entry), FLOW_EXCEED_PROFILE_IDXf); 1577 1578 BCM_IF_ERROR_RETURN( 1579 bcmi_ft_group_flow_limit_profile_refcount_set(unit, index)); 1580 1581 1582 /* Recover Collector copy profile. */ 1583 /* Get associated index from the group. */ 1584 index = soc_mem_field32_get(unit, BSC_DG_GROUP_TABLEm, 1585 ((uint32 *)&dg_group_entry), COPY_TO_COLLECTOR_PROFILE_IDXf); 1586 1587 BCM_IF_ERROR_RETURN( 1588 bcmi_ft_group_collector_copy_profile_refcount_set(unit, index)); 1589 1590 1591 /* Recover Meter profile. */ 1592 /* Get associated index from the group. */ 1593 index = soc_mem_field32_get(unit, BSC_DG_GROUP_TABLEm, 1594 ((uint32 *)&dg_group_entry), GROUP_METER_PROFILE_IDXf); 1595 1596 BCM_IF_ERROR_RETURN( 1597 bcmi_ft_group_meter_profile_refcount_set(unit, index)); 1598 1599 1600 /* now write this index into the group. */ 1601 index = soc_mem_field32_get(unit, BSC_KG_GROUP_TABLEm, 1602 ((uint32 *)&kg_group_entry), SESSION_DATA_TYPEf); 1603 1604 BCM_IF_ERROR_RETURN( 1605 bcmi_ft_group_pdd_profile_refcount_set(unit, index)); 1606 1607 /* Recover Timestamp profiles. */ 1608 index = soc_mem_field32_get(unit, BSC_DG_GROUP_TABLEm, 1609 ((uint32 *)&dg_group_entry), TIMESTAMP_PROFILE_IDXf); 1610 1611 BCM_IF_ERROR_RETURN( 1612 bcmi_ft_group_timestamp_profile_refcount_set(unit, index)); 1613 1614 return BCM_E_NONE; 1615 } 1616 1617 /* 1618 * Function: 1619 * bcmi_ft_recover 1620 * Purpose: 1621 * Recover flowtracker state. 1622 * Parameters: 1623 * unit - (IN) BCM device id 1624 * 1625 * Returns: 1626 * BCM_E_XXX 1627 */ 1628 1629 int 1630 bcmi_ft_recover(int unit) 1631 { 1632 1633 int num_groups = 0, id = 0, i=0, j=0; 1634 soc_mem_t mem; 1635 bcmi_ft_flowchecker_list_t **head = NULL; 1636 bsc_kg_group_table_entry_t kg_group_entry; 1637 soc_scache_handle_t scache_handle; 1638 uint8 *ft_scache_ptr; 1639 int length = 0; 1640 bcm_flowtracker_check_t flowchecker_id; 1641 int stable_size = 0; 1642 uint16 recovered_ver = 0; 1643 int num_flowcheckers = 0; 1644 int pdd_index = 0; 1645 bcmi_ft_group_alu_info_t * temp=NULL; 1646 bcm_flowtracker_tracking_param_info_t *t_info=NULL; 1647 int total_indexes_per_mem = 0; 1648 1649 SOC_SCACHE_HANDLE_SET(scache_handle, unit, BCM_MODULE_FLOWTRACKER, BCM_WB_FT_PART_BASE); 1650 SOC_IF_ERROR_RETURN(soc_stable_size_get(unit, &stable_size)); 1651 1652 if (stable_size <= 0) { /* Limited and Extended recovery only */ 1653 /* No warmboot recovery possible. */ 1654 return BCM_E_NONE; 1655 } 1656 1657 /* Get the scache start address where the information is stored. */ 1658 SOC_IF_ERROR_RETURN(_bcm_esw_scache_ptr_get(unit, scache_handle, FALSE, 1659 0, &ft_scache_ptr, BCM_WB_DEFAULT_VERSION, &recovered_ver)); 1660 1661 mem = BSC_KG_GROUP_TABLEm; 1662 /* total number of groups. */ 1663 num_groups = soc_mem_index_count(unit, mem); 1664 num_flowcheckers = num_groups; 1665 1666 /* start getting the size of each element of group sw state. */ 1667 for(; id<num_groups; id++) { 1668 1669 sal_memset(&kg_group_entry, 0, sizeof(bsc_kg_group_table_entry_t)); 1670 1671 /* First read the group entry. */ 1672 BCM_IF_ERROR_RETURN (soc_mem_read(unit, BSC_KG_GROUP_TABLEm, 1673 MEM_BLOCK_ANY, id, &kg_group_entry)); 1674 1675 /* Do it only for groups which are valid. Get VALID bit from hardware.*/ 1676 if (!(soc_mem_field32_get(unit, BSC_KG_GROUP_TABLEm, &kg_group_entry, 1677 GROUP_VALIDf))) { 1678 1679 continue; 1680 } 1681 1682 /* now write this index into the group. */ 1683 pdd_index = soc_mem_field32_get(unit, BSC_KG_GROUP_TABLEm, 1684 ((uint32 *)&kg_group_entry), SESSION_DATA_TYPEf); 1685 1686 /* Set the group state here. */ 1687 SHR_BITSET(BCMI_FT_GROUP_BITMAP(unit), id); 1688 1689 /* Allocate the sw state for this group first. */ 1690 BCMI_FT_GROUP(unit, id) = (bcmi_ft_group_sw_info_t *) 1691 sal_alloc(sizeof(bcmi_ft_group_sw_info_t), 1692 "flowtracker group sw state"); 1693 1694 if (BCMI_FT_GROUP(unit, id) == NULL) { 1695 return BCM_E_MEMORY; 1696 } 1697 1698 /* memset everything to zero. */ 1699 sal_memset(BCMI_FT_GROUP(unit, id), 0, 1700 sizeof(bcmi_ft_group_sw_info_t)); 1701 1702 1703 /* Save tracking parametrs. */ 1704 sal_memcpy(&(BCMI_FT_GROUP_TRACK_PARAM_NUM(unit, id)), ft_scache_ptr, 1705 sizeof(int)); 1706 ft_scache_ptr += sizeof(int); 1707 1708 BCMI_FT_GROUP_TRACK_PARAM(unit, id) = 1709 (bcm_flowtracker_tracking_param_info_t *) 1710 sal_alloc((sizeof(bcm_flowtracker_tracking_param_info_t) * 1711 BCMI_FT_GROUP_TRACK_PARAM_NUM(unit, id)), 1712 "flowtracker group tracking parameters"); 1713 1714 if (BCMI_FT_GROUP_TRACK_PARAM(unit, id) == NULL) { 1715 return BCM_E_MEMORY; 1716 } 1717 1718 length = BCMI_FT_GROUP_TRACK_PARAM_NUM(unit, id); 1719 t_info = BCMI_FT_GROUP_TRACK_PARAM(unit, id); 1720 1721 for (i=0; i<length; i++) { 1722 sal_memcpy(&t_info->flags, ft_scache_ptr, sizeof(uint32)); 1723 ft_scache_ptr += sizeof(uint32); 1724 1725 sal_memcpy(&t_info->param, ft_scache_ptr, 1726 sizeof(bcm_flowtracker_tracking_param_type_t)); 1727 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1728 1729 sal_memcpy(&t_info->mask, ft_scache_ptr, 1730 sizeof(bcm_flowtracker_tracking_param_type_t)); 1731 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_mask_t); 1732 t_info++; 1733 } 1734 1735 /* Save meter related information. */ 1736 sal_memcpy(&BCMI_FT_GROUP_METER_INFO(unit, id).sw_ckbits_sec, 1737 ft_scache_ptr, sizeof(uint32)); 1738 ft_scache_ptr += sizeof(uint32); 1739 1740 sal_memcpy(&BCMI_FT_GROUP_METER_INFO(unit, id).sw_ckbits_burst, 1741 ft_scache_ptr, sizeof(uint32)); 1742 ft_scache_ptr += sizeof(uint32); 1743 1744 1745 /* Save information for flowchecker lists. */ 1746 /* Get the head of the list. */ 1747 head = &(BCMI_FT_GROUP_FLOWCHECKER_HEAD(unit, id)); 1748 1749 /* Get the length of list which is equal to number of checks. */ 1750 sal_memcpy(&length, ft_scache_ptr, sizeof(int)); 1751 ft_scache_ptr += sizeof(int); 1752 1753 for (i=0; i<length; i++) { 1754 sal_memcpy(&flowchecker_id, ft_scache_ptr, 1755 sizeof(bcm_flowtracker_check_t)); 1756 1757 BCM_IF_ERROR_RETURN( 1758 bcmi_ft_flowchecker_list_add(unit, head, flowchecker_id)); 1759 ft_scache_ptr += sizeof(bcm_flowtracker_check_t); 1760 } 1761 1762 sal_memcpy(&BCMI_FT_GROUP(unit, id)->template_id, ft_scache_ptr, 1763 sizeof(uint32)); 1764 ft_scache_ptr += sizeof(uint32); 1765 1766 sal_memcpy(&BCMI_FT_GROUP(unit, id)->collector_id, ft_scache_ptr, 1767 sizeof(uint32)); 1768 ft_scache_ptr += sizeof(uint32); 1769 1770 /* Recover Groups extraction information. 1771 * 1772 * Session Data. 1773 */ 1774 sal_memcpy(&BCMI_FT_GROUP_EXT_INFO(unit, id).num_data_info, 1775 ft_scache_ptr, sizeof(int)); 1776 ft_scache_ptr += sizeof(int); 1777 1778 1779 length = BCMI_FT_GROUP_EXT_INFO(unit, id).num_data_info; 1780 1781 if (length > 0) { 1782 /* allocate space needed to save this state in group. */ 1783 BCMI_FT_GROUP_EXT_DATA_INFO(unit, id) = 1784 (bcmi_ft_group_alu_info_t *) sal_alloc(length * 1785 sizeof(bcmi_ft_group_alu_info_t), "Group alu info."); 1786 1787 if (BCMI_FT_GROUP_EXT_DATA_INFO(unit, id) == NULL) { 1788 return BCM_E_MEMORY; 1789 } 1790 } 1791 1792 temp = BCMI_FT_GROUP_EXT_DATA_INFO(unit, id); 1793 for (i=0; i<length; i++) { 1794 1795 /* Key 1 attributes and element type. */ 1796 sal_memcpy(&(temp->key1.location), ft_scache_ptr, sizeof(int)); 1797 ft_scache_ptr += sizeof(int); 1798 1799 sal_memcpy(&(temp->key1.length), ft_scache_ptr, sizeof(int)); 1800 ft_scache_ptr += sizeof(int); 1801 1802 sal_memcpy(&(temp->key1.is_alu), ft_scache_ptr, sizeof(int)); 1803 ft_scache_ptr += sizeof(int); 1804 1805 sal_memcpy(&(temp->element_type1), ft_scache_ptr, sizeof(int)); 1806 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1807 1808 /* Key 2 attributes and element type. */ 1809 sal_memcpy(&(temp->key2.location), ft_scache_ptr, sizeof(int)); 1810 ft_scache_ptr += sizeof(int); 1811 1812 sal_memcpy(&(temp->key2.length), ft_scache_ptr, sizeof(int)); 1813 ft_scache_ptr += sizeof(int); 1814 1815 sal_memcpy(&(temp->key2.is_alu), ft_scache_ptr, sizeof(int)); 1816 ft_scache_ptr += sizeof(int); 1817 1818 sal_memcpy(&(temp->element_type2), ft_scache_ptr, sizeof(int)); 1819 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1820 1821 /* action Key attributes and element type. */ 1822 sal_memcpy(&(temp->action_key.location), ft_scache_ptr, sizeof(int)); 1823 ft_scache_ptr += sizeof(int); 1824 1825 sal_memcpy(&(temp->action_key.length), ft_scache_ptr, sizeof(int)); 1826 ft_scache_ptr += sizeof(int); 1827 1828 sal_memcpy(&(temp->action_key.is_alu), ft_scache_ptr, sizeof(int)); 1829 ft_scache_ptr += sizeof(int); 1830 1831 sal_memcpy(&(temp->action_element_type), ft_scache_ptr, sizeof(int)); 1832 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1833 1834 /* Flowchecker id. */ 1835 sal_memcpy(&(temp->flowchecker_id), ft_scache_ptr, sizeof(int)); 1836 ft_scache_ptr += sizeof(bcm_flowtracker_check_t); 1837 1838 /* Alu managament data. */ 1839 sal_memcpy(&(temp->alu_load_index), ft_scache_ptr, sizeof(int)); 1840 ft_scache_ptr += sizeof(int); 1841 1842 sal_memcpy(&(temp->alu_load_type), ft_scache_ptr, sizeof(int)); 1843 ft_scache_ptr += sizeof(bcmi_ft_alu_load_type_t); 1844 temp++; 1845 } 1846 1847 /* 1848 * Session key. 1849 */ 1850 1851 sal_memcpy(&BCMI_FT_GROUP_EXT_INFO(unit, id).num_key_info, 1852 ft_scache_ptr, sizeof(int)); 1853 1854 ft_scache_ptr += sizeof(int); 1855 1856 /* Calculate length for the session key. */ 1857 length = BCMI_FT_GROUP_EXT_INFO(unit, id).num_key_info; 1858 1859 /* allocate space needed to save this state in group. */ 1860 BCMI_FT_GROUP_EXT_KEY_INFO(unit, id) = 1861 (bcmi_ft_group_alu_info_t *) sal_alloc(length * 1862 sizeof(bcmi_ft_group_alu_info_t), "Group alu info."); 1863 1864 if (BCMI_FT_GROUP_EXT_KEY_INFO(unit, id)== NULL) { 1865 return BCM_E_MEMORY; 1866 } 1867 1868 temp = BCMI_FT_GROUP_EXT_KEY_INFO(unit, id); 1869 for (i=0; i<length; i++) { 1870 1871 /* Key 1 attributes and element type. */ 1872 sal_memcpy(&(temp->key1.location), ft_scache_ptr, sizeof(int)); 1873 ft_scache_ptr += sizeof(int); 1874 1875 sal_memcpy(&(temp->key1.length), ft_scache_ptr, sizeof(int)); 1876 ft_scache_ptr += sizeof(int); 1877 1878 sal_memcpy(&(temp->key1.is_alu), ft_scache_ptr, sizeof(int)); 1879 ft_scache_ptr += sizeof(int); 1880 1881 sal_memcpy(&(temp->element_type1), ft_scache_ptr, sizeof(int)); 1882 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1883 1884 /* Key 2 attributes and element type. */ 1885 sal_memcpy(&(temp->key2.location), ft_scache_ptr, sizeof(int)); 1886 ft_scache_ptr += sizeof(int); 1887 1888 sal_memcpy(&(temp->key2.length), ft_scache_ptr, sizeof(int)); 1889 ft_scache_ptr += sizeof(int); 1890 1891 sal_memcpy(&(temp->key2.is_alu), ft_scache_ptr, sizeof(int)); 1892 ft_scache_ptr += sizeof(int); 1893 1894 sal_memcpy(&(temp->element_type2), ft_scache_ptr, sizeof(int)); 1895 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1896 1897 /* action Key attributes and element type. */ 1898 sal_memcpy(&(temp->action_key.location), ft_scache_ptr, sizeof(int)); 1899 ft_scache_ptr += sizeof(int); 1900 1901 sal_memcpy(&(temp->action_key.length), ft_scache_ptr, sizeof(int)); 1902 ft_scache_ptr += sizeof(int); 1903 1904 sal_memcpy(&(temp->action_key.is_alu), ft_scache_ptr, sizeof(int)); 1905 ft_scache_ptr += sizeof(int); 1906 1907 sal_memcpy(&(temp->action_element_type), ft_scache_ptr, sizeof(int)); 1908 ft_scache_ptr += sizeof(bcm_flowtracker_tracking_param_type_t); 1909 1910 /* Flowchecker id. */ 1911 sal_memcpy(&(temp->flowchecker_id), ft_scache_ptr, sizeof(int)); 1912 ft_scache_ptr += sizeof(bcm_flowtracker_check_t); 1913 1914 /* Alu managament data. */ 1915 sal_memcpy(&(temp->alu_load_index), ft_scache_ptr, sizeof(int)); 1916 ft_scache_ptr += sizeof(int); 1917 1918 sal_memcpy(&(temp->alu_load_type), ft_scache_ptr, sizeof(int)); 1919 ft_scache_ptr += sizeof(bcmi_ft_alu_load_type_t); 1920 temp++; 1921 } 1922 1923 /* Session key mode. */ 1924 sal_memcpy(&BCMI_FT_GROUP_EXT_HW_INFO(unit, id).ft_key_mode, 1925 ft_scache_ptr, sizeof(bcmi_ft_group_key_data_mode_t)); 1926 BCMI_FT_GROUP_FTFP_DATA(unit, id).session_key_mode = 1927 BCMI_FT_GROUP_EXT_HW_INFO(unit, id).ft_key_mode; 1928 ft_scache_ptr += sizeof(bcmi_ft_group_key_data_mode_t); 1929 1930 /* Session data mode. */ 1931 sal_memcpy(&BCMI_FT_GROUP_EXT_HW_INFO(unit, id).ft_data_mode, 1932 ft_scache_ptr, sizeof(bcmi_ft_group_key_data_mode_t)); 1933 ft_scache_ptr += sizeof(bcmi_ft_group_key_data_mode_t); 1934 1935 /* ftfp entries on this group. */ 1936 sal_memcpy(&BCMI_FT_GROUP(unit, id)->num_ftfp_entries, ft_scache_ptr, 1937 sizeof(int)); 1938 ft_scache_ptr += sizeof(uint32); 1939 1940 /* Direction on this group. */ 1941 sal_memcpy(&BCMI_FT_GROUP_FTFP_DATA(unit, id).direction, ft_scache_ptr, 1942 sizeof(int)); 1943 ft_scache_ptr += sizeof(int); 1944 1945 /* flowtracker control on this group. */ 1946 sal_memcpy(&BCMI_FT_GROUP_FTFP_DATA(unit, id).flowtrack, ft_scache_ptr, 1947 sizeof(int)); 1948 ft_scache_ptr += sizeof(int); 1949 1950 /* New learn control on this group. */ 1951 sal_memcpy(&BCMI_FT_GROUP_FTFP_DATA(unit, id).new_learn, 1952 ft_scache_ptr, sizeof(int)); 1953 ft_scache_ptr += sizeof(int); 1954 1955 /* FTFP data . profiles. */ 1956 sal_memcpy(&BCMI_FT_GROUP_FTFP_DATA(unit, id). 1957 profiles.session_key_profile_idx, ft_scache_ptr, 1958 sizeof(uint32)); 1959 ft_scache_ptr += sizeof(uint32); 1960 1961 sal_memcpy(&BCMI_FT_GROUP_FTFP_DATA(unit, id). 1962 profiles.session_data_profile_idx, ft_scache_ptr, 1963 sizeof(uint32)); 1964 ft_scache_ptr += sizeof(uint32); 1965 1966 sal_memcpy(&BCMI_FT_GROUP_FTFP_DATA(unit, id). 1967 profiles.alu_data_profile_idx, ft_scache_ptr, 1968 sizeof(uint32)); 1969 ft_scache_ptr += sizeof(uint32); 1970 1971 1972 /* Recover ALU32 usage. */ 1973 sal_memcpy((BCMI_FT_GROUP(unit, id)->ALU32_MEM_USE), ft_scache_ptr, 1974 (BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 1975 sizeof(uint32))); 1976 ft_scache_ptr += 1977 (BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 1978 sizeof(uint32)); 1979 1980 /* Recover ALU16 usage. */ 1981 sal_memcpy((BCMI_FT_GROUP(unit, id)->ALU16_MEM_USE), ft_scache_ptr, 1982 (BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 1983 sizeof(uint32))); 1984 ft_scache_ptr += 1985 (BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 1986 sizeof(uint32)); 1987 1988 /* Recover Group Flags */ 1989 sal_memcpy(&(BCMI_FT_GROUP(unit, id)->flags), ft_scache_ptr, 1990 sizeof(uint32)); 1991 ft_scache_ptr += sizeof(uint32); 1992 1993 /* Recover Groups Validated status. */ 1994 sal_memcpy(&(BCMI_FT_GROUP(unit, id)->validated), ft_scache_ptr, 1995 (sizeof(int))); 1996 ft_scache_ptr += sizeof(int); 1997 1998 /* Recover Timestamp triggers. */ 1999 sal_memcpy(&(BCMI_FT_GROUP_TS_TRIGGERS(unit, id)), ft_scache_ptr, 2000 (sizeof(uint32))); 2001 ft_scache_ptr += sizeof(uint32); 2002 2003 2004 if (BCMI_FT_GROUP_IS_VALIDATED(unit, id)) { 2005 BCM_IF_ERROR_RETURN(soc_mem_read(unit, BSD_POLICY_ACTION_PROFILEm, 2006 MEM_BLOCK_ANY, pdd_index, 2007 (&(BCMI_FT_GROUP(unit, id)->pdd_entry)))); 2008 2009 } 2010 2011 } /* END of group state. */ 2012 /* 2013 * Start flowcheckr state recovery. 2014 */ 2015 2016 sal_memcpy(bcmi_ft_flowchecker_state[unit].fc_idx_refcount, 2017 ft_scache_ptr, 2018 (num_flowcheckers * sizeof(uint32))); 2019 ft_scache_ptr += (num_flowcheckers * sizeof(uint32)); 2020 2021 sal_memcpy(BCMI_FT_FLOWCHECKER_BITMAP(unit), ft_scache_ptr, 2022 SHR_BITALLOCSIZE(num_flowcheckers)); 2023 ft_scache_ptr += SHR_BITALLOCSIZE(num_flowcheckers); 2024 2025 for (id=0; id<num_flowcheckers; id++) { 2026 if (!(SHR_BITGET(BCMI_FT_FLOWCHECKER_BITMAP(unit), id))) { 2027 /* If the particular id is not set then do not save state. */ 2028 continue; 2029 } 2030 2031 /* Allocate memory for the new flowchecker. */ 2032 BCMI_FT_FLOWCHECKER_INFO(unit, id) = 2033 (bcmi_flowtracker_flowchecker_info_t *) 2034 sal_alloc(sizeof(bcmi_flowtracker_flowchecker_info_t), 2035 "flowtracker info"); 2036 2037 if (BCMI_FT_FLOWCHECKER_INFO(unit, id) == NULL) { 2038 return BCM_E_MEMORY; 2039 } 2040 2041 /* Rather than doing memcpy, we should actually set each element. */ 2042 sal_memset(BCMI_FT_FLOWCHECKER_INFO(unit, id), 0, 2043 sizeof(bcmi_flowtracker_flowchecker_info_t)); 2044 2045 /* Software memory is created. Now start populating the state. */ 2046 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->flags, 2047 ft_scache_ptr, 2048 sizeof(uint32)); 2049 ft_scache_ptr += sizeof(uint32); 2050 2051 /* Check-1 info */ 2052 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->check1.flags, 2053 ft_scache_ptr, 2054 sizeof(uint32)); 2055 ft_scache_ptr += sizeof(int); 2056 2057 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->check1.param, 2058 ft_scache_ptr, 2059 sizeof(bcm_flowtracker_export_element_type_t)); 2060 ft_scache_ptr += sizeof(bcm_flowtracker_export_element_type_t); 2061 2062 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->check1.min_value, 2063 ft_scache_ptr, sizeof(int)); 2064 ft_scache_ptr += sizeof(int); 2065 2066 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->check1.max_value, 2067 ft_scache_ptr, sizeof(int)); 2068 ft_scache_ptr += sizeof(int); 2069 2070 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->check1.operation, 2071 ft_scache_ptr, sizeof(bcm_flowtracker_check_operation_t)); 2072 ft_scache_ptr += sizeof(bcm_flowtracker_check_operation_t); 2073 2074 /* Check-2 info */ 2075 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->check2.flags, 2076 ft_scache_ptr, 2077 sizeof(uint32)); 2078 ft_scache_ptr += sizeof(int); 2079 2080 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->check2.param, 2081 ft_scache_ptr, 2082 sizeof(bcm_flowtracker_export_element_type_t)); 2083 ft_scache_ptr += sizeof(bcm_flowtracker_export_element_type_t); 2084 2085 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->check2.min_value, 2086 ft_scache_ptr, sizeof(int)); 2087 ft_scache_ptr += sizeof(int); 2088 2089 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->check2.max_value, 2090 ft_scache_ptr, sizeof(int)); 2091 ft_scache_ptr += sizeof(int); 2092 2093 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->check2.operation, 2094 ft_scache_ptr, sizeof(bcm_flowtracker_check_operation_t)); 2095 ft_scache_ptr += sizeof(bcm_flowtracker_check_operation_t); 2096 2097 /* Action info */ 2098 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->action_info.param, 2099 ft_scache_ptr, sizeof(bcm_flowtracker_export_element_type_t)); 2100 2101 ft_scache_ptr += sizeof(bcm_flowtracker_export_element_type_t); 2102 2103 2104 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)->action_info.action, 2105 ft_scache_ptr, sizeof(bcm_flowtracker_check_action_t)); 2106 ft_scache_ptr += sizeof(bcm_flowtracker_check_action_t); 2107 2108 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)-> 2109 export_info.export_check_threshold, ft_scache_ptr, 2110 sizeof(int)); 2111 ft_scache_ptr += sizeof(int); 2112 2113 /* Export info */ 2114 sal_memcpy(&BCMI_FT_FLOWCHECKER_INFO(unit, id)-> 2115 export_info.operation, 2116 ft_scache_ptr, sizeof(bcm_flowtracker_check_operation_t)); 2117 ft_scache_ptr += sizeof(bcm_flowtracker_check_operation_t); 2118 2119 } /* END : flowchecker information. */ 2120 2121 for (i=bcmiFtAluLoadTypeLoad8; i<bcmiFtAluLoadTypeNone; i++) { 2122 2123 total_indexes_per_mem = 0; 2124 for (j=0; j<alu_load_index_info[unit][i].total_mem_count; j++) { 2125 2126 2127 alu_load_index_info[unit][i].alu_load_info[j].mem_size = 2128 soc_mem_index_count( 2129 unit, alu_load_index_info[unit][i].alu_load_info[j].mem); 2130 2131 total_indexes_per_mem += 2132 alu_load_index_info[unit][i].alu_load_info[j].mem_size; 2133 2134 } 2135 sal_memcpy(alu_load_index_info[unit][i].index_bitmap, ft_scache_ptr, 2136 SHR_BITALLOCSIZE(total_indexes_per_mem)); 2137 } 2138 2139 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, 2140 (BSL_META_U(unit, "Alu-Load state synced. \n"))); 2141 2142 2143 /* Sync chip debug information. */ 2144 sal_memcpy(&BCMI_FT_CHIP_DEBUG_ENABLE(unit), ft_scache_ptr, 2145 sizeof(int)); 2146 2147 ft_scache_ptr += sizeof(int); 2148 2149 if (BCMI_FT_CHIP_DEBUG_ENABLE(unit)) { 2150 /* Sync chip debug information. */ 2151 sal_memcpy(&BCMI_FT_CHIP_DEBUG_INFO(unit).num_debug_info, ft_scache_ptr, 2152 sizeof(int)); 2153 ft_scache_ptr += sizeof(int); 2154 2155 length = BCMI_FT_CHIP_DEBUG_INFO(unit).num_debug_info; 2156 2157 2158 BCMI_FT_CHIP_DEBUG_PARAM_INFO(unit) = 2159 (bcmi_ft_chip_debug_param_t *) 2160 sal_alloc((sizeof(bcmi_ft_chip_debug_param_t) * length), 2161 "flowtracker chip debug information."); 2162 2163 /* Sync chip debug information. */ 2164 sal_memcpy(BCMI_FT_CHIP_DEBUG_PARAM_INFO(unit), ft_scache_ptr, 2165 length * sizeof(bcmi_ft_chip_debug_param_t)); 2166 2167 ft_scache_ptr += (length * sizeof(bcmi_ft_chip_debug_param_t)); 2168 2169 sal_memcpy(BCMI_FT_CHIP_DEBUG_INFO(unit).alu32_mem_used, ft_scache_ptr, 2170 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 2171 sizeof(int)); 2172 ft_scache_ptr += 2173 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 2174 sizeof(int); 2175 2176 sal_memcpy(BCMI_FT_CHIP_DEBUG_INFO(unit).alu16_mem_used, ft_scache_ptr, 2177 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 2178 sizeof(int)); 2179 ft_scache_ptr += 2180 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 2181 sizeof(int); 2182 2183 sal_memcpy(BCMI_FT_CHIP_DEBUG_INFO(unit).alu32_ref_count, ft_scache_ptr, 2184 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 2185 sizeof(int)); 2186 ft_scache_ptr += 2187 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu32) * 2188 sizeof(int); 2189 2190 sal_memcpy(BCMI_FT_CHIP_DEBUG_INFO(unit).alu16_ref_count, ft_scache_ptr, 2191 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 2192 sizeof(int)); 2193 ft_scache_ptr += 2194 BCMI_FT_ALU_LOAD_MEM_COUNT(unit, bcmiFtAluLoadTypeAlu16) * 2195 sizeof(int); 2196 2197 } 2198 2199 2200 /* 2201 * Now that we have recovered all the state from scache, 2202 * we can independtly set the other sw state information 2203 * from this. 2204 */ 2205 /* start getting the size of each element of group sw state. */ 2206 for(id=0; id<num_groups; id++) { 2207 2208 if (bcmi_ft_group_is_invalid(unit, id)) { 2209 continue; 2210 } 2211 2212 BCM_IF_ERROR_RETURN(bcmi_ft_group_sw_reinstall(unit, id)); 2213 } 2214 2215 /* Export database warmboot */ 2216 SOC_SCACHE_HANDLE_SET(scache_handle, unit, BCM_MODULE_FLOWTRACKER, BCM_WB_FT_PART_EXPORT); 2217 BCM_IF_ERROR_RETURN(bcmi_ft_export_warmboot_recover(unit, scache_handle)); 2218 2219 return BCM_E_NONE; 2220 } 2221 2222 /* 2223 * Function: 2224 * bcmi_ft_group_alu_load_wb_recover 2225 * Purpose: 2226 * Warmboot recovery for alu/load sw state. 2227 * Parameters: 2228 * unit - (IN) BCM device id 2229 * id - (IN) FT group id. 2230 * info - (IN) ALU information of group. 2231 * load16_indexes - (IN) Load 16 indexes in group 2232 * load8_indexes - (IN) Load 8 indexes in group 2233 * alu_load_type - (IN) ALU/LOAD type. 2234 * 2235 * Returns: 2236 * BCM_E_XXX 2237 */ 2238 int 2239 bcmi_ft_group_alu_load_wb_recover( 2240 int unit, bcm_flowtracker_group_t id, 2241 bcmi_ft_group_alu_info_t *info, 2242 int *load16_indexes, 2243 int *load8_indexes, 2244 bcmi_ft_alu_load_type_t alu_load_type) 2245 { 2246 2247 int rv = BCM_E_NONE; 2248 int *indexes = NULL; 2249 bcmi_ft_group_alu_info_t *temp = NULL; 2250 bcmi_ft_group_alu_info_t *local = NULL; 2251 int index = -1; 2252 2253 if ((alu_load_type == bcmiFtAluLoadTypeLoad16) || 2254 (alu_load_type == bcmiFtAluLoadTypeLoad8)) { 2255 2256 indexes = ((alu_load_type == bcmiFtAluLoadTypeLoad16) ? 2257 load16_indexes : load8_indexes); 2258 2259 temp = BCMI_FT_GROUP_EXT_DATA_INFO(unit, id); 2260 2261 local = (&(temp[indexes[0]])); 2262 index = local->alu_load_index; 2263 2264 } else { 2265 index = info->alu_load_index; 2266 temp = info; 2267 } 2268 2269 /* 2270 * Insert the hash entry. 2271 * Below coverity error says that indexes can be passed NULL. 2272 * it is passed NULL only for ALU memories and are used 2273 * only for LOAD memories. so no harm. 2274 */ 2275 /* coverity[var_deref_model] */ 2276 rv = bcmi_ft_alu_hash_insert(unit, id, alu_load_type, temp, indexes, 2277 &index); 2278 2279 if (BCM_FAILURE(rv)) { 2280 if (rv == BCM_E_EXISTS) { 2281 /* Increment ref count and set up group table. */ 2282 BCMI_FT_ALU_LOAD_REFCOUNT_INCR(unit, alu_load_type, index); 2283 /* bcmi_ft_alu_load_mem_index_get 2284 (unit, index, bcmiFtAluLoadTypeAlu16, &new_index, &mem, &a_idx);*/ 2285 rv = BCM_E_NONE; 2286 } else { 2287 return rv; 2288 } 2289 } else { 2290 2291 2292 /* Assign the bitmap to this index. */ 2293 SHR_BITSET((BCMI_FT_ALU_LOAD_BITMAP(unit, alu_load_type)), 2294 index); 2295 2296 /* Also increment the ref count on this index. */ 2297 BCMI_FT_ALU_LOAD_REFCOUNT_INCR(unit, alu_load_type, index); 2298 } 2299 2300 return rv; 2301 } 2302 2303 /* 2304 * Function: 2305 * bcmi_ft_pdd_policy_profile_recover 2306 * Purpose: 2307 * Recover PDD profile entry. 2308 * Parameters: 2309 * unit - (IN) BCM device id 2310 * id - (IN) FT group id. 2311 * 2312 * Returns: 2313 * BCM_E_XXX 2314 */ 2315 int 2316 bcmi_ft_pdd_policy_profile_recover( 2317 int unit, bcm_flowtracker_group_t id) 2318 { 2319 2320 2321 bsc_kg_group_table_entry_t kg_group_entry; 2322 uint32 index = 0; 2323 2324 /* First read the group entry. */ 2325 BCM_IF_ERROR_RETURN (soc_mem_read(unit, BSC_KG_GROUP_TABLEm, 2326 MEM_BLOCK_ANY, id, &kg_group_entry)); 2327 2328 2329 /* now write this index into the group. */ 2330 index = soc_mem_field32_get(unit, BSC_KG_GROUP_TABLEm, 2331 ((uint32 *)&kg_group_entry), SESSION_DATA_TYPEf); 2332 2333 2334 BCM_IF_ERROR_RETURN(soc_mem_read(unit, BSD_POLICY_ACTION_PROFILEm, 2335 MEM_BLOCK_ANY, index, (&(BCMI_FT_GROUP(unit, id)->pdd_entry)))); 2336 2337 /* 2338 * PDD entry is present in group table now. we do not maintain any state 2339 * for PDE profile entry and therefore we do not need to read it back. 2340 */ 2341 2342 return BCM_E_NONE; 2343 } 2344 2345 #endif /* BCM_WARM_BOOT_SUPPORT */ 2346 #if 0 2347 void 2348 bcmi_ft_group_state_dump( 2349 int unit, 2350 bcm_flowtracker_group_t id) 2351 { 2352 2353 2354 bcmi_ft_group_alu_info_t *temp = NULL; 2355 int j =0, num_alus_loads; 2356 2357 if (bcmi_ft_group_is_invalid(unit, id)) { 2358 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 2359 " Group id %d is not valid.\n"), id)); 2360 2361 return; 2362 } 2363 2364 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 2365 "======================================================== \n"))); 2366 2367 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 2368 "Printing State for Group : %d \n"), id)); 2369 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 2370 "======================================================== \n"))); 2371 2372 2373 temp = BCMI_FT_GROUP_EXT_DATA_INFO(unit, id); 2374 num_alus_loads = (BCMI_FT_GROUP_EXT_INFO(unit, id)).num_data_info; 2375 2376 2377 for (j=0; j<num_alus_loads; j++) { 2378 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 2379 "location = %d, length = %d, is_alu = %d \n"), 2380 temp->key.location, temp->key.length, temp->key.is_alu)); 2381 2382 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 2383 "Alu/load combined index = %d, type = %s\n"), 2384 temp->alu_load_index, alu_type_str[temp->alu_load_type])); 2385 2386 temp++; 2387 2388 } 2389 } 2390 #endif 2391 void 2392 bcmi_ft_state_dump(int unit) 2393 { 2394 int num_groups = 0, id = 0; 2395 soc_mem_t mem; 2396 2397 /* Group memory. */ 2398 mem = BSC_KG_GROUP_TABLEm; 2399 2400 /* total number of groups. */ 2401 num_groups = soc_mem_index_count(unit, mem); 2402 2403 LOG_INFO(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 2404 "==================Dumping Flowtracker State ================= \n"))); 2405 2406 if (BCMI_FT_CHIP_DEBUG_ENABLE(unit)) { 2407 LOG_ERROR(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 2408 "Chip Level Debugging is Enabled. \n"))); 2409 } else { 2410 LOG_ERROR(BSL_LS_BCM_FLOWTRACKER, (BSL_META_U(unit, 2411 "Chip Level Debugging is Disabled. \n"))); 2412 } 2413 2414 for(; id<num_groups; id++) { 2415 2416 if (bcmi_ft_group_is_invalid(unit, id)) { 2417 continue; 2418 } 2419 2420 bcmi_ft_group_state_dump(unit, id); 2421 } 2422 2423 } 2424 2425 /* 2426 * Function: 2427 * bcmi_ft_chip_debug_info_set 2428 * Purpose: 2429 * Set chip debug information. 2430 * Parameters: 2431 * unit - (IN) BCM device number 2432 * num_debug_info - (IN) actunal number of parameters 2433 * info - (IN) memory to send parameters. 2434 * Returns: 2435 * BCM_E_XXX - BCM error code. 2436 */ 2437 int bcmi_ft_chip_debug_info_set( 2438 int unit, 2439 int num_info, 2440 bcm_flowtracker_chip_debug_info_t *info) 2441 { 2442 int i = 0; 2443 2444 if (info == NULL) { 2445 return BCM_E_PARAM; 2446 } 2447 2448 if (!BCMI_FT_CHIP_DEBUG_ENABLE(unit)) { 2449 return BCM_E_UNAVAIL; 2450 } 2451 2452 if (num_info == 0) { 2453 if (BCMI_FT_CHIP_DEBUG_PARAM_INFO(unit) != NULL) { 2454 sal_free(BCMI_FT_CHIP_DEBUG_PARAM_INFO(unit)); 2455 BCMI_FT_CHIP_DEBUG_PARAM_INFO(unit) = NULL; 2456 } 2457 return BCM_E_NONE; 2458 } 2459 2460 if (BCMI_FT_CHIP_DEBUG_PARAM_INFO(unit) != NULL) { 2461 2462 /* 2463 * There is already existing state. 2464 * Check if user is free to add these tracking informations. 2465 */ 2466 BCM_IF_ERROR_RETURN( 2467 bcmi_ft_chip_debug_data_sanity(unit, num_info, info)); 2468 } 2469 2470 2471 BCMI_FT_CHIP_DEBUG_INFO(unit).num_debug_info = num_info; 2472 2473 BCMI_FT_CHIP_DEBUG_PARAM_INFO(unit) = 2474 (bcmi_ft_chip_debug_param_t *) 2475 sal_alloc((sizeof(bcmi_ft_chip_debug_param_t) * 2476 num_info), 2477 "flowtracker chip debug information."); 2478 2479 if (BCMI_FT_CHIP_DEBUG_PARAM_INFO(unit) == NULL) { 2480 return BCM_E_MEMORY; 2481 } 2482 2483 for (i = 0; i<num_info; i++) { 2484 BCMI_FT_CHIP_DEBUG_PARAM(unit, i).param = info[i].param; 2485 BCMI_FT_CHIP_DEBUG_PARAM(unit, i).count = info[i].count; 2486 BCMI_FT_CHIP_DEBUG_PARAM(unit, i).mem_id = -1; 2487 } 2488 2489 return BCM_E_NONE; 2490 } 2491 2492 2493 2494 /* 2495 * Function: 2496 * bcmi_ft_chip_debug_info_get 2497 * Purpose: 2498 * Get chip debug information. 2499 * Parameters: 2500 * unit - (IN) BCM device number 2501 * max_size - (INOUT) maximum number that user wants. 2502 * info - (OUT) memory to send parameters. 2503 * num_debug_info - (OUT) actunal number of parameters 2504 * Returns: 2505 * BCM_E_XXX - BCM error code. 2506 */ 2507 int bcmi_ft_chip_debug_info_get( 2508 int unit, 2509 int max_size, 2510 bcm_flowtracker_chip_debug_info_t *info, 2511 int *num_debug_info) 2512 { 2513 int result = BCM_E_UNAVAIL; 2514 int i = 0; 2515 2516 if (!BCMI_FT_CHIP_DEBUG_ENABLE(unit)) { 2517 return BCM_E_UNAVAIL; 2518 } 2519 2520 /* If the max_alu_info is non zero and list == NULL, return 2521 * BCM_E_PARAM. 2522 */ 2523 if ((max_size != 0) && (info == NULL)) { 2524 return BCM_E_PARAM; 2525 } 2526 2527 *num_debug_info = BCMI_FT_CHIP_DEBUG_INFO(unit).num_debug_info; 2528 2529 /* If max_alu_info == 0, 2530 * return the number of export elements in list_size 2531 * variable. 2532 */ 2533 if (max_size == 0) { 2534 /* Nothing to be done here. */ 2535 return BCM_E_NONE; 2536 } 2537 2538 /* Pick the number of elements to send back. */ 2539 *num_debug_info = (*num_debug_info < max_size) ? 2540 (*num_debug_info) : max_size; 2541 2542 for (i = 0; i<*num_debug_info; i++) { 2543 info[i].param = BCMI_FT_CHIP_DEBUG_PARAM(unit, i).param; 2544 if (BCMI_FT_CHIP_DEBUG_PARAM(unit, i).mem_id == -1) { 2545 info[i].count = BCMI_FT_CHIP_DEBUG_PARAM(unit, i).count; 2546 } else { 2547 result = bcmi_ft_chip_debug_counter_get(unit, 2548 BCMI_FT_CHIP_DEBUG_PARAM(unit, i).mem_id, 2549 BCMI_FT_CHIP_DEBUG_PARAM(unit, i).alu_type, 2550 (&(info[i].count))); 2551 2552 if (BCM_FAILURE(result)) 2553 return result; 2554 } 2555 2556 } 2557 2558 return BCM_E_NONE; 2559 } 2560 2561 #if 0 2562 int 2563 bcmi_ft_group_ts_state_recover( 2564 int unit, 2565 bcm_flowtracker_group_t id) 2566 { 2567 2568 bsc_dg_group_timestamp_profile_entry_t entry; 2569 bsc_dg_group_table_entry_t dg_group_entry; 2570 uint32 index=0; 2571 uint32 fmt[1]; 2572 2573 2574 soc_field_t ts_data_fields[4] = 2575 {DATA_0f, DATA_1f, DATA_2f, DATA_3f}; 2576 2577 2578 /* Initialize the timestamp profile entry. */ 2579 sal_memset(&entry, 0, 2580 sizeof(bsc_dg_group_timestamp_profile_entry_t)); 2581 /* Initialize group entry. */ 2582 sal_memset(&dg_group_entry, 0, sizeof(bsc_dg_group_table_entry_t)); 2583 2584 /* First read the group entry. */ 2585 BCM_IF_ERROR_RETURN (soc_mem_read(unit, BSC_DG_GROUP_TABLEm, 2586 MEM_BLOCK_ANY, id, &dg_group_entry)); 2587 2588 /* now write this new index into the group. */ 2589 index = soc_mem_field32_get(unit, BSC_DG_GROUP_TABLEm, 2590 ((uint32 *)&dg_group_entry), TIMESTAMP_PROFILE_IDXf, index); 2591 2592 if (index == 0) { 2593 return BCM_E_NONE; 2594 } 2595 2596 /* First read the group entry. */ 2597 BCM_IF_ERROR_RETURN (soc_mem_read(unit, BSC_DG_GROUP_TIMESTAMP_PROFILEm, 2598 MEM_BLOCK_ANY, index, &entry)); 2599 2600 #endif 2601 2602 2603 2604 2605 #if 0 2606 bcmi_ft_group_param_type_t 2607 bcmi_ft_group_get_param_type( 2608 int unit, 2609 soc_field_t fid) 2610 { 2611 2612 bcmi_ft_group_param_type_t param; 2613 2614 param = bcmiFtGroupParamTypeTracking; 2615 2616 switch (fid) { 2617 case bcmFlowtrackerTrackingParamTypeTimestampNewLearn: 2618 param = bcmiFtGroupParamTypeTsNewLearn; 2619 break; 2620 case bcmFlowtrackerTrackingParamTypeTimestampFlowStart: 2621 param = bcmiFtGroupParamTypeTsFlowStart; 2622 break; 2623 case bcmFlowtrackerTrackingParamTypeTimestampFlowEnd: 2624 param = bcmiFtGroupParamTypeTsFlowEnd; 2625 break; 2626 case bcmFlowtrackerTrackingParamTypeTimestampCheckEvent1: 2627 param = bcmiFtGroupParamTypeTsCheckEvent1; 2628 break; 2629 case bcmFlowtrackerTrackingParamTypeTimestampCheckEvent2: 2630 param = bcmiFtGroupParamTypeTsCheckEvent2; 2631 break; 2632 default : 2633 param = bcmiFtGroupParamTypeTracking; 2634 } 2635 2636 return param; 2637 } 2638 2639 2640 bcm_flowtracker_tracking_param_type_t 2641 bcmi_ft_group_get_tracking_param_( 2642 int unit, 2643 bcmi_ft_group_param_type_t pram_type) 2644 { 2645 2646 bcmi_ft_group_param_type_t param; 2647 2648 param = bcmFlowtrackerTrackingParamTypeNone; 2649 2650 switch (pram_type) { 2651 case bcmiFtGroupParamTypeTsNewLearn: 2652 param = bcmFlowtrackerTrackingParamTypeTimestampNewLearn 2653 break; 2654 case FtGroupParamTypeTsFlowStart: 2655 param bcmFlowtrackerTrackingParamTypeTimestampFlowStart; 2656 break; 2657 case bcmiFtGroupParamTypeTsFlowEnd 2658 param = bcmFlowtrackerTrackingParamTypeTimestampFlowEnd: 2659 break; 2660 case bcmiFtGroupParamTypeTsCheckEvent1: 2661 param = bcmFlowtrackerTrackingParamTypeTimestampCheckEvent1: 2662 break; 2663 case bcmiFtGroupParamTypeTsCheckEvent2: 2664 param = bcmFlowtrackerTrackingParamTypeTimestampCheckEvent2: 2665 break; 2666 default : 2667 param = bcmFlowtrackerTrackingParamTypeNone; 2668 } 2669 2670 return param; 2671 } 2672 2673 2674 2675 bcmi_ft_group_param_type_t 2676 bcmi_ft_group_get_ts_type( 2677 int unit, 2678 bcm_flowtracker_group_t id, 2679 soc_field_t fid) 2680 { 2681 int i=0; 2682 2683 for (; i<BCMI_FT_GROUP_MAX_TS_TYPE; i++) { 2684 if (fid == bcmi_ft_group_ts_info[i].field_id) { 2685 return bcmi_ft_group_get_param_type(unit, 2686 bcmi_ft_group_ts_info[i].ts_param); 2687 } 2688 } 2689 2690 return bcmiFtGroupParamTypeTracking; 2691 2692 } 2693 #endif 2694 2695 #else /* BCM_FLOWTRCAKER_SUPPORT*/ 2696 int bcmi_ft_base_not_empty; 2697 #endif /* BCM_FLOWTRCAKER_SUPPORT */