summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/io/mwl/mwl_reg.h
blob: 154a9020c226dd47a9664d3d08a249cfb793861f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
 * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer,
 *    without modification.
 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
 *    redistribution must be conditioned upon including a substantially
 *    similar Disclaimer requirement for further binary redistribution.
 *
 * NO WARRANTY
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGES.
 */

/*
 * Definitions for the Marvell Wireless LAN controller Hardware Access Layer.
 */

#ifndef _MWL_REG_H
#define	_MWL_REG_H

#ifdef __cplusplus
extern "C" {
#endif

#define	MWL_MBSS_SUPPORT		/* enable multi-bss support */

/*
 * Host/Firmware Interface definitions.
 */

/*
 * Define total number of TX queues in the shared memory.
 * This count includes the EDCA queues, Block Ack queues, and HCCA queues
 * In addition to this, there could be a management packet queue some
 * time in the future
 */
#define	NUM_EDCA_QUEUES		4
#define	NUM_HCCA_QUEUES		0
#define	NUM_BA_QUEUES		0
#define	NUM_MGMT_QUEUES		0
#define	NUM_ACK_EVENT_QUEUE	1
#define	TOTAL_TX_QUEUES		\
	(NUM_EDCA_QUEUES +	\
	NUM_HCCA_QUEUES +	\
	NUM_BA_QUEUES +		\
	NUM_MGMT_QUEUES +	\
	NUM_ACK_EVENT_QUEUE)
#define	MAX_TXWCB_QUEUES	TOTAL_TX_QUEUES - NUM_ACK_EVENT_QUEUE
#define	MAX_RXWCB_QUEUES	1

/*
 * Firmware download support.
 */
#define	FW_DOWNLOAD_BLOCK_SIZE	256
#define	FW_CHECK_USECS		(5*1000) /* 5ms */
#define	FW_MAX_NUM_CHECKS	200

#define	MWL_ANT_INFO_SUPPORT /* per-antenna data in rx descriptor */

#define	MACREG_REG_TSF_LOW	0xa600 /* TSF lo */
#define	MACREG_REG_TSF_HIGH	0xa604 /* TSF hi */
#define	MACREG_REG_CHIP_REV	0xa814 /* chip rev */

/*
 * Map to 0x80000000 (Bus control) on BAR0
 */
/* From host to ARM */
#define	MACREG_REG_H2A_INTERRUPT_EVENTS		0x00000C18
#define	MACREG_REG_H2A_INTERRUPT_CAUSE		0x00000C1C
#define	MACREG_REG_H2A_INTERRUPT_MASK		0x00000C20
#define	MACREG_REG_H2A_INTERRUPT_CLEAR_SEL	0x00000C24
#define	MACREG_REG_H2A_INTERRUPT_STATUS_MASK	0x00000C28
/* From ARM to host */
#define	MACREG_REG_A2H_INTERRUPT_EVENTS		0x00000C2C
#define	MACREG_REG_A2H_INTERRUPT_CAUSE		0x00000C30
#define	MACREG_REG_A2H_INTERRUPT_MASK		0x00000C34
#define	MACREG_REG_A2H_INTERRUPT_CLEAR_SEL	0x00000C38
#define	MACREG_REG_A2H_INTERRUPT_STATUS_MASK	0x00000C3C


/* Map to 0x80000000 on BAR1 */
#define	MACREG_REG_GEN_PTR		0x00000C10
#define	MACREG_REG_INT_CODE		0x00000C14
#define	MACREG_REG_SCRATCH		0x00000C40
#define	MACREG_REG_FW_PRESENT		0x0000BFFC

#define	MACREG_REG_PROMISCUOUS		0xA300
/* Bit definitio for MACREG_REG_A2H_INTERRUPT_CAUSE (A2HRIC) */
#define	MACREG_A2HRIC_BIT_TX_DONE	0x00000001 /* bit 0 */
#define	MACREG_A2HRIC_BIT_RX_RDY	0x00000002 /* bit 1 */
#define	MACREG_A2HRIC_BIT_OPC_DONE	0x00000004 /* bit 2 */
#define	MACREG_A2HRIC_BIT_MAC_EVENT	0x00000008 /* bit 3 */
#define	MACREG_A2HRIC_BIT_RX_PROBLEM	0x00000010 /* bit 4 */

#define	MACREG_A2HRIC_BIT_RADIO_OFF	0x00000020 /* bit 5 */
#define	MACREG_A2HRIC_BIT_RADIO_ON	0x00000040 /* bit 6 */

#define	MACREG_A2HRIC_BIT_RADAR_DETECT	0x00000080 /* bit 7 */

#define	MACREG_A2HRIC_BIT_ICV_ERROR	0x00000100 /* bit 8 */
#define	MACREG_A2HRIC_BIT_MIC_ERROR	0x00000200 /* bit 9 */
#define	MACREG_A2HRIC_BIT_QUEUE_EMPTY	0x00004000
#define	MACREG_A2HRIC_BIT_QUEUE_FULL	0x00000800
#define	MACREG_A2HRIC_BIT_CHAN_SWITCH	0x00001000
#define	MACREG_A2HRIC_BIT_TX_WATCHDOG	0x00002000
#define	MACREG_A2HRIC_BIT_BA_WATCHDOG	0x00000400
#define	MACREQ_A2HRIC_BIT_TX_ACK	0x00008000
#define	ISR_SRC_BITS	((MACREG_A2HRIC_BIT_RX_RDY)	| \
			(MACREG_A2HRIC_BIT_TX_DONE)	| \
			(MACREG_A2HRIC_BIT_OPC_DONE)	| \
			(MACREG_A2HRIC_BIT_MAC_EVENT)	| \
			(MACREG_A2HRIC_BIT_MIC_ERROR)	| \
			(MACREG_A2HRIC_BIT_ICV_ERROR)	| \
			(MACREG_A2HRIC_BIT_RADAR_DETECT)| \
			(MACREG_A2HRIC_BIT_CHAN_SWITCH)	| \
			(MACREG_A2HRIC_BIT_TX_WATCHDOG)	| \
			(MACREG_A2HRIC_BIT_QUEUE_EMPTY)	| \
			(MACREG_A2HRIC_BIT_BA_WATCHDOG)	| \
			(MACREQ_A2HRIC_BIT_TX_ACK))

#define	MACREG_A2HRIC_BIT_MASK	ISR_SRC_BITS

/* Bit definitio for MACREG_REG_H2A_INTERRUPT_CAUSE (H2ARIC) */
#define	MACREG_H2ARIC_BIT_PPA_READY	0x00000001 /* bit 0 */
#define	MACREG_H2ARIC_BIT_DOOR_BELL	0x00000002 /* bit 1 */
#define	ISR_RESET			(1<<15)

/* INT code register event definition */
#define	MACREG_INT_CODE_CMD_FINISHED	0x00000005

/*
 * Define OpMode for SoftAP/Station mode
 */

/*
 * The following mode signature has to be written to PCI scratch register#0
 * right after successfully downloading the last block of firmware and
 * before waiting for firmware ready signature
 */
#define	HostCmd_STA_MODE		0x5A
#define	HostCmd_SOFTAP_MODE		0xA5

#define	HostCmd_STA_FWRDY_SIGNATURE	0xF0F1F2F4
#define	HostCmd_SOFTAP_FWRDY_SIGNATURE	0xF1F2F4A5

#define	HostCmd_CMD_CODE_DNLD			0x0001
#define	HostCmd_CMD_GET_HW_SPEC			0x0003
#define	HostCmd_CMD_SET_HW_SPEC			0x0004
#define	HostCmd_CMD_MAC_MULTICAST_ADR		0x0010
#define	HostCmd_CMD_802_11_GET_STAT		0x0014
#define	HostCmd_CMD_MAC_REG_ACCESS		0x0019
#define	HostCmd_CMD_BBP_REG_ACCESS		0x001a
#define	HostCmd_CMD_RF_REG_ACCESS		0x001b
#define	HostCmd_CMD_802_11_RADIO_CONTROL	0x001c
#define	HostCmd_CMD_802_11_RF_TX_POWER		0x001e
#define	HostCmd_CMD_802_11_RF_ANTENNA		0x0020
#define	HostCmd_CMD_SET_BEACON			0x0100
#define	HostCmd_CMD_SET_AID			0x010d
#define	HostCmd_CMD_SET_RF_CHANNEL		0x010a
#define	HostCmd_CMD_SET_INFRA_MODE		0x010e
#define	HostCmd_CMD_SET_G_PROTECT_FLAG		0x010f
#define	HostCmd_CMD_802_11_RTS_THSD		0x0113
#define	HostCmd_CMD_802_11_SET_SLOT		0x0114

#define	HostCmd_CMD_802_11H_DETECT_RADAR	0x0120
#define	HostCmd_CMD_SET_WMM_MODE		0x0123
#define	HostCmd_CMD_HT_GUARD_INTERVAL		0x0124
#define	HostCmd_CMD_SET_FIXED_RATE		0x0126
#define	HostCmd_CMD_SET_LINKADAPT_CS_MODE	0x0129
#define	HostCmd_CMD_SET_MAC_ADDR		0x0202
#define	HostCmd_CMD_SET_RATE_ADAPT_MODE		0x0203
#define	HostCmd_CMD_GET_WATCHDOG_BITMAP		0x0205

/* SoftAP command code */
#define	HostCmd_CMD_BSS_START			0x1100
#define	HostCmd_CMD_SET_NEW_STN			0x1111
#define	HostCmd_CMD_SET_KEEP_ALIVE		0x1112
#define	HostCmd_CMD_SET_APMODE			0x1114
#define	HostCmd_CMD_SET_SWITCH_CHANNEL		0x1121

/*
 * @HWENCR@
 * Command to update firmware encryption keys.
 */
#define	HostCmd_CMD_UPDATE_ENCRYPTION		0x1122
/*
 * @11E-BA@
 * Command to create/destroy block ACK
 */
#define	HostCmd_CMD_BASTREAM			0x1125
#define	HostCmd_CMD_SET_RIFS			0x1126
#define	HostCmd_CMD_SET_N_PROTECT_FLAG		0x1131
#define	HostCmd_CMD_SET_N_PROTECT_OPMODE	0x1132
#define	HostCmd_CMD_SET_OPTIMIZATION_LEVEL	0x1133
#define	HostCmd_CMD_GET_CALTABLE		0x1134
#define	HostCmd_CMD_SET_MIMOPSHT		0x1135
#define	HostCmd_CMD_GET_BEACON			0x1138
#define	HostCmd_CMD_SET_REGION_CODE		0x1139
#define	HostCmd_CMD_SET_POWERSAVESTATION	0x1140
#define	HostCmd_CMD_SET_TIM			0x1141
#define	HostCmd_CMD_GET_TIM			0x1142
#define	HostCmd_CMD_GET_SEQNO			0x1143
#define	HostCmd_CMD_DWDS_ENABLE			0x1144
#define	HostCmd_CMD_AMPDU_RETRY_RATEDROP_MODE	0x1145
#define	HostCmd_CMD_CFEND_ENABLE		0x1146

/*
 * Define general result code for each command
 */
/* RESULT OK */
#define	HostCmd_RESULT_OK		0x0000
/* Genenral error */
#define	HostCmd_RESULT_ERROR		0x0001
/* Command is not valid */
#define	HostCmd_RESULT_NOT_SUPPORT	0x0002
/* Command is pending (will be processed) */
#define	HostCmd_RESULT_PENDING		0x0003
/* System is busy (command ignored) */
#define	HostCmd_RESULT_BUSY		0x0004
/* Data buffer is not big enough */
#define	HostCmd_RESULT_PARTIAL_DATA	0x0005

#define	HostCmd_CMD_SET_EDCA_PARAMS	0x0115

/*
 * Definition of action or option for each command
 */

/*
 * Define general purpose action
 */
#define	HostCmd_ACT_GEN_READ	0x0000
#define	HostCmd_ACT_GEN_WRITE	0x0001
#define	HostCmd_ACT_GEN_GET	0x0000
#define	HostCmd_ACT_GEN_SET	0x0001
#define	HostCmd_ACT_GEN_OFF	0x0000
#define	HostCmd_ACT_GEN_ON	0x0001

#define	HostCmd_ACT_DIFF_CHANNEL	0x0002
#define	HostCmd_ACT_GEN_SET_LIST	0x0002

/* Define action or option for HostCmd_FW_USE_FIXED_RATE */
#define	HostCmd_ACT_USE_FIXED_RATE	0x0001
#define	HostCmd_ACT_NOT_USE_FIXED_RATE	0x0002

/* Define action or option for HostCmd_CMD_802_11_SET_WEP */
#define	HostCmd_ACT_ADD		0x0002
#define	HostCmd_ACT_REMOVE	0x0004
#define	HostCmd_ACT_USE_DEFAULT	0x0008

/*
 * PUBLIC DEFINITIONS
 */
#define	RATE_INDEX_MAX_ARRAY	14
#define	WOW_MAX_STATION		32


#pragma pack(1)

struct mwl_ant_info {
	uint8_t		rssi_a;	/* RSSI for antenna A */
	uint8_t		rssi_b;	/* RSSI for antenna B */
	uint8_t		rssi_c;	/* RSSI for antenna C */
	uint8_t		rsvd1;	/* Reserved */
	uint8_t		nf_a;	/* Noise floor for antenna A */
	uint8_t		nf_b;	/* Noise floor for antenna B */
	uint8_t		nf_c;	/* Noise floor for antenna C */
	uint8_t		rsvd2;	/* Reserved */
	uint8_t		nf;	/* Noise floor */
	uint8_t		rsvd3[3]; /* Reserved - To make word aligned */
};

/*
 * Hardware tx/rx descriptors.
 *
 * NB: tx descriptor size must match f/w expected size
 * because f/w prefetch's the next descriptor linearly
 * and doesn't chase the next pointer.
 */
struct mwl_txdesc {
	uint32_t	Status;
#define	EAGLE_TXD_STATUS_IDLE		0x00000000
#define	EAGLE_TXD_STATUS_USED		0x00000001
#define	EAGLE_TXD_STATUS_OK		0x00000001
#define	EAGLE_TXD_STATUS_OK_RETRY	0x00000002
#define	EAGLE_TXD_STATUS_OK_MORE_RETRY	0x00000004
#define	EAGLE_TXD_STATUS_MULTICAST_TX	0x00000008
#define	EAGLE_TXD_STATUS_BROADCAST_TX	0x00000010
#define	EAGLE_TXD_STATUS_FAILED_LINK_ERROR		0x00000020
#define	EAGLE_TXD_STATUS_FAILED_EXCEED_LIMIT		0x00000040
#define	EAGLE_TXD_STATUS_FAILED_XRETRY	EAGLE_TXD_STATUS_FAILED_EXCEED_LIMIT
#define	EAGLE_TXD_STATUS_FAILED_AGING	0x00000080
#define	EAGLE_TXD_STATUS_FW_OWNED	0x80000000
	uint8_t		DataRate;
	uint8_t		TxPriority;
	uint16_t	QosCtrl;
	uint32_t	PktPtr;
	uint16_t	PktLen;
	uint8_t		DestAddr[6];
	uint32_t	pPhysNext;
	uint32_t	SapPktInfo;
#define	EAGLE_TXD_MODE_BONLY	1
#define	EAGLE_TXD_MODE_GONLY	2
#define	EAGLE_TXD_MODE_BG	3
#define	EAGLE_TXD_MODE_NONLY	4
#define	EAGLE_TXD_MODE_BN	5
#define	EAGLE_TXD_MODE_GN	6
#define	EAGLE_TXD_MODE_BGN	7
#define	EAGLE_TXD_MODE_AONLY	8
#define	EAGLE_TXD_MODE_AG	10
#define	EAGLE_TXD_MODE_AN	12
	uint16_t	Format;
#define	EAGLE_TXD_FORMAT	0x0001	/* frame format/rate */
#define	EAGLE_TXD_FORMAT_LEGACY	0x0000	/* legacy rate frame */
#define	EAGLE_TXD_FORMAT_HT	0x0001	/* HT rate frame */
#define	EAGLE_TXD_GI		0x0002	/* guard interval */
#define	EAGLE_TXD_GI_SHORT	0x0002	/* short guard interval */
#define	EAGLE_TXD_GI_LONG	0x0000	/* long guard interval */
#define	EAGLE_TXD_CHW		0x0004	/* channel width */
#define	EAGLE_TXD_CHW_20	0x0000	/* 20MHz channel width */
#define	EAGLE_TXD_CHW_40	0x0004	/* 40MHz channel width */
#define	EAGLE_TXD_RATE		0x01f8	/* tx rate (legacy)/ MCS */
#define	EAGLE_TXD_RATE_S	3
#define	EAGLE_TXD_ADV		0x0600	/* advanced coding */
#define	EAGLE_TXD_ADV_S		9
#define	EAGLE_TXD_ADV_NONE	0x0000
#define	EAGLE_TXD_ADV_LDPC	0x0200
#define	EAGLE_TXD_ADV_RS	0x0400
/* NB: 3 is reserved */
#define	EAGLE_TXD_ANTENNA	0x1800	/* antenna select */
#define	EAGLE_TXD_ANTENNA_S	11
#define	EAGLE_TXD_EXTCHAN	0x6000	/* extension channel */
#define	EAGLE_TXD_EXTCHAN_S	13
#define	EAGLE_TXD_EXTCHAN_HI	0x0000	/* above */
#define	EAGLE_TXD_EXTCHAN_LO	0x2000	/* below */
#define	EAGLE_TXD_PREAMBLE	0x8000
#define	EAGLE_TXD_PREAMBLE_SHORT 0x8000	/* short preamble */
#define	EAGLE_TXD_PREAMBLE_LONG 0x0000	/* long preamble */
	uint16_t	pad;		/* align to 4-byte boundary */
#define	EAGLE_TXD_FIXED_RATE	0x0100	/* get tx rate from Format */
#define	EAGLE_TXD_DONT_AGGR	0x0200	/* don't aggregate frame */
	uint32_t	ack_wcb_addr;
};

struct mwl_rxdesc {
	/* control element */
	uint8_t		RxControl;
#define	EAGLE_RXD_CTRL_DRIVER_OWN	0x00
#define	EAGLE_RXD_CTRL_OS_OWN		0x04
#define	EAGLE_RXD_CTRL_DMA_OWN		0x80
	/* received signal strengt indication */
	uint8_t		RSSI;
	/* status field w/ USED bit */
	uint8_t		Status;
#define	EAGLE_RXD_STATUS_IDLE		0x00
#define	EAGLE_RXD_STATUS_OK		0x01
#define	EAGLE_RXD_STATUS_MULTICAST_RX	0x02
#define	EAGLE_RXD_STATUS_BROADCAST_RX	0x04
#define	EAGLE_RXD_STATUS_FRAGMENT_RX	0x08
#define	EAGLE_RXD_STATUS_GENERAL_DECRYPT_ERR	0xff
#define	EAGLE_RXD_STATUS_DECRYPT_ERR_MASK	0x80
#define	EAGLE_RXD_STATUS_TKIP_MIC_DECRYPT_ERR	0x02
#define	EAGLE_RXD_STATUS_WEP_ICV_DECRYPT_ERR	0x04
#define	EAGLE_RXD_STATUS_TKIP_ICV_DECRYPT_ERR	0x08
	/* channel # pkt received on */
	uint8_t		Channel;
	/* total length of received data */
	uint16_t	PktLen;
	/* not used */
	uint8_t		SQ2;
	/* received data rate */
	uint8_t		Rate;
	/* physical address of payload data */
	uint32_t	pPhysBuffData;
	/* physical address of next RX desc */
	uint32_t	pPhysNext;
	/* received QosCtrl field variable */
	uint16_t	QosCtrl;
	/* like name states */
	uint16_t	HtSig2;
#ifdef MWL_ANT_INFO_SUPPORT
	/* antenna info */
	struct mwl_ant_info ai;
#endif
};
#pragma pack()



// =============================================================================
//			HOST COMMAND DEFINITIONS
// =============================================================================

//
// Definition of data structure for each command
//
// Define general data structure
#pragma pack(1)
typedef struct {
	uint16_t	Cmd;
	uint16_t	Length;
#ifdef MWL_MBSS_SUPPORT
	uint8_t		SeqNum;
	uint8_t		MacId;
#else
	uint16_t	SeqNum;
#endif
	uint16_t	Result;
} FWCmdHdr;

typedef struct {
	FWCmdHdr	CmdHdr;
	uint8_t		annex;
	uint8_t		index;
	uint8_t		len;
	uint8_t		Reserverd;
#define	CAL_TBL_SIZE	160
	uint8_t	calTbl[CAL_TBL_SIZE];
} HostCmd_FW_GET_CALTABLE;

typedef struct {
	FWCmdHdr	CmdHdr;
	/* version of the HW */
	uint8_t		Version;
	/* host interface */
	uint8_t		HostIf;
	/* Max. number of WCB FW can handle */
	uint16_t	NumOfWCB;
	/* MaxNbr of MC addresses FW can handle */
	uint16_t	NumOfMCastAddr;
	/* MAC address programmed in HW */
	uint8_t		PermanentAddr[6];
	uint16_t	RegionCode;
	/* Number of antenna used */
	uint16_t	NumberOfAntenna;
	/* 4 byte of FW release number */
	uint32_t	FWReleaseNumber;
	uint32_t	WcbBase0;
	uint32_t	RxPdWrPtr;
	uint32_t	RxPdRdPtr;
	uint32_t	ulFwAwakeCookie;
	uint32_t	WcbBase1[3];
} HostCmd_DS_GET_HW_SPEC;

typedef struct {
	FWCmdHdr	CmdHdr;
	/* HW revision */
	uint8_t		Version;
	/* Host interface */
	uint8_t		HostIf;
	/* Max. number of Multicast address FW can handle */
	uint16_t	NumOfMCastAdr;
	/* MAC address */
	uint8_t		PermanentAddr[6];
	/* Region Code */
	uint16_t	RegionCode;
	/* 4 byte of FW release number */
	uint32_t	FWReleaseNumber;
	/* Firmware awake cookie */
	uint32_t	ulFwAwakeCookie;
	/* Device capabilities (see above) */
	uint32_t	DeviceCaps;
	/* Rx shared memory queue */
	uint32_t	RxPdWrPtr;
	/* TX queues in WcbBase array */
	uint32_t	NumTxQueues;
	/* TX WCB Rings */
	uint32_t	WcbBase[MAX_TXWCB_QUEUES];
	uint32_t	Flags;
#define	SET_HW_SPEC_DISABLEMBSS		0x08
#define	SET_HW_SPEC_HOSTFORM_BEACON	0x10
#define	SET_HW_SPEC_HOSTFORM_PROBERESP	0x20
#define	SET_HW_SPEC_HOST_POWERSAVE	0x40
#define	SET_HW_SPEC_HOSTENCRDECR_MGMT	0x80
	uint32_t	TxWcbNumPerQueue;
	uint32_t	TotalRxWcb;
}HostCmd_DS_SET_HW_SPEC;

// used for stand alone bssid sets/clears
typedef struct {
	FWCmdHdr	CmdHdr;
#ifdef MWL_MBSS_SUPPORT
	uint16_t	MacType;
#define	WL_MAC_TYPE_PRIMARY_CLIENT	0
#define	WL_MAC_TYPE_SECONDARY_CLIENT	1
#define	WL_MAC_TYPE_PRIMARY_AP		2
#define	WL_MAC_TYPE_SECONDARY_AP	3
#endif
	uint8_t		MacAddr[6];
} HostCmd_DS_SET_MAC,
	HostCmd_FW_SET_BSSID,
	HostCmd_FW_SET_MAC;

typedef struct {
	uint32_t	LegacyRateBitMap;
	uint32_t	HTRateBitMap;
	uint16_t	CapInfo;
	uint16_t	HTCapabilitiesInfo;
	uint8_t		MacHTParamInfo;
	uint8_t		Rev;
	struct {
		uint8_t		ControlChan;
		uint8_t		AddChan;
		uint16_t	OpMode;
		uint16_t	stbc;
	} AddHtInfo;
} PeerInfo_t;

typedef struct {
	FWCmdHdr	CmdHdr;
	uint16_t	AID;
	uint8_t		MacAddr[6];
	uint16_t	StnId;
	uint16_t	Action;
	uint16_t	Reserved;
	PeerInfo_t	PeerInfo;
	uint8_t		Qosinfo;
	uint8_t		isQosSta;
	uint32_t	FwStaPtr;
} HostCmd_FW_SET_NEW_STN;

/* Define data structure for HostCmd_CMD_802_11_RF_ANTENNA */
typedef struct _HostCmd_DS_802_11_RF_ANTENNA {
	FWCmdHdr	CmdHdr;
	uint16_t	Action;
	/* Number of antennas or 0xffff(diversity) */
	uint16_t	AntennaMode;
} HostCmd_DS_802_11_RF_ANTENNA;

/* Define data structure for HostCmd_CMD_802_11_RADIO_CONTROL */
typedef struct {
	FWCmdHdr	CmdHdr;
	uint16_t	Action;
	/*
	 *  @bit0: 1/0, on/off
	 *  @bit1: 1/0, long/short
	 *  @bit2: 1/0,auto/fix
	 */
	uint16_t	Control;
	uint16_t	RadioOn;
} HostCmd_DS_802_11_RADIO_CONTROL;

/* for HostCmd_CMD_SET_WMM_MODE */
typedef struct {
	FWCmdHdr	CmdHdr;
	/* 0->unset, 1->set */
	uint16_t	Action;
} HostCmd_FW_SetWMMMode;

/* bits 0-5 specify frequency band */
#define	FREQ_BAND_2DOT4GHZ	0x0001
#define	FREQ_BAND_4DOT9GHZ	0x0002	/* XXX not implemented */
#define	FREQ_BAND_5GHZ		0x0004
#define	FREQ_BAND_5DOT2GHZ	0x0008	/* XXX not implemented */
/* bits 6-10 specify channel width */
#define	CH_AUTO_WIDTH		0x0000	/* XXX not used? */
#define	CH_10_MHz_WIDTH		0x0040
#define	CH_20_MHz_WIDTH		0x0080
#define	CH_40_MHz_WIDTH		0x0100
/* bits 11-12 specify extension channel */
#define	EXT_CH_NONE		0x0000	/* no extension channel */
#define	EXT_CH_ABOVE_CTRL_CH	0x0800	/* extension channel above */
#define	EXT_CH_AUTO		0x1000	/* XXX not used? */
#define	EXT_CH_BELOW_CTRL_CH	0x1800	/* extension channel below */
/* bits 13-31 are reserved */

#define	FIXED_RATE_WITH_AUTO_RATE_DROP		0
#define	FIXED_RATE_WITHOUT_AUTORATE_DROP	1

#define	LEGACY_RATE_TYPE			0
#define	HT_RATE_TYPE				1

#define	RETRY_COUNT_VALID			0
#define	RETRY_COUNT_INVALID			1

// Define data structure for HostCmd_CMD_802_11_RF_CHANNEL
typedef struct {
	FWCmdHdr	CmdHdr;
	uint16_t	Action;
	uint8_t		CurrentChannel;	/* channel # */
	uint32_t	ChannelFlags;	/* see below */
} HostCmd_FW_SET_RF_CHANNEL;

#define	TX_POWER_LEVEL_TOTAL	8

/* Define data structure for HostCmd_CMD_802_11_RF_TX_POWER */
typedef struct {
	FWCmdHdr	CmdHdr;
	uint16_t	Action;
	uint16_t	SupportTxPowerLevel;
	uint16_t	CurrentTxPowerLevel;
	uint16_t	Reserved;
	uint16_t	PowerLevelList[TX_POWER_LEVEL_TOTAL];
} HostCmd_DS_802_11_RF_TX_POWER;

typedef struct {
	/*
	 * lower rate after the retry count
	 * 0: legacy, 1: HT
	 */
	uint32_t	FixRateType;
	/*
	 *  0: retry count is not valid
	 *  1: use retry count specified
	 */
	uint32_t	RetryCountValid;
} FIX_RATE_FLAG;

typedef  struct {
	FIX_RATE_FLAG	FixRateTypeFlags;
	/* legacy rate(not index) or an MCS code */
	uint32_t	FixedRate;
	uint32_t	RetryCount;
} FIXED_RATE_ENTRY;

typedef  struct {
	FWCmdHdr	CmdHdr;
	/*
	 * HostCmd_ACT_GEN_GET			0x0000
	 * HostCmd_ACT_GEN_SET 			0x0001
	 * HostCmd_ACT_NOT_USE_FIXED_RATE	0x0002
	 */
	uint32_t	Action;
	/* use fixed rate specified but firmware can drop */
	uint32_t	AllowRateDrop;
	uint32_t	EntryCount;
	FIXED_RATE_ENTRY FixedRateTable[4];
	uint8_t		MulticastRate;
	uint8_t		MultiRateTxType;
	uint8_t		ManagementRate;
} HostCmd_FW_USE_FIXED_RATE;

/* Define data structure for HostCmd_CMD_SET_RATE_ADAPT_MODE */
typedef struct {
	FWCmdHdr	CmdHdr;
	uint16_t	Action;
	uint16_t	RateAdaptMode;
} HostCmd_DS_SET_RATE_ADAPT_MODE;

typedef struct {
	FWCmdHdr	CmdHdr;
	uint8_t	OptLevel;
} HostCmd_FW_SET_OPTIMIZATION_LEVEL;

typedef struct {
	FWCmdHdr	CmdHdr;
	uint16_t	regionCode;
} HostCmd_SET_REGIONCODE_INFO;

typedef struct {
	FWCmdHdr	CmdHdr;
	uint16_t	Action;	/* 0: Get. 1:Set */
	uint32_t	Option;	/* 0: default. 1:Aggressive */
	uint32_t	Threshold;	/* Range 0-200, default 8 */
} HostCmd_FW_AMPDU_RETRY_RATEDROP_MODE;

typedef struct {
	FWCmdHdr	CmdHdr;
	uint32_t	Enable;	/* 0 -- Disable. or 1 -- Enable */
} HostCmd_CFEND_ENABLE;

typedef struct {
	FWCmdHdr	CmdHdr;
	uint32_t	Enable;	/* FALSE: Disable or TRUE: Enable */
} HostCmd_DS_BSS_START;

typedef struct {
	FWCmdHdr	CmdHdr;
} HostCmd_FW_SET_INFRA_MODE;

/* used for AID sets/clears */
typedef struct {
	FWCmdHdr	CmdHdr;
	uint16_t	AssocID;
	uint8_t		MacAddr[6]; /* AP's Mac Address(BSSID) */
	uint32_t	GProtection;
	uint8_t		ApRates[RATE_INDEX_MAX_ARRAY];
} HostCmd_FW_SET_AID;

typedef struct {
	FWCmdHdr	CmdHdr;
	uint16_t	Action;
	uint16_t	Threshold;
} HostCmd_DS_802_11_RTS_THSD;

/* Define data structure for HostCmd_CMD_SET_LINKADAPT_CS_MODE */
typedef struct {
	FWCmdHdr	CmdHdr;
	uint16_t	Action;
	uint16_t	CSMode;
} HostCmd_DS_SET_LINKADAPT_CS_MODE;

typedef struct {
	FWCmdHdr	CmdHdr;
	uint32_t	ActionType; /* ENCR_ACTION_TYPE */
	uint32_t	DataLength; /* size of the data buffer attached */
#ifdef MWL_MBSS_SUPPORT
	uint8_t	macaddr[6];
#endif
	uint8_t	ActionData[1];
} HostCmd_FW_UPDATE_ENCRYPTION;

/*
 * @HWENCR@
 * Hardware Encryption related data structures and constant definitions.
 * Note that all related changes are marked with the @HWENCR@ tag.
 */

#define	MAX_ENCR_KEY_LENGTH	16	/* max 128 bits - depends on type */
#define	MIC_KEY_LENGTH		8	/* size of Tx/Rx MIC key - 8 bytes */

#define	ENCR_KEY_TYPE_ID_WEP	0x00	/* Key type is WEP */
#define	ENCR_KEY_TYPE_ID_TKIP	0x01	/* Key type is TKIP */
#define	ENCR_KEY_TYPE_ID_AES	0x02	/* Key type is AES-CCMP	*/

/*
 * flags used in structure - same as driver EKF_XXX flags
 */
/* indicate key is in use */
#define	ENCR_KEY_FLAG_INUSE		0x00000001
/* Group key for RX only */
#define	ENCR_KEY_FLAG_RXGROUPKEY	0x00000002
/* Group key for TX */
#define	ENCR_KEY_FLAG_TXGROUPKEY	0x00000004
/* pairwise */
#define	ENCR_KEY_FLAG_PAIRWISE		0x00000008
/* only used for RX */
#define	ENCR_KEY_FLAG_RXONLY		0x00000010
/*
 * These flags are new additions - for hardware encryption commands only
 */
/* Key is for Authenticator */
#define	ENCR_KEY_FLAG_AUTHENTICATOR	0x00000020
/* Sequence counters valid */
#define	ENCR_KEY_FLAG_TSC_VALID		0x00000040
/* Tx key for WEP */
#define	ENCR_KEY_FLAG_WEP_TXKEY		0x01000000
/* Tx/Rx MIC keys are valid */
#define	ENCR_KEY_FLAG_MICKEY_VALID	0x02000000

/*
 * Key material definitions (for WEP, TKIP, & AES-CCMP)
 */

/*
 * WEP Key material definition
 * ----------------------------
 * WEPKey	--> An array of 'MAX_ENCR_KEY_LENGTH' bytes.
 * Note that we do not support 152bit WEP keys
 */
typedef struct {
	/* WEP key material (max 128bit) */
	uint8_t	KeyMaterial[MAX_ENCR_KEY_LENGTH];
} WEP_TYPE_KEY;

/*
 * TKIP Key material definition
 * ----------------------------
 * This structure defines TKIP key material. Note that
 * the TxMicKey and RxMicKey may or may not be valid.
 */
/*
 * TKIP Sequence counter - 24 bits
 * Incremented on each fragment MPDU
 */
typedef struct {
	uint16_t	low;
	uint32_t	high;
} ENCR_TKIPSEQCNT;

/*
 * TKIP Key material. Key type (group or pairwise key) is
 * determined by flags in KEY_PARAM_SET structure
 */
typedef struct {
	uint8_t		KeyMaterial[MAX_ENCR_KEY_LENGTH];
	uint8_t		TkipTxMicKey[MIC_KEY_LENGTH];
	uint8_t		TkipRxMicKey[MIC_KEY_LENGTH];
	ENCR_TKIPSEQCNT	TkipRsc;
	ENCR_TKIPSEQCNT	TkipTsc;
} TKIP_TYPE_KEY;

/*
 * AES-CCMP Key material definition
 * --------------------------------
 * This structure defines AES-CCMP key material.
 */
typedef struct {
	/* AES Key material */
	uint8_t	KeyMaterial[MAX_ENCR_KEY_LENGTH];
} AES_TYPE_KEY;

/*
 * UPDATE_ENCRYPTION command action type.
 */
typedef enum {
	/* request to enable/disable HW encryption */
	EncrActionEnableHWEncryption,
	/* request to set encryption key */
	EncrActionTypeSetKey,
	/* request to remove one or more keys */
	EncrActionTypeRemoveKey,
	EncrActionTypeSetGroupKey
} ENCR_ACTION_TYPE;

/*
 * Encryption key definition.
 * --------------------------
 * This structure provides all required/essential
 * information about the key being set/removed.
 */
typedef struct {
	uint16_t	Length;		/* Total length of this structure */
	uint16_t	KeyTypeId;	/* Key type - WEP, TKIP or AES-CCMP */
	uint32_t	KeyInfo;	/* key flags */
	uint32_t	KeyIndex; 	/* For WEP only - actual key index */
	uint16_t	KeyLen;		/* Size of the key */
	union {				/* Key material (variable size array) */
		WEP_TYPE_KEY	WepKey;
		TKIP_TYPE_KEY	TkipKey;
		AES_TYPE_KEY	AesKey;
	} Key;
#ifdef MWL_MBSS_SUPPORT
	uint8_t	Macaddr[6];
#endif
} KEY_PARAM_SET;


typedef struct {
	FWCmdHdr	CmdHdr;
	uint32_t	ActionType;	/* ENCR_ACTION_TYPE */
	uint32_t	DataLength;	/* size of the data buffer attached */
	KEY_PARAM_SET	KeyParam;
#ifndef MWL_MBSS_SUPPORT
	uint8_t		Macaddr[8];
#endif
} HostCmd_FW_UPDATE_ENCRYPTION_SET_KEY;
#pragma pack()

#ifdef __cplusplus
}
#endif

#endif /* _MWL_REG_H */