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