wl1251: Prepare for idle mode support
[pandora-wifi.git] / drivers / net / wireless / wl12xx / wl1271_conf.h
1 /*
2  * This file is part of wl1271
3  *
4  * Copyright (C) 2009 Nokia Corporation
5  *
6  * Contact: Luciano Coelho <luciano.coelho@nokia.com>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * version 2 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23
24 #ifndef __WL1271_CONF_H__
25 #define __WL1271_CONF_H__
26
27 enum {
28         CONF_HW_BIT_RATE_1MBPS   = BIT(0),
29         CONF_HW_BIT_RATE_2MBPS   = BIT(1),
30         CONF_HW_BIT_RATE_5_5MBPS = BIT(2),
31         CONF_HW_BIT_RATE_6MBPS   = BIT(3),
32         CONF_HW_BIT_RATE_9MBPS   = BIT(4),
33         CONF_HW_BIT_RATE_11MBPS  = BIT(5),
34         CONF_HW_BIT_RATE_12MBPS  = BIT(6),
35         CONF_HW_BIT_RATE_18MBPS  = BIT(7),
36         CONF_HW_BIT_RATE_22MBPS  = BIT(8),
37         CONF_HW_BIT_RATE_24MBPS  = BIT(9),
38         CONF_HW_BIT_RATE_36MBPS  = BIT(10),
39         CONF_HW_BIT_RATE_48MBPS  = BIT(11),
40         CONF_HW_BIT_RATE_54MBPS  = BIT(12),
41         CONF_HW_BIT_RATE_MCS_0   = BIT(13),
42         CONF_HW_BIT_RATE_MCS_1   = BIT(14),
43         CONF_HW_BIT_RATE_MCS_2   = BIT(15),
44         CONF_HW_BIT_RATE_MCS_3   = BIT(16),
45         CONF_HW_BIT_RATE_MCS_4   = BIT(17),
46         CONF_HW_BIT_RATE_MCS_5   = BIT(18),
47         CONF_HW_BIT_RATE_MCS_6   = BIT(19),
48         CONF_HW_BIT_RATE_MCS_7   = BIT(20)
49 };
50
51 enum {
52         CONF_HW_RATE_INDEX_1MBPS   = 0,
53         CONF_HW_RATE_INDEX_2MBPS   = 1,
54         CONF_HW_RATE_INDEX_5_5MBPS = 2,
55         CONF_HW_RATE_INDEX_6MBPS   = 3,
56         CONF_HW_RATE_INDEX_9MBPS   = 4,
57         CONF_HW_RATE_INDEX_11MBPS  = 5,
58         CONF_HW_RATE_INDEX_12MBPS  = 6,
59         CONF_HW_RATE_INDEX_18MBPS  = 7,
60         CONF_HW_RATE_INDEX_22MBPS  = 8,
61         CONF_HW_RATE_INDEX_24MBPS  = 9,
62         CONF_HW_RATE_INDEX_36MBPS  = 10,
63         CONF_HW_RATE_INDEX_48MBPS  = 11,
64         CONF_HW_RATE_INDEX_54MBPS  = 12,
65         CONF_HW_RATE_INDEX_MAX     = CONF_HW_RATE_INDEX_54MBPS,
66 };
67
68 struct conf_sg_settings {
69         /*
70          * Defines the PER threshold in PPM of the BT voice of which reaching
71          * this value will trigger raising the priority of the BT voice by
72          * the BT IP until next NFS sample interval time as defined in
73          * nfs_sample_interval.
74          *
75          * Unit: PER value in PPM (parts per million)
76          * #Error_packets / #Total_packets
77
78          * Range: u32
79          */
80         u32 per_threshold;
81
82         /*
83          * This value is an absolute time in micro-seconds to limit the
84          * maximum scan duration compensation while in SG
85          */
86         u32 max_scan_compensation_time;
87
88         /* Defines the PER threshold of the BT voice of which reaching this
89          * value will trigger raising the priority of the BT voice until next
90          * NFS sample interval time as defined in sample_interval.
91          *
92          * Unit: msec
93          * Range: 1-65000
94          */
95         u16 nfs_sample_interval;
96
97         /*
98          * Defines the load ratio for the BT.
99          * The WLAN ratio is: 100 - load_ratio
100          *
101          * Unit: Percent
102          * Range: 0-100
103          */
104         u8 load_ratio;
105
106         /*
107          * true - Co-ex is allowed to enter/exit P.S automatically and
108          *        transparently to the host
109          *
110          * false - Co-ex is disallowed to enter/exit P.S and will trigger an
111          *         event to the host to notify for the need to enter/exit P.S
112          *         due to BT change state
113          *
114          */
115         u8 auto_ps_mode;
116
117         /*
118          * This parameter defines the compensation percentage of num of probe
119          * requests in case scan is initiated during BT voice/BT ACL
120          * guaranteed link.
121          *
122          * Unit: Percent
123          * Range: 0-255 (0 - No compensation)
124          */
125         u8 probe_req_compensation;
126
127         /*
128          * This parameter defines the compensation percentage of scan window
129          * size in case scan is initiated during BT voice/BT ACL Guaranteed
130          * link.
131          *
132          * Unit: Percent
133          * Range: 0-255 (0 - No compensation)
134          */
135         u8 scan_window_compensation;
136
137         /*
138          * Defines the antenna configuration.
139          *
140          * Range: 0 - Single Antenna; 1 - Dual Antenna
141          */
142         u8 antenna_config;
143
144         /*
145          * The percent out of the Max consecutive beacon miss roaming trigger
146          * which is the threshold for raising the priority of beacon
147          * reception.
148          *
149          * Range: 1-100
150          * N = MaxConsecutiveBeaconMiss
151          * P = coexMaxConsecutiveBeaconMissPrecent
152          * Threshold = MIN( N-1, round(N * P / 100))
153          */
154         u8 beacon_miss_threshold;
155
156         /*
157          * The RX rate threshold below which rate adaptation is assumed to be
158          * occurring at the AP which will raise priority for ACTIVE_RX and RX
159          * SP.
160          *
161          * Range: HW_BIT_RATE_*
162          */
163         u32 rate_adaptation_threshold;
164
165         /*
166          * The SNR above which the RX rate threshold indicating AP rate
167          * adaptation is valid
168          *
169          * Range: -128 - 127
170          */
171         s8 rate_adaptation_snr;
172 };
173
174 enum conf_rx_queue_type {
175         CONF_RX_QUEUE_TYPE_LOW_PRIORITY,  /* All except the high priority */
176         CONF_RX_QUEUE_TYPE_HIGH_PRIORITY, /* Management and voice packets */
177 };
178
179 struct conf_rx_settings {
180         /*
181          * The maximum amount of time, in TU, before the
182          * firmware discards the MSDU.
183          *
184          * Range: 0 - 0xFFFFFFFF
185          */
186         u32 rx_msdu_life_time;
187
188         /*
189          * Packet detection threshold in the PHY.
190          *
191          * FIXME: details unknown.
192          */
193         u32 packet_detection_threshold;
194
195         /*
196          * The longest time the STA will wait to receive traffic from the AP
197          * after a PS-poll has been transmitted.
198          *
199          * Range: 0 - 200000
200          */
201         u16 ps_poll_timeout;
202         /*
203          * The longest time the STA will wait to receive traffic from the AP
204          * after a frame has been sent from an UPSD enabled queue.
205          *
206          * Range: 0 - 200000
207          */
208         u16 upsd_timeout;
209
210         /*
211          * The number of octets in an MPDU, below which an RTS/CTS
212          * handshake is not performed.
213          *
214          * Range: 0 - 4096
215          */
216         u16 rts_threshold;
217
218         /*
219          * The RX Clear Channel Assessment threshold in the PHY
220          * (the energy threshold).
221          *
222          * Range: ENABLE_ENERGY_D  == 0x140A
223          *        DISABLE_ENERGY_D == 0xFFEF
224          */
225         u16 rx_cca_threshold;
226
227         /*
228          * Occupied Rx mem-blocks number which requires interrupting the host
229          * (0 = no buffering, 0xffff = disabled).
230          *
231          * Range: u16
232          */
233         u16 irq_blk_threshold;
234
235         /*
236          * Rx packets number which requires interrupting the host
237          * (0 = no buffering).
238          *
239          * Range: u16
240          */
241         u16 irq_pkt_threshold;
242
243         /*
244          * Max time in msec the FW may delay RX-Complete interrupt.
245          *
246          * Range: 1 - 100
247          */
248         u16 irq_timeout;
249
250         /*
251          * The RX queue type.
252          *
253          * Range: RX_QUEUE_TYPE_RX_LOW_PRIORITY, RX_QUEUE_TYPE_RX_HIGH_PRIORITY,
254          */
255         u8 queue_type;
256 };
257
258 #define CONF_TX_MAX_RATE_CLASSES       8
259
260 #define CONF_TX_RATE_MASK_UNSPECIFIED  0
261 #define CONF_TX_RATE_MASK_BASIC        (CONF_HW_BIT_RATE_1MBPS | \
262                                         CONF_HW_BIT_RATE_2MBPS)
263 #define CONF_TX_RATE_RETRY_LIMIT       10
264
265 struct conf_tx_rate_class {
266
267         /*
268          * The rates enabled for this rate class.
269          *
270          * Range: CONF_HW_BIT_RATE_* bit mask
271          */
272         u32 enabled_rates;
273
274         /*
275          * The dot11 short retry limit used for TX retries.
276          *
277          * Range: u8
278          */
279         u8 short_retry_limit;
280
281         /*
282          * The dot11 long retry limit used for TX retries.
283          *
284          * Range: u8
285          */
286         u8 long_retry_limit;
287
288         /*
289          * Flags controlling the attributes of TX transmission.
290          *
291          * Range: bit 0: Truncate - when set, FW attempts to send a frame stop
292          *               when the total valid per-rate attempts have
293          *               been exhausted; otherwise transmissions
294          *               will continue at the lowest available rate
295          *               until the appropriate one of the
296          *               short_retry_limit, long_retry_limit,
297          *               dot11_max_transmit_msdu_life_time, or
298          *               max_tx_life_time, is exhausted.
299          *            1: Preamble Override - indicates if the preamble type
300          *               should be used in TX.
301          *            2: Preamble Type - the type of the preamble to be used by
302          *               the policy (0 - long preamble, 1 - short preamble.
303          */
304         u8 aflags;
305 };
306
307 #define CONF_TX_MAX_AC_COUNT 4
308
309 /* Slot number setting to start transmission at PIFS interval */
310 #define CONF_TX_AIFS_PIFS 1
311 /* Slot number setting to start transmission at DIFS interval normal
312  * DCF access */
313 #define CONF_TX_AIFS_DIFS 2
314
315
316 enum conf_tx_ac {
317         CONF_TX_AC_BE = 0,         /* best effort / legacy */
318         CONF_TX_AC_BK = 1,         /* background */
319         CONF_TX_AC_VI = 2,         /* video */
320         CONF_TX_AC_VO = 3,         /* voice */
321         CONF_TX_AC_CTS2SELF = 4,   /* fictious AC, follows AC_VO */
322         CONF_TX_AC_ANY_TID = 0x1f
323 };
324
325 struct conf_tx_ac_category {
326         /*
327          * The AC class identifier.
328          *
329          * Range: enum conf_tx_ac
330          */
331         u8 ac;
332
333         /*
334          * The contention window minimum size (in slots) for the access
335          * class.
336          *
337          * Range: u8
338          */
339         u8 cw_min;
340
341         /*
342          * The contention window maximum size (in slots) for the access
343          * class.
344          *
345          * Range: u8
346          */
347         u16 cw_max;
348
349         /*
350          * The AIF value (in slots) for the access class.
351          *
352          * Range: u8
353          */
354         u8 aifsn;
355
356         /*
357          * The TX Op Limit (in microseconds) for the access class.
358          *
359          * Range: u16
360          */
361         u16 tx_op_limit;
362 };
363
364 #define CONF_TX_MAX_TID_COUNT 7
365
366 enum {
367         CONF_CHANNEL_TYPE_DCF = 0,   /* DC/LEGACY*/
368         CONF_CHANNEL_TYPE_EDCF = 1,  /* EDCA*/
369         CONF_CHANNEL_TYPE_HCCA = 2,  /* HCCA*/
370 };
371
372 enum {
373         CONF_PS_SCHEME_LEGACY = 0,
374         CONF_PS_SCHEME_UPSD_TRIGGER = 1,
375         CONF_PS_SCHEME_LEGACY_PSPOLL = 2,
376         CONF_PS_SCHEME_SAPSD = 3,
377 };
378
379 enum {
380         CONF_ACK_POLICY_LEGACY = 0,
381         CONF_ACK_POLICY_NO_ACK = 1,
382         CONF_ACK_POLICY_BLOCK = 2,
383 };
384
385
386 struct conf_tx_tid {
387         u8 queue_id;
388         u8 channel_type;
389         u8 tsid;
390         u8 ps_scheme;
391         u8 ack_policy;
392         u32 apsd_conf[2];
393 };
394
395 struct conf_tx_settings {
396         /*
397          * The TX ED value for TELEC Enable/Disable.
398          *
399          * Range: 0, 1
400          */
401         u8 tx_energy_detection;
402
403         /*
404          * Configuration for rate classes for TX (currently only one
405          * rate class supported.)
406          */
407         struct conf_tx_rate_class rc_conf;
408
409         /*
410          * Configuration for access categories for TX rate control.
411          */
412         u8 ac_conf_count;
413         struct conf_tx_ac_category ac_conf[CONF_TX_MAX_AC_COUNT];
414
415         /*
416          * Configuration for TID parameters.
417          */
418         u8 tid_conf_count;
419         struct conf_tx_tid tid_conf[CONF_TX_MAX_TID_COUNT];
420
421         /*
422          * The TX fragmentation threshold.
423          *
424          * Range: u16
425          */
426         u16 frag_threshold;
427
428         /*
429          * Max time in msec the FW may delay frame TX-Complete interrupt.
430          *
431          * Range: u16
432          */
433         u16 tx_compl_timeout;
434
435         /*
436          * Completed TX packet count which requires to issue the TX-Complete
437          * interrupt.
438          *
439          * Range: u16
440          */
441         u16 tx_compl_threshold;
442
443 };
444
445 enum {
446         CONF_WAKE_UP_EVENT_BEACON    = 0x01, /* Wake on every Beacon*/
447         CONF_WAKE_UP_EVENT_DTIM      = 0x02, /* Wake on every DTIM*/
448         CONF_WAKE_UP_EVENT_N_DTIM    = 0x04, /* Wake every Nth DTIM */
449         CONF_WAKE_UP_EVENT_N_BEACONS = 0x08, /* Wake every Nth beacon */
450         CONF_WAKE_UP_EVENT_BITS_MASK = 0x0F
451 };
452
453 #define CONF_MAX_BCN_FILT_IE_COUNT 32
454
455 #define CONF_BCN_RULE_PASS_ON_CHANGE         BIT(0)
456 #define CONF_BCN_RULE_PASS_ON_APPEARANCE     BIT(1)
457
458 #define CONF_BCN_IE_OUI_LEN    3
459 #define CONF_BCN_IE_VER_LEN    2
460
461 struct conf_bcn_filt_rule {
462         /*
463          * IE number to which to associate a rule.
464          *
465          * Range: u8
466          */
467         u8 ie;
468
469         /*
470          * Rule to associate with the specific ie.
471          *
472          * Range: CONF_BCN_RULE_PASS_ON_*
473          */
474         u8 rule;
475
476         /*
477          * OUI for the vendor specifie IE (221)
478          */
479         u8 oui[CONF_BCN_IE_OUI_LEN];
480
481         /*
482          * Type for the vendor specifie IE (221)
483          */
484         u8 type;
485
486         /*
487          * Version for the vendor specifie IE (221)
488          */
489         u8 version[CONF_BCN_IE_VER_LEN];
490 };
491
492 #define CONF_MAX_RSSI_SNR_TRIGGERS 8
493
494 enum {
495         CONF_TRIG_METRIC_RSSI_BEACON = 0,
496         CONF_TRIG_METRIC_RSSI_DATA,
497         CONF_TRIG_METRIC_SNR_BEACON,
498         CONF_TRIG_METRIC_SNR_DATA
499 };
500
501 enum {
502         CONF_TRIG_EVENT_TYPE_LEVEL = 0,
503         CONF_TRIG_EVENT_TYPE_EDGE
504 };
505
506 enum {
507         CONF_TRIG_EVENT_DIR_LOW = 0,
508         CONF_TRIG_EVENT_DIR_HIGH,
509         CONF_TRIG_EVENT_DIR_BIDIR
510 };
511
512
513 struct conf_sig_trigger {
514         /*
515          * The RSSI / SNR threshold value.
516          *
517          * FIXME: what is the range?
518          */
519         s16 threshold;
520
521         /*
522          * Minimum delay between two trigger events for this trigger in ms.
523          *
524          * Range: 0 - 60000
525          */
526         u16 pacing;
527
528         /*
529          * The measurement data source for this trigger.
530          *
531          * Range: CONF_TRIG_METRIC_*
532          */
533         u8 metric;
534
535         /*
536          * The trigger type of this trigger.
537          *
538          * Range: CONF_TRIG_EVENT_TYPE_*
539          */
540         u8 type;
541
542         /*
543          * The direction of the trigger.
544          *
545          * Range: CONF_TRIG_EVENT_DIR_*
546          */
547         u8 direction;
548
549         /*
550          * Hysteresis range of the trigger around the threshold (in dB)
551          *
552          * Range: u8
553          */
554         u8 hysteresis;
555
556         /*
557          * Index of the trigger rule.
558          *
559          * Range: 0 - CONF_MAX_RSSI_SNR_TRIGGERS-1
560          */
561         u8 index;
562
563         /*
564          * Enable / disable this rule (to use for clearing rules.)
565          *
566          * Range: 1 - Enabled, 2 - Not enabled
567          */
568         u8 enable;
569 };
570
571 struct conf_sig_weights {
572
573         /*
574          * RSSI from beacons average weight.
575          *
576          * Range: u8
577          */
578         u8 rssi_bcn_avg_weight;
579
580         /*
581          * RSSI from data average weight.
582          *
583          * Range: u8
584          */
585         u8 rssi_pkt_avg_weight;
586
587         /*
588          * SNR from beacons average weight.
589          *
590          * Range: u8
591          */
592         u8 snr_bcn_avg_weight;
593
594         /*
595          * SNR from data average weight.
596          *
597          * Range: u8
598          */
599         u8 snr_pkt_avg_weight;
600 };
601
602 enum conf_bcn_filt_mode {
603         CONF_BCN_FILT_MODE_DISABLED = 0,
604         CONF_BCN_FILT_MODE_ENABLED = 1
605 };
606
607 enum conf_bet_mode {
608         CONF_BET_MODE_DISABLE = 0,
609         CONF_BET_MODE_ENABLE = 1,
610 };
611
612 struct conf_conn_settings {
613         /*
614          * Firmware wakeup conditions configuration. The host may set only
615          * one bit.
616          *
617          * Range: CONF_WAKE_UP_EVENT_*
618          */
619         u8 wake_up_event;
620
621         /*
622          * Listen interval for beacons or Dtims.
623          *
624          * Range: 0 for beacon and Dtim wakeup
625          *        1-10 for x Dtims
626          *        1-255 for x beacons
627          */
628         u8 listen_interval;
629
630         /*
631          * Enable or disable the beacon filtering.
632          *
633          * Range: CONF_BCN_FILT_MODE_*
634          */
635         enum conf_bcn_filt_mode bcn_filt_mode;
636
637         /*
638          * Configure Beacon filter pass-thru rules.
639          */
640         u8 bcn_filt_ie_count;
641         struct conf_bcn_filt_rule bcn_filt_ie[CONF_MAX_BCN_FILT_IE_COUNT];
642
643         /*
644          * The number of consequtive beacons to lose, before the firmware
645          * becomes out of synch.
646          *
647          * Range: u32
648          */
649         u32 synch_fail_thold;
650
651         /*
652          * After out-of-synch, the number of TU's to wait without a further
653          * received beacon (or probe response) before issuing the BSS_EVENT_LOSE
654          * event.
655          *
656          * Range: u32
657          */
658         u32 bss_lose_timeout;
659
660         /*
661          * Beacon receive timeout.
662          *
663          * Range: u32
664          */
665         u32 beacon_rx_timeout;
666
667         /*
668          * Broadcast receive timeout.
669          *
670          * Range: u32
671          */
672         u32 broadcast_timeout;
673
674         /*
675          * Enable/disable reception of broadcast packets in power save mode
676          *
677          * Range: 1 - enable, 0 - disable
678          */
679         u8 rx_broadcast_in_ps;
680
681         /*
682          * Consequtive PS Poll failures before sending event to driver
683          *
684          * Range: u8
685          */
686         u8 ps_poll_threshold;
687
688         /*
689          * Configuration of signal (rssi/snr) triggers.
690          */
691         u8 sig_trigger_count;
692         struct conf_sig_trigger sig_trigger[CONF_MAX_RSSI_SNR_TRIGGERS];
693
694         /*
695          * Configuration of signal average weights.
696          */
697         struct conf_sig_weights sig_weights;
698
699         /*
700          * Specifies if beacon early termination procedure is enabled or
701          * disabled.
702          *
703          * Range: CONF_BET_MODE_*
704          */
705         u8 bet_enable;
706
707         /*
708          * Specifies the maximum number of consecutive beacons that may be
709          * early terminated. After this number is reached at least one full
710          * beacon must be correctly received in FW before beacon ET
711          * resumes.
712          *
713          * Range 0 - 255
714          */
715         u8 bet_max_consecutive;
716
717         /*
718          * Specifies the maximum number of times to try PSM entry if it fails
719          * (if sending the appropriate null-func message fails.)
720          *
721          * Range 0 - 255
722          */
723         u8 psm_entry_retries;
724 };
725
726 enum {
727         CONF_REF_CLK_19_2_E,
728         CONF_REF_CLK_26_E,
729         CONF_REF_CLK_38_4_E,
730         CONF_REF_CLK_52_E
731 };
732
733 enum single_dual_band_enum {
734         CONF_SINGLE_BAND,
735         CONF_DUAL_BAND
736 };
737
738 #define CONF_RSSI_AND_PROCESS_COMPENSATION_SIZE 15
739 #define CONF_NUMBER_OF_SUB_BANDS_5  7
740 #define CONF_NUMBER_OF_RATE_GROUPS  6
741 #define CONF_NUMBER_OF_CHANNELS_2_4 14
742 #define CONF_NUMBER_OF_CHANNELS_5   35
743
744 struct conf_radio_parms {
745         /*
746          * FEM parameter set to use
747          *
748          * Range: 0 or 1
749          */
750         u8 fem;
751 };
752
753 struct conf_init_settings {
754         /*
755          * Configure radio parameters.
756          */
757         struct conf_radio_parms radioparam;
758
759 };
760
761 struct conf_itrim_settings {
762         /* enable dco itrim */
763         u8 enable;
764
765         /* moderation timeout in microsecs from the last TX */
766         u32 timeout;
767 };
768
769 struct conf_pm_config_settings {
770         /*
771          * Host clock settling time
772          *
773          * Range: 0 - 30000 us
774          */
775         u32 host_clk_settling_time;
776
777         /*
778          * Host fast wakeup support
779          *
780          * Range: true, false
781          */
782         bool host_fast_wakeup_support;
783 };
784
785 struct conf_drv_settings {
786         struct conf_sg_settings sg;
787         struct conf_rx_settings rx;
788         struct conf_tx_settings tx;
789         struct conf_conn_settings conn;
790         struct conf_init_settings init;
791         struct conf_itrim_settings itrim;
792         struct conf_pm_config_settings pm_config;
793 };
794
795 #endif