bfcmap_drv.h (8732B)
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 #ifndef BFCMAP_DRV_H 8 #define BFCMAP_DRV_H 9 10 struct bfcmap_chip_info_s; 11 struct bfcmap_port_ctrl_s; 12 struct bfcmap_dev_ctrl_s; 13 struct bfcmap_api_table_s; 14 struct bfcmap_counter_info_s; 15 struct bfcmap_counter_cb_s; 16 17 typedef int (*msec_unit_init_f)(struct bfcmap_dev_ctrl_s*); 18 typedef int (*msec_unit_uninit_f)(struct bfcmap_dev_ctrl_s*); 19 typedef int (*msec_config_set)(struct bfcmap_port_ctrl_s*,bfcmap_port_config_t*); 20 typedef int (*msec_config_get)(struct bfcmap_port_ctrl_s*,bfcmap_port_config_t*); 21 /*typedef int (*msec_capability_get)(struct bfcmap_port_ctrl_s*,bfcmap_port_capability_t*);*/ 22 typedef int (*msec_port_init)(struct bfcmap_port_ctrl_s*,bfcmap_port_config_t*); 23 typedef int (*msec_port_uninit)(struct bfcmap_port_ctrl_s*); 24 typedef int (*msec_port_reset)(struct bfcmap_port_ctrl_s*); 25 typedef int (*msec_port_shutdown)(struct bfcmap_port_ctrl_s*); 26 typedef int (*msec_port_link_enable)(struct bfcmap_port_ctrl_s*); 27 typedef int (*msec_port_speed_set)(struct bfcmap_port_ctrl_s*, bfcmap_port_speed_t ); 28 typedef int (*msec_port_bounce)(struct bfcmap_port_ctrl_s*); 29 #if defined (BCM_WARM_BOOT_SUPPORT) /* */ 30 typedef int (*msec_vlan_recover)(struct bfcmap_port_ctrl_s*); 31 #endif /* BCM_WARM_BOOT_SUPPORT */ 32 33 34 35 typedef int (*msec_event_handler)(struct bfcmap_dev_ctrl_s*); 36 37 /* diagnostic functions */ 38 typedef int (*msec_cipher_op_encrypt)(struct bfcmap_port_ctrl_s*, 39 #if 0 40 bfcmap_crypto_aes128_gcm_t *key, 41 #endif 42 buint8_t *protected_data, int pdlen, 43 buint8_t *confidential_data, int cdlen, 44 buint8_t *out_data, int outlen); 45 46 typedef int (*msec_cipher_op_decrypt)(struct bfcmap_port_ctrl_s*, 47 #if 0 48 bfcmap_crypto_aes128_gcm_t *key, 49 #endif 50 buint8_t *protected_data, int pdlen, 51 buint8_t *confidential_data, int cdlen, 52 buint8_t *icv_data, int icvlen, 53 buint8_t *out_data, int outlen); 54 55 typedef int (*msec_diag_get)(struct bfcmap_port_ctrl_s*,bfcmap_diag_code_t*); 56 typedef int (*msec_linkfault_trigger_rc_get)(struct bfcmap_port_ctrl_s*,bfcmap_lf_tr_t*, bfcmap_lf_rc_t*); 57 58 typedef int (*msec_port_ability_advert_set)(struct bfcmap_port_ctrl_s*, bfcmap_port_ability_t*); 59 typedef int (*msec_port_ability_advert_get)(struct bfcmap_port_ctrl_s*, bfcmap_port_ability_t*); 60 typedef int (*msec_private_data_set)(struct bfcmap_port_ctrl_s*,buint8_t *, int); 61 typedef int (*msec_vlan_map_add)(struct bfcmap_port_ctrl_s*, bfcmap_vlan_vsan_map_t*); 62 typedef int (*msec_vlan_map_get)(struct bfcmap_port_ctrl_s*, bfcmap_vlan_vsan_map_t*); 63 typedef int (*msec_vlan_map_delete)(struct bfcmap_port_ctrl_s*, bfcmap_vlan_vsan_map_t*); 64 typedef int (*msec_stat_get)(struct bfcmap_port_ctrl_s*, bfcmap_stat_t, buint64_t*); 65 typedef int (*msec_stat_clear)(struct bfcmap_port_ctrl_s*); 66 typedef struct bfcmap_api_table_s { 67 /* Unit APIs */ 68 msec_unit_init_f unit_init; 69 msec_unit_uninit_f unit_uninit; 70 71 /* Port based APIs */ 72 msec_config_set config_set; 73 msec_config_get config_get; 74 /*msec_capability_get capability_get;*/ 75 msec_port_init port_init; 76 msec_port_uninit port_uninit; 77 msec_port_reset port_reset; 78 msec_port_shutdown port_shutdown; 79 msec_port_link_enable port_link_enable; 80 msec_port_speed_set port_speed_set; 81 msec_port_bounce port_bounce; 82 83 msec_event_handler event_handler; 84 msec_diag_get diag_get; 85 msec_linkfault_trigger_rc_get linkfault_trigger_rc_get; 86 #if defined (BCM_WARM_BOOT_SUPPORT) /* */ 87 msec_vlan_recover vlan_recover; 88 #endif /* BCM_WARM_BOOT_SUPPORT */ 89 /* diagnostic functions */ 90 msec_cipher_op_encrypt cipher_op_encrypt; 91 msec_cipher_op_decrypt cipher_op_decrypt; 92 msec_port_ability_advert_set port_ability_advert_set; 93 msec_port_ability_advert_get port_ability_advert_get; 94 msec_private_data_set private_data_set; 95 msec_vlan_map_add vlan_map_add; 96 msec_vlan_map_get vlan_map_get; 97 msec_vlan_map_delete vlan_map_delete; 98 msec_stat_get stat_get; 99 msec_stat_clear stat_clear; 100 } bfcmap_drv_t; 101 102 #define BFCMAP_DRV_FN(_mpc,_mf) (_mpc)->api->_mf 103 104 #define _BFCMAP_DRV_CALL(_mpc, _mf, _ma) \ 105 (_mpc == NULL ? BFCMAP_E_PARAM : \ 106 (BFCMAP_DRV_FN(_mpc,_mf) == NULL ? \ 107 BFCMAP_E_UNAVAIL : BFCMAP_DRV_FN(_mpc,_mf) _ma)) 108 109 #define _BFCMAP_DRV_CALL_1ARG(_mpc, _mf, _ma, _arg) \ 110 (_mpc == NULL ? BFCMAP_E_PARAM : \ 111 (BFCMAP_DRV_FN(_mpc,_mf) == NULL ? \ 112 BFCMAP_E_UNAVAIL : BFCMAP_DRV_FN(_mpc,_mf)(_ma, _arg))) 113 114 #define _BFCMAP_DRV_CALL_2ARG(_mpc, _mf, _ma, _arg1, _arg2) \ 115 (_mpc == NULL ? BFCMAP_E_PARAM : \ 116 (BFCMAP_DRV_FN(_mpc,_mf) == NULL ? \ 117 BFCMAP_E_UNAVAIL : BFCMAP_DRV_FN(_mpc,_mf)(_ma, _arg1, _arg2))) 118 119 #define BFCMAP_PORT_CONFIG_SET(_mpc, _ma) \ 120 _BFCMAP_DRV_CALL_1ARG((_mpc), config_set, (_mpc), (_ma)) 121 122 #define BFCMAP_PORT_CONFIG_GET(_mpc, _ma) \ 123 _BFCMAP_DRV_CALL_1ARG((_mpc), config_get, (_mpc), (_ma)) 124 125 #define BFCMAP_PORT_CAPABILITY_GET(_mpc, _ma) \ 126 _BFCMAP_DRV_CALL((_mpc), capability_get, ((_mpc), (_ma))) 127 128 #define BFCMAP_PORT_INIT(_mpc, _ma) \ 129 _BFCMAP_DRV_CALL((_mpc), port_init, ((_mpc), (_ma))) 130 131 #define BFCMAP_PORT_UNINIT(_mpc) \ 132 _BFCMAP_DRV_CALL((_mpc), port_uninit, ((_mpc))) 133 134 #define BFCMAP_PORT_RESET(_mpc) \ 135 _BFCMAP_DRV_CALL((_mpc), port_reset, ((_mpc))) 136 137 #define BFCMAP_PORT_SHUTDOWN(_mpc) \ 138 _BFCMAP_DRV_CALL((_mpc), port_shutdown, ((_mpc))) 139 140 #define BFCMAP_PORT_LINK_ENABLE(_mpc) \ 141 _BFCMAP_DRV_CALL((_mpc), port_link_enable, ((_mpc))) 142 143 #define BFCMAP_PORT_BOUNCE(_mpc) \ 144 _BFCMAP_DRV_CALL((_mpc), port_bounce, ((_mpc))) 145 146 #define BFCMAP_PORT_SPEED_SET(_mpc, _speed) \ 147 _BFCMAP_DRV_CALL_1ARG((_mpc), port_speed_set, ((_mpc)), (_speed)) 148 149 #define BFCMAP_DEVICE_INIT(_mdc) \ 150 _BFCMAP_DRV_CALL((_mdc)->ports, unit_init, ((_mdc))) 151 152 #define BFCMAP_DEVICE_UNINIT(_mdc) \ 153 _BFCMAP_DRV_CALL((_mdc)->ports, unit_uninit, ((_mdc))) 154 155 #define BFCMAP_PORT_GET_CFG(_mpc, _ma) \ 156 _BFCMAP_DRV_CALL((_mpc), get_cfg, ((_mpc), (_ma))) 157 158 #define BFCMAP_DEVICE_EVENT_HANDLER(_mdc) \ 159 _BFCMAP_DRV_CALL((_mdc)->ports, event_handler, ((_mdc))) 160 161 #define BFCMAP_PORT_LINKFAULT_TRIGGER_RC_GET(_mpc, _ma1, _ma2) \ 162 _BFCMAP_DRV_CALL_2ARG((_mpc), linkfault_trigger_rc_get, (_mpc), (_ma1), (_ma2)) 163 164 #if defined (BCM_WARM_BOOT_SUPPORT) /* */ 165 #define BFCMAP_VLAN_RECOVER(_mpc) \ 166 _BFCMAP_DRV_CALL((_mpc), vlan_recover, ((_mpc))) 167 #endif /* BCM_WARM_BOOT_SUPPORT */ 168 169 170 #define BFCMAP_PORT_DIAG_GET(_mpc, _ma) \ 171 _BFCMAP_DRV_CALL_1ARG((_mpc), diag_get, (_mpc), (_ma)) 172 173 #define BFCMAP_PORT_DIAG_CIPHER_OP_ENCRYPT(_mpc,k,ppd,pdl,pcd,cdl,pout,pol) \ 174 _BFCMAP_DRV_CALL((_mpc), cipher_op_encrypt, \ 175 ((_mpc), (k), (ppd), (pdl), (pcd), (cdl), (pout), (pol))) 176 177 #define BFCMAP_PORT_DIAG_CIPHER_OP_DECRYPT(_mpc,k,ppd,pdl,pcd,cdl,picv,icvl,pout,pol) \ 178 _BFCMAP_DRV_CALL((_mpc), cipher_op_decrypt, \ 179 ((_mpc), (k), (ppd), (pdl), (pcd), (cdl), (picv), (icvl), \ 180 (pout), (pol))) 181 182 #define BFCMAP_PORT_ABILITY_ADVERT_SET(_mpc, _ma) \ 183 _BFCMAP_DRV_CALL_1ARG((_mpc), port_ability_advert_set, (_mpc), (_ma)) 184 185 #define BFCMAP_PORT_ABILITY_ADVERT_GET(_mpc, _ma) \ 186 _BFCMAP_DRV_CALL_1ARG((_mpc), port_ability_advert_get, (_mpc), (_ma)) 187 188 #define BFCMAP_PORT_PRIVATE_DATA_SET(_mpc, _ma1, _ma2) \ 189 _BFCMAP_DRV_CALL_2ARG((_mpc), private_data_set, (_mpc), (_ma1), (_ma2)) 190 191 #define BFCMAP_VLAN_MAP_ADD(_mpc, _ma) \ 192 _BFCMAP_DRV_CALL_1ARG((_mpc), vlan_map_add, (_mpc), (_ma)) 193 194 #define BFCMAP_VLAN_MAP_GET(_mpc, _ma) \ 195 _BFCMAP_DRV_CALL_1ARG((_mpc), vlan_map_get, (_mpc), (_ma)) 196 197 #define BFCMAP_VLAN_MAP_DELETE(_mpc, _ma) \ 198 _BFCMAP_DRV_CALL_1ARG((_mpc), vlan_map_delete, (_mpc), (_ma)) 199 200 #define BFCMAP_STAT_GET(_mpc, _ma1, _ma2) \ 201 _BFCMAP_DRV_CALL_2ARG((_mpc), stat_get, (_mpc), (_ma1), (_ma2)) 202 203 #define BFCMAP_STAT_CLEAR(_mpc) \ 204 _BFCMAP_DRV_CALL((_mpc), stat_clear, ((_mpc))) 205 #endif /* BFCMAP_DRV_H */ 206