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

subport.h (20086B)


      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  * DO NOT EDIT THIS FILE!
      9  * This file is auto-generated.
     10  * Edits to this file will be lost when it is regenerated.
     11  */
     12 
     13 #ifndef __BCM_SUBPORT_H__
     14 #define __BCM_SUBPORT_H__
     15 
     16 #include <bcm/types.h>
     17 
     18 #ifndef BCM_HIDE_DISPATCHABLE
     19 
     20 /* Initialize the BCM subport module. */
     21 extern int bcm_subport_init(
     22     int unit);
     23 
     24 /* Detach the BCM subport module. */
     25 extern int bcm_subport_cleanup(
     26     int unit);
     27 
     28 #endif /* BCM_HIDE_DISPATCHABLE */
     29 
     30 /* Subport group create flags. */
     31 #define BCM_SUBPORT_GROUP_WITH_ID           0x00000001 /* Add using the
     32                                                           specified ID. */
     33 #define BCM_SUBPORT_GROUP_TYPE_LINKPHY      0x00000002 /* Add a LinkPHY subport
     34                                                           group. */
     35 #define BCM_SUBPORT_GROUP_TYPE_SUBPORT_TAG  0x00000004 /* Add a 'subport tag'
     36                                                           (triple vlan tag)
     37                                                           subport group. */
     38 #define BCM_SUBPORT_GROUP_TYPE_SUBPORT_PKTTAG 0x00000008 /* Add a 'LLTAG tag'
     39                                                           (triple vlan tag)
     40                                                           subport group. */
     41 #define BCM_SUBPORT_GROUP_QUEUE             0x00000010 /* If set, use subport
     42                                                           group queues; Else,
     43                                                           use egress port
     44                                                           DiffServ queues. */
     45 #define BCM_SUBPORT_GROUP_TYPE_GENERAL      0x00000020 /* Add a general purpose
     46                                                           subport group. */
     47 
     48 /* Subport port property flags. */
     49 #define BCM_SUBPORT_PROPERTY_PHB    0x00000001 /* Subport port PHB is valid.
     50                                                   Packet's 'internal priority'
     51                                                   and 'color' will be derived
     52                                                   from subport port lookup. */
     53 
     54 #define BCM_SUBPORT_CONFIG_MAX_STREAMS  2          /* Max number of streams per
     55                                                       LinkPHY subport */
     56 
     57 /* bcm_subport_group_config_t */
     58 typedef struct bcm_subport_group_config_s {
     59     uint32 flags;           /* BCM_SUBPORT_GROUP_xxx. */
     60     bcm_gport_t port;       /* Physical GPORT Identifier */
     61     bcm_vlan_t vlan;        /* VLAN the group is attached to */
     62     int if_class;           /* Interface class ID */
     63     uint32 prop_flags;      /* Property flags for this subport group */
     64     bcm_gport_t queue_base; /* Subport group base queue */
     65     int qos_map_id;         /* QoS map identifier which defines priorities 1-1
     66                                mapping to queue offsets (0 ~ 7). */
     67 } bcm_subport_group_config_t;
     68 
     69 /* bcm_subport_group_config_t_init */
     70 extern void bcm_subport_group_config_t_init(
     71     bcm_subport_group_config_t *config);
     72 
     73 #ifndef BCM_HIDE_DISPATCHABLE
     74 
     75 /* bcm_subport_group_create */
     76 extern int bcm_subport_group_create(
     77     int unit, 
     78     bcm_subport_group_config_t *config, 
     79     bcm_gport_t *group);
     80 
     81 /* bcm_subport_group_destroy */
     82 extern int bcm_subport_group_destroy(
     83     int unit, 
     84     bcm_gport_t group);
     85 
     86 /* bcm_subport_group_get */
     87 extern int bcm_subport_group_get(
     88     int unit, 
     89     bcm_gport_t group, 
     90     bcm_subport_group_config_t *config);
     91 
     92 #endif /* BCM_HIDE_DISPATCHABLE */
     93 
     94 /* bcm_subport_match_t */
     95 typedef enum bcm_subport_match_e {
     96     BCM_SUBPORT_MATCH_INVALID = 0,      /* Illegal. */
     97     BCM_SUBPORT_MATCH_PKT_VID = 1,      /* Mod/port/trunk + LLTAG VID. */
     98     BCM_SUBPORT_MATCH_PKT_VID_INNER_VLAN = 2, /* Mod/port/trunk + LLTAG VID + inner
     99                                            VLAN. */
    100     BCM_SUBPORT_MATCH_PKT_VID_OUTER_VLAN = 3, /* Mod/port/trunk + LLTAG VID + outer
    101                                            VLAN. */
    102     BCM_SUBPORT_MATCH_COUNT = 4         /* Must be last. */
    103 } bcm_subport_match_t;
    104 
    105 /* bcm_subport_config_t */
    106 typedef struct bcm_subport_config_s {
    107     bcm_gport_t group;                  /* Subport group */
    108     bcm_vlan_t pkt_vlan;                /* Packet 16-bit VLAN tag */
    109     bcm_vlan_t inner_vlan;              /* 12-bit inner VLAN */
    110     bcm_vlan_t outer_vlan;              /* 12-bit outerVLAN */
    111     int int_pri;                        /* Internal Priority for this subport
    112                                            port */
    113     uint32 prop_flags;                  /* Property flags for this subport port */
    114     uint16 stream_id_array[BCM_SUBPORT_CONFIG_MAX_STREAMS]; /* LinkPHY fragment header Stream ID
    115                                            array to be associated with the
    116                                            LinkPHY subport port. */
    117     int num_streams;                    /* Number of streams associated with the
    118                                            LinkPHY subport port. */
    119     bcm_color_t color;                  /* (internal) color or drop precedence
    120                                            for this subport port. */
    121     bcm_subport_match_t criteria;       /* match criteria. */
    122     bcm_gport_t subport_modport;        /* CoE - System port associated with the
    123                                            subport tag */
    124 } bcm_subport_config_t;
    125 
    126 /* bcm_subport_config_t_init */
    127 extern void bcm_subport_config_t_init(
    128     bcm_subport_config_t *config);
    129 
    130 #ifndef BCM_HIDE_DISPATCHABLE
    131 
    132 /* bcm_subport_port_add */
    133 extern int bcm_subport_port_add(
    134     int unit, 
    135     bcm_subport_config_t *config, 
    136     bcm_gport_t *port);
    137 
    138 /* bcm_subport_port_delete */
    139 extern int bcm_subport_port_delete(
    140     int unit, 
    141     bcm_gport_t port);
    142 
    143 /* bcm_subport_port_get */
    144 extern int bcm_subport_port_get(
    145     int unit, 
    146     bcm_gport_t port, 
    147     bcm_subport_config_t *config);
    148 
    149 #endif /* BCM_HIDE_DISPATCHABLE */
    150 
    151 /* bcm_subport_port_traverse_cb */
    152 typedef int (*bcm_subport_port_traverse_cb)(
    153     int unit, 
    154     bcm_gport_t port, 
    155     bcm_subport_config_t *config, 
    156     void *user_data);
    157 
    158 #ifndef BCM_HIDE_DISPATCHABLE
    159 
    160 /* bcm_subport_port_traverse */
    161 extern int bcm_subport_port_traverse(
    162     int unit, 
    163     bcm_subport_port_traverse_cb cb, 
    164     void *user_data);
    165 
    166 /* 
    167  * Traverse the subports of a given subport group and call the
    168  * user-supplied callback function for each subport
    169  */
    170 extern int bcm_subport_group_traverse(
    171     int unit, 
    172     bcm_gport_t subport_group, 
    173     bcm_subport_port_traverse_cb cb, 
    174     void *user_data);
    175 
    176 #endif /* BCM_HIDE_DISPATCHABLE */
    177 
    178 /* LinkPHY configuration action mask */
    179 #define BCM_SUBPORT_LINKPHY_BASE_STREAM_ID  0x00000001 
    180 #define BCM_SUBPORT_LINKPHY_HEADER_MODE     0x00000002 
    181 #define BCM_SUBPORT_LINKPHY_RX_CHECK_FLAGS  0x00000004 
    182 #define BCM_SUBPORT_LINKPHY_RX_VLAN_TPID    0x00000008 
    183 #define BCM_SUBPORT_LINKPHY_RX_NEAREND_MAC  0x00000010 
    184 #define BCM_SUBPORT_LINKPHY_RX_FAREND_MAC   0x00000020 
    185 #define BCM_SUBPORT_LINKPHY_RX_DFC_DEST_MAC 0x00000040 
    186 #define BCM_SUBPORT_LINKPHY_RX_DFC_OPCODE   0x00000080 
    187 #define BCM_SUBPORT_LINKPHY_RX_DFC_TIME     0x00000100 
    188 #define BCM_SUBPORT_LINKPHY_RX_DFC_MAC_TYPE 0x00000200 
    189 #define BCM_SUBPORT_LINKPHY_TX_VLAN_TPID    0x00000400 
    190 #define BCM_SUBPORT_LINKPHY_TX_NEAREND_MAC  0x00000800 
    191 #define BCM_SUBPORT_LINKPHY_TX_FAREND_MAC   0x00001000 
    192 #define BCM_SUBPORT_LINKPHY_TX_PENULTIMATE_MODE 0x00002000 /* If this flag is
    193                                                           selected then TX
    194                                                           penultimate mode is
    195                                                           enabled. The
    196                                                           penultimate-fragment
    197                                                           of the frame would be
    198                                                           64-bytes(Payload-size)
    199                                                           to avoid padding in
    200                                                           the last-fragment. If
    201                                                           this flag is
    202                                                           deselected then TX
    203                                                           penultimate mode is
    204                                                           disabled. */
    205 #define BCM_SUBPORT_LINKPHY_ALL             0xFFFFFFFF 
    206 
    207 /* Check flags for received LinkPHY fragments */
    208 #define BCM_SUBPORT_LINKPHY_RX_NEAREND_MAC_CHECK 0x00000001 /* enable/disable nearend
    209                                                           MAC compare */
    210 #define BCM_SUBPORT_LINKPHY_RX_FAREND_MAC_CHECK 0x00000002 /* enable/disable far end
    211                                                           MAC compare */
    212 #define BCM_SUBPORT_LINKPHY_RX_DFC_DEST_MAC_CHECK 0x00000004 /* enable/disable DFC
    213                                                           destination MAC
    214                                                           compare */
    215 #define BCM_SUBPORT_LINKPHY_RX_DFC_OPCODE_CHECK 0x00000008 /* enable/disable DFC
    216                                                           opcode compare */
    217 #define BCM_SUBPORT_LINKPHY_RX_DFC_TIME_CHECK 0x00000010 /* enable/disable DFC
    218                                                           time compare */
    219 
    220 /* LinkPHY fragment header mode */
    221 typedef enum bcm_subport_group_linkphy_header_mode_e {
    222     bcmSubportLinkphyHeaderModeEthAdapt = 0, /* Ethernet-Adaptation LinkPHY header
    223                                            mode */
    224     bcmSubportLinkphyHeaderModeTciLength = 1 /* TCI+Length LinkPHY header mode */
    225 } bcm_subport_group_linkphy_header_mode_t;
    226 
    227 /* Subport statistics */
    228 typedef enum bcm_subport_stat_e {
    229     bcmSubportLinkPhyStatRxFragmentBytes = 0, /* LinkPHY subport Rx fragment bytes
    230                                            statistics */
    231     bcmSubportLinkPhyStatRxFragments = 1, /* LinkPHY subport Rx fragments
    232                                            statistics */
    233     bcmSubportLinkPhyStatRxFrameBytes = 2, /* LinkPHY subport Rx frame bytes
    234                                            statistics */
    235     bcmSubportLinkPhyStatRxFrames = 3,  /* LinkPHY subport Rx frames statistics */
    236     bcmSubportLinkPhyStatTxFragmentBytes = 4, /* LinkPHY subport Tx fragment bytes
    237                                            statistics */
    238     bcmSubportLinkPhyStatTxFragments = 5, /* LinkPHY subport Tx fragments
    239                                            statistics */
    240     bcmSubportLinkPhyStatTxFrameBytes = 6, /* LinkPHY subport Tx frame bytes
    241                                            statistics */
    242     bcmSubportLinkPhyStatTxFrames = 7   /* LinkPHY subport Tx frames statistics */
    243 } bcm_subport_stat_t;
    244 
    245 /* List of Linkphy RX errors */
    246 typedef enum bcm_subport_linkphy_rx_error_e {
    247     bcmSubportLinkphyRxErrorMaxFrameSize = 0, /* Linkphy RX error due to Frame with
    248                                            max frame size */
    249     bcmSubportLinkphyRxErrorRuntFrame = 1, /* Linkphy RX error due to Runt frame */
    250     bcmSubportLinkphyRxErrorDfcLength = 2, /* Linkphy RX error due to a DFC Frame
    251                                            with unacceptable length */
    252     bcmSubportLinkphyRxErrorDfcDropPortPurge = 3, /* Linkphy RX error due to a DFC Frame
    253                                            drop due to port purge */
    254     bcmSubportLinkphyRxErrorDfcTime = 4, /* Linkphy RX error due to a DFC Frame
    255                                            with Time error */
    256     bcmSubportLinkphyRxErrorDfcOpcode = 5, /* Linkphy RX error due to a DFC Frame
    257                                            with Opcode error */
    258     bcmSubportLinkphyRxErrorLengthZero = 6, /* Linkphy RX error due to Fragment with
    259                                            header length zero */
    260     bcmSubportLinkphyRxErrorNonEofPaddedFragment = 7, /* Linkphy RX error due to Frame with
    261                                            non-EOF padded fragment */
    262     bcmSubportLinkphyRxErrorHdrLengthGtFragmentLength = 8, /* Linkphy RX error due to Fragment with
    263                                            header length greater than actual
    264                                            fragment length */
    265     bcmSubportLinkphyRxErrorFraming = 9, /* Linkphy RX error due to Frame with
    266                                            SOF/EOF/MOF errors */
    267     bcmSubportLinkphyRxErrorFrameCrc = 10, /* Linkphy RX error due to Frame with
    268                                            CRC error. NA for DFC frame */
    269     bcmSubportLinkphyRxErrorStreamIdUnexpected = 11, /* Linkphy RX error due to Fragment with
    270                                            unexpected streamId */
    271     bcmSubportLinkphyRxErrorMacSA = 12, /* Linkphy RX error due to Data fragment
    272                                            or DFC frame that does not match
    273                                            configured MAC SA */
    274     bcmSubportLinkphyRxErrorMacDA = 13, /* Linkphy RX error due to Data fragment
    275                                            or DFC frame that does not match
    276                                            configured MAC DA */
    277     bcmSubportLinkphyRxErrorEthertype = 14, /* Linkphy RX error due to Data fragment
    278                                            or DFC frame that does not match
    279                                            configured data TPID or DFC ethertype
    280                                            respectively */
    281     bcmSubportLinkphyRxErrorCount = 15  /* Not an usable value. Always last */
    282 } bcm_subport_linkphy_rx_error_t;
    283 
    284 /* Bitmap of Linkphy RX errors */
    285 typedef struct bcm_subport_linkphy_rx_errors_s {
    286     SHR_BITDCL w[_SHR_BITDCLSIZE(bcmSubportLinkphyRxErrorCount)]; 
    287 } bcm_subport_linkphy_rx_errors_t;
    288 
    289 /* Macros to manipulate the bitmap of Linkphy RX errors */
    290 #define BCM_SUBPORT_LINKPHY_RX_ERROR_SET(_error_types, _error_type)  SHR_BITSET(((_error_types).w), (_error_type)) 
    291 #define BCM_SUBPORT_LINKPHY_RX_ERROR_GET(_error_types, _error_type)  SHR_BITGET(((_error_types).w), (_error_type)) 
    292 #define BCM_SUBPORT_LINKPHY_RX_ERROR_CLEAR(_error_types, _error_type)  SHR_BITCLR(((_error_types).w), (_error_type)) 
    293 #define BCM_SUBPORT_LINKPHY_RX_ERROR_SET_ALL(_error_types)  SHR_BITSET_RANGE(((_error_types).w), 0, bcmSubportLinkphyRxErrorCount) 
    294 #define BCM_SUBPORT_LINKPHY_RX_ERROR_CLEAR_ALL(_error_types)  SHR_BITCLR_RANGE(((_error_types).w), 0, bcmSubportLinkphyRxErrorCount) 
    295 
    296 /* LinkPHY configuration parameters per port. */
    297 typedef struct bcm_subport_group_linkphy_config_s {
    298     uint32 action_mask;                 /* BCM_SUBPORT_LINKPHY_xxx flags */
    299     uint16 base_stream_id;              /* External Stream ID base */
    300     bcm_subport_group_linkphy_header_mode_t header_mode; /* LinkPHY fragment header mode */
    301     uint32 rx_check_flags;              /* flags
    302                                            BCM_SUBPORT_LINKPHY_RX_XXX_CHECK for
    303                                            comparing RXed fragment header
    304                                            parameters */
    305     uint16 rx_vlan_tpid;                /* Expected Vlan TPID in header of
    306                                            LinkPHY fragments RXed */
    307     bcm_mac_t rx_nearend_mac;           /* Expected near end MAC address in
    308                                            header of LinkPHY fragments RXed */
    309     bcm_mac_t rx_farend_mac;            /* Expected far end MAC address in
    310                                            header of LinkPHY fragments RXed */
    311     bcm_mac_t rx_dfc_dest_mac;          /* Expected Destination MAC address in
    312                                            header of DFC fragments RXed */
    313     uint16 rx_dfc_opcode;               /* Expected opcode in header of DFC
    314                                            fragments RXed */
    315     uint16 rx_dfc_time;                 /* Expected TIME in header of DFC
    316                                            fragments RXed */
    317     uint16 rx_dfc_mac_type;             /* Expected Ethertype in header of DFC
    318                                            fragments RXed */
    319     uint16 tx_vlan_tpid;                /* Vlan TPID to be set in header of
    320                                            LinkPHY fragments TXed */
    321     bcm_mac_t tx_nearend_mac;           /* Near end MAC address to be set in
    322                                            header of LinkPHY fragments TXed */
    323     bcm_mac_t tx_farend_mac;            /* Far end MAC address to be set in
    324                                            header of LinkPHY fragments TXed */
    325 } bcm_subport_group_linkphy_config_t;
    326 
    327 /* The maximum size of Linkphy RX fragment */
    328 #define BCM_SUBPORT_LINKPHY_MAX_FRAGMENT_SIZE 192        
    329 
    330 /* Data related to the fragment with the error */
    331 typedef struct bcm_subport_linkphy_rx_error_data_s {
    332     bcm_port_t port;                    /* Physical port on which the errored
    333                                            fragment was received */
    334     uint16 ext_stream_id;               /* The external stream id in the errored
    335                                            fragment */
    336     uint8 fragment_data[BCM_SUBPORT_LINKPHY_MAX_FRAGMENT_SIZE]; /* The entire fragment data */
    337 } bcm_subport_linkphy_rx_error_data_t;
    338 
    339 /* bcm_subport_group_linkphy_config_t_init */
    340 extern void bcm_subport_group_linkphy_config_t_init(
    341     bcm_subport_group_linkphy_config_t *linkphy_config);
    342 
    343 #ifndef BCM_HIDE_DISPATCHABLE
    344 
    345 /* Set LinkPHY configuration parameters for a given port. */
    346 extern int bcm_subport_group_linkphy_config_set(
    347     int unit, 
    348     bcm_gport_t port, 
    349     bcm_subport_group_linkphy_config_t *linkphy_config);
    350 
    351 /* Get LinkPHY configuration parameters for a given port. */
    352 extern int bcm_subport_group_linkphy_config_get(
    353     int unit, 
    354     bcm_gport_t port, 
    355     bcm_subport_group_linkphy_config_t *linkphy_config);
    356 
    357 /* Set the statistics value for a given subport port and statistics type. */
    358 extern int bcm_subport_port_stat_set(
    359     int unit, 
    360     bcm_gport_t port, 
    361     int stream_id, 
    362     bcm_subport_stat_t stat_type, 
    363     uint64 val);
    364 
    365 /* Get the statistics value for a given subport port and statistics type. */
    366 extern int bcm_subport_port_stat_get(
    367     int unit, 
    368     bcm_gport_t port, 
    369     int stream_id, 
    370     bcm_subport_stat_t stat_type, 
    371     uint64 *val);
    372 
    373 #endif /* BCM_HIDE_DISPATCHABLE */
    374 
    375 /* 
    376  * BCM_SUBPORT_LINKPHY_RX_ERROR_CB_XXX flags - Used in callback functions
    377  * for Linkphy RX errors
    378  */
    379 #define BCM_SUBPORT_LINKPHY_RX_ERROR_CB_DATA_VALID 0x1        /* Indicates that the
    380                                                           callback data is valid */
    381 
    382 /* Callback function for a given Linkphy RX error type */
    383 typedef int (*bcm_subport_linkphy_rx_error_callback)(
    384     int unit, 
    385     bcm_subport_linkphy_rx_error_t error_type, 
    386     uint32 flags, 
    387     bcm_subport_linkphy_rx_error_data_t *error_data, 
    388     void *user_data);
    389 
    390 /* Information structure passed to Linkphy RX error registration */
    391 typedef struct bcm_subport_linkphy_rx_error_reg_info_s {
    392     bcm_subport_linkphy_rx_error_callback cb; /* Callback to be registered */
    393     int data_log_enable;                /* To enable/disable data logging for
    394                                            given set of errors */
    395 } bcm_subport_linkphy_rx_error_reg_info_t;
    396 
    397 /* Initialize the bcm_subport_linkphy_rx_error_reg_info_t structure */
    398 extern void bcm_subport_linkphy_rx_error_reg_info_t_init(
    399     bcm_subport_linkphy_rx_error_reg_info_t *reg_info);
    400 
    401 #ifndef BCM_HIDE_DISPATCHABLE
    402 
    403 /* Linkphy RX error callback registration API */
    404 extern int bcm_subport_linkphy_rx_error_register(
    405     int unit, 
    406     bcm_subport_linkphy_rx_errors_t errors, 
    407     bcm_subport_linkphy_rx_error_reg_info_t *reg_info, 
    408     void *user_data);
    409 
    410 /* Linkphy RX error callback de-registration API */
    411 extern int bcm_subport_linkphy_rx_error_unregister(
    412     int unit, 
    413     bcm_subport_linkphy_rx_errors_t errors);
    414 
    415 /* Get the mod-port associated with a subport gport. */
    416 extern int bcm_subport_gport_modport_get(
    417     int unit, 
    418     bcm_gport_t subport_gport, 
    419     bcm_module_t *module, 
    420     bcm_port_t *port);
    421 
    422 #endif /* BCM_HIDE_DISPATCHABLE */
    423 
    424 #endif /* __BCM_SUBPORT_H__ */