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