1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2021 Intel Corporation
4  */
5 
6 #ifndef __sap_h__
7 #define __sap_h__
8 
9 #include "mei/iwl-mei.h"
10 
11 /**
12  * DOC: Introduction
13  *
14  * SAP is the protocol used by the Intel Wireless driver (iwlwifi)
15  * and the wireless driver implemented in the CSME firmware.
16  * It allows to do several things:
17  * 1) Decide who is the owner of the device: CSME or the host
18  * 2) When the host is the owner of the device, CSME can still
19  * send and receive packets through iwlwifi.
20  *
21  * The protocol uses the ME interface (mei driver) to send
22  * messages to the CSME firmware. Those messages have a header
23  * &struct iwl_sap_me_msg_hdr and this header is followed
24  * by a payload.
25  *
26  * Since this messaging system cannot support high amounts of
27  * traffic, iwlwifi and the CSME firmware's WLAN driver have an
28  * addtional communication pipe to exchange information. The body
29  * of the message is copied to a shared area and the message that
30  * goes over the ME interface just signals the other side
31  * that a new message is waiting in the shared area. The ME
32  * interface is used only for signaling and not to transfer
33  * the payload.
34  *
35  * This shared area of memory is DMA'able mapped to be
36  * writable by both the CSME firmware and iwlwifi. It is
37  * mapped to address space of the device that controls the ME
38  * interface's DMA engine. Any data that iwlwifi needs to
39  * send to the CSME firmware needs to be copied to there.
40  */
41 
42 /**
43  * DOC: Initial Handshake
44  *
45  * Once we get a link to the CMSE's WLAN driver we start the handshake
46  * to establish the shared memory that will allow the communication between
47  * the CSME's WLAN driver and the host.
48  *
49  * 1) Host sends %SAP_ME_MSG_START message with the physical address
50  * of the shared area.
51  * 2) CSME replies with %SAP_ME_MSG_START_OK which includes the versions
52  * protocol versions supported by CSME.
53  */
54 
55 /**
56  * DOC: Host and driver state messages
57  *
58  * In order to let CSME konw about the host state and the host driver state,
59  * the host sends messages that let CSME know about the host's state.
60  * When the host driver is loaded, the host sends %SAP_MSG_NOTIF_WIFIDR_UP.
61  * When the host driver is unloaded, the host sends %SAP_MSG_NOTIF_WIFIDR_DOWN.
62  * When the iwlmei is unloaded, %SAP_MSG_NOTIF_HOST_GOES_DOWN is sent to let
63  * CSME know not to access the shared memory anymore since it'll be freed.
64  *
65  * CSME will reply to SAP_MSG_NOTIF_WIFIDR_UP by
66  * %SAP_MSG_NOTIF_AMT_STATE to let the host driver whether CSME can use the
67  * WiFi device or not followed by %SAP_MSG_NOTIF_CSME_CONN_STATUS to inform
68  * the host driver on the connection state of CSME.
69  *
70  * When host is associated to an AP, it must send %SAP_MSG_NOTIF_HOST_LINK_UP
71  * and when it disconnect from the AP, it must send
72  * %SAP_MSG_NOTIF_HOST_LINK_DOWN.
73  */
74 
75 /**
76  * DOC: Ownership
77  *
78  * The device can be controlled either by the CSME firmware or
79  * by the host driver: iwlwifi. There is a negotiaion between
80  * those two entities to determine who controls (or owns) the
81  * device. Since the CSME can control the device even when the
82  * OS is not working or even missing, the CSME can request the
83  * device if it comes to the conclusion that the OS's host driver
84  * is not operational. This is why the host driver needs to
85  * signal CSME that it is up and running. If the driver is
86  * unloaded, it'll signal CSME that it is going down so that
87  * CSME can take ownership.
88  */
89 
90 /**
91  * DOC: Ownership transfer
92  *
93  * When the host driver needs the device, it'll send the
94  * %SAP_MSG_NOTIF_HOST_ASKS_FOR_NIC_OWNERSHIP that will be replied by
95  * %SAP_MSG_NOTIF_CSME_REPLY_TO_HOST_OWNERSHIP_REQ which will let the
96  * host know whether the ownership is granted or no. If the ownership is
97  * granted, the hosts sends %SAP_MSG_NOTIF_HOST_OWNERSHIP_CONFIRMED.
98  *
99  * When CSME requests ownership, it'll send the
100  * %SAP_MSG_NOTIF_CSME_TAKING_OWNERSHIP and give some time to host to stop
101  * accessing the device. The host needs to send
102  * %SAP_MSG_NOTIF_CSME_OWNERSHIP_CONFIRMED to confirm that it won't access
103  * the device anymore. If the host failed to send this message fast enough,
104  * CSME will take ownership on the device anyway.
105  * When CSME is willing to release the ownership, it'll send
106  * %SAP_MSG_NOTIF_CSME_CAN_RELEASE_OWNERSHIP.
107  */
108 
109 /**
110  * DOC: Data messages
111  *
112  * Data messages must be sent and receives on a separate queue in the shared
113  * memory. Almost all the data messages use the %SAP_MSG_DATA_PACKET for both
114  * packets sent by CSME to the host to be sent to the AP or for packets
115  * received from the AP and sent by the host to CSME.
116  * CSME sends filters to the host to let the host what inbound packets it must
117  * send to CSME. Those filters are received by the host as a
118  * %SAP_MSG_NOTIF_CSME_FILTERS command.
119  * The only outbound packets that must be sent to CSME are the DHCP packets.
120  * Those packets must use the %SAP_MSG_CB_DATA_PACKET message.
121  */
122 
123 /**
124  * enum iwl_sap_me_msg_id - the ID of the ME message
125  * @SAP_ME_MSG_START: See &struct iwl_sap_me_msg_start.
126  * @SAP_ME_MSG_START_OK: See &struct iwl_sap_me_msg_start_ok.
127  * @SAP_ME_MSG_CHECK_SHARED_AREA: This message has no payload.
128  */
129 enum iwl_sap_me_msg_id {
130 	SAP_ME_MSG_START	= 1,
131 	SAP_ME_MSG_START_OK,
132 	SAP_ME_MSG_CHECK_SHARED_AREA,
133 };
134 
135 /**
136  * struct iwl_sap_me_msg_hdr - the header of the ME message
137  * @type: the type of the message, see &enum iwl_sap_me_msg_id.
138  * @seq_num: a sequence number used for debug only.
139  * @len: the length of the mssage.
140  */
141 struct iwl_sap_me_msg_hdr {
142 	__le32 type;
143 	__le32 seq_num;
144 	__le32 len;
145 } __packed;
146 
147 /**
148  * struct iwl_sap_me_msg_start - used for the %SAP_ME_MSG_START message
149  * @hdr: See &struct iwl_sap_me_msg_hdr.
150  * @shared_mem: physical address of SAP shared memory area.
151  * @init_data_seq_num: seq_num of the first data packet HOST -> CSME.
152  * @init_notif_seq_num: seq_num of the first notification HOST -> CSME.
153  * @supported_versions: The host sends to the CSME a zero-terminated array
154  * of versions its supports.
155  *
156  * This message is sent by the host to CSME and will responded by the
157  * %SAP_ME_MSG_START_OK message.
158  */
159 struct iwl_sap_me_msg_start {
160 	struct iwl_sap_me_msg_hdr hdr;
161 	__le64 shared_mem;
162 	__le16 init_data_seq_num;
163 	__le16 init_notif_seq_num;
164 	u8 supported_versions[64];
165 } __packed;
166 
167 /**
168  * struct iwl_sap_me_msg_start_ok - used for the %SAP_ME_MSG_START_OK
169  * @hdr: See &struct iwl_sap_me_msg_hdr
170  * @init_data_seq_num: Not used.
171  * @init_notif_seq_num: Not used
172  * @supported_version: The version that will be used.
173  * @reserved: For alignment.
174  *
175  * This message is sent by CSME to the host in response to the
176  * %SAP_ME_MSG_START message.
177  */
178 struct iwl_sap_me_msg_start_ok {
179 	struct iwl_sap_me_msg_hdr hdr;
180 	__le16 init_data_seq_num;
181 	__le16 init_notif_seq_num;
182 	u8 supported_version;
183 	u8 reserved[3];
184 } __packed;
185 
186 /**
187  * enum iwl_sap_msg - SAP messages
188  * @SAP_MSG_NOTIF_BOTH_WAYS_MIN: Not used.
189  * @SAP_MSG_NOTIF_PING: No payload. Solicitate a response message (check-alive).
190  * @SAP_MSG_NOTIF_PONG: No payload. The response message.
191  * @SAP_MSG_NOTIF_BOTH_WAYS_MAX: Not used.
192  *
193  * @SAP_MSG_NOTIF_FROM_CSME_MIN: Not used.
194  * @SAP_MSG_NOTIF_CSME_FILTERS: TODO
195  * @SAP_MSG_NOTIF_AMT_STATE: Payload is a DW. Any non-zero value means
196  *	that CSME is enabled.
197  * @SAP_MSG_NOTIF_CSME_REPLY_TO_HOST_OWNERSHIP_REQ: Payload is a DW. 0 means
198  *	the host will not get ownership. Any other value means the host is
199  *	the owner.
200  * @SAP_MSG_NOTIF_CSME_TAKING_OWNERSHIP: No payload.
201  * @SAP_MSG_NOTIF_TRIGGER_IP_REFRESH: No payload.
202  * @SAP_MSG_NOTIF_CSME_CAN_RELEASE_OWNERSHIP: No payload.
203  * @SAP_MSG_NOTIF_NIC_OWNER: Payload is a DW. See &enum iwl_sap_nic_owner.
204  * @SAP_MSG_NOTIF_CSME_CONN_STATUS: See &struct iwl_sap_notif_conn_status.
205  * @SAP_MSG_NOTIF_NVM: See &struct iwl_sap_nvm.
206  * @SAP_MSG_NOTIF_FROM_CSME_MAX: Not used.
207  *
208  * @SAP_MSG_NOTIF_FROM_HOST_MIN: Not used.
209  * @SAP_MSG_NOTIF_BAND_SELECTION: TODO
210  * @SAP_MSG_NOTIF_RADIO_STATE: Payload is a DW.
211  *	See &enum iwl_sap_radio_state_bitmap.
212  * @SAP_MSG_NOTIF_NIC_INFO: See &struct iwl_sap_notif_host_nic_info.
213  * @SAP_MSG_NOTIF_HOST_ASKS_FOR_NIC_OWNERSHIP: No payload.
214  * @SAP_MSG_NOTIF_HOST_SUSPENDS: Payload is a DW. Bitmap described in
215  *	&enum iwl_sap_notif_host_suspends_bitmap.
216  * @SAP_MSG_NOTIF_HOST_RESUMES: Payload is a DW. 0 or 1. 1 says that
217  *	the CSME should re-initialize the init control block.
218  * @SAP_MSG_NOTIF_HOST_GOES_DOWN: No payload.
219  * @SAP_MSG_NOTIF_CSME_OWNERSHIP_CONFIRMED: No payload.
220  * @SAP_MSG_NOTIF_COUNTRY_CODE: See &struct iwl_sap_notif_country_code.
221  * @SAP_MSG_NOTIF_HOST_LINK_UP: See &struct iwl_sap_notif_host_link_up.
222  * @SAP_MSG_NOTIF_HOST_LINK_DOWN: See &struct iwl_sap_notif_host_link_down.
223  * @SAP_MSG_NOTIF_WHO_OWNS_NIC: No payload.
224  * @SAP_MSG_NOTIF_WIFIDR_DOWN: No payload.
225  * @SAP_MSG_NOTIF_WIFIDR_UP: No payload.
226  * @SAP_MSG_NOTIF_HOST_OWNERSHIP_CONFIRMED: No payload.
227  * @SAP_MSG_NOTIF_SAR_LIMITS: See &struct iwl_sap_notif_sar_limits.
228  * @SAP_MSG_NOTIF_GET_NVM: No payload. Triggers %SAP_MSG_NOTIF_NVM.
229  * @SAP_MSG_NOTIF_FROM_HOST_MAX: Not used.
230  *
231  * @SAP_MSG_DATA_MIN: Not used.
232  * @SAP_MSG_DATA_PACKET: Packets that passed the filters defined by
233  *	%SAP_MSG_NOTIF_CSME_FILTERS. The payload is &struct iwl_sap_hdr with
234  *	the payload of the packet immediately afterwards.
235  * @SAP_MSG_CB_DATA_PACKET: Indicates to CSME that we transmitted a specific
236  *	packet. Used only for DHCP transmitted packets. See
237  *	&struct iwl_sap_cb_data.
238  * @SAP_MSG_DATA_MAX: Not used.
239  */
240 enum iwl_sap_msg {
241 	SAP_MSG_NOTIF_BOTH_WAYS_MIN			= 0,
242 	SAP_MSG_NOTIF_PING				= 1,
243 	SAP_MSG_NOTIF_PONG				= 2,
244 	SAP_MSG_NOTIF_BOTH_WAYS_MAX,
245 
246 	SAP_MSG_NOTIF_FROM_CSME_MIN			= 500,
247 	SAP_MSG_NOTIF_CSME_FILTERS			= SAP_MSG_NOTIF_FROM_CSME_MIN,
248 	/* 501 is deprecated */
249 	SAP_MSG_NOTIF_AMT_STATE				= 502,
250 	SAP_MSG_NOTIF_CSME_REPLY_TO_HOST_OWNERSHIP_REQ	= 503,
251 	SAP_MSG_NOTIF_CSME_TAKING_OWNERSHIP		= 504,
252 	SAP_MSG_NOTIF_TRIGGER_IP_REFRESH		= 505,
253 	SAP_MSG_NOTIF_CSME_CAN_RELEASE_OWNERSHIP	= 506,
254 	/* 507 is deprecated */
255 	/* 508 is deprecated */
256 	/* 509 is deprecated */
257 	/* 510 is deprecated */
258 	SAP_MSG_NOTIF_NIC_OWNER				= 511,
259 	SAP_MSG_NOTIF_CSME_CONN_STATUS			= 512,
260 	SAP_MSG_NOTIF_NVM				= 513,
261 	SAP_MSG_NOTIF_FROM_CSME_MAX,
262 
263 	SAP_MSG_NOTIF_FROM_HOST_MIN			= 1000,
264 	SAP_MSG_NOTIF_BAND_SELECTION			= SAP_MSG_NOTIF_FROM_HOST_MIN,
265 	SAP_MSG_NOTIF_RADIO_STATE			= 1001,
266 	SAP_MSG_NOTIF_NIC_INFO				= 1002,
267 	SAP_MSG_NOTIF_HOST_ASKS_FOR_NIC_OWNERSHIP	= 1003,
268 	SAP_MSG_NOTIF_HOST_SUSPENDS			= 1004,
269 	SAP_MSG_NOTIF_HOST_RESUMES			= 1005,
270 	SAP_MSG_NOTIF_HOST_GOES_DOWN			= 1006,
271 	SAP_MSG_NOTIF_CSME_OWNERSHIP_CONFIRMED		= 1007,
272 	SAP_MSG_NOTIF_COUNTRY_CODE			= 1008,
273 	SAP_MSG_NOTIF_HOST_LINK_UP			= 1009,
274 	SAP_MSG_NOTIF_HOST_LINK_DOWN			= 1010,
275 	SAP_MSG_NOTIF_WHO_OWNS_NIC			= 1011,
276 	SAP_MSG_NOTIF_WIFIDR_DOWN			= 1012,
277 	SAP_MSG_NOTIF_WIFIDR_UP				= 1013,
278 	/* 1014 is deprecated */
279 	SAP_MSG_NOTIF_HOST_OWNERSHIP_CONFIRMED		= 1015,
280 	SAP_MSG_NOTIF_SAR_LIMITS			= 1016,
281 	SAP_MSG_NOTIF_GET_NVM				= 1017,
282 	SAP_MSG_NOTIF_FROM_HOST_MAX,
283 
284 	SAP_MSG_DATA_MIN				= 2000,
285 	SAP_MSG_DATA_PACKET				= SAP_MSG_DATA_MIN,
286 	SAP_MSG_CB_DATA_PACKET				= 2001,
287 	SAP_MSG_DATA_MAX,
288 };
289 
290 /**
291  * struct iwl_sap_hdr - prefixes any SAP message
292  * @type: See &enum iwl_sap_msg.
293  * @len: The length of the message (header not included).
294  * @seq_num: For debug.
295  * @payload: The payload of the message.
296  */
297 struct iwl_sap_hdr {
298 	__le16 type;
299 	__le16 len;
300 	__le32 seq_num;
301 	u8 payload[0];
302 };
303 
304 /**
305  * struct iwl_sap_msg_dw - suits any DW long SAP message
306  * @hdr: The SAP header
307  * @val: The value of the DW.
308  */
309 struct iwl_sap_msg_dw {
310 	struct iwl_sap_hdr hdr;
311 	__le32 val;
312 };
313 
314 /**
315  * enum iwl_sap_nic_owner - used by %SAP_MSG_NOTIF_NIC_OWNER
316  * @SAP_NIC_OWNER_UNKNOWN: Not used.
317  * @SAP_NIC_OWNER_HOST: The host owns the NIC.
318  * @SAP_NIC_OWNER_ME: CSME owns the NIC.
319  */
320 enum iwl_sap_nic_owner {
321 	SAP_NIC_OWNER_UNKNOWN,
322 	SAP_NIC_OWNER_HOST,
323 	SAP_NIC_OWNER_ME,
324 };
325 
326 enum iwl_sap_wifi_auth_type {
327 	SAP_WIFI_AUTH_TYPE_OPEN		= IWL_MEI_AKM_AUTH_OPEN,
328 	SAP_WIFI_AUTH_TYPE_RSNA		= IWL_MEI_AKM_AUTH_RSNA,
329 	SAP_WIFI_AUTH_TYPE_RSNA_PSK	= IWL_MEI_AKM_AUTH_RSNA_PSK,
330 	SAP_WIFI_AUTH_TYPE_SAE		= IWL_MEI_AKM_AUTH_SAE,
331 	SAP_WIFI_AUTH_TYPE_MAX,
332 };
333 
334 /**
335  * enum iwl_sap_wifi_cipher_alg
336  * @SAP_WIFI_CIPHER_ALG_NONE: TBD
337  * @SAP_WIFI_CIPHER_ALG_CCMP: TBD
338  * @SAP_WIFI_CIPHER_ALG_GCMP: TBD
339  * @SAP_WIFI_CIPHER_ALG_GCMP_256: TBD
340  */
341 enum iwl_sap_wifi_cipher_alg {
342 	SAP_WIFI_CIPHER_ALG_NONE	= IWL_MEI_CIPHER_NONE,
343 	SAP_WIFI_CIPHER_ALG_CCMP	= IWL_MEI_CIPHER_CCMP,
344 	SAP_WIFI_CIPHER_ALG_GCMP	= IWL_MEI_CIPHER_GCMP,
345 	SAP_WIFI_CIPHER_ALG_GCMP_256	= IWL_MEI_CIPHER_GCMP_256,
346 };
347 
348 /**
349  * struct iwl_sap_notif_connection_info - nested in other structures
350  * @ssid_len: The length of the SSID.
351  * @ssid: The SSID.
352  * @auth_mode: The authentication mode. See &enum iwl_sap_wifi_auth_type.
353  * @pairwise_cipher: The cipher used for unicast packets.
354  *	See &enum iwl_sap_wifi_cipher_alg.
355  * @channel: The channel on which we are associated.
356  * @band: The band on which we are associated.
357  * @reserved: For alignment.
358  * @bssid: The BSSID.
359  * @reserved1: For alignment.
360  */
361 struct iwl_sap_notif_connection_info {
362 	__le32 ssid_len;
363 	u8 ssid[32];
364 	__le32 auth_mode;
365 	__le32 pairwise_cipher;
366 	u8 channel;
367 	u8 band;
368 	__le16 reserved;
369 	u8 bssid[6];
370 	__le16 reserved1;
371 } __packed;
372 
373 /**
374  * enum iwl_sap_scan_request - for the scan_request field
375  * @SCAN_REQUEST_FILTERING: Filtering is requested.
376  * @SCAN_REQUEST_FAST: Fast scan is requested.
377  */
378 enum iwl_sap_scan_request {
379 	SCAN_REQUEST_FILTERING	= 1 << 0,
380 	SCAN_REQUEST_FAST	= 1 << 1,
381 };
382 
383 /**
384  * struct iwl_sap_notif_conn_status - payload of %SAP_MSG_NOTIF_CSME_CONN_STATUS
385  * @hdr: The SAP header
386  * @link_prot_state: Non-zero if link protection is active.
387  * @scan_request: See &enum iwl_sap_scan_request.
388  * @conn_info: Information about the connection.
389  */
390 struct iwl_sap_notif_conn_status {
391 	struct iwl_sap_hdr hdr;
392 	__le32 link_prot_state;
393 	__le32 scan_request;
394 	struct iwl_sap_notif_connection_info conn_info;
395 } __packed;
396 
397 /**
398  * enum iwl_sap_radio_state_bitmap - used for %SAP_MSG_NOTIF_RADIO_STATE
399  * @SAP_SW_RFKILL_DEASSERTED: If set, SW RfKill is de-asserted
400  * @SAP_HW_RFKILL_DEASSERTED: If set, HW RfKill is de-asserted
401  *
402  * If both bits are set, then the radio is on.
403  */
404 enum iwl_sap_radio_state_bitmap {
405 	SAP_SW_RFKILL_DEASSERTED	= 1 << 0,
406 	SAP_HW_RFKILL_DEASSERTED	= 1 << 1,
407 };
408 
409 /**
410  * enum iwl_sap_notif_host_suspends_bitmap - used for %SAP_MSG_NOTIF_HOST_SUSPENDS
411  * @SAP_OFFER_NIC: TBD
412  * @SAP_FILTER_CONFIGURED: TBD
413  * @SAP_NLO_CONFIGURED: TBD
414  * @SAP_HOST_OWNS_NIC: TBD
415  * @SAP_LINK_PROTECTED: TBD
416  */
417 enum iwl_sap_notif_host_suspends_bitmap {
418 	SAP_OFFER_NIC		= 1 << 0,
419 	SAP_FILTER_CONFIGURED	= 1 << 1,
420 	SAP_NLO_CONFIGURED	= 1 << 2,
421 	SAP_HOST_OWNS_NIC	= 1 << 3,
422 	SAP_LINK_PROTECTED	= 1 << 4,
423 };
424 
425 /**
426  * struct iwl_sap_notif_country_code - payload of %SAP_MSG_NOTIF_COUNTRY_CODE
427  * @hdr: The SAP header
428  * @mcc: The country code.
429  * @source_id: TBD
430  * @reserved: For alignment.
431  * @diff_time: TBD
432  */
433 struct iwl_sap_notif_country_code {
434 	struct iwl_sap_hdr hdr;
435 	__le16 mcc;
436 	u8 source_id;
437 	u8 reserved;
438 	__le32 diff_time;
439 } __packed;
440 
441 /**
442  * struct iwl_sap_notif_host_link_up - payload of %SAP_MSG_NOTIF_HOST_LINK_UP
443  * @hdr: The SAP header
444  * @conn_info: Information about the connection.
445  * @colloc_channel: The collocated channel
446  * @colloc_band: The band of the collocated channel.
447  * @reserved: For alignment.
448  * @colloc_bssid: The collocated BSSID.
449  * @reserved1: For alignment.
450  */
451 struct iwl_sap_notif_host_link_up {
452 	struct iwl_sap_hdr hdr;
453 	struct iwl_sap_notif_connection_info conn_info;
454 	u8 colloc_channel;
455 	u8 colloc_band;
456 	__le16 reserved;
457 	u8 colloc_bssid[6];
458 	__le16 reserved1;
459 } __packed;
460 
461 /**
462  * enum iwl_sap_notif_link_down_type - used in &struct iwl_sap_notif_host_link_down
463  * @HOST_LINK_DOWN_TYPE_NONE: TBD
464  * @HOST_LINK_DOWN_TYPE_TEMPORARY: TBD
465  * @HOST_LINK_DOWN_TYPE_LONG: TBD
466  */
467 enum iwl_sap_notif_link_down_type {
468 	HOST_LINK_DOWN_TYPE_NONE,
469 	HOST_LINK_DOWN_TYPE_TEMPORARY,
470 	HOST_LINK_DOWN_TYPE_LONG,
471 };
472 
473 /**
474  * struct iwl_sap_notif_host_link_down - payload for %SAP_MSG_NOTIF_HOST_LINK_DOWN
475  * @hdr: The SAP header
476  * @type: See &enum iwl_sap_notif_link_down_type.
477  * @reserved: For alignment.
478  * @reason_valid: If 0, ignore the next field.
479  * @reason: The reason of the disconnection.
480  */
481 struct iwl_sap_notif_host_link_down {
482 	struct iwl_sap_hdr hdr;
483 	u8 type;
484 	u8 reserved[2];
485 	u8 reason_valid;
486 	__le32 reason;
487 } __packed;
488 
489 /**
490  * struct iwl_sap_notif_host_nic_info - payload for %SAP_MSG_NOTIF_NIC_INFO
491  * @hdr: The SAP header
492  * @mac_address: The MAC address as configured to the interface.
493  * @nvm_address: The MAC address as configured in the NVM.
494  */
495 struct iwl_sap_notif_host_nic_info {
496 	struct iwl_sap_hdr hdr;
497 	u8 mac_address[6];
498 	u8 nvm_address[6];
499 } __packed;
500 
501 /**
502  * struct iwl_sap_notif_dw - payload is a dw
503  * @hdr: The SAP header.
504  * @dw: The payload.
505  */
506 struct iwl_sap_notif_dw {
507 	struct iwl_sap_hdr hdr;
508 	__le32 dw;
509 } __packed;
510 
511 /**
512  * struct iwl_sap_notif_sar_limits - payload for %SAP_MSG_NOTIF_SAR_LIMITS
513  * @hdr: The SAP header
514  * @sar_chain_info_table: Tx power limits.
515  */
516 struct iwl_sap_notif_sar_limits {
517 	struct iwl_sap_hdr hdr;
518 	__le16 sar_chain_info_table[2][5];
519 } __packed;
520 
521 /**
522  * enum iwl_sap_nvm_caps - capabilities for NVM SAP
523  * @SAP_NVM_CAPS_LARI_SUPPORT: Lari is supported
524  * @SAP_NVM_CAPS_11AX_SUPPORT: 11AX is supported
525  */
526 enum iwl_sap_nvm_caps {
527 	SAP_NVM_CAPS_LARI_SUPPORT	= BIT(0),
528 	SAP_NVM_CAPS_11AX_SUPPORT	= BIT(1),
529 };
530 
531 /**
532  * struct iwl_sap_nvm - payload for %SAP_MSG_NOTIF_NVM
533  * @hdr: The SAP header.
534  * @hw_addr: The MAC address
535  * @n_hw_addrs: The number of MAC addresses
536  * @reserved: For alignment.
537  * @radio_cfg: The radio configuration.
538  * @caps: See &enum iwl_sap_nvm_caps.
539  * @nvm_version: The version of the NVM.
540  * @channels: The data for each channel.
541  */
542 struct iwl_sap_nvm {
543 	struct iwl_sap_hdr hdr;
544 	u8 hw_addr[6];
545 	u8 n_hw_addrs;
546 	u8 reserved;
547 	__le32 radio_cfg;
548 	__le32 caps;
549 	__le32 nvm_version;
550 	__le32 channels[110];
551 } __packed;
552 
553 /**
554  * enum iwl_sap_eth_filter_flags - used in &struct iwl_sap_eth_filter
555  * @SAP_ETH_FILTER_STOP: Do not process further filters.
556  * @SAP_ETH_FILTER_COPY: Copy the packet to the CSME.
557  * @SAP_ETH_FILTER_ENABLED: If false, the filter should be ignored.
558  */
559 enum iwl_sap_eth_filter_flags {
560 	SAP_ETH_FILTER_STOP    = BIT(0),
561 	SAP_ETH_FILTER_COPY    = BIT(1),
562 	SAP_ETH_FILTER_ENABLED = BIT(2),
563 };
564 
565 /**
566  * struct iwl_sap_eth_filter - a L2 filter
567  * @mac_address: Address to filter.
568  * @flags: See &enum iwl_sap_eth_filter_flags.
569  */
570 struct iwl_sap_eth_filter {
571 	u8 mac_address[6];
572 	u8 flags;
573 } __packed;
574 
575 /**
576  * enum iwl_sap_flex_filter_flags - used in &struct iwl_sap_flex_filter
577  * @SAP_FLEX_FILTER_COPY: Pass UDP / TCP packets to CSME.
578  * @SAP_FLEX_FILTER_ENABLED: If false, the filter should be ignored.
579  * @SAP_FLEX_FILTER_IPV4: Filter requires match on the IP address as well.
580  * @SAP_FLEX_FILTER_IPV6: Filter requires match on the IP address as well.
581  * @SAP_FLEX_FILTER_TCP: Filter should be applied on TCP packets.
582  * @SAP_FLEX_FILTER_UDP: Filter should be applied on UDP packets.
583  */
584 enum iwl_sap_flex_filter_flags {
585 	SAP_FLEX_FILTER_COPY		= BIT(0),
586 	SAP_FLEX_FILTER_ENABLED		= BIT(1),
587 	SAP_FLEX_FILTER_IPV6		= BIT(2),
588 	SAP_FLEX_FILTER_IPV4		= BIT(3),
589 	SAP_FLEX_FILTER_TCP		= BIT(4),
590 	SAP_FLEX_FILTER_UDP		= BIT(5),
591 };
592 
593 /**
594  * struct iwl_sap_flex_filter -
595  * @src_port: Source port in network format.
596  * @dst_port: Destination port in network format.
597  * @flags: Flags and protocol, see &enum iwl_sap_flex_filter_flags.
598  * @reserved: For alignment.
599  */
600 struct iwl_sap_flex_filter {
601 	__be16 src_port;
602 	__be16 dst_port;
603 	u8 flags;
604 	u8 reserved;
605 } __packed;
606 
607 /**
608  * enum iwl_sap_ipv4_filter_flags - used in &struct iwl_sap_ipv4_filter
609  * @SAP_IPV4_FILTER_ICMP_PASS: Pass ICMP packets to CSME.
610  * @SAP_IPV4_FILTER_ICMP_COPY: Pass ICMP packets to host.
611  * @SAP_IPV4_FILTER_ARP_REQ_PASS: Pass ARP requests to CSME.
612  * @SAP_IPV4_FILTER_ARP_REQ_COPY: Pass ARP requests to host.
613  * @SAP_IPV4_FILTER_ARP_RESP_PASS: Pass ARP responses to CSME.
614  * @SAP_IPV4_FILTER_ARP_RESP_COPY: Pass ARP responses to host.
615  */
616 enum iwl_sap_ipv4_filter_flags {
617 	SAP_IPV4_FILTER_ICMP_PASS	= BIT(0),
618 	SAP_IPV4_FILTER_ICMP_COPY	= BIT(1),
619 	SAP_IPV4_FILTER_ARP_REQ_PASS	= BIT(2),
620 	SAP_IPV4_FILTER_ARP_REQ_COPY	= BIT(3),
621 	SAP_IPV4_FILTER_ARP_RESP_PASS	= BIT(4),
622 	SAP_IPV4_FILTER_ARP_RESP_COPY	= BIT(5),
623 };
624 
625 /**
626  * struct iwl_sap_ipv4_filter-
627  * @ipv4_addr: The IP address to filer.
628  * @flags: See &enum iwl_sap_ipv4_filter_flags.
629  */
630 struct iwl_sap_ipv4_filter {
631 	__be32 ipv4_addr;
632 	__le32 flags;
633 } __packed;
634 
635 /**
636  * enum iwl_sap_ipv6_filter_flags -
637  * @SAP_IPV6_ADDR_FILTER_COPY: Pass packets to the host.
638  * @SAP_IPV6_ADDR_FILTER_ENABLED: If false, the filter should be ignored.
639  */
640 enum iwl_sap_ipv6_filter_flags {
641 	SAP_IPV6_ADDR_FILTER_COPY	= BIT(0),
642 	SAP_IPV6_ADDR_FILTER_ENABLED	= BIT(1),
643 };
644 
645 /**
646  * struct iwl_sap_ipv6_filter -
647  * @addr_lo24: Lowest 24 bits of the IPv6 address.
648  * @flags: See &enum iwl_sap_ipv6_filter_flags.
649  */
650 struct iwl_sap_ipv6_filter {
651 	u8 addr_lo24[3];
652 	u8 flags;
653 } __packed;
654 
655 /**
656  * enum iwl_sap_icmpv6_filter_flags -
657  * @SAP_ICMPV6_FILTER_ENABLED: If false, the filter should be ignored.
658  * @SAP_ICMPV6_FILTER_COPY: Pass packets to the host.
659  */
660 enum iwl_sap_icmpv6_filter_flags {
661 	SAP_ICMPV6_FILTER_ENABLED	= BIT(0),
662 	SAP_ICMPV6_FILTER_COPY		= BIT(1),
663 };
664 
665 /**
666  * enum iwl_sap_vlan_filter_flags -
667  * @SAP_VLAN_FILTER_VLAN_ID_MSK: TBD
668  * @SAP_VLAN_FILTER_ENABLED: If false, the filter should be ignored.
669  */
670 enum iwl_sap_vlan_filter_flags {
671 	SAP_VLAN_FILTER_VLAN_ID_MSK	= 0x0FFF,
672 	SAP_VLAN_FILTER_ENABLED		= BIT(15),
673 };
674 
675 /**
676  * struct iwl_sap_oob_filters - Out of band filters (for RX only)
677  * @flex_filters: Array of &struct iwl_sap_flex_filter.
678  * @icmpv6_flags: See &enum iwl_sap_icmpv6_filter_flags.
679  * @ipv6_filters: Array of &struct iwl_sap_ipv6_filter.
680  * @eth_filters: Array of &struct iwl_sap_eth_filter.
681  * @reserved: For alignment.
682  * @ipv4_filter: &struct iwl_sap_ipv4_filter.
683  * @vlan: See &enum iwl_sap_vlan_filter_flags.
684  */
685 struct iwl_sap_oob_filters {
686 	struct iwl_sap_flex_filter flex_filters[14];
687 	__le32 icmpv6_flags;
688 	struct iwl_sap_ipv6_filter ipv6_filters[4];
689 	struct iwl_sap_eth_filter eth_filters[5];
690 	u8 reserved;
691 	struct iwl_sap_ipv4_filter ipv4_filter;
692 	__le16 vlan[4];
693 } __packed;
694 
695 /**
696  * struct iwl_sap_csme_filters - payload of %SAP_MSG_NOTIF_CSME_FILTERS
697  * @hdr: The SAP header.
698  * @mode: Not used.
699  * @mac_address: Not used.
700  * @reserved: For alignment.
701  * @cbfilters: Not used.
702  * @filters: Out of band filters.
703  */
704 struct iwl_sap_csme_filters {
705 	struct iwl_sap_hdr hdr;
706 	__le32 mode;
707 	u8 mac_address[6];
708 	__le16 reserved;
709 	u8 cbfilters[1728];
710 	struct iwl_sap_oob_filters filters;
711 } __packed;
712 
713 #define CB_TX_DHCP_FILT_IDX 30
714 /**
715  * struct iwl_sap_cb_data - header to be added for transmitted packets.
716  * @hdr: The SAP header.
717  * @reserved: Not used.
718  * @to_me_filt_status: The filter that matches. Bit %CB_TX_DHCP_FILT_IDX should
719  *	be set for DHCP (the only packet that uses this header).
720  * @reserved2: Not used.
721  * @data_len: The length of the payload.
722  * @payload: The payload of the transmitted packet.
723  */
724 struct iwl_sap_cb_data {
725 	struct iwl_sap_hdr hdr;
726 	__le32 reserved[7];
727 	__le32 to_me_filt_status;
728 	__le32 reserved2;
729 	__le32 data_len;
730 	u8 payload[];
731 };
732 
733 #endif /* __sap_h__ */
734