xref: /linux/drivers/net/wireless/intel/iwlwifi/fw/api/coex.h (revision 9410645520e9b820069761f3450ef6661418e279)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2023-2024 Intel Corporation
4  * Copyright (C) 2013-2014, 2018-2019 Intel Corporation
5  * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
6  * Copyright (C) 2017 Intel Deutschland GmbH
7  */
8 #ifndef __iwl_fw_api_coex_h__
9 #define __iwl_fw_api_coex_h__
10 
11 #include <linux/types.h>
12 #include <linux/bitops.h>
13 
14 #define BITS(nb) (BIT(nb) - 1)
15 
16 enum iwl_bt_coex_lut_type {
17 	BT_COEX_TIGHT_LUT = 0,
18 	BT_COEX_LOOSE_LUT,
19 	BT_COEX_TX_DIS_LUT,
20 
21 	BT_COEX_MAX_LUT,
22 	BT_COEX_INVALID_LUT = 0xff,
23 }; /* BT_COEX_DECISION_LUT_INDEX_API_E_VER_1 */
24 
25 #define BT_REDUCED_TX_POWER_BIT BIT(7)
26 
27 enum iwl_bt_coex_mode {
28 	BT_COEX_DISABLE			= 0x0,
29 	BT_COEX_NW			= 0x1,
30 	BT_COEX_BT			= 0x2,
31 	BT_COEX_WIFI			= 0x3,
32 }; /* BT_COEX_MODES_E */
33 
34 enum iwl_bt_coex_enabled_modules {
35 	BT_COEX_MPLUT_ENABLED		= BIT(0),
36 	BT_COEX_MPLUT_BOOST_ENABLED	= BIT(1),
37 	BT_COEX_SYNC2SCO_ENABLED	= BIT(2),
38 	BT_COEX_CORUN_ENABLED		= BIT(3),
39 	BT_COEX_HIGH_BAND_RET		= BIT(4),
40 }; /* BT_COEX_MODULES_ENABLE_E_VER_1 */
41 
42 /**
43  * struct iwl_bt_coex_cmd - bt coex configuration command
44  * @mode: &enum iwl_bt_coex_mode
45  * @enabled_modules: &enum iwl_bt_coex_enabled_modules
46  *
47  * The structure is used for the BT_COEX command.
48  */
49 struct iwl_bt_coex_cmd {
50 	__le32 mode;
51 	__le32 enabled_modules;
52 } __packed; /* BT_COEX_CMD_API_S_VER_6 */
53 
54 /**
55  * struct iwl_bt_coex_reduced_txp_update_cmd
56  * @reduced_txp: bit BT_REDUCED_TX_POWER_BIT to enable / disable, rest of the
57  *	bits are the sta_id (value)
58  */
59 struct iwl_bt_coex_reduced_txp_update_cmd {
60 	__le32 reduced_txp;
61 } __packed; /* BT_COEX_UPDATE_REDUCED_TX_POWER_API_S_VER_1 */
62 
63 /**
64  * struct iwl_bt_coex_ci_cmd - bt coex channel inhibition command
65  * @bt_primary_ci: primary channel inhibition bitmap
66  * @primary_ch_phy_id: primary channel PHY ID
67  * @bt_secondary_ci: secondary channel inhibition bitmap
68  * @secondary_ch_phy_id: secondary channel PHY ID
69  *
70  * Used for BT_COEX_CI command
71  */
72 struct iwl_bt_coex_ci_cmd {
73 	__le64 bt_primary_ci;
74 	__le32 primary_ch_phy_id;
75 
76 	__le64 bt_secondary_ci;
77 	__le32 secondary_ch_phy_id;
78 } __packed; /* BT_CI_MSG_API_S_VER_2 */
79 
80 enum iwl_bt_activity_grading {
81 	BT_OFF			= 0,
82 	BT_ON_NO_CONNECTION	= 1,
83 	BT_LOW_TRAFFIC		= 2,
84 	BT_HIGH_TRAFFIC		= 3,
85 	BT_VERY_HIGH_TRAFFIC	= 4,
86 
87 	BT_MAX_AG,
88 }; /* BT_COEX_BT_ACTIVITY_GRADING_API_E_VER_1 */
89 
90 enum iwl_bt_ci_compliance {
91 	BT_CI_COMPLIANCE_NONE		= 0,
92 	BT_CI_COMPLIANCE_PRIMARY	= 1,
93 	BT_CI_COMPLIANCE_SECONDARY	= 2,
94 	BT_CI_COMPLIANCE_BOTH		= 3,
95 }; /* BT_COEX_CI_COMPLIENCE_E_VER_1 */
96 
97 /**
98  * struct iwl_bt_coex_prof_old_notif - notification about BT coex
99  * @mbox_msg: message from BT to WiFi
100  * @msg_idx: the index of the message
101  * @bt_ci_compliance: enum %iwl_bt_ci_compliance
102  * @primary_ch_lut: LUT used for primary channel &enum iwl_bt_coex_lut_type
103  * @secondary_ch_lut: LUT used for secondary channel &enum iwl_bt_coex_lut_type
104  * @bt_activity_grading: the activity of BT &enum iwl_bt_activity_grading
105  * @ttc_status: is TTC enabled - one bit per PHY
106  * @rrc_status: is RRC enabled - one bit per PHY
107  * The following fields are only for version 5, and are reserved in version 4:
108  * @wifi_loss_low_rssi: The predicted lost WiFi rate (% of air time that BT is
109  *	utilizing) when the RSSI is low (<= -65 dBm)
110  * @wifi_loss_mid_high_rssi: The predicted lost WiFi rate (% of air time that
111  *	BT is utilizing) when the RSSI is mid/high (>= -65 dBm)
112  */
113 struct iwl_bt_coex_prof_old_notif {
114 	__le32 mbox_msg[4];
115 	__le32 msg_idx;
116 	__le32 bt_ci_compliance;
117 
118 	__le32 primary_ch_lut;
119 	__le32 secondary_ch_lut;
120 	__le32 bt_activity_grading;
121 	u8 ttc_status;
122 	u8 rrc_status;
123 	u8 wifi_loss_low_rssi;
124 	u8 wifi_loss_mid_high_rssi;
125 } __packed; /* BT_COEX_PROFILE_NTFY_API_S_VER_4
126 	     * BT_COEX_PROFILE_NTFY_API_S_VER_5
127 	     */
128 
129 /**
130  * enum iwl_bt_coex_subcmd_ids - coex configuration command IDs
131  */
132 enum iwl_bt_coex_subcmd_ids {
133        /**
134 	*@PROFILE_NOTIF: &struct iwl_bt_coex_profile_notif
135 	*/
136 	PROFILE_NOTIF = 0xFF,
137 };
138 
139 #define COEX_NUM_BAND	3
140 #define COEX_NUM_CHAINS	2
141 
142 /**
143  * struct iwl_bt_coex_profile_notif - notification about BT coex
144  * @wifi_loss_low_rssi: The predicted lost WiFi rate (% of air time that BT is
145  *	utilizing) when the RSSI is low (<= -65 dBm)
146  * @wifi_loss_mid_high_rssi: The predicted lost WiFi rate (% of air time that
147  *	BT is utilizing) when the RSSI is mid/high (>= -65 dBm)
148  */
149 struct iwl_bt_coex_profile_notif {
150 	u8 wifi_loss_low_rssi[COEX_NUM_BAND][COEX_NUM_CHAINS];
151 	u8 wifi_loss_mid_high_rssi[COEX_NUM_BAND][COEX_NUM_CHAINS];
152 } __packed; /* BT_COEX_BT_PROFILE_NTF_API_S_VER_1 */
153 
154 #endif /* __iwl_fw_api_coex_h__ */
155