openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

apache.h (31397B)


      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:        apache.h
      8  */
      9 
     10 #ifndef _SOC_APACHE_H_
     11 #define _SOC_APACHE_H_
     12 
     13 #include <soc/drv.h>
     14 #include <soc/mem.h>
     15 #include <soc/error.h>
     16 #include <soc/esw/port.h>
     17 
     18 #define SOC_APACHE_NUM_EL_L2                             4
     19 #define SOC_APACHE_NUM_EL_SHARED                         4
     20 #define SOC_APACHE_NUM_EL_L3                             4
     21 #define SOC_APACHE_NUM_EL_ALPM                           4
     22 #define SOC_APACHE_NUM_EL_VLAN_XLATE                     4
     23 #define SOC_APACHE_NUM_EL_EGR_VLAN_XLATE                 4
     24 #define SOC_APACHE_NUM_EL_ING_L3_NEXT_HOP(unit) \
     25         SOC_BOND_INFO_FEATURE_GET(unit, socBondInfoFeatureL3NHop8k) ? 2 : 8
     26 #define SOC_APACHE_NUM_EL_L3_IPMC(unit) \
     27         SOC_BOND_INFO_FEATURE_GET(unit, socBondInfoFeatureIpmc4k) ? 2 : 4
     28 
     29 #define SOC_APACHE_NUM_EL_L2MC                           6
     30 
     31 #define SOC_APACHE_RAM_OFFSET_L3_NARROW               8192
     32 #define SOC_APACHE_RAM_OFFSET_L3_WIDE                 4096
     33 #define SOC_APACHE_RAM_OFFSET_L3_DOUBLE_WIDE          2048
     34 
     35 #define SOC_APACHE_RAM_OFFSET_ING_L3_NEXT_HOP         4096
     36 #define SOC_APACHE_RAM_OFFSET_L3_IPMC                 2048
     37 #define SOC_APACHE_RAM_OFFSET_L2MC                    4096
     38 
     39 #define SOC_APACHE_L3_DEFIP_ALPM_PER_BKT_COUNT           1
     40 #define SOC_APACHE_L3_DEFIP_ALPM_IPV6_128_PER_BKT_COUNT  2
     41 #define SOC_APACHE_L3_DEFIP_ALPM_IPV6_64_1_PER_BKT_COUNT 3
     42 #define SOC_APACHE_L3_DEFIP_ALPM_IPV6_64_PER_BKT_COUNT   4
     43 #define SOC_APACHE_L3_DEFIP_ALPM_IPV4_1_PER_BKT_COUNT    4
     44 #define SOC_APACHE_L3_DEFIP_ALPM_IPV4_PER_BKT_COUNT      6
     45 
     46 #define SOC_APACHE_NUM_BKTS_PER_L2_BANK               2048
     47 #define SOC_APACHE_NUM_BKTS_PER_L3_BANK                256
     48 #define SOC_APACHE_NUM_BKTS_PER_SHARED_BANK          16384
     49 
     50 #define SOC_APACHE_NUM_ENTRIES_L2_BANK               16384
     51 #define SOC_APACHE_NUM_ENTRIES_L3_BANK                4096
     52 #define SOC_APACHE_NUM_ENTRIES_L3_BANK_WIDE           8192
     53 #define SOC_APACHE_NUM_ENTRIES_L3_BANK_DOUBLE_WIDE    4096
     54 
     55 #define SOC_APACHE_ALPM_MAX_BKTS                     16384
     56 #define SOC_APACHE_ALPM_BKT_OFFFSET                   2048
     57 #define SOC_APACHE_ALPM_BKT_MASK                    0x3FFF
     58 
     59 #define _SOC_APACHE_L2LU_INTR_MASK                 0x01000
     60 #define _SOC_APACHE_FUNC_INTR_MASK _SOC_APACHE_L2LU_INTR_MASK
     61 
     62 typedef enum soc_apache_port_ct_speed_e {
     63     SOC_APACHE_PORT_CT_SPEED_NONE = 0, /* Always First */
     64     SOC_APACHE_PORT_CT_SPEED_10M_FULL,
     65     SOC_APACHE_PORT_CT_SPEED_100M_FULL,
     66     SOC_APACHE_PORT_CT_SPEED_1000M_FULL,
     67     SOC_APACHE_PORT_CT_SPEED_2500M_FULL,
     68     SOC_APACHE_PORT_CT_SPEED_5000M_FULL,
     69     SOC_APACHE_PORT_CT_SPEED_10000M_FULL,
     70     SOC_APACHE_PORT_CT_SPEED_11000M_FULL,
     71     SOC_APACHE_PORT_CT_SPEED_20000M_FULL,
     72     SOC_APACHE_PORT_CT_SPEED_21000M_FULL,
     73     SOC_APACHE_PORT_CT_SPEED_25000M_FULL,
     74     SOC_APACHE_PORT_CT_SPEED_27000M_FULL,
     75     SOC_APACHE_PORT_CT_SPEED_40000M_FULL,
     76     SOC_APACHE_PORT_CT_SPEED_42000M_FULL,
     77     SOC_APACHE_PORT_CT_SPEED_50000M_FULL,
     78     SOC_APACHE_PORT_CT_SPEED_53000M_FULL,
     79     SOC_APACHE_PORT_CT_SPEED_100000M_FULL,
     80     SOC_APACHE_PORT_CT_SPEED_106000M_FULL
     81 } soc_apache_port_ct_speed_t;
     82 
     83 #define SOC_APACHE_NUM_MMU_PORTS_PER_PIPE               75
     84 
     85 #define _APACHE_MMU_NUM_POOL                            4
     86 #define _APACHE_MMU_NUM_RQE_QUEUES                     11
     87 
     88 
     89 
     90 #define _AP_PORTS_PER_TSC         4
     91 #define _AP_TSCS_PER_PGW          9
     92 #define _AP_NUM_XLP_PER_PGW       7
     93 #define _AP_NUM_CLP_PER_PGW       2
     94 #define _AP_PGWS_PER_DEV          2
     95 
     96 #define _AP_PORTS_PER_PGW         (_AP_PORTS_PER_TSC * _AP_TSCS_PER_PGW)
     97 #define _AP_PORTS_PER_PIPE        (_AP_PORTS_PER_PGW * _AP_PGWS_PER_DEV)
     98 
     99 
    100 
    101 #define AP_PHY_PORT_CPU           0
    102 #define AP_PHY_PORT_LB            73
    103 #define AP_PHY_PORT_RDB           74
    104 
    105 typedef enum {
    106     SOC_APACHE_SCHED_MODE_UNKNOWN = 0,
    107     SOC_APACHE_SCHED_MODE_STRICT,
    108     SOC_APACHE_SCHED_MODE_WRR,
    109     SOC_APACHE_SCHED_MODE_WDRR
    110 } soc_apache_sched_mode_e;
    111 
    112 typedef enum {
    113     SOC_APACHE_NODE_LVL_ROOT = 0,
    114     SOC_APACHE_NODE_LVL_S1,
    115     SOC_APACHE_NODE_LVL_L0,
    116     SOC_APACHE_NODE_LVL_L1,
    117     SOC_APACHE_NODE_LVL_L2,
    118     SOC_APACHE_NODE_LVL_MAX
    119 } soc_apache_node_lvl_e;
    120 
    121 typedef enum {
    122     _SOC_APACHE_INDEX_STYLE_BUCKET,
    123     _SOC_APACHE_INDEX_STYLE_BUCKET_MODE,
    124     _SOC_APACHE_INDEX_STYLE_WRED,
    125     _SOC_APACHE_INDEX_STYLE_WRED_DROP_THRESH,
    126     _SOC_APACHE_INDEX_STYLE_SCHEDULER,
    127     _SOC_APACHE_INDEX_STYLE_PERQ_XMT,
    128     _SOC_APACHE_INDEX_STYLE_UCAST_DROP,
    129     _SOC_APACHE_INDEX_STYLE_UCAST_QUEUE,
    130     _SOC_APACHE_INDEX_STYLE_MCAST_QUEUE,
    131     _SOC_APACHE_INDEX_STYLE_EXT_UCAST_QUEUE,
    132     _SOC_APACHE_INDEX_STYLE_EGR_POOL,
    133     _SOC_APACHE_INDEX_STYLE_COUNT
    134 } soc_apache_index_style_t;
    135 
    136 typedef enum soc_apache_drop_limit_alpha_value_e {
    137     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_1_128, /* Use 1/128 as the alpha value for
    138                                            dynamic threshold */
    139     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_1_64, /* Use 1/64 as the alpha value for
    140                                            dynamic threshold */
    141     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_1_32, /* Use 1/32 as the alpha value for
    142                                            dynamic threshold */
    143     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_1_16, /* Use 1/16 as the alpha value for
    144                                            dynamic threshold */
    145     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_1_8, /* Use 1/8 as the alpha value for
    146                                            dynamic threshold */                                          
    147     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_1_4, /* Use 1/4 as the alpha value for
    148                                            dynamic threshold */
    149     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_1_2, /* Use 1/2 as the alpha value for
    150                                            dynamic threshold */
    151     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_1,  /* Use 1 as the alpha value for dynamic
    152                                            threshold */
    153     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_2,  /* Use 2 as the alpha value for dynamic
    154                                            threshold */
    155     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_4,  /* Use 4 as the alpha value for dynamic
    156                                            threshold */
    157     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_8,  /* Use 8 as the alpha value for dynamic
    158                                            threshold */
    159     SOC_APACHE_COSQ_DROP_LIMIT_ALPHA_COUNT /* Must be the last entry! */
    160 } soc_apache_drop_limit_alpha_value_t;
    161 
    162 extern soc_functions_t soc_apache_drv_funs;
    163 extern soc_functions_t soc_monterey_drv_funs;
    164 extern void soc_apache_ser_set_long_delay(int delay);
    165 extern int _soc_apache_mem_ser_control(int unit, soc_mem_t mem,
    166                                          int copyno, int enable);
    167 extern int _soc_apache_mem_cpu_write_control(int unit, soc_mem_t mem,
    168                                                int copyno, int enable,
    169                                                int *orig_enable);
    170 extern int soc_apache_ser_mem_clear(int unit, soc_mem_t mem);
    171 extern void _soc_apache_alpm_bkt_view_set(int unit, int index, soc_mem_t view);
    172 extern soc_mem_t _soc_apache_alpm_bkt_view_get(int unit, int index);
    173 extern void soc_apache_sbus_ring_map_config(int unit);
    174 extern int soc_apache_mem_config(int unit);
    175 extern int _soc_apache_mem_sram_info_get(int unit, soc_mem_t mem, int index, 
    176                                            _soc_ser_sram_info_t *sram_info);
    177 extern int soc_apache_pipe_select(int unit, int egress, int pipe);
    178 extern int soc_apache_num_cosq_init(int unit);
    179 extern int soc_apache_tsc_map_get(int unit, uint32 *tsc_map, uint32 *force_hg);
    180 extern int soc_apache_port_config_init(int unit, uint16 dev_id, uint8 rev_id);
    181 extern int soc_apache_port_config_bandwidth_check(int unit);
    182 extern soc_error_t
    183 soc_apache_port_reg_blk_index_get(int unit ,int port, soc_block_type_t blktype, int *block);
    184 extern int soc_apache_lls_bmap_alloc(int unit);
    185 extern int soc_apache_chip_reset(int unit);
    186 extern int soc_apache_tsc_reset(int unit);
    187 extern int soc_apache_l3_defip_index_map(int unit, soc_mem_t mem, int index);
    188 extern int soc_apache_l3_defip_index_remap(int unit, soc_mem_t mem, int index);
    189 extern int soc_apache_l3_defip_mem_index_get(int unit, int pindex, soc_mem_t *mem);
    190 extern int soc_apache_mem_is_eligible_for_scan(int unit, soc_mem_t mem);
    191 extern int soc_apache_ser_test_skip_check(int unit, soc_mem_t mem);
    192 extern int soc_ap_is_skip_default_lls_creation(int unit);
    193 
    194 extern void
    195 soc_apache_top_intr(void *unit_vp, void *d1, void *d2,
    196                                    void *d3, void *d4);
    197 extern int soc_apache_temperature_monitor_get(int unit,
    198                int temperature_max,
    199                soc_switch_temperature_monitor_t *temperature_array,
    200                int *temperature_count);
    201 extern int soc_apache_show_material_process(int unit);
    202 extern int soc_apache_show_ring_osc(int unit);
    203 extern int soc_apache_show_voltage(int unit);
    204 extern int soc_apache_bond_info_init(int unit);
    205 
    206 enum soc_apache_port_mode_e {
    207     /* WARNING: values given match hardware register; do not modify */
    208     SOC_APACHE_PORT_MODE_QUAD = 0,
    209     SOC_APACHE_PORT_MODE_TRI_012 = 1,
    210     SOC_APACHE_PORT_MODE_TRI_023 = 2,
    211     SOC_APACHE_PORT_MODE_DUAL = 3,
    212     SOC_APACHE_PORT_MODE_SINGLE = 4
    213 };
    214 
    215 extern int      soc_apache_hash_bank_count_get(int unit, soc_mem_t mem,
    216                                                  int *num_banks);
    217 extern int      soc_apache_hash_bank_phy_bitmap_get(int unit, soc_mem_t mem,
    218                                                   uint32 *bitmap);
    219 extern int      soc_apache_hash_bank_number_get(int unit, soc_mem_t mem,
    220                                                   int seq_num, int *bank_num);
    221 extern int      soc_apache_hash_seq_number_get(int unit, soc_mem_t mem, 
    222                                                   int bank_num, int *seq_num);
    223 extern int      soc_apache_hash_bank_info_get(int unit, soc_mem_t mem,
    224                                                 int bank,
    225                                                 int *entries_per_bank,
    226                                                 int *entries_per_row,
    227                                                 int *entries_per_bucket,
    228                                                 int *bank_base,
    229                                                 int *bucket_offset);
    230 extern int      soc_ap_hash_offset_get(int unit, soc_mem_t mem, int bank,
    231                                         int *hash_offset, int *use_lsb);
    232 extern int      soc_ap_hash_offset_set(int unit, soc_mem_t mem, int bank,
    233                                        int hash_offset, int use_lsb);
    234 extern uint32   soc_ap_l2x_hash(int unit, int bank, int hash_offset,
    235                                  int use_lsb, int key_nbits, void *base_entry,
    236                                  uint8 *key);
    237 extern int      soc_ap_l2x_base_entry_to_key(int unit, uint32 *entry,
    238                                               uint8 *key);
    239 extern uint32   soc_ap_l2x_entry_hash(int unit, int bank, int hash_offset,
    240                                        int use_lsb, uint32 *entry);
    241 extern uint32   soc_ap_l2x_bank_entry_hash(int unit, int bank, uint32 *entry);
    242 extern uint32   soc_ap_l3x_hash(int unit, int bank, int hash_offset,
    243                                  int use_lsb, int key_nbits, void *base_entry,
    244                                  uint8 *key);
    245 extern int      soc_ap_l3x_base_entry_to_key(int unit, uint32 *entry,
    246                                               uint8 *key);
    247 extern uint32   soc_ap_l3x_entry_hash(int unit, int bank, int hash_offset,
    248                                        int use_lsb, uint32 *entry);
    249 extern uint32   soc_ap_l3x_bank_entry_hash(int unit, int bank, uint32 *entry);
    250 extern uint32   soc_ap_mpls_hash(int unit, int hash_sel, int key_nbits,
    251                                   void *base_entry, uint8 *key);
    252 extern int      soc_ap_mpls_base_entry_to_key(int unit, void *entry,
    253                                                uint8 *key);
    254 extern uint32   soc_ap_mpls_entry_hash(int unit, int hash_sel, int bank,
    255                                        uint32 *entry);
    256 extern uint32   soc_ap_mpls_bank_entry_hash(int unit, int bank, uint32 *entry);
    257 extern uint32   soc_ap_vlan_xlate_hash(int unit, int hash_sel, int key_nbits,
    258                                         void *base_entry, uint8 *key);
    259 extern int      soc_ap_vlan_xlate_base_entry_to_key(int unit, void *entry,
    260                                                      uint8 *key);
    261 extern uint32   soc_ap_vlan_xlate_entry_hash(int unit, int hash_sel, int bank,
    262                                               uint32 *entry);
    263 extern uint32   soc_ap_vlan_xlate_bank_entry_hash(int unit, int bank,
    264                                                    uint32 *entry);
    265 extern uint32   soc_ap_egr_vlan_xlate_hash(int unit, int hash_sel,
    266                                             int key_nbits, void *base_entry,
    267                                             uint8 *key);
    268 extern int      soc_ap_egr_vlan_xlate_base_entry_to_key(int unit, void *entry,
    269                                                          uint8 *key);
    270 extern uint32   soc_ap_egr_vlan_xlate_entry_hash(int unit, int hash_sel, 
    271                                                  int bank, uint32 *entry);
    272 extern uint32   soc_ap_egr_vlan_xlate_bank_entry_hash(int unit, int bank,
    273                                                        uint32 *entry);
    274 extern uint32   soc_ap_ing_vp_vlan_member_hash(int unit, int hash_sel,
    275                                                 int key_nbits,
    276                                                 void *base_entry, uint8 *key);
    277 extern int      soc_ap_ing_vp_vlan_member_base_entry_to_key(int unit,
    278                                                              void *entry,
    279                                                              uint8 *key);
    280 extern uint32   soc_ap_ing_vp_vlan_member_entry_hash(int unit, int hash_sel,
    281                                                      int bank, uint32 *entry);
    282 extern uint32   soc_ap_egr_vp_vlan_member_hash(int unit, int hash_sel,
    283                                                 int key_nbits,
    284                                                 void *base_entry, uint8 *key);
    285 extern int      soc_ap_egr_vp_vlan_member_base_entry_to_key(int unit,
    286                                                              void *entry,
    287                                                              uint8 *key);
    288 extern uint32   soc_ap_egr_vp_vlan_member_entry_hash(int unit, int hash_sel,
    289                                                      int bank, uint32 *entry);
    290 extern uint32   soc_ap_ing_dnat_address_type_hash(int unit, int hash_sel,
    291                                                    int key_nbits,
    292                                                    void *base_entry,
    293                                                    uint8 *key);
    294 extern int      soc_ap_ing_dnat_address_type_base_entry_to_key(int unit,
    295                                                                 void *entry,
    296                                                                 uint8 *key);
    297 extern uint32   soc_ap_ing_dnat_address_type_entry_hash(int unit,
    298                                                          int hash_sel,
    299                                                          int bank,
    300                                                          uint32 *entry);
    301 extern uint32   soc_ap_l2_endpoint_id_hash(int unit, int hash_sel,
    302                                             int key_nbits, void *base_entry,
    303                                             uint8 *key);
    304 extern int      soc_ap_l2_endpoint_id_base_entry_to_key(int unit, void *entry,
    305                                                          uint8 *key);
    306 extern uint32   soc_ap_l2_endpoint_id_entry_hash(int unit, int hash_sel,
    307                                                  int bank,
    308                                                   uint32 *entry);
    309 extern uint32   soc_ap_endpoint_queue_map_hash(int unit, int hash_sel,
    310                                                 int key_nbits,
    311                                                 void *base_entry,
    312                                                 uint8 *key);
    313 extern int      soc_ap_endpoint_queue_map_base_entry_to_key(int unit,
    314                                                              void *entry,
    315                                                              uint8 *key);
    316 extern uint32   soc_ap_endpoint_queue_map_entry_hash(int unit, int hash_sel,
    317                                                      int bank,
    318                                                       uint32 *entry);
    319 extern int      soc_ap_hash_bucket_get(int unit, int mem, int bank,
    320                                     uint32 *entry, uint32 *bucket);
    321 extern int      soc_ap_hash_index_get(int unit, int mem, int bank, int bucket);
    322 
    323 extern int 
    324 soc_apache_get_def_qbase(int unit, soc_port_t inport, int qtype, 
    325                        int *pbase, int *pnumq);
    326 
    327 #define SOC_APACHE_PORT_PIPE(u, p) 0
    328 
    329 extern uint32 _soc_apache_mmu_port(int unit, int port);
    330 
    331 #define SOC_APACHE_MMU_PORT(u, p)  _soc_apache_mmu_port((u),(p))
    332 
    333 extern uint32 _soc_apache_piped_mem_index(int unit, soc_port_t port,
    334                                  soc_mem_t mem, int arr_off);
    335 
    336 #define SOC_APACHE_MMU_PIPED_MEM_INDEX(u,p,m,off) \
    337                     _soc_apache_piped_mem_index((u),(p),(m),(off))
    338 
    339 #define _SOC_APACHE_NODE_CONFIG_MEM(u,p,n)                                 \
    340     (((n) == SOC_APACHE_NODE_LVL_S1) ? LLS_S1_CONFIGm :                    \
    341      (((n) == SOC_APACHE_NODE_LVL_L0) ? LLS_L0_CONFIGm :                   \
    342       ((n) == SOC_APACHE_NODE_LVL_L1 ? LLS_L1_CONFIGm : -1  )))
    343 
    344 #define _SOC_APACHE_NODE_CONFIG_MEM2(u,p,n) _SOC_APACHE_NODE_CONFIG_MEM(u, p, n)
    345 
    346 #define _SOC_APACHE_NODE_PARENT_MEM(u,p,n)                                 \
    347     (((n)==SOC_APACHE_NODE_LVL_L2) ? LLS_L2_PARENTm :                      \
    348      (((n) == SOC_APACHE_NODE_LVL_L1) ? LLS_L1_PARENTm :                   \
    349       (((n) == SOC_APACHE_NODE_LVL_L0) ? LLS_L0_PARENTm :                  \
    350        (((n) == SOC_APACHE_NODE_LVL_S1) ? LLS_S1_PARENTm : -1  ))))
    351 
    352 #define _SOC_APACHE_NODE_WIEGHT_MEM(u,p,n)                                 \
    353     (((n)==SOC_APACHE_NODE_LVL_S1) ? LLS_S1_CHILD_WEIGHT_CFG_CNTm :        \
    354      (((n)==SOC_APACHE_NODE_LVL_L0) ? LLS_L0_CHILD_WEIGHT_CFG_CNTm :       \
    355      (((n) == SOC_APACHE_NODE_LVL_L1) ? LLS_L1_CHILD_WEIGHT_CFG_CNTm :     \
    356       (((n) == SOC_APACHE_NODE_LVL_L2) ? LLS_L2_CHILD_WEIGHT_CFG_CNTm : -1 ))))
    357 
    358 
    359 typedef enum {
    360     SOC_APACHE_SCHED_UNKNOWN   = 0,
    361     SOC_APACHE_SCHED_LLS,
    362     SOC_APACHE_SCHED_HSP
    363 } soc_apache_sched_type_t;
    364 
    365 extern soc_apache_sched_type_t
    366 _soc_apache_port_sched_type_get(int unit, soc_port_t port);
    367 
    368 extern int
    369 _soc_apache_invalid_parent_index(int unit, int level);
    370 
    371 extern int
    372 soc_apache_sched_hw_index_get(int unit, int port, int lvl, int offset, 
    373                             int *hw_index);
    374 
    375 extern int soc_apache_l2_hw_index(int unit, int qnum, int uc);
    376 extern int soc_apache_hw_index_logical_num(int unit, int port,
    377                                                 int index, int uc);
    378 extern int
    379 soc_apache_cosq_set_sched_child_config(int unit, soc_port_t port,
    380                               int level, int index,
    381                               int num_spri, int first_sp_child, 
    382                               int first_sp_mc_child, uint32 ucmap);
    383 
    384 extern int
    385 soc_apache_cosq_set_sched_mode(int unit, soc_port_t port, 
    386         int level, int index,
    387         soc_apache_sched_mode_e mode, int weight);
    388 
    389 extern int
    390 soc_apache_cosq_set_sched_config(int unit, soc_port_t port,
    391                               int level, int index, int child_index,
    392                               int num_psri, int first_sp_child, 
    393                               int first_sp_mc_child, uint32 ucmap, uint32 spmap,
    394                               soc_apache_sched_mode_e mode, int weight);
    395 
    396 extern int
    397 soc_apache_cosq_get_sched_child_config(int unit, soc_port_t port,
    398                               int level, int index,
    399                               int *pnum_spri, int *pfirst_sp_child, 
    400                               int *pfirst_sp_mc_child, uint32 *pucmap, uint32 *spmap);
    401 
    402 extern int
    403 soc_apache_cosq_get_sched_mode(int unit, soc_port_t port, int level, 
    404                             int index, soc_apache_sched_mode_e *pmode, int *weight);
    405 
    406 extern int _soc_apache_root_scheduler_index(int unit, int port);
    407 extern int
    408 soc_apache_cosq_get_sched_config(int unit, soc_port_t port,
    409                               int level, int index, int child_index,
    410                               int *num_spri, int *first_sp_child, 
    411                               int *first_sp_mc_child, uint32 *ucmap, uint32 *spmap,
    412                               soc_apache_sched_mode_e *mode, int *weight);
    413 
    414 extern int 
    415 soc_apache_get_child_type(int unit, soc_port_t port, int level, int *child_type);
    416 
    417 extern int 
    418 soc_apache_sched_weight_get(int unit, int port, int level, int index, int *weight);
    419 
    420 extern int 
    421 soc_apache_sched_weight_set(int unit, int port, int level, int index, int weight);
    422 
    423 extern int soc_apache_get_pipe_queue_count(int unit, int uc, int xpipe);
    424 
    425 extern int soc_apache_dump_port_lls(int unit, int port);
    426 
    427 extern int soc_apache_dump_port_hsp(int unit, int port);
    428 
    429 extern int soc_apache_lls_init(int unit);
    430 
    431 extern int soc_apache_lb_lls_init(int unit);
    432 
    433 extern int soc_apache_cosq_set_sched_parent(int unit, soc_port_t port,
    434                               int level, int hw_index,
    435                               int parent_hw_idx, int add);
    436 
    437 extern int soc_apache_logical_qnum_hw_qnum(int unit, int port, int lqnum, int uc);
    438 
    439 extern int soc_apache_mmu_get_shared_size(int unit, int *shared_size);
    440 extern int soc_apache_mmu_config_shared_buf_recalc(int unit,
    441                                                 uint32 spid,
    442                                                 int shared_size,
    443                                                 int flags);
    444 extern int soc_apache_mmu_config_res_limits_update(int unit,
    445                                                 uint32 spid,
    446                                                 uint32 shared_size,
    447                                                 int flags);
    448 
    449 extern void soc_apache_process_func_intr(void *unit_vp, void *d1, void *d2,
    450                                       void *d3, void *d4);
    451 
    452 typedef int (*_soc_apache_bst_hw_cb)(int unit);
    453 extern int soc_apache_set_bst_callback(int unit, _soc_apache_bst_hw_cb cb);
    454 extern int soc_apache_port_asf_para_set(int unit, soc_port_t port, int speed,
    455                                      int enable);
    456 extern int soc_apache_port_speed_update(int unit, soc_port_t port, int speed);
    457 extern int soc_apache_port_thdo_rx_enable_set(int unit, soc_port_t port,
    458                                                 int enable);
    459 extern int
    460 soc_apache_idb_buf_reset(int unit, soc_port_t port, int reset);
    461 
    462 extern int
    463 soc_apache_edb_buf_reset(int unit, soc_port_t port, int reset);
    464 
    465 extern int soc_apache_fc_map_shadow_create(int unit);
    466 extern void soc_apache_fc_map_shadow_free(int unit);
    467 extern int
    468 soc_apache_fc_map_shadow_entry_set (int unit, soc_mem_t mem, int index,
    469                                       void* entry_data);
    470 extern int
    471 soc_apache_fc_map_shadow_entry_get (int unit, soc_mem_t mem, int index,
    472                                       void* entry_data);
    473 int soc_apache_fc_map_shadow_clear (int unit, soc_mem_t mem);
    474 extern int soc_apache_port_traffic_egr_enable_set(int unit, int port, int enable);
    475 extern int soc_apache_port_mmu_tx_enable_set(int unit, int port, int enable);
    476 extern int soc_apache_qcn_counter_hw_index_get(int unit, soc_port_t port,
    477                                             int index, int *qindex);
    478 extern int
    479 soc_apache_setup_hsp_port(int unit, int port);
    480 extern int
    481 soc_apache_delete_hsp_port(int unit, int port);
    482 extern int
    483 soc_apache_mmu_config_init(int unit, int test_only, soc_port_t port);
    484 extern int
    485 soc_apache_cosq_enable_hsp_sched(int unit, soc_port_t port);
    486 extern soc_error_t
    487 soc_apache_cosq_disable_hsp_sched(int unit, soc_port_t port);
    488 
    489 #ifdef BCM_WARM_BOOT_SUPPORT
    490 extern int soc_apache_fc_map_shadow_size_get (int unit, uint32* size);
    491 extern int soc_apache_fc_map_shadow_sync(int unit, uint32 **sync_addr);
    492 extern int soc_apache_fc_map_shadow_load(int unit, uint32 **load_addr);
    493 #endif
    494 
    495 #if defined(SER_TR_TEST_SUPPORT)
    496 extern soc_error_t soc_apache_ser_inject_error(int unit, uint32 flags,
    497                                             soc_mem_t mem, int pipe_target,
    498                                             int block, int index);
    499 extern soc_error_t soc_apache_ser_test_mem(int unit, soc_mem_t mem,
    500                                         _soc_ser_test_t test_type, int cmd);
    501 extern soc_error_t soc_apache_ser_test(int unit, _soc_ser_test_t test_type);
    502 extern soc_error_t soc_apache_ser_error_injection_support(int unit,
    503                                                        soc_mem_t mem, int pipe);
    504 extern int soc_apache_ser_test_overlay (int unit, _soc_ser_test_t test_type);
    505 extern int soc_apache_cosq_max_bucket_set(int unit, int port,
    506                                         int index, uint32 level);
    507 extern int ser_test_apache_mem_index_remap(int unit,
    508                                            ser_test_data_t *test_data,
    509                                            int *mem_has_ecc);
    510 #endif /*#if defined(SER_TR_TEST_SUPPORT)*/
    511 
    512 /*
    513  * Data structure use for storing part of the SOC data information
    514  * which is needed during later phases of a FlexPort operation.
    515  */
    516 typedef struct soc_ap_info_s {
    517     int port_l2p_mapping[SOC_MAX_NUM_PORTS];      /* Logic to physical */
    518     int port_p2l_mapping[SOC_MAX_NUM_PORTS];      /* Physical to logic */
    519     int port_p2m_mapping[SOC_MAX_NUM_PORTS];      /* Physical to MMU */
    520     int port_m2p_mapping[SOC_MAX_NUM_MMU_PORTS];  /* MMU to physical */
    521     int port_group[SOC_MAX_NUM_PORTS];            /* Group number */
    522     int port_speed_max[SOC_MAX_NUM_PORTS];        /* Max port speed */
    523     int port_init_speed[SOC_MAX_NUM_PORTS];       /* Init port speed */
    524     int port_num_lanes[SOC_MAX_NUM_PORTS];        /* Number of lanes */
    525     pbmp_t xpipe_pbm;                             /* Ports in X-pipe */
    526     pbmp_t ypipe_pbm;                             /* Ports in Y-pipe */
    527     pbmp_t oversub_pbm;                           /* Oversubscription ports */
    528 } soc_ap_info_t;
    529 
    530 extern int
    531 soc_apache_port_mode_get(int unit, int logical_port, int *mode);
    532 
    533 extern int
    534 soc_apache_is_cut_thru_enabled(int unit, soc_port_t port, int *enable);
    535 
    536 extern int
    537 soc_ap_cut_thru_enable_disable(int unit, soc_port_t port, int enable);
    538 
    539 extern int
    540 soc_ap_phy_info_init(int unit);
    541 extern int
    542 soc_ap_phy_info_deinit(int unit);
    543 
    544 extern int
    545 soc_apache_port_cl91_status_get(int unit, soc_port_t port, uint32 *cl91_enabled);
    546 extern int
    547 soc_ap_port_lanes_valid(int unit, soc_port_t port, int lanes);
    548 
    549 extern int
    550 soc_ap_port_resource_speed_max_get(int unit, int *speed);
    551 
    552 extern soc_error_t
    553 _soc_apache_mmu_ovs_speed_class_map_get(int unit, int *speed, int *spg, uint32 *sp_spacing);
    554 extern int
    555 soc_ap_port_ovs_speed_group_validate(int unit);
    556 extern int
    557 soc_ap_port_mixed_sister_speed_validate(int unit);
    558 
    559 extern int
    560 soc_ap_port_addressable(int unit, soc_port_t port);
    561 
    562 extern int
    563 soc_ap_phy_port_addressable(int unit, int phy_port);
    564 
    565 extern int
    566 soc_ap_edb_buf_reset(int unit, soc_port_t port, int reset);
    567 
    568 extern int
    569 soc_ap_port_resource_validate(int unit, int nport,
    570                               soc_port_resource_t *resource);
    571 extern int
    572 soc_ap_port_resource_configure(int unit, int nport,
    573                                soc_port_resource_t *resource, int flag);
    574 
    575 extern int
    576 soc_ap_port_resource_tdm_set(int unit, int curr_port_info_size,
    577                              soc_port_resource_t *curr_port_info,
    578                              int new_port_info_size,
    579                              soc_port_resource_t *new_port_info,
    580                              soc_ap_info_t *si, int lossless);
    581 
    582 extern int
    583 soc_ap_port_resource_pgw_set(int unit,
    584                              int pre_num_res,  soc_port_resource_t *pre_res,
    585                              int post_num_res, soc_port_resource_t *post_res,
    586                              int lossless);
    587 
    588 extern int
    589 soc_ap_port_resource_ip_set(int unit, int curr_port_info_size,
    590                             soc_port_resource_t *curr_port_info,
    591                             int new_port_info_size,
    592                             soc_port_resource_t *new_port_info,
    593                             soc_ap_info_t *si);
    594 
    595 extern int
    596 soc_ap_port_resource_ep_set(int unit, int curr_port_info_size,
    597                             soc_port_resource_t *curr_port_info,
    598                             int new_port_info_size,
    599                             soc_port_resource_t *new_port_info,
    600                             soc_ap_info_t *si);
    601 extern int
    602 soc_ap_port_resource_mmu_mapping_set(int unit, int nport,
    603                                      soc_port_resource_t *resource);
    604 
    605 extern int
    606 soc_ap_port_resource_mmu_set(int unit, int nport,
    607                              soc_port_resource_t * flexport_data);
    608 
    609 extern int
    610 soc_apache_port_asf_set(int unit, soc_port_t port, int speed);
    611 extern int
    612 soc_apache_port_asf_speed_set(int unit, soc_port_t port, int speed);
    613 
    614 extern int
    615 soc_apache_port_lane_config_get(int unit, int phy_port, int *mode_lane,
    616                               int *found);
    617 extern int
    618 soc_apache_port_autoneg_core_get(int unit, int phy_port, int *an_core,
    619                                int *found);
    620 extern int
    621 soc_apache_mmu_hsp_port_reserve(int unit, int port, int speed_max);
    622 
    623 extern int
    624 soc_apache_tsc_disable(int unit);
    625 
    626 /* 
    627  * FlexPort Functions
    628  */
    629 
    630 extern int soc_apache_is_flex_enable(int unit);
    631 extern soc_error_t
    632 soc_apache_subsidiary_ports_get(int unit, soc_port_t port, soc_pbmp_t *pbmp);
    633 
    634 extern int
    635 soc_apache_mmu_port_resource_set(int unit, soc_port_t port, int speed);
    636 
    637 #ifdef BCM_WARM_BOOT_SUPPORT
    638 extern int soc_apache_flexport_scache_allocate(int unit);
    639 extern int soc_apache_flexport_scache_sync(int unit);
    640 extern int soc_apache_flexport_scache_recovery(int unit);
    641 #endif
    642 
    643 #ifdef BCM_WARM_BOOT_SUPPORT_SW_DUMP
    644 extern void soc_apache_flexport_sw_dump(int unit);
    645 #endif
    646 
    647 #ifdef PORTMOD_SUPPORT
    648 extern int soc_ap_portctrl_pm_portmod_init(int unit);
    649 extern int soc_ap_portctrl_pm_portmod_deinit(int unit);
    650 extern int soc_ap_portctrl_pm_port_config_get(int unit, soc_port_t port, void *port_config_info);
    651 extern int soc_ap_portctrl_pm_port_phyaddr_get(int unit, soc_port_t port);
    652 extern int soc_ap_portctrl_port_ability_update(int unit, soc_port_t port, soc_port_ability_t *ability);
    653 extern int soc_ap_portctrl_pm_type_get(int unit, soc_port_t phy_port, int* pm_type);
    654 #endif
    655 
    656 extern int soc_apache_alpm_mode_get(int unit);
    657 extern int soc_apache_get_alpm_banks(int unit);
    658 extern int soc_apache_l3_defip_index_map(int unit, soc_mem_t mem, int index);
    659 extern int soc_apache_l3_defip_index_remap(int unit, soc_mem_t mem, int index);
    660 
    661 typedef int (*_soc_apache_lls_traverse_cb)(int unit, int port, int level, 
    662         int hw_index, void *cookie);
    663 
    664 #define PORT_IS_PM4x25_PORT_PHY(unit, phy_port) \
    665             (((phy_port <= 36) && (phy_port >= 29)) || \
    666              ((phy_port <= 72) && (phy_port >= 65)))
    667 
    668 #define PORT_IS_PM4x25_PORT(unit, lport) \
    669     PORT_IS_PM4x25_PORT_PHY(unit, (SOC_INFO(unit).port_l2p_mapping[lport]))
    670 
    671 #endif  /* !_SOC_APACHE_H_ */
    672 
    673 /*test*/