flex_test.c (3386B)
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 * This is the top level Flex port test, which will select the 8 * chip-specific flexport test based on chip info. 9 */ 10 #include <appl/diag/system.h> 11 #include <shared/alloc.h> 12 #include <shared/bsl.h> 13 14 #include <soc/cm.h> 15 #include <soc/dma.h> 16 #include <soc/drv.h> 17 #include <soc/dcb.h> 18 #include <soc/cmicm.h> 19 #include <soc/cmic.h> 20 21 #if defined(BCM_ESW_SUPPORT) && defined(INCLUDE_L3) && \ 22 (defined(BCM_CMICM_SUPPORT) || defined(BCM_CMICX_SUPPORT)) && \ 23 !defined(NO_SAL_APPL) && (!defined(__KERNEL__)) 24 25 /* flexport.c : TH2, TD2+ */ 26 extern int flexport_test_init(int,args_t *, void **); 27 extern int flexport_test_cleanup(int, void *); 28 extern int flexport_test(int, args_t *, void *); 29 30 /* flexport_td3.c : TD3 */ 31 extern int flexport_td3_test_init(int,args_t *, void **); 32 extern int flexport_td3_test_cleanup(int, void *); 33 extern int flexport_td3_test(int, args_t *, void *); 34 35 /* flexport_th3.c : TH3 */ 36 #if defined(BCM_TOMAHAWK3_SUPPORT) 37 extern int flexport_th3_test_init(int,args_t *, void **); 38 extern int flexport_th3_test_cleanup(int, void *); 39 extern int flexport_th3_test(int, args_t *, void *); 40 #endif 41 42 /* 43 * Function: 44 * flex_test_init 45 * Purpose: 46 * Test init function. Parse CLI params and do necessary init. 47 * Parameters: 48 * unit - StrataSwitch Unit #. 49 * a - Pointer to arguments 50 * 51 * Returns: 52 * SOC_E_XXXX 53 */ 54 int 55 flex_test_init(int unit, args_t *a, void **pa) 56 { 57 int rv = BCM_E_NONE; 58 59 if (SOC_IS_TOMAHAWK3(unit)) { 60 #if defined(BCM_TOMAHAWK3_SUPPORT) 61 rv = flexport_th3_test_init(unit, a, pa); 62 #endif 63 } else if (SOC_IS_TRIDENT3X(unit)) { 64 rv = flexport_td3_test_init(unit, a, pa); 65 } else if (SOC_IS_TRIDENT2X(unit) || 66 SOC_IS_TOMAHAWK2(unit)) { 67 rv = flexport_test_init(unit, a, pa); 68 } 69 70 return rv; 71 } 72 73 /* 74 * Function: 75 * flex_test 76 * Purpose: 77 * Set up ports/streams and send packets. 78 * Parameters: 79 * unit - StrataSwitch Unit #. 80 * a - Pointer to arguments 81 * 82 * Returns: 83 * SOC_E_XXXX 84 */ 85 int 86 flex_test(int unit, args_t *a, void *pa) 87 { 88 int rv = BCM_E_NONE; 89 90 if (SOC_IS_TOMAHAWK3(unit)) { 91 #if defined(BCM_TOMAHAWK3_SUPPORT) 92 rv = flexport_th3_test(unit, a, pa); 93 #endif 94 } else if (SOC_IS_TRIDENT3X(unit)) { 95 rv = flexport_td3_test(unit, a, pa); 96 } else if (SOC_IS_TRIDENT2X(unit) || 97 SOC_IS_TOMAHAWK2(unit)) { 98 rv = flexport_test(unit, a, pa); 99 } 100 101 return rv; 102 } 103 104 /* 105 * Function: 106 * flex_test_cleanup 107 * Purpose: 108 * Do test end checks and free all allocated memory. 109 * Parameters: 110 * unit - StrataSwitch Unit #. 111 * a - Pointer to arguments 112 * 113 * Returns: 114 * SOC_E_XXXX 115 */ 116 int 117 flex_test_cleanup(int unit, void *pa) 118 { 119 int rv = BCM_E_NONE; 120 121 if (SOC_IS_TOMAHAWK3(unit)) { 122 #if defined(BCM_TOMAHAWK3_SUPPORT) 123 rv = flexport_th3_test_cleanup(unit, pa); 124 #endif 125 } else if (SOC_IS_TRIDENT3X(unit)) { 126 rv = flexport_td3_test_cleanup(unit, pa); 127 } else if (SOC_IS_TRIDENT2X(unit) || 128 SOC_IS_TOMAHAWK2(unit)) { 129 rv = flexport_test_cleanup(unit, pa); 130 } 131 return rv; 132 } 133 134 135 #endif 136