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

bfcmap_int.h (5918B)


      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 
      8 #ifndef BFCMAP_INTERNAL_H
      9 #define BFCMAP_INTERNAL_H
     10 
     11 #include <bfcmap_sal.h>
     12 #include <bfcmap_util.h>
     13 #include <bfcmap_vlan.h>
     14 #include <bfcmap_stat.h>
     15 #include <bfcmap_ident.h>
     16 #include <bfcmap_drv.h>
     17 #include <bfcmap_ctrl.h>
     18 
     19 
     20 /* bmacsec equiv of reg/mem is in mem.h */
     21 #define BFCMAP_REG64_READ(c,a,pv) \
     22             (c)->msec_io_f((c)->dev_addr, BFCMAP_PORT((c)),  \
     23                             BFCMAP_IO_REG_RD, (a), 2, 1, (pv))
     24 
     25 #define BFCMAP_REG32_READ(c,a,pv) \
     26             (c)->msec_io_f((c)->dev_addr, BFCMAP_PORT((c)),  \
     27                             BFCMAP_IO_REG_RD, (a), 1, 1, (pv))
     28 
     29 #define BFCMAP_REG64_WRITE(c,a,pv) \
     30             (c)->msec_io_f((c)->dev_addr, BFCMAP_PORT((c)),  \
     31                             BFCMAP_IO_REG_WR, (a), 2, 1, (pv))
     32 
     33 #define BFCMAP_REG32_WRITE(c,a,pv) \
     34             (c)->msec_io_f((c)->dev_addr, BFCMAP_PORT((c)),  \
     35                             BFCMAP_IO_REG_WR, (a), 1, 1, (pv))
     36 
     37 
     38 #define BFCMAP_WWN_HI(mac)          BMAC_TO_32_HI(mac)
     39 #define BFCMAP_WWN_LO(mac)          BMAC_TO_32_LO(mac)
     40 #define BFCMAP_WWN_BUILD(mac,hi,lo) BMAC_BUILD_FROM_32(mac,hi,lo)
     41 
     42 #define BFCMAP_PID_TO_32(pid)  \
     43    ((((buint8_t *)(pid))[0] << 16 )|\
     44     (((buint8_t *)(pid))[1] << 8  )|\
     45     (((buint8_t *)(pid))[2] << 0  ))
     46 
     47 #define BFCMAP_PID_BUILD(pid, val32)\
     48    ((buint8_t *)(pid))[0] = ((val32) >> 16) & 0xff ;\
     49    ((buint8_t *)(pid))[1] = ((val32) >> 8 ) & 0xff ;\
     50    ((buint8_t *)(pid))[2] = ((val32) >> 0 ) & 0xff ;
     51 
     52 
     53 typedef enum {
     54     BFCMAP_UC_FIRMWARE_INIT = 0xA,
     55     BFCMAP_UC_LINK_RESET,
     56     BFCMAP_UC_LINK_BOUNCE,
     57     BFCMAP_UC_LINK_ENABLE,
     58     BFCMAP_UC_LINK_SPEED,
     59     BFCMAP_UC_RX_BBC_SET
     60 } bfcmap_lmi_uc_cmds_t ;
     61 
     62 typedef enum {
     63     BFCMAP_UC_LINK_UP = 0x1A,
     64     BFCMAP_UC_LINK_FAILURE
     65 } bfcmap_uc_lmi_cmds_t ;
     66 
     67 #if defined(INCLUDE_PHY_8806X)
     68 /* Inband packet handling */
     69 
     70 #ifndef COMPILER_ATTRIBUTE
     71 #define COMPILER_ATTRIBUTE(_a)    __attribute__ (_a)
     72 #endif /* COMPILER_ATTRIBUTE */
     73 
     74 typedef struct bfcmap_mibs_s {
     75     buint64_t fc_c2_rxgoodframes;
     76     buint64_t fc_c2_rxinvalidcrc;  
     77     buint64_t fc_c2_rxframetoolong;
     78     buint64_t fc_c3_rxgoodframes;
     79     buint64_t fc_c3_rxinvalidcrc;
     80     buint64_t fc_c3_rxframetoolong;
     81     buint64_t fc_cf_rxgoodframes;
     82     buint64_t fc_cf_rxinvalidcrc;
     83     buint64_t fc_cf_rxframetoolong;
     84     buint64_t fc_rxdelimitererr;
     85     buint64_t fc_rxbbc0drop;
     86     buint64_t fc_rxbbcredit0;
     87     buint64_t fc_rxlinkfail;
     88     buint64_t fc_rxsyncfail;
     89     buint64_t fc_rxlosssig;
     90     buint64_t fc_rxprimseqerr;
     91     buint64_t fc_rxinvalidset;
     92     buint64_t fc_rxlpicount;
     93     buint64_t fc_rxencodedisparity;
     94     buint64_t fc_rxbadxword;
     95     buint64_t fc_rx_c2_runtframes;
     96     buint64_t fc_rx_c3_runtframes;
     97     buint64_t fc_rx_cf_runtframes;
     98     buint64_t fc_c2_rxbyt;
     99     buint64_t fc_c3_rxbyt;
    100     buint64_t fc_cf_rxbyt;
    101     buint64_t fc_tx_c2_frames;
    102     buint64_t fc_tx_c3_frames;
    103     buint64_t fc_tx_cf_frames;
    104     buint64_t fc_tx_c2_oversized_frames;
    105     buint64_t fc_tx_c3_oversized_frames;
    106     buint64_t fc_tx_cf_oversized_frames;
    107     buint64_t fc_txbbcredit0;
    108     buint64_t fc_c2_txbyt;
    109     buint64_t fc_c3_txbyt;
    110     buint64_t fc_cf_txbyt;
    111 } COMPILER_ATTRIBUTE((packed)) bfcmap_mibs_t;
    112 
    113 /* The order of enums below MUST match the struct bfcmap_mibs_t */
    114 typedef enum {
    115     stat_fc_c2_rxgoodframes,
    116     stat_fc_c2_rxinvalidcrc,  
    117     stat_fc_c2_rxframetoolong,
    118     stat_fc_c3_rxgoodframes,
    119     stat_fc_c3_rxinvalidcrc,
    120     stat_fc_c3_rxframetoolong,
    121     stat_fc_cf_rxgoodframes,
    122     stat_fc_cf_rxinvalidcrc,
    123     stat_fc_cf_rxframetoolong,
    124     stat_fc_rxdelimitererr,
    125     stat_fc_rxbbc0drop,
    126     stat_fc_rxbbcredit0,
    127     stat_fc_rxlinkfail,
    128     stat_fc_rxsyncfail,
    129     stat_fc_rxlosssig,
    130     stat_fc_rxprimseqerr,
    131     stat_fc_rxinvalidset,
    132     stat_fc_rxlpicount,
    133     stat_fc_rxencodedisparity,
    134     stat_fc_rxbadxword,
    135     stat_fc_rx_c2_runtframes,
    136     stat_fc_rx_c3_runtframes,
    137     stat_fc_rx_cf_runtframes,
    138     stat_fc_c2_rxbyt,
    139     stat_fc_c3_rxbyt,
    140     stat_fc_cf_rxbyt,
    141     stat_fc_tx_c2_frames,
    142     stat_fc_tx_c3_frames,
    143     stat_fc_tx_cf_frames,
    144     stat_fc_tx_c2_oversized_frames,
    145     stat_fc_tx_c3_oversized_frames,
    146     stat_fc_tx_cf_oversized_frames,
    147     stat_fc_txbbcredit0,
    148     stat_fc_c2_txbyt,
    149     stat_fc_c3_txbyt,
    150     stat_fc_cf_txbyt,
    151     stat_fc_max_stat /* should be last */
    152 } bfcmap_stat_index_t;
    153 
    154 #define FC_INBAND_FRAME_SIGNATURE 0xFC0E
    155 #define FC_INBAND_NUM_TLV_MAX 0x3
    156 
    157 /* Non byte FC counters are 40 bit wide */
    158 #define FC_COUNTER_WIDTH 40
    159 #define FC_COUNTER_MASK 0xFFFFFFFFFFULL /* 40 bits */
    160 
    161 typedef struct bfcmap_inb_signature_s {
    162     buint16_t sign;
    163     buint8_t num_tlv;
    164     buint8_t frm_seq;
    165 } COMPILER_ATTRIBUTE((packed)) bfcmap_inb_signature_t;
    166 
    167 typedef enum bfcmap_inb_pld_type {
    168     FC_INB_PLD_TYPE_FC_MIBS    = 1,
    169     FC_INB_PLD_TYPE_FC_EVENTS  = 2,
    170     FC_INB_PLD_TYPE_ETH_MIBS   = 3
    171 } bfcmap_inb_pld_type_t;
    172 
    173 typedef struct bfcmap_inb_tlv_s {
    174     buint16_t pld_type;
    175     buint16_t pld_len;
    176 } COMPILER_ATTRIBUTE((packed)) bfcmap_inb_tlv_t;
    177          
    178 typedef struct bfcmap_inb_pl_s {
    179     bfcmap_inb_tlv_t tlv;
    180     buint64_t word[1];
    181 } COMPILER_ATTRIBUTE((packed)) bfcmap_inb_pl_t;
    182 
    183 /* Inband FC frame Payload */
    184 typedef struct bfcmap_inband_fr_payload_s {
    185     bfcmap_inb_signature_t fc_inb_signature;
    186     /* payloads */
    187     bfcmap_inb_pl_t pl1;
    188     bfcmap_inb_pl_t pl2;
    189     bfcmap_inb_pl_t pl3;
    190 } COMPILER_ATTRIBUTE((packed)) bfcmap_inband_fr_payload_t;
    191 
    192 void bfcmap88060_fc_mibs_update(bfcmap_mibs_t *mibs, bfcmap_mibs_t *prev_mibs, buint64_t *cur_fc_mibs);
    193 int bfcmap88060_fc_event_update(buint64_t *cur_fc_evt);
    194 void bfcmap88060_fc_stat_update(buint64_t *dst_stat, buint64_t *cur_stat, buint64_t *prev_stat, int stat_index);
    195 #endif /* INCLUDE_PHY_8806X */
    196 
    197 #endif /* BFCMAP_INTERNAL_H */