xref: /OK3568_Linux_fs/external/rkwifibt/drivers/bcmdhd/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  * Copyright (C) 2020, Broadcom.
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  *      Unless you and Broadcom execute a separate written software license
10*4882a593Smuzhiyun  * agreement governing use of this software, this software is licensed to you
11*4882a593Smuzhiyun  * under the terms of the GNU General Public License version 2 (the "GPL"),
12*4882a593Smuzhiyun  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
13*4882a593Smuzhiyun  * following added to such license:
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  *      As a special exception, the copyright holders of this software give you
16*4882a593Smuzhiyun  * permission to link this software with independent modules, and to copy and
17*4882a593Smuzhiyun  * distribute the resulting executable under terms of your choice, provided that
18*4882a593Smuzhiyun  * you also meet, for each linked independent module, the terms and conditions of
19*4882a593Smuzhiyun  * the license of that module.  An independent module is a module which is not
20*4882a593Smuzhiyun  * derived from this software.  The special exception does not apply to any
21*4882a593Smuzhiyun  * modifications of the software.
22*4882a593Smuzhiyun  *
23*4882a593Smuzhiyun  *
24*4882a593Smuzhiyun  * <<Broadcom-WL-IPTag/Dual:>>
25*4882a593Smuzhiyun  */
26*4882a593Smuzhiyun #ifndef _bcmmsgbuf_h_
27*4882a593Smuzhiyun #define	_bcmmsgbuf_h_
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun #include <ethernet.h>
30*4882a593Smuzhiyun #include <wlioctl.h>
31*4882a593Smuzhiyun #include <bcmpcie.h>
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #define MSGBUF_MAX_MSG_SIZE   ETHER_MAX_LEN
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #define D2H_EPOCH_MODULO		253 /* sequence number wrap */
36*4882a593Smuzhiyun #define D2H_EPOCH_INIT_VAL		(D2H_EPOCH_MODULO + 1)
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #define H2D_EPOCH_MODULO		253 /* sequence number wrap */
39*4882a593Smuzhiyun #define H2D_EPOCH_INIT_VAL		(H2D_EPOCH_MODULO + 1)
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun /* Txpost base workitem size w/o any extended tags */
42*4882a593Smuzhiyun #define H2DRING_TXPOST_BASE_ITEMSIZE	48u
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun /*
45*4882a593Smuzhiyun  * The workitem size - H2DRING_TXPOST_ITEMSIZE is fixed at compile time
46*4882a593Smuzhiyun  * only for FW, depending on the BCMPCIE_EXT_TXPOST_SUPPORT flag.
47*4882a593Smuzhiyun  * For DHD the work item size is decided dynamically based on
48*4882a593Smuzhiyun  * the dongle capability announced in the PCIE_SHARED2 flags which
49*4882a593Smuzhiyun  * is read by DHD during dhdpcie_readshared(). Because this
50*4882a593Smuzhiyun  * happens before DHD allocs memory for the flowrings, the workitem
51*4882a593Smuzhiyun  * size can be dynamic for DHD.
52*4882a593Smuzhiyun  */
53*4882a593Smuzhiyun #define H2DRING_TXPOST_EXT_ITEMSIZE	56
54*4882a593Smuzhiyun #if defined(BCMPCIE_EXT_TXPOST_SUPPORT)
55*4882a593Smuzhiyun #define H2DRING_TXPOST_ITEMSIZE		H2DRING_TXPOST_EXT_ITEMSIZE
56*4882a593Smuzhiyun #else
57*4882a593Smuzhiyun #define H2DRING_TXPOST_ITEMSIZE		H2DRING_TXPOST_BASE_ITEMSIZE
58*4882a593Smuzhiyun #endif
59*4882a593Smuzhiyun #define H2DRING_RXPOST_ITEMSIZE		32
60*4882a593Smuzhiyun #define H2DRING_CTRL_SUB_ITEMSIZE	40
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun #define D2HRING_TXCMPLT_ITEMSIZE	24
63*4882a593Smuzhiyun #define D2HRING_RXCMPLT_ITEMSIZE	40
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun #define D2HRING_TXCMPLT_ITEMSIZE_PREREV7	16
66*4882a593Smuzhiyun #define D2HRING_RXCMPLT_ITEMSIZE_PREREV7	32
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun #define D2HRING_CTRL_CMPLT_ITEMSIZE	24
69*4882a593Smuzhiyun #define H2DRING_INFO_BUFPOST_ITEMSIZE	H2DRING_CTRL_SUB_ITEMSIZE
70*4882a593Smuzhiyun #define D2HRING_INFO_BUFCMPLT_ITEMSIZE	D2HRING_CTRL_CMPLT_ITEMSIZE
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun #define D2HRING_SNAPSHOT_CMPLT_ITEMSIZE		20
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun #define H2DRING_DYNAMIC_INFO_MAX_ITEM          32
75*4882a593Smuzhiyun #define D2HRING_DYNAMIC_INFO_MAX_ITEM          32
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun #define H2DRING_TXPOST_MAX_ITEM			512
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun #if defined(DHD_HTPUT_TUNABLES)
80*4882a593Smuzhiyun #define H2DRING_RXPOST_MAX_ITEM			2048
81*4882a593Smuzhiyun #define D2HRING_RXCMPLT_MAX_ITEM		1024
82*4882a593Smuzhiyun #define D2HRING_TXCMPLT_MAX_ITEM		2048
83*4882a593Smuzhiyun /* Only few htput flowrings use htput max items, other use normal max items */
84*4882a593Smuzhiyun #define H2DRING_HTPUT_TXPOST_MAX_ITEM		2048
85*4882a593Smuzhiyun #define H2DRING_CTRL_SUB_MAX_ITEM		128
86*4882a593Smuzhiyun #else
87*4882a593Smuzhiyun #define H2DRING_RXPOST_MAX_ITEM			512
88*4882a593Smuzhiyun #define D2HRING_TXCMPLT_MAX_ITEM		1024
89*4882a593Smuzhiyun #define D2HRING_RXCMPLT_MAX_ITEM		512
90*4882a593Smuzhiyun #define H2DRING_CTRL_SUB_MAX_ITEM		64
91*4882a593Smuzhiyun #endif /* DHD_HTPUT_TUNABLES */
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun #define D2HRING_EDL_HDR_SIZE			48u
94*4882a593Smuzhiyun #define D2HRING_EDL_ITEMSIZE			2048u
95*4882a593Smuzhiyun #define D2HRING_EDL_MAX_ITEM			256u
96*4882a593Smuzhiyun #define D2HRING_EDL_WATERMARK			(D2HRING_EDL_MAX_ITEM >> 5u)
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun #ifdef BCM_ROUTER_DHD
99*4882a593Smuzhiyun #define D2HRING_CTRL_CMPLT_MAX_ITEM		256
100*4882a593Smuzhiyun #else
101*4882a593Smuzhiyun #define D2HRING_CTRL_CMPLT_MAX_ITEM		64
102*4882a593Smuzhiyun #endif
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun /* Max pktids for each type of pkt, shared between host and dongle */
105*4882a593Smuzhiyun #define MAX_PKTID_CTRL		(1024)
106*4882a593Smuzhiyun #define MAX_PKTID_RX		(4 * 1024)
107*4882a593Smuzhiyun #define MAX_PKTID_TX		(36 * 1024)
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun enum {
110*4882a593Smuzhiyun 	DNGL_TO_HOST_MSGBUF,
111*4882a593Smuzhiyun 	HOST_TO_DNGL_MSGBUF
112*4882a593Smuzhiyun };
113*4882a593Smuzhiyun 
114*4882a593Smuzhiyun enum {
115*4882a593Smuzhiyun 	HOST_TO_DNGL_TXP_DATA,
116*4882a593Smuzhiyun 	HOST_TO_DNGL_RXP_DATA,
117*4882a593Smuzhiyun 	HOST_TO_DNGL_CTRL,
118*4882a593Smuzhiyun 	DNGL_TO_HOST_DATA,
119*4882a593Smuzhiyun 	DNGL_TO_HOST_CTRL
120*4882a593Smuzhiyun };
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun #define MESSAGE_PAYLOAD(a) (a & MSG_TYPE_INTERNAL_USE_START) ? TRUE : FALSE
123*4882a593Smuzhiyun #define PCIEDEV_FIRMWARE_TSINFO 0x1
124*4882a593Smuzhiyun #define PCIEDEV_FIRMWARE_TSINFO_FIRST	0x1
125*4882a593Smuzhiyun #define PCIEDEV_FIRMWARE_TSINFO_MIDDLE	0x2
126*4882a593Smuzhiyun #define PCIEDEV_BTLOG_POST		0x3
127*4882a593Smuzhiyun #define PCIEDEV_BT_SNAPSHOT_POST	0x4
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun #ifdef PCIE_API_REV1
130*4882a593Smuzhiyun 
131*4882a593Smuzhiyun #define BCMMSGBUF_DUMMY_REF(a, b)	do {BCM_REFERENCE((a));BCM_REFERENCE((b));}  while (0)
132*4882a593Smuzhiyun 
133*4882a593Smuzhiyun #define BCMMSGBUF_API_IFIDX(a)		0
134*4882a593Smuzhiyun #define BCMMSGBUF_API_SEQNUM(a)		0
135*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_XTID(a)		0
136*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_PKTID(a)	((a)->cmd_id)
137*4882a593Smuzhiyun 
138*4882a593Smuzhiyun #define BCMMSGBUF_SET_API_IFIDX(a, b)	BCMMSGBUF_DUMMY_REF(a, b)
139*4882a593Smuzhiyun #define BCMMSGBUF_SET_API_SEQNUM(a, b)	BCMMSGBUF_DUMMY_REF(a, b)
140*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_SET_PKTID(a, b)	(BCMMSGBUF_IOCTL_PKTID(a) = (b))
141*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_SET_XTID(a, b)	BCMMSGBUF_DUMMY_REF(a, b)
142*4882a593Smuzhiyun 
143*4882a593Smuzhiyun #else /* PCIE_API_REV1 */
144*4882a593Smuzhiyun 
145*4882a593Smuzhiyun #define BCMMSGBUF_API_IFIDX(a)		((a)->if_id)
146*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_PKTID(a)	((a)->pkt_id)
147*4882a593Smuzhiyun #define BCMMSGBUF_API_SEQNUM(a)		((a)->u.seq.seq_no)
148*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_XTID(a)		((a)->xt_id)
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun #define BCMMSGBUF_SET_API_IFIDX(a, b)	(BCMMSGBUF_API_IFIDX((a)) = (b))
151*4882a593Smuzhiyun #define BCMMSGBUF_SET_API_SEQNUM(a, b)	(BCMMSGBUF_API_SEQNUM((a)) = (b))
152*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_SET_PKTID(a, b)	(BCMMSGBUF_IOCTL_PKTID((a)) = (b))
153*4882a593Smuzhiyun #define BCMMSGBUF_IOCTL_SET_XTID(a, b)	(BCMMSGBUF_IOCTL_XTID((a)) = (b))
154*4882a593Smuzhiyun 
155*4882a593Smuzhiyun #endif /* PCIE_API_REV1 */
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun /* utility data structures */
158*4882a593Smuzhiyun 
159*4882a593Smuzhiyun union addr64 {
160*4882a593Smuzhiyun 	struct {
161*4882a593Smuzhiyun 		uint32 low;
162*4882a593Smuzhiyun 		uint32 high;
163*4882a593Smuzhiyun 	};
164*4882a593Smuzhiyun 	struct {
165*4882a593Smuzhiyun 		uint32 low_addr;
166*4882a593Smuzhiyun 		uint32 high_addr;
167*4882a593Smuzhiyun 	};
168*4882a593Smuzhiyun 	uint64 u64;
169*4882a593Smuzhiyun } DECLSPEC_ALIGN(8);
170*4882a593Smuzhiyun 
171*4882a593Smuzhiyun typedef union addr64 bcm_addr64_t;
172*4882a593Smuzhiyun 
173*4882a593Smuzhiyun /* IOCTL req Hdr */
174*4882a593Smuzhiyun /* cmn Msg Hdr */
175*4882a593Smuzhiyun typedef struct cmn_msg_hdr {
176*4882a593Smuzhiyun 	/** message type */
177*4882a593Smuzhiyun 	uint8 msg_type;
178*4882a593Smuzhiyun 	/** interface index this is valid for */
179*4882a593Smuzhiyun 	uint8 if_id;
180*4882a593Smuzhiyun 	/* flags */
181*4882a593Smuzhiyun 	uint8 flags;
182*4882a593Smuzhiyun 	/** sequence number */
183*4882a593Smuzhiyun 	uint8 epoch;
184*4882a593Smuzhiyun 	/** packet Identifier for the associated host buffer */
185*4882a593Smuzhiyun 	uint32 request_id;
186*4882a593Smuzhiyun } cmn_msg_hdr_t;
187*4882a593Smuzhiyun 
188*4882a593Smuzhiyun /* cmn aggregated work item msg hdr */
189*4882a593Smuzhiyun typedef struct cmn_aggr_msg_hdr {
190*4882a593Smuzhiyun 	/** aggregate message type */
191*4882a593Smuzhiyun 	uint8		msg_type;
192*4882a593Smuzhiyun 	/** aggregation count */
193*4882a593Smuzhiyun 	uint8		aggr_cnt;
194*4882a593Smuzhiyun 	/* current phase */
195*4882a593Smuzhiyun 	uint8		phase;
196*4882a593Smuzhiyun 	/* flags or sequence number */
197*4882a593Smuzhiyun 	union {
198*4882a593Smuzhiyun 		uint8	flags; /* H2D direction */
199*4882a593Smuzhiyun 		uint8	epoch; /* D2H direction */
200*4882a593Smuzhiyun 	};
201*4882a593Smuzhiyun } cmn_aggr_msg_hdr_t;
202*4882a593Smuzhiyun 
203*4882a593Smuzhiyun /** cmn aggregated completion work item msg hdr */
204*4882a593Smuzhiyun typedef struct compl_aggr_msg_hdr {
205*4882a593Smuzhiyun 	/** interface index this is valid for */
206*4882a593Smuzhiyun 	uint8		if_id;
207*4882a593Smuzhiyun 	/** status for the completion */
208*4882a593Smuzhiyun 	int8		status;
209*4882a593Smuzhiyun 	/** submisison flow ring id which generated this status */
210*4882a593Smuzhiyun 	uint16		ring_id;
211*4882a593Smuzhiyun } compl_aggr_msg_hdr_t;
212*4882a593Smuzhiyun 
213*4882a593Smuzhiyun /** message type */
214*4882a593Smuzhiyun typedef enum bcmpcie_msgtype {
215*4882a593Smuzhiyun 	MSG_TYPE_GEN_STATUS		= 0x1,
216*4882a593Smuzhiyun 	MSG_TYPE_RING_STATUS		= 0x2,
217*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_CREATE	= 0x3,
218*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_CREATE_CMPLT	= 0x4,
219*4882a593Smuzhiyun 	/* Enum value as copied from BISON 7.15: new generic message */
220*4882a593Smuzhiyun 	MSG_TYPE_RING_CREATE_CMPLT	= 0x4,
221*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_DELETE	= 0x5,
222*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_DELETE_CMPLT	= 0x6,
223*4882a593Smuzhiyun 	/* Enum value as copied from BISON 7.15: new generic message */
224*4882a593Smuzhiyun 	MSG_TYPE_RING_DELETE_CMPLT	= 0x6,
225*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_FLUSH	= 0x7,
226*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_FLUSH_CMPLT	= 0x8,
227*4882a593Smuzhiyun 	MSG_TYPE_IOCTLPTR_REQ		= 0x9,
228*4882a593Smuzhiyun 	MSG_TYPE_IOCTLPTR_REQ_ACK	= 0xA,
229*4882a593Smuzhiyun 	MSG_TYPE_IOCTLRESP_BUF_POST	= 0xB,
230*4882a593Smuzhiyun 	MSG_TYPE_IOCTL_CMPLT		= 0xC,
231*4882a593Smuzhiyun 	MSG_TYPE_EVENT_BUF_POST		= 0xD,
232*4882a593Smuzhiyun 	MSG_TYPE_WL_EVENT		= 0xE,
233*4882a593Smuzhiyun 	MSG_TYPE_TX_POST		= 0xF,
234*4882a593Smuzhiyun 	MSG_TYPE_TX_STATUS		= 0x10,
235*4882a593Smuzhiyun 	MSG_TYPE_RXBUF_POST		= 0x11,
236*4882a593Smuzhiyun 	MSG_TYPE_RX_CMPLT		= 0x12,
237*4882a593Smuzhiyun 	MSG_TYPE_LPBK_DMAXFER		= 0x13,
238*4882a593Smuzhiyun 	MSG_TYPE_LPBK_DMAXFER_CMPLT	= 0x14,
239*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_RESUME	 = 0x15,
240*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_RESUME_CMPLT	= 0x16,
241*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_SUSPEND	= 0x17,
242*4882a593Smuzhiyun 	MSG_TYPE_FLOW_RING_SUSPEND_CMPLT	= 0x18,
243*4882a593Smuzhiyun 	MSG_TYPE_INFO_BUF_POST		= 0x19,
244*4882a593Smuzhiyun 	MSG_TYPE_INFO_BUF_CMPLT		= 0x1A,
245*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_CREATE	= 0x1B,
246*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_CREATE	= 0x1C,
247*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_CREATE_CMPLT	= 0x1D,
248*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_CREATE_CMPLT	= 0x1E,
249*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_CONFIG	= 0x1F,
250*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_CONFIG	= 0x20,
251*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_CONFIG_CMPLT	= 0x21,
252*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_CONFIG_CMPLT	= 0x22,
253*4882a593Smuzhiyun 	MSG_TYPE_H2D_MAILBOX_DATA	= 0x23,
254*4882a593Smuzhiyun 	MSG_TYPE_D2H_MAILBOX_DATA	= 0x24,
255*4882a593Smuzhiyun 	MSG_TYPE_TIMSTAMP_BUFPOST	= 0x25,
256*4882a593Smuzhiyun 	MSG_TYPE_HOSTTIMSTAMP		= 0x26,
257*4882a593Smuzhiyun 	MSG_TYPE_HOSTTIMSTAMP_CMPLT	= 0x27,
258*4882a593Smuzhiyun 	MSG_TYPE_FIRMWARE_TIMESTAMP	= 0x28,
259*4882a593Smuzhiyun 	MSG_TYPE_SNAPSHOT_UPLOAD	= 0x29,
260*4882a593Smuzhiyun 	MSG_TYPE_SNAPSHOT_CMPLT		= 0x2A,
261*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_DELETE	= 0x2B,
262*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_DELETE	= 0x2C,
263*4882a593Smuzhiyun 	MSG_TYPE_H2D_RING_DELETE_CMPLT	= 0x2D,
264*4882a593Smuzhiyun 	MSG_TYPE_D2H_RING_DELETE_CMPLT	= 0x2E,
265*4882a593Smuzhiyun 	MSG_TYPE_TX_POST_AGGR		= 0x2F,
266*4882a593Smuzhiyun 	MSG_TYPE_TX_STATUS_AGGR		= 0x30,
267*4882a593Smuzhiyun 	MSG_TYPE_RXBUF_POST_AGGR	= 0x31,
268*4882a593Smuzhiyun 	MSG_TYPE_RX_CMPLT_AGGR		= 0x32,
269*4882a593Smuzhiyun 	MSG_TYPE_API_MAX_RSVD		= 0x3F
270*4882a593Smuzhiyun } bcmpcie_msg_type_t;
271*4882a593Smuzhiyun 
272*4882a593Smuzhiyun /* message type used in internal queue */
273*4882a593Smuzhiyun typedef enum bcmpcie_msgtype_int {
274*4882a593Smuzhiyun 	MSG_TYPE_INTERNAL_USE_START	= 0x40,	/* internal pkt */
275*4882a593Smuzhiyun 	MSG_TYPE_EVENT_PYLD		= 0x41,	/* wl event pkt */
276*4882a593Smuzhiyun 	MSG_TYPE_IOCT_PYLD		= 0x42,	/* ioctl compl pkt */
277*4882a593Smuzhiyun 	MSG_TYPE_RX_PYLD		= 0x43,
278*4882a593Smuzhiyun 	MSG_TYPE_HOST_FETCH		= 0x44,
279*4882a593Smuzhiyun 	MSG_TYPE_LPBK_DMAXFER_PYLD	= 0x45,	/* loopback pkt */
280*4882a593Smuzhiyun 	MSG_TYPE_TXMETADATA_PYLD	= 0x46,	/* transmit status pkt */
281*4882a593Smuzhiyun 	MSG_TYPE_INDX_UPDATE		= 0x47,	/* write indx updated */
282*4882a593Smuzhiyun 	MSG_TYPE_INFO_PYLD		= 0x48,
283*4882a593Smuzhiyun 	MSG_TYPE_TS_EVENT_PYLD		= 0x49,
284*4882a593Smuzhiyun 	MSG_TYPE_PVT_BTLOG_CMPLT	= 0x4A,
285*4882a593Smuzhiyun 	MSG_TYPE_BTLOG_PYLD		= 0x4B,
286*4882a593Smuzhiyun 	MSG_TYPE_HMAPTEST_PYLD		= 0x4C,
287*4882a593Smuzhiyun 	MSG_TYPE_PVT_BT_SNAPSHOT_CMPLT  = 0x4D,
288*4882a593Smuzhiyun 	MSG_TYPE_BT_SNAPSHOT_PYLD       = 0x4E,
289*4882a593Smuzhiyun 	MSG_TYPE_LPBK_DMAXFER_PYLD_ADDR	= 0x4F	/* loopback from addr pkt */
290*4882a593Smuzhiyun } bcmpcie_msgtype_int_t;
291*4882a593Smuzhiyun 
292*4882a593Smuzhiyun typedef enum bcmpcie_msgtype_u {
293*4882a593Smuzhiyun 	MSG_TYPE_TX_BATCH_POST		= 0x80,
294*4882a593Smuzhiyun 	MSG_TYPE_IOCTL_REQ		= 0x81,
295*4882a593Smuzhiyun 	MSG_TYPE_HOST_EVNT		= 0x82, /* console related */
296*4882a593Smuzhiyun 	MSG_TYPE_LOOPBACK		= 0x83
297*4882a593Smuzhiyun } bcmpcie_msgtype_u_t;
298*4882a593Smuzhiyun 
299*4882a593Smuzhiyun /**
300*4882a593Smuzhiyun  * D2H ring host wakeup soft doorbell, override the PCIE doorbell.
301*4882a593Smuzhiyun  * Host configures an <32bit address,value> tuple, and dongle uses SBTOPCIE
302*4882a593Smuzhiyun  * Transl0 to write specified value to host address.
303*4882a593Smuzhiyun  *
304*4882a593Smuzhiyun  * Use case: 32bit Address mapped to HW Accelerator Core/Thread Wakeup Register
305*4882a593Smuzhiyun  * and value is Core/Thread context. Host will ensure routing the 32bit address
306*4882a593Smuzhiyun  * offerred to PCIE to the mapped register.
307*4882a593Smuzhiyun  *
308*4882a593Smuzhiyun  * D2H_RING_CONFIG_SUBTYPE_SOFT_DOORBELL
309*4882a593Smuzhiyun  */
310*4882a593Smuzhiyun typedef struct bcmpcie_soft_doorbell {
311*4882a593Smuzhiyun 	uint32	value;  /* host defined value to be written, eg HW threadid */
312*4882a593Smuzhiyun 	bcm_addr64_t haddr; /* host address, eg thread wakeup register address */
313*4882a593Smuzhiyun 	uint16	items;  /* interrupt coalescing: item count before wakeup */
314*4882a593Smuzhiyun 	uint16	msecs;  /* interrupt coalescing: timeout in millisecs */
315*4882a593Smuzhiyun } bcmpcie_soft_doorbell_t;
316*4882a593Smuzhiyun 
317*4882a593Smuzhiyun /**
318*4882a593Smuzhiyun  * D2H interrupt using MSI instead of INTX
319*4882a593Smuzhiyun  * Host configures MSI vector offset for each D2H interrupt
320*4882a593Smuzhiyun  *
321*4882a593Smuzhiyun  * D2H_RING_CONFIG_SUBTYPE_MSI_DOORBELL
322*4882a593Smuzhiyun  */
323*4882a593Smuzhiyun typedef enum bcmpcie_msi_intr_idx {
324*4882a593Smuzhiyun 	MSI_INTR_IDX_CTRL_CMPL_RING	= 0,
325*4882a593Smuzhiyun 	MSI_INTR_IDX_TXP_CMPL_RING	= 1,
326*4882a593Smuzhiyun 	MSI_INTR_IDX_RXP_CMPL_RING	= 2,
327*4882a593Smuzhiyun 	MSI_INTR_IDX_INFO_CMPL_RING	= 3,
328*4882a593Smuzhiyun 	MSI_INTR_IDX_MAILBOX		= 4,
329*4882a593Smuzhiyun 	MSI_INTR_IDX_MAX		= 5
330*4882a593Smuzhiyun } bcmpcie_msi_intr_idx_t;
331*4882a593Smuzhiyun 
332*4882a593Smuzhiyun #define BCMPCIE_D2H_MSI_OFFSET_SINGLE	0
333*4882a593Smuzhiyun typedef enum bcmpcie_msi_offset_type {
334*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_MB0	= 2,
335*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_MB1	= 3,
336*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_DB0	= 4,
337*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_DB1	= 5,
338*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_H1_DB0	= 6,
339*4882a593Smuzhiyun 	BCMPCIE_D2H_MSI_OFFSET_MAX	= 7
340*4882a593Smuzhiyun } bcmpcie_msi_offset_type_t;
341*4882a593Smuzhiyun 
342*4882a593Smuzhiyun typedef struct bcmpcie_msi_offset {
343*4882a593Smuzhiyun 	uint16	intr_idx;    /* interrupt index */
344*4882a593Smuzhiyun 	uint16	msi_offset;  /* msi vector offset */
345*4882a593Smuzhiyun } bcmpcie_msi_offset_t;
346*4882a593Smuzhiyun 
347*4882a593Smuzhiyun typedef struct bcmpcie_msi_offset_config {
348*4882a593Smuzhiyun 	uint32	len;
349*4882a593Smuzhiyun 	bcmpcie_msi_offset_t	bcmpcie_msi_offset[MSI_INTR_IDX_MAX];
350*4882a593Smuzhiyun } bcmpcie_msi_offset_config_t;
351*4882a593Smuzhiyun 
352*4882a593Smuzhiyun #define BCMPCIE_D2H_MSI_OFFSET_DEFAULT	BCMPCIE_D2H_MSI_OFFSET_DB1
353*4882a593Smuzhiyun 
354*4882a593Smuzhiyun #define BCMPCIE_D2H_MSI_SINGLE		0xFFFE
355*4882a593Smuzhiyun 
356*4882a593Smuzhiyun /* if_id */
357*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_PHYINTF_SHFT	5
358*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_PHYINTF_MAX	0x7
359*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_PHYINTF_MASK	\
360*4882a593Smuzhiyun 	(BCMPCIE_CMNHDR_IFIDX_PHYINTF_MAX << BCMPCIE_CMNHDR_IFIDX_PHYINTF_SHFT)
361*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_VIRTINTF_SHFT	0
362*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_VIRTINTF_MAX	0x1F
363*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_IFIDX_VIRTINTF_MASK	\
364*4882a593Smuzhiyun 	(BCMPCIE_CMNHDR_IFIDX_PHYINTF_MAX << BCMPCIE_CMNHDR_IFIDX_PHYINTF_SHFT)
365*4882a593Smuzhiyun 
366*4882a593Smuzhiyun /* flags */
367*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_FLAGS_DMA_R_IDX		0x1
368*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_FLAGS_DMA_R_IDX_INTR	0x2
369*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_FLAGS_TS_SEQNUM_INIT	0x4
370*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_FLAGS_PHASE_BIT		0x80
371*4882a593Smuzhiyun #define BCMPCIE_CMNHDR_PHASE_BIT_INIT		0x80
372*4882a593Smuzhiyun 
373*4882a593Smuzhiyun /* IOCTL request message */
374*4882a593Smuzhiyun typedef struct ioctl_req_msg {
375*4882a593Smuzhiyun 	/** common message header */
376*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
377*4882a593Smuzhiyun 	/** ioctl command type */
378*4882a593Smuzhiyun 	uint32		cmd;
379*4882a593Smuzhiyun 	/** ioctl transaction ID, to pair with a ioctl response */
380*4882a593Smuzhiyun 	uint16		trans_id;
381*4882a593Smuzhiyun 	/** input arguments buffer len */
382*4882a593Smuzhiyun 	uint16		input_buf_len;
383*4882a593Smuzhiyun 	/** expected output len */
384*4882a593Smuzhiyun 	uint16		output_buf_len;
385*4882a593Smuzhiyun 	/** to align the host address on 8 byte boundary */
386*4882a593Smuzhiyun 	uint16		rsvd[3];
387*4882a593Smuzhiyun 	/** always align on 8 byte boundary */
388*4882a593Smuzhiyun 	bcm_addr64_t	host_input_buf_addr;
389*4882a593Smuzhiyun 	/* rsvd */
390*4882a593Smuzhiyun 	uint32		rsvd1[2];
391*4882a593Smuzhiyun } ioctl_req_msg_t;
392*4882a593Smuzhiyun 
393*4882a593Smuzhiyun /** buffer post messages for device to use to return IOCTL responses, Events */
394*4882a593Smuzhiyun typedef struct ioctl_resp_evt_buf_post_msg {
395*4882a593Smuzhiyun 	/** common message header */
396*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
397*4882a593Smuzhiyun 	/** length of the host buffer supplied */
398*4882a593Smuzhiyun 	uint16		host_buf_len;
399*4882a593Smuzhiyun 	/** to align the host address on 8 byte boundary */
400*4882a593Smuzhiyun 	uint16		reserved[3];
401*4882a593Smuzhiyun 	/** always align on 8 byte boundary */
402*4882a593Smuzhiyun 	bcm_addr64_t	host_buf_addr;
403*4882a593Smuzhiyun 	uint32		rsvd[4];
404*4882a593Smuzhiyun } ioctl_resp_evt_buf_post_msg_t;
405*4882a593Smuzhiyun 
406*4882a593Smuzhiyun /* buffer post messages for device to use to return dbg buffers */
407*4882a593Smuzhiyun typedef ioctl_resp_evt_buf_post_msg_t info_buf_post_msg_t;
408*4882a593Smuzhiyun 
409*4882a593Smuzhiyun #ifdef DHD_EFI
410*4882a593Smuzhiyun #define DHD_INFOBUF_RX_BUFPOST_PKTSZ	1800
411*4882a593Smuzhiyun #else
412*4882a593Smuzhiyun #define DHD_INFOBUF_RX_BUFPOST_PKTSZ	(2 * 1024)
413*4882a593Smuzhiyun #endif
414*4882a593Smuzhiyun 
415*4882a593Smuzhiyun #define DHD_BTLOG_RX_BUFPOST_PKTSZ	(2 * 1024)
416*4882a593Smuzhiyun 
417*4882a593Smuzhiyun /* An infobuf host buffer starts with a 32 bit (LE) version. */
418*4882a593Smuzhiyun #define PCIE_INFOBUF_V1                1
419*4882a593Smuzhiyun /* Infobuf v1 type MSGTRACE's data is exactly the same as the MSGTRACE data that
420*4882a593Smuzhiyun  * is wrapped previously/also in a WLC_E_TRACE event.  See structure
421*4882a593Smuzhiyun  * msgrace_hdr_t in msgtrace.h.
422*4882a593Smuzhiyun */
423*4882a593Smuzhiyun #define PCIE_INFOBUF_V1_TYPE_MSGTRACE  1
424*4882a593Smuzhiyun 
425*4882a593Smuzhiyun /* Infobuf v1 type LOGTRACE data is exactly the same as the LOGTRACE data that
426*4882a593Smuzhiyun  * is wrapped previously/also in a WLC_E_TRACE event.  See structure
427*4882a593Smuzhiyun  * msgrace_hdr_t in msgtrace.h.  (The only difference between a MSGTRACE
428*4882a593Smuzhiyun  * and a LOGTRACE is the "trace type" field.)
429*4882a593Smuzhiyun */
430*4882a593Smuzhiyun #define PCIE_INFOBUF_V1_TYPE_LOGTRACE  2
431*4882a593Smuzhiyun 
432*4882a593Smuzhiyun /* An infobuf version 1 host buffer has a single TLV.  The information on the
433*4882a593Smuzhiyun  * version 1 types follow this structure definition. (int's LE)
434*4882a593Smuzhiyun */
435*4882a593Smuzhiyun typedef struct info_buf_payload_hdr_s {
436*4882a593Smuzhiyun 	uint16 type;
437*4882a593Smuzhiyun 	uint16 length;
438*4882a593Smuzhiyun } info_buf_payload_hdr_t;
439*4882a593Smuzhiyun 
440*4882a593Smuzhiyun /* BT logs/memory to DMA directly from BT memory to host */
441*4882a593Smuzhiyun typedef struct info_buf_btlog_s {
442*4882a593Smuzhiyun 	void (*status_cb)(void *ctx, void *p, int error);	/* obsolete - to be removed */
443*4882a593Smuzhiyun 	void *ctx;
444*4882a593Smuzhiyun 	dma64addr_t src_addr;
445*4882a593Smuzhiyun 	uint32 length;
446*4882a593Smuzhiyun 	bool (*pcie_status_cb)(osl_t *osh, void *p, int error);
447*4882a593Smuzhiyun 	uint32 bt_intstatus;
448*4882a593Smuzhiyun 	int error;
449*4882a593Smuzhiyun } info_buf_btlog_t;
450*4882a593Smuzhiyun 
451*4882a593Smuzhiyun /** snapshot upload request message  */
452*4882a593Smuzhiyun typedef struct snapshot_upload_request_msg {
453*4882a593Smuzhiyun 	/** common message header */
454*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
455*4882a593Smuzhiyun 	/** length of the snaphost buffer supplied */
456*4882a593Smuzhiyun 	uint32		snapshot_buf_len;
457*4882a593Smuzhiyun 	/** type of snapshot */
458*4882a593Smuzhiyun 	uint8		snapshot_type;
459*4882a593Smuzhiyun 	/** snapshot param    */
460*4882a593Smuzhiyun 	uint8		snapshot_param;
461*4882a593Smuzhiyun 	/** to align the host address on 8 byte boundary */
462*4882a593Smuzhiyun 	uint8		reserved[2];
463*4882a593Smuzhiyun 	/** always align on 8 byte boundary */
464*4882a593Smuzhiyun 	bcm_addr64_t	host_buf_addr;
465*4882a593Smuzhiyun 	uint32		rsvd[4];
466*4882a593Smuzhiyun } snapshot_upload_request_msg_t;
467*4882a593Smuzhiyun 
468*4882a593Smuzhiyun /** snapshot types  */
469*4882a593Smuzhiyun typedef enum bcmpcie_snapshot_type {
470*4882a593Smuzhiyun 	SNAPSHOT_TYPE_BT		= 0,	/* Bluetooth SRAM and patch RAM */
471*4882a593Smuzhiyun 	SNAPSHOT_TYPE_WLAN_SOCRAM	= 1,	/* WLAN SOCRAM */
472*4882a593Smuzhiyun 	SNAPSHOT_TYPE_WLAN_HEAP		= 2,	/* WLAN HEAP */
473*4882a593Smuzhiyun 	SNAPSHOT_TYPE_WLAN_REGISTER	= 3	/* WLAN registers */
474*4882a593Smuzhiyun } bcmpcie_snapshot_type_t;
475*4882a593Smuzhiyun 
476*4882a593Smuzhiyun #define PCIE_DMA_XFER_FLG_D11_LPBK_MASK		0xF
477*4882a593Smuzhiyun #define PCIE_DMA_XFER_FLG_D11_LPBK_SHIFT	2
478*4882a593Smuzhiyun #define PCIE_DMA_XFER_FLG_CORE_NUMBER_MASK	3
479*4882a593Smuzhiyun #define PCIE_DMA_XFER_FLG_CORE_NUMBER_SHIFT	0
480*4882a593Smuzhiyun 
481*4882a593Smuzhiyun typedef struct pcie_dma_xfer_params {
482*4882a593Smuzhiyun 	/** common message header */
483*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
484*4882a593Smuzhiyun 
485*4882a593Smuzhiyun 	/** always align on 8 byte boundary */
486*4882a593Smuzhiyun 	bcm_addr64_t	host_input_buf_addr;
487*4882a593Smuzhiyun 
488*4882a593Smuzhiyun 	/** always align on 8 byte boundary */
489*4882a593Smuzhiyun 	bcm_addr64_t	host_ouput_buf_addr;
490*4882a593Smuzhiyun 
491*4882a593Smuzhiyun 	/** length of transfer */
492*4882a593Smuzhiyun 	uint32		xfer_len;
493*4882a593Smuzhiyun 	/** delay before doing the src txfer */
494*4882a593Smuzhiyun 	uint32		srcdelay;
495*4882a593Smuzhiyun 	/** delay before doing the dest txfer */
496*4882a593Smuzhiyun 	uint32		destdelay;
497*4882a593Smuzhiyun 	uint8		rsvd[3];
498*4882a593Smuzhiyun 	/* bit0: D11 DMA loopback flag */
499*4882a593Smuzhiyun 	uint8		flags;
500*4882a593Smuzhiyun } pcie_dma_xfer_params_t;
501*4882a593Smuzhiyun 
502*4882a593Smuzhiyun #define BCMPCIE_FLOW_RING_INTF_HP2P		0x01u /* bit0 */
503*4882a593Smuzhiyun #define BCMPCIE_FLOW_RING_OPT_EXT_TXSTATUS	0x02u /* bit1 */
504*4882a593Smuzhiyun #define BCMPCIE_FLOW_RING_INTF_MESH		0x04u /* bit2, identifies the mesh flow ring */
505*4882a593Smuzhiyun 
506*4882a593Smuzhiyun /** Complete msgbuf hdr for flow ring update from host to dongle */
507*4882a593Smuzhiyun typedef struct tx_flowring_create_request {
508*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
509*4882a593Smuzhiyun 	uint8	da[ETHER_ADDR_LEN];
510*4882a593Smuzhiyun 	uint8	sa[ETHER_ADDR_LEN];
511*4882a593Smuzhiyun 	uint8	tid;
512*4882a593Smuzhiyun 	uint8	if_flags;
513*4882a593Smuzhiyun 	uint16	flow_ring_id;
514*4882a593Smuzhiyun 	uint8	tc;
515*4882a593Smuzhiyun 	/* priority_ifrmmask is to define core mask in ifrm mode.
516*4882a593Smuzhiyun 	 * currently it is not used for priority. so uses solely for ifrm mask
517*4882a593Smuzhiyun 	 */
518*4882a593Smuzhiyun 	uint8	priority_ifrmmask;
519*4882a593Smuzhiyun 	uint16	int_vector;
520*4882a593Smuzhiyun 	uint16	max_items;
521*4882a593Smuzhiyun 	uint16	len_item;
522*4882a593Smuzhiyun 	bcm_addr64_t flow_ring_ptr;
523*4882a593Smuzhiyun } tx_flowring_create_request_t;
524*4882a593Smuzhiyun 
525*4882a593Smuzhiyun typedef struct tx_flowring_delete_request {
526*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
527*4882a593Smuzhiyun 	uint16	flow_ring_id;
528*4882a593Smuzhiyun 	uint16	reason;
529*4882a593Smuzhiyun 	uint32	rsvd[7];
530*4882a593Smuzhiyun } tx_flowring_delete_request_t;
531*4882a593Smuzhiyun 
532*4882a593Smuzhiyun typedef tx_flowring_delete_request_t d2h_ring_delete_req_t;
533*4882a593Smuzhiyun typedef tx_flowring_delete_request_t h2d_ring_delete_req_t;
534*4882a593Smuzhiyun 
535*4882a593Smuzhiyun typedef struct tx_flowring_flush_request {
536*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
537*4882a593Smuzhiyun 	uint16	flow_ring_id;
538*4882a593Smuzhiyun 	uint16	reason;
539*4882a593Smuzhiyun 	uint32	rsvd[7];
540*4882a593Smuzhiyun } tx_flowring_flush_request_t;
541*4882a593Smuzhiyun 
542*4882a593Smuzhiyun /** Subtypes for ring_config_req control message */
543*4882a593Smuzhiyun typedef enum ring_config_subtype {
544*4882a593Smuzhiyun 	/** Default D2H PCIE doorbell override using ring_config_req msg */
545*4882a593Smuzhiyun 	D2H_RING_CONFIG_SUBTYPE_SOFT_DOORBELL = 1, /* Software doorbell */
546*4882a593Smuzhiyun 	D2H_RING_CONFIG_SUBTYPE_MSI_DOORBELL = 2   /* MSI configuration */
547*4882a593Smuzhiyun } ring_config_subtype_t;
548*4882a593Smuzhiyun 
549*4882a593Smuzhiyun typedef struct ring_config_req { /* pulled from upcoming rev6 ... */
550*4882a593Smuzhiyun 	cmn_msg_hdr_t	msg;
551*4882a593Smuzhiyun 	uint16	subtype;
552*4882a593Smuzhiyun 	uint16	ring_id;
553*4882a593Smuzhiyun 	uint32	rsvd;
554*4882a593Smuzhiyun 	union {
555*4882a593Smuzhiyun 		uint32  data[6];
556*4882a593Smuzhiyun 		/** D2H_RING_CONFIG_SUBTYPE_SOFT_DOORBELL */
557*4882a593Smuzhiyun 		bcmpcie_soft_doorbell_t soft_doorbell;
558*4882a593Smuzhiyun 		/** D2H_RING_CONFIG_SUBTYPE_MSI_DOORBELL */
559*4882a593Smuzhiyun 		bcmpcie_msi_offset_config_t msi_offset;
560*4882a593Smuzhiyun 	};
561*4882a593Smuzhiyun } ring_config_req_t;
562*4882a593Smuzhiyun 
563*4882a593Smuzhiyun /* data structure to use to create on the fly d2h rings */
564*4882a593Smuzhiyun typedef struct d2h_ring_create_req {
565*4882a593Smuzhiyun 	cmn_msg_hdr_t	msg;
566*4882a593Smuzhiyun 	uint16	ring_id;
567*4882a593Smuzhiyun 	uint16	ring_type;
568*4882a593Smuzhiyun 	uint32	flags;
569*4882a593Smuzhiyun 	bcm_addr64_t	ring_ptr;
570*4882a593Smuzhiyun 	uint16	max_items;
571*4882a593Smuzhiyun 	uint16	len_item;
572*4882a593Smuzhiyun 	uint32	rsvd[3];
573*4882a593Smuzhiyun } d2h_ring_create_req_t;
574*4882a593Smuzhiyun 
575*4882a593Smuzhiyun /* data structure to use to create on the fly h2d rings */
576*4882a593Smuzhiyun #define MAX_COMPLETION_RING_IDS_ASSOCIATED	4
577*4882a593Smuzhiyun typedef struct h2d_ring_create_req {
578*4882a593Smuzhiyun 	cmn_msg_hdr_t	msg;
579*4882a593Smuzhiyun 	uint16	ring_id;
580*4882a593Smuzhiyun 	uint8	ring_type;
581*4882a593Smuzhiyun 	uint8	n_completion_ids;
582*4882a593Smuzhiyun 	uint32	flags;
583*4882a593Smuzhiyun 	bcm_addr64_t	ring_ptr;
584*4882a593Smuzhiyun 	uint16	max_items;
585*4882a593Smuzhiyun 	uint16	len_item;
586*4882a593Smuzhiyun 	uint16	completion_ring_ids[MAX_COMPLETION_RING_IDS_ASSOCIATED];
587*4882a593Smuzhiyun 	uint32	rsvd;
588*4882a593Smuzhiyun } h2d_ring_create_req_t;
589*4882a593Smuzhiyun 
590*4882a593Smuzhiyun typedef struct d2h_ring_config_req {
591*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
592*4882a593Smuzhiyun 	uint16	d2h_ring_config_subtype;
593*4882a593Smuzhiyun 	uint16	d2h_ring_id;
594*4882a593Smuzhiyun 	uint32  d2h_ring_config_data[4];
595*4882a593Smuzhiyun 	uint32  rsvd[3];
596*4882a593Smuzhiyun } d2h_ring_config_req_t;
597*4882a593Smuzhiyun 
598*4882a593Smuzhiyun typedef struct h2d_ring_config_req {
599*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
600*4882a593Smuzhiyun 	uint16	h2d_ring_config_subtype;
601*4882a593Smuzhiyun 	uint16	h2d_ring_id;
602*4882a593Smuzhiyun 	uint32  h2d_ring_config_data;
603*4882a593Smuzhiyun 	uint32  rsvd[6];
604*4882a593Smuzhiyun } h2d_ring_config_req_t;
605*4882a593Smuzhiyun 
606*4882a593Smuzhiyun typedef struct h2d_mailbox_data {
607*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
608*4882a593Smuzhiyun 	uint32	mail_box_data;
609*4882a593Smuzhiyun 	uint32  rsvd[7];
610*4882a593Smuzhiyun } h2d_mailbox_data_t;
611*4882a593Smuzhiyun typedef struct host_timestamp_msg {
612*4882a593Smuzhiyun 	cmn_msg_hdr_t	msg;
613*4882a593Smuzhiyun 	uint16		xt_id; /* transaction ID */
614*4882a593Smuzhiyun 	uint16		input_data_len; /* data len at the host_buf_addr, data in TLVs */
615*4882a593Smuzhiyun 	uint16		seqnum; /* number of times host captured the timestamp */
616*4882a593Smuzhiyun 	uint16		rsvd;
617*4882a593Smuzhiyun 	/* always align on 8 byte boundary */
618*4882a593Smuzhiyun 	bcm_addr64_t	host_buf_addr;
619*4882a593Smuzhiyun 	/* rsvd */
620*4882a593Smuzhiyun 	uint32      rsvd1[4];
621*4882a593Smuzhiyun } host_timestamp_msg_t;
622*4882a593Smuzhiyun 
623*4882a593Smuzhiyun /* buffer post message for timestamp events MSG_TYPE_TIMSTAMP_BUFPOST */
624*4882a593Smuzhiyun typedef ioctl_resp_evt_buf_post_msg_t ts_buf_post_msg_t;
625*4882a593Smuzhiyun 
626*4882a593Smuzhiyun typedef union ctrl_submit_item {
627*4882a593Smuzhiyun 	ioctl_req_msg_t			ioctl_req;
628*4882a593Smuzhiyun 	ioctl_resp_evt_buf_post_msg_t	resp_buf_post;
629*4882a593Smuzhiyun 	pcie_dma_xfer_params_t		dma_xfer;
630*4882a593Smuzhiyun 	tx_flowring_create_request_t	flow_create;
631*4882a593Smuzhiyun 	tx_flowring_delete_request_t	flow_delete;
632*4882a593Smuzhiyun 	tx_flowring_flush_request_t	flow_flush;
633*4882a593Smuzhiyun 	ring_config_req_t		ring_config_req;
634*4882a593Smuzhiyun 	d2h_ring_create_req_t		d2h_create;
635*4882a593Smuzhiyun 	h2d_ring_create_req_t		h2d_create;
636*4882a593Smuzhiyun 	d2h_ring_config_req_t		d2h_config;
637*4882a593Smuzhiyun 	h2d_ring_config_req_t		h2d_config;
638*4882a593Smuzhiyun 	h2d_mailbox_data_t		h2d_mailbox_data;
639*4882a593Smuzhiyun 	host_timestamp_msg_t		host_ts;
640*4882a593Smuzhiyun 	ts_buf_post_msg_t		ts_buf_post;
641*4882a593Smuzhiyun 	d2h_ring_delete_req_t		d2h_delete;
642*4882a593Smuzhiyun 	h2d_ring_delete_req_t		h2d_delete;
643*4882a593Smuzhiyun 	unsigned char			check[H2DRING_CTRL_SUB_ITEMSIZE];
644*4882a593Smuzhiyun } ctrl_submit_item_t;
645*4882a593Smuzhiyun 
646*4882a593Smuzhiyun typedef struct info_ring_submit_item {
647*4882a593Smuzhiyun 	info_buf_post_msg_t		info_buf_post;
648*4882a593Smuzhiyun 	unsigned char			check[H2DRING_INFO_BUFPOST_ITEMSIZE];
649*4882a593Smuzhiyun } info_sumbit_item_t;
650*4882a593Smuzhiyun 
651*4882a593Smuzhiyun /** Control Completion messages (20 bytes) */
652*4882a593Smuzhiyun typedef struct compl_msg_hdr {
653*4882a593Smuzhiyun 	union {
654*4882a593Smuzhiyun 		/** status for the completion */
655*4882a593Smuzhiyun 		int16	status;
656*4882a593Smuzhiyun 
657*4882a593Smuzhiyun 		/* mutually exclusive with pkt fate debug feature */
658*4882a593Smuzhiyun 		struct pktts_compl_hdr {
659*4882a593Smuzhiyun 			uint16 d_t4; /* Delta TimeStamp 3: T4-tref */
660*4882a593Smuzhiyun 		} tx_pktts;
661*4882a593Smuzhiyun 	};
662*4882a593Smuzhiyun 	/** submisison flow ring id which generated this status */
663*4882a593Smuzhiyun 	union {
664*4882a593Smuzhiyun 	    uint16	ring_id;
665*4882a593Smuzhiyun 	    uint16	flow_ring_id;
666*4882a593Smuzhiyun 	};
667*4882a593Smuzhiyun } compl_msg_hdr_t;
668*4882a593Smuzhiyun 
669*4882a593Smuzhiyun /** XOR checksum or a magic number to audit DMA done */
670*4882a593Smuzhiyun typedef uint32 dma_done_t;
671*4882a593Smuzhiyun 
672*4882a593Smuzhiyun #define MAX_CLKSRC_ID	0xF
673*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_0_MASK		0x000000FF
674*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_0_SHIFT	0
675*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_1_MASK		0x0000FF00
676*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_1_SHIFT	8
677*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_2_MASK		0x00FF0000
678*4882a593Smuzhiyun #define TX_PKT_RETRY_CNT_2_SHIFT	16
679*4882a593Smuzhiyun #define TX_PKT_BAND_INFO		0x0F000000
680*4882a593Smuzhiyun #define TX_PKT_BAND_INFO_SHIFT		24
681*4882a593Smuzhiyun #define TX_PKT_VALID_INFO		0xF0000000
682*4882a593Smuzhiyun #define TX_PKT_VALID_INFO_SHIFT		28
683*4882a593Smuzhiyun 
684*4882a593Smuzhiyun typedef struct ts_timestamp_srcid {
685*4882a593Smuzhiyun 	union {
686*4882a593Smuzhiyun 		uint32	ts_low; /* time stamp low 32 bits */
687*4882a593Smuzhiyun 		uint32  rate_spec; /* use ratespec */
688*4882a593Smuzhiyun 	};
689*4882a593Smuzhiyun 	union {
690*4882a593Smuzhiyun 		uint32  ts_high; /* time stamp high 28 bits */
691*4882a593Smuzhiyun 		union {
692*4882a593Smuzhiyun 			uint32  ts_high_ext :28; /* time stamp high 28 bits */
693*4882a593Smuzhiyun 			uint32  clk_id_ext :3; /* clock ID source  */
694*4882a593Smuzhiyun 			uint32  phase :1; /* Phase bit */
695*4882a593Smuzhiyun 			dma_done_t	marker_ext;
696*4882a593Smuzhiyun 		};
697*4882a593Smuzhiyun 		uint32 tx_pkt_band_retry_info;
698*4882a593Smuzhiyun 	};
699*4882a593Smuzhiyun } ts_timestamp_srcid_t;
700*4882a593Smuzhiyun 
701*4882a593Smuzhiyun typedef ts_timestamp_srcid_t ipc_timestamp_t;
702*4882a593Smuzhiyun 
703*4882a593Smuzhiyun typedef struct ts_timestamp {
704*4882a593Smuzhiyun 	uint32	low;
705*4882a593Smuzhiyun 	uint32	high;
706*4882a593Smuzhiyun } ts_timestamp_t;
707*4882a593Smuzhiyun 
708*4882a593Smuzhiyun typedef ts_timestamp_t tick_count_64_t;
709*4882a593Smuzhiyun typedef ts_timestamp_t ts_timestamp_ns_64_t;
710*4882a593Smuzhiyun typedef ts_timestamp_t ts_correction_m_t;
711*4882a593Smuzhiyun typedef ts_timestamp_t ts_correction_b_t;
712*4882a593Smuzhiyun 
713*4882a593Smuzhiyun typedef struct _pktts {
714*4882a593Smuzhiyun 	uint32 tref; /* Ref Clk in uSec (currently, tsf) */
715*4882a593Smuzhiyun 	uint16 d_t2; /* Delta TimeStamp 1: T2-tref */
716*4882a593Smuzhiyun 	uint16 d_t3; /* Delta TimeStamp 2: T3-tref */
717*4882a593Smuzhiyun } pktts_t;
718*4882a593Smuzhiyun 
719*4882a593Smuzhiyun /* completion header status codes */
720*4882a593Smuzhiyun #define	BCMPCIE_SUCCESS			0
721*4882a593Smuzhiyun #define BCMPCIE_NOTFOUND		1
722*4882a593Smuzhiyun #define BCMPCIE_NOMEM			2
723*4882a593Smuzhiyun #define BCMPCIE_BADOPTION		3
724*4882a593Smuzhiyun #define BCMPCIE_RING_IN_USE		4
725*4882a593Smuzhiyun #define BCMPCIE_RING_ID_INVALID		5
726*4882a593Smuzhiyun #define BCMPCIE_PKT_FLUSH		6
727*4882a593Smuzhiyun #define BCMPCIE_NO_EVENT_BUF		7
728*4882a593Smuzhiyun #define BCMPCIE_NO_RX_BUF		8
729*4882a593Smuzhiyun #define BCMPCIE_NO_IOCTLRESP_BUF	9
730*4882a593Smuzhiyun #define BCMPCIE_MAX_IOCTLRESP_BUF	10
731*4882a593Smuzhiyun #define BCMPCIE_MAX_EVENT_BUF		11
732*4882a593Smuzhiyun #define BCMPCIE_BAD_PHASE		12
733*4882a593Smuzhiyun #define BCMPCIE_INVALID_CPL_RINGID	13
734*4882a593Smuzhiyun #define BCMPCIE_RING_TYPE_INVALID	14
735*4882a593Smuzhiyun #define BCMPCIE_NO_TS_EVENT_BUF		15
736*4882a593Smuzhiyun #define BCMPCIE_MAX_TS_EVENT_BUF	16
737*4882a593Smuzhiyun #define BCMPCIE_PCIE_NO_BTLOG_BUF	17
738*4882a593Smuzhiyun #define BCMPCIE_BT_DMA_ERR		18
739*4882a593Smuzhiyun #define BCMPCIE_BT_DMA_DESCR_FETCH_ERR	19
740*4882a593Smuzhiyun #define BCMPCIE_SNAPSHOT_ERR		20
741*4882a593Smuzhiyun #define BCMPCIE_NOT_READY		21
742*4882a593Smuzhiyun #define BCMPCIE_INVALID_DATA		22
743*4882a593Smuzhiyun #define BCMPCIE_NO_RESPONSE		23
744*4882a593Smuzhiyun #define BCMPCIE_NO_CLOCK		24
745*4882a593Smuzhiyun 
746*4882a593Smuzhiyun /** IOCTL completion response */
747*4882a593Smuzhiyun typedef struct ioctl_compl_resp_msg {
748*4882a593Smuzhiyun 	/** common message header */
749*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
750*4882a593Smuzhiyun 	/** completion message header */
751*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
752*4882a593Smuzhiyun 	/** response buffer len where a host buffer is involved */
753*4882a593Smuzhiyun 	uint16			resp_len;
754*4882a593Smuzhiyun 	/** transaction id to pair with a request */
755*4882a593Smuzhiyun 	uint16			trans_id;
756*4882a593Smuzhiyun 	/** cmd id */
757*4882a593Smuzhiyun 	uint32			cmd;
758*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
759*4882a593Smuzhiyun 	dma_done_t		marker;
760*4882a593Smuzhiyun } ioctl_comp_resp_msg_t;
761*4882a593Smuzhiyun 
762*4882a593Smuzhiyun /** IOCTL request acknowledgement */
763*4882a593Smuzhiyun typedef struct ioctl_req_ack_msg {
764*4882a593Smuzhiyun 	/** common message header */
765*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
766*4882a593Smuzhiyun 	/** completion message header */
767*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
768*4882a593Smuzhiyun 	/** cmd id */
769*4882a593Smuzhiyun 	uint32			cmd;
770*4882a593Smuzhiyun 	uint32			rsvd;
771*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
772*4882a593Smuzhiyun 	dma_done_t		marker;
773*4882a593Smuzhiyun } ioctl_req_ack_msg_t;
774*4882a593Smuzhiyun 
775*4882a593Smuzhiyun /** WL event message: send from device to host */
776*4882a593Smuzhiyun typedef struct wlevent_req_msg {
777*4882a593Smuzhiyun 	/** common message header */
778*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
779*4882a593Smuzhiyun 	/** completion message header */
780*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
781*4882a593Smuzhiyun 	/** event data len valid with the event buffer */
782*4882a593Smuzhiyun 	uint16			event_data_len;
783*4882a593Smuzhiyun 	/** sequence number */
784*4882a593Smuzhiyun 	uint16			seqnum;
785*4882a593Smuzhiyun 	/** rsvd	*/
786*4882a593Smuzhiyun 	uint32			rsvd;
787*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
788*4882a593Smuzhiyun 	dma_done_t		marker;
789*4882a593Smuzhiyun } wlevent_req_msg_t;
790*4882a593Smuzhiyun 
791*4882a593Smuzhiyun /** dma xfer complete message */
792*4882a593Smuzhiyun typedef struct pcie_dmaxfer_cmplt {
793*4882a593Smuzhiyun 	/** common message header */
794*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
795*4882a593Smuzhiyun 	/** completion message header */
796*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
797*4882a593Smuzhiyun 	uint32			rsvd[2];
798*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
799*4882a593Smuzhiyun 	dma_done_t		marker;
800*4882a593Smuzhiyun } pcie_dmaxfer_cmplt_t;
801*4882a593Smuzhiyun 
802*4882a593Smuzhiyun /** general status message */
803*4882a593Smuzhiyun typedef struct pcie_gen_status {
804*4882a593Smuzhiyun 	/** common message header */
805*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
806*4882a593Smuzhiyun 	/** completion message header */
807*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
808*4882a593Smuzhiyun 	uint32			rsvd[2];
809*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
810*4882a593Smuzhiyun 	dma_done_t		marker;
811*4882a593Smuzhiyun } pcie_gen_status_t;
812*4882a593Smuzhiyun 
813*4882a593Smuzhiyun /** ring status message */
814*4882a593Smuzhiyun typedef struct pcie_ring_status {
815*4882a593Smuzhiyun 	/** common message header */
816*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
817*4882a593Smuzhiyun 	/** completion message header */
818*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
819*4882a593Smuzhiyun 	/** message which firmware couldn't decode */
820*4882a593Smuzhiyun 	uint16			write_idx;
821*4882a593Smuzhiyun 	uint16			rsvd[3];
822*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
823*4882a593Smuzhiyun 	dma_done_t		marker;
824*4882a593Smuzhiyun } pcie_ring_status_t;
825*4882a593Smuzhiyun 
826*4882a593Smuzhiyun typedef struct ring_create_response {
827*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
828*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
829*4882a593Smuzhiyun 	uint32			rsvd[2];
830*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
831*4882a593Smuzhiyun 	dma_done_t		marker;
832*4882a593Smuzhiyun } ring_create_response_t;
833*4882a593Smuzhiyun 
834*4882a593Smuzhiyun typedef ring_create_response_t tx_flowring_create_response_t;
835*4882a593Smuzhiyun typedef ring_create_response_t h2d_ring_create_response_t;
836*4882a593Smuzhiyun typedef ring_create_response_t d2h_ring_create_response_t;
837*4882a593Smuzhiyun 
838*4882a593Smuzhiyun typedef struct tx_flowring_delete_response {
839*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
840*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
841*4882a593Smuzhiyun 	uint16			read_idx;
842*4882a593Smuzhiyun 	uint16			rsvd[3];
843*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
844*4882a593Smuzhiyun 	dma_done_t		marker;
845*4882a593Smuzhiyun } tx_flowring_delete_response_t;
846*4882a593Smuzhiyun 
847*4882a593Smuzhiyun typedef tx_flowring_delete_response_t	h2d_ring_delete_response_t;
848*4882a593Smuzhiyun typedef tx_flowring_delete_response_t	d2h_ring_delete_response_t;
849*4882a593Smuzhiyun 
850*4882a593Smuzhiyun typedef struct tx_flowring_flush_response {
851*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
852*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
853*4882a593Smuzhiyun 	uint32			rsvd[2];
854*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
855*4882a593Smuzhiyun 	dma_done_t		marker;
856*4882a593Smuzhiyun } tx_flowring_flush_response_t;
857*4882a593Smuzhiyun 
858*4882a593Smuzhiyun /** Common layout of all d2h control messages */
859*4882a593Smuzhiyun typedef struct ctrl_compl_msg {
860*4882a593Smuzhiyun 	/** common message header */
861*4882a593Smuzhiyun 	cmn_msg_hdr_t       cmn_hdr;
862*4882a593Smuzhiyun 	/** completion message header */
863*4882a593Smuzhiyun 	compl_msg_hdr_t     compl_hdr;
864*4882a593Smuzhiyun 	uint32          rsvd[2];
865*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
866*4882a593Smuzhiyun 	dma_done_t      marker;
867*4882a593Smuzhiyun } ctrl_compl_msg_t;
868*4882a593Smuzhiyun 
869*4882a593Smuzhiyun typedef struct ring_config_resp {
870*4882a593Smuzhiyun 	/** common message header */
871*4882a593Smuzhiyun 	cmn_msg_hdr_t       cmn_hdr;
872*4882a593Smuzhiyun 	/** completion message header */
873*4882a593Smuzhiyun 	compl_msg_hdr_t     compl_hdr;
874*4882a593Smuzhiyun 	uint16		subtype;
875*4882a593Smuzhiyun 	uint16          rsvd[3];
876*4882a593Smuzhiyun 	/** XOR checksum or a magic number to audit DMA done */
877*4882a593Smuzhiyun 	dma_done_t      marker;
878*4882a593Smuzhiyun } ring_config_resp_t;
879*4882a593Smuzhiyun 
880*4882a593Smuzhiyun typedef struct d2h_mailbox_data {
881*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
882*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
883*4882a593Smuzhiyun 	uint32			d2h_mailbox_data;
884*4882a593Smuzhiyun 	uint32			rsvd[1];
885*4882a593Smuzhiyun 	/* XOR checksum or a magic number to audit DMA done */
886*4882a593Smuzhiyun 	dma_done_t		marker;
887*4882a593Smuzhiyun } d2h_mailbox_data_t;
888*4882a593Smuzhiyun 
889*4882a593Smuzhiyun /* dbg buf completion msg: send from device to host */
890*4882a593Smuzhiyun typedef struct info_buf_resp {
891*4882a593Smuzhiyun 	/* common message header */
892*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
893*4882a593Smuzhiyun 	/* completion message header */
894*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
895*4882a593Smuzhiyun 	/* event data len valid with the event buffer */
896*4882a593Smuzhiyun 	uint16			info_data_len;
897*4882a593Smuzhiyun 	/* sequence number */
898*4882a593Smuzhiyun 	uint16			seqnum;
899*4882a593Smuzhiyun 	/* destination */
900*4882a593Smuzhiyun 	uint8			dest;
901*4882a593Smuzhiyun 	/* rsvd	*/
902*4882a593Smuzhiyun 	uint8			rsvd[3];
903*4882a593Smuzhiyun 	/* XOR checksum or a magic number to audit DMA done */
904*4882a593Smuzhiyun 	dma_done_t		marker;
905*4882a593Smuzhiyun } info_buf_resp_t;
906*4882a593Smuzhiyun 
907*4882a593Smuzhiyun /* snapshot completion msg: send from device to host */
908*4882a593Smuzhiyun typedef struct snapshot_resp {
909*4882a593Smuzhiyun 	/* common message header */
910*4882a593Smuzhiyun 	cmn_msg_hdr_t		cmn_hdr;
911*4882a593Smuzhiyun 	/* completion message header */
912*4882a593Smuzhiyun 	compl_msg_hdr_t		compl_hdr;
913*4882a593Smuzhiyun 	/* snapshot length uploaded */
914*4882a593Smuzhiyun 	uint32			resp_len;
915*4882a593Smuzhiyun 	/* snapshot type */
916*4882a593Smuzhiyun 	uint8			type;
917*4882a593Smuzhiyun 	/* rsvd	*/
918*4882a593Smuzhiyun 	uint8			rsvd[3];
919*4882a593Smuzhiyun 	/* XOR checksum or a magic number to audit DMA done */
920*4882a593Smuzhiyun 	dma_done_t		marker;
921*4882a593Smuzhiyun } snapshot_resp_t;
922*4882a593Smuzhiyun 
923*4882a593Smuzhiyun typedef struct info_ring_cpl_item {
924*4882a593Smuzhiyun 	info_buf_resp_t		info_buf_post;
925*4882a593Smuzhiyun 	unsigned char		check[D2HRING_INFO_BUFCMPLT_ITEMSIZE];
926*4882a593Smuzhiyun } info_cpl_item_t;
927*4882a593Smuzhiyun 
928*4882a593Smuzhiyun typedef struct host_timestamp_msg_cpl {
929*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
930*4882a593Smuzhiyun 	compl_msg_hdr_t cmplt;
931*4882a593Smuzhiyun 	uint16			xt_id; /* transaction ID */
932*4882a593Smuzhiyun 	uint16			rsvd;
933*4882a593Smuzhiyun 	uint32			rsvd1;
934*4882a593Smuzhiyun 	/* XOR checksum or a magic number to audit DMA done */
935*4882a593Smuzhiyun 	dma_done_t      marker;
936*4882a593Smuzhiyun } host_timestamp_msg_cpl_t;
937*4882a593Smuzhiyun 
938*4882a593Smuzhiyun typedef struct fw_timestamp_event_msg {
939*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
940*4882a593Smuzhiyun 	compl_msg_hdr_t cmplt;
941*4882a593Smuzhiyun 	/* fw captures time stamp info and passed that to host in TLVs */
942*4882a593Smuzhiyun 	uint16			buf_len; /* length of the time stamp data copied in host buf */
943*4882a593Smuzhiyun 	uint16			seqnum; /* number of times fw captured time stamp */
944*4882a593Smuzhiyun 	uint32			rsvd;
945*4882a593Smuzhiyun 	/* XOR checksum or a magic number to audit DMA done */
946*4882a593Smuzhiyun 	dma_done_t		marker;
947*4882a593Smuzhiyun } fw_timestamp_event_msg_t;
948*4882a593Smuzhiyun 
949*4882a593Smuzhiyun typedef union ctrl_completion_item {
950*4882a593Smuzhiyun 	ioctl_comp_resp_msg_t		ioctl_resp;
951*4882a593Smuzhiyun 	wlevent_req_msg_t		event;
952*4882a593Smuzhiyun 	ioctl_req_ack_msg_t		ioct_ack;
953*4882a593Smuzhiyun 	pcie_dmaxfer_cmplt_t		pcie_xfer_cmplt;
954*4882a593Smuzhiyun 	pcie_gen_status_t		pcie_gen_status;
955*4882a593Smuzhiyun 	pcie_ring_status_t		pcie_ring_status;
956*4882a593Smuzhiyun 	tx_flowring_create_response_t	txfl_create_resp;
957*4882a593Smuzhiyun 	tx_flowring_delete_response_t	txfl_delete_resp;
958*4882a593Smuzhiyun 	tx_flowring_flush_response_t	txfl_flush_resp;
959*4882a593Smuzhiyun 	ctrl_compl_msg_t		ctrl_compl;
960*4882a593Smuzhiyun 	ring_config_resp_t		ring_config_resp;
961*4882a593Smuzhiyun 	d2h_mailbox_data_t		d2h_mailbox_data;
962*4882a593Smuzhiyun 	info_buf_resp_t			dbg_resp;
963*4882a593Smuzhiyun 	h2d_ring_create_response_t	h2d_ring_create_resp;
964*4882a593Smuzhiyun 	d2h_ring_create_response_t	d2h_ring_create_resp;
965*4882a593Smuzhiyun 	host_timestamp_msg_cpl_t	host_ts_cpl;
966*4882a593Smuzhiyun 	fw_timestamp_event_msg_t	fw_ts_event;
967*4882a593Smuzhiyun 	h2d_ring_delete_response_t	h2d_ring_delete_resp;
968*4882a593Smuzhiyun 	d2h_ring_delete_response_t	d2h_ring_delete_resp;
969*4882a593Smuzhiyun 	unsigned char			ctrl_response[D2HRING_CTRL_CMPLT_ITEMSIZE];
970*4882a593Smuzhiyun } ctrl_completion_item_t;
971*4882a593Smuzhiyun 
972*4882a593Smuzhiyun /** H2D Rxpost ring work items */
973*4882a593Smuzhiyun typedef struct host_rxbuf_post {
974*4882a593Smuzhiyun 	/** common message header */
975*4882a593Smuzhiyun 	cmn_msg_hdr_t   cmn_hdr;
976*4882a593Smuzhiyun 	/** provided meta data buffer len */
977*4882a593Smuzhiyun 	uint16		metadata_buf_len;
978*4882a593Smuzhiyun 	/** provided data buffer len to receive data */
979*4882a593Smuzhiyun 	uint16		data_buf_len;
980*4882a593Smuzhiyun 	/** alignment to make the host buffers start on 8 byte boundary */
981*4882a593Smuzhiyun 	uint32		rsvd;
982*4882a593Smuzhiyun 	/** provided meta data buffer */
983*4882a593Smuzhiyun 	bcm_addr64_t	metadata_buf_addr;
984*4882a593Smuzhiyun 	/** provided data buffer to receive data */
985*4882a593Smuzhiyun 	bcm_addr64_t	data_buf_addr;
986*4882a593Smuzhiyun } host_rxbuf_post_t;
987*4882a593Smuzhiyun 
988*4882a593Smuzhiyun typedef union rxbuf_submit_item {
989*4882a593Smuzhiyun 	host_rxbuf_post_t	rxpost;
990*4882a593Smuzhiyun 	unsigned char		check[H2DRING_RXPOST_ITEMSIZE];
991*4882a593Smuzhiyun } rxbuf_submit_item_t;
992*4882a593Smuzhiyun 
993*4882a593Smuzhiyun /* D2H Rxcompletion ring work items for IPC rev7 */
994*4882a593Smuzhiyun typedef struct host_rxbuf_cmpl {
995*4882a593Smuzhiyun 	/** common message header */
996*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
997*4882a593Smuzhiyun 	/** completion message header */
998*4882a593Smuzhiyun 	compl_msg_hdr_t	compl_hdr;
999*4882a593Smuzhiyun 	/**  filled up meta data len */
1000*4882a593Smuzhiyun 	uint16		metadata_len;
1001*4882a593Smuzhiyun 	/** filled up buffer len to receive data */
1002*4882a593Smuzhiyun 	uint16		data_len;
1003*4882a593Smuzhiyun 	/** offset in the host rx buffer where the data starts */
1004*4882a593Smuzhiyun 	uint16		data_offset;
1005*4882a593Smuzhiyun 	/** offset in the host rx buffer where the data starts */
1006*4882a593Smuzhiyun 	uint16		flags;
1007*4882a593Smuzhiyun 	/** rx status */
1008*4882a593Smuzhiyun 	uint32		rx_status_0;
1009*4882a593Smuzhiyun 	uint32		rx_status_1;
1010*4882a593Smuzhiyun 
1011*4882a593Smuzhiyun 	union { /* size per IPC = (3 x uint32) bytes */
1012*4882a593Smuzhiyun 		struct {
1013*4882a593Smuzhiyun 			/* used by Monitor mode */
1014*4882a593Smuzhiyun 			uint32 marker;
1015*4882a593Smuzhiyun 			/* timestamp */
1016*4882a593Smuzhiyun 			ipc_timestamp_t ts;
1017*4882a593Smuzhiyun 		};
1018*4882a593Smuzhiyun 
1019*4882a593Smuzhiyun 		/* LatTS_With_XORCSUM */
1020*4882a593Smuzhiyun 		struct {
1021*4882a593Smuzhiyun 			/* latency timestamp */
1022*4882a593Smuzhiyun 			pktts_t rx_pktts;
1023*4882a593Smuzhiyun 			/* XOR checksum or a magic number to audit DMA done */
1024*4882a593Smuzhiyun 			dma_done_t marker_ext;
1025*4882a593Smuzhiyun 		};
1026*4882a593Smuzhiyun 	};
1027*4882a593Smuzhiyun } host_rxbuf_cmpl_t;
1028*4882a593Smuzhiyun 
1029*4882a593Smuzhiyun typedef union rxbuf_complete_item {
1030*4882a593Smuzhiyun 	host_rxbuf_cmpl_t	rxcmpl;
1031*4882a593Smuzhiyun 	unsigned char		check[D2HRING_RXCMPLT_ITEMSIZE];
1032*4882a593Smuzhiyun } rxbuf_complete_item_t;
1033*4882a593Smuzhiyun 
1034*4882a593Smuzhiyun typedef struct host_txbuf_post_v1 {
1035*4882a593Smuzhiyun 	/** common message header */
1036*4882a593Smuzhiyun 	cmn_msg_hdr_t   cmn_hdr;
1037*4882a593Smuzhiyun 	/** eth header */
1038*4882a593Smuzhiyun 	uint8		txhdr[ETHER_HDR_LEN];
1039*4882a593Smuzhiyun 	/** flags */
1040*4882a593Smuzhiyun 	uint8		flags;
1041*4882a593Smuzhiyun 	/** number of segments */
1042*4882a593Smuzhiyun 	uint8		seg_cnt;
1043*4882a593Smuzhiyun 
1044*4882a593Smuzhiyun 	/** provided meta data buffer for txstatus */
1045*4882a593Smuzhiyun 	bcm_addr64_t	metadata_buf_addr;
1046*4882a593Smuzhiyun 	/** provided data buffer containing Tx payload */
1047*4882a593Smuzhiyun 	bcm_addr64_t	data_buf_addr;
1048*4882a593Smuzhiyun 	/** provided meta data buffer len */
1049*4882a593Smuzhiyun 	uint16		metadata_buf_len;
1050*4882a593Smuzhiyun 	/** provided data buffer len */
1051*4882a593Smuzhiyun 	uint16		data_len;
1052*4882a593Smuzhiyun 	union {
1053*4882a593Smuzhiyun 		struct {
1054*4882a593Smuzhiyun 			/** extended transmit flags */
1055*4882a593Smuzhiyun 			uint8 ext_flags;
1056*4882a593Smuzhiyun 			uint8 scale_factor;
1057*4882a593Smuzhiyun 
1058*4882a593Smuzhiyun 			/** user defined rate */
1059*4882a593Smuzhiyun 			uint8 rate;
1060*4882a593Smuzhiyun 			uint8 exp_time;
1061*4882a593Smuzhiyun 		};
1062*4882a593Smuzhiyun 		/** XOR checksum or a magic number to audit DMA done */
1063*4882a593Smuzhiyun 		dma_done_t	marker;
1064*4882a593Smuzhiyun 	};
1065*4882a593Smuzhiyun } host_txbuf_post_v1_t;
1066*4882a593Smuzhiyun 
1067*4882a593Smuzhiyun typedef enum pkt_csum_type_shift {
1068*4882a593Smuzhiyun 	PKT_CSUM_TYPE_IPV4_SHIFT = 0,		/* pkt has IPv4 hdr */
1069*4882a593Smuzhiyun 	PKT_CSUM_TYPE_IPV6_SHIFT = 1,		/* pkt has IPv6 hdr */
1070*4882a593Smuzhiyun 	PKT_CSUM_TYPE_TCP_SHIFT = 2,		/* pkt has TCP hdr */
1071*4882a593Smuzhiyun 	PKT_CSUM_TYPE_UDP_SHIFT = 3,		/* pkt has UDP hdr */
1072*4882a593Smuzhiyun 	PKT_CSUM_TYPE_NWK_CSUM_SHIFT = 4,	/* pkt requires IP csum offload */
1073*4882a593Smuzhiyun 	PKT_CSUM_TYPE_TRANS_CSUM_SHIFT = 5,	/* pkt requires TCP/UDP csum offload */
1074*4882a593Smuzhiyun 	PKT_CSUM_TYPE_PSEUDOHDR_CSUM_SHIFT = 6,	/* pkt requires pseudo header csum offload */
1075*4882a593Smuzhiyun } pkt_type_shift_t;
1076*4882a593Smuzhiyun 
1077*4882a593Smuzhiyun typedef struct pkt_info_cso {
1078*4882a593Smuzhiyun 	/* packet csum type = ipv4/v6|udp|tcp|nwk_csum|trans_csum|ph_csum */
1079*4882a593Smuzhiyun 	uint8 ver;
1080*4882a593Smuzhiyun 	uint8 pkt_csum_type;
1081*4882a593Smuzhiyun 	uint8 nwk_hdr_len;	/* IP header length */
1082*4882a593Smuzhiyun 	uint8 trans_hdr_len;	/* TCP header length */
1083*4882a593Smuzhiyun } pkt_info_cso_t;
1084*4882a593Smuzhiyun 
1085*4882a593Smuzhiyun typedef struct host_txbuf_post_v2 {
1086*4882a593Smuzhiyun 	/** common message header */
1087*4882a593Smuzhiyun 	cmn_msg_hdr_t   cmn_hdr;
1088*4882a593Smuzhiyun 	/** eth header */
1089*4882a593Smuzhiyun 	uint8		txhdr[ETHER_HDR_LEN];
1090*4882a593Smuzhiyun 	/** flags */
1091*4882a593Smuzhiyun 	uint8		flags;
1092*4882a593Smuzhiyun 	/** number of segments */
1093*4882a593Smuzhiyun 	uint8		seg_cnt;
1094*4882a593Smuzhiyun 
1095*4882a593Smuzhiyun 	/** provided meta data buffer for txstatus */
1096*4882a593Smuzhiyun 	bcm_addr64_t	metadata_buf_addr;
1097*4882a593Smuzhiyun 	/** provided data buffer containing Tx payload */
1098*4882a593Smuzhiyun 	bcm_addr64_t	data_buf_addr;
1099*4882a593Smuzhiyun 	/** provided meta data buffer len */
1100*4882a593Smuzhiyun 	uint16		metadata_buf_len;
1101*4882a593Smuzhiyun 	/** provided data buffer len */
1102*4882a593Smuzhiyun 	uint16		data_len;
1103*4882a593Smuzhiyun 	struct {
1104*4882a593Smuzhiyun 		/** extended transmit flags */
1105*4882a593Smuzhiyun 		uint8 ext_flags;
1106*4882a593Smuzhiyun 		uint8 scale_factor;
1107*4882a593Smuzhiyun 
1108*4882a593Smuzhiyun 		/** user defined rate */
1109*4882a593Smuzhiyun 		uint8 rate;
1110*4882a593Smuzhiyun 		uint8 exp_time;
1111*4882a593Smuzhiyun 	};
1112*4882a593Smuzhiyun 	/** additional information on the packet required for CSO */
1113*4882a593Smuzhiyun 	pkt_info_cso_t pktinfo;
1114*4882a593Smuzhiyun 	uint32 PAD;
1115*4882a593Smuzhiyun } host_txbuf_post_v2_t;
1116*4882a593Smuzhiyun 
1117*4882a593Smuzhiyun #if defined(BCMPCIE_EXT_TXPOST_SUPPORT) || defined(TX_CSO)
1118*4882a593Smuzhiyun typedef host_txbuf_post_v2_t host_txbuf_post_t;
1119*4882a593Smuzhiyun #else
1120*4882a593Smuzhiyun typedef host_txbuf_post_v1_t host_txbuf_post_t;
1121*4882a593Smuzhiyun #endif
1122*4882a593Smuzhiyun 
1123*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_802_3	0x01
1124*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_802_11	0x02
1125*4882a593Smuzhiyun 
1126*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_NORETRY		0x01	/* Disable retry on this frame */
1127*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_NOAGGR		0x02	/* Disable aggregation for this frame */
1128*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_UDR		0x04	/* User defined rate for this frame */
1129*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_ATTR_MASK	0x07	/* Attribute mask */
1130*4882a593Smuzhiyun 
1131*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_EXEMPT_MASK	0x03	/* Exempt uses 2 bits */
1132*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_EXEMPT_SHIFT	0x02	/* needs to be shifted past other bits */
1133*4882a593Smuzhiyun 
1134*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_EPOCH_SHIFT           3u
1135*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_EPOCH_MASK            (1u << BCMPCIE_PKT_FLAGS_EPOCH_SHIFT)
1136*4882a593Smuzhiyun 
1137*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_PRIO_SHIFT		5
1138*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_PRIO_MASK		(7 << BCMPCIE_PKT_FLAGS_PRIO_SHIFT)
1139*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_NO_AMSDU	0x00
1140*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_FIRST_PKT	0x01
1141*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_INTER_PKT	0x02
1142*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_LAST_PKT	0x03
1143*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_SHIFT		8
1144*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_MONITOR_MASK		(3 << BCMPCIE_PKT_FLAGS_MONITOR_SHIFT)
1145*4882a593Smuzhiyun 
1146*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_FRAME_MESH		0x400u
1147*4882a593Smuzhiyun /* Indicate RX checksum verified and passed */
1148*4882a593Smuzhiyun #define BCMPCIE_PKT_FLAGS_RCSUM_VALID		0x800u
1149*4882a593Smuzhiyun 
1150*4882a593Smuzhiyun /* These are added to fix up compile issues */
1151*4882a593Smuzhiyun #define BCMPCIE_TXPOST_FLAGS_FRAME_802_3	BCMPCIE_PKT_FLAGS_FRAME_802_3
1152*4882a593Smuzhiyun #define BCMPCIE_TXPOST_FLAGS_FRAME_802_11	BCMPCIE_PKT_FLAGS_FRAME_802_11
1153*4882a593Smuzhiyun #define BCMPCIE_TXPOST_FLAGS_PRIO_SHIFT		BCMPCIE_PKT_FLAGS_PRIO_SHIFT
1154*4882a593Smuzhiyun #define BCMPCIE_TXPOST_FLAGS_PRIO_MASK		BCMPCIE_PKT_FLAGS_PRIO_MASK
1155*4882a593Smuzhiyun 
1156*4882a593Smuzhiyun #define BCMPCIE_TXPOST_FLAGS_HOST_SFH_LLC	0x10u
1157*4882a593Smuzhiyun #define BCMPCIE_TXPOST_RATE_EXT_USAGE		0x80 /* The rate field has extended usage */
1158*4882a593Smuzhiyun #define BCMPCIE_TXPOST_RATE_PROFILE_IDX_MASK	0x07 /* The Tx profile index in the rate field */
1159*4882a593Smuzhiyun 
1160*4882a593Smuzhiyun /* H2D Txpost ring work items */
1161*4882a593Smuzhiyun typedef union txbuf_submit_item {
1162*4882a593Smuzhiyun 	host_txbuf_post_t	txpost;
1163*4882a593Smuzhiyun 	unsigned char		check[H2DRING_TXPOST_ITEMSIZE];
1164*4882a593Smuzhiyun } txbuf_submit_item_t;
1165*4882a593Smuzhiyun 
1166*4882a593Smuzhiyun /* D2H Txcompletion ring work items - extended for IOC rev7 */
1167*4882a593Smuzhiyun typedef struct host_txbuf_cmpl {
1168*4882a593Smuzhiyun 	/** common message header */
1169*4882a593Smuzhiyun 	cmn_msg_hdr_t	cmn_hdr;
1170*4882a593Smuzhiyun 	/** completion message header */
1171*4882a593Smuzhiyun 	compl_msg_hdr_t	compl_hdr;
1172*4882a593Smuzhiyun 
1173*4882a593Smuzhiyun 	union { /* size per IPC = (3 x uint32) bytes */
1174*4882a593Smuzhiyun 		/* Usage 1: TxS_With_TimeSync */
1175*4882a593Smuzhiyun 		struct {
1176*4882a593Smuzhiyun 			 struct {
1177*4882a593Smuzhiyun 				union {
1178*4882a593Smuzhiyun 					/** provided meta data len */
1179*4882a593Smuzhiyun 					uint16	metadata_len;
1180*4882a593Smuzhiyun 					/** provided extended TX status */
1181*4882a593Smuzhiyun 					uint16	tx_status_ext;
1182*4882a593Smuzhiyun 				}; /*Ext_TxStatus */
1183*4882a593Smuzhiyun 
1184*4882a593Smuzhiyun 				/** WLAN side txstatus */
1185*4882a593Smuzhiyun 				uint16	tx_status;
1186*4882a593Smuzhiyun 			}; /* TxS */
1187*4882a593Smuzhiyun 			/* timestamp */
1188*4882a593Smuzhiyun 			ipc_timestamp_t ts;
1189*4882a593Smuzhiyun 		}; /* TxS_with_TS */
1190*4882a593Smuzhiyun 
1191*4882a593Smuzhiyun 		/* Usage 2: LatTS_With_XORCSUM */
1192*4882a593Smuzhiyun 		struct {
1193*4882a593Smuzhiyun 			/* latency timestamp */
1194*4882a593Smuzhiyun 			pktts_t tx_pktts;
1195*4882a593Smuzhiyun 			/* XOR checksum or a magic number to audit DMA done */
1196*4882a593Smuzhiyun 			dma_done_t marker_ext;
1197*4882a593Smuzhiyun 		};
1198*4882a593Smuzhiyun 	};
1199*4882a593Smuzhiyun 
1200*4882a593Smuzhiyun } host_txbuf_cmpl_t;
1201*4882a593Smuzhiyun 
1202*4882a593Smuzhiyun typedef union txbuf_complete_item {
1203*4882a593Smuzhiyun 	host_txbuf_cmpl_t	txcmpl;
1204*4882a593Smuzhiyun 	unsigned char		check[D2HRING_TXCMPLT_ITEMSIZE];
1205*4882a593Smuzhiyun } txbuf_complete_item_t;
1206*4882a593Smuzhiyun 
1207*4882a593Smuzhiyun #define METADATA_VER_1		1u
1208*4882a593Smuzhiyun #define METADATA_VER_2		2u
1209*4882a593Smuzhiyun #define PCIE_METADATA_VER	METADATA_VER_2
1210*4882a593Smuzhiyun 
1211*4882a593Smuzhiyun /* version and length are not part of this structure.
1212*4882a593Smuzhiyun  * dhd queries version and length through bus iovar "bus:metadata_info".
1213*4882a593Smuzhiyun  */
1214*4882a593Smuzhiyun struct metadata_txcmpl_v1 {
1215*4882a593Smuzhiyun 	uint32 tref; /* TSF or Ref Clock in uSecs */
1216*4882a593Smuzhiyun 	uint16 d_t2; /* T2-fwt1 delta */
1217*4882a593Smuzhiyun 	uint16 d_t3; /* T3-fwt1 delta */
1218*4882a593Smuzhiyun 	uint16 d_t4; /* T4-fwt1 delta */
1219*4882a593Smuzhiyun 	uint16 rsvd; /* reserved */
1220*4882a593Smuzhiyun };
1221*4882a593Smuzhiyun 
1222*4882a593Smuzhiyun struct metadata_txcmpl_v2 {
1223*4882a593Smuzhiyun 	uint32 tref; /* TSF or Ref Clock in uSecs */
1224*4882a593Smuzhiyun 	uint16 d_t2; /* T2-fwt1 delta */
1225*4882a593Smuzhiyun 	uint16 d_t3; /* T3-fwt1 delta */
1226*4882a593Smuzhiyun 	uint16 d_t4; /* T4-fwt1 delta */
1227*4882a593Smuzhiyun 
1228*4882a593Smuzhiyun 	uint16 u_t1; /* PSM Packet Fetch Time in 32us */
1229*4882a593Smuzhiyun 	uint16 u_t2; /* Medium Access Delay delta */
1230*4882a593Smuzhiyun 	uint16 u_t3; /* Rx duration delta */
1231*4882a593Smuzhiyun 	uint16 u_t4; /* Mac Suspend Duration delta */
1232*4882a593Smuzhiyun 	uint16 u_t5; /* TxStatus Time in 32us */
1233*4882a593Smuzhiyun 
1234*4882a593Smuzhiyun 	uint16 u_c1; /* Number of times Tx was enabled */
1235*4882a593Smuzhiyun 	uint16 u_c2; /* Other AC TxStatus count */
1236*4882a593Smuzhiyun 	uint16 u_c3; /* DataRetry count */
1237*4882a593Smuzhiyun 	uint16 u_c4; /* RTS */
1238*4882a593Smuzhiyun 	uint16 u_c5; /* CTS */
1239*4882a593Smuzhiyun 	uint16 u_c6; /* debug 1 */
1240*4882a593Smuzhiyun 	uint16 u_c7; /* debug 2 */
1241*4882a593Smuzhiyun 	uint16 u_c8; /* debug 3 */
1242*4882a593Smuzhiyun };
1243*4882a593Smuzhiyun typedef struct metadata_txcmpl_v2 metadata_txcmpl_t;
1244*4882a593Smuzhiyun 
1245*4882a593Smuzhiyun #define BCMPCIE_D2H_METADATA_HDRLEN	4
1246*4882a593Smuzhiyun #define BCMPCIE_D2H_METADATA_MINLEN	(BCMPCIE_D2H_METADATA_HDRLEN + 4)
1247*4882a593Smuzhiyun 
1248*4882a593Smuzhiyun /** ret buf struct */
1249*4882a593Smuzhiyun typedef struct ret_buf_ptr {
1250*4882a593Smuzhiyun 	uint32 low_addr;
1251*4882a593Smuzhiyun 	uint32 high_addr;
1252*4882a593Smuzhiyun } ret_buf_t;
1253*4882a593Smuzhiyun 
1254*4882a593Smuzhiyun #ifdef PCIE_API_REV1
1255*4882a593Smuzhiyun 
1256*4882a593Smuzhiyun /* ioctl specific hdr */
1257*4882a593Smuzhiyun typedef struct ioctl_hdr {
1258*4882a593Smuzhiyun 	uint16		cmd;
1259*4882a593Smuzhiyun 	uint16		retbuf_len;
1260*4882a593Smuzhiyun 	uint32		cmd_id;
1261*4882a593Smuzhiyun } ioctl_hdr_t;
1262*4882a593Smuzhiyun 
1263*4882a593Smuzhiyun typedef struct ioctlptr_hdr {
1264*4882a593Smuzhiyun 	uint16		cmd;
1265*4882a593Smuzhiyun 	uint16		retbuf_len;
1266*4882a593Smuzhiyun 	uint16		buflen;
1267*4882a593Smuzhiyun 	uint16		rsvd;
1268*4882a593Smuzhiyun 	uint32		cmd_id;
1269*4882a593Smuzhiyun } ioctlptr_hdr_t;
1270*4882a593Smuzhiyun 
1271*4882a593Smuzhiyun #else /* PCIE_API_REV1 */
1272*4882a593Smuzhiyun 
1273*4882a593Smuzhiyun typedef struct ioctl_req_hdr {
1274*4882a593Smuzhiyun 	uint32		pkt_id;	/**< Packet ID */
1275*4882a593Smuzhiyun 	uint32		cmd;	/**< IOCTL ID */
1276*4882a593Smuzhiyun 	uint16		retbuf_len;
1277*4882a593Smuzhiyun 	uint16		buflen;
1278*4882a593Smuzhiyun 	uint16		xt_id;	/**< transaction ID */
1279*4882a593Smuzhiyun 	uint16		rsvd[1];
1280*4882a593Smuzhiyun } ioctl_req_hdr_t;
1281*4882a593Smuzhiyun 
1282*4882a593Smuzhiyun #endif /* PCIE_API_REV1 */
1283*4882a593Smuzhiyun 
1284*4882a593Smuzhiyun /** Complete msgbuf hdr for ioctl from host to dongle */
1285*4882a593Smuzhiyun typedef struct ioct_reqst_hdr {
1286*4882a593Smuzhiyun 	cmn_msg_hdr_t msg;
1287*4882a593Smuzhiyun #ifdef PCIE_API_REV1
1288*4882a593Smuzhiyun 	ioctl_hdr_t ioct_hdr;
1289*4882a593Smuzhiyun #else
1290*4882a593Smuzhiyun 	ioctl_req_hdr_t ioct_hdr;
1291*4882a593Smuzhiyun #endif
1292*4882a593Smuzhiyun 	ret_buf_t ret_buf;
1293*4882a593Smuzhiyun } ioct_reqst_hdr_t;
1294*4882a593Smuzhiyun 
1295*4882a593Smuzhiyun typedef struct ioctptr_reqst_hdr {
1296*4882a593Smuzhiyun 	cmn_msg_hdr_t msg;
1297*4882a593Smuzhiyun #ifdef PCIE_API_REV1
1298*4882a593Smuzhiyun 	ioctlptr_hdr_t ioct_hdr;
1299*4882a593Smuzhiyun #else
1300*4882a593Smuzhiyun 	ioctl_req_hdr_t ioct_hdr;
1301*4882a593Smuzhiyun #endif
1302*4882a593Smuzhiyun 	ret_buf_t ret_buf;
1303*4882a593Smuzhiyun 	ret_buf_t ioct_buf;
1304*4882a593Smuzhiyun } ioctptr_reqst_hdr_t;
1305*4882a593Smuzhiyun 
1306*4882a593Smuzhiyun /** ioctl response header */
1307*4882a593Smuzhiyun typedef struct ioct_resp_hdr {
1308*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1309*4882a593Smuzhiyun #ifdef PCIE_API_REV1
1310*4882a593Smuzhiyun 	uint32	cmd_id;
1311*4882a593Smuzhiyun #else
1312*4882a593Smuzhiyun 	uint32	pkt_id;
1313*4882a593Smuzhiyun #endif
1314*4882a593Smuzhiyun 	uint32	status;
1315*4882a593Smuzhiyun 	uint32	ret_len;
1316*4882a593Smuzhiyun 	uint32  inline_data;
1317*4882a593Smuzhiyun #ifdef PCIE_API_REV1
1318*4882a593Smuzhiyun #else
1319*4882a593Smuzhiyun 	uint16	xt_id;	/**< transaction ID */
1320*4882a593Smuzhiyun 	uint16	rsvd[1];
1321*4882a593Smuzhiyun #endif
1322*4882a593Smuzhiyun } ioct_resp_hdr_t;
1323*4882a593Smuzhiyun 
1324*4882a593Smuzhiyun /* ioct resp header used in dongle */
1325*4882a593Smuzhiyun /* ret buf hdr will be stripped off inside dongle itself */
1326*4882a593Smuzhiyun typedef struct msgbuf_ioctl_resp {
1327*4882a593Smuzhiyun 	ioct_resp_hdr_t	ioct_hdr;
1328*4882a593Smuzhiyun 	ret_buf_t	ret_buf;	/**< ret buf pointers */
1329*4882a593Smuzhiyun } msgbuf_ioct_resp_t;
1330*4882a593Smuzhiyun 
1331*4882a593Smuzhiyun /** WL event hdr info */
1332*4882a593Smuzhiyun typedef struct wl_event_hdr {
1333*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1334*4882a593Smuzhiyun 	uint16 event;
1335*4882a593Smuzhiyun 	uint8 flags;
1336*4882a593Smuzhiyun 	uint8 rsvd;
1337*4882a593Smuzhiyun 	uint16 retbuf_len;
1338*4882a593Smuzhiyun 	uint16 rsvd1;
1339*4882a593Smuzhiyun 	uint32 rxbufid;
1340*4882a593Smuzhiyun } wl_event_hdr_t;
1341*4882a593Smuzhiyun 
1342*4882a593Smuzhiyun #define TXDESCR_FLOWID_PCIELPBK_1	0xFF
1343*4882a593Smuzhiyun #define TXDESCR_FLOWID_PCIELPBK_2	0xFE
1344*4882a593Smuzhiyun 
1345*4882a593Smuzhiyun typedef struct txbatch_lenptr_tup {
1346*4882a593Smuzhiyun 	uint32 pktid;
1347*4882a593Smuzhiyun 	uint16 pktlen;
1348*4882a593Smuzhiyun 	uint16 rsvd;
1349*4882a593Smuzhiyun 	ret_buf_t	ret_buf;	/**< ret buf pointers */
1350*4882a593Smuzhiyun } txbatch_lenptr_tup_t;
1351*4882a593Smuzhiyun 
1352*4882a593Smuzhiyun typedef struct txbatch_cmn_msghdr {
1353*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1354*4882a593Smuzhiyun 	uint8 priority;
1355*4882a593Smuzhiyun 	uint8 hdrlen;
1356*4882a593Smuzhiyun 	uint8 pktcnt;
1357*4882a593Smuzhiyun 	uint8 flowid;
1358*4882a593Smuzhiyun 	uint8 txhdr[ETHER_HDR_LEN];
1359*4882a593Smuzhiyun 	uint16 rsvd;
1360*4882a593Smuzhiyun } txbatch_cmn_msghdr_t;
1361*4882a593Smuzhiyun 
1362*4882a593Smuzhiyun typedef struct txbatch_msghdr {
1363*4882a593Smuzhiyun 	txbatch_cmn_msghdr_t txcmn;
1364*4882a593Smuzhiyun 	txbatch_lenptr_tup_t tx_tup[0]; /**< Based on packet count */
1365*4882a593Smuzhiyun } txbatch_msghdr_t;
1366*4882a593Smuzhiyun 
1367*4882a593Smuzhiyun /* TX desc posting header */
1368*4882a593Smuzhiyun typedef struct tx_lenptr_tup {
1369*4882a593Smuzhiyun 	uint16 pktlen;
1370*4882a593Smuzhiyun 	uint16 rsvd;
1371*4882a593Smuzhiyun 	ret_buf_t	ret_buf;	/**< ret buf pointers */
1372*4882a593Smuzhiyun } tx_lenptr_tup_t;
1373*4882a593Smuzhiyun 
1374*4882a593Smuzhiyun typedef struct txdescr_cmn_msghdr {
1375*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1376*4882a593Smuzhiyun 	uint8 priority;
1377*4882a593Smuzhiyun 	uint8 hdrlen;
1378*4882a593Smuzhiyun 	uint8 descrcnt;
1379*4882a593Smuzhiyun 	uint8 flowid;
1380*4882a593Smuzhiyun 	uint32 pktid;
1381*4882a593Smuzhiyun } txdescr_cmn_msghdr_t;
1382*4882a593Smuzhiyun 
1383*4882a593Smuzhiyun typedef struct txdescr_msghdr {
1384*4882a593Smuzhiyun 	txdescr_cmn_msghdr_t txcmn;
1385*4882a593Smuzhiyun 	uint8 txhdr[ETHER_HDR_LEN];
1386*4882a593Smuzhiyun 	uint16 rsvd;
1387*4882a593Smuzhiyun 	tx_lenptr_tup_t tx_tup[0];	/**< Based on descriptor count */
1388*4882a593Smuzhiyun } txdescr_msghdr_t;
1389*4882a593Smuzhiyun 
1390*4882a593Smuzhiyun /** Tx status header info */
1391*4882a593Smuzhiyun typedef struct txstatus_hdr {
1392*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1393*4882a593Smuzhiyun 	uint32 pktid;
1394*4882a593Smuzhiyun } txstatus_hdr_t;
1395*4882a593Smuzhiyun 
1396*4882a593Smuzhiyun /** RX bufid-len-ptr tuple */
1397*4882a593Smuzhiyun typedef struct rx_lenptr_tup {
1398*4882a593Smuzhiyun 	uint32 rxbufid;
1399*4882a593Smuzhiyun 	uint16 len;
1400*4882a593Smuzhiyun 	uint16 rsvd2;
1401*4882a593Smuzhiyun 	ret_buf_t	ret_buf;	/**< ret buf pointers */
1402*4882a593Smuzhiyun } rx_lenptr_tup_t;
1403*4882a593Smuzhiyun 
1404*4882a593Smuzhiyun /** Rx descr Post hdr info */
1405*4882a593Smuzhiyun typedef struct rxdesc_msghdr {
1406*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1407*4882a593Smuzhiyun 	uint16 rsvd0;
1408*4882a593Smuzhiyun 	uint8 rsvd1;
1409*4882a593Smuzhiyun 	uint8 descnt;
1410*4882a593Smuzhiyun 	rx_lenptr_tup_t rx_tup[0];
1411*4882a593Smuzhiyun } rxdesc_msghdr_t;
1412*4882a593Smuzhiyun 
1413*4882a593Smuzhiyun /** RX complete tuples */
1414*4882a593Smuzhiyun typedef struct rxcmplt_tup {
1415*4882a593Smuzhiyun 	uint16 retbuf_len;
1416*4882a593Smuzhiyun 	uint16 data_offset;
1417*4882a593Smuzhiyun 	uint32 rxstatus0;
1418*4882a593Smuzhiyun 	uint32 rxstatus1;
1419*4882a593Smuzhiyun 	uint32 rxbufid;
1420*4882a593Smuzhiyun } rxcmplt_tup_t;
1421*4882a593Smuzhiyun 
1422*4882a593Smuzhiyun /** RX complete messge hdr */
1423*4882a593Smuzhiyun typedef struct rxcmplt_hdr {
1424*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1425*4882a593Smuzhiyun 	uint16 rsvd0;
1426*4882a593Smuzhiyun 	uint16 rxcmpltcnt;
1427*4882a593Smuzhiyun 	rxcmplt_tup_t rx_tup[0];
1428*4882a593Smuzhiyun } rxcmplt_hdr_t;
1429*4882a593Smuzhiyun 
1430*4882a593Smuzhiyun typedef struct hostevent_hdr {
1431*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1432*4882a593Smuzhiyun 	uint32 evnt_pyld;
1433*4882a593Smuzhiyun } hostevent_hdr_t;
1434*4882a593Smuzhiyun 
1435*4882a593Smuzhiyun typedef struct dma_xfer_params {
1436*4882a593Smuzhiyun 	uint32 src_physaddr_hi;
1437*4882a593Smuzhiyun 	uint32 src_physaddr_lo;
1438*4882a593Smuzhiyun 	uint32 dest_physaddr_hi;
1439*4882a593Smuzhiyun 	uint32 dest_physaddr_lo;
1440*4882a593Smuzhiyun 	uint32 len;
1441*4882a593Smuzhiyun 	uint32 srcdelay;
1442*4882a593Smuzhiyun 	uint32 destdelay;
1443*4882a593Smuzhiyun } dma_xfer_params_t;
1444*4882a593Smuzhiyun 
1445*4882a593Smuzhiyun enum {
1446*4882a593Smuzhiyun 	HOST_EVENT_CONS_CMD = 1
1447*4882a593Smuzhiyun };
1448*4882a593Smuzhiyun 
1449*4882a593Smuzhiyun /* defines for flags */
1450*4882a593Smuzhiyun #define MSGBUF_IOC_ACTION_MASK 0x1
1451*4882a593Smuzhiyun 
1452*4882a593Smuzhiyun #define MAX_SUSPEND_REQ 15
1453*4882a593Smuzhiyun 
1454*4882a593Smuzhiyun typedef struct tx_idle_flowring_suspend_request {
1455*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1456*4882a593Smuzhiyun 	uint16	ring_id[MAX_SUSPEND_REQ];      /* ring Id's */
1457*4882a593Smuzhiyun 	uint16	num;	/* number of flowid's to suspend */
1458*4882a593Smuzhiyun } tx_idle_flowring_suspend_request_t;
1459*4882a593Smuzhiyun 
1460*4882a593Smuzhiyun typedef struct tx_idle_flowring_suspend_response {
1461*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
1462*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
1463*4882a593Smuzhiyun 	uint32			rsvd[2];
1464*4882a593Smuzhiyun 	dma_done_t		marker;
1465*4882a593Smuzhiyun } tx_idle_flowring_suspend_response_t;
1466*4882a593Smuzhiyun 
1467*4882a593Smuzhiyun typedef struct tx_idle_flowring_resume_request {
1468*4882a593Smuzhiyun 	cmn_msg_hdr_t   msg;
1469*4882a593Smuzhiyun 	uint16	flow_ring_id;
1470*4882a593Smuzhiyun 	uint16	reason;
1471*4882a593Smuzhiyun 	uint32	rsvd[7];
1472*4882a593Smuzhiyun } tx_idle_flowring_resume_request_t;
1473*4882a593Smuzhiyun 
1474*4882a593Smuzhiyun typedef struct tx_idle_flowring_resume_response {
1475*4882a593Smuzhiyun 	cmn_msg_hdr_t		msg;
1476*4882a593Smuzhiyun 	compl_msg_hdr_t		cmplt;
1477*4882a593Smuzhiyun 	uint32			rsvd[2];
1478*4882a593Smuzhiyun 	dma_done_t		marker;
1479*4882a593Smuzhiyun } tx_idle_flowring_resume_response_t;
1480*4882a593Smuzhiyun 
1481*4882a593Smuzhiyun /* timesync related additions */
1482*4882a593Smuzhiyun 
1483*4882a593Smuzhiyun /* defined similar to bcm_xtlv_t */
1484*4882a593Smuzhiyun typedef struct _bcm_xtlv {
1485*4882a593Smuzhiyun 	uint16		id; /* TLV idenitifier */
1486*4882a593Smuzhiyun 	uint16		len; /* TLV length in bytes */
1487*4882a593Smuzhiyun } _bcm_xtlv_t;
1488*4882a593Smuzhiyun 
1489*4882a593Smuzhiyun #define BCMMSGBUF_FW_CLOCK_INFO_TAG		0
1490*4882a593Smuzhiyun #define BCMMSGBUF_HOST_CLOCK_INFO_TAG		1
1491*4882a593Smuzhiyun #define BCMMSGBUF_HOST_CLOCK_SELECT_TAG		2
1492*4882a593Smuzhiyun #define BCMMSGBUF_D2H_CLOCK_CORRECTION_TAG	3
1493*4882a593Smuzhiyun #define BCMMSGBUF_HOST_TIMESTAMPING_CONFIG_TAG	4
1494*4882a593Smuzhiyun #define BCMMSGBUF_MAX_TSYNC_TAG			5
1495*4882a593Smuzhiyun 
1496*4882a593Smuzhiyun /* Flags in fw clock info TLV */
1497*4882a593Smuzhiyun #define CAP_DEVICE_TS		(1 << 0)
1498*4882a593Smuzhiyun #define CAP_CORRECTED_TS	(1 << 1)
1499*4882a593Smuzhiyun #define TS_CLK_ACTIVE		(1 << 2)
1500*4882a593Smuzhiyun 
1501*4882a593Smuzhiyun typedef struct ts_fw_clock_info {
1502*4882a593Smuzhiyun 	_bcm_xtlv_t  xtlv; /* BCMMSGBUF_FW_CLOCK_INFO_TAG */
1503*4882a593Smuzhiyun 	ts_timestamp_srcid_t  ts; /* tick count */
1504*4882a593Smuzhiyun 	uchar		clk_src[4]; /* clock source acronym ILP/AVB/TSF */
1505*4882a593Smuzhiyun 	uint32		nominal_clock_freq;
1506*4882a593Smuzhiyun 	uint32		reset_cnt;
1507*4882a593Smuzhiyun 	uint8		flags;
1508*4882a593Smuzhiyun 	uint8		rsvd[3];
1509*4882a593Smuzhiyun } ts_fw_clock_info_t;
1510*4882a593Smuzhiyun 
1511*4882a593Smuzhiyun typedef struct ts_host_clock_info {
1512*4882a593Smuzhiyun 	_bcm_xtlv_t  xtlv; /* BCMMSGBUF_HOST_CLOCK_INFO_TAG */
1513*4882a593Smuzhiyun 	tick_count_64_t ticks; /* 64 bit host tick counter */
1514*4882a593Smuzhiyun 	ts_timestamp_ns_64_t ns; /* 64 bit host time in nano seconds */
1515*4882a593Smuzhiyun } ts_host_clock_info_t;
1516*4882a593Smuzhiyun 
1517*4882a593Smuzhiyun typedef struct ts_host_clock_sel {
1518*4882a593Smuzhiyun 	_bcm_xtlv_t	xtlv; /* BCMMSGBUF_HOST_CLOCK_SELECT_TAG */
1519*4882a593Smuzhiyun 	uint32		seqnum; /* number of times GPIO time sync toggled */
1520*4882a593Smuzhiyun 	uint8		min_clk_idx; /* clock idenitifer configured for packet tiem stamping */
1521*4882a593Smuzhiyun 	uint8		max_clk_idx; /* clock idenitifer configured for packet tiem stamping */
1522*4882a593Smuzhiyun 	uint16		rsvd[1];
1523*4882a593Smuzhiyun } ts_host_clock_sel_t;
1524*4882a593Smuzhiyun 
1525*4882a593Smuzhiyun typedef struct ts_d2h_clock_correction {
1526*4882a593Smuzhiyun 	_bcm_xtlv_t		xtlv; /* BCMMSGBUF_HOST_CLOCK_INFO_TAG */
1527*4882a593Smuzhiyun 	uint8			clk_id; /* clock source in the device */
1528*4882a593Smuzhiyun 	uint8			rsvd[3];
1529*4882a593Smuzhiyun 	ts_correction_m_t	m;	/* y  = 'm' x + b */
1530*4882a593Smuzhiyun 	ts_correction_b_t	b;	/* y  = 'm' x + 'c' */
1531*4882a593Smuzhiyun } ts_d2h_clock_correction_t;
1532*4882a593Smuzhiyun 
1533*4882a593Smuzhiyun typedef struct ts_host_timestamping_config {
1534*4882a593Smuzhiyun 	_bcm_xtlv_t		xtlv; /* BCMMSGBUF_HOST_TIMESTAMPING_CONFIG_TAG */
1535*4882a593Smuzhiyun 	/* time period to capture the device time stamp and toggle WLAN_TIME_SYNC_GPIO */
1536*4882a593Smuzhiyun 	uint16			period_ms;
1537*4882a593Smuzhiyun 	uint8			flags;
1538*4882a593Smuzhiyun 	uint8			post_delay;
1539*4882a593Smuzhiyun 	uint32			reset_cnt;
1540*4882a593Smuzhiyun } ts_host_timestamping_config_t;
1541*4882a593Smuzhiyun 
1542*4882a593Smuzhiyun /* Flags in host timestamping config TLV */
1543*4882a593Smuzhiyun #define FLAG_HOST_RESET		(1 << 0)
1544*4882a593Smuzhiyun #define IS_HOST_RESET(x)	((x) & FLAG_HOST_RESET)
1545*4882a593Smuzhiyun #define CLEAR_HOST_RESET(x)	((x) & ~FLAG_HOST_RESET)
1546*4882a593Smuzhiyun 
1547*4882a593Smuzhiyun #define FLAG_CONFIG_NODROP	(1 << 1)
1548*4882a593Smuzhiyun #define IS_CONFIG_NODROP(x)	((x) & FLAG_CONFIG_NODROP)
1549*4882a593Smuzhiyun #define CLEAR_CONFIG_NODROP(x)	((x) & ~FLAG_CONFIG_NODROP)
1550*4882a593Smuzhiyun 
1551*4882a593Smuzhiyun /* HP2P RLLW Extended TxStatus info when host enables the same */
1552*4882a593Smuzhiyun #define D2H_TXSTATUS_EXT_PKT_WITH_OVRRD	0x8000 /**< set when pkt had override bit on */
1553*4882a593Smuzhiyun #define D2H_TXSTATUS_EXT_PKT_XMIT_ON5G	0x4000 /**< set when pkt xmitted on 5G */
1554*4882a593Smuzhiyun #define D2H_TXSTATUS_EXT_PKT_BT_DENY	0x2000 /**< set when WLAN is given prio over BT */
1555*4882a593Smuzhiyun #define D2H_TXSTATUS_EXT_PKT_NAV_SWITCH	0x1000 /**< set when band switched due to NAV intr */
1556*4882a593Smuzhiyun #define D2H_TXSTATUS_EXT_PKT_HOF_SWITCH	0x0800 /**< set when band switched due to HOF intr */
1557*4882a593Smuzhiyun 
1558*4882a593Smuzhiyun /* H2D Txpost aggregated work item */
1559*4882a593Smuzhiyun #define TXBUF_AGGR_CNT	(2u)
1560*4882a593Smuzhiyun 
1561*4882a593Smuzhiyun /* aggregated work item of txpost v2 */
1562*4882a593Smuzhiyun typedef struct host_txbuf_post_aggr_v2 {
1563*4882a593Smuzhiyun 	/** common aggregated message header */
1564*4882a593Smuzhiyun 	cmn_aggr_msg_hdr_t cmn_aggr_hdr;
1565*4882a593Smuzhiyun 
1566*4882a593Smuzhiyun 	/** data buffer len to transmit */
1567*4882a593Smuzhiyun 	uint16		data_buf_len[TXBUF_AGGR_CNT];
1568*4882a593Smuzhiyun 
1569*4882a593Smuzhiyun 	/** address of data buffer to transmit */
1570*4882a593Smuzhiyun 	bcm_addr64_t	data_buf_addr[TXBUF_AGGR_CNT];
1571*4882a593Smuzhiyun 
1572*4882a593Smuzhiyun 	/** packet Identifier for the associated host buffer */
1573*4882a593Smuzhiyun 	uint32		request_id[TXBUF_AGGR_CNT];
1574*4882a593Smuzhiyun 
1575*4882a593Smuzhiyun 	/** eth header */
1576*4882a593Smuzhiyun 	uint8		txhdr[ETHER_HDR_LEN];
1577*4882a593Smuzhiyun 
1578*4882a593Smuzhiyun 	/* reserved bytes */
1579*4882a593Smuzhiyun 	uint16		reserved;
1580*4882a593Smuzhiyun 
1581*4882a593Smuzhiyun 	/** additional information on the packet required for CSO */
1582*4882a593Smuzhiyun 	pkt_info_cso_t	pktinfo[TXBUF_AGGR_CNT];
1583*4882a593Smuzhiyun } host_txbuf_post_aggr_v2_t;
1584*4882a593Smuzhiyun 
1585*4882a593Smuzhiyun /* aggregated work item of txpost v1 */
1586*4882a593Smuzhiyun typedef struct host_txbuf_post_aggr_v1 {
1587*4882a593Smuzhiyun 	/** common aggregated message header */
1588*4882a593Smuzhiyun 	cmn_aggr_msg_hdr_t cmn_aggr_hdr;
1589*4882a593Smuzhiyun 
1590*4882a593Smuzhiyun 	/** data buffer len to transmit */
1591*4882a593Smuzhiyun 	uint16		data_buf_len[TXBUF_AGGR_CNT];
1592*4882a593Smuzhiyun 
1593*4882a593Smuzhiyun 	/** address of data buffer to transmit */
1594*4882a593Smuzhiyun 	bcm_addr64_t	data_buf_addr[TXBUF_AGGR_CNT];
1595*4882a593Smuzhiyun 
1596*4882a593Smuzhiyun 	/** packet Identifier for the associated host buffer */
1597*4882a593Smuzhiyun 	uint32		request_id[TXBUF_AGGR_CNT];
1598*4882a593Smuzhiyun 
1599*4882a593Smuzhiyun 	/** eth header */
1600*4882a593Smuzhiyun 	uint8		txhdr[ETHER_HDR_LEN];
1601*4882a593Smuzhiyun 
1602*4882a593Smuzhiyun 	/* pad bytes */
1603*4882a593Smuzhiyun 	uint16		PAD;
1604*4882a593Smuzhiyun } host_txbuf_post_aggr_v1_t;
1605*4882a593Smuzhiyun 
1606*4882a593Smuzhiyun #if defined(BCMPCIE_EXT_TXPOST_SUPPORT) || defined(TX_CSO)
1607*4882a593Smuzhiyun typedef host_txbuf_post_aggr_v2_t host_txbuf_post_aggr_t;
1608*4882a593Smuzhiyun #else
1609*4882a593Smuzhiyun typedef host_txbuf_post_aggr_v1_t host_txbuf_post_aggr_t;
1610*4882a593Smuzhiyun #endif
1611*4882a593Smuzhiyun 
1612*4882a593Smuzhiyun /* D2H Txcompletion ring aggregated work item */
1613*4882a593Smuzhiyun #define TXCPL_AGGR_CNT		(4u)
1614*4882a593Smuzhiyun 
1615*4882a593Smuzhiyun /* head aggregated work item of txcpl */
1616*4882a593Smuzhiyun typedef struct host_txbuf_cmpl_aggr {
1617*4882a593Smuzhiyun 	/** common aggregated message header */
1618*4882a593Smuzhiyun 	cmn_aggr_msg_hdr_t cmn_aggr_hdr;
1619*4882a593Smuzhiyun 
1620*4882a593Smuzhiyun 	/** completion aggregated message header */
1621*4882a593Smuzhiyun 	compl_aggr_msg_hdr_t compl_aggr_hdr;
1622*4882a593Smuzhiyun 
1623*4882a593Smuzhiyun 	/** packet Identifier for the associated host buffer */
1624*4882a593Smuzhiyun 	uint32 request_id[TXCPL_AGGR_CNT];
1625*4882a593Smuzhiyun } host_txbuf_cmpl_aggr_t;
1626*4882a593Smuzhiyun 
1627*4882a593Smuzhiyun #define TXCPL_AGGR_CNT_EXT	(6u)
1628*4882a593Smuzhiyun /* non-head aggregated work item of txcpl */
1629*4882a593Smuzhiyun typedef struct host_txbuf_cmpl_aggr_ext {
1630*4882a593Smuzhiyun 	/** packet Identifier for the associated host buffer */
1631*4882a593Smuzhiyun 	uint32 request_id[TXCPL_AGGR_CNT_EXT];
1632*4882a593Smuzhiyun } host_txbuf_cmpl_aggr_ext_t;
1633*4882a593Smuzhiyun 
1634*4882a593Smuzhiyun /* H2D Rxpost ring aggregated work items */
1635*4882a593Smuzhiyun #define RXBUF_AGGR_CNT	(2u)
1636*4882a593Smuzhiyun 
1637*4882a593Smuzhiyun /* aggregated work item of rxpost */
1638*4882a593Smuzhiyun typedef struct host_rxbuf_post_aggr {
1639*4882a593Smuzhiyun 	/** common aggregated message header */
1640*4882a593Smuzhiyun 	cmn_aggr_msg_hdr_t cmn_aggr_hdr;
1641*4882a593Smuzhiyun 
1642*4882a593Smuzhiyun 	/** data buffer len to transmit */
1643*4882a593Smuzhiyun 	uint16		data_buf_len[RXBUF_AGGR_CNT];
1644*4882a593Smuzhiyun 
1645*4882a593Smuzhiyun 	/** packet Identifier for the associated host buffer */
1646*4882a593Smuzhiyun 	uint32		request_id[RXBUF_AGGR_CNT];
1647*4882a593Smuzhiyun 
1648*4882a593Smuzhiyun 	/** address of data buffer to transmit */
1649*4882a593Smuzhiyun 	bcm_addr64_t	data_buf_addr[RXBUF_AGGR_CNT];
1650*4882a593Smuzhiyun } host_rxbuf_post_aggr_t;
1651*4882a593Smuzhiyun 
1652*4882a593Smuzhiyun /* D2H Rxcompletion ring for aggregated work items */
1653*4882a593Smuzhiyun #define RXCPL_AGGR_CNT		(2u)
1654*4882a593Smuzhiyun 
1655*4882a593Smuzhiyun /* each rx buffer work item */
1656*4882a593Smuzhiyun typedef struct host_rxbuf_cmpl_pkt {
1657*4882a593Smuzhiyun 	/** offset in the host rx buffer where the data starts */
1658*4882a593Smuzhiyun 	uint16		data_offset;
1659*4882a593Smuzhiyun 	/** filled up buffer len to receive data */
1660*4882a593Smuzhiyun 	uint16		data_len;
1661*4882a593Smuzhiyun 	/** packet Identifier for the associated host buffer */
1662*4882a593Smuzhiyun 	uint32		request_id;
1663*4882a593Smuzhiyun } host_rxbuf_cmpl_item_t;
1664*4882a593Smuzhiyun 
1665*4882a593Smuzhiyun /* head aggregated work item of rxcpl */
1666*4882a593Smuzhiyun typedef struct host_rxbuf_cmpl_aggr {
1667*4882a593Smuzhiyun 	/** common aggregated message header */
1668*4882a593Smuzhiyun 	cmn_aggr_msg_hdr_t cmn_aggr_hdr;
1669*4882a593Smuzhiyun 
1670*4882a593Smuzhiyun 	/** completion aggregated message header */
1671*4882a593Smuzhiyun 	compl_aggr_msg_hdr_t compl_aggr_hdr;
1672*4882a593Smuzhiyun 
1673*4882a593Smuzhiyun 	/** rxbuffer work item */
1674*4882a593Smuzhiyun 	host_rxbuf_cmpl_item_t	item[RXCPL_AGGR_CNT];
1675*4882a593Smuzhiyun } host_rxbuf_cmpl_aggr_t;
1676*4882a593Smuzhiyun 
1677*4882a593Smuzhiyun #define RXCPL_AGGR_CNT_EXT	(5u)
1678*4882a593Smuzhiyun /* non-head aggregated work item of rxcpl */
1679*4882a593Smuzhiyun typedef struct host_rxbuf_cmpl_aggr_ext {
1680*4882a593Smuzhiyun 	/** rxbuffer work item */
1681*4882a593Smuzhiyun 	host_rxbuf_cmpl_item_t	item[RXCPL_AGGR_CNT_EXT];
1682*4882a593Smuzhiyun } host_rxbuf_cmpl_aggr_ext_t;
1683*4882a593Smuzhiyun 
1684*4882a593Smuzhiyun /* txpost extended tag types */
1685*4882a593Smuzhiyun typedef uint8 txpost_ext_tag_type_t;
1686*4882a593Smuzhiyun enum {
1687*4882a593Smuzhiyun 	TXPOST_EXT_TAG_TYPE_RSVD	= 0u,	/* Reserved */
1688*4882a593Smuzhiyun 	TXPOST_EXT_TAG_TYPE_CSO		= 1u,
1689*4882a593Smuzhiyun 	TXPOST_EXT_TAG_TYPE_MESH	= 2u,
1690*4882a593Smuzhiyun 	TXPOST_EXT_TAG_TYPE_MAX		= 3u	/* NOTE: increment this as you add reasons above */
1691*4882a593Smuzhiyun };
1692*4882a593Smuzhiyun 
1693*4882a593Smuzhiyun /* Fixed lengths for each extended tag */
1694*4882a593Smuzhiyun typedef uint8 txpost_ext_tag_len_t;
1695*4882a593Smuzhiyun enum {
1696*4882a593Smuzhiyun 	TXPOST_EXT_TAG_LEN_RSVD		= 0u, /* Reserved */
1697*4882a593Smuzhiyun 	TXPOST_EXT_TAG_LEN_CSO		= 4u,
1698*4882a593Smuzhiyun 	TXPOST_EXT_TAG_LEN_MESH		= 20u
1699*4882a593Smuzhiyun };
1700*4882a593Smuzhiyun 
1701*4882a593Smuzhiyun /*
1702*4882a593Smuzhiyun  * Note: The only requirement is that the overall size of the workitem be multiple of 8.
1703*4882a593Smuzhiyun  * However, each individual ext tag not necessarily 8x.
1704*4882a593Smuzhiyun  */
1705*4882a593Smuzhiyun 
1706*4882a593Smuzhiyun #endif /* _bcmmsgbuf_h_ */
1707