diff --git a/mcux/middleware/wifi_nxp/CMakeLists.txt b/mcux/middleware/wifi_nxp/CMakeLists.txt index 56c98a89f..5aa581b9a 100644 --- a/mcux/middleware/wifi_nxp/CMakeLists.txt +++ b/mcux/middleware/wifi_nxp/CMakeLists.txt @@ -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 diff --git a/mcux/middleware/wifi_nxp/incl/wlcmgr/wlan.h b/mcux/middleware/wifi_nxp/incl/wlcmgr/wlan.h index 8611d87d2..ce52d5265 100644 --- a/mcux/middleware/wifi_nxp/incl/wlcmgr/wlan.h +++ b/mcux/middleware/wifi_nxp/incl/wlcmgr/wlan.h @@ -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. @@ -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. @@ -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. @@ -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. @@ -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. * @@ -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 /** @@ -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 diff --git a/mcux/middleware/wifi_nxp/wifidriver/wifi-sdio.c b/mcux/middleware/wifi_nxp/wifidriver/wifi-sdio.c index be457dda0..40fb535d2 100644 --- a/mcux/middleware/wifi_nxp/wifidriver/wifi-sdio.c +++ b/mcux/middleware/wifi_nxp/wifidriver/wifi-sdio.c @@ -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; @@ -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); @@ -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; @@ -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) @@ -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); @@ -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) { diff --git a/mcux/middleware/wifi_nxp/wlcmgr/wlan.c b/mcux/middleware/wifi_nxp/wlcmgr/wlan.c index b76588b47..1cefd7c8f 100644 --- a/mcux/middleware/wifi_nxp/wlcmgr/wlan.c +++ b/mcux/middleware/wifi_nxp/wlcmgr/wlan.c @@ -250,7 +250,7 @@ extern WPS_DATA wps_global; } OSA_MUTEX_HANDLE_DEFINE(reset_lock); -#ifdef RW610 +#if defined(RW610) || defined(IW610) /* Mon thread */ static bool mon_thread_init = 0; #endif @@ -320,9 +320,6 @@ enum user_request_type CM_STA_USER_REQUEST_SCAN, #if (CONFIG_11K) || (CONFIG_11V) CM_STA_USER_REQUEST_SET_RSSI_THRESHOLD, -#endif -#if CONFIG_HOST_SLEEP - CM_STA_USER_REQUEST_HS, #endif CM_STA_USER_REQUEST_PS_ENTER, CM_STA_USER_REQUEST_PS_EXIT, @@ -433,7 +430,7 @@ static struct wps_config wps_conf = { .prov_session = PROV_NON_SESSION_ATTEMPT, }; #endif /* CONFIG_WPS2 */ -#ifdef RW610 +#if defined(RW610) || defined(IW610) static void wlcmgr_mon_task(osa_task_param_t arg); /* OSA_TASKS: name, priority, instances, stackSz, useFloat */ @@ -522,9 +519,6 @@ static struct bool cm_deepsleepps_configured : 1; bool connect_wakelock_taken : 1; unsigned int wakeup_conditions; -#if CONFIG_HOST_SLEEP - bool is_hs_configured : 1; -#endif #if CONFIG_MEF_CFG bool is_mef_enabled : 1; #endif @@ -584,7 +578,6 @@ static struct bool reassoc_control : 1; bool reassoc_request : 1; unsigned int reassoc_count; - bool hs_enabled; bool hs_configured; unsigned int hs_wakeup_condition; wifi_scan_chan_list_t scan_chan_list; @@ -627,9 +620,6 @@ static struct uint8_t rssi_low_threshold; #endif uint8_t ind_reset; -#if CONFIG_HOST_SLEEP - uint8_t hs_dummy_send; -#endif #if (CONFIG_WIFI_IND_RESET) && (CONFIG_WIFI_IND_DNLD) uint8_t ir_mode; #endif @@ -722,23 +712,6 @@ static void dbg_lock_info(void) /* * Utility Functions */ -#if CONFIG_HOST_SLEEP -#ifdef IW610 -void wlan_register_hs_callback(void (*hs_notify_cb)(void)) -{ - wlan_hs_notify_cb = hs_notify_cb; -} - -static void wlan_notify_hs_status() -{ - if (wlan_hs_notify_cb != NULL) - { - wlan_hs_notify_cb(); - } -} -#endif -#endif - int verify_scan_duration_value(int scan_duration) { if (scan_duration >= 50 && scan_duration <= 500) @@ -940,23 +913,26 @@ static int wlan_get_uap_ipv4_addr(unsigned int *ipv4_addr) static int wlan_set_pmfcfg(uint8_t mfpc, uint8_t mfpr); #if CONFIG_HOST_SLEEP -static int wlan_send_host_sleep_int(uint32_t wake_up_conds, bool is_config) +int wlan_send_host_sleep_int() { int ret = WM_SUCCESS; unsigned int ipv4_addr = 0; enum wlan_bss_type type = WLAN_BSS_TYPE_STA; + uint32_t wake_up_conds = wlan.wakeup_conditions; if (!wlan_is_started()) { (void)PRINTF("Wakeup condition configure is not allowed when WIFI is disabled\r\n"); - return -WM_FAIL; + ret = -WM_FAIL; + goto exit; } /* Check if wake_up_conds is valid or not */ if (wake_up_conds && (wake_up_conds != HOST_SLEEP_CFG_CANCEL) && (wake_up_conds & 0x20)) { (void)PRINTF("Invalid wake_up_conds. Bit 5 is reserved.\r\n"); - return -WM_FAIL; + ret = -WM_FAIL; + goto exit; } if (!is_sta_connected() @@ -970,78 +946,15 @@ static int wlan_send_host_sleep_int(uint32_t wake_up_conds, bool is_config) { wlcm_e("Connection on STA or uAP is required for configured bitmap!\r\n"); ret = -WM_FAIL; - return ret; + goto exit; } } - if (wake_up_conds == HOST_SLEEP_CFG_CANCEL) - { - wlan.hs_enabled = MFALSE; - wlan.hs_configured = MFALSE; - wlan.hs_wakeup_condition = wake_up_conds; -#if CONFIG_MEF_CFG - wlan.is_mef_enabled = MFALSE; - (void)memset(&g_flt_cfg, 0, sizeof(wlan_flt_cfg_t)); - wifi_set_packet_filters(&g_flt_cfg); -#endif - } #if CONFIG_CLOUD_KEEP_ALIVE - else if(is_config == MFALSE) - { - wlan_start_cloud_keep_alive(); - } + wlan_start_cloud_keep_alive(); #endif -#ifndef RW610 -#if CONFIG_MEF_CFG - if (wake_up_conds == HOST_SLEEP_COND_MEF) - { - wlan.hs_enabled = MTRUE; - wlan.hs_wakeup_condition = HOST_SLEEP_NO_COND; - if (g_flt_cfg.nentries == 0 && (is_config == MTRUE)) - { - (void)PRINTF("No user configured MEF entries, use default ARP filters.\r\n"); - /* User doesn't configure MEF, use default MEF entry */ - wlan_mef_set_auto_arp(MEF_ACTION_ALLOW_AND_WAKEUP_HOST); - } - if (wlan.is_mef_enabled == MFALSE) - { - wlan.is_mef_enabled = MTRUE; - wifi_set_packet_filters(&g_flt_cfg); - } - } - else -#endif -#endif - { - wlan.hs_enabled = MTRUE; - wlan.hs_wakeup_condition = wlan_map_to_wifi_wakeup_condtions(wake_up_conds); - if (wlan.hs_wakeup_condition & WIFI_WAKE_ON_MGMT_FRAME) - { - /* Set management frame wakeup filter config */ - mlan_adap->mgmt_filter[0].action = 0x3; /* not discard packet, wakeup host */ - mlan_adap->mgmt_filter[0].type = 0xff; /* management frames */ - mlan_adap->mgmt_filter[0].frame_mask = 0x3C0F; /* Frame-Mask bits : - : Bit 0 - Association Request(unmask) - : Bit 1 - Association Response(unmask) - : Bit 2 - Re-Association Request(unmask) - : Bit 3 - Re-Association Response(unmask) - : Bit 4 - Probe Request(mask) - : Bit 5 - Probe Response(mask) - : Bit 8 - Beacon Frames(mask) - : Bit 10 - Disassociation(unmask) - : Bit 11 - Authentication(unmask) - : Bit 12 - Deauthentication(unmask) - : Bit 13 - Action Frames(unmask) - */ - } - else - { - mlan_adap->mgmt_filter[0].action = 0x0; /* discard and not wakeup host */ - mlan_adap->mgmt_filter[0].type = 0xff; /* management frames */ - mlan_adap->mgmt_filter[0].frame_mask = 0x1400; /* Frame-Mask bits */ - } - } + wlan.hs_wakeup_condition = wlan_map_to_wifi_wakeup_condtions(wake_up_conds); if (is_sta_ipv4_connected() != 0) { @@ -1049,7 +962,8 @@ static int wlan_send_host_sleep_int(uint32_t wake_up_conds, bool is_config) if (ret != WM_SUCCESS) { wlcm_e("HS: cannot get STA IP, check if STA disconnected"); - return -WM_FAIL; + ret = -WM_FAIL; + goto exit; } } #if UAP_SUPPORT @@ -1059,7 +973,8 @@ static int wlan_send_host_sleep_int(uint32_t wake_up_conds, bool is_config) if (ret != WM_SUCCESS) { wlcm_e("HS: cannot get UAP IP, check if uAP stopped"); - return -WM_FAIL; + ret = -WM_FAIL; + goto exit; } type = WLAN_BSS_TYPE_UAP; } @@ -1069,61 +984,14 @@ static int wlan_send_host_sleep_int(uint32_t wake_up_conds, bool is_config) ipv4_addr = 0; } - if ( -#ifndef IW610 - wlan.hs_dummy_send == MFALSE || -#endif - is_config == MFALSE) - { - ret = wifi_send_hs_cfg_cmd((mlan_bss_type)type, ipv4_addr, HS_CONFIGURE, wlan.hs_wakeup_condition); - if (ret == WM_SUCCESS) - { - if (wake_up_conds != HOST_SLEEP_CFG_CANCEL) - { - wlan.hs_configured = MTRUE; - } - } - wlan.hs_dummy_send = MTRUE; - } - return ret; -} - -void wlan_hs_pre_cfg(void) -{ - if (wlan.hs_enabled == MTRUE) - { - (void)wlan_send_host_sleep_int(wlan.hs_wakeup_condition, MFALSE); -#ifndef IW610 - /** Wait for HS Activate to complete */ - OSA_TimeDelay(1000); -#endif - } -} - -void wlan_hs_post_cfg(void) -{ - uint16_t hs_wakeup_reason; - - if (wlan.hs_enabled == MTRUE) - { - (void)wifi_get_wakeup_reason(&hs_wakeup_reason); - - (void)wifi_print_wakeup_reason(hs_wakeup_reason); - } -} + wifi_send_hs_cfg_cmd((mlan_bss_type)type, ipv4_addr, HS_CONFIGURE, wlan.hs_wakeup_condition); -int wlan_send_host_sleep(uint32_t wake_up_conds) -{ - if (!wlan.running) +exit: + if (ret != WM_SUCCESS) { - return WLAN_ERROR_STATE; + wlcm_e("Error: Failed to config host sleep"); } - - wakelock_get(); - - (void)send_user_request(CM_STA_USER_REQUEST_HS, wake_up_conds); - - return WM_SUCCESS; + return ret; } int wlan_get_wakeup_reason(uint16_t *hs_wakeup_reason) @@ -1134,7 +1002,7 @@ int wlan_get_wakeup_reason(uint16_t *hs_wakeup_reason) #endif #if CONFIG_HOST_SLEEP -#ifdef RW610 +#if defined(RW610) || defined(IW610) status_t wlan_hs_send_event(int id, void *data) { struct wlan_message msg; @@ -1260,8 +1128,6 @@ int wlan_wowlan_config(t_u32 wake_up_conds) void wlan_config_host_sleep(bool is_manual, t_u8 is_periodic) { - int ret = 0; - #if CONFIG_WMM_UAPSD if (mlan_adap && mlan_adap->pps_uapsd_mode) { @@ -1295,21 +1161,6 @@ void wlan_config_host_sleep(bool is_manual, t_u8 is_periodic) wakelock_put(); } #endif - if (wlan.status == WLCMGR_ACTIVATED) - { -#if CONFIG_HOST_SLEEP - /* Start host sleep handshake here if manual mode is selected */ - ret = wlan_send_host_sleep_int(wlan.wakeup_conditions, MFALSE); - if (ret != WM_SUCCESS) - { -#if CONFIG_NCP_BRIDGE - app_notify_event(APP_EVT_HS_CONFIG, APP_EVT_REASON_FAILURE, NULL, 0); -#endif - wlcm_e("Error: Failed to config host sleep"); - return; - } -#endif - } } } @@ -1360,7 +1211,6 @@ void wlan_clear_host_sleep_config(void) wakeup_by = 0; wifi_clear_wakeup_reason(); wlan.wakeup_conditions = 0; - wlan.is_hs_configured = MFALSE; } #endif @@ -6831,18 +6681,6 @@ static void wlcm_set_rssi_low_threshold(enum cm_sta_state *next, struct wlan_net } #endif -#if CONFIG_HOST_SLEEP -static void wlcm_send_host_sleep(struct wifi_message *msg, enum cm_sta_state *next, struct wlan_network *network) -{ - uint32_t wake_up_conds = (uint32_t)msg->data; - - (void)next; - (void)network; - - (void)wlan_send_host_sleep_int(wake_up_conds, MTRUE); -} -#endif - #if CONFIG_WIFI_CHANNEL_LOAD static void wlcm_process_chan_load(void *ch_load) { @@ -6991,11 +6829,6 @@ static enum cm_sta_state handle_message(struct wifi_message *msg) case CM_STA_USER_REQUEST_SET_RSSI_THRESHOLD: wlcm_set_rssi_low_threshold(&next, network); break; -#endif -#if CONFIG_HOST_SLEEP - case CM_STA_USER_REQUEST_HS: - wlcm_send_host_sleep(msg, &next, network); - break; #endif case CM_STA_USER_REQUEST_PS_ENTER: #if CONFIG_WIFI_NM_WPA_SUPPLICANT @@ -7191,22 +7024,15 @@ static enum cm_sta_state handle_message(struct wifi_message *msg) #if CONFIG_HOST_SLEEP case WIFI_EVENT_HS_ACTIVATED: case WIFI_EVENT_SLEEP_CONFIRM_DONE: - if (wlan.hs_configured == MTRUE) - { - wlan.hs_configured = MFALSE; #if CONFIG_POWER_MANAGER - if (!wlan_is_manual) - { - is_hs_handshake_done = WLAN_HOSTSLEEP_SUCCESS; + if (!wlan_is_manual) + { + is_hs_handshake_done = WLAN_HOSTSLEEP_SUCCESS; #ifdef RW610 - (void)OSA_TimerDeactivate((osa_timer_handle_t)temperature_mon_timer); -#endif - } -#endif -#ifdef IW610 - wlan_notify_hs_status(); + (void)OSA_TimerDeactivate((osa_timer_handle_t)temperature_mon_timer); #endif } +#endif break; #endif #if (CONFIG_11K) || (CONFIG_11V) @@ -8189,6 +8015,7 @@ int wlan_start(int (*cb)(enum wlan_event_reason reason, void *data)) } mon_thread_init = 1; } +#ifdef RW610 wifi_cau_temperature_enable(); status = OSA_TimerCreate((osa_timer_handle_t)temperature_mon_timer, TEMPERATURE_MON_TIMEOUT, &temperature_mon_cb, NULL, KOSA_TimerPeriodic, OSA_TIMER_AUTO_ACTIVATE); @@ -8196,6 +8023,7 @@ int wlan_start(int (*cb)(enum wlan_event_reason reason, void *data)) { wlcm_e("Unable to create temperature monitor timer"); } +#endif #endif wlan.running = 1; @@ -10753,7 +10581,7 @@ void wlan_reset(cli_reset_option ResetOption) PRINTF("--- Done ---\r\n"); } -#if defined(RW610) +#if defined(RW610) || defined(IW610) #if CONFIG_HOST_SLEEP void wlan_hs_hanshake_cfg(bool skip) { @@ -10799,7 +10627,7 @@ static void wlcmgr_mon_task(void * data) wlcm_d("got mon thread event: %d", msg.id); if (msg.id == HOST_SLEEP_HANDSHAKE) { - ret = wlan_send_host_sleep_int(wlan.wakeup_conditions, MFALSE); + ret = wlan_send_host_sleep_int(); if (ret != WM_SUCCESS) { is_hs_handshake_done = WLAN_HOSTSLEEP_FAIL; @@ -10815,11 +10643,19 @@ static void wlcmgr_mon_task(void * data) (void)OSA_TimerActivate((osa_timer_handle_t)wake_timer); } #endif +#endif +#ifdef IW610 + uint16_t hs_wakeup_reason = 0; + (void)wifi_get_wakeup_reason(&hs_wakeup_reason); + (void)wifi_print_wakeup_reason(hs_wakeup_reason); + wifi_clear_wakeup_reason(); #endif wlan_cancel_host_sleep(); +#ifdef RW610 /* Check fw status and write temperature to firmware after waking up */ temperature_mon_cb(NULL); (void)OSA_TimerActivate((osa_timer_handle_t)temperature_mon_timer); +#endif } #ifndef CONFIG_BT else if (msg.id == HOST_SLEEP_HANDSHAKE_SKIP) @@ -12544,52 +12380,6 @@ int wlan_set_packet_filters(wlan_flt_cfg_t *flt_cfg) return wifi_set_packet_filters(flt_cfg); } -int wlan_set_auto_arp(void) -{ - int ret; - unsigned int ipv4_addr; - wlan_flt_cfg_t flt_cfg; - - ret = wlan_get_ipv4_addr(&ipv4_addr); - if (ret != WM_SUCCESS) - { - wlcm_e("Cannot get IP"); - return -WM_FAIL; - } - - (void)memset(&flt_cfg, 0, sizeof(wlan_flt_cfg_t)); - - flt_cfg.criteria = CRITERIA_BROADCAST; - flt_cfg.nentries = 1; - - flt_cfg.mef_entry[0].mode = MEF_MODE_HOST_SLEEP; // MBIT(0); - flt_cfg.mef_entry[0].action = MEF_AUTO_ARP; - - flt_cfg.mef_entry[0].filter_num = 3; - - flt_cfg.mef_entry[0].filter_item[0].type = TYPE_BYTE_EQ; - flt_cfg.mef_entry[0].filter_item[0].repeat = 6; - flt_cfg.mef_entry[0].filter_item[0].offset = 0; - flt_cfg.mef_entry[0].filter_item[0].num_byte_seq = 1; - flt_cfg.mef_entry[0].filter_item[0].byte_seq[0] = 0xff; - flt_cfg.mef_entry[0].rpn[1] = RPN_TYPE_AND; - - flt_cfg.mef_entry[0].filter_item[1].type = TYPE_BYTE_EQ; - flt_cfg.mef_entry[0].filter_item[1].repeat = 1; - flt_cfg.mef_entry[0].filter_item[1].offset = 20; - flt_cfg.mef_entry[0].filter_item[1].num_byte_seq = 2; - (void)memcpy((void *)flt_cfg.mef_entry[0].filter_item[1].byte_seq, (const void *)"\x08\x06", 2); - flt_cfg.mef_entry[0].rpn[2] = RPN_TYPE_AND; - - flt_cfg.mef_entry[0].filter_item[2].type = TYPE_BYTE_EQ; - flt_cfg.mef_entry[0].filter_item[2].repeat = 1; - flt_cfg.mef_entry[0].filter_item[2].offset = 46; - flt_cfg.mef_entry[0].filter_item[2].num_byte_seq = 4; - (void)memcpy((void *)flt_cfg.mef_entry[0].filter_item[2].byte_seq, (const void *)&ipv4_addr, 4); - - return wifi_set_packet_filters(&flt_cfg); -} - #if !CONFIG_WPA_SUPP static inline bool is_broadcast_ether_addr(const t_u8 *addr) { @@ -12772,36 +12562,6 @@ int wlan_set_auto_ping(void) } #endif /* CONFIG_AUTO_PING */ -int wlan_set_ipv6_ns_offload(void) -{ - wlan_flt_cfg_t flt_cfg; - - (void)memset(&flt_cfg, 0, sizeof(wlan_flt_cfg_t)); - - flt_cfg.criteria = (MBIT(1) | MBIT(3)); - flt_cfg.nentries = 1; - - flt_cfg.mef_entry[0].mode = MBIT(0); - flt_cfg.mef_entry[0].action = 0x40; - - flt_cfg.mef_entry[0].filter_num = 2; - - flt_cfg.mef_entry[0].filter_item[0].type = TYPE_BYTE_EQ; - flt_cfg.mef_entry[0].filter_item[0].repeat = 1; - flt_cfg.mef_entry[0].filter_item[0].offset = 20; - flt_cfg.mef_entry[0].filter_item[0].num_byte_seq = 2; - (void)memcpy((void *)flt_cfg.mef_entry[0].filter_item[0].byte_seq, (const void *)"\x86\xdd", 2); - flt_cfg.mef_entry[0].rpn[1] = RPN_TYPE_AND; - - flt_cfg.mef_entry[0].filter_item[1].type = TYPE_BYTE_EQ; - flt_cfg.mef_entry[0].filter_item[1].repeat = 1; - flt_cfg.mef_entry[0].filter_item[1].offset = 62; - flt_cfg.mef_entry[0].filter_item[1].num_byte_seq = 1; - (void)memcpy((void *)flt_cfg.mef_entry[0].filter_item[1].byte_seq, (const void *)"\x87", 1); - - return wifi_set_packet_filters(&flt_cfg); -} - int wlan_get_current_bssid(uint8_t *bssid) { struct wlan_network* network = NULL; diff --git a/mcux/middleware/wifi_nxp/wlcmgr/wlan_features.c b/mcux/middleware/wifi_nxp/wlcmgr/wlan_features.c index b61d3e694..0fc416445 100644 --- a/mcux/middleware/wifi_nxp/wlcmgr/wlan_features.c +++ b/mcux/middleware/wifi_nxp/wlcmgr/wlan_features.c @@ -17,29 +17,7 @@ #if CONFIG_WIFI_FEATURES #ifdef ENABLE_OFFLOAD -static void test_wlan_ns_offload(int argc, char **argv) -{ - int ret = -WM_FAIL; - ret = wlan_set_ipv6_ns_offload(); - if (ret == WM_SUCCESS) - { - (void)PRINTF("Enabled wlan IPv6 NS offload feature"); - } - else - { - (void)PRINTF("Failed to enabled wlan auto arp offload, error: %d", ret); - } -} -static void test_wlan_auto_arp(int argc, char **argv) -{ - int ret = -WM_FAIL; - ret = wlan_set_auto_arp(); - if (ret == WM_SUCCESS) - (void)PRINTF("Enabled wlan auto arp offload feature\r\n"); - else - (void)PRINTF("Failed to enabled wlan auto arp offload, error: %d\r\n", ret); -} #if (CONFIG_HOST_SLEEP && CONFIG_MEF_CFG) static void dump_wlan_add_packet_filter() { @@ -103,8 +81,6 @@ static void test_wlan_add_packet_filter(int argc, char **argv) #endif static struct cli_command features[] = { - {"enable-ns-offload", NULL, test_wlan_ns_offload}, - {"wlan-auto-arp", NULL, test_wlan_auto_arp}, #if (CONFIG_HOST_SLEEP && CONFIG_MEF_CFG) {"wlan-add-packet-filter", "0/1 ...........", test_wlan_add_packet_filter}, diff --git a/mcux/middleware/wifi_nxp/wlcmgr/wlan_tests.c b/mcux/middleware/wifi_nxp/wlcmgr/wlan_tests.c index c82d29352..4a87c672d 100644 --- a/mcux/middleware/wifi_nxp/wlcmgr/wlan_tests.c +++ b/mcux/middleware/wifi_nxp/wlcmgr/wlan_tests.c @@ -50,8 +50,10 @@ wlan_host_tx_frame_params_t *pmgmtframe_tx_param = NULL; #endif #if CONFIG_HOST_SLEEP +#if defined(RW610) extern uint64_t rtc_timeout; #endif +#endif extern char *net_sprint_addr(sa_family_t af, const void *addr); #if defined(RW610) extern int wlan_send_hostcmd(const void *cmd_buf, uint32_t cmd_buf_len, void *host_resp_buf, uint32_t resp_buf_len, uint32_t *reqd_resp_len); @@ -1996,7 +1998,6 @@ static void test_wlan_set_multiple_mef_config(int argc, char **argv) #endif #if CONFIG_HOST_SLEEP -#ifdef RW610 static void test_wlan_wakeup_condition(int argc, char **argv) { #if CONFIG_MEF_CFG @@ -2075,129 +2076,14 @@ static void test_wlan_wakeup_condition(int argc, char **argv) #endif return; } -#endif /*RW610*/ #if CONFIG_MEF_CFG extern wlan_flt_cfg_t g_flt_cfg; #endif -#ifndef RW610 -static void test_wlan_host_sleep(int argc, char **argv) -{ - int choice = -1, wowlan = 0; - int ret = -WM_FAIL; - - if ((argc < 2) || (argc > 4)) - { - goto done; - } - - errno = 0; - choice = (int)strtol(argv[1], NULL, 10); - if (errno != 0) - { - (void)PRINTF("Error during strtol:host_sleep errno:%d\r\n", errno); - goto done; - } - if ((choice != 0) && (choice != 1)) - { - goto done; - } - - if (choice == 0) - { - ret = wlan_send_host_sleep(HOST_SLEEP_CFG_CANCEL); - if (ret == WM_SUCCESS) - { - (void)PRINTF("Cancel Previous configured Host sleep configuration"); - } - else - { - (void)PRINTF("Failed to Cancel Previous configured Host sleep configuration, error: %d", ret); - } - } - else if (choice == 1) - { -#if CONFIG_MEF_CFG - if (argc < 3) -#else - if (argc < 4) -#endif - { - goto done; - } - - if (string_equal(argv[2], "wowlan")) - { - errno = 0; - wowlan = (int)strtol(argv[3], NULL, 16); - if (errno != 0) - { - (void)PRINTF("Error during strtol:wowlan errno:%d\r\n", errno); - return; - } - - ret = wlan_send_host_sleep(wowlan); - if (ret == WM_SUCCESS) - { - (void)PRINTF("Host sleep configuration req sent"); - } - else - { - (void)PRINTF("Failed to host sleep configuration, error: %d", ret); - } - } -#if CONFIG_MEF_CFG - else if (string_equal(argv[2], "mef")) - { - ret = wlan_send_host_sleep(HOST_SLEEP_COND_MEF); - if (ret == WM_SUCCESS) - { - (void)PRINTF("Host sleep configuration successs with MEF"); - } - else - { - (void)PRINTF("Failed to host sleep configuration, error: %d", ret); - } - } -#endif - else - { - goto done; - } - } - else - { - done: - (void)PRINTF("Error: invalid number of arguments\r\n"); - (void)PRINTF("Usage:\r\n"); - (void)PRINTF(" wlan-host-sleep <1/0> \r\n"); - (void)PRINTF(" [wake_up_conds] -- value for host wakeup conditions\r\n"); - (void)PRINTF(" bit 0: WAKE_ON_ALL_BROADCAST\r\n"); - (void)PRINTF(" bit 1: WAKE_ON_UNICAST\r\n"); - (void)PRINTF(" bit 2: WAKE_ON_MAC_EVENT\r\n"); - (void)PRINTF(" bit 3: WAKE_ON_MULTICAST\r\n"); - (void)PRINTF(" bit 4: WAKE_ON_ARP_BROADCAST\r\n"); - (void)PRINTF(" bit 6: WAKE_ON_MGMT_FRAME\r\n"); - (void)PRINTF(" All bit 0 discard and not wakeup host\r\n"); -#if CONFIG_MEF_CFG - (void)PRINTF(" mef -- MEF host wakeup\r\n"); -#endif - (void)PRINTF("Example:\r\n"); -#if CONFIG_MEF_CFG - (void)PRINTF(" wlan-host-sleep <1/0> mef\r\n"); -#endif - (void)PRINTF(" wlan-host-sleep <1/0> wowlan 0x1e\r\n"); - return; - } -} -#endif - -#ifdef RW610 #if !(CONFIG_WIFI_BLE_COEX_APP) static void test_wlan_auto_host_sleep(int argc, char **argv) { - bool is_manual = MFALSE; t_u8 is_periodic = 0; t_u8 enable = 0; @@ -2235,33 +2121,9 @@ static void test_wlan_auto_host_sleep(int argc, char **argv) return; } is_periodic = (t_u8)atoi(argv[2]); - wlan_config_host_sleep(is_manual, is_periodic); + wlan_config_host_sleep(false, is_periodic); } #endif /* CONFIG_WIFI_BLE_COEX_APP */ -#else -static void test_wlan_ns_offload(int argc, char **argv) -{ - int ret = -WM_FAIL; - ret = wlan_set_ipv6_ns_offload(); - if (ret == WM_SUCCESS) - { - (void)PRINTF("Enabled wlan IPv6 NS offload feature"); - } - else - { - (void)PRINTF("Failed to enabled wlan auto arp offload, error: %d", ret); - } -} - -static void test_wlan_auto_arp(int argc, char **argv) -{ - int ret = -WM_FAIL; - ret = wlan_set_auto_arp(); - if (ret == WM_SUCCESS) - (void)PRINTF("Enabled wlan auto arp offload feature\r\n"); - else - (void)PRINTF("Failed to enabled wlan auto arp offload, error: %d\r\n", ret); -} #if CONFIG_MEF_CFG static void dump_wlan_add_packet_filter() @@ -2270,12 +2132,12 @@ static void dump_wlan_add_packet_filter() (void)PRINTF("For wowlan Add packet filter\r\n"); (void)PRINTF("wowlan magic filter:\r\n"); (void)PRINTF("wlan_add_packet_filter 1:\r\n"); - (void)PRINTF("wowlan User defined pattren packet filter:\r\n"); + (void)PRINTF("wowlan User defined pattern packet filter:\r\n"); (void)PRINTF("wlan_add_packet_filter 0 ........:\r\n"); (void)PRINTF( "For 2 number of patterns Usage \r\nwlan_add_packet_filter 0 2 6 0 0xff 0xff 0xff 0xff 0xff 0xff 4 20 192 168 " "10 1\r\n"); - (void)PRINTF("wowlan User defined pattren and magic packet filter:\r\n"); + (void)PRINTF("wowlan User defined pattern and magic packet filter:\r\n"); (void)PRINTF("wlan_add_packet_filter 1 ........:\r\n"); (void)PRINTF( "For 2 number of patterns Usage \r\nwlan_add_packet_filter 1 2 6 0 0xff 0xff 0xff 0xff 0xff 0xff 4 20 192 168 " @@ -2300,11 +2162,11 @@ static void test_wlan_add_packet_filter(int argc, char **argv) if (string_equal("sta", argv[1])) { - bss_type = MLAN_BSS_TYPE_STA; + bss_type = WLAN_BSS_TYPE_STA; } else if (string_equal("uap", argv[1])) { - bss_type = MLAN_BSS_TYPE_UAP; + bss_type = WLAN_BSS_TYPE_UAP; } else { @@ -2335,6 +2197,13 @@ static void test_wlan_add_packet_filter(int argc, char **argv) (void)memset(&wowlan_ptn_cfg, 0, sizeof(wlan_wowlan_ptn_cfg_t)); wowlan_ptn_cfg.enable = atoi(argv[2]); + if((0 == wowlan_ptn_cfg.enable) && (argc < 7)) + { + (void)PRINTF("Need to add user defined pattern packet filter\r\n"); + dump_wlan_add_packet_filter(); + return; + } + if (argc > 3) { wowlan_ptn_cfg.n_patterns = atoi(argv[3]); @@ -2358,7 +2227,6 @@ static void test_wlan_add_packet_filter(int argc, char **argv) (void)PRINTF("Failed to enabled magic pkt filter offload, error: %d", ret); } #endif /* CONFIG_MEF_CFG */ -#endif /*RW610*/ #endif /* CONFIG_HOST_SLEEP */ #define HOSTCMD_RESP_BUFF_SIZE 1024 @@ -8990,26 +8858,16 @@ static struct cli_command tests[] = { {"wlan-multi-mef", " []", test_wlan_set_multiple_mef_config}, #endif #if CONFIG_HOST_SLEEP -#ifdef RW610 #if CONFIG_MEF_CFG {"wlan-wakeup-condition", "", test_wlan_wakeup_condition}, + {"wlan-add-packet-filter", " sta/uap 0/1 ...........", + test_wlan_add_packet_filter}, #else {"wlan-wakeup-condition", "", test_wlan_wakeup_condition}, #endif /*CONFIG_MEF_CFG*/ #if !defined(CONFIG_WIFI_BLE_COEX_APP) {"wlan-auto-host-sleep", " ", test_wlan_auto_host_sleep}, #endif -#else - {"enable-ns-offload", NULL, test_wlan_ns_offload}, - {"wlan-auto-arp", NULL, test_wlan_auto_arp}, -#if CONFIG_MEF_CFG - {"wlan-add-packet-filter", "0/1 ...........", - test_wlan_add_packet_filter}, - {"wlan-host-sleep", "<0/1> mef/wowlan ", test_wlan_host_sleep}, -#else - {"wlan-host-sleep", "<0/1> wowlan ", test_wlan_host_sleep}, -#endif /*CONFIG_MEF_CFG*/ -#endif /*RW610*/ #endif /*CONFIG_HOST_SLEEP*/ {"wlan-send-hostcmd", NULL, test_wlan_send_hostcmd}, #if defined(RW610) || defined(SD9177) || defined(IW610)