1 /**
2  * Copyright 2023-2024 NXP
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * @file nxp_wifi_drv.h
6  * Shim layer between wifi driver connection manager and zephyr
7  * Wi-Fi L2 layer
8  */
9 
10 #ifndef ZEPHYR_DRIVERS_WIFI_NNP_WIFI_DRV_H_
11 #define ZEPHYR_DRIVERS_WIFI_NXP_WIFI_DRV_H_
12 
13 #include <zephyr/kernel.h>
14 #include <stdio.h>
15 #ifdef CONFIG_SDIO_STACK
16 #include <zephyr/sd/sd.h>
17 #include <zephyr/sd/sdio.h>
18 #endif
19 #include <zephyr/drivers/gpio.h>
20 #include <zephyr/net/wifi_mgmt.h>
21 #include <zephyr/net/dhcpv4_server.h>
22 
23 #include "wlan_bt_fw.h"
24 #include "wlan.h"
25 #include "wm_net.h"
26 #if defined(CONFIG_NXP_WIFI_SHELL)
27 #include "wifi_shell.h"
28 #endif
29 #if defined(CONFIG_WIFI_NM_WPA_SUPPLICANT)
30 #include "wifi_nxp.h"
31 #include "rtos_wpa_supp_if.h"
32 #endif
33 
34 #define MAX_DATA_SIZE 1600
35 
36 #define NXP_WIFI_SYNC_TIMEOUT_MS K_FOREVER
37 
38 #define NXP_WIFI_UAP_NETWORK_NAME "uap-network"
39 
40 #define NXP_WIFI_STA_NETWORK_NAME "sta-network"
41 
42 #define NXP_WIFI_EVENT_BIT(event) (1 << event)
43 
44 #define NXP_WIFI_SYNC_INIT_GROUP                                                                   \
45 	NXP_WIFI_EVENT_BIT(WLAN_REASON_INITIALIZED) |                                              \
46 		NXP_WIFI_EVENT_BIT(WLAN_REASON_INITIALIZATION_FAILED)
47 
48 #define NXP_WIFI_SYNC_PS_GROUP                                                                     \
49 	NXP_WIFI_EVENT_BIT(WLAN_REASON_PS_ENTER) | NXP_WIFI_EVENT_BIT(WLAN_REASON_PS_EXIT)
50 
51 enum nxp_wifi_ret {
52 	NXP_WIFI_RET_SUCCESS,
53 	NXP_WIFI_RET_FAIL,
54 	NXP_WIFI_RET_NOT_FOUND,
55 	NXP_WIFI_RET_AUTH_FAILED,
56 	NXP_WIFI_RET_ADDR_FAILED,
57 	NXP_WIFI_RET_NOT_CONNECTED,
58 	NXP_WIFI_RET_NOT_READY,
59 	NXP_WIFI_RET_TIMEOUT,
60 	NXP_WIFI_RET_BAD_PARAM,
61 };
62 
63 enum nxp_wifi_state {
64 	NXP_WIFI_NOT_INITIALIZED,
65 	NXP_WIFI_INITIALIZED,
66 	NXP_WIFI_STARTED,
67 };
68 
69 struct nxp_wifi_dev {
70 	struct net_if *iface;
71 	scan_result_cb_t scan_cb;
72 	struct k_mutex mutex;
73 };
74 
75 int nxp_wifi_wlan_event_callback(enum wlan_event_reason reason, void *data);
76 
77 #if defined(CONFIG_NXP_WIFI_SHELL)
78 void nxp_wifi_shell_register(struct nxp_wifi_dev *dev);
79 #else
80 #define nxp_wifi_shell_register(dev)
81 #endif
82 
83 #endif
84