1 /* 2 * Header file describing the internal (inter-module) DHD interfaces. 3 * 4 * Provides type definitions and function prototypes used to link the 5 * DHD OS, bus, and protocol modules. 6 * 7 * Copyright (C) 2020, Broadcom. 8 * 9 * Unless you and Broadcom execute a separate written software license 10 * agreement governing use of this software, this software is licensed to you 11 * under the terms of the GNU General Public License version 2 (the "GPL"), 12 * available at http://www.broadcom.com/licenses/GPLv2.php, with the 13 * following added to such license: 14 * 15 * As a special exception, the copyright holders of this software give you 16 * permission to link this software with independent modules, and to copy and 17 * distribute the resulting executable under terms of your choice, provided that 18 * you also meet, for each linked independent module, the terms and conditions of 19 * the license of that module. An independent module is a module which is not 20 * derived from this software. The special exception does not apply to any 21 * modifications of the software. 22 * 23 * 24 * <<Broadcom-WL-IPTag/Open:>> 25 * 26 * $Id$ 27 */ 28 29 #ifndef _dhd_proto_h_ 30 #define _dhd_proto_h_ 31 32 #include <dhdioctl.h> 33 #include <wlioctl.h> 34 #ifdef BCMPCIE 35 #include <dhd_flowring.h> 36 #endif 37 38 #ifdef BCMINTERNAL 39 #ifdef DHD_FWTRACE 40 #include <bcm_fwtrace.h> 41 #endif /* DHD_FWTRACE */ 42 #endif /* BCMINTERNAL */ 43 44 #define DEFAULT_IOCTL_RESP_TIMEOUT (5 * 1000) /* 5 seconds */ 45 #ifndef IOCTL_RESP_TIMEOUT 46 #if defined(BCMQT_HW) 47 #define IOCTL_RESP_TIMEOUT (600 * 1000) /* 600 sec in real time */ 48 #elif defined(BCMFPGA_HW) 49 #define IOCTL_RESP_TIMEOUT (60 * 1000) /* 60 sec in real time */ 50 #else 51 /* In milli second default value for Production FW */ 52 #define IOCTL_RESP_TIMEOUT DEFAULT_IOCTL_RESP_TIMEOUT 53 #endif /* BCMQT */ 54 #endif /* IOCTL_RESP_TIMEOUT */ 55 56 #if defined(BCMQT_HW) 57 #define IOCTL_DMAXFER_TIMEOUT (260 * 1000) /* 260 seconds second */ 58 #elif defined(BCMFPGA_HW) 59 #define IOCTL_DMAXFER_TIMEOUT (120 * 1000) /* 120 seconds */ 60 #else 61 /* In milli second default value for Production FW */ 62 #define IOCTL_DMAXFER_TIMEOUT (15 * 1000) /* 15 seconds for Production FW */ 63 #endif /* BCMQT */ 64 65 #ifndef MFG_IOCTL_RESP_TIMEOUT 66 #define MFG_IOCTL_RESP_TIMEOUT 20000 /* In milli second default value for MFG FW */ 67 #endif /* MFG_IOCTL_RESP_TIMEOUT */ 68 69 #define DEFAULT_D3_ACK_RESP_TIMEOUT 2000 70 #ifndef D3_ACK_RESP_TIMEOUT 71 #define D3_ACK_RESP_TIMEOUT DEFAULT_D3_ACK_RESP_TIMEOUT 72 #endif /* D3_ACK_RESP_TIMEOUT */ 73 74 #define DEFAULT_DHD_BUS_BUSY_TIMEOUT (IOCTL_RESP_TIMEOUT + 1000) 75 #ifndef DHD_BUS_BUSY_TIMEOUT 76 #define DHD_BUS_BUSY_TIMEOUT DEFAULT_DHD_BUS_BUSY_TIMEOUT 77 #endif /* DEFAULT_DHD_BUS_BUSY_TIMEOUT */ 78 79 #define DS_EXIT_TIMEOUT 1000 /* In ms */ 80 #define DS_ENTER_TIMEOUT 1000 /* In ms */ 81 82 #define IOCTL_DISABLE_TIMEOUT 0 83 84 /* 85 * Exported from the dhd protocol module (dhd_cdc, dhd_rndis) 86 */ 87 88 /* Linkage, sets prot link and updates hdrlen in pub */ 89 extern int dhd_prot_attach(dhd_pub_t *dhdp); 90 91 /* Initilizes the index block for dma'ing indices */ 92 extern int dhd_prot_dma_indx_init(dhd_pub_t *dhdp, uint32 rw_index_sz, 93 uint8 type, uint32 length); 94 #ifdef DHD_DMA_INDICES_SEQNUM 95 extern int dhd_prot_dma_indx_copybuf_init(dhd_pub_t *dhd, uint32 buf_sz, 96 uint8 type); 97 extern uint32 dhd_prot_read_seqnum(dhd_pub_t *dhd, bool host); 98 extern void dhd_prot_write_host_seqnum(dhd_pub_t *dhd, uint32 seq_num); 99 extern void dhd_prot_save_dmaidx(dhd_pub_t *dhd); 100 #endif /* DHD_DMA_INDICES_SEQNUM */ 101 /* Unlink, frees allocated protocol memory (including dhd_prot) */ 102 extern void dhd_prot_detach(dhd_pub_t *dhdp); 103 104 /* Initialize protocol: sync w/dongle state. 105 * Sets dongle media info (iswl, drv_version, mac address). 106 */ 107 extern int dhd_sync_with_dongle(dhd_pub_t *dhdp); 108 109 /* Protocol initialization needed for IOCTL/IOVAR path */ 110 extern int dhd_prot_init(dhd_pub_t *dhd); 111 112 /* Stop protocol: sync w/dongle state. */ 113 extern void dhd_prot_stop(dhd_pub_t *dhdp); 114 115 /* Add any protocol-specific data header. 116 * Caller must reserve prot_hdrlen prepend space. 117 */ 118 extern void dhd_prot_hdrpush(dhd_pub_t *, int ifidx, void *txp); 119 extern uint dhd_prot_hdrlen(dhd_pub_t *, void *txp); 120 121 /* Remove any protocol-specific data header. */ 122 extern int dhd_prot_hdrpull(dhd_pub_t *, int *ifidx, void *rxp, uchar *buf, uint *len); 123 124 #ifdef DHD_LOSSLESS_ROAMING 125 extern int dhd_update_sdio_data_prio_map(dhd_pub_t *dhdp); 126 #endif // DHD_LOSSLESS_ROAMING 127 128 /* Use protocol to issue ioctl to dongle */ 129 extern int dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t * ioc, void * buf, int len); 130 131 /* Handles a protocol control response asynchronously */ 132 extern int dhd_prot_ctl_complete(dhd_pub_t *dhd); 133 134 /* Check for and handle local prot-specific iovar commands */ 135 extern int dhd_prot_iovar_op(dhd_pub_t *dhdp, const char *name, 136 void *params, int plen, void *arg, int len, bool set); 137 138 /* Add prot dump output to a buffer */ 139 extern void dhd_prot_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf); 140 141 /* Dump extended trap data */ 142 extern int dhd_prot_dump_extended_trap(dhd_pub_t *dhdp, struct bcmstrbuf *b, bool raw); 143 144 /* Update local copy of dongle statistics */ 145 extern void dhd_prot_dstats(dhd_pub_t *dhdp); 146 147 extern int dhd_ioctl(dhd_pub_t * dhd_pub, dhd_ioctl_t *ioc, void * buf, uint buflen); 148 149 extern int dhd_preinit_ioctls(dhd_pub_t *dhd); 150 151 extern int dhd_process_pkt_reorder_info(dhd_pub_t *dhd, uchar *reorder_info_buf, 152 uint reorder_info_len, void **pkt, uint32 *free_buf_count); 153 154 #ifdef BCMPCIE 155 extern bool dhd_prot_process_msgbuf_txcpl(dhd_pub_t *dhd, uint bound, int ringtype); 156 extern bool dhd_prot_process_msgbuf_rxcpl(dhd_pub_t *dhd, uint bound, int ringtype); 157 extern bool dhd_prot_process_msgbuf_infocpl(dhd_pub_t *dhd, uint bound); 158 #ifdef BTLOG 159 extern bool dhd_prot_process_msgbuf_btlogcpl(dhd_pub_t *dhd, uint bound); 160 #endif /* BTLOG */ 161 extern int dhd_prot_process_ctrlbuf(dhd_pub_t * dhd); 162 extern int dhd_prot_process_trapbuf(dhd_pub_t * dhd); 163 extern bool dhd_prot_dtohsplit(dhd_pub_t * dhd); 164 extern int dhd_post_dummy_msg(dhd_pub_t *dhd); 165 extern int dhdmsgbuf_lpbk_req(dhd_pub_t *dhd, uint len); 166 extern void dhd_prot_rx_dataoffset(dhd_pub_t *dhd, uint32 offset); 167 extern int dhd_prot_txdata(dhd_pub_t *dhd, void *p, uint8 ifidx); 168 extern void dhd_prot_schedule_aggregate_h2d_db(dhd_pub_t *dhd, uint16 flow_id); 169 extern int dhdmsgbuf_dmaxfer_req(dhd_pub_t *dhd, 170 uint len, uint srcdelay, uint destdelay, uint d11_lpbk, uint core_num, 171 uint32 mem_addr); 172 extern int dhdmsgbuf_dmaxfer_status(dhd_pub_t *dhd, dma_xfer_info_t *result); 173 174 extern void dhd_dma_buf_init(dhd_pub_t *dhd, void *dma_buf, 175 void *va, uint32 len, dmaaddr_t pa, void *dmah, void *secdma); 176 extern void dhd_prot_flowrings_pool_release(dhd_pub_t *dhd, 177 uint16 flowid, void *msgbuf_ring); 178 extern int dhd_prot_flow_ring_create(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node); 179 extern int dhd_post_tx_ring_item(dhd_pub_t *dhd, void *PKTBUF, uint8 ifindex); 180 extern int dhd_prot_flow_ring_delete(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node); 181 extern int dhd_prot_flow_ring_flush(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node); 182 extern int dhd_prot_ringupd_dump(dhd_pub_t *dhd, struct bcmstrbuf *b); 183 extern uint32 dhd_prot_metadata_dbg_set(dhd_pub_t *dhd, bool val); 184 extern uint32 dhd_prot_metadata_dbg_get(dhd_pub_t *dhd); 185 extern uint32 dhd_prot_metadatalen_set(dhd_pub_t *dhd, uint32 val, bool rx); 186 extern uint32 dhd_prot_metadatalen_get(dhd_pub_t *dhd, bool rx); 187 extern void dhd_prot_print_flow_ring(dhd_pub_t *dhd, void *msgbuf_flow_info, bool h2d, 188 struct bcmstrbuf *strbuf, const char * fmt); 189 extern void dhd_prot_print_info(dhd_pub_t *dhd, struct bcmstrbuf *strbuf); 190 extern void dhd_prot_update_txflowring(dhd_pub_t *dhdp, uint16 flow_id, void *msgring_info); 191 extern void dhd_prot_txdata_write_flush(dhd_pub_t *dhd, uint16 flow_id); 192 extern uint32 dhd_prot_txp_threshold(dhd_pub_t *dhd, bool set, uint32 val); 193 extern void dhd_prot_reset(dhd_pub_t *dhd); 194 extern uint16 dhd_get_max_flow_rings(dhd_pub_t *dhd); 195 196 #ifdef IDLE_TX_FLOW_MGMT 197 extern int dhd_prot_flow_ring_batch_suspend_request(dhd_pub_t *dhd, uint16 *ringid, uint16 count); 198 extern int dhd_prot_flow_ring_resume(dhd_pub_t *dhd, flow_ring_node_t *flow_ring_node); 199 #endif /* IDLE_TX_FLOW_MGMT */ 200 extern int dhd_prot_init_info_rings(dhd_pub_t *dhd); 201 #ifdef BTLOG 202 extern int dhd_prot_init_btlog_rings(dhd_pub_t *dhd); 203 #endif /* BTLOG */ 204 #ifdef DHD_HP2P 205 extern int dhd_prot_init_hp2p_rings(dhd_pub_t *dhd); 206 #endif /* DHD_HP2P */ 207 extern int dhd_prot_check_tx_resource(dhd_pub_t *dhd); 208 #endif /* BCMPCIE */ 209 210 #ifdef DHD_LB 211 extern void dhd_lb_tx_compl_handler(unsigned long data); 212 extern void dhd_lb_rx_compl_handler(unsigned long data); 213 extern void dhd_lb_rx_process_handler(unsigned long data); 214 #endif /* DHD_LB */ 215 extern int dhd_prot_h2d_mbdata_send_ctrlmsg(dhd_pub_t *dhd, uint32 mb_data); 216 217 #ifdef BCMPCIE 218 extern int dhd_prot_send_host_timestamp(dhd_pub_t *dhdp, uchar *tlv, uint16 tlv_len, 219 uint16 seq, uint16 xt_id); 220 extern bool dhd_prot_data_path_tx_timestamp_logging(dhd_pub_t *dhd, bool enable, bool set); 221 extern bool dhd_prot_data_path_rx_timestamp_logging(dhd_pub_t *dhd, bool enable, bool set); 222 extern bool dhd_prot_pkt_noretry(dhd_pub_t *dhd, bool enable, bool set); 223 extern bool dhd_prot_pkt_noaggr(dhd_pub_t *dhd, bool enable, bool set); 224 extern bool dhd_prot_pkt_fixed_rate(dhd_pub_t *dhd, bool enable, bool set); 225 #else /* BCMPCIE */ 226 #define dhd_prot_send_host_timestamp(a, b, c, d, e) 0 227 #define dhd_prot_data_path_tx_timestamp_logging(a, b, c) 0 228 #define dhd_prot_data_path_rx_timestamp_logging(a, b, c) 0 229 #endif /* BCMPCIE */ 230 231 extern void dhd_prot_dma_indx_free(dhd_pub_t *dhd); 232 233 #ifdef SNAPSHOT_UPLOAD 234 /* send request to take snapshot */ 235 int dhd_prot_send_snapshot_request(dhd_pub_t *dhdp, uint8 snapshot_type, uint8 snapshot_param); 236 /* get uploaded snapshot */ 237 int dhd_prot_get_snapshot(dhd_pub_t *dhdp, uint8 snapshot_type, uint32 offset, 238 uint32 dst_buf_size, uint8 *dst_buf, uint32 *dst_size, bool *is_more); 239 #endif /* SNAPSHOT_UPLOAD */ 240 241 #ifdef EWP_EDL 242 int dhd_prot_init_edl_rings(dhd_pub_t *dhd); 243 bool dhd_prot_process_msgbuf_edl(dhd_pub_t *dhd); 244 int dhd_prot_process_edl_complete(dhd_pub_t *dhd, void *evt_decode_data); 245 #endif /* EWP_EDL */ 246 247 /* APIs for managing a DMA-able buffer */ 248 int dhd_dma_buf_alloc(dhd_pub_t *dhd, dhd_dma_buf_t *dma_buf, uint32 buf_len); 249 void dhd_dma_buf_free(dhd_pub_t *dhd, dhd_dma_buf_t *dma_buf); 250 void dhd_local_buf_reset(char *buf, uint32 len); 251 252 /******************************** 253 * For version-string expansion * 254 */ 255 #if defined(BDC) 256 #define DHD_PROTOCOL "bdc" 257 #elif defined(CDC) 258 #define DHD_PROTOCOL "cdc" 259 #else 260 #define DHD_PROTOCOL "unknown" 261 #endif /* proto */ 262 263 int dhd_get_hscb_info(dhd_pub_t *dhd, void ** va, uint32 *len); 264 int dhd_get_hscb_buff(dhd_pub_t *dhd, uint32 offset, uint32 length, void * buff); 265 266 #ifdef BCMINTERNAL 267 typedef struct host_page_location_info { 268 uint32 addr_lo; 269 uint32 addr_hi; 270 uint32 binary_size; 271 uint32 tlv_size; 272 uint32 tlv_signature; 273 } host_page_location_info_t; 274 #define BCM_HOST_PAGE_LOCATION_SIGNATURE 0xFEED10C5u 275 276 #ifdef DHD_FWTRACE 277 typedef struct host_fwtrace_buf_location_info { 278 fwtrace_hostaddr_info_t host_buf_info; 279 uint32 tlv_size; 280 uint32 tlv_signature; 281 } host_fwtrace_buf_location_info_t; 282 /* Host buffer info for pushing the trace info */ 283 #define BCM_HOST_FWTRACE_BUF_LOCATION_SIGNATURE 0xFEED10C6u 284 #endif /* DHD_FWTRACE */ 285 #endif /* BCMINTERNAL */ 286 287 #ifdef DHD_HP2P 288 extern uint8 dhd_prot_hp2p_enable(dhd_pub_t *dhd, bool set, int enable); 289 extern uint32 dhd_prot_pkt_threshold(dhd_pub_t *dhd, bool set, uint32 val); 290 extern uint32 dhd_prot_time_threshold(dhd_pub_t *dhd, bool set, uint32 val); 291 extern uint32 dhd_prot_pkt_expiry(dhd_pub_t *dhd, bool set, uint32 val); 292 #endif 293 294 #ifdef DHD_MAP_LOGGING 295 extern void dhd_prot_smmu_fault_dump(dhd_pub_t *dhdp); 296 #endif /* DHD_MAP_LOGGING */ 297 298 extern uint16 dhd_prot_get_h2d_max_txpost(dhd_pub_t *dhd); 299 extern void dhd_prot_set_h2d_max_txpost(dhd_pub_t *dhd, uint16 max_txpost); 300 301 #if defined(DHD_HTPUT_TUNABLES) 302 extern uint16 dhd_prot_get_h2d_htput_max_txpost(dhd_pub_t *dhd); 303 extern void dhd_prot_set_h2d_htput_max_txpost(dhd_pub_t *dhd, uint16 max_txpost); 304 #endif /* DHD_HTPUT_TUNABLES */ 305 306 #endif /* _dhd_proto_h_ */ 307