mbist.c (3573B)
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 * Memory Built-in Self Test 8 */ 9 10 11 #include <sal/types.h> 12 #include <soc/mem.h> 13 #include <shared/bsl.h> 14 #include <appl/diag/system.h> 15 #include <appl/diag/parse.h> 16 #include <bcm/link.h> 17 #include "testlist.h" 18 19 #if defined(BCM_PETRA_SUPPORT) 20 #include <soc/dpp/drv.h> 21 #endif 22 23 #if defined(BCM_TRIDENT2_SUPPORT) 24 25 typedef enum { 26 MEMORY_BIST, 27 LOGIC_BIST, 28 ALL_BIST 29 } bist_type_t; 30 31 static bist_type_t bist_test_parameters[SOC_MAX_NUM_DEVICES]; 32 33 int 34 memory_logic_bist_test_init(int u, args_t *a, void **p) 35 { 36 char * test_type_name = NULL; 37 bist_type_t * bist_type = NULL; 38 parse_table_t pt; 39 40 bist_type = &bist_test_parameters[u]; 41 parse_table_init(u, &pt); 42 parse_table_add(&pt, "type", PQ_STRING, "memory", 43 &(test_type_name), NULL); 44 if (parse_arg_eq(a, &pt) < 0) { 45 cli_out("%s: Invalid option: %s\n", 46 ARG_CMD(a), ARG_CUR(a)); 47 parse_arg_eq_done(&pt); 48 return -1; 49 } 50 51 if (!sal_strcasecmp(test_type_name, "memory")) { 52 *bist_type = MEMORY_BIST; 53 } else if (!sal_strcasecmp(test_type_name, "logic")) { 54 *bist_type = LOGIC_BIST; 55 } else if (!sal_strcasecmp(test_type_name, "all")) { 56 *bist_type = ALL_BIST; 57 } else { 58 parse_arg_eq_done(&pt); 59 cli_out("Invalid test type selected.\n"); 60 return -1; 61 } 62 if (soc_feature(u, soc_feature_mbist)){ 63 BCM_IF_ERROR_RETURN(bcm_linkscan_enable_set(u, 0)); 64 if (!SOC_IS_TOMAHAWK3(u)) { 65 if ((soc_reset_init(u)) < 0) { 66 parse_arg_eq_done(&pt); 67 return -1; 68 } 69 } 70 } 71 *p = bist_type; 72 parse_arg_eq_done(&pt); 73 return 0; 74 } 75 76 int 77 memory_logic_bist_test(int u, args_t *a, void *p) 78 { 79 bist_type_t * bist_type = p; 80 81 if ((*bist_type == MEMORY_BIST) || (*bist_type == ALL_BIST)) { 82 if (SOC_IS_TRIDENT2(u)) { 83 cli_out("MEMORY BIST...\n"); 84 (void)trident2_mem_bist(u); 85 cli_out("REGFILE BIST...\n"); 86 (void)trident2_regfile_bist(u); 87 } 88 #ifdef BCM_TOMAHAWK2_SUPPORT 89 else if (SOC_IS_TOMAHAWK2(u)) { 90 cli_out("MEMORY BIST...\n"); 91 SOC_IF_ERROR_RETURN(tomahawk2_mem_bist(u)); 92 } 93 #endif /* BCM_TOMAHAWK2_SUPPORT */ 94 #ifdef BCM_TOMAHAWK3_SUPPORT 95 else if (SOC_IS_TOMAHAWK3(u)) { 96 cli_out("MEMORY BIST...\n"); 97 SOC_IF_ERROR_RETURN(tomahawk3_mem_bist(u)); 98 } 99 #endif /* BCM_TOMAHAWK2_SUPPORT */ 100 #ifdef BCM_TRIDENT3_SUPPORT 101 else if (SOC_IS_TRIDENT3(u)) { 102 cli_out("MEMORY BIST...\n"); 103 SOC_IF_ERROR_RETURN(trident3_mem_bist(u)); 104 } 105 #endif /* BCM_TRIDENT3_SUPPORT*/ 106 #ifdef BCM_TOMAHAWK_SUPPORT 107 else if (SOC_IS_TOMAHAWK(u)) { 108 cli_out("MEMORY BIST...\n"); 109 SOC_IF_ERROR_RETURN(tomahawk_mem_bist(u)); 110 } 111 #endif /* BCM_TOMAHAWK_SUPPORT */ 112 } 113 return 0; 114 } 115 116 int 117 memory_logic_bist_test_done(int u, void *p) 118 { 119 if (soc_feature(u, soc_feature_mbist)){ 120 if ((soc_reset_init(u)) < 0) { 121 return -1; 122 } 123 } 124 return 0; 125 } 126 127 #endif 128 #if defined(BCM_PETRA_SUPPORT) 129 int 130 tcam_bist_test(int u, args_t *a, void *p) 131 { 132 int rv = 0; 133 134 rv = soc_dpp_tcam_bist_check(u);; 135 136 if (rv < 0) 137 { 138 test_error(u, "TCAM BIST Failed!!!\n"); 139 return rv; 140 } 141 142 return rv; 143 } 144 145 #endif