1e3037485SYan-Hsuan Chuang /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2e3037485SYan-Hsuan Chuang /* Copyright(c) 2018-2019 Realtek Corporation
3e3037485SYan-Hsuan Chuang */
4e3037485SYan-Hsuan Chuang
5e3037485SYan-Hsuan Chuang #ifndef __RTW_FW_H_
6e3037485SYan-Hsuan Chuang #define __RTW_FW_H_
7e3037485SYan-Hsuan Chuang
8e3037485SYan-Hsuan Chuang #define H2C_PKT_SIZE 32
9e3037485SYan-Hsuan Chuang #define H2C_PKT_HDR_SIZE 8
10e3037485SYan-Hsuan Chuang
11e3037485SYan-Hsuan Chuang /* FW bin information */
12e3037485SYan-Hsuan Chuang #define FW_HDR_SIZE 64
13e3037485SYan-Hsuan Chuang #define FW_HDR_CHKSUM_SIZE 8
14e3037485SYan-Hsuan Chuang
15b6c12908SChin-Yen Lee #define FW_NLO_INFO_CHECK_SIZE 4
16b6c12908SChin-Yen Lee
17e3037485SYan-Hsuan Chuang #define FIFO_PAGE_SIZE_SHIFT 12
18e3037485SYan-Hsuan Chuang #define FIFO_PAGE_SIZE 4096
19e3037485SYan-Hsuan Chuang #define FIFO_DUMP_ADDR 0x8000
20e3037485SYan-Hsuan Chuang
2115d2fcc6SPing-Ke Shih #define DLFW_PAGE_SIZE_SHIFT_LEGACY 12
2215d2fcc6SPing-Ke Shih #define DLFW_PAGE_SIZE_LEGACY 0x1000
2315d2fcc6SPing-Ke Shih #define DLFW_BLK_SIZE_SHIFT_LEGACY 2
2415d2fcc6SPing-Ke Shih #define DLFW_BLK_SIZE_LEGACY 4
2515d2fcc6SPing-Ke Shih #define FW_START_ADDR_LEGACY 0x1000
2615d2fcc6SPing-Ke Shih
27cd96e22bSPo-Hao Huang #define BCN_LOSS_CNT 10
28cd96e22bSPo-Hao Huang #define BCN_FILTER_NOTIFY_SIGNAL_CHANGE 0
29cd96e22bSPo-Hao Huang #define BCN_FILTER_CONNECTION_LOSS 1
30cd96e22bSPo-Hao Huang #define BCN_FILTER_CONNECTED 2
31cd96e22bSPo-Hao Huang #define BCN_FILTER_NOTIFY_BEACON_LOSS 3
32cd96e22bSPo-Hao Huang
33a853d234SChin-Yen Lee #define SCAN_NOTIFY_TIMEOUT msecs_to_jiffies(10)
34a853d234SChin-Yen Lee
3510d162b2SPo-Hao Huang #define RTW_CHANNEL_TIME 45
3610d162b2SPo-Hao Huang #define RTW_OFF_CHAN_TIME 100
3710d162b2SPo-Hao Huang #define RTW_PASS_CHAN_TIME 105
3810d162b2SPo-Hao Huang #define RTW_DFS_CHAN_TIME 20
3910d162b2SPo-Hao Huang #define RTW_CH_INFO_SIZE 4
4010d162b2SPo-Hao Huang #define RTW_EX_CH_INFO_SIZE 3
4110d162b2SPo-Hao Huang #define RTW_EX_CH_INFO_HDR_SIZE 2
4210d162b2SPo-Hao Huang #define RTW_SCAN_WIDTH 0
4310d162b2SPo-Hao Huang #define RTW_PRI_CH_IDX 1
44d2eb7cb9SPo-Hao Huang #define RTW_OLD_PROBE_PG_CNT 2
45d2eb7cb9SPo-Hao Huang #define RTW_PROBE_PG_CNT 4
4610d162b2SPo-Hao Huang
47e3037485SYan-Hsuan Chuang enum rtw_c2h_cmd_id {
48614b1f87SPing-Ke Shih C2H_CCX_TX_RPT = 0x03,
49e3037485SYan-Hsuan Chuang C2H_BT_INFO = 0x09,
504136214fSYan-Hsuan Chuang C2H_BT_MP_INFO = 0x0b,
51fc3c66d3SChing-Te Ku C2H_BT_HID_INFO = 0x45,
52699c7730STzu-En Huang C2H_RA_RPT = 0x0c,
53e3037485SYan-Hsuan Chuang C2H_HW_FEATURE_REPORT = 0x19,
544136214fSYan-Hsuan Chuang C2H_WLAN_INFO = 0x27,
55f31e039fSChin-Yen Lee C2H_WLAN_RFON = 0x32,
56cd96e22bSPo-Hao Huang C2H_BCN_FILTER_NOTIFY = 0x36,
57fe7bc23aSChin-Yen Lee C2H_ADAPTIVITY = 0x37,
58a853d234SChin-Yen Lee C2H_SCAN_RESULT = 0x38,
59e3037485SYan-Hsuan Chuang C2H_HW_FEATURE_DUMP = 0xfd,
60e3037485SYan-Hsuan Chuang C2H_HALMAC = 0xff,
61e3037485SYan-Hsuan Chuang };
62e3037485SYan-Hsuan Chuang
63e3037485SYan-Hsuan Chuang enum rtw_c2h_cmd_id_ext {
6410d162b2SPo-Hao Huang C2H_SCAN_STATUS_RPT = 0x3,
65e3037485SYan-Hsuan Chuang C2H_CCX_RPT = 0x0f,
6610d162b2SPo-Hao Huang C2H_CHAN_SWITCH = 0x22,
67e3037485SYan-Hsuan Chuang };
68e3037485SYan-Hsuan Chuang
69e3037485SYan-Hsuan Chuang struct rtw_c2h_cmd {
70e3037485SYan-Hsuan Chuang u8 id;
71e3037485SYan-Hsuan Chuang u8 seq;
72a1b7714bSGustavo A. R. Silva u8 payload[];
73e3037485SYan-Hsuan Chuang } __packed;
74e3037485SYan-Hsuan Chuang
75fe7bc23aSChin-Yen Lee struct rtw_c2h_adaptivity {
76fe7bc23aSChin-Yen Lee u8 density;
77fe7bc23aSChin-Yen Lee u8 igi;
78fe7bc23aSChin-Yen Lee u8 l2h_th_init;
79fe7bc23aSChin-Yen Lee u8 l2h;
80fe7bc23aSChin-Yen Lee u8 h2l;
81fe7bc23aSChin-Yen Lee u8 option;
82fe7bc23aSChin-Yen Lee } __packed;
83fe7bc23aSChin-Yen Lee
84823092a5SJi-Pin Jou struct rtw_h2c_register {
85823092a5SJi-Pin Jou u32 w0;
86823092a5SJi-Pin Jou u32 w1;
87823092a5SJi-Pin Jou } __packed;
88823092a5SJi-Pin Jou
89e3037485SYan-Hsuan Chuang #define RTW_H2C_W0_CMDID GENMASK(7, 0)
90e3037485SYan-Hsuan Chuang
91895c096dSYan-Hsuan Chuang /* H2C_CMD_DEFAULT_PORT command */
92e3037485SYan-Hsuan Chuang #define RTW_H2C_DEFAULT_PORT_W0_PORTID GENMASK(15, 8)
93e3037485SYan-Hsuan Chuang #define RTW_H2C_DEFAULT_PORT_W0_MACID GENMASK(23, 16)
94e3037485SYan-Hsuan Chuang
95e3037485SYan-Hsuan Chuang struct rtw_h2c_cmd {
9604b786e0SYan-Hsuan Chuang __le32 msg;
9704b786e0SYan-Hsuan Chuang __le32 msg_ext;
98b6c12908SChin-Yen Lee } __packed;
99b6c12908SChin-Yen Lee
100b6c12908SChin-Yen Lee enum rtw_rsvd_packet_type {
101e3037485SYan-Hsuan Chuang RSVD_BEACON,
102e3037485SYan-Hsuan Chuang RSVD_DUMMY,
103e3037485SYan-Hsuan Chuang RSVD_PS_POLL,
104e3037485SYan-Hsuan Chuang RSVD_PROBE_RESP,
105e3037485SYan-Hsuan Chuang RSVD_NULL,
106e3037485SYan-Hsuan Chuang RSVD_QOS_NULL,
107e3037485SYan-Hsuan Chuang RSVD_LPS_PG_DPK,
108e3037485SYan-Hsuan Chuang RSVD_LPS_PG_INFO,
109e3037485SYan-Hsuan Chuang RSVD_PROBE_REQ,
110e3037485SYan-Hsuan Chuang RSVD_NLO_INFO,
111e3037485SYan-Hsuan Chuang RSVD_CH_INFO,
112e3037485SYan-Hsuan Chuang };
113e3037485SYan-Hsuan Chuang
114e3037485SYan-Hsuan Chuang enum rtw_fw_rf_type {
115e3037485SYan-Hsuan Chuang FW_RF_1T2R = 0,
116a9594960SChin-Yen Lee FW_RF_2T4R = 1,
117a9594960SChin-Yen Lee FW_RF_2T2R = 2,
118a9594960SChin-Yen Lee FW_RF_2T3R = 3,
119a9594960SChin-Yen Lee FW_RF_1T1R = 4,
120a9594960SChin-Yen Lee FW_RF_2T2R_GREEN = 5,
1215d5d68bcSChin-Yen Lee FW_RF_3T3R = 6,
122cd96e22bSPo-Hao Huang FW_RF_3T4R = 7,
123a853d234SChin-Yen Lee FW_RF_4T4R = 8,
124fe7bc23aSChin-Yen Lee FW_RF_MAX_TYPE = 0xF,
12510d162b2SPo-Hao Huang };
126a9594960SChin-Yen Lee
127a9594960SChin-Yen Lee enum rtw_fw_feature {
128a9594960SChin-Yen Lee FW_FEATURE_SIG = BIT(0),
129d2eb7cb9SPo-Hao Huang FW_FEATURE_LPS_C2H = BIT(1),
130d2eb7cb9SPo-Hao Huang FW_FEATURE_LCLK = BIT(2),
131d2eb7cb9SPo-Hao Huang FW_FEATURE_PG = BIT(3),
132d2eb7cb9SPo-Hao Huang FW_FEATURE_TX_WAKE = BIT(4),
133cd96e22bSPo-Hao Huang FW_FEATURE_BCN_FILTER = BIT(5),
134cd96e22bSPo-Hao Huang FW_FEATURE_NOTIFY_SCAN = BIT(6),
135cd96e22bSPo-Hao Huang FW_FEATURE_ADAPTIVITY = BIT(7),
136cd96e22bSPo-Hao Huang FW_FEATURE_SCAN_OFFLOAD = BIT(8),
137cd96e22bSPo-Hao Huang FW_FEATURE_MAX = BIT(31),
138cd96e22bSPo-Hao Huang };
1390c283b47SPo-Hao Huang
140cd96e22bSPo-Hao Huang enum rtw_fw_feature_ext {
141cd96e22bSPo-Hao Huang FW_FEATURE_EXT_OLD_PAGE_NUM = BIT(0),
1424136214fSYan-Hsuan Chuang };
1434136214fSYan-Hsuan Chuang
1444136214fSYan-Hsuan Chuang enum rtw_beacon_filter_offload_mode {
1454136214fSYan-Hsuan Chuang BCN_FILTER_OFFLOAD_MODE_0 = 0,
1464136214fSYan-Hsuan Chuang BCN_FILTER_OFFLOAD_MODE_1,
1474136214fSYan-Hsuan Chuang BCN_FILTER_OFFLOAD_MODE_2,
1484136214fSYan-Hsuan Chuang BCN_FILTER_OFFLOAD_MODE_3,
1494136214fSYan-Hsuan Chuang
150e3037485SYan-Hsuan Chuang BCN_FILTER_OFFLOAD_MODE_DEFAULT = BCN_FILTER_OFFLOAD_MODE_0,
151e3037485SYan-Hsuan Chuang };
152e3037485SYan-Hsuan Chuang
153e3037485SYan-Hsuan Chuang struct rtw_coex_info_req {
154e3037485SYan-Hsuan Chuang u8 seq;
15504b786e0SYan-Hsuan Chuang u8 op_code;
15604b786e0SYan-Hsuan Chuang u8 para1;
15704b786e0SYan-Hsuan Chuang u8 para2;
15804b786e0SYan-Hsuan Chuang u8 para3;
15904b786e0SYan-Hsuan Chuang };
16004b786e0SYan-Hsuan Chuang
16104b786e0SYan-Hsuan Chuang struct rtw_iqk_para {
16204b786e0SYan-Hsuan Chuang u8 clear;
16304b786e0SYan-Hsuan Chuang u8 segment_iqk;
16404b786e0SYan-Hsuan Chuang };
16504b786e0SYan-Hsuan Chuang
16604b786e0SYan-Hsuan Chuang struct rtw_lps_pg_dpk_hdr {
16704b786e0SYan-Hsuan Chuang u16 dpk_path_ok;
16804b786e0SYan-Hsuan Chuang u8 dpk_txagc[2];
16904b786e0SYan-Hsuan Chuang u16 dpk_gs[2];
17004b786e0SYan-Hsuan Chuang u32 coef[2][20];
17104b786e0SYan-Hsuan Chuang u8 dpk_ch;
17204b786e0SYan-Hsuan Chuang } __packed;
17304b786e0SYan-Hsuan Chuang
174e3037485SYan-Hsuan Chuang struct rtw_lps_pg_info_hdr {
175895c096dSYan-Hsuan Chuang u8 macid;
176895c096dSYan-Hsuan Chuang u8 mbssid;
177895c096dSYan-Hsuan Chuang u8 pattern_count;
178895c096dSYan-Hsuan Chuang u8 mu_tab_group_id;
179895c096dSYan-Hsuan Chuang u8 sec_cam_count;
180895c096dSYan-Hsuan Chuang u8 tx_bu_page_count;
181895c096dSYan-Hsuan Chuang u16 rsvd;
182e3037485SYan-Hsuan Chuang u8 sec_cam[MAX_PG_CAM_BACKUP_NUM];
183e3037485SYan-Hsuan Chuang } __packed;
184e3037485SYan-Hsuan Chuang
185f2217968SPo-Hao Huang struct rtw_rsvd_page {
186e3037485SYan-Hsuan Chuang /* associated with each vif */
187b6c12908SChin-Yen Lee struct list_head vif_list;
18869c70445SChin-Yen Lee struct rtw_vif *rtwvif;
189e3037485SYan-Hsuan Chuang
190e3037485SYan-Hsuan Chuang /* associated when build rsvd page */
19144bc17f7SChin-Yen Lee struct list_head build_list;
19244bc17f7SChin-Yen Lee
19344bc17f7SChin-Yen Lee struct sk_buff *skb;
19444bc17f7SChin-Yen Lee enum rtw_rsvd_packet_type type;
19544bc17f7SChin-Yen Lee u8 page;
196b6c12908SChin-Yen Lee u16 tim_offset;
197b6c12908SChin-Yen Lee bool add_txdesc;
198b6c12908SChin-Yen Lee struct cfg80211_ssid *ssid;
199b6c12908SChin-Yen Lee u16 probe_req_size;
200b6c12908SChin-Yen Lee };
201b6c12908SChin-Yen Lee
202b6c12908SChin-Yen Lee enum rtw_keep_alive_pkt_type {
203b6c12908SChin-Yen Lee KEEP_ALIVE_NULL_PKT = 0,
204b6c12908SChin-Yen Lee KEEP_ALIVE_ARP_RSP = 1,
205b6c12908SChin-Yen Lee };
206b6c12908SChin-Yen Lee
207b6c12908SChin-Yen Lee struct rtw_nlo_info_hdr {
208b6c12908SChin-Yen Lee u8 nlo_count;
209b6c12908SChin-Yen Lee u8 hidden_ap_count;
210b6c12908SChin-Yen Lee u8 rsvd1[2];
211b6c12908SChin-Yen Lee u8 pattern_check[FW_NLO_INFO_CHECK_SIZE];
212b6c12908SChin-Yen Lee u8 rsvd2[8];
213b6c12908SChin-Yen Lee u8 ssid_len[16];
21444bc17f7SChin-Yen Lee u8 chiper[16];
21544bc17f7SChin-Yen Lee u8 rsvd3[16];
21644bc17f7SChin-Yen Lee u8 location[8];
21744bc17f7SChin-Yen Lee } __packed;
21844bc17f7SChin-Yen Lee
21944bc17f7SChin-Yen Lee enum rtw_packet_type {
22044bc17f7SChin-Yen Lee RTW_PACKET_PROBE_REQ = 0x00,
22144bc17f7SChin-Yen Lee
22244bc17f7SChin-Yen Lee RTW_PACKET_UNDEFINE = 0x7FFFFFFF,
22344bc17f7SChin-Yen Lee };
22444bc17f7SChin-Yen Lee
22544bc17f7SChin-Yen Lee struct rtw_fw_wow_keep_alive_para {
22610d162b2SPo-Hao Huang bool adopt;
22710d162b2SPo-Hao Huang u8 pkt_type;
22810d162b2SPo-Hao Huang u8 period; /* unit: sec */
22910d162b2SPo-Hao Huang };
23010d162b2SPo-Hao Huang
23110d162b2SPo-Hao Huang struct rtw_fw_wow_disconnect_para {
23210d162b2SPo-Hao Huang bool adopt;
23310d162b2SPo-Hao Huang u8 period; /* unit: sec */
23410d162b2SPo-Hao Huang u8 retry_count;
23510d162b2SPo-Hao Huang };
23610d162b2SPo-Hao Huang
23710d162b2SPo-Hao Huang enum rtw_channel_type {
23810d162b2SPo-Hao Huang RTW_CHANNEL_PASSIVE,
23910d162b2SPo-Hao Huang RTW_CHANNEL_ACTIVE,
24010d162b2SPo-Hao Huang RTW_CHANNEL_RADAR,
24110d162b2SPo-Hao Huang };
24210d162b2SPo-Hao Huang
24310d162b2SPo-Hao Huang enum rtw_scan_extra_id {
24410d162b2SPo-Hao Huang RTW_SCAN_EXTRA_ID_DFS,
24510d162b2SPo-Hao Huang };
24610d162b2SPo-Hao Huang
24710d162b2SPo-Hao Huang enum rtw_scan_extra_info {
24810d162b2SPo-Hao Huang RTW_SCAN_EXTRA_ACTION_SCAN,
24910d162b2SPo-Hao Huang };
25010d162b2SPo-Hao Huang
25110d162b2SPo-Hao Huang enum rtw_scan_report_code {
25210d162b2SPo-Hao Huang RTW_SCAN_REPORT_SUCCESS = 0x00,
25310d162b2SPo-Hao Huang RTW_SCAN_REPORT_ERR_PHYDM = 0x01,
25410d162b2SPo-Hao Huang RTW_SCAN_REPORT_ERR_ID = 0x02,
25510d162b2SPo-Hao Huang RTW_SCAN_REPORT_ERR_TX = 0x03,
25610d162b2SPo-Hao Huang RTW_SCAN_REPORT_CANCELED = 0x10,
25710d162b2SPo-Hao Huang RTW_SCAN_REPORT_CANCELED_EXT = 0x11,
25810d162b2SPo-Hao Huang RTW_SCAN_REPORT_FW_DISABLED = 0xF0,
25910d162b2SPo-Hao Huang };
26010d162b2SPo-Hao Huang
26110d162b2SPo-Hao Huang enum rtw_scan_notify_id {
26210d162b2SPo-Hao Huang RTW_SCAN_NOTIFY_ID_PRESWITCH = 0x00,
26310d162b2SPo-Hao Huang RTW_SCAN_NOTIFY_ID_POSTSWITCH = 0x01,
26410d162b2SPo-Hao Huang RTW_SCAN_NOTIFY_ID_PROBE_PRETX = 0x02,
26510d162b2SPo-Hao Huang RTW_SCAN_NOTIFY_ID_PROBE_ISSUETX = 0x03,
26610d162b2SPo-Hao Huang RTW_SCAN_NOTIFY_ID_NULL0_PRETX = 0x04,
26710d162b2SPo-Hao Huang RTW_SCAN_NOTIFY_ID_NULL0_ISSUETX = 0x05,
26810d162b2SPo-Hao Huang RTW_SCAN_NOTIFY_ID_NULL0_POSTTX = 0x06,
26910d162b2SPo-Hao Huang RTW_SCAN_NOTIFY_ID_NULL1_PRETX = 0x07,
27010d162b2SPo-Hao Huang RTW_SCAN_NOTIFY_ID_NULL1_ISSUETX = 0x08,
271b6c12908SChin-Yen Lee RTW_SCAN_NOTIFY_ID_NULL1_POSTTX = 0x09,
272b6c12908SChin-Yen Lee RTW_SCAN_NOTIFY_ID_DWELLEXT = 0x0A,
273b6c12908SChin-Yen Lee };
274b6c12908SChin-Yen Lee
275b6c12908SChin-Yen Lee enum rtw_scan_notify_status {
276b6c12908SChin-Yen Lee RTW_SCAN_NOTIFY_STATUS_SUCCESS = 0x00,
277b6c12908SChin-Yen Lee RTW_SCAN_NOTIFY_STATUS_FAILURE = 0x01,
278b6c12908SChin-Yen Lee RTW_SCAN_NOTIFY_STATUS_RESOURCE = 0x02,
279b6c12908SChin-Yen Lee RTW_SCAN_NOTIFY_STATUS_TIMEOUT = 0x03,
280b6c12908SChin-Yen Lee };
281b6c12908SChin-Yen Lee
282b6c12908SChin-Yen Lee struct rtw_ch_switch_option {
283b6c12908SChin-Yen Lee u8 periodic_option;
28410d162b2SPo-Hao Huang u32 tsf_high;
28510d162b2SPo-Hao Huang u32 tsf_low;
286b6c12908SChin-Yen Lee u8 dest_ch_en;
287b6c12908SChin-Yen Lee u8 absolute_time_en;
288cc20a713SPing-Ke Shih u8 dest_ch;
289cc20a713SPing-Ke Shih u8 normal_period;
290cc20a713SPing-Ke Shih u8 normal_period_sel;
291cc20a713SPing-Ke Shih u8 normal_cycle;
292cc20a713SPing-Ke Shih u8 slow_period;
293cc20a713SPing-Ke Shih u8 slow_period_sel;
294cc20a713SPing-Ke Shih u8 nlo_en;
295cc20a713SPing-Ke Shih bool switch_en;
296a9594960SChin-Yen Lee bool back_op_en;
297cc20a713SPing-Ke Shih };
298cc20a713SPing-Ke Shih
299cc20a713SPing-Ke Shih struct rtw_fw_hdr {
300cc20a713SPing-Ke Shih __le16 signature;
301cc20a713SPing-Ke Shih u8 category;
302cc20a713SPing-Ke Shih u8 function;
303cc20a713SPing-Ke Shih __le16 version; /* 0x04 */
304cc20a713SPing-Ke Shih u8 subversion;
305cc20a713SPing-Ke Shih u8 subindex;
306cc20a713SPing-Ke Shih __le32 rsvd; /* 0x08 */
307cc20a713SPing-Ke Shih __le32 feature; /* 0x0C */
308cc20a713SPing-Ke Shih u8 month; /* 0x10 */
309cc20a713SPing-Ke Shih u8 day;
310cc20a713SPing-Ke Shih u8 hour;
311cc20a713SPing-Ke Shih u8 min;
312cc20a713SPing-Ke Shih __le16 year; /* 0x14 */
313cc20a713SPing-Ke Shih __le16 rsvd3;
314cc20a713SPing-Ke Shih u8 mem_usage; /* 0x18 */
31589dca86dSBrian Norris u8 rsvd4[3];
316cc20a713SPing-Ke Shih __le16 h2c_fmt_ver; /* 0x1C */
31715d2fcc6SPing-Ke Shih __le16 rsvd5;
31815d2fcc6SPing-Ke Shih __le32 dmem_addr; /* 0x20 */
31915d2fcc6SPing-Ke Shih __le32 dmem_size;
32015d2fcc6SPing-Ke Shih __le32 rsvd6;
32115d2fcc6SPing-Ke Shih __le32 rsvd7;
32215d2fcc6SPing-Ke Shih __le32 imem_size; /* 0x30 */
32315d2fcc6SPing-Ke Shih __le32 emem_size;
32415d2fcc6SPing-Ke Shih __le32 emem_addr;
32515d2fcc6SPing-Ke Shih __le32 imem_addr;
32615d2fcc6SPing-Ke Shih } __packed;
32715d2fcc6SPing-Ke Shih
32815d2fcc6SPing-Ke Shih struct rtw_fw_hdr_legacy {
32915d2fcc6SPing-Ke Shih __le16 signature;
33015d2fcc6SPing-Ke Shih u8 category;
33115d2fcc6SPing-Ke Shih u8 function;
33215d2fcc6SPing-Ke Shih __le16 version; /* 0x04 */
33315d2fcc6SPing-Ke Shih u8 subversion1;
33415d2fcc6SPing-Ke Shih u8 subversion2;
33515d2fcc6SPing-Ke Shih u8 month; /* 0x08 */
336d2eb7cb9SPo-Hao Huang u8 day;
337d2eb7cb9SPo-Hao Huang u8 hour;
338d2eb7cb9SPo-Hao Huang u8 minute;
339d2eb7cb9SPo-Hao Huang __le16 size;
340d2eb7cb9SPo-Hao Huang __le16 rsvd2;
341e3037485SYan-Hsuan Chuang __le32 idx; /* 0x10 */
342614b1f87SPing-Ke Shih __le32 rsvd3;
343614b1f87SPing-Ke Shih __le32 rsvd4; /* 0x18 */
344614b1f87SPing-Ke Shih __le32 rsvd5;
345614b1f87SPing-Ke Shih } __packed;
346e3037485SYan-Hsuan Chuang
34710d162b2SPo-Hao Huang #define RTW_FW_VER_CODE(ver, sub_ver, idx) \
34810d162b2SPo-Hao Huang (((ver) << 16) | ((sub_ver) << 8) | (idx))
34910d162b2SPo-Hao Huang #define RTW_FW_SUIT_VER_CODE(s) \
35010d162b2SPo-Hao Huang RTW_FW_VER_CODE((s).version, (s).sub_version, (s).sub_index)
35110d162b2SPo-Hao Huang
352699c7730STzu-En Huang /* C2H */
353699c7730STzu-En Huang #define GET_CCX_REPORT_SEQNUM_V0(c2h_payload) (c2h_payload[6] & 0xfc)
354699c7730STzu-En Huang #define GET_CCX_REPORT_STATUS_V0(c2h_payload) (c2h_payload[0] & 0xc0)
355699c7730STzu-En Huang #define GET_CCX_REPORT_SEQNUM_V1(c2h_payload) (c2h_payload[8] & 0xfc)
356699c7730STzu-En Huang #define GET_CCX_REPORT_STATUS_V1(c2h_payload) (c2h_payload[9] & 0xc0)
357cd96e22bSPo-Hao Huang
358cd96e22bSPo-Hao Huang #define GET_SCAN_REPORT_RETURN_CODE(c2h_payload) (c2h_payload[2] & 0xff)
359cd96e22bSPo-Hao Huang
360cd96e22bSPo-Hao Huang #define GET_CHAN_SWITCH_CENTRAL_CH(c2h_payload) (c2h_payload[2])
361e3037485SYan-Hsuan Chuang #define GET_CHAN_SWITCH_ID(c2h_payload) (c2h_payload[3])
362e3037485SYan-Hsuan Chuang #define GET_CHAN_SWITCH_STATUS(c2h_payload) (c2h_payload[4])
363e3037485SYan-Hsuan Chuang #define GET_RA_REPORT_RATE(c2h_payload) (c2h_payload[0] & 0x7f)
364e3037485SYan-Hsuan Chuang #define GET_RA_REPORT_SGI(c2h_payload) ((c2h_payload[0] & 0x80) >> 7)
365e3037485SYan-Hsuan Chuang #define GET_RA_REPORT_BW(c2h_payload) (c2h_payload[6])
366e3037485SYan-Hsuan Chuang #define GET_RA_REPORT_MACID(c2h_payload) (c2h_payload[1])
367e3037485SYan-Hsuan Chuang
368e3037485SYan-Hsuan Chuang #define GET_BCN_FILTER_NOTIFY_TYPE(c2h_payload) (c2h_payload[1] & 0xf)
369b6c12908SChin-Yen Lee #define GET_BCN_FILTER_NOTIFY_EVENT(c2h_payload) (c2h_payload[1] & 0x10)
370b6c12908SChin-Yen Lee #define GET_BCN_FILTER_NOTIFY_RSSI(c2h_payload) (c2h_payload[2] - 100)
37110d162b2SPo-Hao Huang
372b6c12908SChin-Yen Lee /* PKT H2C */
373b6c12908SChin-Yen Lee #define H2C_PKT_CMD_ID 0xFF
374b6c12908SChin-Yen Lee #define H2C_PKT_CATEGORY 0x01
375b6c12908SChin-Yen Lee
376e3037485SYan-Hsuan Chuang #define H2C_PKT_GENERAL_INFO 0x0D
377e3037485SYan-Hsuan Chuang #define H2C_PKT_PHYDM_INFO 0x11
378e3037485SYan-Hsuan Chuang #define H2C_PKT_IQK 0x0E
379e3037485SYan-Hsuan Chuang
380e3037485SYan-Hsuan Chuang #define H2C_PKT_CH_SWITCH 0x02
381e3037485SYan-Hsuan Chuang #define H2C_PKT_UPDATE_PKT 0x0C
382e3037485SYan-Hsuan Chuang #define H2C_PKT_SCAN_OFFLOAD 0x19
383e3037485SYan-Hsuan Chuang
384e3037485SYan-Hsuan Chuang #define H2C_PKT_CH_SWITCH_LEN 0x20
385e3037485SYan-Hsuan Chuang #define H2C_PKT_UPDATE_PKT_LEN 0x4
386e3037485SYan-Hsuan Chuang
387e3037485SYan-Hsuan Chuang #define SET_PKT_H2C_CATEGORY(h2c_pkt, value) \
388e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(6, 0))
389e3037485SYan-Hsuan Chuang #define SET_PKT_H2C_CMD_ID(h2c_pkt, value) \
390e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
391e3037485SYan-Hsuan Chuang #define SET_PKT_H2C_SUB_CMD_ID(h2c_pkt, value) \
392e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 16))
393e3037485SYan-Hsuan Chuang #define SET_PKT_H2C_TOTAL_LEN(h2c_pkt, value) \
394e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(15, 0))
395e3037485SYan-Hsuan Chuang
rtw_h2c_pkt_set_header(u8 * h2c_pkt,u8 sub_id)396e3037485SYan-Hsuan Chuang static inline void rtw_h2c_pkt_set_header(u8 *h2c_pkt, u8 sub_id)
397e3037485SYan-Hsuan Chuang {
398e3037485SYan-Hsuan Chuang SET_PKT_H2C_CATEGORY(h2c_pkt, H2C_PKT_CATEGORY);
399e3037485SYan-Hsuan Chuang SET_PKT_H2C_CMD_ID(h2c_pkt, H2C_PKT_CMD_ID);
400e3037485SYan-Hsuan Chuang SET_PKT_H2C_SUB_CMD_ID(h2c_pkt, sub_id);
401e3037485SYan-Hsuan Chuang }
402e3037485SYan-Hsuan Chuang
403e3037485SYan-Hsuan Chuang #define FW_OFFLOAD_H2C_SET_SEQ_NUM(h2c_pkt, value) \
404e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(31, 16))
405e3037485SYan-Hsuan Chuang #define GENERAL_INFO_SET_FW_TX_BOUNDARY(h2c_pkt, value) \
406e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(23, 16))
407e3037485SYan-Hsuan Chuang
408e3037485SYan-Hsuan Chuang #define PHYDM_INFO_SET_REF_TYPE(h2c_pkt, value) \
409e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(7, 0))
410e3037485SYan-Hsuan Chuang #define PHYDM_INFO_SET_RF_TYPE(h2c_pkt, value) \
411e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(15, 8))
412b6c12908SChin-Yen Lee #define PHYDM_INFO_SET_CUT_VER(h2c_pkt, value) \
413b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(23, 16))
414b6c12908SChin-Yen Lee #define PHYDM_INFO_SET_RX_ANT_STATUS(h2c_pkt, value) \
415b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(27, 24))
416b6c12908SChin-Yen Lee #define PHYDM_INFO_SET_TX_ANT_STATUS(h2c_pkt, value) \
417b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(31, 28))
418b6c12908SChin-Yen Lee #define IQK_SET_CLEAR(h2c_pkt, value) \
419b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(0))
420b6c12908SChin-Yen Lee #define IQK_SET_SEGMENT_IQK(h2c_pkt, value) \
421b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(1))
42210d162b2SPo-Hao Huang
42310d162b2SPo-Hao Huang #define CHSW_INFO_SET_CH(pkt, value) \
42410d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(pkt) + 0x00, value, GENMASK(7, 0))
42510d162b2SPo-Hao Huang #define CHSW_INFO_SET_PRI_CH_IDX(pkt, value) \
42610d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(pkt) + 0x00, value, GENMASK(11, 8))
42710d162b2SPo-Hao Huang #define CHSW_INFO_SET_BW(pkt, value) \
42810d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(pkt) + 0x00, value, GENMASK(15, 12))
42910d162b2SPo-Hao Huang #define CHSW_INFO_SET_TIMEOUT(pkt, value) \
43010d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(pkt) + 0x00, value, GENMASK(23, 16))
43110d162b2SPo-Hao Huang #define CHSW_INFO_SET_ACTION_ID(pkt, value) \
43210d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(pkt) + 0x00, value, GENMASK(30, 24))
43310d162b2SPo-Hao Huang #define CHSW_INFO_SET_EXTRA_INFO(pkt, value) \
43410d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(pkt) + 0x00, value, BIT(31))
43510d162b2SPo-Hao Huang
43610d162b2SPo-Hao Huang #define CH_INFO_SET_CH(pkt, value) \
43710d162b2SPo-Hao Huang u8p_replace_bits((u8 *)(pkt) + 0x00, value, GENMASK(7, 0))
43810d162b2SPo-Hao Huang #define CH_INFO_SET_PRI_CH_IDX(pkt, value) \
43910d162b2SPo-Hao Huang u8p_replace_bits((u8 *)(pkt) + 0x01, value, GENMASK(3, 0))
44010d162b2SPo-Hao Huang #define CH_INFO_SET_BW(pkt, value) \
44110d162b2SPo-Hao Huang u8p_replace_bits((u8 *)(pkt) + 0x01, value, GENMASK(7, 4))
44210d162b2SPo-Hao Huang #define CH_INFO_SET_TIMEOUT(pkt, value) \
44310d162b2SPo-Hao Huang u8p_replace_bits((u8 *)(pkt) + 0x02, value, GENMASK(7, 0))
44410d162b2SPo-Hao Huang #define CH_INFO_SET_ACTION_ID(pkt, value) \
44510d162b2SPo-Hao Huang u8p_replace_bits((u8 *)(pkt) + 0x03, value, GENMASK(6, 0))
446b6c12908SChin-Yen Lee #define CH_INFO_SET_EXTRA_INFO(pkt, value) \
447b6c12908SChin-Yen Lee u8p_replace_bits((u8 *)(pkt) + 0x03, value, BIT(7))
448b6c12908SChin-Yen Lee
449b6c12908SChin-Yen Lee #define EXTRA_CH_INFO_SET_ID(pkt, value) \
450b6c12908SChin-Yen Lee u8p_replace_bits((u8 *)(pkt) + 0x04, value, GENMASK(6, 0))
451b6c12908SChin-Yen Lee #define EXTRA_CH_INFO_SET_INFO(pkt, value) \
452b6c12908SChin-Yen Lee u8p_replace_bits((u8 *)(pkt) + 0x04, value, BIT(7))
453b6c12908SChin-Yen Lee #define EXTRA_CH_INFO_SET_SIZE(pkt, value) \
454b6c12908SChin-Yen Lee u8p_replace_bits((u8 *)(pkt) + 0x05, value, GENMASK(7, 0))
455b6c12908SChin-Yen Lee #define EXTRA_CH_INFO_SET_DFS_EXT_TIME(pkt, value) \
456b6c12908SChin-Yen Lee u8p_replace_bits((u8 *)(pkt) + 0x06, value, GENMASK(7, 0))
457b6c12908SChin-Yen Lee
458b6c12908SChin-Yen Lee #define UPDATE_PKT_SET_SIZE(h2c_pkt, value) \
459b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(15, 0))
460b6c12908SChin-Yen Lee #define UPDATE_PKT_SET_PKT_ID(h2c_pkt, value) \
461b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(23, 16))
46210d162b2SPo-Hao Huang #define UPDATE_PKT_SET_LOCATION(h2c_pkt, value) \
46310d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(31, 24))
46410d162b2SPo-Hao Huang
46510d162b2SPo-Hao Huang #define CH_SWITCH_SET_START(h2c_pkt, value) \
466b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(0))
467b6c12908SChin-Yen Lee #define CH_SWITCH_SET_DEST_CH_EN(h2c_pkt, value) \
468b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(1))
469b6c12908SChin-Yen Lee #define CH_SWITCH_SET_ABSOLUTE_TIME(h2c_pkt, value) \
470b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(2))
471b6c12908SChin-Yen Lee #define CH_SWITCH_SET_PERIODIC_OPT(h2c_pkt, value) \
47210d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(4, 3))
47310d162b2SPo-Hao Huang #define CH_SWITCH_SET_SCAN_MODE(h2c_pkt, value) \
474b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(5))
475b6c12908SChin-Yen Lee #define CH_SWITCH_SET_BACK_OP_EN(h2c_pkt, value) \
476b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(6))
477b6c12908SChin-Yen Lee #define CH_SWITCH_SET_INFO_LOC(h2c_pkt, value) \
478b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(15, 8))
479b6c12908SChin-Yen Lee #define CH_SWITCH_SET_CH_NUM(h2c_pkt, value) \
480b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(23, 16))
481b6c12908SChin-Yen Lee #define CH_SWITCH_SET_PRI_CH_IDX(h2c_pkt, value) \
482b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(27, 24))
483b6c12908SChin-Yen Lee #define CH_SWITCH_SET_DEST_BW(h2c_pkt, value) \
484b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(31, 28))
485b6c12908SChin-Yen Lee #define CH_SWITCH_SET_DEST_CH(h2c_pkt, value) \
486b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, GENMASK(7, 0))
487b6c12908SChin-Yen Lee #define CH_SWITCH_SET_NORMAL_PERIOD(h2c_pkt, value) \
488b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, GENMASK(13, 8))
489b6c12908SChin-Yen Lee #define CH_SWITCH_SET_NORMAL_PERIOD_SEL(h2c_pkt, value) \
490b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, GENMASK(15, 14))
491b6c12908SChin-Yen Lee #define CH_SWITCH_SET_SLOW_PERIOD(h2c_pkt, value) \
492b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, GENMASK(21, 16))
49310d162b2SPo-Hao Huang #define CH_SWITCH_SET_SLOW_PERIOD_SEL(h2c_pkt, value) \
49410d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, GENMASK(23, 22))
49510d162b2SPo-Hao Huang #define CH_SWITCH_SET_NORMAL_CYCLE(h2c_pkt, value) \
49610d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, GENMASK(31, 24))
49710d162b2SPo-Hao Huang #define CH_SWITCH_SET_TSF_HIGH(h2c_pkt, value) \
49810d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x04, value, GENMASK(31, 0))
49910d162b2SPo-Hao Huang #define CH_SWITCH_SET_TSF_LOW(h2c_pkt, value) \
50010d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x05, value, GENMASK(31, 0))
50110d162b2SPo-Hao Huang #define CH_SWITCH_SET_INFO_SIZE(h2c_pkt, value) \
50210d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x06, value, GENMASK(15, 0))
50310d162b2SPo-Hao Huang
50410d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_START(h2c_pkt, value) \
50510d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(0))
50610d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_BACK_OP_EN(h2c_pkt, value) \
50710d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(1))
50810d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_RANDOM_SEQ_EN(h2c_pkt, value) \
50910d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(2))
51010d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_NO_CCK_EN(h2c_pkt, value) \
51110d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(3))
51210d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_VERBOSE(h2c_pkt, value) \
51310d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(4))
51410d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_CH_NUM(h2c_pkt, value) \
51510d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(15, 8))
51610d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_CH_INFO_SIZE(h2c_pkt, value) \
51710d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(31, 16))
51810d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_CH_INFO_LOC(h2c_pkt, value) \
51910d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, GENMASK(7, 0))
52010d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_OP_CH(h2c_pkt, value) \
52110d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, GENMASK(15, 8))
52210d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_OP_PRI_CH_IDX(h2c_pkt, value) \
52310d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, GENMASK(19, 16))
52410d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_OP_BW(h2c_pkt, value) \
52510d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, GENMASK(23, 20))
52610d162b2SPo-Hao Huang #define SCAN_OFFLOAD_SET_OP_PORT_ID(h2c_pkt, value) \
52710d162b2SPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, GENMASK(26, 24))
528e3037485SYan-Hsuan Chuang #define SCAN_OFFLOAD_SET_OP_DWELL_TIME(h2c_pkt, value) \
529e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x04, value, GENMASK(15, 0))
530e3037485SYan-Hsuan Chuang #define SCAN_OFFLOAD_SET_OP_GAP_TIME(h2c_pkt, value) \
531e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x04, value, GENMASK(31, 16))
53204b786e0SYan-Hsuan Chuang #define SCAN_OFFLOAD_SET_MODE(h2c_pkt, value) \
533e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x05, value, GENMASK(3, 0))
534e3037485SYan-Hsuan Chuang #define SCAN_OFFLOAD_SET_SSID_NUM(h2c_pkt, value) \
535cd96e22bSPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x05, value, GENMASK(7, 4))
536cd96e22bSPo-Hao Huang #define SCAN_OFFLOAD_SET_PKT_LOC(h2c_pkt, value) \
537ec7480edSPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x05, value, GENMASK(15, 8))
538a853d234SChin-Yen Lee
539fe7bc23aSChin-Yen Lee /* Command H2C */
540e3037485SYan-Hsuan Chuang #define H2C_CMD_RSVD_PAGE 0x0
5414136214fSYan-Hsuan Chuang #define H2C_CMD_MEDIA_STATUS_RPT 0x01
5424136214fSYan-Hsuan Chuang #define H2C_CMD_SET_PWR_MODE 0x20
5434136214fSYan-Hsuan Chuang #define H2C_CMD_LPS_PG_INFO 0x2b
5444136214fSYan-Hsuan Chuang #define H2C_CMD_DEFAULT_PORT 0x2c
5454136214fSYan-Hsuan Chuang #define H2C_CMD_RA_INFO 0x40
5464136214fSYan-Hsuan Chuang #define H2C_CMD_RSSI_MONITOR 0x42
5474136214fSYan-Hsuan Chuang #define H2C_CMD_BCN_FILTER_OFFLOAD_P0 0x56
548056b239fSGuo-Feng Fan #define H2C_CMD_BCN_FILTER_OFFLOAD_P1 0x57
549fc3c66d3SChing-Te Ku #define H2C_CMD_WL_PHY_INFO 0x58
5504136214fSYan-Hsuan Chuang #define H2C_CMD_SCAN 0x59
55144bc17f7SChin-Yen Lee #define H2C_CMD_ADAPTIVITY 0x5A
55244bc17f7SChin-Yen Lee
55344bc17f7SChin-Yen Lee #define H2C_CMD_COEX_TDMA_TYPE 0x60
55444bc17f7SChin-Yen Lee #define H2C_CMD_QUERY_BT_INFO 0x61
55544bc17f7SChin-Yen Lee #define H2C_CMD_FORCE_BT_TX_POWER 0x62
556b6c12908SChin-Yen Lee #define H2C_CMD_IGNORE_WLAN_ACTION 0x63
557b6c12908SChin-Yen Lee #define H2C_CMD_WL_CH_INFO 0x66
5587c57d3dcSPing-Ke Shih #define H2C_CMD_QUERY_BT_MP_INFO 0x67
5597c57d3dcSPing-Ke Shih #define H2C_CMD_BT_WIFI_CONTROL 0x69
560e3037485SYan-Hsuan Chuang #define H2C_CMD_WIFI_CALIBRATION 0x6d
561e3037485SYan-Hsuan Chuang #define H2C_CMD_QUERY_BT_HID_INFO 0x73
562e3037485SYan-Hsuan Chuang
563e3037485SYan-Hsuan Chuang #define H2C_CMD_KEEP_ALIVE 0x03
564e3037485SYan-Hsuan Chuang #define H2C_CMD_DISCONNECT_DECISION 0x04
565e3037485SYan-Hsuan Chuang #define H2C_CMD_WOWLAN 0x80
566e3037485SYan-Hsuan Chuang #define H2C_CMD_REMOTE_WAKE_CTRL 0x81
567e3037485SYan-Hsuan Chuang #define H2C_CMD_AOAC_GLOBAL_INFO 0x82
568ec7480edSPo-Hao Huang #define H2C_CMD_NLO_INFO 0x8C
569ec7480edSPo-Hao Huang
570ec7480edSPo-Hao Huang #define H2C_CMD_RECOVER_BT_DEV 0xD1
571ec7480edSPo-Hao Huang
572ec7480edSPo-Hao Huang #define SET_H2C_CMD_ID_CLASS(h2c_pkt, value) \
573ec7480edSPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(7, 0))
574ec7480edSPo-Hao Huang
575ec7480edSPo-Hao Huang #define MEDIA_STATUS_RPT_SET_OP_MODE(h2c_pkt, value) \
576ec7480edSPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
577ec7480edSPo-Hao Huang #define MEDIA_STATUS_RPT_SET_MACID(h2c_pkt, value) \
578cd96e22bSPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
579cd96e22bSPo-Hao Huang
580cd96e22bSPo-Hao Huang #define SET_WL_PHY_INFO_TX_TP(h2c_pkt, value) \
581cd96e22bSPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(17, 8))
582cd96e22bSPo-Hao Huang #define SET_WL_PHY_INFO_RX_TP(h2c_pkt, value) \
583cd96e22bSPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(27, 18))
584cd96e22bSPo-Hao Huang #define SET_WL_PHY_INFO_TX_RATE_DESC(h2c_pkt, value) \
585cd96e22bSPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(7, 0))
586cd96e22bSPo-Hao Huang #define SET_WL_PHY_INFO_RX_RATE_DESC(h2c_pkt, value) \
587cd96e22bSPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(15, 8))
588cd96e22bSPo-Hao Huang #define SET_WL_PHY_INFO_RX_EVM(h2c_pkt, value) \
589cd96e22bSPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(23, 16))
590cd96e22bSPo-Hao Huang #define SET_BCN_FILTER_OFFLOAD_P1_MACID(h2c_pkt, value) \
591cd96e22bSPo-Hao Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
592ec7480edSPo-Hao Huang #define SET_BCN_FILTER_OFFLOAD_P1_ENABLE(h2c_pkt, value) \
593a853d234SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(16))
594a853d234SChin-Yen Lee #define SET_BCN_FILTER_OFFLOAD_P1_HYST(h2c_pkt, value) \
595a853d234SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(20, 17))
596fe7bc23aSChin-Yen Lee #define SET_BCN_FILTER_OFFLOAD_P1_OFFLOAD_MODE(h2c_pkt, value) \
597fe7bc23aSChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 21))
598fe7bc23aSChin-Yen Lee #define SET_BCN_FILTER_OFFLOAD_P1_THRESHOLD(h2c_pkt, value) \
599fe7bc23aSChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
600fe7bc23aSChin-Yen Lee #define SET_BCN_FILTER_OFFLOAD_P1_BCN_LOSS_CNT(h2c_pkt, value) \
601fe7bc23aSChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(3, 0))
602fe7bc23aSChin-Yen Lee #define SET_BCN_FILTER_OFFLOAD_P1_BCN_INTERVAL(h2c_pkt, value) \
603fe7bc23aSChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(13, 4))
604fe7bc23aSChin-Yen Lee
605fe7bc23aSChin-Yen Lee #define SET_SCAN_START(h2c_pkt, value) \
606fe7bc23aSChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
607e3037485SYan-Hsuan Chuang
608e3037485SYan-Hsuan Chuang #define SET_ADAPTIVITY_MODE(h2c_pkt, value) \
609e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(11, 8))
610e3037485SYan-Hsuan Chuang #define SET_ADAPTIVITY_OPTION(h2c_pkt, value) \
611e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 12))
612e3037485SYan-Hsuan Chuang #define SET_ADAPTIVITY_IGI(h2c_pkt, value) \
613e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
614e3037485SYan-Hsuan Chuang #define SET_ADAPTIVITY_L2H(h2c_pkt, value) \
615e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
616e3037485SYan-Hsuan Chuang #define SET_ADAPTIVITY_DENSITY(h2c_pkt, value) \
617e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(7, 0))
618e3037485SYan-Hsuan Chuang
61904b786e0SYan-Hsuan Chuang #define SET_PWR_MODE_SET_MODE(h2c_pkt, value) \
62004b786e0SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(14, 8))
62104b786e0SYan-Hsuan Chuang #define SET_PWR_MODE_SET_RLBM(h2c_pkt, value) \
62204b786e0SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(19, 16))
62304b786e0SYan-Hsuan Chuang #define SET_PWR_MODE_SET_SMART_PS(h2c_pkt, value) \
62404b786e0SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 20))
625e3e400dfSChin-Yen Lee #define SET_PWR_MODE_SET_AWAKE_INTERVAL(h2c_pkt, value) \
626e3e400dfSChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
627e3037485SYan-Hsuan Chuang #define SET_PWR_MODE_SET_PORT_ID(h2c_pkt, value) \
628e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(7, 5))
629e3037485SYan-Hsuan Chuang #define SET_PWR_MODE_SET_PWR_STATE(h2c_pkt, value) \
630e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(15, 8))
631e3037485SYan-Hsuan Chuang #define LPS_PG_INFO_LOC(h2c_pkt, value) \
632e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
633e3037485SYan-Hsuan Chuang #define LPS_PG_DPK_LOC(h2c_pkt, value) \
634e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
635e3037485SYan-Hsuan Chuang #define LPS_PG_SEC_CAM_EN(h2c_pkt, value) \
636e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
637e3037485SYan-Hsuan Chuang #define LPS_PG_PATTERN_CAM_EN(h2c_pkt, value) \
638e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(10))
639e3037485SYan-Hsuan Chuang #define SET_RSSI_INFO_MACID(h2c_pkt, value) \
640e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
641e3037485SYan-Hsuan Chuang #define SET_RSSI_INFO_RSSI(h2c_pkt, value) \
642e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
643e3037485SYan-Hsuan Chuang #define SET_RSSI_INFO_STBC(h2c_pkt, value) \
644e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, BIT(1))
645e3037485SYan-Hsuan Chuang #define SET_RA_INFO_MACID(h2c_pkt, value) \
646e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
647e3037485SYan-Hsuan Chuang #define SET_RA_INFO_RATE_ID(h2c_pkt, value) \
648e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(20, 16))
649e3037485SYan-Hsuan Chuang #define SET_RA_INFO_INIT_RA_LVL(h2c_pkt, value) \
650e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(22, 21))
651e3037485SYan-Hsuan Chuang #define SET_RA_INFO_SGI_EN(h2c_pkt, value) \
652e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(23))
653e3037485SYan-Hsuan Chuang #define SET_RA_INFO_BW_MODE(h2c_pkt, value) \
654e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(25, 24))
655e3037485SYan-Hsuan Chuang #define SET_RA_INFO_LDPC(h2c_pkt, value) \
656e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(26))
657e3037485SYan-Hsuan Chuang #define SET_RA_INFO_NO_UPDATE(h2c_pkt, value) \
658e3037485SYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(27))
6594136214fSYan-Hsuan Chuang #define SET_RA_INFO_VHT_EN(h2c_pkt, value) \
6604136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(29, 28))
6614136214fSYan-Hsuan Chuang #define SET_RA_INFO_DIS_PT(h2c_pkt, value) \
6624136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(30))
6634136214fSYan-Hsuan Chuang #define SET_RA_INFO_RA_MASK0(h2c_pkt, value) \
6644136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(7, 0))
6654136214fSYan-Hsuan Chuang #define SET_RA_INFO_RA_MASK1(h2c_pkt, value) \
6664136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(15, 8))
6674136214fSYan-Hsuan Chuang #define SET_RA_INFO_RA_MASK2(h2c_pkt, value) \
6684136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(23, 16))
6694136214fSYan-Hsuan Chuang #define SET_RA_INFO_RA_MASK3(h2c_pkt, value) \
6704136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(31, 24))
6714136214fSYan-Hsuan Chuang #define SET_QUERY_BT_INFO(h2c_pkt, value) \
6724136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
6734136214fSYan-Hsuan Chuang #define SET_WL_CH_INFO_LINK(h2c_pkt, value) \
6744136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
6754136214fSYan-Hsuan Chuang #define SET_WL_CH_INFO_CHNL(h2c_pkt, value) \
6764136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
6774136214fSYan-Hsuan Chuang #define SET_WL_CH_INFO_BW(h2c_pkt, value) \
6784136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
6794136214fSYan-Hsuan Chuang #define SET_BT_MP_INFO_SEQ(h2c_pkt, value) \
6804136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 12))
6814136214fSYan-Hsuan Chuang #define SET_BT_MP_INFO_OP_CODE(h2c_pkt, value) \
6824136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
6834136214fSYan-Hsuan Chuang #define SET_BT_MP_INFO_PARA1(h2c_pkt, value) \
6844136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
6854136214fSYan-Hsuan Chuang #define SET_BT_MP_INFO_PARA2(h2c_pkt, value) \
6864136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(7, 0))
6874136214fSYan-Hsuan Chuang #define SET_BT_MP_INFO_PARA3(h2c_pkt, value) \
6884136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(15, 8))
6894136214fSYan-Hsuan Chuang #define SET_BT_TX_POWER_INDEX(h2c_pkt, value) \
6904136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
6914136214fSYan-Hsuan Chuang #define SET_IGNORE_WLAN_ACTION_EN(h2c_pkt, value) \
6924136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
6934136214fSYan-Hsuan Chuang #define SET_COEX_TDMA_TYPE_PARA1(h2c_pkt, value) \
6944136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
6954136214fSYan-Hsuan Chuang #define SET_COEX_TDMA_TYPE_PARA2(h2c_pkt, value) \
6964136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
6974136214fSYan-Hsuan Chuang #define SET_COEX_TDMA_TYPE_PARA3(h2c_pkt, value) \
6984136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
6994136214fSYan-Hsuan Chuang #define SET_COEX_TDMA_TYPE_PARA4(h2c_pkt, value) \
7004136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(7, 0))
7014136214fSYan-Hsuan Chuang #define SET_COEX_TDMA_TYPE_PARA5(h2c_pkt, value) \
7024136214fSYan-Hsuan Chuang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(15, 8))
703e3037485SYan-Hsuan Chuang #define SET_BT_WIFI_CONTROL_OP_CODE(h2c_pkt, value) \
704fc3c66d3SChing-Te Ku le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
705fc3c66d3SChing-Te Ku #define SET_BT_WIFI_CONTROL_DATA1(h2c_pkt, value) \
706fc3c66d3SChing-Te Ku le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
707fc3c66d3SChing-Te Ku #define SET_BT_WIFI_CONTROL_DATA2(h2c_pkt, value) \
708fc3c66d3SChing-Te Ku le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
70944bc17f7SChin-Yen Lee #define SET_BT_WIFI_CONTROL_DATA3(h2c_pkt, value) \
71044bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(7, 0))
71144bc17f7SChin-Yen Lee #define SET_BT_WIFI_CONTROL_DATA4(h2c_pkt, value) \
71244bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(15, 8))
71344bc17f7SChin-Yen Lee #define SET_BT_WIFI_CONTROL_DATA5(h2c_pkt, value) \
71444bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(23, 16))
71544bc17f7SChin-Yen Lee
71644bc17f7SChin-Yen Lee #define SET_COEX_QUERY_HID_INFO_SUBID(h2c_pkt, value) \
71744bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
71844bc17f7SChin-Yen Lee #define SET_COEX_QUERY_HID_INFO_DATA1(h2c_pkt, value) \
71944bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
72044bc17f7SChin-Yen Lee
72144bc17f7SChin-Yen Lee #define SET_KEEP_ALIVE_ENABLE(h2c_pkt, value) \
72244bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
72344bc17f7SChin-Yen Lee #define SET_KEEP_ALIVE_ADOPT(h2c_pkt, value) \
72444bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(9))
72544bc17f7SChin-Yen Lee #define SET_KEEP_ALIVE_PKT_TYPE(h2c_pkt, value) \
72644bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(10))
72744bc17f7SChin-Yen Lee #define SET_KEEP_ALIVE_CHECK_PERIOD(h2c_pkt, value) \
72844bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
729e3e400dfSChin-Yen Lee
730e3e400dfSChin-Yen Lee #define SET_DISCONNECT_DECISION_ENABLE(h2c_pkt, value) \
73144bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
73244bc17f7SChin-Yen Lee #define SET_DISCONNECT_DECISION_ADOPT(h2c_pkt, value) \
73344bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(9))
73444bc17f7SChin-Yen Lee #define SET_DISCONNECT_DECISION_CHECK_PERIOD(h2c_pkt, value) \
73544bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
73644bc17f7SChin-Yen Lee #define SET_DISCONNECT_DECISION_TRY_PKT_NUM(h2c_pkt, value) \
73744bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
73844bc17f7SChin-Yen Lee
73944bc17f7SChin-Yen Lee #define SET_WOWLAN_FUNC_ENABLE(h2c_pkt, value) \
74044bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
74144bc17f7SChin-Yen Lee #define SET_WOWLAN_PATTERN_MATCH_ENABLE(h2c_pkt, value) \
74244bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(9))
74344bc17f7SChin-Yen Lee #define SET_WOWLAN_MAGIC_PKT_ENABLE(h2c_pkt, value) \
74444bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(10))
74544bc17f7SChin-Yen Lee #define SET_WOWLAN_UNICAST_PKT_ENABLE(h2c_pkt, value) \
74644bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(11))
74744bc17f7SChin-Yen Lee #define SET_WOWLAN_REKEY_WAKEUP_ENABLE(h2c_pkt, value) \
74844bc17f7SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(14))
74944bc17f7SChin-Yen Lee #define SET_WOWLAN_DEAUTH_WAKEUP_ENABLE(h2c_pkt, value) \
750b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(15))
751b6c12908SChin-Yen Lee
752b6c12908SChin-Yen Lee #define SET_REMOTE_WAKECTRL_ENABLE(h2c_pkt, value) \
753b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
754b6c12908SChin-Yen Lee #define SET_REMOTE_WAKE_CTRL_NLO_OFFLOAD_EN(h2c_pkt, value) \
755b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(12))
756b6c12908SChin-Yen Lee
757b6c12908SChin-Yen Lee #define SET_AOAC_GLOBAL_INFO_PAIRWISE_ENC_ALG(h2c_pkt, value) \
758b6c12908SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
7597c57d3dcSPing-Ke Shih #define SET_AOAC_GLOBAL_INFO_GROUP_ENC_ALG(h2c_pkt, value) \
7607c57d3dcSPing-Ke Shih le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
7617c57d3dcSPing-Ke Shih
762714f71f9STzu-En Huang #define SET_NLO_FUN_EN(h2c_pkt, value) \
763714f71f9STzu-En Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
764714f71f9STzu-En Huang #define SET_NLO_PS_32K(h2c_pkt, value) \
765714f71f9STzu-En Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(9))
766714f71f9STzu-En Huang #define SET_NLO_IGNORE_SECURITY(h2c_pkt, value) \
767714f71f9STzu-En Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(10))
768714f71f9STzu-En Huang #define SET_NLO_LOC_NLO_INFO(h2c_pkt, value) \
769714f71f9STzu-En Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
770714f71f9STzu-En Huang
771714f71f9STzu-En Huang #define SET_RECOVER_BT_DEV_EN(h2c_pkt, value) \
772714f71f9STzu-En Huang le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
773714f71f9STzu-En Huang
774714f71f9STzu-En Huang #define GET_FW_DUMP_LEN(_header) \
775714f71f9STzu-En Huang le32_get_bits(*((__le32 *)(_header) + 0x00), GENMASK(15, 0))
776056b239fSGuo-Feng Fan #define GET_FW_DUMP_SEQ(_header) \
777056b239fSGuo-Feng Fan le32_get_bits(*((__le32 *)(_header) + 0x00), GENMASK(22, 16))
778056b239fSGuo-Feng Fan #define GET_FW_DUMP_MORE(_header) \
779e3037485SYan-Hsuan Chuang le32_get_bits(*((__le32 *)(_header) + 0x00), BIT(23))
780e3037485SYan-Hsuan Chuang #define GET_FW_DUMP_VERSION(_header) \
781e3037485SYan-Hsuan Chuang le32_get_bits(*((__le32 *)(_header) + 0x00), GENMASK(31, 24))
782e3037485SYan-Hsuan Chuang #define GET_FW_DUMP_TLV_TYPE(_header) \
783e3037485SYan-Hsuan Chuang le32_get_bits(*((__le32 *)(_header) + 0x01), GENMASK(15, 0))
784e3037485SYan-Hsuan Chuang #define GET_FW_DUMP_TLV_LEN(_header) \
785e3037485SYan-Hsuan Chuang le32_get_bits(*((__le32 *)(_header) + 0x01), GENMASK(31, 16))
786e3037485SYan-Hsuan Chuang #define GET_FW_DUMP_TLV_VAL(_header) \
7879a711831SChin-Yen Lee le32_get_bits(*((__le32 *)(_header) + 0x02), GENMASK(31, 0))
7889a711831SChin-Yen Lee
7899a711831SChin-Yen Lee #define RFK_SET_INFORM_START(h2c_pkt, value) \
7909a711831SChin-Yen Lee le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
get_c2h_from_skb(struct sk_buff * skb)7919a711831SChin-Yen Lee static inline struct rtw_c2h_cmd *get_c2h_from_skb(struct sk_buff *skb)
7929a711831SChin-Yen Lee {
793d2eb7cb9SPo-Hao Huang u32 pkt_offset;
794d2eb7cb9SPo-Hao Huang
795d2eb7cb9SPo-Hao Huang pkt_offset = *((u32 *)skb->cb);
796d2eb7cb9SPo-Hao Huang return (struct rtw_c2h_cmd *)(skb->data + pkt_offset);
797d2eb7cb9SPo-Hao Huang }
798d2eb7cb9SPo-Hao Huang
rtw_fw_feature_check(struct rtw_fw_state * fw,enum rtw_fw_feature feature)7990d762f03SYan-Hsuan Chuang static inline bool rtw_fw_feature_check(struct rtw_fw_state *fw,
8000d762f03SYan-Hsuan Chuang enum rtw_fw_feature feature)
801e3037485SYan-Hsuan Chuang {
802e3037485SYan-Hsuan Chuang return !!(fw->feature & feature);
803e3037485SYan-Hsuan Chuang }
804e3037485SYan-Hsuan Chuang
rtw_fw_feature_ext_check(struct rtw_fw_state * fw,enum rtw_fw_feature_ext feature)805e3037485SYan-Hsuan Chuang static inline bool rtw_fw_feature_ext_check(struct rtw_fw_state *fw,
806056b239fSGuo-Feng Fan enum rtw_fw_feature_ext feature)
807e3037485SYan-Hsuan Chuang {
80804b786e0SYan-Hsuan Chuang return !!(fw->feature_ext & feature);
8094136214fSYan-Hsuan Chuang }
8104136214fSYan-Hsuan Chuang
8114136214fSYan-Hsuan Chuang void rtw_fw_c2h_cmd_rx_irqsafe(struct rtw_dev *rtwdev, u32 pkt_offset,
8124136214fSYan-Hsuan Chuang struct sk_buff *skb);
8134136214fSYan-Hsuan Chuang void rtw_fw_c2h_cmd_handle(struct rtw_dev *rtwdev, struct sk_buff *skb);
8144136214fSYan-Hsuan Chuang void rtw_fw_send_general_info(struct rtw_dev *rtwdev);
8154136214fSYan-Hsuan Chuang void rtw_fw_send_phydm_info(struct rtw_dev *rtwdev);
8164136214fSYan-Hsuan Chuang void rtw_fw_default_port(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif);
817fc3c66d3SChing-Te Ku
818fc3c66d3SChing-Te Ku void rtw_fw_do_iqk(struct rtw_dev *rtwdev, struct rtw_iqk_para *para);
8194136214fSYan-Hsuan Chuang void rtw_fw_inform_rfk_status(struct rtw_dev *rtwdev, bool start);
820e3037485SYan-Hsuan Chuang void rtw_fw_set_pwr_mode(struct rtw_dev *rtwdev);
821c1edc864SPo-Hao Huang void rtw_fw_set_pg_info(struct rtw_dev *rtwdev);
822c1edc864SPo-Hao Huang void rtw_fw_query_bt_info(struct rtw_dev *rtwdev);
823e3037485SYan-Hsuan Chuang void rtw_fw_wl_ch_info(struct rtw_dev *rtwdev, u8 link, u8 ch, u8 bw);
824ec7480edSPo-Hao Huang void rtw_fw_query_bt_mp_info(struct rtw_dev *rtwdev,
825cd96e22bSPo-Hao Huang struct rtw_coex_info_req *req);
826cd96e22bSPo-Hao Huang void rtw_fw_force_bt_tx_power(struct rtw_dev *rtwdev, u8 bt_pwr_dec_lvl);
827e3037485SYan-Hsuan Chuang void rtw_fw_bt_ignore_wlan_action(struct rtw_dev *rtwdev, bool enable);
828e3037485SYan-Hsuan Chuang void rtw_fw_coex_tdma_type(struct rtw_dev *rtwdev,
829895c096dSYan-Hsuan Chuang u8 para1, u8 para2, u8 para3, u8 para4, u8 para5);
830895c096dSYan-Hsuan Chuang void rtw_fw_coex_query_hid_info(struct rtw_dev *rtwdev, u8 sub_id, u8 data);
831895c096dSYan-Hsuan Chuang
832895c096dSYan-Hsuan Chuang void rtw_fw_bt_wifi_control(struct rtw_dev *rtwdev, u8 op_code, u8 *data);
833895c096dSYan-Hsuan Chuang void rtw_fw_send_rssi_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si);
834895c096dSYan-Hsuan Chuang void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
835895c096dSYan-Hsuan Chuang bool reset_ra_mask);
836895c096dSYan-Hsuan Chuang void rtw_fw_media_status_report(struct rtw_dev *rtwdev, u8 mac_id, bool conn);
837895c096dSYan-Hsuan Chuang void rtw_fw_update_wl_phy_info(struct rtw_dev *rtwdev);
8387711fe71SPing-Ke Shih void rtw_fw_beacon_filter_config(struct rtw_dev *rtwdev, bool connect,
839e3037485SYan-Hsuan Chuang struct ieee80211_vif *vif);
840e3037485SYan-Hsuan Chuang int rtw_fw_write_data_rsvd_page(struct rtw_dev *rtwdev, u16 pg_addr,
841e3037485SYan-Hsuan Chuang u8 *buf, u32 size);
84244bc17f7SChin-Yen Lee void rtw_remove_rsvd_page(struct rtw_dev *rtwdev,
84344bc17f7SChin-Yen Lee struct rtw_vif *rtwvif);
84444bc17f7SChin-Yen Lee void rtw_add_rsvd_page_bcn(struct rtw_dev *rtwdev,
84544bc17f7SChin-Yen Lee struct rtw_vif *rtwvif);
84644bc17f7SChin-Yen Lee void rtw_add_rsvd_page_pno(struct rtw_dev *rtwdev,
84744bc17f7SChin-Yen Lee struct rtw_vif *rtwvif);
84844bc17f7SChin-Yen Lee void rtw_add_rsvd_page_sta(struct rtw_dev *rtwdev,
84944bc17f7SChin-Yen Lee struct rtw_vif *rtwvif);
850b6c12908SChin-Yen Lee int rtw_fw_download_rsvd_page(struct rtw_dev *rtwdev);
8517c57d3dcSPing-Ke Shih void rtw_fw_update_beacon_work(struct work_struct *work);
852b6c12908SChin-Yen Lee void rtw_send_rsvd_page_h2c(struct rtw_dev *rtwdev);
853b6c12908SChin-Yen Lee int rtw_dump_drv_rsvd_page(struct rtw_dev *rtwdev,
854b6c12908SChin-Yen Lee u32 offset, u32 size, u32 *buf);
855c376c1fcSTzu-En Huang void rtw_fw_set_remote_wake_ctrl_cmd(struct rtw_dev *rtwdev, bool enable);
8565c831644STzu-En Huang void rtw_fw_set_wowlan_ctrl_cmd(struct rtw_dev *rtwdev, bool enable);
8570fbc2f0fSTzu-En Huang void rtw_fw_set_keep_alive_cmd(struct rtw_dev *rtwdev, bool enable);
8580fbc2f0fSTzu-En Huang void rtw_fw_set_disconnect_decision_cmd(struct rtw_dev *rtwdev, bool enable);
859a853d234SChin-Yen Lee void rtw_fw_set_aoac_global_info_cmd(struct rtw_dev *rtwdev,
860fe7bc23aSChin-Yen Lee u8 pairwise_key_enc,
86168c53914SChih-Kang Chang u8 group_key_enc);
86279ba1062SChih-Kang Chang
86310d162b2SPo-Hao Huang void rtw_fw_set_nlo_info(struct rtw_dev *rtwdev, bool enable);
86410d162b2SPo-Hao Huang void rtw_fw_set_recover_bt_device(struct rtw_dev *rtwdev);
86510d162b2SPo-Hao Huang void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev,
86610d162b2SPo-Hao Huang struct cfg80211_ssid *ssid);
86710d162b2SPo-Hao Huang void rtw_fw_channel_switch(struct rtw_dev *rtwdev, bool enable);
86810d162b2SPo-Hao Huang void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c);
86910d162b2SPo-Hao Huang void rtw_fw_c2h_cmd_isr(struct rtw_dev *rtwdev);
87010d162b2SPo-Hao Huang int rtw_fw_dump_fifo(struct rtw_dev *rtwdev, u8 fifo_sel, u32 addr, u32 size,
871*a1b8015dSPo-Hao Huang u32 *buffer);
872e3037485SYan-Hsuan Chuang void rtw_fw_scan_notify(struct rtw_dev *rtwdev, bool start);
873 void rtw_fw_adaptivity(struct rtw_dev *rtwdev);
874 void rtw_store_op_chan(struct rtw_dev *rtwdev, bool backup);
875 void rtw_clear_op_chan(struct rtw_dev *rtwdev);
876 void rtw_hw_scan_start(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
877 struct ieee80211_scan_request *req);
878 void rtw_hw_scan_complete(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
879 bool aborted);
880 int rtw_hw_scan_offload(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
881 bool enable);
882 void rtw_hw_scan_status_report(struct rtw_dev *rtwdev, struct sk_buff *skb);
883 void rtw_hw_scan_chan_switch(struct rtw_dev *rtwdev, struct sk_buff *skb);
884 void rtw_hw_scan_abort(struct rtw_dev *rtwdev);
885 #endif
886