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

tnl_term.h (4555B)


      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 _TUNNEL_TERMINATION_H_
      9 #define _TUNNEL_TERMINATION_H_
     10 #include <shared/l3.h>
     11 #include <soc/mem.h>
     12 
     13 #define SOC_TNL_TERM_IPV4_ENTRY_WIDTH  (1) /* 1 table entry required     */
     14                                            /* for IPv4 tunnel terminator.*/
     15 #define SOC_TNL_TERM_IPV6_ENTRY_WIDTH  (4) /* 4 table entries required   */
     16                                            /* for IPv6 tunnel terminator.*/
     17 
     18 #define SOC_TNL_TERM_ENTRY_MODE_SINGLE  0
     19 #define SOC_TNL_TERM_ENTRY_MODE_DOUBLE  2
     20 #define SOC_TNL_TERM_ENTRY_MODE_QUAD    1
     21 
     22 #define SOC_TNL_TERM_ENTRY_WIDTH_SINGLE 1
     23 #define SOC_TNL_TERM_ENTRY_WIDTH_DOUBLE 2
     24 #define SOC_TNL_TERM_ENTRY_WIDTH_QUAD 4
     25 
     26 
     27 #define SOC_TNL_TERM_IDX_TO_BLOCK_START(_idx_, _block_start_, _block_size_)    \
     28        (_block_start_) = (_idx_) - ((_idx_) % _block_size_); 
     29 
     30 /*
     31  * Tunnel termination entry structure. 
     32  * contains up to SOC_TNL_TERM_ENTRY_WIDTH_MAX L3_TUNNEL table entries
     33  */
     34 /*
     35  * Tomahawk3 uses generic Hash table with L3_TUNNEL_quad and L3_TUNNEL_DOUBLE
     36  * for L3 tunnel entries. The sizes of these entries are 48 and 24 bytes, and
     37  * will fit in this structure, however we may have to handle any changes for
     38  * future devices.
     39  */
     40 
     41 typedef struct soc_tunnel_term_s {
     42     tunnel_entry_t entry_arr[SOC_TNL_TERM_IPV6_ENTRY_WIDTH];
     43 } soc_tunnel_term_t;
     44 
     45 
     46 /* Tunnel terminator hash key. */
     47 typedef union soc_tnl_term_hash_key_u {
     48     /* IPv4/IPv6 Key fields */
     49     struct {
     50         uint8 dip[_SHR_L3_IP6_ADDRLEN];     /* Destination ip address. */
     51         uint8 sip[_SHR_L3_IP6_ADDRLEN];     /* Source ip address.      */
     52         uint8 sip_plen;                     /* Source ip prefix length.*/
     53         uint16 l4_src_port;                 /* L4 source port.         */
     54         uint16 l4_dst_port;                 /* L4 destination port.    */
     55         uint16 ip_protocol;                 /* Ip protocol.            */
     56     } ip_hash_key;
     57 
     58     /* MIM Key Fields */
     59     struct {
     60         uint16 sglp;                        /* MIM: SGLP               */
     61         uint16 bvid;                        /* MIM: BVlan              */
     62         sal_mac_addr_t bmacsa;              /* MIM: Bmacsa             */
     63     } mim_hash_key;
     64 
     65     /* MPLS Key Fields */
     66     struct {
     67         uint32 mpls_label;                  /* MPLS: Mpls_label        */
     68         uint16 module_id;                   /* MPLS: Module_id         */
     69         uint16 port;                        /* MPLS: Port              */
     70         uint16 trunk_id;                    /* MPLS: Trunk id          */
     71     } mpls_hash_key;
     72 
     73     struct {
     74         uint32 entry[SOC_MAX_MEM_WORDS];
     75     } flex_hash_key;
     76 
     77 } soc_tnl_term_hash_key_t;
     78 
     79 
     80 /*
     81  * Tunnel termination hash table. 
     82  */
     83 typedef struct soc_tnl_term_hash_s {
     84     int         unit;
     85     int         entry_count;    /* Number entries in hash table */
     86     int         index_count;    /* Hash index max value + 1     */
     87     uint16      *table;         /* Hash table with 16 bit index */
     88     uint16      *link_table;    /* To handle collisions         */
     89 } soc_tnl_term_hash_t;
     90 
     91 /* Key bit width for CRC calculation. (words * 32) */
     92 #define SOC_TNL_TERM_HASH_BIT_WIDTH    ((sizeof(soc_tnl_term_hash_key_t)) << 3)
     93 
     94 /* 
     95  * Tunnel termination type tcam indexes. 
     96  */
     97 typedef struct soc_tnl_term_state_s {
     98     int start;  /* start index for this entry priority. */
     99     int end;    /* End index for this entry priority. */
    100     int prev;   /* Previous (Lo to Hi) priority with non zero entry count. */
    101     int next;   /* Next (Hi to Lo) priority with non zero entry count. */
    102     int vent;   /* Number of valid entries. */
    103     int fent;   /* Number of free entries. */
    104 } soc_tnl_term_state_t, *soc_tnl_term_state_p;
    105 
    106 extern int soc_tunnel_term_init(int unit);
    107 extern int soc_tunnel_term_deinit(int unit);
    108 extern int soc_tunnel_term_insert(int unit, soc_tunnel_term_t *entry, uint32 *index);
    109 extern int soc_tunnel_term_delete(int unit, soc_tunnel_term_t *key);
    110 extern int soc_tunnel_term_delete_all(int unit);
    111 extern int soc_tunnel_term_match(int unit, soc_tunnel_term_t *key,
    112                                    soc_tunnel_term_t *result, int *entry_index);
    113 extern void soc_tunnel_term_sw_dump(int unit);
    114 extern int  soc_tunnel_term_used_get(int unit);
    115 
    116 #if defined(BCM_WARM_BOOT_SUPPORT)
    117 extern int soc_tunnel_term_reinit(int unit);
    118 #endif /*  BCM_WARM_BOOT_SUPPORT */
    119 
    120 #endif	/* !_TUNNEL_TERMINATION_H_ */