xref: /OK3568_Linux_fs/external/rkwifibt/drivers/infineon/include/bcmmsgbuf.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * MSGBUF network driver ioctl/indication encoding
3*4882a593Smuzhiyun  * Broadcom 802.11abg Networking Device Driver
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Definitions subject to change without notice.
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$
33*4882a593Smuzhiyun  */
34*4882a593Smuzhiyun #ifndef _bcmmsgbuf_h_
35*4882a593Smuzhiyun #define	_bcmmsgbuf_h_
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #include <ethernet.h>
38*4882a593Smuzhiyun #include <wlioctl.h>
39*4882a593Smuzhiyun #include <bcmpcie.h>
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #define MSGBUF_MAX_MSG_SIZE   ETHER_MAX_LEN
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #define D2H_EPOCH_MODULO		253 /* sequence number wrap */
44*4882a593Smuzhiyun #define D2H_EPOCH_INIT_VAL		(D2H_EPOCH_MODULO + 1)
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun #define H2D_EPOCH_MODULO		253 /* sequence number wrap */
47*4882a593Smuzhiyun #define H2D_EPOCH_INIT_VAL		(H2D_EPOCH_MODULO + 1)
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun #define H2DRING_TXPOST_ITEMSIZE		48
50*4882a593Smuzhiyun #define H2DRING_RXPOST_ITEMSIZE		32
51*4882a593Smuzhiyun #define H2DRING_CTRL_SUB_ITEMSIZE	40
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun #define D2HRING_TXCMPLT_ITEMSIZE	24
54*4882a593Smuzhiyun #define D2HRING_RXCMPLT_ITEMSIZE	40
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun #define D2HRING_TXCMPLT_ITEMSIZE_PREREV7	16
57*4882a593Smuzhiyun #define D2HRING_RXCMPLT_ITEMSIZE_PREREV7	32
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun #define D2HRING_CTRL_CMPLT_ITEMSIZE	24
60*4882a593Smuzhiyun #define H2DRING_INFO_BUFPOST_ITEMSIZE	H2DRING_CTRL_SUB_ITEMSIZE
61*4882a593Smuzhiyun #define D2HRING_INFO_BUFCMPLT_ITEMSIZE	D2HRING_CTRL_CMPLT_ITEMSIZE
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun #define D2HRING_SNAPSHOT_CMPLT_ITEMSIZE		20
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun #define H2DRING_TXPOST_MAX_ITEM			512
66*4882a593Smuzhiyun #define H2DRING_RXPOST_MAX_ITEM			512
67*4882a593Smuzhiyun #define H2DRING_CTRL_SUB_MAX_ITEM		64
68*4882a593Smuzhiyun #define D2HRING_TXCMPLT_MAX_ITEM		1024
69*4882a593Smuzhiyun #define D2HRING_RXCMPLT_MAX_ITEM		512
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun #define H2DRING_DYNAMIC_INFO_MAX_ITEM          32
72*4882a593Smuzhiyun #define D2HRING_DYNAMIC_INFO_MAX_ITEM          32
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun #define D2HRING_EDL_HDR_SIZE			48u
75*4882a593Smuzhiyun #define D2HRING_EDL_ITEMSIZE			2048u
76*4882a593Smuzhiyun #define D2HRING_EDL_MAX_ITEM			256u
77*4882a593Smuzhiyun #define D2HRING_EDL_WATERMARK			(D2HRING_EDL_MAX_ITEM >> 5u)
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun #define D2HRING_CTRL_CMPLT_MAX_ITEM		64
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun enum {
82*4882a593Smuzhiyun 	DNGL_TO_HOST_MSGBUF,
83*4882a593Smuzhiyun 	HOST_TO_DNGL_MSGBUF
84*4882a593Smuzhiyun };
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun enum {
87*4882a593Smuzhiyun 	HOST_TO_DNGL_TXP_DATA,
88*4882a593Smuzhiyun 	HOST_TO_DNGL_RXP_DATA,
89*4882a593Smuzhiyun 	HOST_TO_DNGL_CTRL,
90*4882a593Smuzhiyun 	DNGL_TO_HOST_DATA,
91*4882a593Smuzhiyun 	DNGL_TO_HOST_CTRL
92*4882a593Smuzhiyun };
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun #define MESSAGE_PAYLOAD(a) (a & MSG_TYPE_INTERNAL_USE_START) ? TRUE : FALSE
95*4882a593Smuzhiyun #define PCIEDEV_FIRMWARE_TSINFO 0x1
96*4882a593Smuzhiyun #define PCIEDEV_FIRMWARE_TSINFO_FIRST	0x1
97*4882a593Smuzhiyun #define PCIEDEV_FIRMWARE_TSINFO_MIDDLE	0x2
98*4882a593Smuzhiyun #define PCIEDEV_BTLOG_POST		0x3
99*4882a593Smuzhiyun #define PCIEDEV_BT_SNAPSHOT_POST	0x4
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun #ifdef PCIE_API_REV1
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun #define BCMMSGBUF_DUMMY_REF(a, b)	do {BCM_REFERENCE((a));BCM_REFERENCE((b));}  while (0)
104*4882a593Smuzhiyun 
105*4882a593Smuzhiyun #define BCMMSGBUF_API_IFIDX(a)		0
106*4882a593Smuzhiyun #define BCMMSGBUF_API_SEQNUM(a)		0
107*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_XTID(a)		0
108*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_PKTID(a)	((a)->cmd_id)
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun #define BCMMSGBUF_SET_API_IFIDX(a, b)	BCMMSGBUF_DUMMY_REF(a, b)
111*4882a593Smuzhiyun #define BCMMSGBUF_SET_API_SEQNUM(a, b)	BCMMSGBUF_DUMMY_REF(a, b)
112*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_SET_PKTID(a, b)	(BCMMSGBUF_IOCTL_PKTID(a) = (b))
113*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_SET_XTID(a, b)	BCMMSGBUF_DUMMY_REF(a, b)
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun #else /* PCIE_API_REV1 */
116*4882a593Smuzhiyun 
117*4882a593Smuzhiyun #define BCMMSGBUF_API_IFIDX(a)		((a)->if_id)
118*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_PKTID(a)	((a)->pkt_id)
119*4882a593Smuzhiyun #define BCMMSGBUF_API_SEQNUM(a)		((a)->u.seq.seq_no)
120*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_XTID(a)		((a)->xt_id)
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun #define BCMMSGBUF_SET_API_IFIDX(a, b)	(BCMMSGBUF_API_IFIDX((a)) = (b))
123*4882a593Smuzhiyun #define BCMMSGBUF_SET_API_SEQNUM(a, b)	(BCMMSGBUF_API_SEQNUM((a)) = (b))
124*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_SET_PKTID(a, b)	(BCMMSGBUF_IOCTL_PKTID((a)) = (b))
125*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_SET_XTID(a, b)	(BCMMSGBUF_IOCTL_XTID((a)) = (b))
126*4882a593Smuzhiyun 
127*4882a593Smuzhiyun #endif /* PCIE_API_REV1 */
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun /* utility data structures */
130*4882a593Smuzhiyun 
131*4882a593Smuzhiyun union addr64 {
132*4882a593Smuzhiyun 	struct {
133*4882a593Smuzhiyun 		uint32 low;
134*4882a593Smuzhiyun 		uint32 high;
135*4882a593Smuzhiyun 	};
136*4882a593Smuzhiyun 	struct {
137*4882a593Smuzhiyun 		uint32 low_addr;
138*4882a593Smuzhiyun 		uint32 high_addr;
139*4882a593Smuzhiyun 	};
140*4882a593Smuzhiyun 	uint64 u64;
141*4882a593Smuzhiyun } DECLSPEC_ALIGN(8);
142*4882a593Smuzhiyun 
143*4882a593Smuzhiyun typedef union addr64 bcm_addr64_t;
144*4882a593Smuzhiyun 
145*4882a593Smuzhiyun /* IOCTL req Hdr */
146*4882a593Smuzhiyun /* cmn Msg Hdr */
147*4882a593Smuzhiyun typedef struct cmn_msg_hdr {
148*4882a593Smuzhiyun 	/** message type */
149*4882a593Smuzhiyun 	uint8 msg_type;
150*4882a593Smuzhiyun 	/** interface index this is valid for */
151*4882a593Smuzhiyun 	uint8 if_id;
152*4882a593Smuzhiyun 	/* flags */
153*4882a593Smuzhiyun 	uint8 flags;
154*4882a593Smuzhiyun 	/** sequence number */
155*4882a593Smuzhiyun 	uint8 epoch;
156*4882a593Smuzhiyun 	/** packet Identifier for the associated host buffer */
157*4882a593Smuzhiyun 	uint32 request_id;
158*4882a593Smuzhiyun } cmn_msg_hdr_t;
159*4882a593Smuzhiyun 
160*4882a593Smuzhiyun /** message type */
161*4882a593Smuzhiyun typedef enum bcmpcie_msgtype {
162*4882a593Smuzhiyun 	MSG_TYPE_GEN_STATUS		= 0x1,
163*4882a593Smuzhiyun 	MSG_TYPE_RING_STATUS		= 0x2,
164*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_CREATE	= 0x3,
165*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_CREATE_CMPLT	= 0x4,
166*4882a593Smuzhiyun 	/* Enum value as copied from BISON 7.15: new generic message */
167*4882a593Smuzhiyun 	MSG_TYPE_RING_CREATE_CMPLT	= 0x4,
168*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_DELETE	= 0x5,
169*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_DELETE_CMPLT	= 0x6,
170*4882a593Smuzhiyun 	/* Enum value as copied from BISON 7.15: new generic message */
171*4882a593Smuzhiyun 	MSG_TYPE_RING_DELETE_CMPLT	= 0x6,
172*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_FLUSH	= 0x7,
173*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_FLUSH_CMPLT	= 0x8,
174*4882a593Smuzhiyun 	MSG_TYPE_IOCTLPTR_REQ		= 0x9,
175*4882a593Smuzhiyun 	MSG_TYPE_IOCTLPTR_REQ_ACK	= 0xA,
176*4882a593Smuzhiyun 	MSG_TYPE_IOCTLRESP_BUF_POST	= 0xB,
177*4882a593Smuzhiyun 	MSG_TYPE_IOCTL_CMPLT		= 0xC,
178*4882a593Smuzhiyun 	MSG_TYPE_EVENT_BUF_POST		= 0xD,
179*4882a593Smuzhiyun 	MSG_TYPE_WL_EVENT		= 0xE,
180*4882a593Smuzhiyun 	MSG_TYPE_TX_POST		= 0xF,
181*4882a593Smuzhiyun 	MSG_TYPE_TX_STATUS		= 0x10,
182*4882a593Smuzhiyun 	MSG_TYPE_RXBUF_POST		= 0x11,
183*4882a593Smuzhiyun 	MSG_TYPE_RX_CMPLT		= 0x12,
184*4882a593Smuzhiyun 	MSG_TYPE_LPBK_DMAXFER		= 0x13,
185*4882a593Smuzhiyun 	MSG_TYPE_LPBK_DMAXFER_CMPLT	= 0x14,
186*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_RESUME	 = 0x15,
187*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_RESUME_CMPLT	= 0x16,
188*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_SUSPEND	= 0x17,
189*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_SUSPEND_CMPLT	= 0x18,
190*4882a593Smuzhiyun 	MSG_TYPE_INFO_BUF_POST		= 0x19,
191*4882a593Smuzhiyun 	MSG_TYPE_INFO_BUF_CMPLT		= 0x1A,
192*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_CREATE	= 0x1B,
193*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_CREATE	= 0x1C,
194*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_CREATE_CMPLT	= 0x1D,
195*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_CREATE_CMPLT	= 0x1E,
196*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_CONFIG	= 0x1F,
197*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_CONFIG	= 0x20,
198*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_CONFIG_CMPLT	= 0x21,
199*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_CONFIG_CMPLT	= 0x22,
200*4882a593Smuzhiyun 	MSG_TYPE_H2D_MAILBOX_DATA	= 0x23,
201*4882a593Smuzhiyun 	MSG_TYPE_D2H_MAILBOX_DATA	= 0x24,
202*4882a593Smuzhiyun 	MSG_TYPE_TIMSTAMP_BUFPOST	= 0x25,
203*4882a593Smuzhiyun 	MSG_TYPE_HOSTTIMSTAMP		= 0x26,
204*4882a593Smuzhiyun 	MSG_TYPE_HOSTTIMSTAMP_CMPLT	= 0x27,
205*4882a593Smuzhiyun 	MSG_TYPE_FIRMWARE_TIMESTAMP	= 0x28,
206*4882a593Smuzhiyun 	MSG_TYPE_SNAPSHOT_UPLOAD	= 0x29,
207*4882a593Smuzhiyun 	MSG_TYPE_SNAPSHOT_CMPLT		= 0x2A,
208*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_DELETE	= 0x2B,
209*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_DELETE	= 0x2C,
210*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_DELETE_CMPLT	= 0x2D,
211*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_DELETE_CMPLT	= 0x2E,
212*4882a593Smuzhiyun 	MSG_TYPE_API_MAX_RSVD		= 0x3F
213*4882a593Smuzhiyun } bcmpcie_msg_type_t;
214*4882a593Smuzhiyun 
215*4882a593Smuzhiyun typedef enum bcmpcie_msgtype_int {
216*4882a593Smuzhiyun 	MSG_TYPE_INTERNAL_USE_START	= 0x40,
217*4882a593Smuzhiyun 	MSG_TYPE_EVENT_PYLD		= 0x41,
218*4882a593Smuzhiyun 	MSG_TYPE_IOCT_PYLD		= 0x42,
219*4882a593Smuzhiyun 	MSG_TYPE_RX_PYLD		= 0x43,
220*4882a593Smuzhiyun 	MSG_TYPE_HOST_FETCH		= 0x44,
221*4882a593Smuzhiyun 	MSG_TYPE_LPBK_DMAXFER_PYLD	= 0x45,
222*4882a593Smuzhiyun 	MSG_TYPE_TXMETADATA_PYLD	= 0x46,
223*4882a593Smuzhiyun 	MSG_TYPE_INDX_UPDATE		= 0x47,
224*4882a593Smuzhiyun 	MSG_TYPE_INFO_PYLD		= 0x48,
225*4882a593Smuzhiyun 	MSG_TYPE_TS_EVENT_PYLD		= 0x49,
226*4882a593Smuzhiyun 	MSG_TYPE_PVT_BTLOG_CMPLT	= 0x4A,
227*4882a593Smuzhiyun 	MSG_TYPE_BTLOG_PYLD		= 0x4B,
228*4882a593Smuzhiyun 	MSG_TYPE_HMAPTEST_PYLD		= 0x4C,
229*4882a593Smuzhiyun 	MSG_TYPE_PVT_BT_SNAPSHOT_CMPLT  = 0x4D,
230*4882a593Smuzhiyun 	MSG_TYPE_BT_SNAPSHOT_PYLD       = 0x4E
231*4882a593Smuzhiyun } bcmpcie_msgtype_int_t;
232*4882a593Smuzhiyun 
233*4882a593Smuzhiyun typedef enum bcmpcie_msgtype_u {
234*4882a593Smuzhiyun 	MSG_TYPE_TX_BATCH_POST		= 0x80,
235*4882a593Smuzhiyun 	MSG_TYPE_IOCTL_REQ		= 0x81,
236*4882a593Smuzhiyun 	MSG_TYPE_HOST_EVNT		= 0x82, /* console related */
237*4882a593Smuzhiyun 	MSG_TYPE_LOOPBACK		= 0x83
238*4882a593Smuzhiyun } bcmpcie_msgtype_u_t;
239*4882a593Smuzhiyun 
240*4882a593Smuzhiyun /**
241*4882a593Smuzhiyun  * D2H ring host wakeup soft doorbell, override the PCIE doorbell.
242*4882a593Smuzhiyun  * Host configures an <32bit address,value> tuple, and dongle uses SBTOPCIE
243*4882a593Smuzhiyun  * Transl0 to write specified value to host address.
244*4882a593Smuzhiyun  *
245*4882a593Smuzhiyun  * Use case: 32bit Address mapped to HW Accelerator Core/Thread Wakeup Register
246*4882a593Smuzhiyun  * and value is Core/Thread context. Host will ensure routing the 32bit address
247*4882a593Smuzhiyun  * offerred to PCIE to the mapped register.
248*4882a593Smuzhiyun  *
249*4882a593Smuzhiyun  * D2H_RING_CONFIG_SUBTYPE_SOFT_DOORBELL
250*4882a593Smuzhiyun  */
251*4882a593Smuzhiyun typedef struct bcmpcie_soft_doorbell {
252*4882a593Smuzhiyun 	uint32	value;  /* host defined value to be written, eg HW threadid */
253*4882a593Smuzhiyun 	bcm_addr64_t haddr; /* host address, eg thread wakeup register address */
254*4882a593Smuzhiyun 	uint16	items;  /* interrupt coalescing: item count before wakeup */
255*4882a593Smuzhiyun 	uint16	msecs;  /* interrupt coalescing: timeout in millisecs */
256*4882a593Smuzhiyun } bcmpcie_soft_doorbell_t;
257*4882a593Smuzhiyun 
258*4882a593Smuzhiyun /**
259*4882a593Smuzhiyun  * D2H interrupt using MSI instead of INTX
260*4882a593Smuzhiyun  * Host configures MSI vector offset for each D2H interrupt
261*4882a593Smuzhiyun  *
262*4882a593Smuzhiyun  * D2H_RING_CONFIG_SUBTYPE_MSI_DOORBELL
263*4882a593Smuzhiyun  */
264*4882a593Smuzhiyun typedef enum bcmpcie_msi_intr_idx {
265*4882a593Smuzhiyun 	MSI_INTR_IDX_CTRL_CMPL_RING	= 0,
266*4882a593Smuzhiyun 	MSI_INTR_IDX_TXP_CMPL_RING	= 1,
267*4882a593Smuzhiyun 	MSI_INTR_IDX_RXP_CMPL_RING	= 2,
268*4882a593Smuzhiyun 	MSI_INTR_IDX_INFO_CMPL_RING	= 3,
269*4882a593Smuzhiyun 	MSI_INTR_IDX_MAILBOX		= 4,
270*4882a593Smuzhiyun 	MSI_INTR_IDX_MAX		= 5
271*4882a593Smuzhiyun } bcmpcie_msi_intr_idx_t;
272*4882a593Smuzhiyun 
273*4882a593Smuzhiyun #define BCMPCIE_D2H_MSI_OFFSET_SINGLE	0
274*4882a593Smuzhiyun typedef enum bcmpcie_msi_offset_type {
275*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_MB0	= 2,
276*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_MB1	= 3,
277*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_DB0	= 4,
278*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_DB1	= 5,
279*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_H1_DB0	= 6,
280*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_MAX	= 7
281*4882a593Smuzhiyun } bcmpcie_msi_offset_type_t;
282*4882a593Smuzhiyun 
283*4882a593Smuzhiyun typedef struct bcmpcie_msi_offset {
284*4882a593Smuzhiyun 	uint16	intr_idx;    /* interrupt index */
285*4882a593Smuzhiyun 	uint16	msi_offset;  /* msi vector offset */
286*4882a593Smuzhiyun } bcmpcie_msi_offset_t;
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun typedef struct bcmpcie_msi_offset_config {
289*4882a593Smuzhiyun 	uint32	len;
290*4882a593Smuzhiyun 	bcmpcie_msi_offset_t	bcmpcie_msi_offset[MSI_INTR_IDX_MAX];
291*4882a593Smuzhiyun } bcmpcie_msi_offset_config_t;
292*4882a593Smuzhiyun 
293*4882a593Smuzhiyun #define BCMPCIE_D2H_MSI_OFFSET_DEFAULT	BCMPCIE_D2H_MSI_OFFSET_DB1
294*4882a593Smuzhiyun 
295*4882a593Smuzhiyun #define BCMPCIE_D2H_MSI_SINGLE		0xFFFE
296*4882a593Smuzhiyun 
297*4882a593Smuzhiyun /* if_id */
298*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_PHYINTF_SHFT	5
299*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_PHYINTF_MAX	0x7
300*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_PHYINTF_MASK	\
301*4882a593Smuzhiyun 	(BCMPCIE_CMNHDR_IFIDX_PHYINTF_MAX << BCMPCIE_CMNHDR_IFIDX_PHYINTF_SHFT)
302*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_VIRTINTF_SHFT	0
303*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_VIRTINTF_MAX	0x1F
304*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_VIRTINTF_MASK	\
305*4882a593Smuzhiyun 	(BCMPCIE_CMNHDR_IFIDX_PHYINTF_MAX << BCMPCIE_CMNHDR_IFIDX_PHYINTF_SHFT)
306*4882a593Smuzhiyun 
307*4882a593Smuzhiyun /* flags */
308*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_FLAGS_DMA_R_IDX		0x1
309*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_FLAGS_DMA_R_IDX_INTR	0x2
310*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_FLAGS_TS_SEQNUM_INIT	0x4
311*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_FLAGS_PHASE_BIT		0x80
312*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_PHASE_BIT_INIT		0x80
313*4882a593Smuzhiyun 
314*4882a593Smuzhiyun /* IOCTL request message */
315*4882a593Smuzhiyun typedef struct ioctl_req_msg {
316*4882a593Smuzhiyun 	/** common message header */
317*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
318*4882a593Smuzhiyun 	/** ioctl command type */
319*4882a593Smuzhiyun 	uint32		cmd;
320*4882a593Smuzhiyun 	/** ioctl transaction ID, to pair with a ioctl response */
321*4882a593Smuzhiyun 	uint16		trans_id;
322*4882a593Smuzhiyun 	/** input arguments buffer len */
323*4882a593Smuzhiyun 	uint16		input_buf_len;
324*4882a593Smuzhiyun 	/** expected output len */
325*4882a593Smuzhiyun 	uint16		output_buf_len;
326*4882a593Smuzhiyun 	/** to align the host address on 8 byte boundary */
327*4882a593Smuzhiyun 	uint16		rsvd[3];
328*4882a593Smuzhiyun 	/** always align on 8 byte boundary */
329*4882a593Smuzhiyun 	bcm_addr64_t	host_input_buf_addr;
330*4882a593Smuzhiyun 	/* rsvd */
331*4882a593Smuzhiyun 	uint32		rsvd1[2];
332*4882a593Smuzhiyun } ioctl_req_msg_t;
333*4882a593Smuzhiyun 
334*4882a593Smuzhiyun /** buffer post messages for device to use to return IOCTL responses, Events */
335*4882a593Smuzhiyun typedef struct ioctl_resp_evt_buf_post_msg {
336*4882a593Smuzhiyun 	/** common message header */
337*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
338*4882a593Smuzhiyun 	/** length of the host buffer supplied */
339*4882a593Smuzhiyun 	uint16		host_buf_len;
340*4882a593Smuzhiyun 	/** to align the host address on 8 byte boundary */
341*4882a593Smuzhiyun 	uint16		reserved[3];
342*4882a593Smuzhiyun 	/** always align on 8 byte boundary */
343*4882a593Smuzhiyun 	bcm_addr64_t	host_buf_addr;
344*4882a593Smuzhiyun 	uint32		rsvd[4];
345*4882a593Smuzhiyun } ioctl_resp_evt_buf_post_msg_t;
346*4882a593Smuzhiyun 
347*4882a593Smuzhiyun /* buffer post messages for device to use to return dbg buffers */
348*4882a593Smuzhiyun typedef ioctl_resp_evt_buf_post_msg_t info_buf_post_msg_t;
349*4882a593Smuzhiyun 
350*4882a593Smuzhiyun #define DHD_INFOBUF_RX_BUFPOST_PKTSZ	(2 * 1024)
351*4882a593Smuzhiyun 
352*4882a593Smuzhiyun #define DHD_BTLOG_RX_BUFPOST_PKTSZ	(2 * 1024)
353*4882a593Smuzhiyun 
354*4882a593Smuzhiyun /* An infobuf host buffer starts with a 32 bit (LE) version. */
355*4882a593Smuzhiyun #define PCIE_INFOBUF_V1                1
356*4882a593Smuzhiyun /* Infobuf v1 type MSGTRACE's data is exactly the same as the MSGTRACE data that
357*4882a593Smuzhiyun  * is wrapped previously/also in a WLC_E_TRACE event.  See structure
358*4882a593Smuzhiyun  * msgrace_hdr_t in msgtrace.h.
359*4882a593Smuzhiyun */
360*4882a593Smuzhiyun #define PCIE_INFOBUF_V1_TYPE_MSGTRACE  1
361*4882a593Smuzhiyun 
362*4882a593Smuzhiyun /* Infobuf v1 type LOGTRACE data is exactly the same as the LOGTRACE data that
363*4882a593Smuzhiyun  * is wrapped previously/also in a WLC_E_TRACE event.  See structure
364*4882a593Smuzhiyun  * msgrace_hdr_t in msgtrace.h.  (The only difference between a MSGTRACE
365*4882a593Smuzhiyun  * and a LOGTRACE is the "trace type" field.)
366*4882a593Smuzhiyun */
367*4882a593Smuzhiyun #define PCIE_INFOBUF_V1_TYPE_LOGTRACE  2
368*4882a593Smuzhiyun 
369*4882a593Smuzhiyun /* An infobuf version 1 host buffer has a single TLV.  The information on the
370*4882a593Smuzhiyun  * version 1 types follow this structure definition. (int's LE)
371*4882a593Smuzhiyun */
372*4882a593Smuzhiyun typedef struct info_buf_payload_hdr_s {
373*4882a593Smuzhiyun 	uint16 type;
374*4882a593Smuzhiyun 	uint16 length;
375*4882a593Smuzhiyun } info_buf_payload_hdr_t;
376*4882a593Smuzhiyun 
377*4882a593Smuzhiyun /* BT logs/memory to DMA directly from BT memory to host */
378*4882a593Smuzhiyun typedef struct info_buf_btlog_s {
379*4882a593Smuzhiyun 	void (*status_cb)(void *ctx, void *p, int error);	/* obsolete - to be removed */
380*4882a593Smuzhiyun 	void *ctx;
381*4882a593Smuzhiyun 	dma64addr_t src_addr;
382*4882a593Smuzhiyun 	uint32 length;
383*4882a593Smuzhiyun 	bool (*pcie_status_cb)(osl_t *osh, void *p, int error);
384*4882a593Smuzhiyun 	uint32 bt_intstatus;
385*4882a593Smuzhiyun 	int error;
386*4882a593Smuzhiyun } info_buf_btlog_t;
387*4882a593Smuzhiyun 
388*4882a593Smuzhiyun /** snapshot upload request message  */
389*4882a593Smuzhiyun typedef struct snapshot_upload_request_msg {
390*4882a593Smuzhiyun 	/** common message header */
391*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
392*4882a593Smuzhiyun 	/** length of the snaphost buffer supplied */
393*4882a593Smuzhiyun 	uint32		snapshot_buf_len;
394*4882a593Smuzhiyun 	/** type of snapshot */
395*4882a593Smuzhiyun 	uint8		snapshot_type;
396*4882a593Smuzhiyun 	/** snapshot param    */
397*4882a593Smuzhiyun 	uint8		snapshot_param;
398*4882a593Smuzhiyun 	/** to align the host address on 8 byte boundary */
399*4882a593Smuzhiyun 	uint8		reserved[2];
400*4882a593Smuzhiyun 	/** always align on 8 byte boundary */
401*4882a593Smuzhiyun 	bcm_addr64_t	host_buf_addr;
402*4882a593Smuzhiyun 	uint32		rsvd[4];
403*4882a593Smuzhiyun } snapshot_upload_request_msg_t;
404*4882a593Smuzhiyun 
405*4882a593Smuzhiyun /** snapshot types  */
406*4882a593Smuzhiyun typedef enum bcmpcie_snapshot_type {
407*4882a593Smuzhiyun 	SNAPSHOT_TYPE_BT		= 0,	/* Bluetooth SRAM and patch RAM */
408*4882a593Smuzhiyun 	SNAPSHOT_TYPE_WLAN_SOCRAM	= 1,	/* WLAN SOCRAM */
409*4882a593Smuzhiyun 	SNAPSHOT_TYPE_WLAN_HEAP		= 2,	/* WLAN HEAP */
410*4882a593Smuzhiyun 	SNAPSHOT_TYPE_WLAN_REGISTER	= 3	/* WLAN registers */
411*4882a593Smuzhiyun } bcmpcie_snapshot_type_t;
412*4882a593Smuzhiyun 
413*4882a593Smuzhiyun #define PCIE_DMA_XFER_FLG_D11_LPBK_MASK		0xF
414*4882a593Smuzhiyun #define PCIE_DMA_XFER_FLG_D11_LPBK_SHIFT	2
415*4882a593Smuzhiyun #define PCIE_DMA_XFER_FLG_CORE_NUMBER_MASK	3
416*4882a593Smuzhiyun #define PCIE_DMA_XFER_FLG_CORE_NUMBER_SHIFT	0
417*4882a593Smuzhiyun 
418*4882a593Smuzhiyun typedef struct pcie_dma_xfer_params {
419*4882a593Smuzhiyun 	/** common message header */
420*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
421*4882a593Smuzhiyun 
422*4882a593Smuzhiyun 	/** always align on 8 byte boundary */
423*4882a593Smuzhiyun 	bcm_addr64_t	host_input_buf_addr;
424*4882a593Smuzhiyun 
425*4882a593Smuzhiyun 	/** always align on 8 byte boundary */
426*4882a593Smuzhiyun 	bcm_addr64_t	host_ouput_buf_addr;
427*4882a593Smuzhiyun 
428*4882a593Smuzhiyun 	/** length of transfer */
429*4882a593Smuzhiyun 	uint32		xfer_len;
430*4882a593Smuzhiyun 	/** delay before doing the src txfer */
431*4882a593Smuzhiyun 	uint32		srcdelay;
432*4882a593Smuzhiyun 	/** delay before doing the dest txfer */
433*4882a593Smuzhiyun 	uint32		destdelay;
434*4882a593Smuzhiyun 	uint8		rsvd[3];
435*4882a593Smuzhiyun 	/* bit0: D11 DMA loopback flag */
436*4882a593Smuzhiyun 	uint8		flags;
437*4882a593Smuzhiyun } pcie_dma_xfer_params_t;
438*4882a593Smuzhiyun 
439*4882a593Smuzhiyun #define BCMPCIE_FLOW_RING_INTF_HP2P 0x1
440*4882a593Smuzhiyun /** Complete msgbuf hdr for flow ring update from host to dongle */
441*4882a593Smuzhiyun typedef struct tx_flowring_create_request {
442*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
443*4882a593Smuzhiyun 	uint8	da[ETHER_ADDR_LEN];
444*4882a593Smuzhiyun 	uint8	sa[ETHER_ADDR_LEN];
445*4882a593Smuzhiyun 	uint8	tid;
446*4882a593Smuzhiyun 	uint8	if_flags;
447*4882a593Smuzhiyun 	uint16	flow_ring_id;
448*4882a593Smuzhiyun 	uint8	tc;
449*4882a593Smuzhiyun 	/* priority_ifrmmask is to define core mask in ifrm mode.
450*4882a593Smuzhiyun 	 * currently it is not used for priority. so uses solely for ifrm mask
451*4882a593Smuzhiyun 	 */
452*4882a593Smuzhiyun 	uint8	priority_ifrmmask;
453*4882a593Smuzhiyun 	uint16	int_vector;
454*4882a593Smuzhiyun 	uint16	max_items;
455*4882a593Smuzhiyun 	uint16	len_item;
456*4882a593Smuzhiyun 	bcm_addr64_t flow_ring_ptr;
457*4882a593Smuzhiyun } tx_flowring_create_request_t;
458*4882a593Smuzhiyun 
459*4882a593Smuzhiyun typedef struct tx_flowring_delete_request {
460*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
461*4882a593Smuzhiyun 	uint16	flow_ring_id;
462*4882a593Smuzhiyun 	uint16	reason;
463*4882a593Smuzhiyun 	uint32	rsvd[7];
464*4882a593Smuzhiyun } tx_flowring_delete_request_t;
465*4882a593Smuzhiyun 
466*4882a593Smuzhiyun typedef tx_flowring_delete_request_t d2h_ring_delete_req_t;
467*4882a593Smuzhiyun typedef tx_flowring_delete_request_t h2d_ring_delete_req_t;
468*4882a593Smuzhiyun 
469*4882a593Smuzhiyun typedef struct tx_flowring_flush_request {
470*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
471*4882a593Smuzhiyun 	uint16	flow_ring_id;
472*4882a593Smuzhiyun 	uint16	reason;
473*4882a593Smuzhiyun 	uint32	rsvd[7];
474*4882a593Smuzhiyun } tx_flowring_flush_request_t;
475*4882a593Smuzhiyun 
476*4882a593Smuzhiyun /** Subtypes for ring_config_req control message */
477*4882a593Smuzhiyun typedef enum ring_config_subtype {
478*4882a593Smuzhiyun 	/** Default D2H PCIE doorbell override using ring_config_req msg */
479*4882a593Smuzhiyun 	D2H_RING_CONFIG_SUBTYPE_SOFT_DOORBELL = 1, /* Software doorbell */
480*4882a593Smuzhiyun 	D2H_RING_CONFIG_SUBTYPE_MSI_DOORBELL = 2   /* MSI configuration */
481*4882a593Smuzhiyun } ring_config_subtype_t;
482*4882a593Smuzhiyun 
483*4882a593Smuzhiyun typedef struct ring_config_req {
484*4882a593Smuzhiyun 	cmn_msg_hdr_t	msg;
485*4882a593Smuzhiyun 	uint16	subtype;
486*4882a593Smuzhiyun 	uint16	ring_id;
487*4882a593Smuzhiyun 	uint32	rsvd;
488*4882a593Smuzhiyun 	union {
489*4882a593Smuzhiyun 		uint32  data[6];
490*4882a593Smuzhiyun 		/** D2H_RING_CONFIG_SUBTYPE_SOFT_DOORBELL */
491*4882a593Smuzhiyun 		bcmpcie_soft_doorbell_t soft_doorbell;
492*4882a593Smuzhiyun 		/** D2H_RING_CONFIG_SUBTYPE_MSI_DOORBELL */
493*4882a593Smuzhiyun 		bcmpcie_msi_offset_config_t msi_offset;
494*4882a593Smuzhiyun 	};
495*4882a593Smuzhiyun } ring_config_req_t;
496*4882a593Smuzhiyun 
497*4882a593Smuzhiyun /* data structure to use to create on the fly d2h rings */
498*4882a593Smuzhiyun typedef struct d2h_ring_create_req {
499*4882a593Smuzhiyun 	cmn_msg_hdr_t	msg;
500*4882a593Smuzhiyun 	uint16	ring_id;
501*4882a593Smuzhiyun 	uint16	ring_type;
502*4882a593Smuzhiyun 	uint32	flags;
503*4882a593Smuzhiyun 	bcm_addr64_t	ring_ptr;
504*4882a593Smuzhiyun 	uint16	max_items;
505*4882a593Smuzhiyun 	uint16	len_item;
506*4882a593Smuzhiyun 	uint32	rsvd[3];
507*4882a593Smuzhiyun } d2h_ring_create_req_t;
508*4882a593Smuzhiyun 
509*4882a593Smuzhiyun /* data structure to use to create on the fly h2d rings */
510*4882a593Smuzhiyun #define MAX_COMPLETION_RING_IDS_ASSOCIATED	4
511*4882a593Smuzhiyun typedef struct h2d_ring_create_req {
512*4882a593Smuzhiyun 	cmn_msg_hdr_t	msg;
513*4882a593Smuzhiyun 	uint16	ring_id;
514*4882a593Smuzhiyun 	uint8	ring_type;
515*4882a593Smuzhiyun 	uint8	n_completion_ids;
516*4882a593Smuzhiyun 	uint32	flags;
517*4882a593Smuzhiyun 	bcm_addr64_t	ring_ptr;
518*4882a593Smuzhiyun 	uint16	max_items;
519*4882a593Smuzhiyun 	uint16	len_item;
520*4882a593Smuzhiyun 	uint16	completion_ring_ids[MAX_COMPLETION_RING_IDS_ASSOCIATED];
521*4882a593Smuzhiyun 	uint32	rsvd;
522*4882a593Smuzhiyun } h2d_ring_create_req_t;
523*4882a593Smuzhiyun 
524*4882a593Smuzhiyun typedef struct d2h_ring_config_req {
525*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
526*4882a593Smuzhiyun 	uint16	d2h_ring_config_subtype;
527*4882a593Smuzhiyun 	uint16	d2h_ring_id;
528*4882a593Smuzhiyun 	uint32  d2h_ring_config_data[4];
529*4882a593Smuzhiyun 	uint32  rsvd[3];
530*4882a593Smuzhiyun } d2h_ring_config_req_t;
531*4882a593Smuzhiyun 
532*4882a593Smuzhiyun typedef struct h2d_ring_config_req {
533*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
534*4882a593Smuzhiyun 	uint16	h2d_ring_config_subtype;
535*4882a593Smuzhiyun 	uint16	h2d_ring_id;
536*4882a593Smuzhiyun 	uint32  h2d_ring_config_data;
537*4882a593Smuzhiyun 	uint32  rsvd[6];
538*4882a593Smuzhiyun } h2d_ring_config_req_t;
539*4882a593Smuzhiyun 
540*4882a593Smuzhiyun typedef struct h2d_mailbox_data {
541*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
542*4882a593Smuzhiyun 	uint32	mail_box_data;
543*4882a593Smuzhiyun 	uint32  rsvd[7];
544*4882a593Smuzhiyun } h2d_mailbox_data_t;
545*4882a593Smuzhiyun typedef struct host_timestamp_msg {
546*4882a593Smuzhiyun 	cmn_msg_hdr_t	msg;
547*4882a593Smuzhiyun 	uint16		xt_id; /* transaction ID */
548*4882a593Smuzhiyun 	uint16		input_data_len; /* data len at the host_buf_addr, data in TLVs */
549*4882a593Smuzhiyun 	uint16		seqnum; /* number of times host captured the timestamp */
550*4882a593Smuzhiyun 	uint16		rsvd;
551*4882a593Smuzhiyun 	/* always align on 8 byte boundary */
552*4882a593Smuzhiyun 	bcm_addr64_t	host_buf_addr;
553*4882a593Smuzhiyun 	/* rsvd */
554*4882a593Smuzhiyun 	uint32      rsvd1[4];
555*4882a593Smuzhiyun } host_timestamp_msg_t;
556*4882a593Smuzhiyun 
557*4882a593Smuzhiyun /* buffer post message for timestamp events MSG_TYPE_TIMSTAMP_BUFPOST */
558*4882a593Smuzhiyun typedef ioctl_resp_evt_buf_post_msg_t ts_buf_post_msg_t;
559*4882a593Smuzhiyun 
560*4882a593Smuzhiyun typedef union ctrl_submit_item {
561*4882a593Smuzhiyun 	ioctl_req_msg_t			ioctl_req;
562*4882a593Smuzhiyun 	ioctl_resp_evt_buf_post_msg_t	resp_buf_post;
563*4882a593Smuzhiyun 	pcie_dma_xfer_params_t		dma_xfer;
564*4882a593Smuzhiyun 	tx_flowring_create_request_t	flow_create;
565*4882a593Smuzhiyun 	tx_flowring_delete_request_t	flow_delete;
566*4882a593Smuzhiyun 	tx_flowring_flush_request_t	flow_flush;
567*4882a593Smuzhiyun 	ring_config_req_t		ring_config_req;
568*4882a593Smuzhiyun 	d2h_ring_create_req_t		d2h_create;
569*4882a593Smuzhiyun 	h2d_ring_create_req_t		h2d_create;
570*4882a593Smuzhiyun 	d2h_ring_config_req_t		d2h_config;
571*4882a593Smuzhiyun 	h2d_ring_config_req_t		h2d_config;
572*4882a593Smuzhiyun 	h2d_mailbox_data_t		h2d_mailbox_data;
573*4882a593Smuzhiyun 	host_timestamp_msg_t		host_ts;
574*4882a593Smuzhiyun 	ts_buf_post_msg_t		ts_buf_post;
575*4882a593Smuzhiyun 	d2h_ring_delete_req_t		d2h_delete;
576*4882a593Smuzhiyun 	h2d_ring_delete_req_t		h2d_delete;
577*4882a593Smuzhiyun 	unsigned char			check[H2DRING_CTRL_SUB_ITEMSIZE];
578*4882a593Smuzhiyun } ctrl_submit_item_t;
579*4882a593Smuzhiyun 
580*4882a593Smuzhiyun typedef struct info_ring_submit_item {
581*4882a593Smuzhiyun 	info_buf_post_msg_t		info_buf_post;
582*4882a593Smuzhiyun 	unsigned char			check[H2DRING_INFO_BUFPOST_ITEMSIZE];
583*4882a593Smuzhiyun } info_sumbit_item_t;
584*4882a593Smuzhiyun 
585*4882a593Smuzhiyun /** Control Completion messages (20 bytes) */
586*4882a593Smuzhiyun typedef struct compl_msg_hdr {
587*4882a593Smuzhiyun 	/** status for the completion */
588*4882a593Smuzhiyun 	int16	status;
589*4882a593Smuzhiyun 	/** submisison flow ring id which generated this status */
590*4882a593Smuzhiyun 	union {
591*4882a593Smuzhiyun 	    uint16	ring_id;
592*4882a593Smuzhiyun 	    uint16	flow_ring_id;
593*4882a593Smuzhiyun 	};
594*4882a593Smuzhiyun } compl_msg_hdr_t;
595*4882a593Smuzhiyun 
596*4882a593Smuzhiyun /** XOR checksum or a magic number to audit DMA done */
597*4882a593Smuzhiyun typedef uint32 dma_done_t;
598*4882a593Smuzhiyun 
599*4882a593Smuzhiyun #define MAX_CLKSRC_ID	0xF
600*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_0_MASK		0x000000FF
601*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_0_SHIFT	0
602*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_1_MASK		0x0000FF00
603*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_1_SHIFT	8
604*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_2_MASK		0x00FF0000
605*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_2_SHIFT	16
606*4882a593Smuzhiyun #define TX_PKT_BAND_INFO		0x0F000000
607*4882a593Smuzhiyun #define TX_PKT_BAND_INFO_SHIFT		24
608*4882a593Smuzhiyun #define TX_PKT_VALID_INFO		0xF0000000
609*4882a593Smuzhiyun #define TX_PKT_VALID_INFO_SHIFT		28
610*4882a593Smuzhiyun 
611*4882a593Smuzhiyun typedef struct ts_timestamp_srcid {
612*4882a593Smuzhiyun 	union {
613*4882a593Smuzhiyun 		uint32	ts_low; /* time stamp low 32 bits */
614*4882a593Smuzhiyun 		uint32  rate_spec; /* use ratespec */
615*4882a593Smuzhiyun 	};
616*4882a593Smuzhiyun 	union {
617*4882a593Smuzhiyun 		uint32  ts_high; /* time stamp high 28 bits */
618*4882a593Smuzhiyun 		union {
619*4882a593Smuzhiyun 			uint32  ts_high_ext :28; /* time stamp high 28 bits */
620*4882a593Smuzhiyun 			uint32  clk_id_ext :3; /* clock ID source  */
621*4882a593Smuzhiyun 			uint32  phase :1; /* Phase bit */
622*4882a593Smuzhiyun 			dma_done_t	marker_ext;
623*4882a593Smuzhiyun 		};
624*4882a593Smuzhiyun 		uint32 tx_pkt_band_retry_info;
625*4882a593Smuzhiyun 	};
626*4882a593Smuzhiyun } ts_timestamp_srcid_t;
627*4882a593Smuzhiyun 
628*4882a593Smuzhiyun typedef ts_timestamp_srcid_t ipc_timestamp_t;
629*4882a593Smuzhiyun 
630*4882a593Smuzhiyun typedef struct ts_timestamp {
631*4882a593Smuzhiyun 	uint32	low;
632*4882a593Smuzhiyun 	uint32	high;
633*4882a593Smuzhiyun } ts_timestamp_t;
634*4882a593Smuzhiyun 
635*4882a593Smuzhiyun typedef ts_timestamp_t tick_count_64_t;
636*4882a593Smuzhiyun typedef ts_timestamp_t ts_timestamp_ns_64_t;
637*4882a593Smuzhiyun typedef ts_timestamp_t ts_correction_m_t;
638*4882a593Smuzhiyun typedef ts_timestamp_t ts_correction_b_t;
639*4882a593Smuzhiyun 
640*4882a593Smuzhiyun /* completion header status codes */
641*4882a593Smuzhiyun #define	BCMPCIE_SUCCESS			0
642*4882a593Smuzhiyun #define BCMPCIE_NOTFOUND		1
643*4882a593Smuzhiyun #define BCMPCIE_NOMEM			2
644*4882a593Smuzhiyun #define BCMPCIE_BADOPTION		3
645*4882a593Smuzhiyun #define BCMPCIE_RING_IN_USE		4
646*4882a593Smuzhiyun #define BCMPCIE_RING_ID_INVALID		5
647*4882a593Smuzhiyun #define BCMPCIE_PKT_FLUSH		6
648*4882a593Smuzhiyun #define BCMPCIE_NO_EVENT_BUF		7
649*4882a593Smuzhiyun #define BCMPCIE_NO_RX_BUF		8
650*4882a593Smuzhiyun #define BCMPCIE_NO_IOCTLRESP_BUF	9
651*4882a593Smuzhiyun #define BCMPCIE_MAX_IOCTLRESP_BUF	10
652*4882a593Smuzhiyun #define BCMPCIE_MAX_EVENT_BUF		11
653*4882a593Smuzhiyun #define BCMPCIE_BAD_PHASE		12
654*4882a593Smuzhiyun #define BCMPCIE_INVALID_CPL_RINGID	13
655*4882a593Smuzhiyun #define BCMPCIE_RING_TYPE_INVALID	14
656*4882a593Smuzhiyun #define BCMPCIE_NO_TS_EVENT_BUF		15
657*4882a593Smuzhiyun #define BCMPCIE_MAX_TS_EVENT_BUF	16
658*4882a593Smuzhiyun #define BCMPCIE_PCIE_NO_BTLOG_BUF	17
659*4882a593Smuzhiyun #define BCMPCIE_BT_DMA_ERR		18
660*4882a593Smuzhiyun #define BCMPCIE_BT_DMA_DESCR_FETCH_ERR	19
661*4882a593Smuzhiyun #define BCMPCIE_SNAPSHOT_ERR		20
662*4882a593Smuzhiyun #define BCMPCIE_NOT_READY		21
663*4882a593Smuzhiyun #define BCMPCIE_INVALID_DATA		22
664*4882a593Smuzhiyun #define BCMPCIE_NO_RESPONSE		23
665*4882a593Smuzhiyun #define BCMPCIE_NO_CLOCK		24
666*4882a593Smuzhiyun 
667*4882a593Smuzhiyun /** IOCTL completion response */
668*4882a593Smuzhiyun typedef struct ioctl_compl_resp_msg {
669*4882a593Smuzhiyun 	/** common message header */
670*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
671*4882a593Smuzhiyun 	/** completion message header */
672*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
673*4882a593Smuzhiyun 	/** response buffer len where a host buffer is involved */
674*4882a593Smuzhiyun 	uint16			resp_len;
675*4882a593Smuzhiyun 	/** transaction id to pair with a request */
676*4882a593Smuzhiyun 	uint16			trans_id;
677*4882a593Smuzhiyun 	/** cmd id */
678*4882a593Smuzhiyun 	uint32			cmd;
679*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
680*4882a593Smuzhiyun 	dma_done_t		marker;
681*4882a593Smuzhiyun } ioctl_comp_resp_msg_t;
682*4882a593Smuzhiyun 
683*4882a593Smuzhiyun /** IOCTL request acknowledgement */
684*4882a593Smuzhiyun typedef struct ioctl_req_ack_msg {
685*4882a593Smuzhiyun 	/** common message header */
686*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
687*4882a593Smuzhiyun 	/** completion message header */
688*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
689*4882a593Smuzhiyun 	/** cmd id */
690*4882a593Smuzhiyun 	uint32			cmd;
691*4882a593Smuzhiyun 	uint32			rsvd;
692*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
693*4882a593Smuzhiyun 	dma_done_t		marker;
694*4882a593Smuzhiyun } ioctl_req_ack_msg_t;
695*4882a593Smuzhiyun 
696*4882a593Smuzhiyun /** WL event message: send from device to host */
697*4882a593Smuzhiyun typedef struct wlevent_req_msg {
698*4882a593Smuzhiyun 	/** common message header */
699*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
700*4882a593Smuzhiyun 	/** completion message header */
701*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
702*4882a593Smuzhiyun 	/** event data len valid with the event buffer */
703*4882a593Smuzhiyun 	uint16			event_data_len;
704*4882a593Smuzhiyun 	/** sequence number */
705*4882a593Smuzhiyun 	uint16			seqnum;
706*4882a593Smuzhiyun 	/** rsvd	*/
707*4882a593Smuzhiyun 	uint32			rsvd;
708*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
709*4882a593Smuzhiyun 	dma_done_t		marker;
710*4882a593Smuzhiyun } wlevent_req_msg_t;
711*4882a593Smuzhiyun 
712*4882a593Smuzhiyun /** dma xfer complete message */
713*4882a593Smuzhiyun typedef struct pcie_dmaxfer_cmplt {
714*4882a593Smuzhiyun 	/** common message header */
715*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
716*4882a593Smuzhiyun 	/** completion message header */
717*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
718*4882a593Smuzhiyun 	uint32			rsvd[2];
719*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
720*4882a593Smuzhiyun 	dma_done_t		marker;
721*4882a593Smuzhiyun } pcie_dmaxfer_cmplt_t;
722*4882a593Smuzhiyun 
723*4882a593Smuzhiyun /** general status message */
724*4882a593Smuzhiyun typedef struct pcie_gen_status {
725*4882a593Smuzhiyun 	/** common message header */
726*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
727*4882a593Smuzhiyun 	/** completion message header */
728*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
729*4882a593Smuzhiyun 	uint32			rsvd[2];
730*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
731*4882a593Smuzhiyun 	dma_done_t		marker;
732*4882a593Smuzhiyun } pcie_gen_status_t;
733*4882a593Smuzhiyun 
734*4882a593Smuzhiyun /** ring status message */
735*4882a593Smuzhiyun typedef struct pcie_ring_status {
736*4882a593Smuzhiyun 	/** common message header */
737*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
738*4882a593Smuzhiyun 	/** completion message header */
739*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
740*4882a593Smuzhiyun 	/** message which firmware couldn't decode */
741*4882a593Smuzhiyun 	uint16			write_idx;
742*4882a593Smuzhiyun 	uint16			rsvd[3];
743*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
744*4882a593Smuzhiyun 	dma_done_t		marker;
745*4882a593Smuzhiyun } pcie_ring_status_t;
746*4882a593Smuzhiyun 
747*4882a593Smuzhiyun typedef struct ring_create_response {
748*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
749*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
750*4882a593Smuzhiyun 	uint32			rsvd[2];
751*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
752*4882a593Smuzhiyun 	dma_done_t		marker;
753*4882a593Smuzhiyun } ring_create_response_t;
754*4882a593Smuzhiyun 
755*4882a593Smuzhiyun typedef ring_create_response_t tx_flowring_create_response_t;
756*4882a593Smuzhiyun typedef ring_create_response_t h2d_ring_create_response_t;
757*4882a593Smuzhiyun typedef ring_create_response_t d2h_ring_create_response_t;
758*4882a593Smuzhiyun 
759*4882a593Smuzhiyun typedef struct tx_flowring_delete_response {
760*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
761*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
762*4882a593Smuzhiyun 	uint16			read_idx;
763*4882a593Smuzhiyun 	uint16			rsvd[3];
764*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
765*4882a593Smuzhiyun 	dma_done_t		marker;
766*4882a593Smuzhiyun } tx_flowring_delete_response_t;
767*4882a593Smuzhiyun 
768*4882a593Smuzhiyun typedef tx_flowring_delete_response_t	h2d_ring_delete_response_t;
769*4882a593Smuzhiyun typedef tx_flowring_delete_response_t	d2h_ring_delete_response_t;
770*4882a593Smuzhiyun 
771*4882a593Smuzhiyun typedef struct tx_flowring_flush_response {
772*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
773*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
774*4882a593Smuzhiyun 	uint32			rsvd[2];
775*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
776*4882a593Smuzhiyun 	dma_done_t		marker;
777*4882a593Smuzhiyun } tx_flowring_flush_response_t;
778*4882a593Smuzhiyun 
779*4882a593Smuzhiyun /** Common layout of all d2h control messages */
780*4882a593Smuzhiyun typedef struct ctrl_compl_msg {
781*4882a593Smuzhiyun 	/** common message header */
782*4882a593Smuzhiyun 	cmn_msg_hdr_t       cmn_hdr;
783*4882a593Smuzhiyun 	/** completion message header */
784*4882a593Smuzhiyun 	compl_msg_hdr_t     compl_hdr;
785*4882a593Smuzhiyun 	uint32          rsvd[2];
786*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
787*4882a593Smuzhiyun 	dma_done_t      marker;
788*4882a593Smuzhiyun } ctrl_compl_msg_t;
789*4882a593Smuzhiyun 
790*4882a593Smuzhiyun typedef struct ring_config_resp {
791*4882a593Smuzhiyun 	/** common message header */
792*4882a593Smuzhiyun 	cmn_msg_hdr_t       cmn_hdr;
793*4882a593Smuzhiyun 	/** completion message header */
794*4882a593Smuzhiyun 	compl_msg_hdr_t     compl_hdr;
795*4882a593Smuzhiyun 	uint16		subtype;
796*4882a593Smuzhiyun 	uint16          rsvd[3];
797*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
798*4882a593Smuzhiyun 	dma_done_t      marker;
799*4882a593Smuzhiyun } ring_config_resp_t;
800*4882a593Smuzhiyun 
801*4882a593Smuzhiyun typedef struct d2h_mailbox_data {
802*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
803*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
804*4882a593Smuzhiyun 	uint32			d2h_mailbox_data;
805*4882a593Smuzhiyun 	uint32			rsvd[1];
806*4882a593Smuzhiyun 	/* XOR checksum or a magic number to audit DMA done */
807*4882a593Smuzhiyun 	dma_done_t		marker;
808*4882a593Smuzhiyun } d2h_mailbox_data_t;
809*4882a593Smuzhiyun 
810*4882a593Smuzhiyun /* dbg buf completion msg: send from device to host */
811*4882a593Smuzhiyun typedef struct info_buf_resp {
812*4882a593Smuzhiyun 	/* common message header */
813*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
814*4882a593Smuzhiyun 	/* completion message header */
815*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
816*4882a593Smuzhiyun 	/* event data len valid with the event buffer */
817*4882a593Smuzhiyun 	uint16			info_data_len;
818*4882a593Smuzhiyun 	/* sequence number */
819*4882a593Smuzhiyun 	uint16			seqnum;
820*4882a593Smuzhiyun 	/* destination */
821*4882a593Smuzhiyun 	uint8			dest;
822*4882a593Smuzhiyun 	/* rsvd	*/
823*4882a593Smuzhiyun 	uint8			rsvd[3];
824*4882a593Smuzhiyun 	/* XOR checksum or a magic number to audit DMA done */
825*4882a593Smuzhiyun 	dma_done_t		marker;
826*4882a593Smuzhiyun } info_buf_resp_t;
827*4882a593Smuzhiyun 
828*4882a593Smuzhiyun /* snapshot completion msg: send from device to host */
829*4882a593Smuzhiyun typedef struct snapshot_resp {
830*4882a593Smuzhiyun 	/* common message header */
831*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
832*4882a593Smuzhiyun 	/* completion message header */
833*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
834*4882a593Smuzhiyun 	/* snapshot length uploaded */
835*4882a593Smuzhiyun 	uint32			resp_len;
836*4882a593Smuzhiyun 	/* snapshot type */
837*4882a593Smuzhiyun 	uint8			type;
838*4882a593Smuzhiyun 	/* rsvd	*/
839*4882a593Smuzhiyun 	uint8			rsvd[3];
840*4882a593Smuzhiyun 	/* XOR checksum or a magic number to audit DMA done */
841*4882a593Smuzhiyun 	dma_done_t		marker;
842*4882a593Smuzhiyun } snapshot_resp_t;
843*4882a593Smuzhiyun 
844*4882a593Smuzhiyun typedef struct info_ring_cpl_item {
845*4882a593Smuzhiyun 	info_buf_resp_t		info_buf_post;
846*4882a593Smuzhiyun 	unsigned char		check[D2HRING_INFO_BUFCMPLT_ITEMSIZE];
847*4882a593Smuzhiyun } info_cpl_item_t;
848*4882a593Smuzhiyun 
849*4882a593Smuzhiyun typedef struct host_timestamp_msg_cpl {
850*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
851*4882a593Smuzhiyun 	compl_msg_hdr_t cmplt;
852*4882a593Smuzhiyun 	uint16			xt_id; /* transaction ID */
853*4882a593Smuzhiyun 	uint16			rsvd;
854*4882a593Smuzhiyun 	uint32			rsvd1;
855*4882a593Smuzhiyun 	/* XOR checksum or a magic number to audit DMA done */
856*4882a593Smuzhiyun 	dma_done_t      marker;
857*4882a593Smuzhiyun } host_timestamp_msg_cpl_t;
858*4882a593Smuzhiyun 
859*4882a593Smuzhiyun typedef struct fw_timestamp_event_msg {
860*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
861*4882a593Smuzhiyun 	compl_msg_hdr_t cmplt;
862*4882a593Smuzhiyun 	/* fw captures time stamp info and passed that to host in TLVs */
863*4882a593Smuzhiyun 	uint16			buf_len; /* length of the time stamp data copied in host buf */
864*4882a593Smuzhiyun 	uint16			seqnum; /* number of times fw captured time stamp */
865*4882a593Smuzhiyun 	uint32			rsvd;
866*4882a593Smuzhiyun 	/* XOR checksum or a magic number to audit DMA done */
867*4882a593Smuzhiyun 	dma_done_t		marker;
868*4882a593Smuzhiyun } fw_timestamp_event_msg_t;
869*4882a593Smuzhiyun 
870*4882a593Smuzhiyun typedef union ctrl_completion_item {
871*4882a593Smuzhiyun 	ioctl_comp_resp_msg_t		ioctl_resp;
872*4882a593Smuzhiyun 	wlevent_req_msg_t		event;
873*4882a593Smuzhiyun 	ioctl_req_ack_msg_t		ioct_ack;
874*4882a593Smuzhiyun 	pcie_dmaxfer_cmplt_t		pcie_xfer_cmplt;
875*4882a593Smuzhiyun 	pcie_gen_status_t		pcie_gen_status;
876*4882a593Smuzhiyun 	pcie_ring_status_t		pcie_ring_status;
877*4882a593Smuzhiyun 	tx_flowring_create_response_t	txfl_create_resp;
878*4882a593Smuzhiyun 	tx_flowring_delete_response_t	txfl_delete_resp;
879*4882a593Smuzhiyun 	tx_flowring_flush_response_t	txfl_flush_resp;
880*4882a593Smuzhiyun 	ctrl_compl_msg_t		ctrl_compl;
881*4882a593Smuzhiyun 	ring_config_resp_t		ring_config_resp;
882*4882a593Smuzhiyun 	d2h_mailbox_data_t		d2h_mailbox_data;
883*4882a593Smuzhiyun 	info_buf_resp_t			dbg_resp;
884*4882a593Smuzhiyun 	h2d_ring_create_response_t	h2d_ring_create_resp;
885*4882a593Smuzhiyun 	d2h_ring_create_response_t	d2h_ring_create_resp;
886*4882a593Smuzhiyun 	host_timestamp_msg_cpl_t	host_ts_cpl;
887*4882a593Smuzhiyun 	fw_timestamp_event_msg_t	fw_ts_event;
888*4882a593Smuzhiyun 	h2d_ring_delete_response_t	h2d_ring_delete_resp;
889*4882a593Smuzhiyun 	d2h_ring_delete_response_t	d2h_ring_delete_resp;
890*4882a593Smuzhiyun 	unsigned char			ctrl_response[D2HRING_CTRL_CMPLT_ITEMSIZE];
891*4882a593Smuzhiyun } ctrl_completion_item_t;
892*4882a593Smuzhiyun 
893*4882a593Smuzhiyun /** H2D Rxpost ring work items */
894*4882a593Smuzhiyun typedef struct host_rxbuf_post {
895*4882a593Smuzhiyun 	/** common message header */
896*4882a593Smuzhiyun 	cmn_msg_hdr_t   cmn_hdr;
897*4882a593Smuzhiyun 	/** provided meta data buffer len */
898*4882a593Smuzhiyun 	uint16		metadata_buf_len;
899*4882a593Smuzhiyun 	/** provided data buffer len to receive data */
900*4882a593Smuzhiyun 	uint16		data_buf_len;
901*4882a593Smuzhiyun 	/** alignment to make the host buffers start on 8 byte boundary */
902*4882a593Smuzhiyun 	uint32		rsvd;
903*4882a593Smuzhiyun 	/** provided meta data buffer */
904*4882a593Smuzhiyun 	bcm_addr64_t	metadata_buf_addr;
905*4882a593Smuzhiyun 	/** provided data buffer to receive data */
906*4882a593Smuzhiyun 	bcm_addr64_t	data_buf_addr;
907*4882a593Smuzhiyun } host_rxbuf_post_t;
908*4882a593Smuzhiyun 
909*4882a593Smuzhiyun typedef union rxbuf_submit_item {
910*4882a593Smuzhiyun 	host_rxbuf_post_t	rxpost;
911*4882a593Smuzhiyun 	unsigned char		check[H2DRING_RXPOST_ITEMSIZE];
912*4882a593Smuzhiyun } rxbuf_submit_item_t;
913*4882a593Smuzhiyun 
914*4882a593Smuzhiyun /* D2H Rxcompletion ring work items for IPC rev7 */
915*4882a593Smuzhiyun typedef struct host_rxbuf_cmpl {
916*4882a593Smuzhiyun 	/** common message header */
917*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
918*4882a593Smuzhiyun 	/** completion message header */
919*4882a593Smuzhiyun 	compl_msg_hdr_t	compl_hdr;
920*4882a593Smuzhiyun 	/**  filled up meta data len */
921*4882a593Smuzhiyun 	uint16		metadata_len;
922*4882a593Smuzhiyun 	/** filled up buffer len to receive data */
923*4882a593Smuzhiyun 	uint16		data_len;
924*4882a593Smuzhiyun 	/** offset in the host rx buffer where the data starts */
925*4882a593Smuzhiyun 	uint16		data_offset;
926*4882a593Smuzhiyun 	/** Flags */
927*4882a593Smuzhiyun 	uint16		flags;
928*4882a593Smuzhiyun 	/** rx status */
929*4882a593Smuzhiyun 	uint32		rx_status_0;
930*4882a593Smuzhiyun 	uint32		rx_status_1;
931*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
932*4882a593Smuzhiyun 	/* This is for rev6 only. For IPC rev7, this is a reserved field */
933*4882a593Smuzhiyun 	dma_done_t	marker;
934*4882a593Smuzhiyun 	/* timestamp */
935*4882a593Smuzhiyun 	ipc_timestamp_t ts;
936*4882a593Smuzhiyun } host_rxbuf_cmpl_t;
937*4882a593Smuzhiyun 
938*4882a593Smuzhiyun typedef union rxbuf_complete_item {
939*4882a593Smuzhiyun 	host_rxbuf_cmpl_t	rxcmpl;
940*4882a593Smuzhiyun 	unsigned char		check[D2HRING_RXCMPLT_ITEMSIZE];
941*4882a593Smuzhiyun } rxbuf_complete_item_t;
942*4882a593Smuzhiyun 
943*4882a593Smuzhiyun typedef struct host_txbuf_post {
944*4882a593Smuzhiyun 	/** common message header */
945*4882a593Smuzhiyun 	cmn_msg_hdr_t   cmn_hdr;
946*4882a593Smuzhiyun 	/** eth header */
947*4882a593Smuzhiyun 	uint8		txhdr[ETHER_HDR_LEN];
948*4882a593Smuzhiyun 	/** flags */
949*4882a593Smuzhiyun 	uint8		flags;
950*4882a593Smuzhiyun 	/** number of segments */
951*4882a593Smuzhiyun 	uint8		seg_cnt;
952*4882a593Smuzhiyun 
953*4882a593Smuzhiyun 	/** provided meta data buffer for txstatus */
954*4882a593Smuzhiyun 	bcm_addr64_t	metadata_buf_addr;
955*4882a593Smuzhiyun 	/** provided data buffer to receive data */
956*4882a593Smuzhiyun 	bcm_addr64_t	data_buf_addr;
957*4882a593Smuzhiyun 	/** provided meta data buffer len */
958*4882a593Smuzhiyun 	uint16		metadata_buf_len;
959*4882a593Smuzhiyun 	/** provided data buffer len to receive data */
960*4882a593Smuzhiyun 	uint16		data_len;
961*4882a593Smuzhiyun 	union {
962*4882a593Smuzhiyun 		struct {
963*4882a593Smuzhiyun 			/** extended transmit flags */
964*4882a593Smuzhiyun 			uint8 ext_flags;
965*4882a593Smuzhiyun 			uint8 rsvd1;
966*4882a593Smuzhiyun 
967*4882a593Smuzhiyun 			/** user defined rate */
968*4882a593Smuzhiyun 			uint8 rate;
969*4882a593Smuzhiyun 			uint8 exp_time;
970*4882a593Smuzhiyun 		};
971*4882a593Smuzhiyun 		/** XOR checksum or a magic number to audit DMA done */
972*4882a593Smuzhiyun 		dma_done_t	marker;
973*4882a593Smuzhiyun 	};
974*4882a593Smuzhiyun } host_txbuf_post_t;
975*4882a593Smuzhiyun 
976*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_802_3	0x01
977*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_802_11	0x02
978*4882a593Smuzhiyun 
979*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_NORETRY		0x01	/* Disable retry on this frame */
980*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_NOAGGR		0x02	/* Disable aggregation for this frame */
981*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_UDR		0x04	/* User defined rate for this frame */
982*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_ATTR_MASK	0x07	/* Attribute mask */
983*4882a593Smuzhiyun 
984*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_EXEMPT_MASK	0x03	/* Exempt uses 2 bits */
985*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_EXEMPT_SHIFT	0x02	/* needs to be shifted past other bits */
986*4882a593Smuzhiyun 
987*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_PRIO_SHIFT		5
988*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_PRIO_MASK		(7 << BCMPCIE_PKT_FLAGS_PRIO_SHIFT)
989*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_NO_AMSDU	0x00
990*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_FIRST_PKT	0x01
991*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_INTER_PKT	0x02
992*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_LAST_PKT	0x03
993*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_NO_FORWARD		0x04
994*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_SHIFT		8
995*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_MASK		(3 << BCMPCIE_PKT_FLAGS_MONITOR_SHIFT)
996*4882a593Smuzhiyun 
997*4882a593Smuzhiyun /* These are added to fix up compile issues */
998*4882a593Smuzhiyun #define BCMPCIE_TXPOST_FLAGS_FRAME_802_3	BCMPCIE_PKT_FLAGS_FRAME_802_3
999*4882a593Smuzhiyun #define BCMPCIE_TXPOST_FLAGS_FRAME_802_11	BCMPCIE_PKT_FLAGS_FRAME_802_11
1000*4882a593Smuzhiyun #define BCMPCIE_TXPOST_FLAGS_PRIO_SHIFT		BCMPCIE_PKT_FLAGS_PRIO_SHIFT
1001*4882a593Smuzhiyun #define BCMPCIE_TXPOST_FLAGS_PRIO_MASK		BCMPCIE_PKT_FLAGS_PRIO_MASK
1002*4882a593Smuzhiyun 
1003*4882a593Smuzhiyun /* H2D Txpost ring work items */
1004*4882a593Smuzhiyun typedef union txbuf_submit_item {
1005*4882a593Smuzhiyun 	host_txbuf_post_t	txpost;
1006*4882a593Smuzhiyun 	unsigned char		check[H2DRING_TXPOST_ITEMSIZE];
1007*4882a593Smuzhiyun } txbuf_submit_item_t;
1008*4882a593Smuzhiyun 
1009*4882a593Smuzhiyun /* D2H Txcompletion ring work items - extended for IOC rev7 */
1010*4882a593Smuzhiyun typedef struct host_txbuf_cmpl {
1011*4882a593Smuzhiyun 	/** common message header */
1012*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
1013*4882a593Smuzhiyun 	/** completion message header */
1014*4882a593Smuzhiyun 	compl_msg_hdr_t	compl_hdr;
1015*4882a593Smuzhiyun 	union {
1016*4882a593Smuzhiyun 		struct {
1017*4882a593Smuzhiyun 			union {
1018*4882a593Smuzhiyun 				/** provided meta data len */
1019*4882a593Smuzhiyun 				uint16	metadata_len;
1020*4882a593Smuzhiyun 				/** provided extended TX status */
1021*4882a593Smuzhiyun 				uint16	tx_status_ext;
1022*4882a593Smuzhiyun 			};
1023*4882a593Smuzhiyun 			/** WLAN side txstatus */
1024*4882a593Smuzhiyun 			uint16	tx_status;
1025*4882a593Smuzhiyun 		};
1026*4882a593Smuzhiyun 		/** XOR checksum or a magic number to audit DMA done */
1027*4882a593Smuzhiyun 		/* This is for rev6 only. For IPC rev7, this is not used */
1028*4882a593Smuzhiyun 		dma_done_t	marker;
1029*4882a593Smuzhiyun 	};
1030*4882a593Smuzhiyun 	/* timestamp */
1031*4882a593Smuzhiyun 	ipc_timestamp_t ts;
1032*4882a593Smuzhiyun 
1033*4882a593Smuzhiyun } host_txbuf_cmpl_t;
1034*4882a593Smuzhiyun 
1035*4882a593Smuzhiyun typedef union txbuf_complete_item {
1036*4882a593Smuzhiyun 	host_txbuf_cmpl_t	txcmpl;
1037*4882a593Smuzhiyun 	unsigned char		check[D2HRING_TXCMPLT_ITEMSIZE];
1038*4882a593Smuzhiyun } txbuf_complete_item_t;
1039*4882a593Smuzhiyun 
1040*4882a593Smuzhiyun #define BCMPCIE_D2H_METADATA_HDRLEN	4
1041*4882a593Smuzhiyun #define BCMPCIE_D2H_METADATA_MINLEN	(BCMPCIE_D2H_METADATA_HDRLEN + 4)
1042*4882a593Smuzhiyun 
1043*4882a593Smuzhiyun /** ret buf struct */
1044*4882a593Smuzhiyun typedef struct ret_buf_ptr {
1045*4882a593Smuzhiyun 	uint32 low_addr;
1046*4882a593Smuzhiyun 	uint32 high_addr;
1047*4882a593Smuzhiyun } ret_buf_t;
1048*4882a593Smuzhiyun 
1049*4882a593Smuzhiyun #ifdef PCIE_API_REV1
1050*4882a593Smuzhiyun 
1051*4882a593Smuzhiyun /* ioctl specific hdr */
1052*4882a593Smuzhiyun typedef struct ioctl_hdr {
1053*4882a593Smuzhiyun 	uint16		cmd;
1054*4882a593Smuzhiyun 	uint16		retbuf_len;
1055*4882a593Smuzhiyun 	uint32		cmd_id;
1056*4882a593Smuzhiyun } ioctl_hdr_t;
1057*4882a593Smuzhiyun 
1058*4882a593Smuzhiyun typedef struct ioctlptr_hdr {
1059*4882a593Smuzhiyun 	uint16		cmd;
1060*4882a593Smuzhiyun 	uint16		retbuf_len;
1061*4882a593Smuzhiyun 	uint16		buflen;
1062*4882a593Smuzhiyun 	uint16		rsvd;
1063*4882a593Smuzhiyun 	uint32		cmd_id;
1064*4882a593Smuzhiyun } ioctlptr_hdr_t;
1065*4882a593Smuzhiyun 
1066*4882a593Smuzhiyun #else /* PCIE_API_REV1 */
1067*4882a593Smuzhiyun 
1068*4882a593Smuzhiyun typedef struct ioctl_req_hdr {
1069*4882a593Smuzhiyun 	uint32		pkt_id;	/**< Packet ID */
1070*4882a593Smuzhiyun 	uint32		cmd;	/**< IOCTL ID */
1071*4882a593Smuzhiyun 	uint16		retbuf_len;
1072*4882a593Smuzhiyun 	uint16		buflen;
1073*4882a593Smuzhiyun 	uint16		xt_id;	/**< transaction ID */
1074*4882a593Smuzhiyun 	uint16		rsvd[1];
1075*4882a593Smuzhiyun } ioctl_req_hdr_t;
1076*4882a593Smuzhiyun 
1077*4882a593Smuzhiyun #endif /* PCIE_API_REV1 */
1078*4882a593Smuzhiyun 
1079*4882a593Smuzhiyun /** Complete msgbuf hdr for ioctl from host to dongle */
1080*4882a593Smuzhiyun typedef struct ioct_reqst_hdr {
1081*4882a593Smuzhiyun 	cmn_msg_hdr_t msg;
1082*4882a593Smuzhiyun #ifdef PCIE_API_REV1
1083*4882a593Smuzhiyun 	ioctl_hdr_t ioct_hdr;
1084*4882a593Smuzhiyun #else
1085*4882a593Smuzhiyun 	ioctl_req_hdr_t ioct_hdr;
1086*4882a593Smuzhiyun #endif // endif
1087*4882a593Smuzhiyun 	ret_buf_t ret_buf;
1088*4882a593Smuzhiyun } ioct_reqst_hdr_t;
1089*4882a593Smuzhiyun 
1090*4882a593Smuzhiyun typedef struct ioctptr_reqst_hdr {
1091*4882a593Smuzhiyun 	cmn_msg_hdr_t msg;
1092*4882a593Smuzhiyun #ifdef PCIE_API_REV1
1093*4882a593Smuzhiyun 	ioctlptr_hdr_t ioct_hdr;
1094*4882a593Smuzhiyun #else
1095*4882a593Smuzhiyun 	ioctl_req_hdr_t ioct_hdr;
1096*4882a593Smuzhiyun #endif // endif
1097*4882a593Smuzhiyun 	ret_buf_t ret_buf;
1098*4882a593Smuzhiyun 	ret_buf_t ioct_buf;
1099*4882a593Smuzhiyun } ioctptr_reqst_hdr_t;
1100*4882a593Smuzhiyun 
1101*4882a593Smuzhiyun /** ioctl response header */
1102*4882a593Smuzhiyun typedef struct ioct_resp_hdr {
1103*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1104*4882a593Smuzhiyun #ifdef PCIE_API_REV1
1105*4882a593Smuzhiyun 	uint32	cmd_id;
1106*4882a593Smuzhiyun #else
1107*4882a593Smuzhiyun 	uint32	pkt_id;
1108*4882a593Smuzhiyun #endif // endif
1109*4882a593Smuzhiyun 	uint32	status;
1110*4882a593Smuzhiyun 	uint32	ret_len;
1111*4882a593Smuzhiyun 	uint32  inline_data;
1112*4882a593Smuzhiyun #ifdef PCIE_API_REV1
1113*4882a593Smuzhiyun #else
1114*4882a593Smuzhiyun 	uint16	xt_id;	/**< transaction ID */
1115*4882a593Smuzhiyun 	uint16	rsvd[1];
1116*4882a593Smuzhiyun #endif // endif
1117*4882a593Smuzhiyun } ioct_resp_hdr_t;
1118*4882a593Smuzhiyun 
1119*4882a593Smuzhiyun /* ioct resp header used in dongle */
1120*4882a593Smuzhiyun /* ret buf hdr will be stripped off inside dongle itself */
1121*4882a593Smuzhiyun typedef struct msgbuf_ioctl_resp {
1122*4882a593Smuzhiyun 	ioct_resp_hdr_t	ioct_hdr;
1123*4882a593Smuzhiyun 	ret_buf_t	ret_buf;	/**< ret buf pointers */
1124*4882a593Smuzhiyun } msgbuf_ioct_resp_t;
1125*4882a593Smuzhiyun 
1126*4882a593Smuzhiyun /** WL event hdr info */
1127*4882a593Smuzhiyun typedef struct wl_event_hdr {
1128*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1129*4882a593Smuzhiyun 	uint16 event;
1130*4882a593Smuzhiyun 	uint8 flags;
1131*4882a593Smuzhiyun 	uint8 rsvd;
1132*4882a593Smuzhiyun 	uint16 retbuf_len;
1133*4882a593Smuzhiyun 	uint16 rsvd1;
1134*4882a593Smuzhiyun 	uint32 rxbufid;
1135*4882a593Smuzhiyun } wl_event_hdr_t;
1136*4882a593Smuzhiyun 
1137*4882a593Smuzhiyun #define TXDESCR_FLOWID_PCIELPBK_1	0xFF
1138*4882a593Smuzhiyun #define TXDESCR_FLOWID_PCIELPBK_2	0xFE
1139*4882a593Smuzhiyun 
1140*4882a593Smuzhiyun typedef struct txbatch_lenptr_tup {
1141*4882a593Smuzhiyun 	uint32 pktid;
1142*4882a593Smuzhiyun 	uint16 pktlen;
1143*4882a593Smuzhiyun 	uint16 rsvd;
1144*4882a593Smuzhiyun 	ret_buf_t	ret_buf;	/**< ret buf pointers */
1145*4882a593Smuzhiyun } txbatch_lenptr_tup_t;
1146*4882a593Smuzhiyun 
1147*4882a593Smuzhiyun typedef struct txbatch_cmn_msghdr {
1148*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1149*4882a593Smuzhiyun 	uint8 priority;
1150*4882a593Smuzhiyun 	uint8 hdrlen;
1151*4882a593Smuzhiyun 	uint8 pktcnt;
1152*4882a593Smuzhiyun 	uint8 flowid;
1153*4882a593Smuzhiyun 	uint8 txhdr[ETHER_HDR_LEN];
1154*4882a593Smuzhiyun 	uint16 rsvd;
1155*4882a593Smuzhiyun } txbatch_cmn_msghdr_t;
1156*4882a593Smuzhiyun 
1157*4882a593Smuzhiyun typedef struct txbatch_msghdr {
1158*4882a593Smuzhiyun 	txbatch_cmn_msghdr_t txcmn;
1159*4882a593Smuzhiyun 	txbatch_lenptr_tup_t tx_tup[0]; /**< Based on packet count */
1160*4882a593Smuzhiyun } txbatch_msghdr_t;
1161*4882a593Smuzhiyun 
1162*4882a593Smuzhiyun /* TX desc posting header */
1163*4882a593Smuzhiyun typedef struct tx_lenptr_tup {
1164*4882a593Smuzhiyun 	uint16 pktlen;
1165*4882a593Smuzhiyun 	uint16 rsvd;
1166*4882a593Smuzhiyun 	ret_buf_t	ret_buf;	/**< ret buf pointers */
1167*4882a593Smuzhiyun } tx_lenptr_tup_t;
1168*4882a593Smuzhiyun 
1169*4882a593Smuzhiyun typedef struct txdescr_cmn_msghdr {
1170*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1171*4882a593Smuzhiyun 	uint8 priority;
1172*4882a593Smuzhiyun 	uint8 hdrlen;
1173*4882a593Smuzhiyun 	uint8 descrcnt;
1174*4882a593Smuzhiyun 	uint8 flowid;
1175*4882a593Smuzhiyun 	uint32 pktid;
1176*4882a593Smuzhiyun } txdescr_cmn_msghdr_t;
1177*4882a593Smuzhiyun 
1178*4882a593Smuzhiyun typedef struct txdescr_msghdr {
1179*4882a593Smuzhiyun 	txdescr_cmn_msghdr_t txcmn;
1180*4882a593Smuzhiyun 	uint8 txhdr[ETHER_HDR_LEN];
1181*4882a593Smuzhiyun 	uint16 rsvd;
1182*4882a593Smuzhiyun 	tx_lenptr_tup_t tx_tup[0];	/**< Based on descriptor count */
1183*4882a593Smuzhiyun } txdescr_msghdr_t;
1184*4882a593Smuzhiyun 
1185*4882a593Smuzhiyun /** Tx status header info */
1186*4882a593Smuzhiyun typedef struct txstatus_hdr {
1187*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1188*4882a593Smuzhiyun 	uint32 pktid;
1189*4882a593Smuzhiyun } txstatus_hdr_t;
1190*4882a593Smuzhiyun 
1191*4882a593Smuzhiyun /** RX bufid-len-ptr tuple */
1192*4882a593Smuzhiyun typedef struct rx_lenptr_tup {
1193*4882a593Smuzhiyun 	uint32 rxbufid;
1194*4882a593Smuzhiyun 	uint16 len;
1195*4882a593Smuzhiyun 	uint16 rsvd2;
1196*4882a593Smuzhiyun 	ret_buf_t	ret_buf;	/**< ret buf pointers */
1197*4882a593Smuzhiyun } rx_lenptr_tup_t;
1198*4882a593Smuzhiyun 
1199*4882a593Smuzhiyun /** Rx descr Post hdr info */
1200*4882a593Smuzhiyun typedef struct rxdesc_msghdr {
1201*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1202*4882a593Smuzhiyun 	uint16 rsvd0;
1203*4882a593Smuzhiyun 	uint8 rsvd1;
1204*4882a593Smuzhiyun 	uint8 descnt;
1205*4882a593Smuzhiyun 	rx_lenptr_tup_t rx_tup[0];
1206*4882a593Smuzhiyun } rxdesc_msghdr_t;
1207*4882a593Smuzhiyun 
1208*4882a593Smuzhiyun /** RX complete tuples */
1209*4882a593Smuzhiyun typedef struct rxcmplt_tup {
1210*4882a593Smuzhiyun 	uint16 retbuf_len;
1211*4882a593Smuzhiyun 	uint16 data_offset;
1212*4882a593Smuzhiyun 	uint32 rxstatus0;
1213*4882a593Smuzhiyun 	uint32 rxstatus1;
1214*4882a593Smuzhiyun 	uint32 rxbufid;
1215*4882a593Smuzhiyun } rxcmplt_tup_t;
1216*4882a593Smuzhiyun 
1217*4882a593Smuzhiyun /** RX complete messge hdr */
1218*4882a593Smuzhiyun typedef struct rxcmplt_hdr {
1219*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1220*4882a593Smuzhiyun 	uint16 rsvd0;
1221*4882a593Smuzhiyun 	uint16 rxcmpltcnt;
1222*4882a593Smuzhiyun 	rxcmplt_tup_t rx_tup[0];
1223*4882a593Smuzhiyun } rxcmplt_hdr_t;
1224*4882a593Smuzhiyun 
1225*4882a593Smuzhiyun typedef struct hostevent_hdr {
1226*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1227*4882a593Smuzhiyun 	uint32 evnt_pyld;
1228*4882a593Smuzhiyun } hostevent_hdr_t;
1229*4882a593Smuzhiyun 
1230*4882a593Smuzhiyun typedef struct dma_xfer_params {
1231*4882a593Smuzhiyun 	uint32 src_physaddr_hi;
1232*4882a593Smuzhiyun 	uint32 src_physaddr_lo;
1233*4882a593Smuzhiyun 	uint32 dest_physaddr_hi;
1234*4882a593Smuzhiyun 	uint32 dest_physaddr_lo;
1235*4882a593Smuzhiyun 	uint32 len;
1236*4882a593Smuzhiyun 	uint32 srcdelay;
1237*4882a593Smuzhiyun 	uint32 destdelay;
1238*4882a593Smuzhiyun } dma_xfer_params_t;
1239*4882a593Smuzhiyun 
1240*4882a593Smuzhiyun enum {
1241*4882a593Smuzhiyun 	HOST_EVENT_CONS_CMD = 1
1242*4882a593Smuzhiyun };
1243*4882a593Smuzhiyun 
1244*4882a593Smuzhiyun /* defines for flags */
1245*4882a593Smuzhiyun #define MSGBUF_IOC_ACTION_MASK 0x1
1246*4882a593Smuzhiyun 
1247*4882a593Smuzhiyun #define MAX_SUSPEND_REQ 15
1248*4882a593Smuzhiyun 
1249*4882a593Smuzhiyun typedef struct tx_idle_flowring_suspend_request {
1250*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1251*4882a593Smuzhiyun 	uint16	ring_id[MAX_SUSPEND_REQ];      /* ring Id's */
1252*4882a593Smuzhiyun 	uint16	num;	/* number of flowid's to suspend */
1253*4882a593Smuzhiyun } tx_idle_flowring_suspend_request_t;
1254*4882a593Smuzhiyun 
1255*4882a593Smuzhiyun typedef struct tx_idle_flowring_suspend_response {
1256*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
1257*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
1258*4882a593Smuzhiyun 	uint32			rsvd[2];
1259*4882a593Smuzhiyun 	dma_done_t		marker;
1260*4882a593Smuzhiyun } tx_idle_flowring_suspend_response_t;
1261*4882a593Smuzhiyun 
1262*4882a593Smuzhiyun typedef struct tx_idle_flowring_resume_request {
1263*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1264*4882a593Smuzhiyun 	uint16	flow_ring_id;
1265*4882a593Smuzhiyun 	uint16	reason;
1266*4882a593Smuzhiyun 	uint32	rsvd[7];
1267*4882a593Smuzhiyun } tx_idle_flowring_resume_request_t;
1268*4882a593Smuzhiyun 
1269*4882a593Smuzhiyun typedef struct tx_idle_flowring_resume_response {
1270*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
1271*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
1272*4882a593Smuzhiyun 	uint32			rsvd[2];
1273*4882a593Smuzhiyun 	dma_done_t		marker;
1274*4882a593Smuzhiyun } tx_idle_flowring_resume_response_t;
1275*4882a593Smuzhiyun 
1276*4882a593Smuzhiyun /* timesync related additions */
1277*4882a593Smuzhiyun 
1278*4882a593Smuzhiyun typedef struct _bcm_xtlv {
1279*4882a593Smuzhiyun 	uint16		id; /* TLV idenitifier */
1280*4882a593Smuzhiyun 	uint16		len; /* TLV length in bytes */
1281*4882a593Smuzhiyun } _bcm_xtlv_t;
1282*4882a593Smuzhiyun 
1283*4882a593Smuzhiyun #define BCMMSGBUF_FW_CLOCK_INFO_TAG		0
1284*4882a593Smuzhiyun #define BCMMSGBUF_HOST_CLOCK_INFO_TAG		1
1285*4882a593Smuzhiyun #define BCMMSGBUF_HOST_CLOCK_SELECT_TAG		2
1286*4882a593Smuzhiyun #define BCMMSGBUF_D2H_CLOCK_CORRECTION_TAG	3
1287*4882a593Smuzhiyun #define BCMMSGBUF_HOST_TIMESTAMPING_CONFIG_TAG	4
1288*4882a593Smuzhiyun #define BCMMSGBUF_MAX_TSYNC_TAG			5
1289*4882a593Smuzhiyun 
1290*4882a593Smuzhiyun /* Flags in fw clock info TLV */
1291*4882a593Smuzhiyun #define CAP_DEVICE_TS		(1 << 0)
1292*4882a593Smuzhiyun #define CAP_CORRECTED_TS	(1 << 1)
1293*4882a593Smuzhiyun #define TS_CLK_ACTIVE		(1 << 2)
1294*4882a593Smuzhiyun 
1295*4882a593Smuzhiyun typedef struct ts_fw_clock_info {
1296*4882a593Smuzhiyun 	_bcm_xtlv_t  xtlv; /* BCMMSGBUF_FW_CLOCK_INFO_TAG */
1297*4882a593Smuzhiyun 	ts_timestamp_srcid_t  ts; /* tick count */
1298*4882a593Smuzhiyun 	uchar		clk_src[4]; /* clock source acronym ILP/AVB/TSF */
1299*4882a593Smuzhiyun 	uint32		nominal_clock_freq;
1300*4882a593Smuzhiyun 	uint32		reset_cnt;
1301*4882a593Smuzhiyun 	uint8		flags;
1302*4882a593Smuzhiyun 	uint8		rsvd[3];
1303*4882a593Smuzhiyun } ts_fw_clock_info_t;
1304*4882a593Smuzhiyun 
1305*4882a593Smuzhiyun typedef struct ts_host_clock_info {
1306*4882a593Smuzhiyun 	_bcm_xtlv_t  xtlv; /* BCMMSGBUF_HOST_CLOCK_INFO_TAG */
1307*4882a593Smuzhiyun 	tick_count_64_t ticks; /* 64 bit host tick counter */
1308*4882a593Smuzhiyun 	ts_timestamp_ns_64_t ns; /* 64 bit host time in nano seconds */
1309*4882a593Smuzhiyun } ts_host_clock_info_t;
1310*4882a593Smuzhiyun 
1311*4882a593Smuzhiyun typedef struct ts_host_clock_sel {
1312*4882a593Smuzhiyun 	_bcm_xtlv_t	xtlv; /* BCMMSGBUF_HOST_CLOCK_SELECT_TAG */
1313*4882a593Smuzhiyun 	uint32		seqnum; /* number of times GPIO time sync toggled */
1314*4882a593Smuzhiyun 	uint8		min_clk_idx; /* clock idenitifer configured for packet tiem stamping */
1315*4882a593Smuzhiyun 	uint8		max_clk_idx; /* clock idenitifer configured for packet tiem stamping */
1316*4882a593Smuzhiyun 	uint16		rsvd[1];
1317*4882a593Smuzhiyun } ts_host_clock_sel_t;
1318*4882a593Smuzhiyun 
1319*4882a593Smuzhiyun typedef struct ts_d2h_clock_correction {
1320*4882a593Smuzhiyun 	_bcm_xtlv_t		xtlv; /* BCMMSGBUF_HOST_CLOCK_INFO_TAG */
1321*4882a593Smuzhiyun 	uint8			clk_id; /* clock source in the device */
1322*4882a593Smuzhiyun 	uint8			rsvd[3];
1323*4882a593Smuzhiyun 	ts_correction_m_t	m;	/* y  = 'm' x + b */
1324*4882a593Smuzhiyun 	ts_correction_b_t	b;	/* y  = 'm' x + 'c' */
1325*4882a593Smuzhiyun } ts_d2h_clock_correction_t;
1326*4882a593Smuzhiyun 
1327*4882a593Smuzhiyun typedef struct ts_host_timestamping_config {
1328*4882a593Smuzhiyun 	_bcm_xtlv_t		xtlv; /* BCMMSGBUF_HOST_TIMESTAMPING_CONFIG_TAG */
1329*4882a593Smuzhiyun 	/* time period to capture the device time stamp and toggle WLAN_TIME_SYNC_GPIO */
1330*4882a593Smuzhiyun 	uint16			period_ms;
1331*4882a593Smuzhiyun 	uint8			flags;
1332*4882a593Smuzhiyun 	uint8			post_delay;
1333*4882a593Smuzhiyun 	uint32			reset_cnt;
1334*4882a593Smuzhiyun } ts_host_timestamping_config_t;
1335*4882a593Smuzhiyun 
1336*4882a593Smuzhiyun /* Flags in host timestamping config TLV */
1337*4882a593Smuzhiyun #define FLAG_HOST_RESET		(1 << 0)
1338*4882a593Smuzhiyun #define IS_HOST_RESET(x)	((x) & FLAG_HOST_RESET)
1339*4882a593Smuzhiyun #define CLEAR_HOST_RESET(x)	((x) & ~FLAG_HOST_RESET)
1340*4882a593Smuzhiyun 
1341*4882a593Smuzhiyun #define FLAG_CONFIG_NODROP	(1 << 1)
1342*4882a593Smuzhiyun #define IS_CONFIG_NODROP(x)	((x) & FLAG_CONFIG_NODROP)
1343*4882a593Smuzhiyun #define CLEAR_CONFIG_NODROP(x)	((x) & ~FLAG_CONFIG_NODROP)
1344*4882a593Smuzhiyun 
1345*4882a593Smuzhiyun #endif /* _bcmmsgbuf_h_ */
1346