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

next_hop.h (6996B)


      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:        next_hop.h
      8  * Purpose:     Header file for next hop transport
      9  */
     10 
     11 #ifndef   _CPUTRANS_NEXT_HOP_H_
     12 #define   _CPUTRANS_NEXT_HOP_H_
     13 
     14 #include <sdk_config.h>
     15 #include <bcm/rx.h>
     16 
     17 #include <appl/cputrans/nh_tx.h>
     18 #include <appl/cpudb/cpudb.h>
     19 
     20 #ifndef NEXT_HOP_MTU_DEFAULT
     21 #define NEXT_HOP_MTU_DEFAULT         2048
     22 #endif
     23 
     24 /* Max number of supported callbacks */
     25 #ifndef NEXT_HOP_CALLBACK_MAX
     26 #define NEXT_HOP_CALLBACK_MAX        10
     27 #endif
     28 
     29 #define NEXT_HOP_PKT_TYPE            SHARED_PKT_TYPE_NEXT_HOP
     30 
     31 /*
     32  * Keeping track of sequence numbers per CPU:
     33  *     SEQ_NUM_TRACK:  Number of sequence numbers to track per CPU
     34  *     SEQ_NUM_MAX:    Max sequence number to put in a packet
     35  *
     36  * These parameters are very important to the inner workings of
     37  * next hop.  The NO_TRACK is the number of sequence numbers recorded
     38  * per CPU.  If a copy of a packet is received, it is discarded b/c
     39  * its sequence number is in this list.  If the list is not long enough,
     40  * a packet could be incorrectly forwarded and sent up the stack.
     41  *
     42  * The trade off is the amount of space and time it requires to check
     43  * if an incoming packet has been seen before.
     44  *
     45  * The SEQ_NUM_MAX must be large enough so that rollover cannot result
     46  * in a new packet being mistaken for an old packet.
     47  */
     48 
     49 #ifndef NEXT_HOP_SEQ_NUM_TRACK
     50 #define NEXT_HOP_SEQ_NUM_TRACK                  16
     51 #endif
     52 #ifndef NEXT_HOP_SEQ_NUM_MAX
     53 #define NEXT_HOP_SEQ_NUM_MAX                    (8 * 1024)
     54 #endif
     55 
     56 #ifndef NEXT_HOP_RX_QUEUE_SIZE
     57 #define NEXT_HOP_RX_QUEUE_SIZE                  32
     58 #endif
     59 #ifndef NEXT_HOP_TX_QUEUE_SIZE
     60 #define NEXT_HOP_TX_QUEUE_SIZE                  32
     61 #endif
     62 
     63 #ifndef NEXT_HOP_RX_PRIORITY_DEFAULT
     64 #define NEXT_HOP_RX_PRIORITY_DEFAULT            105	/* bit more than atp */
     65 #endif
     66 #ifndef NEXT_HOP_THREAD_PRIORITY_DEFAULT
     67 #define NEXT_HOP_THREAD_PRIORITY_DEFAULT        100
     68 #endif
     69 #ifndef NEXT_HOP_TRANS_PTR_DEFAULT
     70 #define NEXT_HOP_TRANS_PTR_DEFAULT              (&bcm_trans_ptr)
     71 #endif
     72 
     73 /*
     74  * Typedef:
     75  *      next_hop_rx_callback_f
     76  * Purpose:
     77  *      Next hop broadcast application packet handler callback.
     78  * Parameters:
     79  *      src_key       - The source key of the originating CPU
     80  *      rx_unit       - Unit on which packet received
     81  *      rx_port       - Port on which packet received
     82  *      pkt_buf       - Packet buffer including all headers
     83  *      len           - Total length of pkt in bytes
     84  * Returns:
     85  *      BCM_RX_HANDLED       - Done with packet; no more processing
     86  *      BCM_RX_HANDLED_OWNED - Done with packet; do not free pkt buffer
     87  *      Otherwise, continue processing.
     88  * Notes:
     89  *      Use NEXT_HOP_PAYLOAD_OFFSET to index to start of data.
     90  *      src_key should be treated as const.
     91  */
     92 
     93 typedef bcm_rx_t (*next_hop_rx_callback_f)(cpudb_key_t src_key, int mplx_num,
     94                                            int rx_unit, int rx_port,
     95                                            uint8 *pkt_buf, int len,
     96                                            void *cookie);
     97 
     98 
     99 /*
    100  * Typedef:
    101  *      next_hop_tx_callback_f
    102  * Purpose:
    103  *      Next hop broadcast transmit function callback 
    104  * Parameters:
    105  *      return_code    - Success or failure code of transmit, BCM_E_XXX
    106  *      pkt_buf        - The buffer that was transmitted.
    107  *      cookie         - Cookie passed with transmit call.
    108  * Notes:
    109  *      Use for async transmits.
    110  *      For all transmits, provide NEXT_HOP_PAYLOAD_OFFSET bytes at
    111  *      the start of the packet for lower layers.
    112  */
    113 typedef void (*next_hop_tx_callback_f)(int return_code,
    114                                        uint8 *pkt_buf,
    115                                        void *cookie);
    116 
    117 extern int next_hop_start(const cpudb_base_t *local_base);
    118 extern int next_hop_update(const cpudb_base_t *local_base);
    119 extern int next_hop_running(void);
    120 extern int next_hop_config_set(bcm_trans_ptr_t *trans_ptr,
    121                                int thread_priority,
    122                                int rx_priority);
    123 extern int next_hop_config_get(bcm_trans_ptr_t **trans_ptr,
    124                                int *thread_priority,
    125                                int *rx_priority);
    126 
    127 extern int next_hop_stop(void);
    128 
    129 extern int next_hop_port_add(int unit, int port, int duplex);
    130 extern int next_hop_port_remove(int unit, int port);
    131 
    132 extern int next_hop_num_ports_get(void);
    133 extern int next_hop_port_get(int idx, int *unit, int *port, int *duplex);
    134 
    135 extern int next_hop_max_entries_get(void);
    136 extern const cpudb_key_t *next_hop_key_get(int idx);
    137 
    138 extern bcm_pkt_t * next_hop_pkt_create(uint8 *pkt_buf,
    139                                        int len,
    140                                        int cos,
    141                                        int vlan,
    142                                        int seg_len,
    143                                        uint32 ct_flags,
    144                                        int mplx_num,
    145                                        const cpudb_key_t nh_dest_key,
    146                                        int *tot_segs,
    147                                        int *rvp);
    148 
    149 extern int next_hop_pkt_update(bcm_pkt_t *pkt,
    150                                int mplx_num,
    151                                const cpudb_key_t nh_dest_key);
    152 
    153 extern int next_hop_pkt_send(bcm_pkt_t *pkt,
    154                              next_hop_tx_callback_f callback,
    155                              void *cookie);
    156 
    157 extern int next_hop_pkt_destroy(bcm_pkt_t *pkt);
    158 
    159 extern int next_hop_buffer_init(uint8 *hdr_buf,
    160                                 int mplx_num,
    161                                 const cpudb_key_t nh_dest_key);
    162 
    163 extern int next_hop_tx(uint8 *pkt_buf,
    164                        int len,
    165                        int cos,
    166                        int vlan,
    167                        int seg_len,
    168                        uint32 ct_flags,
    169                        int mplx_num,
    170                        const cpudb_key_t nh_dest_key,
    171                        next_hop_tx_callback_f callback,
    172                        void *cookie);
    173 
    174 extern int next_hop_register(next_hop_rx_callback_f callback, void *cookie,
    175                              int mplx_num);
    176 extern int next_hop_unregister(next_hop_rx_callback_f callback,
    177                                int mplx_num);
    178 
    179 extern int next_hop_key_invalidate(cpudb_key_t key);
    180 
    181 extern int next_hop_mtu_get(int *mtu);
    182 extern int next_hop_mtu_set(int mtu);
    183 
    184 extern int next_hop_lru_enable_get(void);
    185 extern void next_hop_lru_enable_set(int lru);
    186 
    187 
    188 extern int next_hop_cos_set(int cos);
    189 extern int next_hop_cos_get(int *cos);
    190 extern int next_hop_vlan_set(int vlan);
    191 extern int next_hop_vlan_get(int *vlan);
    192 
    193 extern int next_hop_queue_size_set(int rx_size, int tx_size);
    194 extern int next_hop_queue_size_get(int *rx_size, int *tx_size);
    195 
    196 #if defined(BROADCOM_DEBUG)
    197 void next_hop_dump(void);
    198 #endif  /* BROADCOM_DEBUG */
    199 
    200 #endif /* _CPUTRANS_NEXT_HOP_H_ */