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

olp_pkt.h (13805B)


      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:        olp_pkt.h
      8  * Purpose:     olp Packet Format definitions
      9  *              common to SDK and uKernel.
     10  */
     11 
     12 #ifndef   _SOC_SHARED_OLP_PKT_H_
     13 #define   _SOC_SHARED_OLP_PKT_H_
     14 
     15 #ifdef BCM_UKERNEL
     16 /* Build for uKernel not SDK */
     17 #include "sdk_typedefs.h"
     18 #else
     19 #include <sal/types.h>
     20 #endif
     21 #include <shared/pack.h>
     22 
     23 /*************************************
     24  * OLP Packet Format
     25  */
     26 
     27 /*
     28  * OLP TX HDR
     29  */
     30 
     31 typedef struct soc_olp_tx_hdr {
     32 
     33 #ifdef LE_HOST
     34     union {
     35         uint32 h1;
     36         struct {
     37             uint32 mod_id:8,
     38                    int_pri:4,
     39                    hdr_subtype:8,
     40                    hdr_type:8,
     41                    ver:4;
     42         }s1;
     43     }u1;
     44     union {
     45         uint32 h2;
     46         struct {
     47             uint32 _ctr2_id1:5,
     48                    ctr2_location:1,
     49                    ctr1_action:2,
     50                    ctr1_id:15,
     51                    ctr1_location:1,
     52                    port_id:8;
     53         }s2;
     54     }u2;
     55 #if defined(BCM_TRIDENT2PLUS_SUPPORT) || defined (BCM_SABER2_SUPPORT)
     56     /* There are differences between OLP header formats used in TD2+ and SB2.
     57      * sX1 (where X is 3 or 4) are overlay structures used for TD2+
     58      * sX2 (where X is 3 or 4) are overlay structures used for SB2.
     59      */
     60     union {
     61         uint32 h3;
     62         struct {
     63             uint32 _class_id1:10,
     64                    oam_replacement_offset:8,
     65                    timestamp_action:2,
     66                    ctr2_action:2,
     67                    _ctr2_id2:10;
     68         }s31;
     69         struct {
     70             uint32 _ctr3_id1:4,
     71                    ctr3_location:1,
     72                    lm_replacement_off_oper:1,
     73                    rel_lm_replacement_off:4,
     74                    oam_replacement_offset:8,
     75                    timestamp_action:2,
     76                    ctr2_action:2,
     77                    _ctr2_id2:10;
     78         }s32; /* Overlay that is used for Saber2 */
     79     }u3;
     80     union {
     81         uint32 h4;
     82         struct {
     83             uint32 _rsvd1:26,
     84                    _class_id2:6;
     85         }s41;
     86         struct {
     87             uint32 
     88                 _rsvd1:1,
     89                 ctr3_off_to_lm:6,
     90                 ctr2_off_to_lm:6,
     91                 ctr1_off_to_lm:6,
     92                 ctr3_action:2,
     93                 _ctr3_id2:11;
     94         }s42; /* Overlay that is used for Saber2 */
     95     }u4;
     96 #else
     97     union {
     98         uint32 h3; 
     99     }u3;
    100     union {
    101         uint32 h4; 
    102     }u4;
    103 #endif   /* !(Td2+ or Sb2) */
    104 
    105 #else  /* !LE_HOST*/
    106     union {
    107         uint32 h1;
    108         struct {
    109             uint32 ver:4,
    110                    hdr_type:8,
    111                    hdr_subtype:8,
    112                    int_pri:4,
    113                    mod_id:8;
    114         }s1;
    115     }u1;
    116     union {
    117         uint32 h2;
    118         struct {
    119             uint32 port_id:8,
    120                    ctr1_location:1,
    121                    ctr1_id:15,
    122                    ctr1_action:2,
    123                    ctr2_location:1,
    124                    _ctr2_id1:5;
    125         }s2;
    126     }u2;
    127 #if defined(BCM_TRIDENT2PLUS_SUPPORT) || defined (BCM_SABER2_SUPPORT) 
    128     /* There are differences between OLP header formats used in TD2+ and SB2.
    129      * sX1 (where X is 3 or 4) are overlay structures used for TD2+
    130      * sX2 (where X is 3 or 4) are overlay structures used for SB2.
    131      */
    132     union {
    133         uint32 h3;
    134         struct {
    135             uint32 _ctr2_id2:10,
    136                    ctr2_action:2,
    137                    timestamp_action:2,
    138                    oam_replacement_offset:8,
    139                    _class_id1:10;
    140         }s31;
    141         struct {
    142             uint32 
    143                 _ctr2_id2:10,
    144                 ctr2_action:2,
    145                 timestamp_action:2,
    146                 oam_replacement_offset:8,
    147                 rel_lm_replacement_off:4,
    148                 lm_replacement_off_oper:1,
    149                 ctr3_location:1,
    150                 _ctr3_id1:4;
    151         }s32; /* Overlay that is used for Saber2 */
    152     }u3;
    153     union {
    154         uint32 h4;
    155         struct {
    156             uint32 _class_id2:6,
    157                    :26;
    158         }s41;
    159         struct {
    160             uint32 
    161                 _ctr3_id2:11,
    162                 ctr3_action:2,
    163                 ctr1_off_to_lm:6,
    164                 ctr2_off_to_lm:6,
    165                 ctr3_off_to_lm:6,
    166                 _rsvd1:1;
    167         }s42; /* Overlay that is used for Saber2 */
    168     }u4;
    169 #else
    170     union {
    171         uint32 h3; 
    172     }u3;
    173     union {
    174         uint32 h4; 
    175     }u4;
    176 #endif /* !(Td2+ or Sb2) */
    177 #endif  /* LE_HOST */
    178  
    179 } soc_olp_tx_hdr_t;
    180 
    181 /*
    182  * OLP RX HDR
    183  */
    184 
    185 typedef struct soc_olp_rx_hdr {
    186 
    187 #ifdef LE_HOST
    188     union {
    189         uint32 h1;
    190         struct {
    191             uint32 _port_id1:4,
    192                    mod_id:8,
    193                    hdr_subtype:8,
    194                    hdr_type:8,
    195                    ver:4;
    196         }s1;
    197     }u1;
    198     union {
    199         uint32 h2;
    200         struct {
    201             uint32 _rx_timestamp_upper1:10,
    202                    sample_type:2,
    203                    session_id:16,
    204                    _port_id2:4;
    205         }s2;
    206     }u2;
    207     union {
    208         uint32 h3;
    209         struct {
    210             uint32 _rx_timestamp1:10,
    211                    _rx_timestamp_upper2:22;
    212         }s3;
    213     }u3;
    214 #if defined(BCM_TRIDENT2PLUS_SUPPORT) || defined (BCM_SABER2_SUPPORT)
    215     /* There are differences between OLP header formats used in TD2+ and SB2.
    216      * s41 is overlay structure used for TD2+
    217      * s42 is overlay structure used for SB2.
    218      * s5 is overlay structure used for SB2 only.
    219      */
    220     union {
    221         uint32 h4;
    222         struct {
    223             uint32 
    224                 :2,
    225                 oam_pdu:8,
    226                 _rx_timestamp2:22;
    227         }s41;
    228         struct {
    229             uint32 _sample_value_ext1:1,
    230                    sample_type_ext:1,
    231                    oam_pdu:8,
    232                    _rx_timestamp2:22;
    233         }s42;/* Overlay that is used for Saber2 */
    234     }u4;
    235     union {
    236         uint32 h5;
    237         struct {
    238             uint32 
    239                     :1,
    240                    _sample_value_ext2:31;
    241         }s5; /* Overlay that is used only for Saber2 */
    242     }u5;
    243 #else
    244     union {
    245         uint32 h4; 
    246     }u4;
    247     union {
    248         uint32 h5; 
    249     }u5;
    250 
    251 #endif /* !(Td2+ or sb2) */
    252 
    253 #else /* ! LE_HOST*/
    254 
    255     union {
    256         uint32 h1;
    257         struct {
    258             uint32 ver:4,
    259                    hdr_type:8,
    260                    hdr_subtype:8,
    261                    mod_id:8,
    262                    _port_id1:4;
    263         }s1;
    264     }u1;
    265     union {
    266         uint32 h2;
    267         struct {
    268             uint32 _port_id2:4,
    269                    session_id:16,
    270                    sample_type:2,
    271                    _rx_timestamp_upper1:10;
    272         }s2;
    273     }u2;
    274     union {
    275         uint32 h3;
    276         struct {
    277             uint32 _rx_timestamp_upper2:22,
    278                    _rx_timestamp1:10;
    279         }s3;
    280     }u3;
    281 #if defined(BCM_TRIDENT2PLUS_SUPPORT) || defined (BCM_SABER2_SUPPORT)
    282     /* There are differences between OLP header formats used in TD2+ and SB2.
    283      * s41 is overlay structure used for TD2+
    284      * s42 is overlay structure used for SB2.
    285      * s5 is overlay structure used for SB2 only.
    286      */
    287     union {
    288         uint32 h4;
    289         struct {
    290             uint32 _rx_timestamp2:22,
    291                    oam_pdu:8,
    292                    :2;
    293         }s41;
    294         struct {
    295             uint32 _rx_timestamp2:22,
    296                    oam_pdu:8,
    297                    sample_type_ext:1,
    298                    _sample_value_ext1:1;
    299         }s42; /* Overlay For saber2 */
    300     }u4;
    301     union {
    302         uint32 h5;
    303         struct {
    304             uint32 _sample_value_ext2:31,
    305                    :1;
    306         }s5;/* overlay used only for Saber2 */
    307     }u5;
    308 #else
    309     union {
    310         uint32 h4;
    311     }u4;
    312     union {
    313         uint32 h5;
    314     }u5;
    315 #endif  /* !(Td2+ or Sb2) */
    316 
    317 #endif /*LE HOST*/
    318 
    319 } soc_olp_rx_hdr_t;
    320 
    321 typedef struct __attribute__ ((__packed__)) soc_olp_l2_hdr_s {
    322     uint8 dst_mac[6];
    323     uint8 src_mac[6];
    324     uint16 tpid;
    325     uint16 vlan;
    326     uint16 etherType;
    327 } soc_olp_l2_hdr_t;
    328 
    329 typedef struct __attribute__ ((__packed__)) soc_olp_rx_pkt_s {
    330     soc_olp_l2_hdr_t l2_hdr; 
    331     soc_olp_rx_hdr_t rx_hdr;
    332 } soc_olp_rx_pkt_t;
    333 
    334 
    335 typedef struct __attribute__ ((__packed__)) soc_olp_tx_pkt_s {
    336     soc_olp_l2_hdr_t l2_hdr;
    337     soc_olp_tx_hdr_t tx_hdr;
    338 } soc_olp_tx_pkt_t;
    339 
    340 /*******************************************
    341  * Extraction Macros
    342  */
    343 
    344 #define SOC_OLP_RX_VER_GET(_orh)     \
    345     ((_orh)->u1.s1.ver )
    346 #define SOC_OLP_RX_HDR_TYPE_GET(_orh)     \
    347     ((_orh)->u1.s1.hdr_type )
    348 #define SOC_OLP_RX_HDR_STYPE_GET(_orh)     \
    349     ((_orh)->u1.s1.hdr_subtype )
    350 #define SOC_OLP_RX_MODID_GET(_orh)     \
    351     ((_orh)->u1.s1.mod_id )
    352 #define SOC_OLP_RX_PORT_GET(_orh)     \
    353     (((_orh)->u1.s1._port_id1 << 4) | ((_orh)->u2.s2._port_id2))
    354 #define SOC_OLP_RX_SESSION_ID_GET(_orh)     \
    355     ((_orh)->u2.s2.session_id )
    356 #define SOC_OLP_RX_SAMPLE_TYPE_GET(_orh)     \
    357     ((_orh)->u2.s2.sample_type )
    358 #define SOC_OLP_RX_TIMESTAMP_UPPER_GET(_orh)     \
    359     (((_orh)->u2.s2._rx_timestamp_upper1 << 22) | ((_orh)->u3.s3._rx_timestamp_upper2 ))
    360 #define SOC_OLP_RX_TIMESTAMP_GET(_orh)     \
    361     (((_orh)->u3.s3._rx_timestamp1 << 22) | ((_orh)->u4.s41._rx_timestamp2 ))
    362 #define SOC_OLP_RX_OAM_PDU_OFFSET_GET(_orh)     \
    363     ((_orh)->u4.s41.oam_pdu )
    364 
    365 #ifdef BCM_SABER2_SUPPORT
    366 #define SOC_OLP_RX_OAM_SAMPLE_TYPE_EXT_GET(_orh)     \
    367     ((_orh)->u4.s42.sample_type_ext )
    368 #define SOC_OLP_RX_SAMPLE_VALUE_EXT_GET(_orh)     \
    369     (((_orh)->u4.s42._sample_value_ext1 << 31) | ((_orh)->u5.s5._sample_value_ext2 ))
    370 
    371 #endif /* BCM_SABER2_SUPPORT */
    372 
    373 #define SOC_OLP_TX_VER_GET(_oth)     \
    374     ((_oth)->u1.s1.ver )
    375 #define SOC_OLP_TX_HDR_TYPE_GET(_oth)     \
    376     ((_oth)->u1.s1.hdr_type )
    377 #define SOC_OLP_TX_HDR_STYPE_GET(_oth)     \
    378     ((_oth)->u1.s1.hdr_subtype )
    379 #define SOC_OLP_TX_PRI_GET(_oth)     \
    380     ((_oth)->u1.s1.int_pri )
    381 #define SOC_OLP_TX_MODID_GET(_oth)     \
    382     ((_oth)->u1.s1.mod_id )
    383 #define SOC_OLP_TX_PORT_GET(_oth)     \
    384     ((_oth)->u2.s2.port_id)
    385 #define SOC_OLP_TX_CTR1_LOCATION_GET(_oth)     \
    386     ((_oth)->u2.s2.ctr1_location )
    387 #define SOC_OLP_TX_CTR1_ID_GET(_oth)     \
    388     ((_oth)->u2.s2.ctr1_id )
    389 #define SOC_OLP_TX_CTR1_ACTION_GET(_oth)     \
    390     ((_oth)->u2.s2.ctr1_action )
    391 #define SOC_OLP_TX_CTR2_LOCATION_GET(_oth)     \
    392     ((_oth)->u2.s2.ctr2_location )
    393 #define SOC_OLP_TX_CTR2_ID_GET(_oth)     \
    394     (((_oth)->u2.s2._ctr2_id1 << 10) | ((_oth)->u3.s31._ctr2_id2))
    395 #define SOC_OLP_TX_CTR2_ACTION_GET(_oth)     \
    396     ((_oth)->u3.s31.ctr2_action )
    397 #define SOC_OLP_TX_TIMESTAMP_ACTION_GET(_oth)     \
    398     ((_oth)->u3.s31.timestamp_action )
    399 #define SOC_OLP_TX_OAM_OFFSET_GET(_oth)     \
    400     ((_oth)->u3.s31.oam_replacement_offset )
    401 
    402 #define SOC_OLP_TX_VER(_oth)                SOC_OLP_TX_VER_GET(_oth) 
    403 #define SOC_OLP_TX_HDR_TYPE(_oth)           SOC_OLP_TX_HDR_TYPE_GET(_oth) 
    404 #define SOC_OLP_TX_HDR_STYPE(_oth)          SOC_OLP_TX_HDR_STYPE_GET(_oth) 
    405 #define SOC_OLP_TX_PRI(_oth)                SOC_OLP_TX_PRI_GET(_oth)
    406 #define SOC_OLP_TX_MODID(_oth)              SOC_OLP_TX_MODID_GET(_oth) 
    407 #define SOC_OLP_TX_PORT(_oth)               SOC_OLP_TX_PORT_GET(_oth)
    408 #define SOC_OLP_TX_CTR1_LOCATION(_oth)      SOC_OLP_TX_CTR1_LOCATION_GET(_oth)   
    409 #define SOC_OLP_TX_CTR1_ID(_oth)            SOC_OLP_TX_CTR1_ID_GET(_oth)
    410 #define SOC_OLP_TX_CTR1_ACTION(_oth)        SOC_OLP_TX_CTR1_ACTION_GET(_oth) 
    411 #define SOC_OLP_TX_CTR2_LOCATION(_oth)      SOC_OLP_TX_CTR2_LOCATION_GET(_oth)   
    412 #define SOC_OLP_TX_CTR2_ACTION(_oth)        SOC_OLP_TX_CTR2_ACTION_GET(_oth) 
    413 #define SOC_OLP_TX_TIMESTAMP_ACTION(_oth)   SOC_OLP_TX_TIMESTAMP_ACTION_GET(_oth)  
    414 #define SOC_OLP_TX_OAM_OFFSET(_oth)         SOC_OLP_TX_OAM_OFFSET_GET(_oth)
    415 
    416 #define SOC_OLP_TX_CTR2_ID_SET(_oth,val)    {           \
    417     (_oth)->u2.s2._ctr2_id1 = ((val) & 0x7C00) >> 10;   \
    418     (_oth)->u3.s31._ctr2_id2 = (val) & (0x3ff);        \
    419     }
    420 
    421 #ifdef BCM_TRIDENT2PLUS_SUPPORT     
    422 #define SOC_OLP_TX_CLASSID_GET(_oth)     \
    423     (((_oth)->u3.s31._class_id1 << 6) | ((_oth)->u4.s41._class_id2))
    424 
    425 #define SOC_OLP_TX_CLASSID(_oth)    SOC_OLP_TX_CLASSID_GET(_oth) 
    426 #endif
    427 
    428 #if defined(BCM_SABER2_SUPPORT) || defined(BCM_APACHE_SUPPORT)
    429 #define SOC_OLP_TX_REL_LM_REP_OFF_GET(_oth)     \
    430     ((_oth)->u3.s32.rel_lm_replacement_off )
    431 #define SOC_OLP_TX_REL_LM_REP_OP_GET(_oth)     \
    432     ((_oth)->u3.s32.lm_replacement_off_oper )
    433 #define SOC_OLP_TX_CTR3_LOCATION_GET(_oth)     \
    434     ((_oth)->u3.s32.ctr3_location )
    435 #define SOC_OLP_TX_CTR3_ID_GET(_oth)     \
    436     (((_oth)->u3.s32._ctr3_id1 << 11) | ((_oth)->u4.s42._ctr3_id2))
    437 #define SOC_OLP_TX_CTR3_ACTION_GET(_oth)     \
    438     ((_oth)->u4.s42.ctr3_action )
    439 #define SOC_OLP_TX_CTR1_OFF_LM_GET(_oth)     \
    440     ((_oth)->u4.s42.ctr1_off_to_lm )
    441 #define SOC_OLP_TX_CTR2_OFF_LM_GET(_oth)     \
    442     ((_oth)->u4.s42.ctr2_off_to_lm )
    443 #define SOC_OLP_TX_CTR3_OFF_LM_GET(_oth)     \
    444     ((_oth)->u4.s42.ctr3_off_to_lm )
    445 
    446 #define SOC_OLP_TX_REL_LM_REP_OFF(_oth)     SOC_OLP_TX_REL_LM_REP_OFF_GET(_oth)    
    447 #define SOC_OLP_TX_REL_LM_REP_OP(_oth)      SOC_OLP_TX_REL_LM_REP_OP_GET(_oth)
    448 #define SOC_OLP_TX_CTR3_LOCATION(_oth)      SOC_OLP_TX_CTR3_LOCATION_GET(_oth)
    449 #define SOC_OLP_TX_CTR3_ID_SET(_oth,val)    {           \
    450     (_oth)->u3.s32._ctr3_id1 = ((val) & 0x7800) >> 11;   \
    451     (_oth)->u4.s42._ctr3_id2 = (val) & (0x7ff);        \
    452     }
    453 #define SOC_OLP_TX_CTR3_ACTION(_oth)        SOC_OLP_TX_CTR3_ACTION_GET(_oth)
    454 #define SOC_OLP_TX_CTR1_OFF_LM(_oth)        SOC_OLP_TX_CTR1_OFF_LM_GET(_oth)
    455 #define SOC_OLP_TX_CTR2_OFF_LM(_oth)        SOC_OLP_TX_CTR2_OFF_LM_GET(_oth)
    456 #define SOC_OLP_TX_CTR3_OFF_LM(_oth)        SOC_OLP_TX_CTR3_OFF_LM_GET(_oth)
    457 
    458 #endif /* BCM_SABER2_SUPPORT || BCM_APACHE_SUPPORT */
    459 
    460 #define SOC_OLP_TX_CTR(pool,idx)    \
    461         ((((pool) << 12) & 0x7000) | ((idx) & 0xfff))
    462 
    463 #endif /* _SOC_SHARED_OLP_PKT_H_ */
    464