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

cpu2cpu.h (4657B)


      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-2020 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        cpu2cpu.h
      8  * Purpose:     
      9  */
     10 
     11 #ifndef   _CPUTRANS_CPU2CPU_H_
     12 #define   _CPUTRANS_CPU2CPU_H_
     13 
     14 #include <sdk_config.h>
     15 #include <shared/idents.h>
     16 
     17 #include <bcm/types.h>
     18 #include <bcm/pkt.h>
     19 #include <bcm/tx.h>
     20 #include <bcm/rx.h>
     21 
     22 #include <appl/cpudb/cpudb.h>
     23 
     24 
     25 
     26 /* Default values for various parameters */
     27 #ifndef C2C_VLAN_DEFAULT
     28 #define C2C_VLAN_DEFAULT               1
     29 #endif
     30 #ifndef C2C_SNAP_MAC_DEFAULT
     31 #define C2C_SNAP_MAC_DEFAULT           SHARED_BRCM_NTSW_SNAP_MAC
     32 #endif
     33 #ifndef C2C_SNAP_TYPE_DEFAULT
     34 #define C2C_SNAP_TYPE_DEFAULT          SHARED_BRCM_NTSW_SNAP_TYPE
     35 #endif
     36 #define C2C_TRANS_TYPE_DEFAULT         SHARED_PKT_TYPE_C2C
     37 #ifndef C2C_TRANS_PTR_DEFAULT
     38 #define C2C_TRANS_PTR_DEFAULT          (&bcm_trans_ptr)
     39 #endif
     40 #ifndef C2C_SRC_MODID_DEFAULT
     41 #define C2C_SRC_MODID_DEFAULT          -1
     42 #endif
     43 
     44 /* Configuration flags:
     45  *
     46  *     DEST_MAC_CHECK_ENABLE
     47  *          Normally, when a packet is checked, the destination
     48  *          MAC address is ignored.  It can be checked against
     49  *          the c2c mac address by setting this flag in c2c_config_set.
     50  */
     51 #ifndef C2C_F_DEST_MAC_CHECK_ENABLE
     52 #define C2C_F_DEST_MAC_CHECK_ENABLE 0x1
     53 #endif
     54 
     55 typedef void (*c2c_cb_f)(uint8 *pkt, void *cookie);
     56 
     57 /****************************************************************
     58  *
     59  * C2C driver function type declarations
     60  *
     61  *     c2c_tx_f      Transmit a bcm_pkt_t pkt; same prototype as bcm_tx
     62  *     c2c_alloc_f   Allocate a packet buffer
     63  *     c2c_free_f    Free a packet buffer
     64  */
     65 
     66 typedef int (*c2c_tx_f)(int unit, bcm_pkt_t *pkt, void *cookie);
     67 typedef uint8 *(*c2c_alloc_f)(int len);
     68 typedef void (*c2c_free_f)(uint8 *);
     69 
     70 /****************************************************************
     71  *
     72  * Programming requirement:
     73  *     Must call c2c_config_set before calling any transmit
     74  *     function.  Pass in TX function (like bcm_tx), allocate
     75  *     and free functions for packet data.
     76  */
     77 
     78 extern int c2c_snap_set(bcm_mac_t new_mac, uint16 new_type,
     79                         uint16 new_trans_type);
     80 extern int c2c_snap_get(bcm_mac_t snap_mac, uint16 *new_type,
     81                         uint16 *trans_type);
     82 
     83 /* Two alternatives for sending:
     84  *     c2c_tx:  One shot set and tear down
     85  *
     86  *     c2c_pkt_create, [c2c_pkt_update], c2c_pkt_send, c2c_pkt_destroy:
     87  *          Allows the same packet to be sent multiple times before
     88  *          tear down.
     89  */
     90 
     91 extern int            c2c_tx         (cpudb_key_t dest_key,
     92                                       uint8 *pkt_buf,
     93                                       int len,
     94                                       int cos,
     95                                       int vlan,
     96                                       int seg_len,
     97                                       uint16 mplx_num,
     98                                       uint32 ct_flags,
     99                                       c2c_cb_f callback,
    100                                       void *cookie);
    101 
    102 extern bcm_pkt_t *   c2c_pkt_create  (cpudb_key_t dest_key,
    103                                       uint8 *pkt_buf,
    104                                       int len,
    105                                       int cos,
    106                                       int vlan,
    107                                       int seg_len,
    108                                       uint16 mplx_num,
    109                                       uint32 ct_flags,
    110                                       int *tot_segs,
    111                                       int *rvp);
    112 
    113 extern int           c2c_pkt_send    (bcm_pkt_t *pkt,
    114                                       c2c_cb_f callback,
    115                                       void *cookie);
    116 
    117 extern int           c2c_pkt_update  (bcm_pkt_t *pkt,
    118                                       cpudb_key_t dest_key);
    119 
    120 extern void          c2c_pkt_destroy (bcm_pkt_t *pkt);
    121 
    122 extern int           c2c_pkt_recognize(uint8 *pkt_data,
    123                                        cpudb_key_t *src_key,
    124                                        uint16 *mplx_num);
    125 
    126 extern int c2c_config_get(bcm_trans_ptr_t **trans_ptr, 
    127 			  bcm_mac_t local_mac, 
    128 			  uint32 *flags); 
    129 
    130 extern int c2c_config_set(bcm_trans_ptr_t *trans_ptr,
    131 			  bcm_mac_t local_mac,
    132 			  uint32 flags); 
    133 
    134 extern int c2c_cpu_add(const cpudb_entry_t *db_ent);
    135 extern int c2c_cpu_remove(const cpudb_key_t key);
    136 extern int c2c_cpu_clear(void);
    137 extern int c2c_cpu_update(cpudb_ref_t db_ref);
    138 extern int c2c_src_mod_set(int src_mod);
    139 extern int c2c_src_mod_get(int *src_mod);
    140 
    141 #endif /* _CPUTRANS_CPU2CPU_H_ */