mmi_cmn.h (4493B)
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 8 #ifndef BLMI_MMI_CMN_H 9 #define BLMI_MMI_CMN_H 10 11 #include <blmi_io.h> 12 #undef STATIC 13 #define STATIC static 14 15 /******************************************************* 16 * Trace callback 17 */ 18 typedef void (*_mmi_trace_callback_t)( 19 blmi_dev_addr_t dev_addr, 20 blmi_io_op_t op, 21 buint32_t io_addr, 22 buint32_t *data, 23 int word_sz, 24 int num_entry); 25 26 27 /******************************************************* 28 * LMI control structure 29 */ 30 typedef struct _mmi_dev_info_s { 31 blmi_dev_addr_t addr; 32 buser_sal_lock_t lock; 33 int used; 34 int fifo_size; 35 int is_cl45; 36 int cl45_dev; 37 buint32_t cap_flags; 38 } _mmi_dev_info_t; 39 40 /******************************************************* 41 * Pre-process LMI callback 42 */ 43 typedef int (*_mmi_pre_cb_t)( 44 _mmi_dev_info_t *dev_info, 45 int dev_port, 46 blmi_io_op_t op, 47 buint32_t *io_addr, 48 buint32_t *data, 49 int word_sz, 50 int num_entry); 51 52 /******************************************************* 53 * Post-process LMI callback 54 */ 55 typedef int (*_mmi_post_cb_t)( 56 _mmi_dev_info_t *dev_info, 57 int dev_port, 58 blmi_io_op_t op, 59 buint32_t *io_addr, 60 buint32_t *data, 61 int word_sz, 62 int num_entry); 63 64 65 extern blmi_dev_mmi_mdio_rd_f _blmi_mmi_rd_f; 66 extern blmi_dev_mmi_mdio_wr_f _blmi_mmi_wr_f; 67 68 _mmi_dev_info_t* 69 _blmi_mmi_create_device(blmi_dev_addr_t dev_addr, int cl45); 70 71 _mmi_dev_info_t * 72 _blmi_mmi_cmn_get_device_info(blmi_dev_addr_t dev_addr); 73 74 75 /* 76 * The following flags define the capability of the MMI 77 * core. 78 */ 79 /* Move register/table entries within the device */ 80 #define BLMI_MMI_CAP_DMA_WITHIN_DEVICE 0x01 81 /* DMA to/from host to device table/registers */ 82 #define BLMI_MMI_CAP_DMA_TO_FROM_HOST 0x02 83 /* Write the same entry to incremental addresses */ 84 #define BLMI_MMI_CAP_WRITE_MULTIPLE 0x04 85 86 87 /* Trace functions */ 88 extern _mmi_trace_callback_t _blmi_trace_cb; 89 extern unsigned int _blmi_trace_flags; 90 #define BLMI_TRACE_REG 0x01 91 #define BLMI_TRACE_TBL 0x02 92 int 93 _blmi_register_trace(unsigned int flags, _mmi_trace_callback_t cb); 94 95 int 96 _blmi_unregister_trace(unsigned int flags); 97 98 99 #define BLMI_TRACE_CALLBACK(dev_info,op,io_addr,data,word_sz,num_entry)\ 100 if (_blmi_trace_flags) { \ 101 switch (op) { \ 102 case BLMI_IO_REG_RD: \ 103 case BLMI_IO_REG_WR: \ 104 if (_blmi_trace_flags & BLMI_TRACE_REG) { \ 105 _blmi_trace_cb( \ 106 (dev_info)->addr, \ 107 op, \ 108 io_addr, \ 109 data, \ 110 word_sz, \ 111 num_entry); \ 112 } \ 113 break; \ 114 case BLMI_IO_TBL_RD: \ 115 case BLMI_IO_TBL_WR: \ 116 if (_blmi_trace_flags & BLMI_TRACE_TBL) { \ 117 _blmi_trace_cb( \ 118 (dev_info)->addr, \ 119 op, \ 120 io_addr, \ 121 data, \ 122 word_sz, \ 123 num_entry); \ 124 } \ 125 break; \ 126 } \ 127 } 128 129 130 #endif /* BLMI_MMI_CMN_H */ 131