mbox.h (3206B)
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 * Shared Memory Mailbox infrastruction - mbox communications & debug logging 8 */ 9 10 #ifndef _BCM_COMMON_MBOX_H_ 11 #define _BCM_COMMON_MBOX_H_ 12 13 #include <sal/types.h> 14 #include <sal/core/time.h> 15 #include <sal/core/sync.h> 16 17 #include "Bs_feature.h" 18 19 #define _BCM_MBOX_MAX_BUFFERS (16) 20 #define _BCM_MBOX_MAX_LOG (1024) 21 22 #define _BCM_MBOX_RESPONSE_TIMEOUT_US (10000000) /* 1 sec */ 23 24 typedef enum _bcm_mbox_transport_type_e { 25 _BCM_MBOX_MESSAGE, 26 _BCM_MBOX_TUNNEL_TO, 27 _BCM_MBOX_TUNNEL_OUT 28 } _bcm_mbox_transport_type_t; 29 30 typedef enum _bcm_mbox_mbox_status_e { 31 _BCM_MBOX_MS_EMPTY, 32 _BCM_MBOX_MS_CMD, 33 _BCM_MBOX_MS_TUNNEL_TO, 34 _BCM_MBOX_MS_TUNNEL_OUT, 35 _BCM_MBOX_MS_RESP, 36 _BCM_MBOX_MS_EVENT, 37 _BCM_MBOX_MS_TUNNEL_IN, 38 _BCM_MBOX_MS_PENDING, 39 _BCM_MBOX_MS_ERR 40 } _bcm_mbox_mailbox_status_t; 41 42 43 typedef struct _bcm_bs_internal_stack_mbox_s { 44 volatile uint32 node_num; /* clock number that the message is addressed to/from */ 45 volatile uint32 data_len; 46 volatile uint8 data[1536]; 47 } _bcm_bs_internal_stack_mbox_t; 48 49 typedef struct _bcm_bs_internal_stack_mboxes_s { 50 volatile uint32 num_buffers; /* == BCM_MBOX_MAX_BUFFERS */ 51 volatile uint32 status[_BCM_MBOX_MAX_BUFFERS]; /* MBOX_STATUS_x value */ 52 volatile _bcm_bs_internal_stack_mbox_t mbox[_BCM_MBOX_MAX_BUFFERS]; /* contents of mbox */ 53 } _bcm_bs_internal_stack_mboxes_t; 54 55 typedef struct _bcm_bs_internal_stack_log_s { 56 volatile uint32 size; /* allocated size of buf (below) */ 57 volatile uint32 head; /* host-read, updated by CMICm */ 58 uint32 tail; /* host-read/write. not updated by CMICm */ 59 volatile uint8 buf[4]; /* '4' is placeholder. Actual size is 'size' */ 60 } _bcm_bs_internal_stack_log_t; 61 62 typedef struct _bcm_bs_internal_stack_state_s { 63 /* network-byte-ordered pointers to the shared structures */ 64 volatile uint32 mbox_ptr; 65 volatile uint32 log_ptr; 66 67 _bcm_bs_internal_stack_mboxes_t * mboxes; 68 _bcm_bs_internal_stack_log_t * log; 69 70 /* Elements after this point are not accessed by firmware */ 71 int core_num; 72 int is_running; 73 74 sal_mutex_t status_access_lock; /* must be held to flush or invalidate status array */ 75 sal_sem_t response_ready; 76 77 uint8 *response_data; 78 uint32 response_len; 79 } _bcm_bs_internal_stack_state_t; 80 81 typedef struct _bcm_bs_internal_comm_info_s { 82 _bcm_bs_internal_stack_state_t *unit_state; 83 84 sal_sem_t comm_available; 85 } _bcm_bs_internal_comm_info_t; 86 87 88 89 int _bcm_mbox_bs_wb_prep(int unit); 90 int _bcm_mbox_comm_init(int unit, int appl_type); 91 92 int _bcm_mbox_txrx(int unit, uint32 node_num, _bcm_mbox_transport_type_t transport, 93 uint8 *out_data, int out_len, uint8 *in_data, int *in_len); 94 95 int _bcm_mbox_debug_flag_set(uint32 flags); 96 int _bcm_mbox_debug_flag_get(uint32 *flags); 97 98 99 #endif /* _BCM_COMMON_MBOX_H_ */