init.h (8159B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 7 * 8 */ 9 10 #ifndef __BCM_INIT_H__ 11 #define __BCM_INIT_H__ 12 13 #include <bcm/types.h> 14 #include <bcm/module.h> 15 16 /* BCM Information structure. */ 17 typedef struct bcm_info_s { 18 uint32 vendor; /* PCI values used usually. */ 19 uint32 device; /* PCI values used usually. */ 20 uint32 revision; /* PCI values used usually. */ 21 uint32 capability; 22 int num_pipes; /* Number of pipes in the device. */ 23 int num_pp_pipes; /* Number of packet processing pipes in the device. */ 24 int num_buffers; /* Number of packet buffers. */ 25 } bcm_info_t; 26 27 /* Capability flags. */ 28 #define BCM_INFO_SWITCH 0x00000001 /* Network switch chip. */ 29 #define BCM_INFO_FABRIC 0x00000002 /* Fabric chip. */ 30 #define BCM_INFO_L3 0x00000004 /* Chip has layer 3. */ 31 #define BCM_INFO_IPMC 0x00000008 /* Chip has IP multicast. */ 32 33 #ifndef BCM_HIDE_DISPATCHABLE 34 35 /* Initialize the BCM software layer for a device. */ 36 extern int bcm_init( 37 int unit); 38 39 /* Initialize the BCM software layer for a device. */ 40 extern int bcm_init_selective( 41 int unit, 42 uint32 flags); 43 44 /* Check the return value from system_init() operation. */ 45 extern int bcm_init_check( 46 int unit); 47 48 #endif /* BCM_HIDE_DISPATCHABLE */ 49 50 /* Attach a device as a BCM unit. */ 51 extern int bcm_attach( 52 int unit, 53 char *type, 54 char *subtype, 55 int remunit); 56 57 /* Attach only tx and rx modules to a device as a BCM unit. */ 58 extern int bcm_attach_early_txrx( 59 int unit, 60 char *type, 61 char *subtype, 62 int remunit); 63 64 /* Detach a device as a BCM unit. */ 65 extern int bcm_detach( 66 int unit); 67 68 /* Detach all modules excluding tx and rx from BCM unit. */ 69 extern int bcm_detach_late_txrx( 70 int unit); 71 72 /* Find a matching BCM unit. */ 73 extern int bcm_find( 74 char *type, 75 char *subtype, 76 int remunit); 77 78 /* Determine if a BCM unit is attached. */ 79 extern int bcm_attach_check( 80 int unit); 81 82 /* Determine the highest BCM unit currently attached. */ 83 extern int bcm_attach_max( 84 int *max_units); 85 86 #ifndef BCM_HIDE_DISPATCHABLE 87 88 /* Get information about a BCM unit. */ 89 extern int bcm_info_get( 90 int unit, 91 bcm_info_t *info); 92 93 #endif /* BCM_HIDE_DISPATCHABLE */ 94 95 /* Groups of devices */ 96 typedef enum bcm_device_member_e { 97 bcmDeviceMemberDNX = 0, /* DNX FAP device */ 98 bcmDeviceMemberDNXF = 1, /* DNX Fabric element device */ 99 bcmDeviceMemberDPP = 2, /* DPP FAP device */ 100 bcmDeviceMemberDFE = 3, /* DFE Fabric element device */ 101 bcmDeviceMemberDNXC = 4 /* DNX FAP or Fabric element device */ 102 } bcm_device_member_t; 103 104 #ifndef BCM_HIDE_DISPATCHABLE 105 106 /* Check if device is member in group 'member_type' */ 107 extern int bcm_device_member_get( 108 int unit, 109 uint32 flags, 110 bcm_device_member_t member_type, 111 int *is_member); 112 113 /* Initialize a device excluding stacking functionality. */ 114 extern int bcm_clear( 115 int unit); 116 117 #endif /* BCM_HIDE_DISPATCHABLE */ 118 119 /* Initialize the BCM Information structure. */ 120 extern void bcm_info_t_init( 121 bcm_info_t *info); 122 123 #if !defined(BCM_WARM_BOOT_SUPPORT) 124 /* Define as empty just to be safe. */ 125 #define _bcm_shutdown(unit) BCM_E_NONE 126 #endif 127 128 #ifndef BCM_HIDE_DISPATCHABLE 129 130 #if defined(BCM_WARM_BOOT_SUPPORT) 131 /* _bcm_shutdown */ 132 extern int _bcm_shutdown( 133 int unit); 134 #endif 135 136 #endif /* BCM_HIDE_DISPATCHABLE */ 137 138 /* Device State. */ 139 typedef enum bcm_device_state_e { 140 bcmDeviceStateAttach = 0, /* Device attach. */ 141 bcmDeviceStateDetach = 1 /* Device detach. */ 142 } bcm_device_state_t; 143 144 /* Attach/detach information. */ 145 typedef struct bcm_attach_info_s { 146 int unit; /* Attach/detach unit. */ 147 const char *type; /* Attach/detach type. */ 148 const char *subtype; /* Attach/detach subtype. */ 149 int remunit; /* Attach/detach remunit. */ 150 } bcm_attach_info_t; 151 152 /* Initialize a BCM Attach Information structure. */ 153 extern void bcm_attach_info_t_init( 154 bcm_attach_info_t *info); 155 156 /* Attach/detach callback */ 157 typedef int (*bcm_attach_cb_t)( 158 int unit, 159 bcm_device_state_t state, 160 bcm_attach_info_t *info, 161 void *user_data); 162 163 /* 164 * Register/unregister a callback function to be called before 165 * BCM device attachment and after BCM device detachment. 166 */ 167 extern int bcm_attach_register( 168 int unit, 169 bcm_attach_cb_t cb, 170 void *user_data); 171 172 /* 173 * Register/unregister a callback function to be called before 174 * BCM device attachment and after BCM device detachment. 175 */ 176 extern int bcm_attach_unregister( 177 int unit, 178 bcm_attach_cb_t cb, 179 void *user_data); 180 181 /* Detach retry. */ 182 typedef struct bcm_detach_retry_s { 183 uint32 poll_usecs; /* Time poll interval in usecs. */ 184 int num_retries; /* Number of retries. */ 185 } bcm_detach_retry_t; 186 187 /* Initialize a BCM Detach Retry structure. */ 188 extern void bcm_detach_retry_t_init( 189 bcm_detach_retry_t *retry); 190 191 /* Set/get the poll interval and number of retries before detach exits. */ 192 extern int bcm_detach_retry_set( 193 int unit, 194 bcm_detach_retry_t *retry); 195 196 /* Set/get the poll interval and number of retries before detach exits. */ 197 extern int bcm_detach_retry_get( 198 int unit, 199 bcm_detach_retry_t *retry); 200 201 /* This structure should contain user's information. */ 202 typedef struct bcm_init_advanced_info_s { 203 uint32 debug_flags; /* Holds flags, such as print time stamp, print memory 204 utilization, test memory leak, etc. */ 205 } bcm_init_advanced_info_t; 206 207 #ifndef BCM_HIDE_DISPATCHABLE 208 209 /* 210 * API for initialization, caller can decide himself on flags and init 211 * info 212 */ 213 extern int bcm_init_advanced( 214 int unit, 215 bcm_init_advanced_info_t *init_advanced_info); 216 217 #endif /* BCM_HIDE_DISPATCHABLE */ 218 219 #define BCM_INIT_ADVANCED_F_MEM_LEAK_DETECT 0x1 /* Memory Leak detection 220 Activated. */ 221 #define BCM_INIT_ADVANCED_F_MEM_LOG 0x2 /* Memory Logging. */ 222 #define BCM_INIT_ADVANCED_F_TIME_STAMP 0x4 /* Time Stamp saving 223 Activated. */ 224 #define BCM_INIT_ADVANCED_F_TIME_LOG 0x8 /* Time Stamp saving 225 Activated. */ 226 #define BCM_INIT_ADVANCED_F_SWSTATE_LOG 0x10 /* SW state resources 227 Logging. */ 228 #define BCM_INIT_ADVANCED_F_ACCESS_ONLY 0x20 /* Access only booting. 229 Will run just steps 230 marked with 231 UTILEX_SEQ_STEP_F_REQUIRED_FOR_ACCESS_ONLY 232 and 233 UTILEX_SEQ_STEP_F_REQUIRED_FOR_ACCESS_ONLY. */ 234 #define BCM_INIT_ADVANCED_F_TIME_ANALYZER_LOG 0x40 /* Display time analyzer 235 logging. */ 236 #define BCM_INIT_ADVANCED_F_MULTITHREAD 0x80 /* Multithreading 237 activated. */ 238 #define BCM_INIT_ADVANCED_F_KBP_MULTITHREAD 0x100 /* KBP Multithreading 239 activated. */ 240 #define BCM_INIT_ADVANCED_F_HEAT_UP 0x200 /* Heat production 241 activated. Will run 242 minimal startup to 243 cause the device to 244 produce more heat. */ 245 246 /* Set/get the warmboot state in BCM Layer. */ 247 extern int bcm_warmboot_set( 248 int unit, 249 int warmboot); 250 251 /* Set/get the warmboot state in BCM Layer. */ 252 extern int bcm_warmboot_get( 253 int unit, 254 int *warmboot); 255 256 #endif /* __BCM_INIT_H__ */