From 26246bf60afa613272156fa268e4ff99f5d810ae Mon Sep 17 00:00:00 2001 From: Sherry Sun Date: Sat, 26 Aug 2023 15:35:06 +0800 Subject: [PATCH] mxm_wifiex: update to mxm6x17408.p2 release Corresponding firmware version: SDIO-UART W8987 Firmware version 16.92.21.p99.2 PCIE-UART W8997 Firmware version 16.92.21.p84.4 SDIO-UART W8997 Firmware version 16.92.21.p84.4 SDIO-UART IW416 Firmware version 16.92.21.p84.3 SDIO_UART IW612 Firmware version 18.99.2.p19.15 SDIO-UART W8801 Firmware version 14.92.36.p182 SDIO-UART W9098 Firmware version 17.92.1.p136.131 PCIE-UART W9098 Firmware version 17.92.1.p136.131 Signed-off-by: Sherry Sun --- mxm_wifiex/wlan_src/README | 2 + mxm_wifiex/wlan_src/mlan/mlan_cmdevt.c | 6 +- mxm_wifiex/wlan_src/mlan/mlan_decl.h | 6 +- mxm_wifiex/wlan_src/mlan/mlan_fw.h | 29 +++ mxm_wifiex/wlan_src/mlan/mlan_init.c | 1 + mxm_wifiex/wlan_src/mlan/mlan_ioctl.h | 5 + mxm_wifiex/wlan_src/mlan/mlan_join.c | 28 ++- mxm_wifiex/wlan_src/mlan/mlan_main.h | 11 + mxm_wifiex/wlan_src/mlan/mlan_misc.c | 26 +++ mxm_wifiex/wlan_src/mlan/mlan_sdio.c | 4 +- mxm_wifiex/wlan_src/mlan/mlan_sta_event.c | 53 ++++- mxm_wifiex/wlan_src/mlan/mlan_sta_ioctl.c | 3 + mxm_wifiex/wlan_src/mlan/mlan_sta_rx.c | 7 + mxm_wifiex/wlan_src/mlan/mlan_sta_tx.c | 5 + mxm_wifiex/wlan_src/mlan/mlan_txrx.c | 54 +++++ mxm_wifiex/wlan_src/mlan/mlan_uap_cmdevent.c | 13 ++ mxm_wifiex/wlan_src/mlan/mlan_uap_txrx.c | 27 ++- mxm_wifiex/wlan_src/mlan/mlan_wmm.c | 9 +- mxm_wifiex/wlan_src/mlinux/mlan_decl.h | 6 +- mxm_wifiex/wlan_src/mlinux/mlan_ioctl.h | 5 + mxm_wifiex/wlan_src/mlinux/moal_cfg80211.h | 4 + .../wlan_src/mlinux/moal_cfg80211_util.c | 5 + mxm_wifiex/wlan_src/mlinux/moal_eth_ioctl.c | 120 ++++++++++ mxm_wifiex/wlan_src/mlinux/moal_eth_ioctl.h | 3 + mxm_wifiex/wlan_src/mlinux/moal_ioctl.c | 42 ++++ mxm_wifiex/wlan_src/mlinux/moal_main.c | 160 ++++++++++++- mxm_wifiex/wlan_src/mlinux/moal_main.h | 33 +++ mxm_wifiex/wlan_src/mlinux/moal_shim.c | 48 ++++ .../wlan_src/mlinux/moal_sta_cfg80211.c | 158 ++++++++++++- mxm_wifiex/wlan_src/mlinux/moal_uap.c | 55 +++++ mxm_wifiex/wlan_src/mlinux/moal_uap.h | 6 + .../wlan_src/mlinux/moal_uap_cfg80211.c | 218 ++++++++++++++++++ mxm_wifiex/wlan_src/mlinux/moal_uap_priv.c | 10 + mxm_wifiex/wlan_src/mlinux/moal_uap_priv.h | 5 + mxm_wifiex/wlan_src/mlinux/moal_uap_wext.c | 4 + 35 files changed, 1145 insertions(+), 26 deletions(-) diff --git a/mxm_wifiex/wlan_src/README b/mxm_wifiex/wlan_src/README index df7ead3..4574419 100644 --- a/mxm_wifiex/wlan_src/README +++ b/mxm_wifiex/wlan_src/README @@ -505,6 +505,8 @@ #ifdef TX_POWERCFG txpwrlimit_cfg= e.g. copy txpwrlimit_cfg_set.conf to firmware directory, txpwrlimit_cfg=nxp/txpwrlimit_cfg_set.conf + txpwrlimit_cfg_set.conf file should be the binary format file generate by mlanutl application + #ifdef OTP_CHANINFO cntry_txpwr=0|1|2 #else diff --git a/mxm_wifiex/wlan_src/mlan/mlan_cmdevt.c b/mxm_wifiex/wlan_src/mlan/mlan_cmdevt.c index 2e144df..094ddfd 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_cmdevt.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_cmdevt.c @@ -8811,7 +8811,7 @@ static void wlan_fill_link_statistic(mlan_private *priv, .get_link_statistic; /* TLV parse */ - if (resp->size > (sizeof(HostCmd_DS_802_11_LINK_STATISTIC) - S_DS_GEN)) + if (resp->size > (sizeof(HostCmd_DS_802_11_LINK_STATISTIC) + S_DS_GEN)) left_len = resp->size - sizeof(HostCmd_DS_802_11_LINK_STATISTIC) - S_DS_GEN; @@ -8820,6 +8820,10 @@ static void wlan_fill_link_statistic(mlan_private *priv, while (left_len > sizeof(MrvlIEtypesHeader_t)) { tlv_type = wlan_le16_to_cpu(tlv->type); tlv_len = wlan_le16_to_cpu(tlv->len); + if (left_len < (tlv_len + sizeof(MrvlIEtypesHeader_t))) { + PRINTM(MERROR, "Invalid link statistic tlv\n"); + break; + } switch (tlv_type) { case TLV_TYPE_LL_STAT_IFACE: fw_ifaceStat = (mlan_wifi_iface_stat diff --git a/mxm_wifiex/wlan_src/mlan/mlan_decl.h b/mxm_wifiex/wlan_src/mlan/mlan_decl.h index fee793e..8de713d 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_decl.h +++ b/mxm_wifiex/wlan_src/mlan/mlan_decl.h @@ -24,7 +24,7 @@ #define _MLAN_DECL_H_ /** MLAN release version */ -#define MLAN_RELEASE_VERSION "408" +#define MLAN_RELEASE_VERSION "408.p2" /** Re-define generic data types for MLAN/MOAL */ /** Signed char (1-byte) */ @@ -621,6 +621,8 @@ typedef enum { #define MLAN_BUF_FLAG_TX_CTRL MBIT(14) +#define MLAN_BUF_FLAG_EASYMESH MBIT(16) + #define MLAN_BUF_FLAG_MC_AGGR_PKT MBIT(17) #ifdef DEBUG_LEVEL1 @@ -1335,6 +1337,8 @@ typedef struct _mlan_buffer { t_u32 extra_ts_sec; /** Time stamp when packet is dequed from rx_q(micro seconds) */ t_u32 extra_ts_usec; + /** When TX ra mac address, When Rx Ta mac address*/ + t_u8 mac[MLAN_MAC_ADDR_LENGTH]; /** Fields below are valid for MLAN module only */ /** Pointer to parent mlan_buffer */ struct _mlan_buffer *pparent; diff --git a/mxm_wifiex/wlan_src/mlan/mlan_fw.h b/mxm_wifiex/wlan_src/mlan/mlan_fw.h index 69d50d1..fe0e7ec 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_fw.h +++ b/mxm_wifiex/wlan_src/mlan/mlan_fw.h @@ -334,6 +334,9 @@ typedef enum _WLAN_802_11_WEP_STATUS { /**TLV type : Host MLME Flag*/ #define TLV_TYPE_HOST_MLME (PROPRIETARY_TLV_BASE_ID + 307) +/** TLV type: MULTI AP Flag */ +#define TLV_TYPE_MULTI_AP (PROPRIETARY_TLV_BASE_ID + 326) + /** TLV type : AP wacp mode */ #define TLV_TYPE_UAP_WACP_MODE (PROPRIETARY_TLV_BASE_ID + 0x147) /* 0x0247 */ @@ -1607,6 +1610,8 @@ enum wls_event_subtype { /** TDLS off channel */ #define TDLS_OFF_CHANNEL 1 +#define RXPD_FLAG_PKT_EASYMESH MBIT(4) + /** structure for channel switch result from TDLS FW */ typedef MLAN_PACK_START struct _chan_switch_result { /** current channel, 0 - base channel, 1 - off channel*/ @@ -1724,6 +1729,9 @@ typedef MLAN_PACK_START struct _MrvlIEtypes_TDLS_Idle_Timeout_t { /** Bit mask for TxPD flags field for Tx status report */ #define MRVDRV_TxPD_FLAGS_TX_PACKET_STATUS MBIT(5) +/** Bit mask for TxPD flags field for EASYMESH */ +#define MRVDRV_TxPD_FLAGS_EASYMESH MBIT(7) + /** Packet type: 802.11 */ #define PKT_TYPE_802DOT11 0x05 @@ -1863,6 +1871,9 @@ typedef MLAN_PACK_START struct _TxPD { t_u8 reserved; /** Tx Control */ t_u32 tx_control_1; + /** ra mac address */ + t_u8 ra_mac[6]; + t_u8 reserved3[2]; } MLAN_PACK_END TxPD, *PTxPD; /** RxPD Descriptor */ @@ -1908,6 +1919,8 @@ typedef MLAN_PACK_START struct _RxPD { /** Reserved */ t_u8 reserved3[8]; + t_u8 ta_mac[6]; + t_u8 reserved4[2]; } MLAN_PACK_END RxPD, *PRxPD; /** IEEEtypes_FrameCtl_t*/ @@ -2213,6 +2226,14 @@ typedef MLAN_PACK_START struct _MrvlIEtypes_HostMlme_t { t_u8 host_mlme; } MLAN_PACK_END MrvlIEtypes_HostMlme_t; +/** MrvlIEtypes_MultiAp_t */ +typedef MLAN_PACK_START struct _MrvlIEtypes_MultiAp_t { + /** Header */ + MrvlIEtypesHeader_t header; + /** Multi AP flag */ + t_u8 flag; +} MLAN_PACK_END MrvlIEtypes_MultiAp_t; + /** MrvlIEtypes_NumProbes_t */ typedef MLAN_PACK_START struct _MrvlIEtypes_NumProbes_t { /** Header */ @@ -7255,6 +7276,14 @@ typedef MLAN_PACK_START struct _HostCmd_DS_STA_CONFIGURE { t_u8 tlv_buffer[]; /**MrvlIEtypes_channel_band_t band_channel; */ } MLAN_PACK_END HostCmd_DS_STA_CONFIGURE; + +/** Event_Link_Lost structure */ +typedef MLAN_PACK_START struct _Event_Link_Lost { + /** Reason code */ + t_u16 reason_code; + /** bssid of Link Lost AP */ + t_u8 bssid[MLAN_MAC_ADDR_LENGTH]; +} MLAN_PACK_END Event_Link_Lost; #endif /** HostCmd_DS_AUTO_TX structure */ diff --git a/mxm_wifiex/wlan_src/mlan/mlan_init.c b/mxm_wifiex/wlan_src/mlan/mlan_init.c index 4ffeaee..a27dcba 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_init.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_init.c @@ -615,6 +615,7 @@ mlan_status wlan_init_priv(pmlan_private priv) priv->hotspot_cfg = 0; priv->intf_hr_len = pmadapter->ops.intf_header_len; + priv->multi_ap_flag = 0; memset(pmadapter, &priv->chan_rep_req, 0, sizeof(priv->chan_rep_req)); #ifdef USB if (IS_USB(pmadapter->card_type)) { diff --git a/mxm_wifiex/wlan_src/mlan/mlan_ioctl.h b/mxm_wifiex/wlan_src/mlan/mlan_ioctl.h index a4dce18..b234715 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_ioctl.h +++ b/mxm_wifiex/wlan_src/mlan/mlan_ioctl.h @@ -357,6 +357,7 @@ enum _mlan_ioctl_req_id { MLAN_OID_MISC_TP_STATE = 0x0020007D, MLAN_OID_MISC_HAL_PHY_CFG = 0x0020007E, MLAN_OID_MISC_RF_TEST_HE_POWER = 0X0020007F, + MLAN_OID_MISC_MULTI_AP_CFG = 0x00200080, #ifdef UAP_SUPPORT MLAN_OID_MISC_WACP_MODE = 0x00200081, #endif @@ -1185,6 +1186,8 @@ typedef struct _mlan_uap_bss_param { /** uap host based config */ t_u32 uap_host_based_config; + /** multi ap flag */ + t_u8 multi_ap_flag; } mlan_uap_bss_param, *pmlan_uap_bss_param; /** mlan_uap_scan_channels */ @@ -6188,6 +6191,8 @@ typedef struct _mlan_ds_misc_cfg { #endif /** Hotspot config param set */ t_u32 hotspot_cfg; + /** Multi AP flag */ + t_u8 multi_ap_flag; #ifdef STA_SUPPORT ExtCap_t ext_cap; #endif diff --git a/mxm_wifiex/wlan_src/mlan/mlan_join.c b/mxm_wifiex/wlan_src/mlan/mlan_join.c index b8a63b7..07f2bac 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_join.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_join.c @@ -1045,6 +1045,7 @@ mlan_status wlan_cmd_802_11_associate(mlan_private *pmpriv, MrvlIEtypes_HostMlme_t *host_mlme_tlv = MNULL; MrvlIEtypes_PrevBssid_t *prev_bssid_tlv = MNULL; t_u8 zero_mac[MLAN_MAC_ADDR_LENGTH] = {0}; + MrvlIEtypes_MultiAp_t *multi_ap_tlv = MNULL; ENTER(); @@ -1055,6 +1056,9 @@ mlan_status wlan_cmd_802_11_associate(mlan_private *pmpriv, /* Save so we know which BSS Desc to use in the response handler */ pmpriv->pattempted_bss_desc = pbss_desc; + memcpy_ext(pmpriv->adapter, &pmpriv->curr_bss_params.attemp_bssid, + pbss_desc->mac_address, MLAN_MAC_ADDR_LENGTH, + MLAN_MAC_ADDR_LENGTH); /* clear assoc_rsp_size */ pmpriv->assoc_rsp_size = 0; pmpriv->assoc_req_size = 0; @@ -1474,6 +1478,18 @@ mlan_status wlan_cmd_802_11_associate(mlan_private *pmpriv, pos += sizeof(prev_bssid_tlv->header) + MLAN_MAC_ADDR_LENGTH; } + if (pmpriv->multi_ap_flag) { + multi_ap_tlv = (MrvlIEtypes_MultiAp_t *)pos; + multi_ap_tlv->header.type = wlan_cpu_to_le16(TLV_TYPE_MULTI_AP); + multi_ap_tlv->header.len = sizeof(multi_ap_tlv->flag); + multi_ap_tlv->flag = pmpriv->multi_ap_flag; + PRINTM(MINFO, " TLV multi_ap_flag : 0x%x\n", + multi_ap_tlv->flag); + pos += sizeof(multi_ap_tlv->header) + multi_ap_tlv->header.len; + multi_ap_tlv->header.len = + wlan_cpu_to_le16(sizeof(multi_ap_tlv->flag)); + } + if (wlan_11d_create_dnld_countryinfo(pmpriv, pbss_desc->bss_band)) { PRINTM(MERROR, "Dnld_countryinfo_11d failed\n"); ret = MLAN_STATUS_FAILURE; @@ -1658,11 +1674,19 @@ mlan_status wlan_ret_802_11_associate(mlan_private *pmpriv, pmpriv->pattempted_bss_desc->mac_address, MLAN_MAC_ADDR_LENGTH)) wlan_reset_connect_state(pmpriv, MTRUE); - else + else { + memcpy_ext( + pmpriv->adapter, + &pmpriv->curr_bss_params.attemp_bssid, + pmpriv->curr_bss_params.bss_descriptor + .mac_address, + MLAN_MAC_ADDR_LENGTH, + MLAN_MAC_ADDR_LENGTH); wlan_recv_event( pmpriv, MLAN_EVENT_ID_DRV_ASSOC_FAILURE_REPORT, MNULL); + } } else wlan_reset_connect_state(pmpriv, MTRUE); pmpriv->adapter->dbg.num_cmd_assoc_failure++; @@ -1689,6 +1713,7 @@ mlan_status wlan_ret_802_11_associate(mlan_private *pmpriv, /* Send a Media Connected event, according to the Spec */ pmpriv->media_connected = MTRUE; + pmpriv->multi_ap_flag = 0; pmpriv->adapter->pps_uapsd_mode = MFALSE; pmpriv->adapter->tx_lock_flag = MFALSE; pmpriv->adapter->delay_null_pkt = MFALSE; @@ -1878,7 +1903,6 @@ done: pioctl_req->status_code = MLAN_ERROR_NO_ERROR; } } - LEAVE(); return ret; } diff --git a/mxm_wifiex/wlan_src/mlan/mlan_main.h b/mxm_wifiex/wlan_src/mlan/mlan_main.h index b95e66b..6b844f5 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_main.h +++ b/mxm_wifiex/wlan_src/mlan/mlan_main.h @@ -863,7 +863,10 @@ typedef struct { t_u8 data_rates[WLAN_SUPPORTED_RATES]; /** Host MLME flag*/ t_u8 host_mlme; + /** prev_bssid */ mlan_802_11_mac_addr prev_bssid; + /** attemp_bssid */ + mlan_802_11_mac_addr attemp_bssid; t_u8 use_mfp; } current_bss_params_t; @@ -1327,6 +1330,7 @@ typedef struct _mlan_private { /** IP address */ t_u8 ip_addr[IPADDR_LEN]; t_u32 hotspot_cfg; + t_u8 multi_ap_flag; #ifdef STA_SUPPORT ExtCap_t ext_cap; ExtCap_t def_ext_cap; @@ -1580,6 +1584,8 @@ struct _sta_node { /** station band mode */ t_u16 bandmode; sta_stats stats; + /** station aid */ + t_u16 aid; }; /** 802.11h State information kept in the 'mlan_adapter' driver structure */ @@ -3949,6 +3955,8 @@ static inline t_u8 wlan_is_port_ready(pmlan_adapter pmadapter, t_u32 port_index) return MTRUE; } #endif +mlan_status wlan_check_easymesh_pkt(mlan_private *priv, pmlan_buffer pmbuf, + RxPD *prx_pd); #ifdef UAP_SUPPORT mlan_status wlan_process_uap_rx_packet(mlan_private *priv, pmlan_buffer pmbuf); @@ -4096,6 +4104,9 @@ mlan_status wlan_set_drvdbg(pmlan_adapter pmadapter, mlan_status wlan_misc_hotspot_cfg(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req); +mlan_status wlan_misc_multi_ap_cfg(pmlan_adapter pmadapter, + pmlan_ioctl_req pioctl_req); + mlan_status wlan_misc_ext_capa_cfg(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req); diff --git a/mxm_wifiex/wlan_src/mlan/mlan_misc.c b/mxm_wifiex/wlan_src/mlan/mlan_misc.c index cd79f82..3a3d0f8 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_misc.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_misc.c @@ -3496,6 +3496,32 @@ mlan_status wlan_misc_hotspot_cfg(pmlan_adapter pmadapter, return ret; } +/** + * @brief Set multi ap flag + * + * @param pmadapter A pointer to mlan_adapter structure + * @param pioctl_req A pointer to ioctl request buffer + * + * @return MLAN_STATUS_PENDING --success, otherwise fail + */ +mlan_status wlan_misc_multi_ap_cfg(pmlan_adapter pmadapter, + pmlan_ioctl_req pioctl_req) +{ + pmlan_private pmpriv = pmadapter->priv[pioctl_req->bss_index]; + mlan_ds_misc_cfg *misc = (mlan_ds_misc_cfg *)pioctl_req->pbuf; + mlan_status ret = MLAN_STATUS_SUCCESS; + + ENTER(); + + if (MLAN_ACT_GET == pioctl_req->action) + misc->param.multi_ap_flag = pmpriv->multi_ap_flag; + else if (MLAN_ACT_SET == pioctl_req->action) + pmpriv->multi_ap_flag = misc->param.multi_ap_flag; + + LEAVE(); + return ret; +} + #ifdef STA_SUPPORT /** * @brief This function check if we should enable beacon protection support diff --git a/mxm_wifiex/wlan_src/mlan/mlan_sdio.c b/mxm_wifiex/wlan_src/mlan/mlan_sdio.c index 0d5851c..bd35666 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_sdio.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_sdio.c @@ -1360,8 +1360,8 @@ static mlan_status wlan_decode_rx_packet(mlan_adapter *pmadapter, case MLAN_TYPE_EVENT: PRINTM(MINFO, "--- Rx: Event ---\n"); - event = *(t_u32 *)&pmbuf->pbuf[MIN( - pmbuf->data_offset + SDIO_INTF_HEADER_LEN, UINT_MAX)]; + event = *(t_u32 *)&pmbuf->pbuf[pmbuf->data_offset + + SDIO_INTF_HEADER_LEN]; pmadapter->event_cause = wlan_le32_to_cpu(event); if ((pmadapter->upld_len > MLAN_EVENT_HEADER_LEN) && ((pmadapter->upld_len - MLAN_EVENT_HEADER_LEN) < diff --git a/mxm_wifiex/wlan_src/mlan/mlan_sta_event.c b/mxm_wifiex/wlan_src/mlan/mlan_sta_event.c index c909928..b75746e 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_sta_event.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_sta_event.c @@ -406,6 +406,7 @@ t_void wlan_reset_connect_state(pmlan_private priv, t_u8 drv_disconnect) priv->rxpd_rate_info = 0; priv->max_amsdu = 0; priv->amsdu_disable = MFALSE; + priv->multi_ap_flag = 0; wlan_coex_ampdu_rxwinsize(pmadapter); priv->sec_info.ewpa_enabled = MFALSE; @@ -675,6 +676,7 @@ mlan_status wlan_ops_sta_process_event(t_void *priv) t_u8 radar_chan; t_u8 bandwidth; t_u16 enable = 0; + Event_Link_Lost *link_lost_evt = MNULL; ENTER(); @@ -756,12 +758,51 @@ mlan_status wlan_ops_sta_process_event(t_void *priv) break; case EVENT_LINK_LOST: - reason_code = wlan_le16_to_cpu(*(t_u16 *)(pmbuf->pbuf + - pmbuf->data_offset + - sizeof(eventcause))); - PRINTM(MMSG, "wlan: EVENT: Link lost (reason 0x%x)\n", - reason_code); - pmpriv->disconnect_reason_code = reason_code; + if (pmbuf && (pmbuf->data_len >= + sizeof(eventcause) + sizeof(Event_Link_Lost))) { + link_lost_evt = (Event_Link_Lost *)(pmbuf->pbuf + + pmbuf->data_offset + + sizeof(eventcause)); + PRINTM(MMSG, + "wlan: EVENT: Link lost (reason 0x%x) bssid: " MACSTR + "\n", + link_lost_evt->reason_code, + MAC2STR(link_lost_evt->bssid)); + pmpriv->disconnect_reason_code = + link_lost_evt->reason_code; + if (memcmp(pmpriv->adapter, link_lost_evt->bssid, + &pmpriv->curr_bss_params.attemp_bssid, + MLAN_MAC_ADDR_LENGTH)) { + PRINTM(MMSG, "wlan: skip link lost event\n"); + PRINTM(MMSG, "pattempted_bssid: " MACSTR "\n", + MAC2STR(&pmpriv->curr_bss_params + .attemp_bssid)); + break; + } + } else { + if (memcmp(pmpriv->adapter, + pmpriv->curr_bss_params.bss_descriptor + .mac_address, + &pmpriv->curr_bss_params.attemp_bssid, + MLAN_MAC_ADDR_LENGTH)) { + PRINTM(MMSG, "wlan: skip link lost event\n"); + PRINTM(MMSG, + "pattempted_bssid: " MACSTR + " curr_bssid:" MACSTR "\n", + MAC2STR(&pmpriv->curr_bss_params + .attemp_bssid), + MAC2STR(pmpriv->curr_bss_params + .bss_descriptor + .mac_address)); + break; + } + reason_code = wlan_le16_to_cpu( + *(t_u16 *)(pmbuf->pbuf + pmbuf->data_offset + + sizeof(eventcause))); + PRINTM(MMSG, "wlan: EVENT: Link lost (reason 0x%x)\n", + reason_code); + pmpriv->disconnect_reason_code = reason_code; + } pmadapter->dbg.num_event_link_lost++; wlan_handle_disconnect_event(pmpriv); break; diff --git a/mxm_wifiex/wlan_src/mlan/mlan_sta_ioctl.c b/mxm_wifiex/wlan_src/mlan/mlan_sta_ioctl.c index 2b3800f..c1e144d 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_sta_ioctl.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_sta_ioctl.c @@ -5164,6 +5164,9 @@ static mlan_status wlan_misc_cfg_ioctl(pmlan_adapter pmadapter, case MLAN_OID_MISC_HOTSPOT_CFG: status = wlan_misc_hotspot_cfg(pmadapter, pioctl_req); break; + case MLAN_OID_MISC_MULTI_AP_CFG: + status = wlan_misc_multi_ap_cfg(pmadapter, pioctl_req); + break; case MLAN_OID_MISC_OTP_USER_DATA: status = wlan_misc_otp_user_data(pmadapter, pioctl_req); break; diff --git a/mxm_wifiex/wlan_src/mlan/mlan_sta_rx.c b/mxm_wifiex/wlan_src/mlan/mlan_sta_rx.c index 41b8d96..7be24cb 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_sta_rx.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_sta_rx.c @@ -719,6 +719,13 @@ mlan_status wlan_ops_sta_process_rx_packet(t_void *adapter, pmlan_buffer pmbuf) rxpd_rate_info_orig, prx_pd->rate_info); } rx_pkt_type = prx_pd->rx_pkt_type; + if (prx_pd->flags & RXPD_FLAG_PKT_EASYMESH) { + PRINTM_NETINTF(MDAT_D, priv); + PRINTM(MDAT_D, "Easymesh flags : 0x%x\n", prx_pd->flags); + ret = wlan_check_easymesh_pkt(priv, pmbuf, prx_pd); + if (ret != MLAN_STATUS_SUCCESS) + goto done; + } prx_pkt = (RxPacketHdr_t *)((t_u8 *)prx_pd + prx_pd->rx_pkt_offset); if ((prx_pd->rx_pkt_offset + prx_pd->rx_pkt_length) != diff --git a/mxm_wifiex/wlan_src/mlan/mlan_sta_tx.c b/mxm_wifiex/wlan_src/mlan/mlan_sta_tx.c index 49ff34d..7f274b0 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_sta_tx.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_sta_tx.c @@ -127,6 +127,11 @@ t_void *wlan_ops_sta_process_txpd(t_void *priv, pmlan_buffer pmbuf) } if (pmbuf->flags & MLAN_BUF_FLAG_TDLS) plocal_tx_pd->flags |= MRVDRV_TxPD_FLAGS_TDLS_PACKET; + if (pmbuf->flags & MLAN_BUF_FLAG_EASYMESH) { + plocal_tx_pd->flags |= MRVDRV_TxPD_FLAGS_EASYMESH; + memcpy_ext(pmpriv->adapter, plocal_tx_pd->ra_mac, pmbuf->mac, + MLAN_MAC_ADDR_LENGTH, MLAN_MAC_ADDR_LENGTH); + } /* Offset of actual data */ plocal_tx_pd->tx_pkt_offset = (t_u16)( (t_ptr)pmbuf->pbuf + pmbuf->data_offset - (t_ptr)plocal_tx_pd); diff --git a/mxm_wifiex/wlan_src/mlan/mlan_txrx.c b/mxm_wifiex/wlan_src/mlan/mlan_txrx.c index c55c145..d97e36d 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_txrx.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_txrx.c @@ -446,3 +446,57 @@ t_void wlan_process_bypass_tx(pmlan_adapter pmadapter) !wlan_bypass_tx_list_empty(pmadapter)); LEAVE(); } + +/** + * @brief This function will convert 802.11 header to 802.3 header + and save the backhaul station aid to pmbuf + * + * @param priv A pointer to mlan_private + * @param pmbuf A pointer to mlan_buffer + * @param prx_pd A pointer to RxPD + * + * @return MLAN_STATUS_PENDING --success, otherwise fail + */ +mlan_status wlan_check_easymesh_pkt(mlan_private *priv, pmlan_buffer pmbuf, + RxPD *prx_pd) +{ + Eth803Hdr_t *eth_header = MNULL; + sta_node *sta_ptr = MNULL; + mlan_status ret = MLAN_STATUS_SUCCESS; + t_u8 *pos = MNULL; + t_u32 tmp = 0; + + ENTER(); + + pos = (t_u8 *)prx_pd + prx_pd->rx_pkt_offset; + eth_header = (Eth803Hdr_t *)pos; + + PRINTM(MDAT_D, + "Rx Easymesh ETH header destination address: " FULL_MACSTR + "\nETH header source address: " FULL_MACSTR "\n", + FULL_MAC2STR(eth_header->dest_addr), + FULL_MAC2STR(eth_header->src_addr)); + + if (priv->bss_type == MLAN_BSS_TYPE_UAP) { + pmbuf->flags |= MLAN_BUF_FLAG_EASYMESH; + memcpy_ext(priv->adapter, pmbuf->mac, prx_pd->ta_mac, + MLAN_MAC_ADDR_LENGTH, MLAN_MAC_ADDR_LENGTH); + + sta_ptr = wlan_get_station_entry(priv, prx_pd->ta_mac); + if (!sta_ptr) { + PRINTM(MERROR, + "Easymesh Error! Can't find station in the station list\n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + /* Save station aid to pmbuf and send it to moal */ + tmp = (t_u32)sta_ptr->aid; + pmbuf->priority |= (tmp << 24); + PRINTM(MDAT_D, "Easymesh: Rx for VLAN " FULL_MACSTR "\n", + FULL_MAC2STR(prx_pd->ta_mac)); + } +done: + LEAVE(); + return ret; +} diff --git a/mxm_wifiex/wlan_src/mlan/mlan_uap_cmdevent.c b/mxm_wifiex/wlan_src/mlan/mlan_uap_cmdevent.c index 6175dc9..2c84a8e 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_uap_cmdevent.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_uap_cmdevent.c @@ -705,6 +705,7 @@ static mlan_status wlan_uap_cmd_ap_config(pmlan_private pmpriv, MrvlIETypes_HTCap_t *tlv_htcap = MNULL; MrvlIEtypes_wmm_parameter_t *tlv_wmm_parameter = MNULL; MrvlIEtypes_preamble_t *tlv_preamble = MNULL; + MrvlIEtypes_MultiAp_t *tlv_multi_ap = MNULL; t_u32 cmd_size = 0; t_u8 zero_mac[] = {0, 0, 0, 0, 0, 0}; @@ -1433,6 +1434,16 @@ static mlan_status wlan_uap_cmd_ap_config(pmlan_private pmpriv, cmd_size += sizeof(MrvlIEtypes_preamble_t); tlv += sizeof(MrvlIEtypes_preamble_t); } + if (bss->param.bss_config.multi_ap_flag) { + /** Add multi AP tlv here */ + tlv_multi_ap = (MrvlIEtypes_MultiAp_t *)tlv; + tlv_multi_ap->header.type = wlan_cpu_to_le16(TLV_TYPE_MULTI_AP); + tlv_multi_ap->header.len = + wlan_cpu_to_le16(sizeof(tlv_multi_ap->flag)); + tlv_multi_ap->flag = bss->param.bss_config.multi_ap_flag; + cmd_size += sizeof(MrvlIEtypes_MultiAp_t); + tlv += sizeof(MrvlIEtypes_MultiAp_t); + } cmd->size = (t_u16)wlan_cpu_to_le16(cmd_size); PRINTM(MCMND, "AP config: cmd_size=%d\n", cmd_size); LEAVE(); @@ -4369,6 +4380,8 @@ static mlan_status wlan_uap_cmd_add_station(pmlan_private pmpriv, LEAVE(); return MLAN_STATUS_FAILURE; } + /* Save station aid for multi-ap */ + sta_ptr->aid = bss->param.sta_info.aid; memcpy_ext(pmadapter, new_sta->peer_mac, bss->param.sta_info.peer_mac, MLAN_MAC_ADDR_LENGTH, MLAN_MAC_ADDR_LENGTH); if (cmd_action != HostCmd_ACT_ADD_STA) diff --git a/mxm_wifiex/wlan_src/mlan/mlan_uap_txrx.c b/mxm_wifiex/wlan_src/mlan/mlan_uap_txrx.c index 426a8da..db5ff56 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_uap_txrx.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_uap_txrx.c @@ -246,6 +246,11 @@ t_void *wlan_ops_uap_process_txpd(t_void *priv, pmlan_buffer pmbuf) plocal_tx_pd->tx_pkt_type = (t_u16)pkt_type; plocal_tx_pd->tx_control = tx_control; } + if (pmbuf->flags & MLAN_BUF_FLAG_EASYMESH) { + plocal_tx_pd->flags |= MRVDRV_TxPD_FLAGS_EASYMESH; + memcpy_ext(pmpriv->adapter, plocal_tx_pd->ra_mac, pmbuf->mac, + MLAN_MAC_ADDR_LENGTH, MLAN_MAC_ADDR_LENGTH); + } if (pmbuf->flags & MLAN_BUF_FLAG_TX_CTRL) { if (pmbuf->u.tx_info.data_rate) { @@ -388,6 +393,14 @@ mlan_status wlan_ops_uap_process_rx_packet(t_void *adapter, pmlan_buffer pmbuf) } rx_pkt_type = prx_pd->rx_pkt_type; + if (prx_pd->flags & RXPD_FLAG_PKT_EASYMESH) { + PRINTM_NETINTF(MDAT_D, priv); + PRINTM(MDAT_D, "UAP Rx Easymesh pkt flags : 0x%x\n", + prx_pd->flags); + ret = wlan_check_easymesh_pkt(priv, pmbuf, prx_pd); + if (ret != MLAN_STATUS_SUCCESS) + goto done; + } prx_pkt = (RxPacketHdr_t *)((t_u8 *)prx_pd + prx_pd->rx_pkt_offset); PRINTM(MINFO, @@ -549,7 +562,11 @@ mlan_status wlan_ops_uap_process_rx_packet(t_void *adapter, pmlan_buffer pmbuf) } } - sta_ptr = wlan_get_station_entry(priv, prx_pkt->eth803_hdr.src_addr); + if (prx_pd->flags & RXPD_FLAG_PKT_EASYMESH) + sta_ptr = wlan_get_station_entry(priv, prx_pd->ta_mac); + else + sta_ptr = wlan_get_station_entry(priv, + prx_pkt->eth803_hdr.src_addr); if (sta_ptr) { sta_ptr->snr = prx_pd->snr; sta_ptr->nf = prx_pd->nf; @@ -569,8 +586,12 @@ mlan_status wlan_ops_uap_process_rx_packet(t_void *adapter, pmlan_buffer pmbuf) wlan_process_uap_rx_packet(priv, pmbuf); goto done; } - memcpy_ext(pmadapter, ta, prx_pkt->eth803_hdr.src_addr, - MLAN_MAC_ADDR_LENGTH, MLAN_MAC_ADDR_LENGTH); + if (prx_pd->flags & RXPD_FLAG_PKT_EASYMESH) + memcpy_ext(pmadapter, ta, prx_pd->ta_mac, MLAN_MAC_ADDR_LENGTH, + MLAN_MAC_ADDR_LENGTH); + else + memcpy_ext(pmadapter, ta, prx_pkt->eth803_hdr.src_addr, + MLAN_MAC_ADDR_LENGTH, MLAN_MAC_ADDR_LENGTH); if ((rx_pkt_type != PKT_TYPE_BAR) && (prx_pd->priority < MAX_NUM_TID)) { sta_ptr = wlan_get_station_entry(priv, ta); if (sta_ptr) { diff --git a/mxm_wifiex/wlan_src/mlan/mlan_wmm.c b/mxm_wifiex/wlan_src/mlan/mlan_wmm.c index 5c641fc..41a6f9e 100644 --- a/mxm_wifiex/wlan_src/mlan/mlan_wmm.c +++ b/mxm_wifiex/wlan_src/mlan/mlan_wmm.c @@ -2159,8 +2159,13 @@ t_void wlan_wmm_add_buf_txqueue(pmlan_adapter pmadapter, pmlan_buffer pmbuf) &priv->wmm.tid_tbl_ptr[tid_down].ra_list, MNULL, MNULL); } else { - memcpy_ext(pmadapter, ra, pmbuf->pbuf + pmbuf->data_offset, - MLAN_MAC_ADDR_LENGTH, MLAN_MAC_ADDR_LENGTH); + if (pmbuf->flags & MLAN_BUF_FLAG_EASYMESH) + memcpy_ext(pmadapter, ra, pmbuf->mac, + MLAN_MAC_ADDR_LENGTH, MLAN_MAC_ADDR_LENGTH); + else + memcpy_ext(pmadapter, ra, + pmbuf->pbuf + pmbuf->data_offset, + MLAN_MAC_ADDR_LENGTH, MLAN_MAC_ADDR_LENGTH); /** put multicast/broadcast packet in the same ralist */ if (ra[0] & 0x01) memset(pmadapter, ra, 0xff, sizeof(ra)); diff --git a/mxm_wifiex/wlan_src/mlinux/mlan_decl.h b/mxm_wifiex/wlan_src/mlinux/mlan_decl.h index fee793e..8de713d 100644 --- a/mxm_wifiex/wlan_src/mlinux/mlan_decl.h +++ b/mxm_wifiex/wlan_src/mlinux/mlan_decl.h @@ -24,7 +24,7 @@ #define _MLAN_DECL_H_ /** MLAN release version */ -#define MLAN_RELEASE_VERSION "408" +#define MLAN_RELEASE_VERSION "408.p2" /** Re-define generic data types for MLAN/MOAL */ /** Signed char (1-byte) */ @@ -621,6 +621,8 @@ typedef enum { #define MLAN_BUF_FLAG_TX_CTRL MBIT(14) +#define MLAN_BUF_FLAG_EASYMESH MBIT(16) + #define MLAN_BUF_FLAG_MC_AGGR_PKT MBIT(17) #ifdef DEBUG_LEVEL1 @@ -1335,6 +1337,8 @@ typedef struct _mlan_buffer { t_u32 extra_ts_sec; /** Time stamp when packet is dequed from rx_q(micro seconds) */ t_u32 extra_ts_usec; + /** When TX ra mac address, When Rx Ta mac address*/ + t_u8 mac[MLAN_MAC_ADDR_LENGTH]; /** Fields below are valid for MLAN module only */ /** Pointer to parent mlan_buffer */ struct _mlan_buffer *pparent; diff --git a/mxm_wifiex/wlan_src/mlinux/mlan_ioctl.h b/mxm_wifiex/wlan_src/mlinux/mlan_ioctl.h index a4dce18..b234715 100644 --- a/mxm_wifiex/wlan_src/mlinux/mlan_ioctl.h +++ b/mxm_wifiex/wlan_src/mlinux/mlan_ioctl.h @@ -357,6 +357,7 @@ enum _mlan_ioctl_req_id { MLAN_OID_MISC_TP_STATE = 0x0020007D, MLAN_OID_MISC_HAL_PHY_CFG = 0x0020007E, MLAN_OID_MISC_RF_TEST_HE_POWER = 0X0020007F, + MLAN_OID_MISC_MULTI_AP_CFG = 0x00200080, #ifdef UAP_SUPPORT MLAN_OID_MISC_WACP_MODE = 0x00200081, #endif @@ -1185,6 +1186,8 @@ typedef struct _mlan_uap_bss_param { /** uap host based config */ t_u32 uap_host_based_config; + /** multi ap flag */ + t_u8 multi_ap_flag; } mlan_uap_bss_param, *pmlan_uap_bss_param; /** mlan_uap_scan_channels */ @@ -6188,6 +6191,8 @@ typedef struct _mlan_ds_misc_cfg { #endif /** Hotspot config param set */ t_u32 hotspot_cfg; + /** Multi AP flag */ + t_u8 multi_ap_flag; #ifdef STA_SUPPORT ExtCap_t ext_cap; #endif diff --git a/mxm_wifiex/wlan_src/mlinux/moal_cfg80211.h b/mxm_wifiex/wlan_src/mlinux/moal_cfg80211.h index dcc3329..402c1aa 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_cfg80211.h +++ b/mxm_wifiex/wlan_src/mlinux/moal_cfg80211.h @@ -66,6 +66,10 @@ #define MRVL_PKT_TYPE_MGMT_FRAME 0xE5 +#if defined(UAP_CFG80211) || defined(STA_CFG80211) +#define MRVL_PKT_TYPE_MGMT_EASYMESH 0xCF +#endif + mlan_status woal_cfg80211_set_key(moal_private *priv, t_u8 is_enable_wep, t_u32 cipher, const t_u8 *key, int key_len, const t_u8 *seq, int seq_len, t_u8 key_index, diff --git a/mxm_wifiex/wlan_src/mlinux/moal_cfg80211_util.c b/mxm_wifiex/wlan_src/mlinux/moal_cfg80211_util.c index 4086234..5f3d637 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_cfg80211_util.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_cfg80211_util.c @@ -2900,6 +2900,11 @@ static int woal_cfg80211_subcmd_link_statistic_get(struct wiphy *wiphy, t_u64 inter_msec = 0; t_u64 max_msec = (t_u64)24 * (t_u64)24 * (t_u64)3600 * (t_u64)1000; moal_handle *handle = priv->phandle; + if (!priv->media_connected) { + PRINTM(MERROR, + "Block get_link_statistics in disconnected state!\n"); + return -EINVAL; + } /* Allocate an IOCTL request buffer */ req = woal_alloc_mlan_ioctl_req(sizeof(t_u32) + BUF_MAXLEN); diff --git a/mxm_wifiex/wlan_src/mlinux/moal_eth_ioctl.c b/mxm_wifiex/wlan_src/mlinux/moal_eth_ioctl.c index e2aceb6..ed7e9dc 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_eth_ioctl.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_eth_ioctl.c @@ -2913,6 +2913,116 @@ done: } #endif +#if defined(UAP_SUPPORT) +#if defined(STA_CFG80211) && defined(UAP_CFG80211) +/** + * @brief easymesh uap Set/Get multi AP mode handler + * + * @param priv A pointer to moal_private structure + * @param req A pointer to ifreq structure + * @return 0 --success, otherwise fail + */ +static int woal_uap_set_multiap_mode(moal_private *priv, t_u8 *respbuf, + t_u32 respbuflen) +{ + mlan_ioctl_req *req = NULL; + mlan_ds_misc_cfg *misc = NULL; + mlan_status status = MLAN_STATUS_SUCCESS; + int mode[1] = {0}; + int ret = 0; + int header_len = 0; + int user_data_len = 0; + + ENTER(); + + if (!respbuf) { + PRINTM(MERROR, "response buffer is not available!\n"); + ret = -EINVAL; + goto done; + } + + header_len = strlen(CMD_NXP) + strlen(PRIV_CMD_SETMODE); + user_data_len = strlen(respbuf) - header_len; + + /* Allocate an IOCTL request buffer */ + req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg)); + if (req == NULL) { + ret = -ENOMEM; + goto done; + } + + /* Fill request buffer */ + misc = (mlan_ds_misc_cfg *)req->pbuf; + misc->sub_command = MLAN_OID_MISC_MULTI_AP_CFG; + req->req_id = MLAN_IOCTL_MISC_CFG; + + if ((int)strlen(respbuf) == header_len) { + /* GET operation */ + user_data_len = 0; + req->action = MLAN_ACT_GET; + } else { + /* SET operation */ + parse_arguments(respbuf + header_len, mode, ARRAY_SIZE(mode), + &user_data_len); + if (user_data_len > 1) { + PRINTM(MERROR, "Invalid number of args!\n"); + ret = -EINVAL; + goto done; + } + if ((mode[0] != EASY_MESH_MULTI_AP_BSS_MODE_3) && + (mode[0] != EASY_MESH_MULTI_AP_BSS_MODE_2) && + (mode[0] != EASY_MESH_MULTI_AP_BSS_MODE_1)) { + PRINTM(MERROR, "Invalid setmode value\n"); + ret = -EINVAL; + goto done; + } + + if (mode[0] == EASY_MESH_MULTI_AP_BSS_MODE_3) + /* Supports backhaul and fronthaul BSS */ + priv->multi_ap_flag = EASY_MESH_MULTI_AP_BH_AND_FH_BSS; + else if (mode[0] == EASY_MESH_MULTI_AP_BSS_MODE_2) + /* Supports backhaul BSS */ + priv->multi_ap_flag = EASY_MESH_MULTI_AP_BH_BSS; + else if (mode[0] == EASY_MESH_MULTI_AP_BSS_MODE_1) + /* Supports fronthaul BSS */ + priv->multi_ap_flag = EASY_MESH_MULTI_AP_FH_BSS; + PRINTM(MINFO, "[EM:%s:%d] priv->multi_ap_flag 0x%x\n", __func__, + __LINE__, priv->multi_ap_flag); + + req->action = MLAN_ACT_SET; + } + + /* Send IOCTL request to MLAN */ + status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT); + if (status != MLAN_STATUS_SUCCESS) { + ret = -EFAULT; + goto done; + } + + if (req->action == MLAN_ACT_GET) { + if (priv->multi_ap_flag == EASY_MESH_MULTI_AP_BH_AND_FH_BSS) + mode[0] = EASY_MESH_MULTI_AP_BSS_MODE_3; + else if (priv->multi_ap_flag == EASY_MESH_MULTI_AP_BH_BSS) + mode[0] = EASY_MESH_MULTI_AP_BSS_MODE_2; + else if (priv->multi_ap_flag == EASY_MESH_MULTI_AP_FH_BSS) + mode[0] = EASY_MESH_MULTI_AP_BSS_MODE_1; + + PRINTM(MINFO, "[EM:%s:%d] setmode to 0x%x\n", __func__, + __LINE__, mode[0]); + moal_memcpy_ext(priv->phandle, respbuf, (t_u8 *)mode, + sizeof(mode), respbuflen); + ret = sizeof(mode); + } +done: + if (status != MLAN_STATUS_PENDING) + kfree(req); + + LEAVE(); + return ret; +} +#endif +#endif + #ifdef WIFI_DIRECT_SUPPORT #if defined(STA_SUPPORT) && defined(UAP_SUPPORT) /** @@ -20034,6 +20144,16 @@ int woal_android_priv_cmd(struct net_device *dev, struct ifreq *req) priv_cmd.total_len); goto handled; #endif +#if defined(UAP_SUPPORT) +#if defined(STA_CFG80211) && defined(UAP_CFG80211) + } else if (strnicmp(buf + strlen(CMD_NXP), PRIV_CMD_SETMODE, + strlen(PRIV_CMD_SETMODE)) == 0) { + /* Set multi_ap mode */ + len = woal_uap_set_multiap_mode(priv, buf, + priv_cmd.total_len); + goto handled; +#endif +#endif #ifdef WIFI_DIRECT_SUPPORT #if defined(STA_SUPPORT) && defined(UAP_SUPPORT) } else if (strnicmp(buf + strlen(CMD_NXP), PRIV_CMD_BSSROLE, diff --git a/mxm_wifiex/wlan_src/mlinux/moal_eth_ioctl.h b/mxm_wifiex/wlan_src/mlinux/moal_eth_ioctl.h index 6b1dc2c..ad1e549 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_eth_ioctl.h +++ b/mxm_wifiex/wlan_src/mlinux/moal_eth_ioctl.h @@ -82,6 +82,9 @@ Change log: #define PRIV_CMD_GET_STA_LIST "getstalist" #define PRIV_CMD_BSS_CONFIG "bssconfig" #endif +#if defined(UAP_SUPPORT) +#define PRIV_CMD_SETMODE "setmode" +#endif #ifdef WIFI_DIRECT_SUPPORT #if defined(STA_SUPPORT) && defined(UAP_SUPPORT) #define PRIV_CMD_BSSROLE "bssrole" diff --git a/mxm_wifiex/wlan_src/mlinux/moal_ioctl.c b/mxm_wifiex/wlan_src/mlinux/moal_ioctl.c index 710ac0f..e38942b 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_ioctl.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_ioctl.c @@ -7623,6 +7623,48 @@ done: return status; } +#if defined(STA_CFG80211) || defined(UAP_CFG80211) +/** + * @brief Set multi ap flag to mlan layer + * + * @param priv A pointer to moal_private structure + * @param wait_option wait_option of ioctl + * @param flag multi ap flag + * + * @return MLAN_STATUS_SUCCESS -- success, otherwise fail + */ +mlan_status woal_multi_ap_cfg(moal_private *priv, t_u8 wait_option, t_u8 flag) +{ + mlan_status status = MLAN_STATUS_SUCCESS; + mlan_ioctl_req *req = NULL; + mlan_ds_misc_cfg *cfg = NULL; + + ENTER(); + + req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg)); + if (req == NULL) { + status = MLAN_STATUS_FAILURE; + goto done; + } + + cfg = (mlan_ds_misc_cfg *)req->pbuf; + cfg->param.multi_ap_flag = flag; + cfg->sub_command = MLAN_OID_MISC_MULTI_AP_CFG; + req->req_id = MLAN_IOCTL_MISC_CFG; + req->action = MLAN_ACT_SET; + + status = woal_request_ioctl(priv, req, wait_option); + if (status != MLAN_STATUS_SUCCESS) + goto done; + +done: + if (status != MLAN_STATUS_PENDING) + kfree(req); + LEAVE(); + return status; +} +#endif + /** * @brief Set hotspot configuration value to mlan layer * diff --git a/mxm_wifiex/wlan_src/mlinux/moal_main.c b/mxm_wifiex/wlan_src/mlinux/moal_main.c index 46c0647..d30f692 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_main.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_main.c @@ -585,6 +585,8 @@ static struct _card_info card_info_PCIE8997 = { .magic_reg = 0x0cd4, .fw_name = PCIE8997_DEFAULT_COMBO_FW_NAME, .fw_name_wlan = PCIE8997_DEFAULT_WLAN_FW_NAME, + .fw_reset_reg = 0xcf4, + .fw_reset_val = 0x99, .sniffer_support = 1, .per_pkt_cfg_support = 1, .host_mlme_required = 1, @@ -5520,6 +5522,11 @@ void woal_remove_interface(moal_handle *handle, t_u8 bss_index) #endif int i = 0; +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + int count = 0; +#endif +#endif ENTER(); if (!priv || !priv->netdev) @@ -5621,6 +5628,18 @@ void woal_remove_interface(moal_handle *handle, t_u8 bss_index) if (IS_STA_OR_UAP_CFG80211(handle->params.cfg80211_wext)) priv->phandle->wiphy->extended_capabilities = NULL; #endif +#ifdef UAP_SUPPORT + /* Clear the whole backhaul station list in moal */ + for (count = 0; count < MAX_STA_COUNT; count++) { + if (priv->vlan_sta_list[count]) { + if (priv->vlan_sta_list[count]->is_valid) + unregister_netdevice( + priv->vlan_sta_list[count]->netdev); + kfree(priv->vlan_sta_list[count]); + } + priv->vlan_sta_list[count] = NULL; + } +#endif #endif priv->phandle->priv[priv->bss_index] = NULL; priv->phandle = NULL; @@ -6067,6 +6086,9 @@ int woal_open(struct net_device *dev) #endif /* < 2.6.34 */ #endif /* USB_SUSPEND_RESUME */ t_u8 carrier_on = MFALSE; +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + int cfg80211_wext = priv->phandle->params.cfg80211_wext; +#endif ENTER(); @@ -6134,6 +6156,13 @@ int woal_open(struct net_device *dev) carrier_on = MTRUE; #endif +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + if (IS_STA_OR_UAP_CFG80211(cfg80211_wext)) { + if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP_VLAN) + carrier_on = MTRUE; + } +#endif + if (carrier_on == MTRUE) { if (!netif_carrier_ok(priv->netdev)) netif_carrier_on(priv->netdev); @@ -6171,6 +6200,18 @@ int woal_close(struct net_device *dev) #endif ENTER(); +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + if (IS_STA_OR_UAP_CFG80211(cfg80211_wext)) { + /** For multi-ap virtual interface */ + if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP_VLAN) { + woal_stop_queue(priv->netdev); + MODULE_PUT; + LEAVE(); + return 0; + } + } +#endif + woal_flush_tx_stat_queue(priv); if ((priv->media_connected == MTRUE) @@ -6314,6 +6355,13 @@ int woal_set_mac_address(struct net_device *dev, void *addr) return -EFAULT; } +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + /* No need to set mac address for multi-ap virtual interface */ + if ((dev->ieee80211_ptr) && + (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP_VLAN)) + return 0; +#endif + moal_memcpy_ext(priv->phandle, prev_addr, priv->current_addr, ETH_ALEN, ETH_ALEN); memset(priv->current_addr, 0, ETH_ALEN); @@ -7598,6 +7646,66 @@ done: #endif #endif +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) +/** + * @brief This function check if the packet is easymesh packet + * + * @param priv A pointer to moal_private structure + * @param skb A pointer to sk_buff structure + * + * @return MTRUE/MFALSE + */ +static BOOLEAN woal_check_easymesh_packet(moal_private *priv, + mlan_buffer *pmbuf) +{ + struct sk_buff *skb = pmbuf->pdesc; + ENTER(); + + /** not construct 4 address if SA is same as local address */ + if (!moal_memcmp(NULL, (skb->data + 6), priv->current_addr, ETH_ALEN)) { + PRINTM(MINFO, + "%s: SA is same as local address " FULL_MACSTR "\n", + __func__, FULL_MAC2STR(priv->current_addr)); + LEAVE(); + return MFALSE; + } + + /* RA TA */ + switch (priv->wdev->iftype) { +#ifdef UAP_SUPPORT + case NL80211_IFTYPE_AP_VLAN: + PRINTM(MDAT_D, "%s: Easymesh AP_VLAN\n", priv->netdev->name); + moal_memcpy_ext(priv->phandle, pmbuf->mac, + priv->vlan_sta_ptr->peer_mac, + MLAN_MAC_ADDR_LENGTH, ETH_ALEN); + pmbuf->flags |= MLAN_BUF_FLAG_EASYMESH; + break; +#endif + case NL80211_IFTYPE_STATION: + PRINTM(MDAT_D, "%s Easymesh STATION\n", priv->netdev->name); + moal_memcpy_ext(priv->phandle, pmbuf->mac, priv->cfg_bssid, + ETH_ALEN, ETH_ALEN); + pmbuf->flags |= MLAN_BUF_FLAG_EASYMESH; + break; + default: + PRINTM(MERROR, "Not supported iftype\n"); + LEAVE(); + return MFALSE; + } + PRINTM(MDAT_D, + "Easymesh Tx %s:\nRA: " FULL_MACSTR "\nTA: " FULL_MACSTR + "\nDA: " FULL_MACSTR "\nSA: " FULL_MACSTR "\n", + __func__, FULL_MAC2STR(pmbuf->mac), + FULL_MAC2STR(priv->current_addr), FULL_MAC2STR(skb->data), + FULL_MAC2STR(skb->data + ETH_ALEN)); + + LEAVE(); + return MTRUE; +} +#endif +#endif + /** * @brief This function handles packet transmission * @@ -7616,6 +7724,12 @@ static void woal_start_xmit(moal_private *priv, struct sk_buff *skb) #endif int ret = 0; +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + BOOLEAN multi_ap_packet = MFALSE; +#endif +#endif + ENTER(); priv->num_tx_timeout = 0; @@ -7660,6 +7774,23 @@ static void woal_start_xmit(moal_private *priv, struct sk_buff *skb) pmbuf->bss_index = priv->bss_index; woal_fill_mlan_buffer(priv, pmbuf, skb); +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + if (priv->wdev->use_4addr) { + if ((priv->wdev->iftype == NL80211_IFTYPE_AP_VLAN && + !priv->vlan_sta_ptr) || + (priv->wdev->iftype == NL80211_IFTYPE_STATION && + !priv->media_connected)) { + priv->stats.tx_dropped++; + dev_kfree_skb_any(skb); + LEAVE(); + return; + } + multi_ap_packet = woal_check_easymesh_packet(priv, pmbuf); + } +#endif +#endif + if (priv->enable_tcp_ack_enh == MTRUE) { ret = woal_process_tcp_ack(priv, pmbuf); if (ret) @@ -7696,6 +7827,13 @@ static void woal_start_xmit(moal_private *priv, struct sk_buff *skb) case MLAN_STATUS_PENDING: atomic_inc(&priv->phandle->tx_pending); +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + if (priv->wdev->iftype == NL80211_IFTYPE_AP_VLAN) + priv = priv->parent_priv; +#endif +#endif + #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29) atomic_inc(&priv->wmm_tx_pending[index]); if (atomic_read(&priv->wmm_tx_pending[index]) >= @@ -7999,6 +8137,12 @@ void woal_set_multicast_list(struct net_device *dev) */ void woal_init_priv(moal_private *priv, t_u8 wait_option) { +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + int i; +#endif +#endif + ENTER(); #ifdef STA_SUPPORT if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA) { @@ -8060,6 +8204,14 @@ void woal_init_priv(moal_private *priv, t_u8 wait_option) woal_init_wifi_hal(priv); #endif #endif +#endif + +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + priv->vlan_sta_ptr = NULL; + for (i = 0; i < MAX_STA_COUNT; i++) + priv->vlan_sta_list[i] = NULL; +#endif #endif } #endif @@ -8189,6 +8341,11 @@ void woal_init_priv(moal_private *priv, t_u8 wait_option) priv->chan_num_pkts = DEFAULT_RETRY_PKTS; priv->user_cac_period_msec = 0; priv->chan_under_nop = MFALSE; +#endif +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + priv->multi_ap_flag = 0; +#endif #endif LEAVE(); } @@ -12570,7 +12727,8 @@ static int woal_pcie_reset_and_reload_fw(moal_handle *handle) if (!IS_PCIE9098(handle->card_type) && !IS_PCIEIW624(handle->card_type) && !IS_PCIEAW693(handle->card_type) && - !IS_PCIE9097(handle->card_type)) { + !IS_PCIE9097(handle->card_type) && + !IS_PCIE8997(handle->card_type)) { PRINTM(MERROR, "HW don't support PCIE in-band reset\n"); return -EFAULT; } diff --git a/mxm_wifiex/wlan_src/mlinux/moal_main.h b/mxm_wifiex/wlan_src/mlinux/moal_main.h index 5b9927c..3b04562 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_main.h +++ b/mxm_wifiex/wlan_src/mlinux/moal_main.h @@ -1435,6 +1435,27 @@ typedef struct _auto_zero_dfs_cfg { t_u8 dfs_chan_list[MAX_DFS_CHAN_LIST]; } __ATTRIB_PACK__ auto_zero_dfs_cfg; +#if defined(UAP_CFG80211) || defined(STA_CFG80211) +typedef struct _station_node { + /** station aid */ + t_u16 aid; + /** station mac address */ + t_u8 peer_mac[MLAN_MAC_ADDR_LENGTH]; + /** net_device that station is bind to */ + struct net_device *netdev; + /** is valid flag */ + t_u8 is_valid; +} station_node; + +#define EASY_MESH_MULTI_AP_FH_BSS (t_u8)(0x20) +#define EASY_MESH_MULTI_AP_BH_BSS (t_u8)(0x40) +#define EASY_MESH_MULTI_AP_BH_AND_FH_BSS (t_u8)(0x60) + +#define EASY_MESH_MULTI_AP_BSS_MODE_1 (t_u8)(0x01) +#define EASY_MESH_MULTI_AP_BSS_MODE_2 (t_u8)(0x02) +#define EASY_MESH_MULTI_AP_BSS_MODE_3 (t_u8)(0x03) +#endif + #ifdef STA_SUPPORT enum scan_set_band { SCAN_SETBAND_AUTO = 0, @@ -1813,6 +1834,14 @@ struct _moal_private { void *rings[RING_ID_MAX]; t_u8 pkt_fate_monitor_enable; void *packet_filter; +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + t_u8 multi_ap_flag; + station_node *vlan_sta_ptr; + station_node *vlan_sta_list[MAX_STA_COUNT]; + moal_private *parent_priv; +#endif +#endif /** txwatchdog disable */ t_u8 txwatchdog_disable; @@ -4139,6 +4168,10 @@ void woal_hist_data_add(moal_private *priv, t_u16 rx_rate, t_s8 snr, t_s8 nflr, mlan_status woal_set_hotspotcfg(moal_private *priv, t_u8 wait_option, t_u32 hotspotcfg); +#if defined(STA_CFG80211) +mlan_status woal_multi_ap_cfg(moal_private *priv, t_u8 wait_option, t_u8 flag); +#endif + mlan_status woal_set_get_wowlan_config(moal_private *priv, t_u16 action, t_u8 wait_option, mlan_ds_misc_mef_flt_cfg *mefcfg); diff --git a/mxm_wifiex/wlan_src/mlinux/moal_shim.c b/mxm_wifiex/wlan_src/mlinux/moal_shim.c index 497287c..956bf0b 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_shim.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_shim.c @@ -1886,6 +1886,32 @@ done: #endif #endif +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) +/** + * @brief This function get binded net_device from station list + * + * @param priv Pointer to structure moal_private + * @param aid station aid from mlan + * + * @return binded net_device pointer or NULL if not found + */ +struct net_device *moal_get_netdev_from_stalist(moal_private *priv, t_u16 aid) +{ + station_node *sta_node = NULL; + + ENTER(); + sta_node = priv->vlan_sta_list[(aid - 1) % MAX_STA_COUNT]; + if (sta_node) { + LEAVE(); + return sta_node->netdev; + } + LEAVE(); + return NULL; +} +#endif +#endif + /** * @brief This function uploads amsdu packet to the network stack * @@ -2088,6 +2114,11 @@ mlan_status moal_recv_packet(t_void *pmoal, pmlan_buffer pmbuf) int j; struct ethhdr *ethh = NULL; struct net_device *netdev = NULL; +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + t_u16 aid = 0; +#endif +#endif ENTER(); if (pmbuf) { @@ -2204,6 +2235,23 @@ mlan_status moal_recv_packet(t_void *pmoal, pmlan_buffer pmbuf) priv->deauth_evt_cnt = 0; #endif } +#ifdef UAP_SUPPORT +#if defined(UAP_CFG80211) || defined(STA_CFG80211) + if (pmbuf->flags & MLAN_BUF_FLAG_EASYMESH) { + aid = (pmbuf->priority & 0xFF000000) >> 24; + if (!priv->vlan_sta_list[(aid - 1) % + MAX_STA_COUNT] + ->is_valid) { + status = MLAN_STATUS_FAILURE; + priv->stats.rx_dropped++; + goto done; + } + if (aid != 0) + netdev = moal_get_netdev_from_stalist( + priv, aid); + } +#endif +#endif if (!netdev) netdev = priv->netdev; skb->dev = netdev; diff --git a/mxm_wifiex/wlan_src/mlinux/moal_sta_cfg80211.c b/mxm_wifiex/wlan_src/mlinux/moal_sta_cfg80211.c index fa91645..95dd39d 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_sta_cfg80211.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_sta_cfg80211.c @@ -911,6 +911,9 @@ static int woal_cfg80211_assoc_ies_cfg(moal_private *priv, t_u8 *ie, t_u8 wps_oui[] = {0x00, 0x50, 0xf2, 0x04}; t_u8 hs20_oui[] = {0x50, 0x6f, 0x9a, 0x10}; + t_u8 multiap_oui[] = {0x50, 0x6f, 0x9a, 0x1b}; + t_u8 multiap_flag = 0; + while (bytes_left >= 2) { element_id = (IEEEtypes_ElementId_e)(*((t_u8 *)pcurrent_ptr)); element_len = *((t_u8 *)pcurrent_ptr + 1); @@ -948,6 +951,21 @@ static int woal_cfg80211_assoc_ies_cfg(moal_private *priv, t_u8 *ie, } } + if (!memcmp(pvendor_ie->vend_hdr.oui, multiap_oui, + sizeof(pvendor_ie->vend_hdr.oui)) && + (pvendor_ie->vend_hdr.oui_type == multiap_oui[3])) { + multiap_flag = pvendor_ie->data[0]; + if (MLAN_STATUS_SUCCESS != + woal_multi_ap_cfg(priv, wait_option, + multiap_flag)) { + PRINTM(MERROR, + "%s: failed to configure multi ap\n", + __func__); + ret = -EFAULT; + goto done; + } + } + if (!memcmp(pvendor_ie->vend_hdr.oui, hs20_oui, sizeof(pvendor_ie->vend_hdr.oui)) && (pvendor_ie->vend_hdr.oui_type == hs20_oui[3])) { @@ -2743,6 +2761,7 @@ static int woal_cfg80211_associate(struct wiphy *wiphy, struct net_device *dev, { moal_private *priv = (moal_private *)woal_get_netdev_priv(dev); int ret = 0; + int ie_len; mlan_ssid_bssid *ssid_bssid = NULL; unsigned long flags; const u8 *ssid_ie; @@ -2915,6 +2934,22 @@ done: "woal_get_bss_info Fails to get bss info\n"); } priv->channel = bss_info.bss_chan; + } else { + /* clear the encryption mode */ + if (MLAN_STATUS_SUCCESS != + woal_cfg80211_set_auth(priv, MLAN_ENCRYPTION_MODE_NONE, + MFALSE, MOAL_IOCTL_WAIT)) { + PRINTM(MERROR, "Could not clear encryption \n"); + ret = -EFAULT; + } + /* clear IE */ + ie_len = 0; + if (MLAN_STATUS_SUCCESS != + woal_set_get_gen_ie(priv, MLAN_ACT_SET, NULL, &ie_len, + MOAL_IOCTL_WAIT)) { + PRINTM(MERROR, "Could not clear RSN IE\n"); + ret = -EFAULT; + } } spin_lock_irqsave(&priv->connect_lock, flags); @@ -3385,6 +3420,37 @@ done: return ret; } +#if CFG80211_VERSION_CODE >= KERNEL_VERSION(5, 1, 18) +/** + * @brief This function convert he_gi to nl80211_he_gi + * + * @param he_gi 0/1/2/3 + * + * + * @return 0: NL80211_RATE_INFO_HE_GI_0_8 + * 1: NL80211_RATE_INFO_HE_GI_1_6 + * 2: NL80211_RATE_INFO_HE_GI_3_2 + */ +static t_u8 woal_he_gi_to_nl80211_he_gi(t_u8 he_gi) +{ + t_u8 cfg_he_gi = 0; + switch (he_gi) { + case 3: + cfg_he_gi = NL80211_RATE_INFO_HE_GI_3_2; + break; + case 2: + cfg_he_gi = NL80211_RATE_INFO_HE_GI_1_6; + break; + case 0: + case 1: + default: + cfg_he_gi = NL80211_RATE_INFO_HE_GI_0_8; + break; + } + return cfg_he_gi; +} +#endif + /** * @brief Request the driver to fill the tx/rx rate info * @@ -3461,7 +3527,8 @@ static void woal_cfg80211_fill_rate_info(moal_private *priv, sinfo->txrate.flags = RATE_INFO_FLAGS_HE_MCS; sinfo->txrate.nss = rate->param.data_rate.tx_nss + 1; sinfo->txrate.mcs = rate->param.data_rate.tx_mcs_index; - sinfo->txrate.he_gi = rate->param.data_rate.tx_ht_gi; + sinfo->txrate.he_gi = woal_he_gi_to_nl80211_he_gi( + rate->param.data_rate.tx_ht_gi); if (rate->param.data_rate.tx_ht_bw == MLAN_VHT_BW80) sinfo->txrate.bw = RATE_INFO_BW_80; else if (rate->param.data_rate.tx_ht_bw == MLAN_HT_BW40) @@ -3508,7 +3575,8 @@ static void woal_cfg80211_fill_rate_info(moal_private *priv, sinfo->rxrate.flags = RATE_INFO_FLAGS_HE_MCS; sinfo->rxrate.nss = rate->param.data_rate.rx_nss + 1; sinfo->rxrate.mcs = rate->param.data_rate.rx_mcs_index; - sinfo->rxrate.he_gi = rate->param.data_rate.rx_ht_gi; + sinfo->rxrate.he_gi = woal_he_gi_to_nl80211_he_gi( + rate->param.data_rate.rx_ht_gi); if (rate->param.data_rate.rx_ht_bw == MLAN_VHT_BW80) sinfo->rxrate.bw = RATE_INFO_BW_80; else if (rate->param.data_rate.rx_ht_bw == MLAN_HT_BW40) @@ -4551,7 +4619,30 @@ static int woal_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev, if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) scan_req->chan_list[num_chans].scan_time = INIT_PASSIVE_SCAN_CHAN_TIME; - else + else if ((priv->bss_type == MLAN_BSS_TYPE_STA) && + (1 == + priv->phandle->scan_request->n_channels)) { + /* + * Set passive scan time to 110ms to discover + * all nearby AP's, Current 40ms passive scan + * time does not scan all AP's. There are issues + * with 40ms scan time: + * 1. Regular user passive scan does list + * limited nearby AP's. + * 2. Radio Measurement RPT with beacon report + * for passive scan mode does not list all + * required AP's and hence cert fails. This + * change is limited to below scenario only: + * 1. Single channel user scan is requested + * 2. STA is in connected state + * 3. Scan type is passive + */ + if (scan_req->chan_list[num_chans].scan_type == + MLAN_SCAN_TYPE_PASSIVE) + scan_req->chan_list[num_chans] + .scan_time = + PASSIVE_SCAN_CHAN_TIME; + } else scan_req->chan_list[num_chans].scan_time = MIN( MIN_SPECIFIC_SCAN_CHAN_TIME, scan_cfg.scan_time.specific_scan_time); @@ -7339,8 +7430,8 @@ void woal_check_auto_tdls(struct wiphy *wiphy, struct net_device *dev) if (tdls_discovery) #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 15, 0) #if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 5, 0) - woal_cfg80211_tdls_mgmt(wiphy, dev, bcast_addr, - 0, TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, + woal_cfg80211_tdls_mgmt(wiphy, dev, bcast_addr, 0, + TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0); #else #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) @@ -8490,8 +8581,41 @@ static int woal_cfg80211_change_station(struct wiphy *wiphy, struct station_parameters *params) { int ret = 0; +#ifdef UAP_SUPPORT + moal_private *priv = (moal_private *)woal_get_netdev_priv(dev); + moal_private *vlan_priv = NULL; + station_node *sta_node = NULL; + int i = 0; +#endif ENTER(); +#ifdef UAP_SUPPORT + /** Bind the station to uap virtual interface and + save the station info in moal_private */ + if (params->vlan) { + if (params->vlan->ieee80211_ptr && + params->vlan->ieee80211_ptr->iftype == + NL80211_IFTYPE_AP_VLAN) { + vlan_priv = (moal_private *)woal_get_netdev_priv( + params->vlan); + for (i = 0; i < MAX_STA_COUNT; i++) { + sta_node = priv->vlan_sta_list[i]; + if (sta_node && + !moal_memcmp(priv->phandle, + sta_node->peer_mac, mac, + MLAN_MAC_ADDR_LENGTH)) { + PRINTM(MCMND, + "wlan: Easymesh change station aid=%d\n", + sta_node->aid); + sta_node->netdev = params->vlan; + sta_node->is_valid = MTRUE; + vlan_priv->vlan_sta_ptr = sta_node; + break; + } + } + } + } +#endif /**do nothing*/ LEAVE(); @@ -8522,12 +8646,29 @@ static int woal_cfg80211_add_station(struct wiphy *wiphy, { moal_private *priv = (moal_private *)woal_get_netdev_priv(dev); int ret = 0; + station_node *sta_node = NULL; ENTER(); #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) #ifdef UAP_SUPPORT if (moal_extflg_isset(priv->phandle, EXT_HOST_MLME) && (priv->bss_role == MLAN_BSS_ROLE_UAP)) { + sta_node = kmalloc(sizeof(station_node), GFP_KERNEL); + if (!sta_node) { + PRINTM(MERROR, + "Failed to alloc memory for station node\n"); + LEAVE(); + return -ENOMEM; + } + memset(sta_node, 0, sizeof(*sta_node)); + moal_memcpy_ext(priv->phandle, sta_node->peer_mac, mac, + MLAN_MAC_ADDR_LENGTH, ETH_ALEN); + sta_node->netdev = dev; + sta_node->aid = params->aid; + sta_node->is_valid = MFALSE; + /** AID should start from 1 to MAX_STA_COUNT */ + priv->vlan_sta_list[(params->aid - 1) % MAX_STA_COUNT] = + sta_node; ret = woal_cfg80211_uap_add_station(wiphy, dev, (u8 *)mac, params); LEAVE(); @@ -9934,8 +10075,9 @@ mlan_status woal_register_cfg80211(moal_private *priv) wiphy->max_scan_ssids = MRVDRV_MAX_SSID_LIST_LENGTH; wiphy->max_scan_ie_len = MAX_IE_SIZE; wiphy->interface_modes = 0; - wiphy->interface_modes = - MBIT(NL80211_IFTYPE_STATION) | MBIT(NL80211_IFTYPE_AP); + wiphy->interface_modes = MBIT(NL80211_IFTYPE_STATION) | + MBIT(NL80211_IFTYPE_AP_VLAN) | + MBIT(NL80211_IFTYPE_AP); wiphy->interface_modes |= MBIT(NL80211_IFTYPE_MONITOR); #ifdef WIFI_DIRECT_SUPPORT @@ -10097,6 +10239,8 @@ mlan_status woal_register_cfg80211(moal_private *priv) if (moal_extflg_isset(priv->phandle, EXT_HOST_MLME)) wiphy->features |= NL80211_FEATURE_SAE; #endif + wiphy->flags |= WIPHY_FLAG_4ADDR_AP; + wiphy->flags |= WIPHY_FLAG_4ADDR_STATION; #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; #endif diff --git a/mxm_wifiex/wlan_src/mlinux/moal_uap.c b/mxm_wifiex/wlan_src/mlinux/moal_uap.c index 3db70df..1268079 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_uap.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_uap.c @@ -4111,6 +4111,61 @@ done: return ret; } +#if defined(UAP_CFG80211) +#if defined(STA_WEXT) || defined(UAP_WEXT) +/** + * @brief Set/Get multi AP mode + * + * @param priv A pointer to moal_private structure + * @param wrq A pointer to structure iwreq + * + * @return 0 --success, otherwise fail + */ +int woal_uap_set_get_multi_ap_mode(moal_private *priv, struct iwreq *wrq) +{ + int ret = 0; + int mode = 0; + + ENTER(); + + if (wrq->u.data.length) { + if (wrq->u.data.length > 1) { + PRINTM(MERROR, "Invalid no of arguments!\n"); + ret = -EINVAL; + goto done; + } + if (copy_from_user(&mode, wrq->u.data.pointer, sizeof(int))) { + PRINTM(MERROR, "copy from user failed\n"); + ret = -EFAULT; + goto done; + } + if (mode == EASY_MESH_MULTI_AP_BSS_MODE_3) + /* Supports backhaul and fronthaul BSS */ + priv->multi_ap_flag = EASY_MESH_MULTI_AP_BH_AND_FH_BSS; + else if (mode == EASY_MESH_MULTI_AP_BSS_MODE_2) + /* Supports backhaul BSS */ + priv->multi_ap_flag = EASY_MESH_MULTI_AP_BH_BSS; + else if (mode == EASY_MESH_MULTI_AP_BSS_MODE_1) + /* Supports fronthaul BSS */ + priv->multi_ap_flag = EASY_MESH_MULTI_AP_FH_BSS; + } else { + if (priv->multi_ap_flag == EASY_MESH_MULTI_AP_BH_AND_FH_BSS) + mode = EASY_MESH_MULTI_AP_BSS_MODE_3; + else if (priv->multi_ap_flag == EASY_MESH_MULTI_AP_BH_BSS) + mode = EASY_MESH_MULTI_AP_BSS_MODE_2; + else if (priv->multi_ap_flag == EASY_MESH_MULTI_AP_FH_BSS) + mode = EASY_MESH_MULTI_AP_BSS_MODE_1; + wrq->u.data.length = 1; + if (copy_to_user(wrq->u.data.pointer, &mode, sizeof(int))) + ret = -EFAULT; + } +done: + LEAVE(); + return ret; +} +#endif +#endif + /** * @brief Set AP configuration * diff --git a/mxm_wifiex/wlan_src/mlinux/moal_uap.h b/mxm_wifiex/wlan_src/mlinux/moal_uap.h index 5719f66..1c4d25c 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_uap.h +++ b/mxm_wifiex/wlan_src/mlinux/moal_uap.h @@ -588,6 +588,12 @@ mlan_status woal_set_get_ap_wmm_para(moal_private *priv, t_u16 action, wmm_parameter_t *ap_wmm_para); int woal_uap_set_ap_cfg(moal_private *priv, t_u8 *data, int len); +#if defined(UAP_CFG80211) +#if defined(STA_WEXT) || defined(UAP_WEXT) +int woal_uap_set_get_multi_ap_mode(moal_private *priv, struct iwreq *wrq); +#endif +#endif + int woal_uap_set_11ac_status(moal_private *priv, t_u8 action, t_u8 vht20_40, IEEEtypes_VHTCap_t *vhtcap_ie); int woal_11ax_cfg(moal_private *priv, t_u8 action, mlan_ds_11ax_he_cfg *he_cfg, diff --git a/mxm_wifiex/wlan_src/mlinux/moal_uap_cfg80211.c b/mxm_wifiex/wlan_src/mlinux/moal_uap_cfg80211.c index 0f73065..a836968 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_uap_cfg80211.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_uap_cfg80211.c @@ -31,6 +31,7 @@ /******************************************************** Global Variables ********************************************************/ +extern const struct net_device_ops woal_uap_netdev_ops; /******************************************************** Local Functions ********************************************************/ @@ -1482,6 +1483,11 @@ static int woal_cfg80211_beacon_config(moal_private *priv, sys_config->sta_ageout_timer, sys_config->ps_sta_ageout_timer); #endif + if (priv->multi_ap_flag) { + sys_config->multi_ap_flag = priv->multi_ap_flag; + PRINTM(MINFO, "%s: multi_ap_flag is 0x%x\n", __func__, + sys_config->multi_ap_flag); + } if (MLAN_STATUS_SUCCESS != woal_set_get_sys_config(priv, MLAN_ACT_SET, MOAL_IOCTL_WAIT, sys_config)) { @@ -1666,6 +1672,167 @@ fail: return ret; } +/** + * @brief This function setup the multi-ap virtual interface + * + * @param dev A pointer to structure net_device + * + * @return N/A + */ +static void woal_vlan_virt_if_setup(struct net_device *dev) +{ + ENTER(); + ether_setup(dev); + dev->netdev_ops = &woal_uap_netdev_ops; +#if CFG80211_VERSION_CODE >= KERNEL_VERSION(4, 11, 9) + dev->needs_free_netdev = true; +#else + dev->destructor = free_netdev; +#endif + LEAVE(); +} + +#if CFG80211_VERSION_CODE >= KERNEL_VERSION(4, 1, 0) +/** + * @brief Request the driver to add a multi-ap virtual interface + * + * @param wiphy A pointer to wiphy structure + * @param name Virtual interface name + * @param name_assign_type Interface name assignment type + * @param flags Flags for the virtual interface + * @param params A pointer to vif_params structure + * @param new_dev new net_device to return + * + * @return 0 -- success, otherwise fail + */ +static int woal_cfg80211_add_vlan_vir_if(struct wiphy *wiphy, const char *name, + unsigned char name_assign_type, +#if CFG80211_VERSION_CODE < KERNEL_VERSION(4, 12, 0) + u32 *flags, +#endif + struct vif_params *params, + struct net_device **new_dev) +#else +/** + * @brief Request the driver to add a multi-ap virtual interface + * + * @param wiphy A pointer to wiphy structure + * @param name Virtual interface name + * @param flags Flags for the virtual interface + * @param params A pointer to vif_params structure + * @param new_dev new net_device to return + * + * @return 0 -- success, otherwise fail + */ +static int woal_cfg80211_add_vlan_vir_if(struct wiphy *wiphy, +#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) + const +#endif + char *name, + u32 *flags, struct vif_params *params, + struct net_device **new_dev) +#endif +{ + int ret = 0; + moal_handle *handle = (moal_handle *)woal_get_wiphy_priv(wiphy); + moal_private *priv = + (moal_private *)woal_get_priv(handle, MLAN_BSS_ROLE_UAP); + moal_private *new_priv = NULL; + struct net_device *ndev = NULL; + + ENTER(); + ASSERT_RTNL(); +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29) +#ifndef MAX_WMM_QUEUE +#define MAX_WMM_QUEUE 4 +#endif +#endif +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0) + ndev = alloc_netdev_mq(sizeof(moal_private), name, name_assign_type, + woal_vlan_virt_if_setup, 1); +#else + ndev = alloc_netdev_mq(sizeof(moal_private), name, NET_NAME_UNKNOWN, + woal_vlan_virt_if_setup, 1); +#endif +#else + ndev = alloc_netdev_mq(sizeof(moal_private), name, + woal_vlan_virt_if_setup, 1); +#endif +#else + ndev = alloc_netdev_mq(sizeof(moal_private), name, + woal_vlan_virt_if_setup); +#endif + if (!ndev) { + PRINTM(MFATAL, "Init virtual ethernet device failed\n"); + ret = -EFAULT; + goto fail; + } + + ret = dev_alloc_name(ndev, ndev->name); + if (ret < 0) { + PRINTM(MFATAL, "Net device alloc name fail.\n"); + ret = -EFAULT; + goto fail; + } + + dev_net_set(ndev, wiphy_net(wiphy)); + + moal_memcpy_ext(handle, ndev->perm_addr, wiphy->perm_addr, ETH_ALEN, + sizeof(ndev->perm_addr)); + moal_memcpy_ext(handle, ndev->perm_addr, priv->current_addr, ETH_ALEN, + sizeof(ndev->perm_addr)); + moal_memcpy_ext(handle, (t_void *)ndev->dev_addr, ndev->perm_addr, + ETH_ALEN, MAX_ADDR_LEN); + + SET_NETDEV_DEV(ndev, wiphy_dev(wiphy)); + ndev->watchdog_timeo = MRVDRV_DEFAULT_UAP_WATCHDOG_TIMEOUT; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) + ndev->needed_headroom += MLAN_MIN_DATA_HEADER_LEN + + sizeof(mlan_buffer) + priv->extra_tx_head_len; +#else + ndev->hard_header_len += MLAN_MIN_DATA_HEADER_LEN + + sizeof(mlan_buffer) + priv->extra_tx_head_len; +#endif + + ndev->flags |= IFF_BROADCAST | IFF_MULTICAST; + + new_priv = netdev_priv(ndev); + + ndev->ieee80211_ptr = &new_priv->w_dev; + + new_priv->wdev = &new_priv->w_dev; + new_priv->netdev = ndev; + new_priv->extra_tx_head_len = priv->extra_tx_head_len; + + moal_memcpy_ext(priv->phandle, new_priv->current_addr, + priv->current_addr, ETH_ALEN, ETH_ALEN); + + new_priv->phandle = handle; + new_priv->wdev->wiphy = handle->wiphy; + new_priv->bss_type = MLAN_BSS_TYPE_UAP; + new_priv->bss_role = MLAN_BSS_ROLE_UAP; + new_priv->bss_index = priv->bss_index; + new_priv->parent_priv = priv; + new_priv->wdev->iftype = NL80211_IFTYPE_AP_VLAN; + + ndev->ieee80211_ptr->use_4addr = params->use_4addr; + + ret = register_netdevice(ndev); + if (ret) { + PRINTM(MFATAL, "register net_device failed, ret=%d\n", ret); + free_netdev(ndev); + goto fail; + } + + if (new_dev) + *new_dev = ndev; +fail: + LEAVE(); + return ret; +} + #ifdef WIFI_DIRECT_SUPPORT #if CFG80211_VERSION_CODE >= WIFI_DIRECT_KERNEL_VERSION /** @@ -2348,6 +2515,20 @@ woal_cfg80211_add_virtual_intf(struct wiphy *wiphy, const char *name, ret = -EFAULT; } break; + case NL80211_IFTYPE_AP_VLAN: +#if CFG80211_VERSION_CODE >= KERNEL_VERSION(4, 1, 0) +#if CFG80211_VERSION_CODE < KERNEL_VERSION(4, 12, 0) + ret = woal_cfg80211_add_vlan_vir_if( + wiphy, name, name_assign_type, flags, params, &ndev); +#else + ret = woal_cfg80211_add_vlan_vir_if( + wiphy, name, name_assign_type, params, &ndev); +#endif +#else + ret = woal_cfg80211_add_vlan_vir_if(wiphy, name, flags, params, + &ndev); +#endif + break; default: PRINTM(MWARN, "Not supported if type: %d\n", type); ret = -EFAULT; @@ -2404,6 +2585,9 @@ int woal_cfg80211_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev = wdev->netdev; #endif + moal_private *vlan_priv = NULL; + t_u16 aid = 0; + ENTER(); PRINTM(MIOCTL, "del virtual intf %s\n", dev->name); @@ -2428,6 +2612,26 @@ int woal_cfg80211_del_virtual_intf(struct wiphy *wiphy, return ret; } +#ifdef UAP_SUPPORT + /** + * For multi-ap virtual interface, unregister netdevice + * directly for now. Will add more in the future. + */ + if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP_VLAN) { + /* stop network before doing cleanup */ + if (netif_carrier_ok(dev)) + netif_carrier_off(dev); + vlan_priv = (moal_private *)netdev_priv(dev); + aid = vlan_priv->vlan_sta_ptr->aid; + PRINTM(MCMND, "wlan: Easymesh del Vlan aid=%d\n", aid); + vlan_priv->parent_priv->vlan_sta_list[(aid - 1) % MAX_STA_COUNT] + ->is_valid = MFALSE; + unregister_netdevice(dev); + LEAVE(); + return ret; + } +#endif + if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP) { for (i = 0; i < handle->priv_num; i++) { vir_priv = handle->priv[i]; @@ -2761,6 +2965,7 @@ int woal_cfg80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) #ifdef STA_SUPPORT moal_private *pmpriv = NULL; #endif + int i; ENTER(); @@ -2842,6 +3047,19 @@ int woal_cfg80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) memset(priv->uap_wep_key, 0, sizeof(priv->uap_wep_key)); priv->channel = 0; priv->bandwidth = 0; +#ifdef UAP_SUPPORT + priv->multi_ap_flag = 0; + /* Clear the whole backhaul station list in moal */ + for (i = 0; i < MAX_STA_COUNT; i++) { + if (priv->vlan_sta_list[i]) { + if (priv->vlan_sta_list[i]->is_valid) + unregister_netdevice( + priv->vlan_sta_list[i]->netdev); + kfree(priv->vlan_sta_list[i]); + } + priv->vlan_sta_list[i] = NULL; + } +#endif PRINTM(MMSG, "wlan: AP stopped\n"); done: LEAVE(); diff --git a/mxm_wifiex/wlan_src/mlinux/moal_uap_priv.c b/mxm_wifiex/wlan_src/mlinux/moal_uap_priv.c index b28e0db..ab503b2 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_uap_priv.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_uap_priv.c @@ -119,6 +119,16 @@ int woal_uap_do_priv_ioctl(struct net_device *dev, struct ifreq *req, int cmd) ret = woal_set_get_bss_role(priv, wrq); break; #endif +#endif +#if defined(UAP_CFG80211) +#if defined(STA_WEXT) || defined(UAP_WEXT) + case WOAL_UAP_SET_MODE: + PRINTM(MINFO, + "%s: setting multi_ap flag through user command\n", + __func__); + ret = woal_uap_set_get_multi_ap_mode(priv, wrq); + break; +#endif #endif default: ret = -EINVAL; diff --git a/mxm_wifiex/wlan_src/mlinux/moal_uap_priv.h b/mxm_wifiex/wlan_src/mlinux/moal_uap_priv.h index 4eab2f5..c49d36a 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_uap_priv.h +++ b/mxm_wifiex/wlan_src/mlinux/moal_uap_priv.h @@ -65,6 +65,11 @@ Change log: #endif #endif +#if defined(UAP_CFG80211) +/** Private command ID for set multi-AP BSS mode */ +#define WOAL_UAP_SET_MODE 27 +#endif + /** Private command ID for hostcmd */ #define WOAL_UAP_HOST_CMD (WOAL_UAP_IOCTL + 17) diff --git a/mxm_wifiex/wlan_src/mlinux/moal_uap_wext.c b/mxm_wifiex/wlan_src/mlinux/moal_uap_wext.c index aa4dc78..5fe4926 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_uap_wext.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_uap_wext.c @@ -84,6 +84,10 @@ static const struct iw_priv_args woal_uap_priv_args[] = { #endif #endif +#if defined(UAP_CFG80211) + {WOAL_UAP_SET_MODE, IW_PRIV_TYPE_INT | 1, IW_PRIV_TYPE_INT | 1, + "setmode"}, +#endif {WOAL_UAP_SET_GET_256_CHAR, IW_PRIV_TYPE_CHAR | 256, IW_PRIV_TYPE_CHAR | 256, ""}, {WOAL_WL_FW_RELOAD, IW_PRIV_TYPE_CHAR | 256, IW_PRIV_TYPE_CHAR | 256,