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

uc_msg.h (5076B)


      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:    uc_msg.h
      8  */
      9 
     10 #ifndef _SOC_UC_MSG_H
     11 #define _SOC_UC_MSG_H
     12 
     13 /* Define how the shared msg headers find certain items */
     14 #include <soc/shared/mos_msg_common.h>
     15 
     16 /* Macros to set and clear the S/W interrupt bits in the correct CMC */
     17 #define CMIC_CMC_SW_INTR_SET(unit, target)                              \
     18     soc_pci_write(unit,                                                 \
     19                   (target == CMICM_SW_INTR_HOST) ? CMIC_CMC0_SW_INTR_CONFIG_OFFSET : \
     20                   (target == CMICM_SW_INTR_UC0) ? CMIC_CMC1_SW_INTR_CONFIG_OFFSET : \
     21                   (target == CMICM_SW_INTR_UC1) ? CMIC_CMC2_SW_INTR_CONFIG_OFFSET : \
     22                   CMIC_CMC2_SW_INTR_CONFIG_OFFSET,                      \
     23                   0x4 | ((target) == CMICM_SW_INTR_RCPU?                \
     24                     CMICM_SW_INTR_RCPU : CMICM_SW_INTR_HOST))
     25 
     26 /* We only clear our own - but clear the right target */
     27 #define CMIC_CMC_SW_INTR_CLEAR(unit, target)                            \
     28     soc_pci_write(unit, CMIC_CMC0_SW_INTR_CONFIG_OFFSET, target)
     29 
     30 #ifdef BCM_CMICX_SUPPORT
     31 /* Macro to set the S/W interrupt bits as per correct target */
     32 #define CMICX_SW_INTR_SET(unit, target) do { \
     33     if (target == CMICM_SW_INTR_UC0) { \
     34         WRITE_ICFG_PCIE_SW_PROG_INTRr(unit, (1<<1)); \
     35     } else { \
     36         WRITE_ICFG_CMIC_RCPU_SW_PROG_INTRr(unit, (1<<2)); \
     37     } \
     38 } while (0)
     39 #endif
     40 
     41 #define CMIC_MSG_PBUF_SIZE      256
     42 
     43 /* seconds / nanoseconds time, corresponding to TAI/UTC/PTP/... time */
     44 typedef struct soc_cmic_uc_time_s {
     45     uint64 seconds;
     46     uint32 nanoseconds;
     47 } soc_cmic_uc_time_t;
     48 
     49 /* Timestamp data associated with a particular event type */
     50 typedef struct soc_cmic_uc_ts_data_s {
     51     uint64 hwts;              /* Most recent timestamp for event type      */
     52     uint64 prev_hwts;         /* Preceeding timestamp for event type       */
     53     uint64 hwts_ts1;          /* Corresponding TS1 timestamp (IPROC/CMICd) */
     54     soc_cmic_uc_time_t time;  /* Corresponding full time from firmware     */
     55 } soc_cmic_uc_ts_data_t;
     56 
     57 /* Callback to application code to indicate that messaging/uC is stopping */
     58 typedef enum soc_cmic_uc_shutdown_stage_e {
     59     SOC_CMIC_UC_SHUTDOWN_STARTING = 1, /* about to shut down */
     60     SOC_CMIC_UC_SHUTDOWN_HALTED,       /* uC core is halted  */
     61     SOC_CMIC_UC_SHUTDOWN_NOHALT        /* Apps should run without host */
     62 } soc_cmic_uc_shutdown_stage_t;
     63 
     64 typedef int (soc_cmic_uc_appl_cb_t)(int unit,
     65                                     int uC,
     66                                     soc_cmic_uc_shutdown_stage_t stage,
     67                                     void *user_data);
     68 
     69 /* Routines */
     70 extern void soc_cmic_sw_intr(int unit, uint32 rupt_num);
     71 extern void soc_cmic_uc_msg_init(int unit);
     72 extern int soc_cmic_uc_msg_start(int unit);
     73 extern int soc_cmic_uc_msg_stop(int unit);
     74 extern int soc_cmic_uc_msg_shutdown_halt(int unit);
     75 extern int soc_cmic_uc_msg_uc_shutdown_halt(int unit, int uC);
     76 extern int soc_cmic_uc_msg_apps_notify(int unit,
     77                soc_cmic_uc_shutdown_stage_t notification);
     78 extern int soc_cmic_uc_msg_uc_apps_notify(int unit,
     79                soc_cmic_uc_shutdown_stage_t notification, int uC);
     80 extern int soc_cmic_uc_msg_active_wait(int unit, uint32 host);
     81 extern void soc_cmic_uc_msg_thread(void *unit_vp);
     82 extern int soc_cmic_uc_msg_uc_start(int unit, int uC);
     83 extern int soc_cmic_uc_msg_uc_stop(int unit, int uC);
     84 extern int soc_cmic_uc_msg_send(int unit, int uC, mos_msg_data_t *msg,
     85                                 sal_usecs_t timeout);
     86 extern int soc_cmic_uc_msg_receive(int unit, int uC, uint8 mclass,
     87                                    mos_msg_data_t *msg, int timeout);
     88 extern int soc_cmic_uc_msg_receive_cancel(int unit, int uC, int msg_class);
     89 extern int soc_cmic_uc_msg_send_receive(int unit, int uC, mos_msg_data_t *send,
     90                                         mos_msg_data_t *reply,
     91                                         sal_usecs_t timeout);
     92 extern int soc_cmic_uc_appl_init(int unit, int uC, int msg_class,
     93                                  sal_usecs_t timeout, uint32 version_info,
     94                                  uint32 min_appl_version,
     95                                  soc_cmic_uc_appl_cb_t *shutdown_cb,
     96                                  void *cb_data);
     97 
     98 #if defined (INCLUDE_UC_ULINK)
     99 extern int soc_cmic_uc_pkd_link_notify(int unit);
    100 #endif
    101 
    102 #ifdef BCM_KATANA2_SUPPORT
    103 extern uint32 soc_cmic_bs_reg_cache(int unit, int bs_num);
    104 #endif
    105 
    106 extern int soc_cmic_uc_msg_timestamp_get(int unit,  int event_id,
    107                                          soc_cmic_uc_ts_data_t *ts_data);
    108 
    109 extern int soc_cmic_uc_msg_timestamp_enable(int unit,  int event_id);
    110 extern int soc_cmic_uc_msg_timestamp_disable(int unit,  int event_id);
    111 
    112 extern uint32 soc_cmic_timestamp_base(int unit);
    113 
    114 #ifdef BCM_CMICX_SUPPORT
    115 extern int soc_cmicx_uc_msg_init(int unit);
    116 #endif  /* BCM_CMICX_SUPPORT */
    117 
    118 #endif