1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2021 - 2022 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  * additional 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 know 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 negotiation 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 message.
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_PLDR_ACK: See &struct iwl_sap_pldr_ack_data.
207  * @SAP_MSG_NOTIF_FROM_CSME_MAX: Not used.
208  *
209  * @SAP_MSG_NOTIF_FROM_HOST_MIN: Not used.
210  * @SAP_MSG_NOTIF_BAND_SELECTION: TODO
211  * @SAP_MSG_NOTIF_RADIO_STATE: Payload is a DW.
212  *	See &enum iwl_sap_radio_state_bitmap.
213  * @SAP_MSG_NOTIF_NIC_INFO: See &struct iwl_sap_notif_host_nic_info.
214  * @SAP_MSG_NOTIF_HOST_ASKS_FOR_NIC_OWNERSHIP: No payload.
215  * @SAP_MSG_NOTIF_HOST_SUSPENDS: Payload is a DW. Bitmap described in
216  *	&enum iwl_sap_notif_host_suspends_bitmap.
217  * @SAP_MSG_NOTIF_HOST_RESUMES: Payload is a DW. 0 or 1. 1 says that
218  *	the CSME should re-initialize the init control block.
219  * @SAP_MSG_NOTIF_HOST_GOES_DOWN: No payload.
220  * @SAP_MSG_NOTIF_CSME_OWNERSHIP_CONFIRMED: No payload.
221  * @SAP_MSG_NOTIF_COUNTRY_CODE: See &struct iwl_sap_notif_country_code.
222  * @SAP_MSG_NOTIF_HOST_LINK_UP: See &struct iwl_sap_notif_host_link_up.
223  * @SAP_MSG_NOTIF_HOST_LINK_DOWN: See &struct iwl_sap_notif_host_link_down.
224  * @SAP_MSG_NOTIF_WHO_OWNS_NIC: No payload.
225  * @SAP_MSG_NOTIF_WIFIDR_DOWN: No payload.
226  * @SAP_MSG_NOTIF_WIFIDR_UP: No payload.
227  * @SAP_MSG_NOTIF_HOST_OWNERSHIP_CONFIRMED: No payload.
228  * @SAP_MSG_NOTIF_SAR_LIMITS: See &struct iwl_sap_notif_sar_limits.
229  * @SAP_MSG_NOTIF_GET_NVM: No payload. Triggers %SAP_MSG_NOTIF_NVM.
230  * @SAP_MSG_NOTIF_PLDR: See &struct iwl_sap_pldr_data.
231  * @SAP_MSG_NOTIF_PLDR_END: See &struct iwl_sap_pldr_end_data.
232  * @SAP_MSG_NOTIF_FROM_HOST_MAX: Not used.
233  *
234  * @SAP_MSG_DATA_MIN: Not used.
235  * @SAP_MSG_DATA_PACKET: Packets that passed the filters defined by
236  *	%SAP_MSG_NOTIF_CSME_FILTERS. The payload is &struct iwl_sap_hdr with
237  *	the payload of the packet immediately afterwards.
238  * @SAP_MSG_CB_DATA_PACKET: Indicates to CSME that we transmitted a specific
239  *	packet. Used only for DHCP transmitted packets. See
240  *	&struct iwl_sap_cb_data.
241  * @SAP_MSG_DATA_MAX: Not used.
242  */
243 enum iwl_sap_msg {
244 	SAP_MSG_NOTIF_BOTH_WAYS_MIN			= 0,
245 	SAP_MSG_NOTIF_PING				= 1,
246 	SAP_MSG_NOTIF_PONG				= 2,
247 	SAP_MSG_NOTIF_BOTH_WAYS_MAX,
248 
249 	SAP_MSG_NOTIF_FROM_CSME_MIN			= 500,
250 	SAP_MSG_NOTIF_CSME_FILTERS			= SAP_MSG_NOTIF_FROM_CSME_MIN,
251 	/* 501 is deprecated */
252 	SAP_MSG_NOTIF_AMT_STATE				= 502,
253 	SAP_MSG_NOTIF_CSME_REPLY_TO_HOST_OWNERSHIP_REQ	= 503,
254 	SAP_MSG_NOTIF_CSME_TAKING_OWNERSHIP		= 504,
255 	SAP_MSG_NOTIF_TRIGGER_IP_REFRESH		= 505,
256 	SAP_MSG_NOTIF_CSME_CAN_RELEASE_OWNERSHIP	= 506,
257 	/* 507 is deprecated */
258 	/* 508 is deprecated */
259 	/* 509 is deprecated */
260 	/* 510 is deprecated */
261 	SAP_MSG_NOTIF_NIC_OWNER				= 511,
262 	SAP_MSG_NOTIF_CSME_CONN_STATUS			= 512,
263 	SAP_MSG_NOTIF_NVM				= 513,
264 	/* 514 - 517 not supported */
265 	SAP_MSG_NOTIF_PLDR_ACK				= 518,
266 	SAP_MSG_NOTIF_FROM_CSME_MAX,
267 
268 	SAP_MSG_NOTIF_FROM_HOST_MIN			= 1000,
269 	SAP_MSG_NOTIF_BAND_SELECTION			= SAP_MSG_NOTIF_FROM_HOST_MIN,
270 	SAP_MSG_NOTIF_RADIO_STATE			= 1001,
271 	SAP_MSG_NOTIF_NIC_INFO				= 1002,
272 	SAP_MSG_NOTIF_HOST_ASKS_FOR_NIC_OWNERSHIP	= 1003,
273 	SAP_MSG_NOTIF_HOST_SUSPENDS			= 1004,
274 	SAP_MSG_NOTIF_HOST_RESUMES			= 1005,
275 	SAP_MSG_NOTIF_HOST_GOES_DOWN			= 1006,
276 	SAP_MSG_NOTIF_CSME_OWNERSHIP_CONFIRMED		= 1007,
277 	SAP_MSG_NOTIF_COUNTRY_CODE			= 1008,
278 	SAP_MSG_NOTIF_HOST_LINK_UP			= 1009,
279 	SAP_MSG_NOTIF_HOST_LINK_DOWN			= 1010,
280 	SAP_MSG_NOTIF_WHO_OWNS_NIC			= 1011,
281 	SAP_MSG_NOTIF_WIFIDR_DOWN			= 1012,
282 	SAP_MSG_NOTIF_WIFIDR_UP				= 1013,
283 	/* 1014 is deprecated */
284 	SAP_MSG_NOTIF_HOST_OWNERSHIP_CONFIRMED		= 1015,
285 	SAP_MSG_NOTIF_SAR_LIMITS			= 1016,
286 	SAP_MSG_NOTIF_GET_NVM				= 1017,
287 	/* 1018 - 1023 not supported */
288 	SAP_MSG_NOTIF_PLDR				= 1024,
289 	SAP_MSG_NOTIF_PLDR_END				= 1025,
290 	SAP_MSG_NOTIF_FROM_HOST_MAX,
291 
292 	SAP_MSG_DATA_MIN				= 2000,
293 	SAP_MSG_DATA_PACKET				= SAP_MSG_DATA_MIN,
294 	SAP_MSG_CB_DATA_PACKET				= 2001,
295 	SAP_MSG_DATA_MAX,
296 };
297 
298 /**
299  * struct iwl_sap_hdr - prefixes any SAP message
300  * @type: See &enum iwl_sap_msg.
301  * @len: The length of the message (header not included).
302  * @seq_num: For debug.
303  * @payload: The payload of the message.
304  */
305 struct iwl_sap_hdr {
306 	__le16 type;
307 	__le16 len;
308 	__le32 seq_num;
309 	u8 payload[];
310 };
311 
312 /**
313  * struct iwl_sap_msg_dw - suits any DW long SAP message
314  * @hdr: The SAP header
315  * @val: The value of the DW.
316  */
317 struct iwl_sap_msg_dw {
318 	struct iwl_sap_hdr hdr;
319 	__le32 val;
320 };
321 
322 /**
323  * enum iwl_sap_nic_owner - used by %SAP_MSG_NOTIF_NIC_OWNER
324  * @SAP_NIC_OWNER_UNKNOWN: Not used.
325  * @SAP_NIC_OWNER_HOST: The host owns the NIC.
326  * @SAP_NIC_OWNER_ME: CSME owns the NIC.
327  */
328 enum iwl_sap_nic_owner {
329 	SAP_NIC_OWNER_UNKNOWN,
330 	SAP_NIC_OWNER_HOST,
331 	SAP_NIC_OWNER_ME,
332 };
333 
334 enum iwl_sap_wifi_auth_type {
335 	SAP_WIFI_AUTH_TYPE_OPEN		= IWL_MEI_AKM_AUTH_OPEN,
336 	SAP_WIFI_AUTH_TYPE_RSNA		= IWL_MEI_AKM_AUTH_RSNA,
337 	SAP_WIFI_AUTH_TYPE_RSNA_PSK	= IWL_MEI_AKM_AUTH_RSNA_PSK,
338 	SAP_WIFI_AUTH_TYPE_SAE		= IWL_MEI_AKM_AUTH_SAE,
339 	SAP_WIFI_AUTH_TYPE_MAX,
340 };
341 
342 /**
343  * enum iwl_sap_wifi_cipher_alg
344  * @SAP_WIFI_CIPHER_ALG_NONE: TBD
345  * @SAP_WIFI_CIPHER_ALG_TKIP: TBD
346  * @SAP_WIFI_CIPHER_ALG_CCMP: TBD
347  * @SAP_WIFI_CIPHER_ALG_GCMP: TBD
348  * @SAP_WIFI_CIPHER_ALG_GCMP_256: TBD
349  */
350 enum iwl_sap_wifi_cipher_alg {
351 	SAP_WIFI_CIPHER_ALG_NONE	= IWL_MEI_CIPHER_NONE,
352 	SAP_WIFI_CIPHER_ALG_TKIP	= IWL_MEI_CIPHER_TKIP,
353 	SAP_WIFI_CIPHER_ALG_CCMP	= IWL_MEI_CIPHER_CCMP,
354 	SAP_WIFI_CIPHER_ALG_GCMP	= IWL_MEI_CIPHER_GCMP,
355 	SAP_WIFI_CIPHER_ALG_GCMP_256	= IWL_MEI_CIPHER_GCMP_256,
356 };
357 
358 /**
359  * struct iwl_sap_notif_connection_info - nested in other structures
360  * @ssid_len: The length of the SSID.
361  * @ssid: The SSID.
362  * @auth_mode: The authentication mode. See &enum iwl_sap_wifi_auth_type.
363  * @pairwise_cipher: The cipher used for unicast packets.
364  *	See &enum iwl_sap_wifi_cipher_alg.
365  * @channel: The channel on which we are associated.
366  * @band: The band on which we are associated.
367  * @reserved: For alignment.
368  * @bssid: The BSSID.
369  * @reserved1: For alignment.
370  */
371 struct iwl_sap_notif_connection_info {
372 	__le32 ssid_len;
373 	u8 ssid[32];
374 	__le32 auth_mode;
375 	__le32 pairwise_cipher;
376 	u8 channel;
377 	u8 band;
378 	__le16 reserved;
379 	u8 bssid[6];
380 	__le16 reserved1;
381 } __packed;
382 
383 /**
384  * enum iwl_sap_scan_request - for the scan_request field
385  * @SCAN_REQUEST_FILTERING: Filtering is requested.
386  * @SCAN_REQUEST_FAST: Fast scan is requested.
387  */
388 enum iwl_sap_scan_request {
389 	SCAN_REQUEST_FILTERING	= 1 << 0,
390 	SCAN_REQUEST_FAST	= 1 << 1,
391 };
392 
393 /**
394  * struct iwl_sap_notif_conn_status - payload of %SAP_MSG_NOTIF_CSME_CONN_STATUS
395  * @hdr: The SAP header
396  * @link_prot_state: Non-zero if link protection is active.
397  * @scan_request: See &enum iwl_sap_scan_request.
398  * @conn_info: Information about the connection.
399  */
400 struct iwl_sap_notif_conn_status {
401 	struct iwl_sap_hdr hdr;
402 	__le32 link_prot_state;
403 	__le32 scan_request;
404 	struct iwl_sap_notif_connection_info conn_info;
405 } __packed;
406 
407 /**
408  * enum iwl_sap_radio_state_bitmap - used for %SAP_MSG_NOTIF_RADIO_STATE
409  * @SAP_SW_RFKILL_DEASSERTED: If set, SW RfKill is de-asserted
410  * @SAP_HW_RFKILL_DEASSERTED: If set, HW RfKill is de-asserted
411  *
412  * If both bits are set, then the radio is on.
413  */
414 enum iwl_sap_radio_state_bitmap {
415 	SAP_SW_RFKILL_DEASSERTED	= 1 << 0,
416 	SAP_HW_RFKILL_DEASSERTED	= 1 << 1,
417 };
418 
419 /**
420  * enum iwl_sap_notif_host_suspends_bitmap - used for %SAP_MSG_NOTIF_HOST_SUSPENDS
421  * @SAP_OFFER_NIC: TBD
422  * @SAP_FILTER_CONFIGURED: TBD
423  * @SAP_NLO_CONFIGURED: TBD
424  * @SAP_HOST_OWNS_NIC: TBD
425  * @SAP_LINK_PROTECTED: TBD
426  */
427 enum iwl_sap_notif_host_suspends_bitmap {
428 	SAP_OFFER_NIC		= 1 << 0,
429 	SAP_FILTER_CONFIGURED	= 1 << 1,
430 	SAP_NLO_CONFIGURED	= 1 << 2,
431 	SAP_HOST_OWNS_NIC	= 1 << 3,
432 	SAP_LINK_PROTECTED	= 1 << 4,
433 };
434 
435 /**
436  * struct iwl_sap_notif_country_code - payload of %SAP_MSG_NOTIF_COUNTRY_CODE
437  * @hdr: The SAP header
438  * @mcc: The country code.
439  * @source_id: TBD
440  * @reserved: For alignment.
441  * @diff_time: TBD
442  */
443 struct iwl_sap_notif_country_code {
444 	struct iwl_sap_hdr hdr;
445 	__le16 mcc;
446 	u8 source_id;
447 	u8 reserved;
448 	__le32 diff_time;
449 } __packed;
450 
451 /**
452  * struct iwl_sap_notif_host_link_up - payload of %SAP_MSG_NOTIF_HOST_LINK_UP
453  * @hdr: The SAP header
454  * @conn_info: Information about the connection.
455  * @colloc_channel: The collocated channel
456  * @colloc_band: The band of the collocated channel.
457  * @reserved: For alignment.
458  * @colloc_bssid: The collocated BSSID.
459  * @reserved1: For alignment.
460  */
461 struct iwl_sap_notif_host_link_up {
462 	struct iwl_sap_hdr hdr;
463 	struct iwl_sap_notif_connection_info conn_info;
464 	u8 colloc_channel;
465 	u8 colloc_band;
466 	__le16 reserved;
467 	u8 colloc_bssid[6];
468 	__le16 reserved1;
469 } __packed;
470 
471 /**
472  * enum iwl_sap_notif_link_down_type - used in &struct iwl_sap_notif_host_link_down
473  * @HOST_LINK_DOWN_TYPE_NONE: TBD
474  * @HOST_LINK_DOWN_TYPE_TEMPORARY: TBD
475  * @HOST_LINK_DOWN_TYPE_LONG: TBD
476  */
477 enum iwl_sap_notif_link_down_type {
478 	HOST_LINK_DOWN_TYPE_NONE,
479 	HOST_LINK_DOWN_TYPE_TEMPORARY,
480 	HOST_LINK_DOWN_TYPE_LONG,
481 };
482 
483 /**
484  * struct iwl_sap_notif_host_link_down - payload for %SAP_MSG_NOTIF_HOST_LINK_DOWN
485  * @hdr: The SAP header
486  * @type: See &enum iwl_sap_notif_link_down_type.
487  * @reserved: For alignment.
488  * @reason_valid: If 0, ignore the next field.
489  * @reason: The reason of the disconnection.
490  */
491 struct iwl_sap_notif_host_link_down {
492 	struct iwl_sap_hdr hdr;
493 	u8 type;
494 	u8 reserved[2];
495 	u8 reason_valid;
496 	__le32 reason;
497 } __packed;
498 
499 /**
500  * struct iwl_sap_notif_host_nic_info - payload for %SAP_MSG_NOTIF_NIC_INFO
501  * @hdr: The SAP header
502  * @mac_address: The MAC address as configured to the interface.
503  * @nvm_address: The MAC address as configured in the NVM.
504  */
505 struct iwl_sap_notif_host_nic_info {
506 	struct iwl_sap_hdr hdr;
507 	u8 mac_address[6];
508 	u8 nvm_address[6];
509 } __packed;
510 
511 /**
512  * struct iwl_sap_notif_dw - payload is a dw
513  * @hdr: The SAP header.
514  * @dw: The payload.
515  */
516 struct iwl_sap_notif_dw {
517 	struct iwl_sap_hdr hdr;
518 	__le32 dw;
519 } __packed;
520 
521 /**
522  * struct iwl_sap_notif_sar_limits - payload for %SAP_MSG_NOTIF_SAR_LIMITS
523  * @hdr: The SAP header
524  * @sar_chain_info_table: Tx power limits.
525  */
526 struct iwl_sap_notif_sar_limits {
527 	struct iwl_sap_hdr hdr;
528 	__le16 sar_chain_info_table[2][5];
529 } __packed;
530 
531 /**
532  * enum iwl_sap_nvm_caps - capabilities for NVM SAP
533  * @SAP_NVM_CAPS_LARI_SUPPORT: Lari is supported
534  * @SAP_NVM_CAPS_11AX_SUPPORT: 11AX is supported
535  */
536 enum iwl_sap_nvm_caps {
537 	SAP_NVM_CAPS_LARI_SUPPORT	= BIT(0),
538 	SAP_NVM_CAPS_11AX_SUPPORT	= BIT(1),
539 };
540 
541 /**
542  * struct iwl_sap_nvm - payload for %SAP_MSG_NOTIF_NVM
543  * @hdr: The SAP header.
544  * @hw_addr: The MAC address
545  * @n_hw_addrs: The number of MAC addresses
546  * @reserved: For alignment.
547  * @radio_cfg: The radio configuration.
548  * @caps: See &enum iwl_sap_nvm_caps.
549  * @nvm_version: The version of the NVM.
550  * @channels: The data for each channel.
551  */
552 struct iwl_sap_nvm {
553 	struct iwl_sap_hdr hdr;
554 	u8 hw_addr[6];
555 	u8 n_hw_addrs;
556 	u8 reserved;
557 	__le32 radio_cfg;
558 	__le32 caps;
559 	__le32 nvm_version;
560 	__le32 channels[110];
561 } __packed;
562 
563 /**
564  * enum iwl_sap_eth_filter_flags - used in &struct iwl_sap_eth_filter
565  * @SAP_ETH_FILTER_STOP: Do not process further filters.
566  * @SAP_ETH_FILTER_COPY: Copy the packet to the CSME.
567  * @SAP_ETH_FILTER_ENABLED: If false, the filter should be ignored.
568  */
569 enum iwl_sap_eth_filter_flags {
570 	SAP_ETH_FILTER_STOP    = BIT(0),
571 	SAP_ETH_FILTER_COPY    = BIT(1),
572 	SAP_ETH_FILTER_ENABLED = BIT(2),
573 };
574 
575 /**
576  * struct iwl_sap_eth_filter - a L2 filter
577  * @mac_address: Address to filter.
578  * @flags: See &enum iwl_sap_eth_filter_flags.
579  */
580 struct iwl_sap_eth_filter {
581 	u8 mac_address[6];
582 	u8 flags;
583 } __packed;
584 
585 /**
586  * enum iwl_sap_flex_filter_flags - used in &struct iwl_sap_flex_filter
587  * @SAP_FLEX_FILTER_COPY: Pass UDP / TCP packets to CSME.
588  * @SAP_FLEX_FILTER_ENABLED: If false, the filter should be ignored.
589  * @SAP_FLEX_FILTER_IPV4: Filter requires match on the IP address as well.
590  * @SAP_FLEX_FILTER_IPV6: Filter requires match on the IP address as well.
591  * @SAP_FLEX_FILTER_TCP: Filter should be applied on TCP packets.
592  * @SAP_FLEX_FILTER_UDP: Filter should be applied on UDP packets.
593  */
594 enum iwl_sap_flex_filter_flags {
595 	SAP_FLEX_FILTER_COPY		= BIT(0),
596 	SAP_FLEX_FILTER_ENABLED		= BIT(1),
597 	SAP_FLEX_FILTER_IPV6		= BIT(2),
598 	SAP_FLEX_FILTER_IPV4		= BIT(3),
599 	SAP_FLEX_FILTER_TCP		= BIT(4),
600 	SAP_FLEX_FILTER_UDP		= BIT(5),
601 };
602 
603 /**
604  * struct iwl_sap_flex_filter -
605  * @src_port: Source port in network format.
606  * @dst_port: Destination port in network format.
607  * @flags: Flags and protocol, see &enum iwl_sap_flex_filter_flags.
608  * @reserved: For alignment.
609  */
610 struct iwl_sap_flex_filter {
611 	__be16 src_port;
612 	__be16 dst_port;
613 	u8 flags;
614 	u8 reserved;
615 } __packed;
616 
617 /**
618  * enum iwl_sap_ipv4_filter_flags - used in &struct iwl_sap_ipv4_filter
619  * @SAP_IPV4_FILTER_ICMP_PASS: Pass ICMP packets to CSME.
620  * @SAP_IPV4_FILTER_ICMP_COPY: Pass ICMP packets to host.
621  * @SAP_IPV4_FILTER_ARP_REQ_PASS: Pass ARP requests to CSME.
622  * @SAP_IPV4_FILTER_ARP_REQ_COPY: Pass ARP requests to host.
623  * @SAP_IPV4_FILTER_ARP_RESP_PASS: Pass ARP responses to CSME.
624  * @SAP_IPV4_FILTER_ARP_RESP_COPY: Pass ARP responses to host.
625  */
626 enum iwl_sap_ipv4_filter_flags {
627 	SAP_IPV4_FILTER_ICMP_PASS	= BIT(0),
628 	SAP_IPV4_FILTER_ICMP_COPY	= BIT(1),
629 	SAP_IPV4_FILTER_ARP_REQ_PASS	= BIT(2),
630 	SAP_IPV4_FILTER_ARP_REQ_COPY	= BIT(3),
631 	SAP_IPV4_FILTER_ARP_RESP_PASS	= BIT(4),
632 	SAP_IPV4_FILTER_ARP_RESP_COPY	= BIT(5),
633 };
634 
635 /**
636  * struct iwl_sap_ipv4_filter-
637  * @ipv4_addr: The IP address to filer.
638  * @flags: See &enum iwl_sap_ipv4_filter_flags.
639  */
640 struct iwl_sap_ipv4_filter {
641 	__be32 ipv4_addr;
642 	__le32 flags;
643 } __packed;
644 
645 /**
646  * enum iwl_sap_ipv6_filter_flags -
647  * @SAP_IPV6_ADDR_FILTER_COPY: Pass packets to the host.
648  * @SAP_IPV6_ADDR_FILTER_ENABLED: If false, the filter should be ignored.
649  */
650 enum iwl_sap_ipv6_filter_flags {
651 	SAP_IPV6_ADDR_FILTER_COPY	= BIT(0),
652 	SAP_IPV6_ADDR_FILTER_ENABLED	= BIT(1),
653 };
654 
655 /**
656  * struct iwl_sap_ipv6_filter -
657  * @addr_lo24: Lowest 24 bits of the IPv6 address.
658  * @flags: See &enum iwl_sap_ipv6_filter_flags.
659  */
660 struct iwl_sap_ipv6_filter {
661 	u8 addr_lo24[3];
662 	u8 flags;
663 } __packed;
664 
665 /**
666  * enum iwl_sap_icmpv6_filter_flags -
667  * @SAP_ICMPV6_FILTER_ENABLED: If false, the filter should be ignored.
668  * @SAP_ICMPV6_FILTER_COPY: Pass packets to the host.
669  */
670 enum iwl_sap_icmpv6_filter_flags {
671 	SAP_ICMPV6_FILTER_ENABLED	= BIT(0),
672 	SAP_ICMPV6_FILTER_COPY		= BIT(1),
673 };
674 
675 /**
676  * enum iwl_sap_vlan_filter_flags -
677  * @SAP_VLAN_FILTER_VLAN_ID_MSK: TBD
678  * @SAP_VLAN_FILTER_ENABLED: If false, the filter should be ignored.
679  */
680 enum iwl_sap_vlan_filter_flags {
681 	SAP_VLAN_FILTER_VLAN_ID_MSK	= 0x0FFF,
682 	SAP_VLAN_FILTER_ENABLED		= BIT(15),
683 };
684 
685 /**
686  * struct iwl_sap_oob_filters - Out of band filters (for RX only)
687  * @flex_filters: Array of &struct iwl_sap_flex_filter.
688  * @icmpv6_flags: See &enum iwl_sap_icmpv6_filter_flags.
689  * @ipv6_filters: Array of &struct iwl_sap_ipv6_filter.
690  * @eth_filters: Array of &struct iwl_sap_eth_filter.
691  * @reserved: For alignment.
692  * @ipv4_filter: &struct iwl_sap_ipv4_filter.
693  * @vlan: See &enum iwl_sap_vlan_filter_flags.
694  */
695 struct iwl_sap_oob_filters {
696 	struct iwl_sap_flex_filter flex_filters[14];
697 	__le32 icmpv6_flags;
698 	struct iwl_sap_ipv6_filter ipv6_filters[4];
699 	struct iwl_sap_eth_filter eth_filters[5];
700 	u8 reserved;
701 	struct iwl_sap_ipv4_filter ipv4_filter;
702 	__le16 vlan[4];
703 } __packed;
704 
705 /**
706  * struct iwl_sap_csme_filters - payload of %SAP_MSG_NOTIF_CSME_FILTERS
707  * @hdr: The SAP header.
708  * @mode: Not used.
709  * @mac_address: Not used.
710  * @reserved: For alignment.
711  * @cbfilters: Not used.
712  * @filters: Out of band filters.
713  */
714 struct iwl_sap_csme_filters {
715 	struct iwl_sap_hdr hdr;
716 	__le32 mode;
717 	u8 mac_address[6];
718 	__le16 reserved;
719 	u8 cbfilters[1728];
720 	struct iwl_sap_oob_filters filters;
721 } __packed;
722 
723 #define CB_TX_DHCP_FILT_IDX 30
724 /**
725  * struct iwl_sap_cb_data - header to be added for transmitted packets.
726  * @hdr: The SAP header.
727  * @reserved: Not used.
728  * @to_me_filt_status: The filter that matches. Bit %CB_TX_DHCP_FILT_IDX should
729  *	be set for DHCP (the only packet that uses this header).
730  * @reserved2: Not used.
731  * @data_len: The length of the payload.
732  * @payload: The payload of the transmitted packet.
733  */
734 struct iwl_sap_cb_data {
735 	struct iwl_sap_hdr hdr;
736 	__le32 reserved[7];
737 	__le32 to_me_filt_status;
738 	__le32 reserved2;
739 	__le32 data_len;
740 	u8 payload[];
741 };
742 
743 /**
744  * struct iwl_sap_pldr_data - payload of %SAP_MSG_NOTIF_PLDR
745  * @hdr: The SAP header.
746  * @version: SAP message version
747  */
748 struct iwl_sap_pldr_data {
749 	struct iwl_sap_hdr hdr;
750 	__le32 version;
751 } __packed;
752 
753 /**
754  * enum iwl_sap_pldr_status -
755  * @SAP_PLDR_STATUS_SUCCESS: PLDR started/ended successfully
756  * @SAP_PLDR_STATUS_FAILURE: PLDR failed to start/end
757  */
758 enum iwl_sap_pldr_status {
759 	SAP_PLDR_STATUS_SUCCESS	= 0,
760 	SAP_PLDR_STATUS_FAILURE	= 1,
761 };
762 
763 /*
764  * struct iwl_sap_pldr_end_data - payload of %SAP_MSG_NOTIF_PLDR_END
765  * @hdr: The SAP header.
766  * @version: SAP message version
767  * @status: PLDR end status
768  */
769 struct iwl_sap_pldr_end_data {
770 	struct iwl_sap_hdr hdr;
771 	__le32 version;
772 	__le32 status;
773 } __packed;
774 
775 /*
776  * struct iwl_sap_pldr_ack_data - payload of %SAP_MSG_NOTIF_PLDR_ACK
777  * @version: SAP message version
778  * @status: CSME accept/refuse to the PLDR request
779  */
780 struct iwl_sap_pldr_ack_data {
781 	struct iwl_sap_hdr hdr;
782 	__le32 version;
783 	__le32 status;
784 } __packed;
785 
786 #endif /* __sap_h__ */
787