register.h (25613B)
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: register.h 8 * Purpose: Base definitions for register types 9 * Requires: 10 */ 11 12 #ifndef _SOC_REGISTER_H 13 #define _SOC_REGISTER_H 14 15 #include <soc/defs.h> 16 #if defined(BCM_ESW_SUPPORT) || defined(BCM_SAND_SUPPORT) || defined(PORTMOD_SUPPORT) 17 #include <soc/mcm/allenum.h> 18 #endif 19 #include <sal/core/time.h> 20 #include <soc/field.h> 21 #include <soc/error.h> 22 23 /* 24 * Options for soc_reg_addr_get() 25 * 26 * WRITE - Indicates this is a call for a write operation, which 27 * may result in a different block number. 28 * PRESERVE_PORT - Preserve the value of the 'port' argument and 29 * do not make any translation to the the index 30 * (e.g. use 'port' value for physical port). 31 */ 32 #define SOC_REG_ADDR_OPTION_NONE (0x0) 33 #define SOC_REG_ADDR_OPTION_WRITE (1 << 0) 34 #define SOC_REG_ADDR_OPTION_PRESERVE_PORT (1 << 1) 35 36 37 /* argument to soc_reg_addr() */ 38 #define REG_PORT_ANY (-10) 39 40 /* use bit 31 to indicate the port argument is an instance id */ 41 #define SOC_REG_ADDR_INSTANCE_BP (31) 42 #define SOC_REG_ADDR_INSTANCE_MASK (1<<SOC_REG_ADDR_INSTANCE_BP) 43 #define SOC_REG_ADDR_SCHAN_ID_MASK (1<<(SOC_REG_ADDR_INSTANCE_BP-1)) 44 #define SOC_REG_ADDR_BLOCK_ID_MASK (1<<(SOC_REG_ADDR_INSTANCE_BP-2)) 45 #define SOC_REG_ADDR_PHY_ACC_MASK (1<<(SOC_REG_ADDR_INSTANCE_BP-3)) 46 47 #define _SOC_MAX_REGLIST (2 * SOC_MAX_NUM_PORTS * SOC_MAX_NUM_COS) 48 49 50 #define SOC_REG_FIRST_BLK_TYPE(regblklist) regblklist[0] 51 52 53 54 #define FE_GET(unit, port, reg, gth_reg, fld, var) \ 55 soc_reg_field_get(unit, reg, var, fld) 56 57 #define FE_SET(unit, port, reg, gth_reg, fld, var, val) \ 58 soc_reg_field_set(unit, reg, &var, fld, val) 59 60 #define FE_READ(reg, gth_reg, unit, port, val_p) \ 61 soc_reg32_get(unit, reg, port, 0, val_p) 62 63 #define FE_WRITE(reg, gth_reg, unit, port, val) \ 64 soc_reg32_set(unit, reg, port, 0, val) 65 66 /*************ABOVE 64 REGS******************/ 67 68 #define SOC_REG_ABOVE_64_MAX_SIZE_U32 20 69 70 typedef uint32 soc_reg_above_64_val_t[SOC_REG_ABOVE_64_MAX_SIZE_U32]; 71 72 #define SOC_REG_ABOVE_64_SET_PATTERN(reg_above_64_val, patern) \ 73 sal_memset(reg_above_64_val, patern, SOC_REG_ABOVE_64_MAX_SIZE_U32*4); 74 75 #define SOC_REG_ABOVE_64_CLEAR(reg_above_64_val) \ 76 SOC_REG_ABOVE_64_SET_PATTERN(reg_above_64_val, 0); 77 78 #define SOC_REG_ABOVE_64_ALLONES(reg_above_64_val) \ 79 SOC_REG_ABOVE_64_SET_PATTERN(reg_above_64_val, 0xFFFFFFFF); 80 81 #define SOC_REG_ABOVE_64_CREATE_MASK(reg_above_64_val, len, start) \ 82 SOC_REG_ABOVE_64_CLEAR(reg_above_64_val) \ 83 SHR_BITSET_RANGE(reg_above_64_val, start, len); 84 85 #define SOC_REG_ABOVE_64_NOT(reg_above_64_val) \ 86 SHR_BITNEGATE_RANGE(reg_above_64_val, 0, SOC_REG_ABOVE_64_MAX_SIZE_U32*32, reg_above_64_val); 87 88 #define SOC_REG_ABOVE_64_AND(reg_above_64_val1, reg_above_64_val2) \ 89 SHR_BITAND_RANGE(reg_above_64_val1, reg_above_64_val2, 0, SOC_REG_ABOVE_64_MAX_SIZE_U32*32, reg_above_64_val1); 90 91 #define SOC_REG_ABOVE_64_OR(reg_above_64_val1, reg_above_64_val2) \ 92 SHR_BITOR_RANGE(reg_above_64_val1, reg_above_64_val2, 0, SOC_REG_ABOVE_64_MAX_SIZE_U32*32, reg_above_64_val1); 93 94 #define SOC_REG_ABOVE_64_XOR(reg_above_64_val1, reg_above_64_val2) \ 95 SHR_BITXOR_RANGE(reg_above_64_val1, reg_above_64_val2, 0, SOC_REG_ABOVE_64_MAX_SIZE_U32*32, reg_above_64_val1); 96 97 #define SOC_REG_ABOVE_64_COPY(reg_above_64_val1, reg_above_64_val2) \ 98 SHR_BITCOPY_RANGE(reg_above_64_val1, 0, reg_above_64_val2, 0, SOC_REG_ABOVE_64_MAX_SIZE_U32*32); 99 100 #define SOC_REG_ABOVE_64_IS_ZERO(reg_above_64_val) \ 101 SHR_BITNULL_RANGE(reg_above_64_val, 0, SOC_REG_ABOVE_64_MAX_SIZE_U32*32) 102 103 #define SOC_REG_ABOVE_64_IS_EQUAL(reg_above_64_val1, reg_above_64_val2) \ 104 SHR_BITEQ_RANGE(reg_above_64_val1, reg_above_64_val2, 0, SOC_REG_ABOVE_64_MAX_SIZE_U32*32) 105 106 /* 107 * Copy width bits to reg_above_64_val offset reg_above_64_start_bit from bit array uint32_arr offset uint32_arr_start_bit 108 * * 109 * reg_above_64_val[reg_above_64_start_bit:reg_above_64_start_bit + width] = uint32_arr[uint32_arr_start_bit:uint32_arr_start_bit + width]* 110 */ 111 #define SOC_REG_ABOVE_64_RANGE_COPY(reg_above_64_val, reg_above_64_start_bit, uint32_arr, uint32_arr_start_bit, width) \ 112 SHR_BITCOPY_RANGE(reg_above_64_val, reg_above_64_start_bit, uint32_arr, uint32_arr_start_bit, width) 113 114 #define SOC_REG_ABOVE_64_WORD_SET(reg_above_64_val, uint32_val, uint32_index) \ 115 do \ 116 { \ 117 uint32 _val = uint32_val; \ 118 SOC_REG_ABOVE_64_RANGE_COPY(reg_above_64_val, uint32_index*32, &_val, 0, 32); \ 119 } while(0) 120 121 #define SOC_REG_ABOVE_64_SET_WORD_PATTERN(reg_above_64_val, uint32_pattern) \ 122 do \ 123 { \ 124 int _i; \ 125 for(_i = 0; _i < SOC_REG_ABOVE_64_MAX_SIZE_U32; ++_i) { \ 126 SOC_REG_ABOVE_64_WORD_SET(reg_above_64_val, uint32_pattern, _i); \ 127 } \ 128 } while(0) 129 130 #define SOC_REG_ABOVE_64_WORD_GET(reg_above_64_val, uint32_valp, uint32_index) \ 131 do \ 132 { \ 133 SHR_BITCOPY_RANGE(uint32_valp, 0, reg_above_64_val, uint32_index*32, 32); \ 134 } while(0) 135 136 /* The max number of block instances to write to by software, and not by ASIC broadcast writes */ 137 #define SOC_REG_ACCESS_INFO_MAX_NOF_BLOCKS_PER_REG 2 138 /* register information structure, needed for accessing it using s-channel */ 139 typedef struct soc_reg_access_info_s { 140 uint32 offset; /* register offset/address in its block */ 141 unsigned num_blks; /* The number of s-channel blocks */ 142 int blk_list[SOC_REG_ACCESS_INFO_MAX_NOF_BLOCKS_PER_REG]; /* The s-channel block IDs of the register, usually just one */ 143 uint8 acc_type; /* access type */ 144 } soc_reg_access_info_t; 145 146 extern int soc_reg_above_64_get(int unit, soc_reg_t reg, int port, int index, 147 soc_reg_above_64_val_t data); 148 extern int soc_reg_above_64_set(int unit, soc_reg_t reg, int port, int index, 149 soc_reg_above_64_val_t data); 150 extern void soc_reg_above_64_field_get(int unit, soc_reg_t reg, soc_reg_above_64_val_t regval, 151 soc_field_t field, soc_reg_above_64_val_t field_val); 152 extern int soc_reg_above_64_field_read(int unit, soc_reg_t reg, soc_port_t port, int index, soc_field_t field, soc_reg_above_64_val_t out_field_val); 153 extern void soc_reg_above_64_field_set(int unit, soc_reg_t reg, soc_reg_above_64_val_t regval, 154 soc_field_t field, CONST soc_reg_above_64_val_t value); 155 extern uint32 soc_reg_above_64_field32_get(int unit, soc_reg_t reg, soc_reg_above_64_val_t regval, soc_field_t field); 156 extern int soc_reg_above_64_field32_read(int unit, soc_reg_t reg, soc_port_t port, int index, soc_field_t field, uint32* out_field_val); 157 extern void soc_reg_above_64_field32_set(int unit, soc_reg_t reg, soc_reg_above_64_val_t regval, soc_field_t field, uint32 value); 158 extern uint64 soc_reg_above_64_field64_get(int unit, soc_reg_t reg, soc_reg_above_64_val_t regval, soc_field_t field); 159 extern int soc_reg_above_64_field64_read(int unit, soc_reg_t reg, soc_port_t port, int index, soc_field_t field, uint64* out_field_val); 160 extern int SOC_REG_IS_DYNAMIC(int unit, soc_reg_t reg); 161 162 /******************************************/ 163 164 /* SOC Register Routines */ 165 166 extern int soc_reg_field_length(int unit, soc_reg_t reg, soc_field_t field); 167 extern uint32 soc_reg_field_get(int unit, soc_reg_t reg, uint32 regval, 168 soc_field_t field); 169 extern int soc_ftmh_cfg_get(int unit, int * p_cfg_ftmh_lb_key_ext_en, 170 int * p_cfg_ftmh_stacking_ext_enable); 171 extern uint64 soc_reg64_field_get(int unit, soc_reg_t reg, uint64 regval, 172 soc_field_t field); 173 extern void soc_reg_field_set(int unit, soc_reg_t reg, uint32 *regval, 174 soc_field_t field, uint32 value); 175 extern void soc_reg64_field_set(int unit, soc_reg_t reg, uint64 *regval, 176 soc_field_t field, uint64 value); 177 extern uint32 soc_reg64_field32_get(int unit, soc_reg_t reg, uint64 regval, 178 soc_field_t field); 179 extern void soc_reg64_field32_set(int unit, soc_reg_t reg, uint64 *regval, 180 soc_field_t field, uint32 value); 181 extern void soc_reg_above_64_field64_set(int unit, soc_reg_t reg, soc_reg_above_64_val_t regval, 182 soc_field_t field, uint64 value); 183 extern int soc_reg_field_validate(int unit, soc_reg_t reg, soc_field_t field, uint32 value); 184 extern int soc_reg64_field_validate(int unit, soc_reg_t reg, soc_field_t field, uint64 value); 185 extern int soc_reg_signed_field_mask(int unit, soc_reg_t reg, soc_field_t field, 186 int32 value_in, uint32 *value_out); 187 extern int soc_reg_unsigned_field_mask(int unit, soc_reg_t reg, soc_field_t field, 188 int32 value_in, uint32 *value_out); 189 extern uint32 soc_reg_addr(int unit, soc_reg_t reg, int port, int index); 190 extern uint32 soc_reg_addr_get(int unit, soc_reg_t reg, int port, int index, 191 uint32 options, 192 int *blk, uint8 *acc_type); 193 extern int soc_reg_xaddr_get(int unit, soc_reg_t reg, int port, int index, 194 uint32 options, soc_reg_access_info_t *access_info); 195 extern uint32 soc_reg_datamask(int unit, soc_reg_t reg, int flags); 196 extern uint64 soc_reg64_datamask(int unit, soc_reg_t reg, int flags); 197 extern void soc_reg_above_64_datamask(int unit, soc_reg_t reg, int flags, soc_reg_above_64_val_t datamask); 198 extern int soc_reg_fields32_modify(int unit, soc_reg_t reg, soc_port_t port, 199 int field_count, soc_field_t *fields, 200 uint32 *values); 201 extern int soc_reg_field32_modify(int unit, soc_reg_t reg, soc_port_t port, 202 soc_field_t field, uint32 value); 203 extern int soc_reg_above_64_field32_modify(int unit, soc_reg_t reg, soc_port_t port, int index, 204 soc_field_t field, uint32 value); 205 extern int soc_reg_above_64_field64_modify(int unit, soc_reg_t reg, soc_port_t port, int index, 206 soc_field_t field, uint64 value); 207 extern int soc_reg_field_valid(int unit, soc_reg_t reg, soc_field_t field); 208 209 extern void soc_reg_field_acc_mode_get(int unit, soc_reg_t reg, soc_field_t field, uint32 *is_read_only, 210 uint32 *is_write_only); 211 212 /* Get register length in bytes */ 213 extern int soc_reg_bytes(int unit, soc_reg_t reg); 214 /* Get register length in bits */ 215 extern int soc_reg_bits(int unit, soc_reg_t reg); 216 217 #define SOC_REG_FIELD_VALID(_u_,_reg_,_fld_) \ 218 soc_reg_field_valid(_u_, _reg_, _fld_) 219 220 extern int soc_reg_port_idx_valid(int unit, soc_reg_t reg, soc_port_t port, int idx); 221 222 #define SOC_REG_PORT_VALID(_u_,_reg_,_port_) \ 223 soc_reg_port_idx_valid(_u_, _reg_, _port_, 0) 224 #define SOC_REG_PORT_IDX_VALID(_u_,_reg_,_port_,_idx_) \ 225 soc_reg_port_idx_valid(_u_, _reg_, _port_, _idx_) 226 227 void soc_reg_init(void); 228 229 typedef struct soc_large_reg_info_t { 230 uint32 size; /*Size in uint32*/ 231 uint32* reset; 232 uint32* mask; 233 } soc_reg_above_64_info_t; 234 235 /* Flags for memory snooping callback register */ 236 #define SOC_REG_SNOOP_WRITE 0x00000001 /* snooping write operations */ 237 #define SOC_REG_SNOOP_READ 0x00000002 /* snooping read operations */ 238 239 240 /* additional information for registers which are arrays */ 241 /* To be used if in soc_reg_info_t, the SOC_REG_FLAG_REG_ARRAY bit is set */ 242 typedef struct soc_reg_array_info_t { /* additional information for register which are arrays */ 243 uint32 element_skip; /* how many bytes to skip between array elements */ 244 } soc_reg_array_info_t; 245 246 typedef struct soc_regaddrinfo_t { 247 uint32 addr; 248 int valid; 249 soc_reg_t reg; /* INVALIDr if not used */ 250 int idx; /* If array, this is an index */ 251 soc_block_t block; /* SOC_BLK_NONE if not used */ 252 soc_port_t port; /* -1 if not used */ 253 soc_cos_t cos; /* -1 if not used */ 254 int is_custom; /* custom regs use soc_custom_reg_access_t API's instead of standart soc_reg_set/get */ 255 uint8 acc_type; 256 soc_field_t field; /* INVALIDf for entire reg */ 257 } soc_regaddrinfo_t; 258 /* Routines to register/unregister UserCallBack routine for register snooping */ 259 typedef void (*soc_reg_snoop_cb_t) (int unit, soc_reg_t reg, 260 soc_regaddrinfo_t *ainfo, uint32 flags, 261 uint32 data_hi, uint32 data_lo, 262 void *user_data); 263 void soc_reg_snoop_register(int unit, soc_reg_t reg, uint32 flags, 264 soc_reg_snoop_cb_t snoop_cb, void *user_data); 265 266 void soc_reg_snoop_unregister(int unit, soc_reg_t reg); 267 268 #define SOC_REG_FLAG_64_BITS (1<<0) /* Register is 64 bits wide */ 269 #define SOC_REG_FLAG_COUNTER (1<<1) /* Register is a counter */ 270 #define SOC_REG_FLAG_ARRAY (1<<2) /* Register is an array */ 271 #define SOC_REG_FLAG_NO_DGNL (1<<3) /* Array does not have diagonal els */ 272 #define SOC_REG_FLAG_RO (1<<4) /* Register is write only */ 273 #define SOC_REG_FLAG_WO (1<<5) /* Register is read only */ 274 #define SOC_REG_FLAG_ED_CNTR (1<<6) /* Counter of discard/error */ 275 #define SOC_REG_FLAG_SPECIAL (1<<7) /* Counter requires special 276 processing */ 277 #define SOC_REG_FLAG_EMULATION (1<<8) /* Available only in emulation */ 278 #define SOC_REG_FLAG_VARIANT1 (1<<9) /* Not available in chip variants */ 279 #define SOC_REG_FLAG_VARIANT2 (1<<10) /* -- '' -- */ 280 #define SOC_REG_FLAG_VARIANT3 (1<<11) /* -- '' -- */ 281 #define SOC_REG_FLAG_VARIANT4 (1<<12) /* -- '' -- */ 282 #define SOC_REG_FLAG_32_BITS (1<<13) /* Register is 32 bits wide */ 283 #define SOC_REG_FLAG_16_BITS (1<<14) /* Register is 16 bits wide */ 284 #define SOC_REG_FLAG_8_BITS (1<<15) /* Register is 8 bits wide */ 285 #define SOC_REG_FLAG_ARRAY2 (1<<16) /* Register is an array with stride 2*/ 286 #define SOC_REG_FLAG_ARRAY4 (1<<17) /* Register is an array with stride 4*/ 287 #define SOC_REG_FLAG_ABOVE_64_BITS (1<<20) /* Register is above 64 bits wide */ 288 #define SOC_REG_FLAG_REG_ARRAY (1<<21) /* This is a register array with indexed access */ 289 #define SOC_REG_FLAG_INTERRUPT (1<<22) /* This is register is an interrupt */ 290 #define SOC_REG_FLAG_GENERAL_COUNTER (1<<23) /* This is a general counter */ 291 #define SOC_REG_FLAG_SIGNAL (1<<24) /* this is signal register */ 292 #define SOC_REG_FLAG_IGNORE_DEFAULT (1<<25) /* this is register, default value of it should be ignored */ 293 #define SOC_REG_FLAG_ACC_TYPE_MASK 0x1f /* Access type */ 294 #define SOC_REG_FLAG_ACC_TYPE_SHIFT 26 295 #define SOC_REG_ACC_TYPE(unit, reg) ((SOC_REG_INFO(unit, reg).flags >> \ 296 SOC_REG_FLAG_ACC_TYPE_SHIFT) & \ 297 SOC_REG_FLAG_ACC_TYPE_MASK) 298 #define SOC_REG_BASE_TYPE(unit, reg) ((SOC_REG_INFO(unit, reg).offset >> \ 299 23) & 0x7) 300 301 /* Bit Definitios for flags1 */ 302 #define SOC_REG_FLAG_CCH (1<<0) /* Register is CCH */ 303 #define SOC_REG_FLAG_COUNTER_FEILDS (1<<1) /* Register counter fields */ 304 #define SOC_REG_FLAG_CLEAR_BITS_ON_WRITE (1<<2) /* this is a register that is clearing bits on write */ 305 #define SOC_REG_FLAG_INIT_ON_READ (1<<3) /* this is a register that is initilized on read */ 306 307 typedef struct soc_reg_info_t { 308 soc_block_types_t block; 309 soc_regtype_t regtype; /* Also indicates invalid */ 310 int numels; /* If array, num els in array. */ 311 /* Otherwise -1. */ 312 uint32 first_array_index; /* first index of arrays */ 313 uint32 offset; /* Includes 2-bit form field */ 314 315 uint32 flags; 316 uint32 flags1; 317 int nFields; 318 soc_field_info_t *fields; 319 #if !defined(SOC_NO_RESET_VALS) 320 uint32 rst_val_lo; 321 uint32 rst_val_hi; /* 64-bit regs only */ 322 uint32 rst_mask_lo; /* 1 where resetVal is valid */ 323 uint32 rst_mask_hi; /* 64-bit regs only */ 324 #endif 325 int ctr_idx; /* Counters only; sw idx */ 326 int numelportlist_idx; /* Per-Port Registers Only */ 327 uint32 access_latency_mode; /* accessibility in latency mode */ 328 soc_reg_snoop_cb_t snoop_cb; /* UserCallBack for snooping register*/ 329 void *snoop_user_data; /* User data for callback function */ 330 uint32 snoop_flags; /* Snooping flags SOC_REG_SNOOP_* */ 331 } soc_reg_info_t; 332 333 334 typedef struct soc_regaddrlist_t { 335 int count; 336 soc_regaddrinfo_t *ainfo; 337 } soc_regaddrlist_t; 338 339 typedef struct soc_numelport_set_t { 340 int f_idx; 341 int l_idx; 342 int pl_idx; 343 } soc_numelport_set_t; 344 345 #ifdef BCM_CMICM_SUPPORT 346 typedef struct soc_cmicm_reg_t { 347 uint32 addr; 348 char *name; 349 soc_reg_t reg; 350 } soc_cmicm_reg_t; 351 352 extern soc_cmicm_reg_t *soc_cmicm_reg_get(uint32 idx); 353 extern soc_reg_t soc_cmicm_addr_reg(uint32 addr); 354 extern char *soc_cmicm_addr_name(uint32 addr); 355 #endif 356 357 #ifdef BCM_CMICX_SUPPORT 358 typedef struct soc_cmicx_reg_t { 359 uint32 addr; 360 char *name; 361 soc_reg_t reg; 362 } soc_cmicx_reg_t; 363 364 extern soc_cmicx_reg_t *soc_cmicx_reg_get(uint32 idx); 365 extern soc_reg_t soc_cmicx_addr_reg(uint32 addr); 366 extern char *soc_cmicx_addr_name(uint32 addr); 367 extern int soc_parse_cmicx_regname(int unit, char *name, uint32 *offset_ptr); 368 #endif 369 370 extern int soc_regaddrlist_alloc(soc_regaddrlist_t *addrlist); 371 extern int soc_regaddrlist_free(soc_regaddrlist_t *addrlist); 372 373 /* Function for register iteration. */ 374 typedef int (*soc_reg_iter_f)(int unit, soc_regaddrinfo_t *ainfo, void *data); 375 376 extern void soc_regaddrinfo_get(int unit, soc_regaddrinfo_t *ainfo, 377 uint32 addr); 378 extern void soc_regaddrinfo_extended_get(int unit, soc_regaddrinfo_t *ainfo, 379 soc_block_t block, int acc_type, 380 uint32 addr); 381 extern void soc_cpuregaddrinfo_get(int unit, soc_regaddrinfo_t *ainfo, 382 uint32 addr); 383 384 extern int soc_reg_iterate(int unit, soc_reg_iter_f do_it, void *data); 385 386 extern void soc_reg_sprint_addr(int unit, char *bp, 387 soc_regaddrinfo_t *ainfo); 388 389 extern void soc_reg_sprint_data(int unit, char *bp, char *infix, 390 soc_reg_t reg, uint32 value); 391 392 393 /* In soc_common.c */ 394 extern char *soc_regtypenames[]; 395 extern int soc_regtype_gran[]; 396 397 /* 398 * The following callbacks are used to allow registration of user defined callbacks for 399 * registers and memories operations. 400 */ 401 typedef int (*soc_reg32_get_f) (int unit, soc_reg_t reg, int port, int index, uint32* data); 402 typedef int (*soc_reg64_get_f) (int unit, soc_reg_t reg, int port, int index, uint64* data); 403 typedef int (*soc_reg_above64_get_f)(int unit, soc_reg_t reg, int port, int index, soc_reg_above_64_val_t data); 404 405 typedef int (*soc_reg32_set_f) (int unit, soc_reg_t reg, int port, int index, uint32 data); 406 typedef int (*soc_reg64_set_f) (int unit, soc_reg_t reg, int port, int index, uint64 data); 407 typedef int (*soc_reg_above64_set_f)(int unit, soc_reg_t reg, int port, int index, soc_reg_above_64_val_t data); 408 409 typedef int (*soc_mem_array_read_f) (int unit, soc_mem_t mem, unsigned array_index, int copyno, int index, void *entry_data); 410 typedef int (*soc_mem_array_write_f)(int unit, soc_mem_t mem, unsigned array_index, int copyno, int index, void *entry_data); 411 412 typedef struct soc_reg_access_s { 413 soc_reg32_get_f reg32_get; 414 soc_reg64_get_f reg64_get; 415 soc_reg_above64_get_f reg_above64_get; 416 417 soc_reg32_set_f reg32_set; 418 soc_reg64_set_f reg64_set; 419 soc_reg_above64_set_f reg_above64_set; 420 421 soc_mem_array_read_f mem_read; 422 soc_mem_array_write_f mem_write; 423 424 } soc_reg_access_t; 425 426 typedef struct soc_custom_reg_access_s { 427 soc_reg32_get_f custom_reg32_get; 428 soc_reg64_get_f custom_reg64_get; 429 soc_reg_above64_get_f custom_reg_above64_get; 430 431 soc_reg32_set_f custom_reg32_set; 432 soc_reg64_set_f custom_reg64_set; 433 soc_reg_above64_set_f custom_reg_above64_set; 434 435 soc_pbmp_t custom_port_pbmp; 436 437 } soc_custom_reg_access_t; 438 439 typedef int (*soc_polling_f) (int unit, sal_usecs_t time_out, int32 min_polls, soc_reg_t reg, int32 port, int32 index, soc_field_t field, uint32 expected_value); 440 typedef int (*soc_direct_reg_set_f) (int unit, int cmic_block, uint32 addr, uint32 dwc_write, uint32 *data); 441 typedef int (*soc_fast_reg_set_f) (int unit, soc_reg_t reg, int acc_type, int addr, int block, soc_reg_above_64_val_t data); 442 typedef int (*soc_fast_reg_get_f) (int unit, soc_reg_t reg, int acc_type, int addr, int block, soc_reg_above_64_val_t data); 443 444 typedef int (*soc_reg_set_f) (int unit, soc_reg_t reg, int port, int index, uint64 data); 445 typedef int (*soc_reg_get_f) (int unit, soc_reg_t reg, int port, int index, uint64 *data); 446 typedef int (*soc_reg_set_nocache_f) (int unit, soc_reg_t reg, int port, int index, uint64 data); 447 448 #ifdef CRASH_RECOVERY_SUPPORT 449 /* callbacks specific to CRASH RECOVERY */ 450 typedef int (*soc_mem_sbusdma_write_f) (int unit, int flags, soc_mem_t mem, unsigned array_index_start, unsigned array_index_end, int copyno, int index_begin, int index_end, void *buffer, uint8 mem_clear, int clear_buf_ent, int vchan); 451 typedef int (*soc_mem_sbusdma_read_f) (int unit, soc_mem_t mem, unsigned array_index, 452 int copyno, int index_min, int index_max, 453 uint32 ser_flags, void *buffer, int vchan); 454 455 typedef int (*soc_mem_descdma_read_f) (int unit, soc_mem_t mem, unsigned array_index, int copyno, int index, void *entry_data); 456 typedef int (*soc_mem_descdma_write_f)(int unit, soc_mem_t mem, unsigned array_index, int copyno, int index, void *entry_data); 457 458 459 typedef struct soc_hw_log_access_s { 460 soc_reg32_get_f reg32_get; 461 soc_reg64_get_f reg64_get; 462 soc_reg_above64_get_f reg_above64_get; 463 464 soc_reg32_set_f reg32_set; 465 soc_reg64_set_f reg64_set; 466 soc_reg_above64_set_f reg_above64_set; 467 468 soc_mem_array_read_f mem_read; 469 soc_mem_array_write_f mem_write; 470 471 soc_polling_f polling; 472 soc_direct_reg_set_f direct_reg_set; 473 soc_fast_reg_set_f fast_reg_set; 474 soc_fast_reg_get_f fast_reg_get; 475 476 soc_reg_set_f soc_reg_set; 477 soc_reg_get_f soc_reg_get; 478 479 soc_reg_set_nocache_f soc_reg_set_nocache; 480 481 soc_mem_sbusdma_write_f soc_sbusdma_write; 482 soc_mem_sbusdma_read_f soc_sbusdma_read; 483 484 soc_mem_descdma_write_f soc_descdma_write; 485 } soc_hw_log_access_t; 486 #endif /* CRASH_RECOVERY_SUPPORT */ 487 488 489 int soc_reg_access_func_register(int unit, soc_reg_access_t* reg_access) ; 490 491 typedef struct soc_reg_brdc_block_info_s 492 { 493 soc_block_t blk_type; 494 int blk_ids[SOC_MAX_NUM_BLKS]; /*ids for schan commands of the blocks that controlled by the brdc block 495 last element must be set to -1*/ 496 } soc_reg_brdc_block_info_t; 497 498 #if defined(SER_TR_TEST_SUPPORT) 499 #define SOC_MAX_REG_NAME_LEN 200 500 501 typedef struct ser_reg_test_data_s { 502 soc_reg_t reg; /* reg for error inject */ 503 soc_reg_t parity_enable_reg; 504 soc_field_t parity_enable_field; 505 soc_port_t port; 506 int index; 507 soc_reg_info_t *reg_info; 508 soc_field_t test_field; 509 uint64 *reg_buf; 510 uint32 *field_buf; 511 char reg_name[SOC_MAX_REG_NAME_LEN]; 512 char field_name[SOC_MAX_REG_NAME_LEN]; 513 uint32 badData; 514 } ser_reg_test_data_t; 515 516 extern void soc_ser_create_reg_test_data(int unit, uint32 *reg_data, uint32 *field_data, 517 soc_reg_t parity_enable_reg, 518 soc_field_t parity_enable_field, 519 soc_reg_t reg, soc_field_t test_field, 520 soc_port_t port, int index, 521 ser_reg_test_data_t *reg_test_data); 522 523 extern soc_error_t ser_test_reg(int unit, ser_reg_test_data_t *test_reg, 524 int *error_count); 525 526 #endif 527 528 #endif /* !_SOC_REGISTER_H */