fw-api-bt-coex.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. /******************************************************************************
  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. #ifndef __fw_api_bt_coex_h__
  63. #define __fw_api_bt_coex_h__
  64. #include <linux/types.h>
  65. #include <linux/bitops.h>
  66. #define BITS(nb) (BIT(nb) - 1)
  67. /**
  68. * enum iwl_bt_coex_flags - flags for BT_COEX command
  69. * @BT_CH_PRIMARY_EN:
  70. * @BT_CH_SECONDARY_EN:
  71. * @BT_NOTIF_COEX_OFF:
  72. * @BT_COEX_MODE_POS:
  73. * @BT_COEX_MODE_MSK:
  74. * @BT_COEX_DISABLE:
  75. * @BT_COEX_2W:
  76. * @BT_COEX_3W:
  77. * @BT_COEX_NW:
  78. * @BT_USE_DEFAULTS:
  79. * @BT_SYNC_2_BT_DISABLE:
  80. * @BT_COEX_CORUNNING_TBL_EN:
  81. */
  82. enum iwl_bt_coex_flags {
  83. BT_CH_PRIMARY_EN = BIT(0),
  84. BT_CH_SECONDARY_EN = BIT(1),
  85. BT_NOTIF_COEX_OFF = BIT(2),
  86. BT_COEX_MODE_POS = 3,
  87. BT_COEX_MODE_MSK = BITS(3) << BT_COEX_MODE_POS,
  88. BT_COEX_DISABLE = 0x0 << BT_COEX_MODE_POS,
  89. BT_COEX_2W = 0x1 << BT_COEX_MODE_POS,
  90. BT_COEX_3W = 0x2 << BT_COEX_MODE_POS,
  91. BT_COEX_NW = 0x3 << BT_COEX_MODE_POS,
  92. BT_USE_DEFAULTS = BIT(6),
  93. BT_SYNC_2_BT_DISABLE = BIT(7),
  94. /*
  95. * For future use - when the flags will be enlarged
  96. * BT_COEX_CORUNNING_TBL_EN = BIT(8),
  97. */
  98. };
  99. /*
  100. * indicates what has changed in the BT_COEX command.
  101. */
  102. enum iwl_bt_coex_valid_bit_msk {
  103. BT_VALID_ENABLE = BIT(0),
  104. BT_VALID_BT_PRIO_BOOST = BIT(1),
  105. BT_VALID_MAX_KILL = BIT(2),
  106. BT_VALID_3W_TMRS = BIT(3),
  107. BT_VALID_KILL_ACK = BIT(4),
  108. BT_VALID_KILL_CTS = BIT(5),
  109. BT_VALID_REDUCED_TX_POWER = BIT(6),
  110. BT_VALID_LUT = BIT(7),
  111. BT_VALID_WIFI_RX_SW_PRIO_BOOST = BIT(8),
  112. BT_VALID_WIFI_TX_SW_PRIO_BOOST = BIT(9),
  113. BT_VALID_MULTI_PRIO_LUT = BIT(10),
  114. BT_VALID_TRM_KICK_FILTER = BIT(11),
  115. BT_VALID_CORUN_LUT_20 = BIT(12),
  116. BT_VALID_CORUN_LUT_40 = BIT(13),
  117. BT_VALID_ANT_ISOLATION = BIT(14),
  118. BT_VALID_ANT_ISOLATION_THRS = BIT(15),
  119. /*
  120. * For future use - when the valid flags will be enlarged
  121. * BT_VALID_TXTX_DELTA_FREQ_THRS = BIT(16),
  122. * BT_VALID_TXRX_MAX_FREQ_0 = BIT(17),
  123. */
  124. };
  125. /**
  126. * enum iwl_bt_reduced_tx_power - allows to reduce txpower for WiFi frames.
  127. * @BT_REDUCED_TX_POWER_CTL: reduce Tx power for control frames
  128. * @BT_REDUCED_TX_POWER_DATA: reduce Tx power for data frames
  129. *
  130. * This mechanism allows to have BT and WiFi run concurrently. Since WiFi
  131. * reduces its Tx power, it can work along with BT, hence reducing the amount
  132. * of WiFi frames being killed by BT.
  133. */
  134. enum iwl_bt_reduced_tx_power {
  135. BT_REDUCED_TX_POWER_CTL = BIT(0),
  136. BT_REDUCED_TX_POWER_DATA = BIT(1),
  137. };
  138. #define BT_COEX_LUT_SIZE (12)
  139. /**
  140. * struct iwl_bt_coex_cmd - bt coex configuration command
  141. * @flags:&enum iwl_bt_coex_flags
  142. * @lead_time:
  143. * @max_kill:
  144. * @bt3_time_t7_value:
  145. * @kill_ack_msk:
  146. * @kill_cts_msk:
  147. * @bt3_prio_sample_time:
  148. * @bt3_timer_t2_value:
  149. * @bt4_reaction_time:
  150. * @decision_lut[12]:
  151. * @bt_reduced_tx_power: enum %iwl_bt_reduced_tx_power
  152. * @valid_bit_msk: enum %iwl_bt_coex_valid_bit_msk
  153. * @bt_prio_boost: values for PTA boost register
  154. * @wifi_tx_prio_boost: SW boost of wifi tx priority
  155. * @wifi_rx_prio_boost: SW boost of wifi rx priority
  156. *
  157. * The structure is used for the BT_COEX command.
  158. */
  159. struct iwl_bt_coex_cmd {
  160. u8 flags;
  161. u8 lead_time;
  162. u8 max_kill;
  163. u8 bt3_time_t7_value;
  164. __le32 kill_ack_msk;
  165. __le32 kill_cts_msk;
  166. u8 bt3_prio_sample_time;
  167. u8 bt3_timer_t2_value;
  168. __le16 bt4_reaction_time;
  169. __le32 decision_lut[BT_COEX_LUT_SIZE];
  170. u8 bt_reduced_tx_power;
  171. u8 reserved;
  172. __le16 valid_bit_msk;
  173. __le32 bt_prio_boost;
  174. u8 reserved2;
  175. u8 wifi_tx_prio_boost;
  176. __le16 wifi_rx_prio_boost;
  177. } __packed; /* BT_COEX_CMD_API_S_VER_3 */
  178. #define BT_MBOX(n_dw, _msg, _pos, _nbits) \
  179. BT_MBOX##n_dw##_##_msg##_POS = (_pos), \
  180. BT_MBOX##n_dw##_##_msg = BITS(_nbits) << BT_MBOX##n_dw##_##_msg##_POS
  181. enum iwl_bt_mxbox_dw0 {
  182. BT_MBOX(0, LE_SLAVE_LAT, 0, 3),
  183. BT_MBOX(0, LE_PROF1, 3, 1),
  184. BT_MBOX(0, LE_PROF2, 4, 1),
  185. BT_MBOX(0, LE_PROF_OTHER, 5, 1),
  186. BT_MBOX(0, CHL_SEQ_N, 8, 4),
  187. BT_MBOX(0, INBAND_S, 13, 1),
  188. BT_MBOX(0, LE_MIN_RSSI, 16, 4),
  189. BT_MBOX(0, LE_SCAN, 20, 1),
  190. BT_MBOX(0, LE_ADV, 21, 1),
  191. BT_MBOX(0, LE_MAX_TX_POWER, 24, 4),
  192. BT_MBOX(0, OPEN_CON_1, 28, 2),
  193. };
  194. enum iwl_bt_mxbox_dw1 {
  195. BT_MBOX(1, BR_MAX_TX_POWER, 0, 4),
  196. BT_MBOX(1, IP_SR, 4, 1),
  197. BT_MBOX(1, LE_MSTR, 5, 1),
  198. BT_MBOX(1, AGGR_TRFC_LD, 8, 6),
  199. BT_MBOX(1, MSG_TYPE, 16, 3),
  200. BT_MBOX(1, SSN, 19, 2),
  201. };
  202. enum iwl_bt_mxbox_dw2 {
  203. BT_MBOX(2, SNIFF_ACT, 0, 3),
  204. BT_MBOX(2, PAG, 3, 1),
  205. BT_MBOX(2, INQUIRY, 4, 1),
  206. BT_MBOX(2, CONN, 5, 1),
  207. BT_MBOX(2, SNIFF_INTERVAL, 8, 5),
  208. BT_MBOX(2, DISC, 13, 1),
  209. BT_MBOX(2, SCO_TX_ACT, 16, 2),
  210. BT_MBOX(2, SCO_RX_ACT, 18, 2),
  211. BT_MBOX(2, ESCO_RE_TX, 20, 2),
  212. BT_MBOX(2, SCO_DURATION, 24, 6),
  213. };
  214. enum iwl_bt_mxbox_dw3 {
  215. BT_MBOX(3, SCO_STATE, 0, 1),
  216. BT_MBOX(3, SNIFF_STATE, 1, 1),
  217. BT_MBOX(3, A2DP_STATE, 2, 1),
  218. BT_MBOX(3, ACL_STATE, 3, 1),
  219. BT_MBOX(3, MSTR_STATE, 4, 1),
  220. BT_MBOX(3, OBX_STATE, 5, 1),
  221. BT_MBOX(3, OPEN_CON_2, 8, 2),
  222. BT_MBOX(3, TRAFFIC_LOAD, 10, 2),
  223. BT_MBOX(3, CHL_SEQN_LSB, 12, 1),
  224. BT_MBOX(3, INBAND_P, 13, 1),
  225. BT_MBOX(3, MSG_TYPE_2, 16, 3),
  226. BT_MBOX(3, SSN_2, 19, 2),
  227. BT_MBOX(3, UPDATE_REQUEST, 21, 1),
  228. };
  229. #define BT_MBOX_MSG(_notif, _num, _field) \
  230. ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\
  231. >> BT_MBOX##_num##_##_field##_POS)
  232. /**
  233. * struct iwl_bt_coex_profile_notif - notification about BT coex
  234. * @mbox_msg: message from BT to WiFi
  235. * @:bt_status: 0 - off, 1 - on
  236. * @:bt_open_conn: number of BT connections open
  237. * @:bt_traffic_load: load of BT traffic
  238. * @:bt_agg_traffic_load: aggregated load of BT traffic
  239. * @:bt_ci_compliance: 0 - no CI compliance, 1 - CI compliant
  240. */
  241. struct iwl_bt_coex_profile_notif {
  242. __le32 mbox_msg[4];
  243. u8 bt_status;
  244. u8 bt_open_conn;
  245. u8 bt_traffic_load;
  246. u8 bt_agg_traffic_load;
  247. u8 bt_ci_compliance;
  248. u8 reserved[3];
  249. } __packed; /* BT_COEX_PROFILE_NTFY_API_S_VER_2 */
  250. enum iwl_bt_coex_prio_table_event {
  251. BT_COEX_PRIO_TBL_EVT_INIT_CALIB1 = 0,
  252. BT_COEX_PRIO_TBL_EVT_INIT_CALIB2 = 1,
  253. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW1 = 2,
  254. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW2 = 3,
  255. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH1 = 4,
  256. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH2 = 5,
  257. BT_COEX_PRIO_TBL_EVT_DTIM = 6,
  258. BT_COEX_PRIO_TBL_EVT_SCAN52 = 7,
  259. BT_COEX_PRIO_TBL_EVT_SCAN24 = 8,
  260. BT_COEX_PRIO_TBL_EVT_IDLE = 9,
  261. BT_COEX_PRIO_TBL_EVT_MAX = 16,
  262. }; /* BT_COEX_PRIO_TABLE_EVENTS_API_E_VER_1 */
  263. enum iwl_bt_coex_prio_table_prio {
  264. BT_COEX_PRIO_TBL_DISABLED = 0,
  265. BT_COEX_PRIO_TBL_PRIO_LOW = 1,
  266. BT_COEX_PRIO_TBL_PRIO_HIGH = 2,
  267. BT_COEX_PRIO_TBL_PRIO_BYPASS = 3,
  268. BT_COEX_PRIO_TBL_PRIO_COEX_OFF = 4,
  269. BT_COEX_PRIO_TBL_PRIO_COEX_ON = 5,
  270. BT_COEX_PRIO_TBL_PRIO_COEX_IDLE = 6,
  271. BT_COEX_PRIO_TBL_MAX = 8,
  272. }; /* BT_COEX_PRIO_TABLE_PRIORITIES_API_E_VER_1 */
  273. #define BT_COEX_PRIO_TBL_SHRD_ANT_POS (0)
  274. #define BT_COEX_PRIO_TBL_PRIO_POS (1)
  275. #define BT_COEX_PRIO_TBL_RESERVED_POS (4)
  276. /**
  277. * struct iwl_bt_coex_prio_tbl_cmd - priority table for BT coex
  278. * @prio_tbl:
  279. */
  280. struct iwl_bt_coex_prio_tbl_cmd {
  281. u8 prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX];
  282. } __packed;
  283. enum iwl_bt_coex_env_action {
  284. BT_COEX_ENV_CLOSE = 0,
  285. BT_COEX_ENV_OPEN = 1,
  286. }; /* BT_COEX_PROT_ENV_ACTION_API_E_VER_1 */
  287. /**
  288. * struct iwl_bt_coex_prot_env_cmd - BT Protection Envelope
  289. * @action: enum %iwl_bt_coex_env_action
  290. * @type: enum %iwl_bt_coex_prio_table_event
  291. */
  292. struct iwl_bt_coex_prot_env_cmd {
  293. u8 action; /* 0 = closed, 1 = open */
  294. u8 type; /* 0 .. 15 */
  295. u8 reserved[2];
  296. } __packed;
  297. #endif /* __fw_api_bt_coex_h__ */