blob: a470ea0db29e5ab3566366e45f1fc90f2ad80c00 [file] [log] [blame]
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +02001/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2013 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called COPYING.
26 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2013 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *****************************************************************************/
62
63#ifndef __fw_api_bt_coex_h__
64#define __fw_api_bt_coex_h__
65
66#include <linux/types.h>
67#include <linux/bitops.h>
68
69#define BITS(nb) (BIT(nb) - 1)
70
71/**
72 * enum iwl_bt_coex_flags - flags for BT_COEX command
73 * @BT_CH_PRIMARY_EN:
74 * @BT_CH_SECONDARY_EN:
75 * @BT_NOTIF_COEX_OFF:
76 * @BT_COEX_MODE_POS:
77 * @BT_COEX_MODE_MSK:
78 * @BT_COEX_DISABLE:
79 * @BT_COEX_2W:
80 * @BT_COEX_3W:
81 * @BT_COEX_NW:
82 * @BT_USE_DEFAULTS:
83 * @BT_SYNC_2_BT_DISABLE:
84 * @BT_COEX_CORUNNING_TBL_EN:
85 */
86enum iwl_bt_coex_flags {
87 BT_CH_PRIMARY_EN = BIT(0),
88 BT_CH_SECONDARY_EN = BIT(1),
89 BT_NOTIF_COEX_OFF = BIT(2),
90 BT_COEX_MODE_POS = 3,
91 BT_COEX_MODE_MSK = BITS(3) << BT_COEX_MODE_POS,
92 BT_COEX_DISABLE = 0x0 << BT_COEX_MODE_POS,
93 BT_COEX_2W = 0x1 << BT_COEX_MODE_POS,
94 BT_COEX_3W = 0x2 << BT_COEX_MODE_POS,
95 BT_COEX_NW = 0x3 << BT_COEX_MODE_POS,
96 BT_USE_DEFAULTS = BIT(6),
97 BT_SYNC_2_BT_DISABLE = BIT(7),
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +030098 BT_COEX_CORUNNING_TBL_EN = BIT(8),
99 BT_COEX_MPLUT_TBL_EN = BIT(9),
100 /* Bit 10 is reserved */
101 BT_COEX_WF_PRIO_BOOST_CHECK_EN = BIT(11),
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200102};
103
104/*
105 * indicates what has changed in the BT_COEX command.
106 */
107enum iwl_bt_coex_valid_bit_msk {
108 BT_VALID_ENABLE = BIT(0),
109 BT_VALID_BT_PRIO_BOOST = BIT(1),
110 BT_VALID_MAX_KILL = BIT(2),
111 BT_VALID_3W_TMRS = BIT(3),
112 BT_VALID_KILL_ACK = BIT(4),
113 BT_VALID_KILL_CTS = BIT(5),
114 BT_VALID_REDUCED_TX_POWER = BIT(6),
115 BT_VALID_LUT = BIT(7),
116 BT_VALID_WIFI_RX_SW_PRIO_BOOST = BIT(8),
117 BT_VALID_WIFI_TX_SW_PRIO_BOOST = BIT(9),
118 BT_VALID_MULTI_PRIO_LUT = BIT(10),
119 BT_VALID_TRM_KICK_FILTER = BIT(11),
120 BT_VALID_CORUN_LUT_20 = BIT(12),
121 BT_VALID_CORUN_LUT_40 = BIT(13),
122 BT_VALID_ANT_ISOLATION = BIT(14),
123 BT_VALID_ANT_ISOLATION_THRS = BIT(15),
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300124 BT_VALID_TXTX_DELTA_FREQ_THRS = BIT(16),
125 BT_VALID_TXRX_MAX_FREQ_0 = BIT(17),
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200126};
127
128/**
129 * enum iwl_bt_reduced_tx_power - allows to reduce txpower for WiFi frames.
130 * @BT_REDUCED_TX_POWER_CTL: reduce Tx power for control frames
131 * @BT_REDUCED_TX_POWER_DATA: reduce Tx power for data frames
132 *
133 * This mechanism allows to have BT and WiFi run concurrently. Since WiFi
134 * reduces its Tx power, it can work along with BT, hence reducing the amount
135 * of WiFi frames being killed by BT.
136 */
137enum iwl_bt_reduced_tx_power {
138 BT_REDUCED_TX_POWER_CTL = BIT(0),
139 BT_REDUCED_TX_POWER_DATA = BIT(1),
140};
141
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300142enum iwl_bt_coex_lut_type {
143 BT_COEX_TIGHT_LUT = 0,
144 BT_COEX_LOOSE_LUT,
145 BT_COEX_TX_DIS_LUT,
146
147 BT_COEX_MAX_LUT,
148};
149
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200150#define BT_COEX_LUT_SIZE (12)
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300151#define BT_COEX_CORUN_LUT_SIZE (32)
152#define BT_COEX_MULTI_PRIO_LUT_SIZE (2)
153#define BT_COEX_BOOST_SIZE (4)
154#define BT_REDUCED_TX_POWER_BIT BIT(7)
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200155
156/**
157 * struct iwl_bt_coex_cmd - bt coex configuration command
158 * @flags:&enum iwl_bt_coex_flags
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200159 * @max_kill:
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200160 * @bt_reduced_tx_power: enum %iwl_bt_reduced_tx_power
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300161 * @bt4_antenna_isolation:
162 * @bt4_antenna_isolation_thr:
163 * @bt4_tx_tx_delta_freq_thr:
164 * @bt4_tx_rx_max_freq0:
165 * @bt_prio_boost:
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200166 * @wifi_tx_prio_boost: SW boost of wifi tx priority
167 * @wifi_rx_prio_boost: SW boost of wifi rx priority
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300168 * @kill_ack_msk:
169 * @kill_cts_msk:
170 * @decision_lut:
171 * @bt4_multiprio_lut:
172 * @bt4_corun_lut20:
173 * @bt4_corun_lut40:
174 * @valid_bit_msk: enum %iwl_bt_coex_valid_bit_msk
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200175 *
176 * The structure is used for the BT_COEX command.
177 */
178struct iwl_bt_coex_cmd {
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300179 __le32 flags;
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200180 u8 max_kill;
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300181 u8 bt_reduced_tx_power;
182 u8 reserved[2];
183
184 u8 bt4_antenna_isolation;
185 u8 bt4_antenna_isolation_thr;
186 u8 bt4_tx_tx_delta_freq_thr;
187 u8 bt4_tx_rx_max_freq0;
188
189 __le32 bt_prio_boost[BT_COEX_BOOST_SIZE];
190 __le32 wifi_tx_prio_boost;
191 __le32 wifi_rx_prio_boost;
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200192 __le32 kill_ack_msk;
193 __le32 kill_cts_msk;
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300194
195 __le32 decision_lut[BT_COEX_MAX_LUT][BT_COEX_LUT_SIZE];
196 __le32 bt4_multiprio_lut[BT_COEX_MULTI_PRIO_LUT_SIZE];
197 __le32 bt4_corun_lut20[BT_COEX_CORUN_LUT_SIZE];
198 __le32 bt4_corun_lut40[BT_COEX_CORUN_LUT_SIZE];
199
200 __le32 valid_bit_msk;
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200201} __packed; /* BT_COEX_CMD_API_S_VER_3 */
202
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300203/**
204 * struct iwl_bt_coex_ci_cmd - bt coex channel inhibition command
205 * @bt_primary_ci:
206 * @bt_secondary_ci:
207 * @co_run_bw_primary:
208 * @co_run_bw_secondary:
209 * @primary_ch_phy_id:
210 * @secondary_ch_phy_id:
211 *
212 * Used for BT_COEX_CI command
213 */
214struct iwl_bt_coex_ci_cmd {
215 __le64 bt_primary_ci;
216 __le64 bt_secondary_ci;
217
218 u8 co_run_bw_primary;
219 u8 co_run_bw_secondary;
220 u8 primary_ch_phy_id;
221 u8 secondary_ch_phy_id;
222} __packed; /* BT_CI_MSG_API_S_VER_1 */
223
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200224#define BT_MBOX(n_dw, _msg, _pos, _nbits) \
225 BT_MBOX##n_dw##_##_msg##_POS = (_pos), \
226 BT_MBOX##n_dw##_##_msg = BITS(_nbits) << BT_MBOX##n_dw##_##_msg##_POS
227
228enum iwl_bt_mxbox_dw0 {
229 BT_MBOX(0, LE_SLAVE_LAT, 0, 3),
230 BT_MBOX(0, LE_PROF1, 3, 1),
231 BT_MBOX(0, LE_PROF2, 4, 1),
232 BT_MBOX(0, LE_PROF_OTHER, 5, 1),
233 BT_MBOX(0, CHL_SEQ_N, 8, 4),
234 BT_MBOX(0, INBAND_S, 13, 1),
235 BT_MBOX(0, LE_MIN_RSSI, 16, 4),
236 BT_MBOX(0, LE_SCAN, 20, 1),
237 BT_MBOX(0, LE_ADV, 21, 1),
238 BT_MBOX(0, LE_MAX_TX_POWER, 24, 4),
239 BT_MBOX(0, OPEN_CON_1, 28, 2),
240};
241
242enum iwl_bt_mxbox_dw1 {
243 BT_MBOX(1, BR_MAX_TX_POWER, 0, 4),
244 BT_MBOX(1, IP_SR, 4, 1),
245 BT_MBOX(1, LE_MSTR, 5, 1),
246 BT_MBOX(1, AGGR_TRFC_LD, 8, 6),
247 BT_MBOX(1, MSG_TYPE, 16, 3),
248 BT_MBOX(1, SSN, 19, 2),
249};
250
251enum iwl_bt_mxbox_dw2 {
252 BT_MBOX(2, SNIFF_ACT, 0, 3),
253 BT_MBOX(2, PAG, 3, 1),
254 BT_MBOX(2, INQUIRY, 4, 1),
255 BT_MBOX(2, CONN, 5, 1),
256 BT_MBOX(2, SNIFF_INTERVAL, 8, 5),
257 BT_MBOX(2, DISC, 13, 1),
258 BT_MBOX(2, SCO_TX_ACT, 16, 2),
259 BT_MBOX(2, SCO_RX_ACT, 18, 2),
260 BT_MBOX(2, ESCO_RE_TX, 20, 2),
261 BT_MBOX(2, SCO_DURATION, 24, 6),
262};
263
264enum iwl_bt_mxbox_dw3 {
265 BT_MBOX(3, SCO_STATE, 0, 1),
266 BT_MBOX(3, SNIFF_STATE, 1, 1),
267 BT_MBOX(3, A2DP_STATE, 2, 1),
268 BT_MBOX(3, ACL_STATE, 3, 1),
269 BT_MBOX(3, MSTR_STATE, 4, 1),
270 BT_MBOX(3, OBX_STATE, 5, 1),
271 BT_MBOX(3, OPEN_CON_2, 8, 2),
272 BT_MBOX(3, TRAFFIC_LOAD, 10, 2),
273 BT_MBOX(3, CHL_SEQN_LSB, 12, 1),
274 BT_MBOX(3, INBAND_P, 13, 1),
275 BT_MBOX(3, MSG_TYPE_2, 16, 3),
276 BT_MBOX(3, SSN_2, 19, 2),
277 BT_MBOX(3, UPDATE_REQUEST, 21, 1),
278};
279
280#define BT_MBOX_MSG(_notif, _num, _field) \
281 ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\
282 >> BT_MBOX##_num##_##_field##_POS)
283
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300284enum iwl_bt_activity_grading {
285 BT_OFF = 0,
286 BT_ON_NO_CONNECTION = 1,
287 BT_LOW_TRAFFIC = 2,
288 BT_HIGH_TRAFFIC = 3,
289};
290
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200291/**
292 * struct iwl_bt_coex_profile_notif - notification about BT coex
293 * @mbox_msg: message from BT to WiFi
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300294 * @msg_idx: the index of the message
295 * @bt_status: 0 - off, 1 - on
296 * @bt_open_conn: number of BT connections open
297 * @bt_traffic_load: load of BT traffic
298 * @bt_agg_traffic_load: aggregated load of BT traffic
299 * @bt_ci_compliance: 0 - no CI compliance, 1 - CI compliant
300 * @primary_ch_lut: LUT used for primary channel
301 * @secondary_ch_lut: LUT used for secondary channel
302 * @bt_activity_grading: the activity of BT enum %iwl_bt_activity_grading
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200303 */
304struct iwl_bt_coex_profile_notif {
305 __le32 mbox_msg[4];
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300306 __le32 msg_idx;
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200307 u8 bt_status;
308 u8 bt_open_conn;
309 u8 bt_traffic_load;
310 u8 bt_agg_traffic_load;
311 u8 bt_ci_compliance;
312 u8 reserved[3];
Emmanuel Grumbachdac94da2013-06-18 07:35:27 +0300313
314 __le32 primary_ch_lut;
315 __le32 secondary_ch_lut;
316 __le32 bt_activity_grading;
Emmanuel Grumbachfb3ceb82013-01-14 15:04:01 +0200317} __packed; /* BT_COEX_PROFILE_NTFY_API_S_VER_2 */
318
319enum iwl_bt_coex_prio_table_event {
320 BT_COEX_PRIO_TBL_EVT_INIT_CALIB1 = 0,
321 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2 = 1,
322 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW1 = 2,
323 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW2 = 3,
324 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH1 = 4,
325 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH2 = 5,
326 BT_COEX_PRIO_TBL_EVT_DTIM = 6,
327 BT_COEX_PRIO_TBL_EVT_SCAN52 = 7,
328 BT_COEX_PRIO_TBL_EVT_SCAN24 = 8,
329 BT_COEX_PRIO_TBL_EVT_IDLE = 9,
330 BT_COEX_PRIO_TBL_EVT_MAX = 16,
331}; /* BT_COEX_PRIO_TABLE_EVENTS_API_E_VER_1 */
332
333enum iwl_bt_coex_prio_table_prio {
334 BT_COEX_PRIO_TBL_DISABLED = 0,
335 BT_COEX_PRIO_TBL_PRIO_LOW = 1,
336 BT_COEX_PRIO_TBL_PRIO_HIGH = 2,
337 BT_COEX_PRIO_TBL_PRIO_BYPASS = 3,
338 BT_COEX_PRIO_TBL_PRIO_COEX_OFF = 4,
339 BT_COEX_PRIO_TBL_PRIO_COEX_ON = 5,
340 BT_COEX_PRIO_TBL_PRIO_COEX_IDLE = 6,
341 BT_COEX_PRIO_TBL_MAX = 8,
342}; /* BT_COEX_PRIO_TABLE_PRIORITIES_API_E_VER_1 */
343
344#define BT_COEX_PRIO_TBL_SHRD_ANT_POS (0)
345#define BT_COEX_PRIO_TBL_PRIO_POS (1)
346#define BT_COEX_PRIO_TBL_RESERVED_POS (4)
347
348/**
349 * struct iwl_bt_coex_prio_tbl_cmd - priority table for BT coex
350 * @prio_tbl:
351 */
352struct iwl_bt_coex_prio_tbl_cmd {
353 u8 prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX];
354} __packed;
355
356enum iwl_bt_coex_env_action {
357 BT_COEX_ENV_CLOSE = 0,
358 BT_COEX_ENV_OPEN = 1,
359}; /* BT_COEX_PROT_ENV_ACTION_API_E_VER_1 */
360
361/**
362 * struct iwl_bt_coex_prot_env_cmd - BT Protection Envelope
363 * @action: enum %iwl_bt_coex_env_action
364 * @type: enum %iwl_bt_coex_prio_table_event
365 */
366struct iwl_bt_coex_prot_env_cmd {
367 u8 action; /* 0 = closed, 1 = open */
368 u8 type; /* 0 .. 15 */
369 u8 reserved[2];
370} __packed;
371
372#endif /* __fw_api_bt_coex_h__ */