Skip to content

mcux: wifi_nxp: Add IW610 host sleep support #566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mcux/middleware/wifi_nxp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ zephyr_compile_definitions_ifdef(CONFIG_NXP_IW610_MURATA_2LL_M2
CONFIG_NXP_WIFI_ED_OFFSET_2G=0x0A
CONFIG_NXP_WIFI_ED_OFFSET_5G=0x0A
WIFI_BT_USE_M2_INTERFACE
WIFI_IW610_BOARD_MURATA_2LL_M2
)

zephyr_compile_definitions_ifdef(CONFIG_NXP_IW610_RD_USD
Expand Down
61 changes: 14 additions & 47 deletions mcux/middleware/wifi_nxp/incl/wlcmgr/wlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,7 @@ int wlan_remove_all_network_profiles(void);
*/
void wlan_reset(cli_reset_option ResetOption);

#if defined(RW610)
#if defined(RW610) || defined(IW610)
/** Stop and remove all Wi-Fi network (access point).
*
* \return WM_SUCCESS if successful.
Expand Down Expand Up @@ -3422,7 +3422,6 @@ void wlan_subscribe_rssi_low_event(void);
#endif

#if CONFIG_HOST_SLEEP
#ifdef RW610
#if CONFIG_MEF_CFG
/** Wowlan (wake on wireless LAN) configuration.
* This function may be called to configure host sleep in firmware.
Expand Down Expand Up @@ -3460,7 +3459,6 @@ void wlan_config_host_sleep(bool is_manual, t_u8 is_periodic);
* \return kStatus_Success if successful else return -WM_FAIL.
*/
status_t wlan_hs_send_event(int id, void *data);
#endif /*RW610*/

/** Cancel host sleep.
* This function is called to cancel the host sleep in the firmware.
Expand Down Expand Up @@ -4062,14 +4060,6 @@ int wlan_get_tbtt_offset_stats(wlan_tbtt_offset_t *tbtt_offset);
*/
int wlan_set_packet_filters(wlan_flt_cfg_t *flt_cfg);

/**
* Use this API to enable ARP (address resolution protocol) offload in Wi-Fi firmware
*
* \return WM_SUCCESS if operation is successful.
* \return -WM_FAIL if command fails.
*/
int wlan_set_auto_arp(void);

#if CONFIG_AUTO_PING
/**
* Use this API to enable ping offload in Wi-Fi firmware.
Expand All @@ -4092,38 +4082,7 @@ int wlan_set_auto_ping(void);
int wlan_wowlan_cfg_ptn_match(wlan_wowlan_ptn_cfg_t *ptn_cfg);
#endif

/**
* Use this API to enable NS offload in Wi-Fi firmware.
*
* \return WM_SUCCESS if operation is successful.
* \return -WM_FAIL if command fails.
*/
int wlan_set_ipv6_ns_offload(void);

#if CONFIG_HOST_SLEEP

/** Use this API to set configuration before going to host sleep */
void wlan_hs_pre_cfg(void);

/** Use this API to get and print the reason of waking up from host sleep */
void wlan_hs_post_cfg(void);

/**
* Use this API to configure host sleep parameters in Wi-Fi firmware.
*
* \param[in] wakeup_condition: bit 0: WAKE_ON_ALL_BROADCAST
* bit 1: WAKE_ON_UNICAST
* bit 2: WAKE_ON_MAC_EVENT
* bit 3: WAKE_ON_MULTICAST
* bit 4: WAKE_ON_ARP_BROADCAST
* bit 6: WAKE_ON_MGMT_FRAME
* All bit 0 discard and not wakeup host
*
* \return WM_SUCCESS if operation is successful.
* \return -WM_FAIL if command fails.
*/
int wlan_send_host_sleep(uint32_t wakeup_condition);

/**
* Use this API to get host sleep wakeup reason from Wi-Fi firmware after waking up from host sleep by Wi-Fi.
*
Expand All @@ -4142,11 +4101,6 @@ int wlan_send_host_sleep(uint32_t wakeup_condition);
* \return -WM_FAIL if command fails.
*/
int wlan_get_wakeup_reason(uint16_t *hs_wakeup_reason);

#ifdef IW610
/** Use this API to register call back for host sleep confirm done*/
void wlan_register_hs_callback(void (*hs_notify_cb)(void));
#endif
#endif

/**
Expand Down Expand Up @@ -6734,6 +6688,19 @@ enum wlan_mef_type
*
*/
int wlan_mef_set_auto_arp(t_u8 mef_action);

/** This function set multicast packet as low power wake up condition.
*
* \param[in] mef_action: To be\n
* 0--discard multicast packet and not wake host\n
* 1--discard multicast packet and wake host\n
* 3--allow multicast packet and wake host.
*
* \return WM_SUCCESS if successful otherwise return -WM_FAIL.
*
*/
int wlan_mef_set_multicast(t_u8 mef_action);

/** This function set auto ping configuration.
*
* \param[in] mef_action: To be\n
Expand Down
36 changes: 35 additions & 1 deletion mcux/middleware/wifi_nxp/wifidriver/wifi-sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ uint8_t dev_mac_addr[MLAN_MAC_ADDR_LENGTH];
uint8_t dev_mac_addr_uap[MLAN_MAC_ADDR_LENGTH];
static uint8_t dev_fw_ver_ext[MLAN_MAX_VER_STR_LEN];

#if CONFIG_HOST_SLEEP
extern int is_hs_handshake_done;
extern bool skip_hs_handshake;
extern void wlan_hs_hanshake_cfg(bool skip);
#endif

static mlan_status wifi_send_fw_data(t_u8 *data, t_u32 txlen)
{
t_u32 tx_blocks = 0, buflen = 0;
Expand All @@ -119,6 +125,13 @@ static mlan_status wifi_send_fw_data(t_u8 *data, t_u32 txlen)
if (data == NULL || txlen == 0)
return MLAN_STATUS_FAILURE;

#if CONFIG_HOST_SLEEP
if (skip_hs_handshake == true)
{
wlan_hs_hanshake_cfg(false);
}
#endif

w_pkt_d("Data TX SIG: Driver=>FW, len %d", txlen);

calculate_sdio_write_params(txlen, &tx_blocks, &buflen);
Expand Down Expand Up @@ -1598,6 +1611,13 @@ int wlan_send_sdio_cmd(t_u8 *buf, t_u32 tx_blocks, t_u32 buflen)

(void)wifi_sdio_lock();

#if CONFIG_HOST_SLEEP
if (skip_hs_handshake == true)
{
wlan_hs_hanshake_cfg(false);
}
#endif

(void)memcpy((void *)outbuf, (const void *)buf, tx_blocks * buflen);
sdio->pkttype = MLAN_TYPE_CMD;
sdio->size = sdio->hostcmd.size + INTF_HEADER_LEN;
Expand Down Expand Up @@ -1713,6 +1733,13 @@ static mlan_status wifi_tx_data(t_u8 start_port, t_u8 ports, t_u8 pkt_cnt, t_u32
}
#endif

#if CONFIG_HOST_SLEEP
if (skip_hs_handshake == true)
{
wlan_hs_hanshake_cfg(false);
}
#endif

calculate_sdio_write_params(txlen, &tx_blocks, &buflen);

if (pkt_cnt == 1)
Expand Down Expand Up @@ -2639,6 +2666,13 @@ mlan_status wlan_process_int_status(mlan_adapter *pmadapter)
t_u32 pre_wr_bitmap = pmadapter->mp_wr_bitmap;
#endif

#if CONFIG_HOST_SLEEP
if (skip_hs_handshake == true)
{
wlan_hs_hanshake_cfg(false);
}
#endif

/* Get the interrupt status */
wlan_interrupt(pmadapter);

Expand Down Expand Up @@ -3137,7 +3171,7 @@ void wifi_print_wakeup_reason(t_u16 hs_wakeup_reason)
{
if (hs_wakeup_reason == 0)
{
PRINTF("Woken up by unknown reason\r\n");
PRINTF("Woken up by pin\r\n");
}
else if (hs_wakeup_reason == 1)
{
Expand Down
Loading