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

rcpu.h (6980B)


      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  * This header file defines RCPU packet formats and soc layer API.
      8  */
      9 
     10 #ifndef _SOC_RCPU_H
     11 #define _SOC_RCPU_H
     12 
     13 #include <soc/types.h>
     14 #include <soc/macipadr.h>
     15 #include <soc/schanmsg.h>
     16 #include <sal/core/sync.h>
     17 
     18 #ifdef INCLUDE_RCPU
     19 
     20 #define DEFAULT_RCPU_DST_MAC  "00:00:11:22:33:00"
     21 #define DEFAULT_RCPU_SRC_MAC  "00:AA:BB:22:33:00"
     22 
     23 #define DEFAULT_RCPU_TPID          0x8100
     24 #define DEFAULT_RCPU_VLAN               1
     25 #define DEFAULT_RCPU_ETHER_TYPE    0x8874
     26 #define DEFAULT_RCPU_SIGNATURE     0x5600
     27 
     28 #define DEFAULT_RCPU_MASTER_UNIT        0 /* Default local unit used for in-band RCPU */
     29 #define DEFAULT_RCPU_ETH_UNIT           0 /* Default eth unit used for out-of-band RCPU */
     30 
     31 /* RCPU CFG flags encodings */
     32 typedef struct soc_rcpu_cfg_s {
     33     sal_mac_addr_t   dst_mac;    /* MAC address of the remote unit   */
     34     sal_mac_addr_t   src_mac;    /* MAC address of local CMIC/NIC    */
     35     uint32      ether_type;      /* Remote CMIC Ethernet Type        */
     36     uint32      signature;       /* Rremote CMIC signature           */
     37     uint16      vlan;            /* Vlan id                          */
     38     uint16      tpid;            /* TPID                             */
     39     soc_port_t  port;            /* Port used for RCPU communication */
     40 } soc_rcpu_cfg_t;
     41 
     42 /* RX packet callback function. */
     43 typedef int (*rcpu_rx_cb_f)(
     44     int unit, 
     45     uint8 *pkt,
     46     int len,
     47     void *cookie);
     48 
     49 /* RX packet register function. */
     50 typedef int (*rcpu_rx_register_f)(
     51     int unit, 
     52     rcpu_rx_cb_f rx,
     53     void *cookie);
     54 
     55 /* RX packet register function. */
     56 typedef int (*rcpu_rx_unregister_f)(
     57     int unit, 
     58     rcpu_rx_cb_f rx);
     59 
     60 /* TX packet callback function. */
     61 typedef int (*rcpu_tx_f)(
     62     int unit, 
     63     uint8 *pkt_buf,
     64     int len,
     65     void *cookie);
     66 
     67 /* Packet buffer allocation function. */
     68 typedef int (*rcpu_data_alloc_f)(
     69     int unit, 
     70     int size, 
     71     void **pkt_buf);
     72 
     73 /* Packet buffer deallocation function. */
     74 typedef int (*rcpu_data_free_f)(
     75     int unit, 
     76     void *pkt_buf);
     77 
     78 /* Structure of transport related function pointers. */
     79 typedef struct rcpu_trans_ptr_s {
     80     rcpu_rx_register_f   rcpu_tp_rx_register;
     81     rcpu_rx_unregister_f rcpu_tp_rx_unregister;
     82     rcpu_tx_f            rcpu_tp_tx;
     83     rcpu_data_alloc_f    rcpu_tp_data_alloc;
     84     rcpu_data_free_f     rcpu_tp_data_free;
     85     int tp_unit; /* device unit for in-band or ethernet unit for out-of-band */
     86     int ref_count;
     87 }rcpu_trans_ptr_t;
     88 
     89 /* Standard in-band transport pointer structure. */
     90 extern rcpu_trans_ptr_t rcpu_trans_ptr;
     91 #if defined(BCM_OOB_RCPU_SUPPORT)
     92 /* Standard out-of-band transport pointer structure. */
     93 extern rcpu_trans_ptr_t rcpu_oob_trans_ptr;
     94 #endif
     95 
     96 /* Operation encodings. */
     97 #define SOC_RCPU_OP_SCHAN_REQ       0x01
     98 #define SOC_RCPU_OP_SCHAN_REPLY     0x02
     99 #define SOC_RCPU_OP_CMIC_REQ        0x03
    100 #define SOC_RCPU_OP_CMIC_REPLY      0x04
    101 #define SOC_RCPU_OP_TOCPU_PKT       0x10
    102 #define SOC_RCPU_OP_FROMCPU_PKT     0x20
    103 #define SOC_RCPU_OP_INTR_PKT        0x30
    104 
    105 /* Flags encodings. */
    106 #define SOC_RCPU_FLAG_REPLY         0x01
    107 #define SOC_RCPU_FLAG_MINIPKT       0x02
    108 #define SOC_RCPU_FLAG_MODHDR        0x04
    109 #define SOC_RCPU_FLAG_FAIL          0x08
    110 #define SOC_RCPU_FLAG_BUSY          0x20
    111 #define SOC_RCPU_FLAG_TRUNCATED     0x40
    112 #define SOC_RCPU_FLAG_JUMBO         0x80
    113 
    114 /* CMIC packet header format (32 bytes) */
    115 typedef struct rcpu1_cmic_pkt_hdr_s {
    116     sal_mac_addr_t      dst_mac;    /* Destination MAC address  */
    117     sal_mac_addr_t      src_mac;    /* Source MAC address       */
    118     uint16              tpid;       /* vlan TPID                */
    119     uint16              vlan;       /* vlan tag                 */
    120     uint16              ethertype;  /* Ether type               */
    121     uint16              signature;  /* RCPU packet signature    */
    122     uint8               operation;  /* op-code                  */
    123     uint8               flags;      /* flags                    */
    124     uint16              transid;    /* transaction number       */
    125     uint16              datalen;    /* length of data (in bytes)*/
    126     uint16              replen;     /* expected data length     */
    127     uint32              reserved;   /* reserved must be 0       */
    128 } rcpu1_cmic_pkt_hdr_t;
    129 
    130 typedef struct rcpu_encap_info_s {
    131     uint8               cmic_hdr_size;/* Received CMIC header size */
    132     uint8               dcb_size;     /* Received DCB size         */
    133     uint8               operation;    /* op-code                   */
    134     uint8               flags;        /* flags                     */
    135     uint16              transid;      /* transaction number        */
    136     uint16              datalen;      /* length of data (in bytes) */
    137     uint16              replen;       /* expected data length      */
    138 } rcpu_encap_info_t;
    139 
    140 /* ToCPU packet handler */
    141 typedef int (*rcpu_tocpu_cb_f)(
    142     int unit, 
    143     uint8 *pkt,
    144     int len,
    145     rcpu_encap_info_t *info);
    146 
    147 typedef struct soc_rcpu_control_s {
    148     sal_mutex_t         lock;
    149     sal_sem_t           schan_reply;
    150     uint32              flags;
    151     uint8               reply_data[CMIC_SCHAN_WORDS_ALLOC*4];
    152     rcpu_tocpu_cb_f     tocpu_cb;
    153     uint16              transid;
    154     /* some stats */
    155     uint32              tx_pkt;
    156     uint32              tx_fail;
    157     uint32              rx_pkt;
    158 } soc_rcpu_control_t;
    159 
    160 /* RCPU interrupt packet data format */
    161 typedef struct soc_rcpu_intr_packet_s {
    162     uint32              cmc0_irq_stat;
    163     uint32              cmc0_rcpu_irq_mask;
    164     uint32              cmc1_irq_stat;
    165     uint32              cmc1_rcpu_irq_mask;
    166     uint32              cmc2_irq_stat;
    167     uint32              cmc2_rcpu_irq_mask;
    168     uint32              rcpu_irq0_stat;
    169     uint32              rcpu_irq0_mask;
    170     uint32              rcpu_irq1_stat;
    171     uint32              rcpu_irq1_mask;
    172     uint32              rcpu_irq2_stat;
    173     uint32              rcpu_irq2_mask;
    174     uint32              rcpu_irq3_stat;
    175     uint32              rcpu_irq3_mask;
    176     uint32              rcpu_irq4_stat;
    177     uint32              rcpu_irq4_mask;
    178     uint32              cmic_link_staus_0;
    179     uint32              cmic_link_staus_1;
    180     uint32              cmic_link_staus_2;
    181     uint32              cmic_link_staus_3;
    182 } soc_rcpu_intr_packet_t;
    183 
    184 int soc_rcpu_init(int unit);
    185 int soc_rcpu_deinit(int unit);
    186 int soc_rcpu_schan_op(int dev, schan_msg_t *msg, int dwc_write, int dwc_read);
    187 uint32 soc_rcpu_cmic_read(int unit, uint32 addr);
    188 int soc_rcpu_cmic_write(int unit, uint32 addr, uint32 data);
    189 
    190 int soc_rcpu_encap(int unit, uint8 *buf, rcpu_encap_info_t *info);
    191 int soc_rcpu_decap(uint8 *buf, int *runit, rcpu_encap_info_t *info);
    192 
    193 int soc_rcpu_tocpu_cb_register(int unit, rcpu_tocpu_cb_f f);
    194 int soc_rcpu_tocpu_cb_unregister(int unit);
    195 
    196 #endif /* defined(INCLUDE_RCPU) */
    197 
    198 #endif	/* _SOC_RCPU_H */