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

tdm.h (9064B)


      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  */
      9 
     10 #ifndef __BCM_TDM_H__
     11 #define __BCM_TDM_H__
     12 
     13 #include <bcm/types.h>
     14 #include <bcm/error.h>
     15 
     16 /* Egress editing type */
     17 typedef enum bcm_tdm_egress_editing_type_e {
     18     bcmTdmEgressEditingNoHeader = 0,    /* No Header is prepended for outgoing
     19                                            TDM packet */
     20     bcmTdmEgressEditingNoStamp = 1,     /* No stamping performed by egress, TDM
     21                                            packet header left as it arrived from
     22                                            ingress */
     23     bcmTdmEgressEditingStampMulticastEncapId = 2, /* Stamp MC ID inside the TDM
     24                                            header(either OTMH or FTMH) */
     25     bcmTdmEgressEditingStampMulticastUserDefined = 3 /* Stamp Port Attribute in Outgoing TDM
     26                                            Header(either OTMH or FTMH) */
     27 } bcm_tdm_egress_editing_type_t;
     28 
     29 /* Ingress editing type */
     30 typedef enum bcm_tdm_ingress_editing_type_e {
     31     bcmTdmIngressEditingNoChange = 0,   /* Do not prepend FTMH header, assuming
     32                                            is was added by upstream device */
     33     bcmTdmIngressEditingPrepend = 1     /* Prepend internal forwarding header
     34                                            (FTMH) to all received TDM packets */
     35 } bcm_tdm_ingress_editing_type_t;
     36 
     37 /* Control of various global TDM features */
     38 typedef enum bcm_tdm_control_e {
     39     bcmTdmBypassMinPacketSize = 0,  /* Minimum packet size for Bypass TDM packet */
     40     bcmTdmBypassMaxPacketSize = 1,  /* Maximum packet size for Bypass TDM packet */
     41     bcmTdmOutHeaderType = 2,        /* One of BCM_TDM_CONTROL_OUT_HEADER_XXX. */
     42     bcmTdmStreamMulticastPrefix = 3 /* Set 5 Bit prefix from Stream ID to
     43                                        Multicast ID. */
     44 } bcm_tdm_control_t;
     45 
     46 #ifndef BCM_HIDE_DISPATCHABLE
     47 
     48 extern int bcm_tdm_control_set(
     49     int unit, 
     50     bcm_tdm_control_t type, 
     51     int arg);
     52 
     53 extern int bcm_tdm_control_get(
     54     int unit, 
     55     bcm_tdm_control_t type, 
     56     int *arg);
     57 
     58 #endif /* BCM_HIDE_DISPATCHABLE */
     59 
     60 /* TDM controls defines for outgoing header type */
     61 #define BCM_TDM_CONTROL_OUT_HEADER_OTMH     0          /* TDM outgoing header is
     62                                                           OTMH */
     63 #define BCM_TDM_CONTROL_OUT_HEADER_FTMH     1          /* TDM outgoing header is
     64                                                           FTMH */
     65 #define BCM_TDM_CONTROL_OUT_HEADER_OTMH_4B_WITH_CUD 2          /* TDM outgoing header is
     66                                                           4 bytes OTMH with CUD */
     67 
     68 /* tdm egress editing configuration */
     69 typedef struct bcm_tdm_egress_editing_s {
     70     bcm_tdm_egress_editing_type_t type; /* Editing type */
     71     uint32 user_data;                   /* User data to be stamped in outgoing
     72                                            TDM header, valid only for
     73                                            TdmEgressEditingStampMulticastUserDefined
     74                                            editing type */
     75 } bcm_tdm_egress_editing_t;
     76 
     77 #ifndef BCM_HIDE_DISPATCHABLE
     78 
     79 /* Set/Get visibility mode */
     80 extern int bcm_tdm_egress_editing_set(
     81     int unit, 
     82     uint32 flags, 
     83     bcm_gport_t gport, 
     84     bcm_tdm_egress_editing_t *editing);
     85 
     86 /* Set/Get visibility mode */
     87 extern int bcm_tdm_egress_editing_get(
     88     int unit, 
     89     uint32 flags, 
     90     bcm_gport_t gport, 
     91     bcm_tdm_egress_editing_t *editing);
     92 
     93 #endif /* BCM_HIDE_DISPATCHABLE */
     94 
     95 /* TDM ingress context flags */
     96 #define BCM_TDM_INGRESS_CONTEXT_WITH_ID     0x0001     /* Use the specified
     97                                                           ingress context ID */
     98 #define BCM_TDM_INGRESS_CONTEXT_REPLACE     0x0002     /* Replace the content of
     99                                                           already existing
    100                                                           ingress context */
    101 #define BCM_TDM_INGRESS_CONTEXT_SPECIFIC_FABRIC_LINKS 0x0004     /* Select setup for
    102                                                           fabric links assigned
    103                                                           for TDM */
    104 
    105 /* Misc. defines for TDM module */
    106 #define BCM_TDM_USER_DATA_MAX_SIZE  6          /* Maximum size of user field in
    107                                                   bytes */
    108 #define BCM_TDM_MAX_FABRIC_PORTS    112        /* maximum fabric links */
    109 
    110 /* TDM ingress editing context */
    111 typedef struct bcm_tdm_ingress_context_s {
    112     bcm_tdm_ingress_editing_type_t type; /* Ingress editing type */
    113     int is_mc;                          /* TRUE => multicast_id is valid, FALSE
    114                                            => destination_port is valid */
    115     bcm_gport_t destination_port;       /* destination port. Valid for unicast
    116                                            configuration. */
    117     bcm_multicast_t multicast_id;       /* Multicast Id. Valid for multicast
    118                                            configuration. */
    119     uint8 user_data[BCM_TDM_USER_DATA_MAX_SIZE]; /* User data to be set in FTMH header.
    120                                            Not relevant for Optimized FTMH
    121                                            header */
    122     int user_data_count;                /* Actual number of valid bits in
    123                                            user_data */
    124     bcm_port_t fabric_ports[BCM_TDM_MAX_FABRIC_PORTS]; /* Array of fabric ports used for direct
    125                                            routing */
    126     int fabric_ports_count;             /* Actual number of valid fabric ports
    127                                            in array. Setting count to zero
    128                                            implies no direct routing */
    129     int is_not_tdm;                     /* TRUE => CPU Injected Traffic will not
    130                                            be marked TDM, FALSE => Regular
    131                                            behaviour */
    132     int stamp_mcid_with_sid;            /* TRUE value means replace Multicast ID
    133                                            by Stream ID in FTMH header */
    134 } bcm_tdm_ingress_context_t;
    135 
    136 /* Initialize a tdm ingress editing context structure. */
    137 extern void bcm_tdm_ingress_editing_context_t_init(
    138     bcm_tdm_ingress_context_t *editing);
    139 
    140 #ifndef BCM_HIDE_DISPATCHABLE
    141 
    142 /* Set TDM editing context configuration */
    143 extern int bcm_tdm_ingress_context_create(
    144     int unit, 
    145     uint32 flags, 
    146     int *ingress_context_id, 
    147     bcm_tdm_ingress_context_t *editing);
    148 
    149 /* Delete TDM Ingress Context */
    150 extern int bcm_tdm_ingress_context_destroy(
    151     int unit, 
    152     uint32 flags, 
    153     int ingress_context_id);
    154 
    155 /* Get TDM editing context configuration */
    156 extern int bcm_tdm_ingress_context_get(
    157     int unit, 
    158     uint32 flags, 
    159     int ingress_context_id, 
    160     bcm_tdm_ingress_context_t *editing);
    161 
    162 /* Enable/Disable Drop per editing context */
    163 extern int bcm_tdm_ingress_context_failover_set(
    164     int unit, 
    165     uint32 flags, 
    166     int nof_contexts, 
    167     int *context_ids, 
    168     int *context_en);
    169 
    170 /* Get Drop mode per editing context configuration */
    171 extern int bcm_tdm_ingress_context_failover_get(
    172     int unit, 
    173     uint32 flags, 
    174     int nof_contexts, 
    175     int *context_ids, 
    176     int *context_en);
    177 
    178 /* Set context ID per stream */
    179 extern int bcm_tdm_stream_ingress_context_set(
    180     int unit, 
    181     uint32 flags, 
    182     bcm_gport_t gport, 
    183     int ingress_context_id);
    184 
    185 /* Get context ID per stream */
    186 extern int bcm_tdm_stream_ingress_context_get(
    187     int unit, 
    188     uint32 flags, 
    189     int stream_id, 
    190     int *ingress_context_id);
    191 
    192 #endif /* BCM_HIDE_DISPATCHABLE */
    193 
    194 /* TDM stream configuration */
    195 typedef struct bcm_tdm_interface_config_s {
    196     int stream_id_base;         /* start address for interface stream entries in
    197                                    Flow to Context map */
    198     int stream_id_enable;       /* When TRUE, Stream is defined by offset &
    199                                    size, When FALSE, ILKN - Stream is assigned
    200                                    per channel, Ethernet - only one stream per
    201                                    interface */
    202     int stream_id_key_offset;   /* Relevant for stream_id_enable TRUE only. Key
    203                                    offset from the beginning of packet header in
    204                                    bits 8b 0-255 */
    205     int stream_id_key_size;     /* Relevant for stream_id_enable TRUE only. Key
    206                                    size in bits 1-14 */
    207 } bcm_tdm_interface_config_t;
    208 
    209 #ifndef BCM_HIDE_DISPATCHABLE
    210 
    211 /* Set TDM interface stream configuration */
    212 extern int bcm_tdm_interface_config_set(
    213     int unit, 
    214     uint32 flags, 
    215     bcm_gport_t gport, 
    216     bcm_tdm_interface_config_t *interface_config);
    217 
    218 /* Get TDM interface stream configuration */
    219 extern int bcm_tdm_interface_config_get(
    220     int unit, 
    221     uint32 flags, 
    222     bcm_gport_t gport, 
    223     bcm_tdm_interface_config_t *interface_config);
    224 
    225 #endif /* BCM_HIDE_DISPATCHABLE */
    226 
    227 #endif /* __BCM_TDM_H__ */