schanmsg.h (17585B)
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 * S-Channel Message: data structure used by firmware to transport 8 * S-Channel Data into SOC via CMIC. 9 */ 10 11 #ifndef _SOC_SCHAN_H 12 #define _SOC_SCHAN_H 13 14 #include <soc/types.h> 15 16 #if defined(BCM_CMICM_SUPPORT) || defined(BCM_CMICX_SUPPORT) 17 #define CMIC_SCHAN_WORDS(unit) \ 18 ((soc_feature(unit, soc_feature_schmsg_alias) || soc_feature(unit, soc_feature_cmicm) || soc_feature(unit, soc_feature_cmicx)) ? 22 : 20) 19 extern int fschan_wait_idle(int unit); 20 #else 21 #define CMIC_SCHAN_WORDS(unit) \ 22 (soc_feature(unit, soc_feature_schmsg_alias) ? 22 : 20) 23 #endif 24 25 /* number of words to use when allocating space */ 26 #define CMIC_SCHAN_WORDS_ALLOC 22 27 28 /* 29 * The endianness of the host is taken into account by the routines 30 * which copy S-Channel messages into and out of PCI space as 32-bit 31 * words. Unfortunately, the compiler also switches bit field packing 32 * order according to host endianness. We must undo this "feature" by 33 * giving the fields in both orders. 34 */ 35 36 typedef union schan_header_s { 37 struct v2_s { 38 #if defined(LE_HOST) 39 uint32 nack:1; 40 uint32 bank_ignore_mask:2; 41 uint32 dma:1; 42 uint32 ecode: 2; 43 uint32 err:1; 44 uint32 data_byte_len:7; 45 uint32 src_blk:6; 46 uint32 dst_blk:6; 47 uint32 opcode:6; 48 #else 49 uint32 opcode:6; 50 uint32 dst_blk:6; 51 uint32 src_blk:6; 52 uint32 data_byte_len:7; 53 uint32 err:1; 54 uint32 ecode: 2; 55 uint32 dma:1; 56 uint32 bank_ignore_mask:2; 57 uint32 nack:1; 58 #endif 59 } v2; 60 struct v3_s { 61 #if defined(LE_HOST) 62 uint32 nack:1; 63 uint32 bank_ignore_mask:2; 64 uint32 dma:1; 65 uint32 ecode: 2; 66 uint32 err:1; 67 uint32 data_byte_len:7; 68 uint32 acc_type:3; 69 uint32 :3; 70 uint32 dst_blk:6; 71 uint32 opcode:6; 72 #else 73 uint32 opcode:6; 74 uint32 dst_blk:6; 75 uint32 :3; 76 uint32 acc_type:3; 77 uint32 data_byte_len:7; 78 uint32 err:1; 79 uint32 ecode: 2; 80 uint32 dma:1; 81 uint32 bank_ignore_mask:2; 82 uint32 nack:1; 83 #endif 84 } v3; 85 struct v4_s { 86 #if defined(LE_HOST) 87 uint32 nack:1; 88 uint32 bank_ignore_mask:2; 89 uint32 dma:1; 90 uint32 ecode: 2; 91 uint32 err:1; 92 uint32 data_byte_len:7; 93 uint32 acc_type:5; 94 uint32 dst_blk:7; 95 uint32 opcode:6; 96 #else 97 uint32 opcode:6; 98 uint32 dst_blk:7; 99 uint32 acc_type:5; 100 uint32 data_byte_len:7; 101 uint32 err:1; 102 uint32 ecode: 2; 103 uint32 dma:1; 104 uint32 bank_ignore_mask:2; 105 uint32 nack:1; 106 #endif 107 } v4; 108 uint32 word; 109 } schan_header_t; 110 111 /* 112 * Individual S-Channel message formats. 113 * Different ways of peeking and poking at an S-Channel message 114 * packet. Applicable message types are listed inside each structure. 115 */ 116 117 typedef struct schan_msg_plain_s { 118 /* GBP Full Notification */ 119 /* GBP Available Notification */ 120 /* Write Memory Ack */ 121 /* Write Register Ack */ 122 /* ARL Insert Complete */ 123 /* ARL Delete Complete */ 124 /* Memory Failed Notification */ 125 /* Initialize CFAP (Cell FAP) */ 126 /* Initialize SFAP (Slot FAP) */ 127 /* Enter Debug Mode */ 128 /* Exit Debug Mode */ 129 schan_header_t header; 130 } schan_msg_plain_t; 131 132 typedef struct schan_msg_bitmap_s { 133 /* Back Pressure Warning Status */ 134 /* Back Pressure Discard Status */ 135 /* Link Status Notification (except 5695) */ 136 /* COS Queue Status Notification */ 137 /* HOL Status Notification */ 138 schan_header_t header; 139 uint32 bitmap; 140 uint32 bitmap_word1; /* 5665 only, so far */ 141 } schan_msg_bitmap_t; 142 143 typedef struct schan_msg_readcmd_s { 144 /* Read Memory Command */ 145 /* Read Register Command */ 146 schan_header_t header; 147 uint32 address; 148 } schan_msg_readcmd_t; 149 150 typedef struct schan_msg_readresp_s { 151 /* Read Memory Ack */ 152 /* Read Register Ack */ 153 schan_header_t header; 154 uint32 data[CMIC_SCHAN_WORDS_ALLOC - 1]; 155 } schan_msg_readresp_t; 156 157 typedef struct schan_msg_writecmd_s { 158 /* Write Memory Command */ 159 /* Write Register Command */ 160 schan_header_t header; 161 uint32 address; 162 uint32 data[CMIC_SCHAN_WORDS_ALLOC - 2]; 163 } schan_msg_writecmd_t; 164 165 typedef struct schan_msg_arlins_s { 166 /* ARL Insert Command */ 167 /* (Also: ARL Message Buffer Format) */ 168 /* (Also: ARL DMA Message Format) */ 169 schan_header_t header; 170 uint32 data[3]; 171 } schan_msg_arlins_t; 172 173 typedef struct schan_msg_arldel_s { 174 /* ARL Delete Command */ 175 schan_header_t header; 176 uint32 data[2]; 177 } schan_msg_arldel_t; 178 179 typedef struct schan_msg_arllkup_s { 180 /* ARL Lookup Command */ 181 schan_header_t header; 182 uint32 address; 183 uint32 data[2]; 184 } schan_msg_arllkup_t; 185 186 typedef struct schan_msg_l3ins_s { 187 /* L3 Insert Command */ 188 schan_header_t header; 189 uint32 data[4]; 190 } schan_msg_l3ins_t; 191 192 typedef struct schan_msg_l3del_s { 193 /* L3 Delete Command */ 194 schan_header_t header; 195 uint32 data[4]; 196 } schan_msg_l3del_t; 197 198 typedef struct schan_msg_l3lkup_s { 199 /* L3 Lookup Command */ 200 schan_header_t header; 201 uint32 address; 202 uint32 data[4]; 203 } schan_msg_l3lkup_t; 204 205 typedef struct schan_msg_l2x2_s { 206 /* L2 Insert/Delete/Lookup Command 56504 / 5630x / 5610x */ 207 schan_header_t header; 208 uint32 data[3]; 209 } schan_msg_l2x2_t; 210 211 typedef struct schan_msg_l3x2_s { 212 /* L3 Insert/Delete/Lookup Command 56504 / 5630x / 5610x */ 213 schan_header_t header; 214 uint32 data[13]; 215 } schan_msg_l3x2_t; 216 217 #define SCHAN_GEN_RESP_TYPE_FOUND 0 218 #define SCHAN_GEN_RESP_TYPE_NOT_FOUND 1 219 #define SCHAN_GEN_RESP_TYPE_FULL 2 220 #define SCHAN_GEN_RESP_TYPE_INSERTED 3 221 #define SCHAN_GEN_RESP_TYPE_REPLACED 4 222 #define SCHAN_GEN_RESP_TYPE_DELETED 5 223 #define SCHAN_GEN_RESP_TYPE_ENTRY_IS_OLD 6 224 #define SCHAN_GEN_RESP_TYPE_CLEARED_VALID 7 225 #define SCHAN_GEN_RESP_TYPE_L2_FIFO_FULL 8 226 #define SCHAN_GEN_RESP_TYPE_MAC_LIMIT_THRE 9 227 #define SCHAN_GEN_RESP_TYPE_MAC_LIMIT_DEL 10 228 #define SCHAN_GEN_RESP_TYPE_L2_STATIC 11 229 230 #define SCHAN_GEN_RESP_L2_MOD_FIFO_FULL 6 231 #ifdef BCM_ISM_SUPPORT 232 #define SCHAN_GEN_RESP_MAC_LIMIT_THRESHOLD 7 233 #define SCHAN_GEN_RESP_MAC_LIMIT_DELETE 8 234 #endif 235 #define SCHAN_GEN_RESP_TYPE_ERROR 15 236 237 #define SCHAN_GEN_RESP_ERR_INFO_ERROR_IN_HASH_TABLE 0 238 #define SCHAN_GEN_RESP_ERR_INFO_ERROR_IN_LP_TABLE 1 239 240 241 #define SCHAN_GEN_RESP_ERROR_BUSY -1 242 #define SCHAN_GEN_RESP_ERROR_PARITY -1 243 244 typedef struct schan_genresp_s { 245 #if defined(LE_HOST) 246 uint32 index:20, 247 r0:1, /* Reserved */ 248 err_info:4, /* SCHAN_GEN_RESP_ERROR_* */ 249 r1:1, /* Reserved */ 250 type:4, /* SCHAN_GEN_RESP_TYPE_* */ 251 src:2; 252 #else 253 uint32 src:2, 254 type:4, /* SCHAN_GEN_RESP_TYPE_* */ 255 r0:1, /* Reserved */ 256 err_info:4, /* SCHAN_GEN_RESP_ERROR_* */ 257 r1:1, /* Reserved */ 258 index:20; 259 #endif 260 } schan_genresp_t; 261 262 263 typedef struct schan_genresp_v2_s { 264 #if defined(LE_HOST) 265 uint32 index:20, 266 r0:4, /* Reserved */ 267 err_info:4, /* SCHAN_GEN_RESP_ERROR_* */ 268 type:4; /* SCHAN_GEN_RESP_TYPE_* */ 269 #else 270 uint32 type:4, /* SCHAN_GEN_RESP_TYPE_* */ 271 err_info:4, /* SCHAN_GEN_RESP_ERROR_* */ 272 r0:4, /* Reserved */ 273 index:20; 274 #endif 275 } schan_genresp_v2_t; 276 277 typedef struct schan_msg_gencmd_s { 278 /* Generic table Insert/Delete/Lookup Command 5662x */ 279 schan_header_t header; 280 uint32 address; 281 uint32 data[CMIC_SCHAN_WORDS_ALLOC - 2]; 282 } schan_msg_gencmd_t; 283 284 #define SOC_HASH_BANK_MASK_ISM 0xfffff 285 #define SOC_HASH_BANK_MASK_SHARED 0xfff 286 287 typedef struct schan_msg_genresp_s { 288 /* Generic table Insert/Delete/Lookup Command 5662x */ 289 schan_header_t header; 290 schan_genresp_t response; 291 uint32 data[CMIC_SCHAN_WORDS_ALLOC - 2]; 292 } schan_msg_genresp_t; 293 294 typedef struct schan_msg_genresp_v2_s { 295 /* Generic table Insert/Delete/Lookup Command 5664x */ 296 schan_header_t header; 297 schan_genresp_v2_t response; 298 uint32 data[CMIC_SCHAN_WORDS_ALLOC - 2]; 299 } schan_msg_genresp_v2_t; 300 301 typedef struct schan_msg_popcmd_s { 302 /* Pop Memory Command */ 303 schan_header_t header; 304 uint32 address; 305 } schan_msg_popcmd_t; 306 307 typedef struct schan_msg_popresp_s { 308 /* Pop Memory Response */ 309 schan_header_t header; 310 uint32 data[CMIC_SCHAN_WORDS_ALLOC - 1]; 311 } schan_msg_popresp_t; 312 313 typedef struct schan_msg_pushcmd_s { 314 /* Push Memory Command */ 315 schan_header_t header; 316 uint32 address; 317 uint32 data[CMIC_SCHAN_WORDS_ALLOC - 2]; 318 } schan_msg_pushcmd_t; 319 320 typedef struct schan_msg_pushresp_s { 321 /* Push Memory Response */ 322 schan_header_t header; 323 uint32 data[CMIC_SCHAN_WORDS_ALLOC - 1]; 324 } schan_msg_pushresp_t; 325 326 /* 327 * Union of all S-Channel message types (use to declare all message buffers) 328 * 329 * When building messages, address the union according to packet type. 330 * When writing to PCI, address data.dwords. 331 * When writing to I2C, address data.bytes. 332 */ 333 334 #define schan_msg_clear(m) ((m)->header_dword = 0) 335 336 typedef union schan_msg_u { 337 schan_header_t header; 338 uint32 header_dword; 339 schan_msg_plain_t plain; 340 schan_msg_bitmap_t bitmap; 341 schan_msg_readcmd_t readcmd; 342 schan_msg_readresp_t readresp; 343 schan_msg_writecmd_t writecmd; 344 schan_msg_arlins_t arlins; 345 schan_msg_arldel_t arldel; 346 schan_msg_arllkup_t arllkup; 347 schan_msg_l3ins_t l3ins; 348 schan_msg_l3del_t l3del; 349 schan_msg_l3lkup_t l3lkup; 350 schan_msg_l2x2_t l2x2; 351 schan_msg_l3x2_t l3x2; 352 schan_msg_gencmd_t gencmd; 353 schan_msg_genresp_t genresp; 354 schan_msg_genresp_v2_t genresp_v2; 355 schan_msg_popcmd_t popcmd; 356 schan_msg_popresp_t popresp; 357 schan_msg_pushcmd_t pushcmd; 358 schan_msg_pushresp_t pushresp; 359 uint32 dwords[CMIC_SCHAN_WORDS_ALLOC]; 360 uint8 bytes[sizeof(uint32) * CMIC_SCHAN_WORDS_ALLOC]; 361 } schan_msg_t; 362 363 /* 364 * S-Channel Message Types 365 */ 366 367 #define BP_WARN_STATUS_MSG 0x01 368 #define BP_DISCARD_STATUS_MSG 0x02 369 #define COS_QSTAT_NOTIFY_MSG 0x03 /* Not on XGS */ 370 #define IPIC_HOL_STAT_MSG 0x03 /* 5665 (alias) */ 371 #define HOL_STAT_NOTIFY_MSG 0x04 372 #define READ_MEMORY_CMD_MSG 0x07 373 #define READ_MEMORY_ACK_MSG 0x08 374 #define WRITE_MEMORY_CMD_MSG 0x09 375 #define WRITE_MEMORY_ACK_MSG 0x0a 376 #define READ_REGISTER_CMD_MSG 0x0b 377 #define READ_REGISTER_ACK_MSG 0x0c 378 #define WRITE_REGISTER_CMD_MSG 0x0d 379 #define WRITE_REGISTER_ACK_MSG 0x0e 380 #define ARL_INSERT_CMD_MSG 0x0f 381 #define ARL_INSERT_DONE_MSG 0x10 382 #define ARL_DELETE_CMD_MSG 0x11 383 #define ARL_DELETE_DONE_MSG 0x12 384 #define LINKSTAT_NOTIFY_MSG 0x13 /* Strata I/II only */ 385 #define MEMORY_FAIL_NOTIFY 0x14 386 #define INIT_CFAP_MSG 0x15 /* 5690 only */ 387 #define IPIC_GBP_FULL_MSG 0x15 /* 5665 (alias) */ 388 #define IPIC_GBP_AVAIL_MSG 0x16 /* 5665 (alias) */ 389 #define ENTER_DEBUG_MODE_MSG 0x17 390 #define EXIT_DEBUG_MODE_MSG 0x18 391 #define ARL_LOOKUP_CMD_MSG 0x19 392 #define L3_INSERT_CMD_MSG 0x1a 393 #define L3_INSERT_DONE_MSG 0x1b 394 #define L3_DELETE_CMD_MSG 0x1c 395 #define L3_DELETE_DONE_MSG 0x1d 396 #define L3_LOOKUP_CMD_MSG 0x1e /* 5695 */ 397 #define L2_LOOKUP_CMD_MSG 0x20 /* 56504 / 5630x / 5610x */ 398 #define L2_LOOKUP_ACK_MSG 0x21 /* 56504 / 5630x / 5610x */ 399 #define L3X2_LOOKUP_CMD_MSG 0x22 /* 56504 / 5630x / 5610x */ 400 #define L3X2_LOOKUP_ACK_MSG 0x23 /* 56504 / 5630x / 5610x */ 401 /* New for 5662x (see soc_feature_generic_table_ops) */ 402 #define TABLE_INSERT_CMD_MSG 0x24 /* 5662x */ 403 #define TABLE_INSERT_DONE_MSG 0x25 /* 5662x */ 404 #define TABLE_DELETE_CMD_MSG 0x26 /* 5662x */ 405 #define TABLE_DELETE_DONE_MSG 0x27 /* 5662x */ 406 #define TABLE_LOOKUP_CMD_MSG 0x28 /* 5662x */ 407 #define TABLE_LOOKUP_DONE_MSG 0x29 /* 5662x */ 408 #define FIFO_POP_CMD_MSG 0x2a /* 5662x */ 409 #define FIFO_POP_DONE_MSG 0x2b /* 5662x */ 410 #define FIFO_PUSH_CMD_MSG 0x2c /* 5662x */ 411 #define FIFO_PUSH_DONE_MSG 0x2d /* 5662x */ 412 413 414 /* 415 * Schan error types 416 */ 417 typedef enum soc_schan_err_e { 418 SOC_SCERR_CFAP_OVER_UNDER, 419 SOC_SCERR_SDRAM_CHKSUM, 420 SOC_SCERR_UNEXP_FIRST_CELL, 421 SOC_SCERR_MMU_SOFT_RST, 422 SOC_SCERR_CBP_CELL_CRC, 423 SOC_SCERR_CBP_HEADER_PARITY, 424 SOC_SCERR_MMU_NPKT_CELLS, 425 SOC_SCERR_MEMORY_PARITY, 426 SOC_SCERR_PLL_DLL_LOCK_LOSS, 427 SOC_SCERR_CELL_PTR_CRC, 428 SOC_SCERR_CELL_DATA_CRC, 429 SOC_SCERR_FRAME_DATA_CRC, 430 SOC_SCERR_CELL_PTR_BLOCK_CRC, 431 SOC_SCERR_MULTIPLE_ERR, 432 SOC_SCERR_INVALID 433 } soc_schan_err_t; 434 435 /******************************************* 436 * @function soc_schan_header_cmd_set 437 * purpose API to set the command header 438 * 439 * @param handle [in] unit 440 * @param header [out] Populated Command header pointer 441 * @param opcode [in] Opcode 442 * @param dst_blk [in] Block ID 443 * @param acc_type [in] Acc Type 444 * @param data_byte_len [in] Dlen 445 * @param dma, bank_ignore_mask [in] Misc Ctrl/ Status 446 * @returns None 447 * 448 * @end 449 */ 450 extern void soc_schan_header_cmd_set(int unit, schan_header_t *header, 451 int opcode, int dst_blk, int src_blk, 452 int acc_type, int data_byte_len, int dma, 453 uint32 bank_ignore_mask); 454 455 /******************************************* 456 * @function soc_schan_header_cmd_get 457 * purpose API to get the command header 458 * 459 * @param handle [in] unit 460 * @param header [in] Populated Command header pointer 461 * @param opcode [out] Opcode 462 * @param dst_blk [out] Block ID 463 * @param acc_type [out] Acc Type 464 * @param data_byte_len [out] Dlen 465 * @param dma, bank_ignore_mask [out] Misc Ctrl/ Status 466 * @returns None 467 * 468 * @end 469 */ 470 extern void soc_schan_header_cmd_get(int unit, schan_header_t *header, 471 int *opcode, int *dst_blk, int *src_blk, 472 int *acc_type, int *data_byte_len, 473 int *dma, uint32 *bank_ignore_mask); 474 475 /******************************************* 476 * @function soc_schan_header_status_get 477 * purpose API to get the header status 478 * 479 * @param handle [in] unit 480 * @param header [in] Populated Command header pointer 481 * @param opcode [out] Opcode 482 * @param dst_blk [out] Block ID 483 * @param acc_type [out] Acc Type 484 * @param data_byte_len [out] Dlen 485 * @param err, ecode, nack [out] Misc Ctrl/ Status 486 * @returns None 487 * 488 * @end 489 */ 490 extern void soc_schan_header_status_get(int unit, schan_header_t *header, 491 int *opcode, int *src_blk, 492 int *data_byte_len, int *err, 493 int *ecode, int *nack); 494 /******************************************* 495 * @function soc_schan_op 496 * purpose SDK-6 API used to initiate the schan operation 497 * 498 * @param handle [in] unit 499 * @param msg [in] SCHAN message pointer 500 * @param dwc_write [in] Number of messages to write 501 * @param dwc_read [in] Number of messages to read 502 * @param intr [in] Interrupt 503 * 504 * @returns SOC_E_NONE 505 * @returns SOC_E_XXX 506 507 * @end 508 */ 509 extern int soc_schan_op( 510 int unit, 511 schan_msg_t *msg, 512 int dwc_write, 513 int dwc_read, 514 int intr); 515 516 /******************************************* 517 * @function soc_schan_dump 518 * @Purpose Dump an S-Channel message for debugging 519 * 520 * @param unit [in] unit 521 * 522 * @returns SOC_E_NONE 523 * @returns SOC_E_XXX 524 * 525 * @end 526 */ 527 extern void 528 soc_schan_dump(int unit, schan_msg_t *msg, int dwc); 529 530 531 /******************************************* 532 * @function soc_schan_init 533 * purpose API to Initialize and config SCHAN 534 * 535 * @param unit [in] unit 536 * 537 * @returns SOC_E_NONE 538 * @returns SOC_E_XXX 539 * 540 * @end 541 */ 542 extern int soc_schan_init(int unit); 543 544 /******************************************* 545 * @function soc_schan_deinit 546 * purpose SDK-7 API to de-Initialize SCHAN 547 * 548 * @param unit [in] unit 549 * 550 * @returns SOC_E_NONE 551 * @returns SOC_E_XXX 552 * 553 * @end 554 */ 555 extern int soc_schan_deinit(int unit); 556 557 /******************************************* 558 * @function soc_schan_override_enable 559 * @Purpose Enable schan override 560 * 561 * @param unit [in] unit 562 * 563 * @returns SOC_E_NONE 564 * @returns SOC_E_XXX 565 * 566 * @end 567 */ 568 extern int 569 soc_schan_override_enable(int unit); 570 571 /******************************************* 572 * @function soc_schan_override_disable 573 * @Purpose Disable schan override 574 * 575 * @param unit [in] unit 576 * 577 * @returns SOC_E_NONE 578 * @returns SOC_E_XXX 579 * 580 * @end 581 */ 582 extern int 583 soc_schan_override_disable(int unit); 584 585 /* 586 * Structures and prototypes related to PEM block access. 587 * { 588 */ 589 typedef struct phy_mem_s { 590 unsigned int reserve ; 591 unsigned int block_identifier ; 592 unsigned int mem_address ; 593 unsigned int row_index ; 594 unsigned int mem_width_in_bits ; 595 unsigned int is_reg; 596 unsigned int is_industrial_tcam; 597 } phy_mem_t ; 598 599 int phy_mem_read(int unit, phy_mem_t *mem, void *entry_data) ; 600 int phy_mem_write(int unit, phy_mem_t *mem, void *entry_data) ; 601 602 /* 603 * } 604 */ 605 #endif /* !_SOC_SCHAN_H */