VOID RTMP_CFG80211_VirtualIF_Remove( IN struct rtmp_adapter *pAd, IN struct net_device * dev_p, IN uint32_t DevType) { bool isGoOn = false; struct rtmp_wifi_dev *wdev; if (dev_p) { RTMP_CFG80211_RemoveVifEntry(pAd, dev_p); RTMP_OS_NETDEV_STOP_QUEUE(dev_p); { /* Never Opened When New Netdevice on */ RtmpOSNetDevDetach(dev_p); } if (dev_p->ieee80211_ptr) { kfree(dev_p->ieee80211_ptr); dev_p->ieee80211_ptr = NULL; } } }
VOID RTMP_CFG80211_VirtualIF_Remove( IN VOID *pAdSrc, IN PNET_DEV dev_p, IN UINT32 DevType) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; BOOLEAN isGoOn = FALSE; struct wifi_dev *wdev; if (dev_p) { RTMP_CFG80211_RemoveVifEntry(pAd, dev_p); RTMP_OS_NETDEV_STOP_QUEUE(dev_p); #ifdef RT_CFG80211_P2P_SUPPORT pAd->cfg80211_ctrl.Cfg80211VifDevSet.isGoingOn = FALSE; isGoOn = RTMP_CFG80211_VIF_P2P_GO_ON(pAd); if (isGoOn) { RtmpOSNetDevDetach(dev_p); pAd->ApCfg.MBSSID[MAIN_MBSSID].MSSIDDev = NULL; } else if (pAd->flg_apcli_init) { wdev = &pAd->ApCfg.ApCliTab[MAIN_MBSSID].wdev; OPSTATUS_CLEAR_FLAG(pAd, fOP_AP_STATUS_MEDIA_STATE_CONNECTED); cfg80211_disconnected(dev_p, 0, NULL, 0, GFP_KERNEL); NdisZeroMemory(pAd->ApCfg.ApCliTab[MAIN_MBSSID].CfgApCliBssid, MAC_ADDR_LEN); RtmpOSNetDevDetach(dev_p); rtmp_wdev_idx_unreg(pAd, wdev); pAd->flg_apcli_init = FALSE; wdev->if_dev = NULL; } else #endif /* RT_CFG80211_P2P_SUPPORT */ { /* Never Opened When New Netdevice on */ RtmpOSNetDevDetach(dev_p); } if (dev_p->ieee80211_ptr) { kfree(dev_p->ieee80211_ptr); dev_p->ieee80211_ptr = NULL; } } }
VOID RTMP_CFG80211_VirtualIF_Remove( IN VOID *pAdSrc, IN PNET_DEV dev_p, IN UINT32 DevType) { PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; BOOLEAN isGoOn = FALSE; struct wifi_dev *wdev; #ifdef RT_CFG80211_P2P_SUPPORT UINT apidx = CFG_GO_BSSID_IDX; #else UINT apidx = MAIN_MBSSID; #endif /*RT_CFG80211_P2P_SUPPORT*/ if (dev_p) { pAd->cfg80211_ctrl.Cfg80211VifDevSet.isGoingOn = FALSE; RTMP_CFG80211_RemoveVifEntry(pAd, dev_p); RTMP_OS_NETDEV_STOP_QUEUE(dev_p); #ifdef RT_CFG80211_P2P_CONCURRENT_DEVICE isGoOn = RTMP_CFG80211_VIF_P2P_GO_ON(pAd); if (isGoOn) { wdev = &pAd->ApCfg.MBSSID[apidx].wdev; BSS_STRUCT *pMbss = &pAd->ApCfg.MBSSID[CFG_GO_BSSID_IDX]; struct wifi_dev *pwdev = &pMbss->wdev; if (pAd->Mlme.bStartScc == TRUE) { pAd->Mlme.bStartScc = FALSE; AsicSwitchChannel(pAd, pAd->StaCfg.wdev.CentralChannel, FALSE); AsicLockChannel(pAd, pAd->StaCfg.wdev.CentralChannel); bbp_set_bw(pAd, pAd->StaCfg.wdev.bw); } pwdev->channel = 0; pwdev->CentralChannel= 0; pwdev->bw = 0; pwdev->extcha = EXTCHA_NONE; /*after p2p cli connect , neet to change to default configure*/ pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW; pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40; pAd->CommonCfg.HT_Disable = 0; SetCommonHT(pAd); wdev_bcn_buf_deinit(pAd, &pAd->ApCfg.MBSSID[apidx].bcn_buf); RtmpOSNetDevDetach(dev_p); rtmp_wdev_idx_unreg(pAd, wdev); wdev->if_dev = NULL; } else #endif /* RT_CFG80211_P2P_CONCURRENT_DEVICE */ if (pAd->flg_apcli_init) { wdev = &pAd->ApCfg.ApCliTab[MAIN_MBSSID].wdev; //actually not mcc still need to check this! if (pAd->Mlme.bStartScc == TRUE) { printk("GC remove & switch to Infra BW = %d pAd->StaCfg.wdev.CentralChannel %d \n",pAd->StaCfg.wdev.bw,pAd->StaCfg.wdev.CentralChannel); pAd->Mlme.bStartScc = FALSE; AsicSwitchChannel(pAd, pAd->StaCfg.wdev.CentralChannel, FALSE); AsicLockChannel(pAd, pAd->StaCfg.wdev.CentralChannel); bbp_set_bw(pAd, pAd->StaCfg.wdev.bw); } wdev->CentralChannel = 0; wdev->channel= 0; wdev->bw = HT_BW_20; wdev->extcha = EXTCHA_NONE; OPSTATUS_CLEAR_FLAG(pAd, fOP_AP_STATUS_MEDIA_STATE_CONNECTED); cfg80211_disconnected(dev_p, 0, NULL, 0, GFP_KERNEL); NdisZeroMemory(pAd->ApCfg.ApCliTab[MAIN_MBSSID].CfgApCliBssid, MAC_ADDR_LEN); RtmpOSNetDevDetach(dev_p); rtmp_wdev_idx_unreg(pAd, wdev); pAd->flg_apcli_init = FALSE; wdev->if_dev = NULL; } else /* Never Opened When New Netdevice on */ { RtmpOSNetDevDetach(dev_p); } if (dev_p->ieee80211_ptr) { kfree(dev_p->ieee80211_ptr); dev_p->ieee80211_ptr = NULL; } } }
BOOLEAN CFG80211DRV_OpsChgVirtualInf(RTMP_ADAPTER *pAd, VOID *pData) { PCFG80211_CTRL pCfg80211_ctrl = &pAd->cfg80211_ctrl; UINT newType, oldType; CMD_RTPRIV_IOCTL_80211_VIF_PARM *pVifParm; pVifParm = (CMD_RTPRIV_IOCTL_80211_VIF_PARM *)pData; newType = pVifParm->newIfType; oldType = pVifParm->oldIfType; #ifdef RT_CFG80211_P2P_STATIC_CONCURRENT_DEVICE APCLI_STRUCT *pApCliEntry; struct wifi_dev *wdev; PCFG80211_CTRL cfg80211_ctrl = &pAd->cfg80211_ctrl; UINT apidx = 1; CHAR tr_tb_idx = MAX_LEN_OF_MAC_TABLE + apidx; printk(" CFG80211DRV_OpsChgVirtualInf newType %d oldType %d \n",newType,oldType); if (strcmp(pVifParm->net_dev->name, "p2p0") == 0) { switch (newType) { case RT_CMD_80211_IFTYPE_MONITOR: DBGPRINT(RT_DEBUG_TRACE, ("CFG80211 I/F Monitor Type\n")); //RTMP_OS_NETDEV_SET_TYPE_MONITOR(new_dev_p); break; case RT_CMD_80211_IFTYPE_STATION: RTMP_CFG80211_RemoveVifEntry(pAd,cfg80211_ctrl->dummy_p2p_net_dev); RTMP_CFG80211_AddVifEntry(pAd, cfg80211_ctrl->dummy_p2p_net_dev, newType); AsicSetBssid(pAd, pAd->cfg80211_ctrl.P2PCurrentAddress, 0x1); AsicSetBssid(pAd, pAd->CurrentAddress, 0x0); break; case RT_CMD_80211_IFTYPE_P2P_CLIENT: pAd->ApCfg.ApCliTab[MAIN_MBSSID].wdev.if_dev = NULL; pApCliEntry = &pAd->ApCfg.ApCliTab[MAIN_MBSSID]; pApCliEntry->wdev.if_dev= cfg80211_ctrl->dummy_p2p_net_dev; wdev = &pApCliEntry->wdev; wdev->wdev_type = WDEV_TYPE_STA; wdev->func_dev = pApCliEntry; wdev->sys_handle = (void *)pAd; DBGPRINT(RT_DEBUG_TRACE, ("ApCli_Open\n")); RTMP_CFG80211_RemoveVifEntry(pAd,cfg80211_ctrl->dummy_p2p_net_dev); /* TX */ RTMP_CFG80211_AddVifEntry(pAd, cfg80211_ctrl->dummy_p2p_net_dev, newType); wdev->tx_pkt_allowed = ApCliAllowToSendPacket; wdev->wdev_hard_tx = APHardTransmit; wdev->tx_pkt_handle = APSendPacket; /* RX */ wdev->rx_pkt_allowed = sta_rx_pkt_allow; wdev->rx_pkt_foward = sta_rx_fwd_hnd; RTMP_OS_NETDEV_SET_PRIV(cfg80211_ctrl->dummy_p2p_net_dev, pAd); RTMP_OS_NETDEV_SET_WDEV(cfg80211_ctrl->dummy_p2p_net_dev, wdev); COPY_MAC_ADDR(wdev->if_addr,pAd->cfg80211_ctrl.P2PCurrentAddress); if (rtmp_wdev_idx_reg(pAd, wdev) < 0) { DBGPRINT(RT_DEBUG_ERROR, ("%s: Assign wdev idx for %s failed, free net device!\n", __FUNCTION__,RTMP_OS_NETDEV_GET_DEVNAME(cfg80211_ctrl->dummy_p2p_net_dev))); RtmpOSNetDevFree(cfg80211_ctrl->dummy_p2p_net_dev); break; } pAd->flg_apcli_init = TRUE; ApCli_Open(pAd, cfg80211_ctrl->dummy_p2p_net_dev); // COPY_MAC_ADDR(wdev->if_addr,pAd->cfg80211_ctrl.P2PCurrentAddress); AsicSetBssid(pAd, pAd->CurrentAddress, 0x0); break; case RT_CMD_80211_IFTYPE_P2P_GO: // pNetDevOps->priv_flags = INT_P2P; /* The Behivaor in SetBeacon Ops */ pAd->cfg80211_ctrl.isCfgInApMode = RT_CMD_80211_IFTYPE_AP; wdev = &pAd->ApCfg.MBSSID[apidx].wdev; wdev->wdev_type = WDEV_TYPE_AP; wdev->func_dev = &pAd->ApCfg.MBSSID[apidx]; wdev->func_idx = apidx; wdev->sys_handle = (void *)pAd; wdev->if_dev = cfg80211_ctrl->dummy_p2p_net_dev; /* BC/MC Handling */ wdev->tr_tb_idx = tr_tb_idx; tr_tb_set_mcast_entry(pAd, tr_tb_idx, wdev); RTMP_CFG80211_RemoveVifEntry(pAd,cfg80211_ctrl->dummy_p2p_net_dev); /* TX */ RTMP_CFG80211_AddVifEntry(pAd, cfg80211_ctrl->dummy_p2p_net_dev, newType); // RT_MOD_INC_USE_COUNT(); /* TX */ wdev->tx_pkt_allowed = ApAllowToSendPacket; wdev->wdev_hard_tx = APHardTransmit; wdev->tx_pkt_handle = APSendPacket; /* RX */ wdev->rx_pkt_allowed = ap_rx_pkt_allow; wdev->rx_pkt_foward = ap_rx_foward_handle; wdev->rx_ps_handle = ap_rx_ps_handle; // RTMP_OS_NETDEV_START_QUEUE(cfg80211_ctrl->dummy_p2p_net_dev); RTMP_OS_NETDEV_SET_PRIV(cfg80211_ctrl->dummy_p2p_net_dev, pAd); RTMP_OS_NETDEV_SET_WDEV(cfg80211_ctrl->dummy_p2p_net_dev, wdev); wdev_bcn_buf_init(pAd, &pAd->ApCfg.MBSSID[apidx].bcn_buf); RTMP_OS_NETDEV_SET_PRIV(cfg80211_ctrl->dummy_p2p_net_dev, pAd); RTMP_OS_NETDEV_SET_WDEV(cfg80211_ctrl->dummy_p2p_net_dev, wdev); if (rtmp_wdev_idx_reg(pAd, wdev) < 0) { DBGPRINT(RT_DEBUG_ERROR, ("%s: Assign wdev idx for %s failed, free net device!\n", __FUNCTION__,RTMP_OS_NETDEV_GET_DEVNAME(cfg80211_ctrl->dummy_p2p_net_dev))); RtmpOSNetDevFree(cfg80211_ctrl->dummy_p2p_net_dev); break; } COPY_MAC_ADDR(pAd->ApCfg.MBSSID[apidx].wdev.if_addr, pAd->cfg80211_ctrl.P2PCurrentAddress); COPY_MAC_ADDR(pAd->ApCfg.MBSSID[apidx].wdev.bssid, pAd->cfg80211_ctrl.P2PCurrentAddress); AsicSetBssid(pAd, pAd->CurrentAddress, 0x0); break; default: DBGPRINT(RT_DEBUG_ERROR, ("Unknown CFG80211 I/F Type (%d)\n", newType)); } } if ((newType == RT_CMD_80211_IFTYPE_STATION) && (oldType == RT_CMD_80211_IFTYPE_P2P_CLIENT) && (pAd->flg_apcli_init == TRUE)) { DBGPRINT(RT_DEBUG_TRACE, ("ApCli_Close\n")); CFG80211OS_ScanEnd(pAd->pCfg80211_CB, TRUE); // RT_MOD_DEC_USE_COUNT(); pAd->flg_apcli_init = FALSE; RT_MOD_INC_USE_COUNT(); printk("iverson ApCli_Close \n"); AsicSetBssid(pAd, pAd->cfg80211_ctrl.P2PCurrentAddress, 0x1); AsicSetBssid(pAd, pAd->CurrentAddress, 0x0); pAd->cfg80211_ctrl.isCfgInApMode = RT_CMD_80211_IFTYPE_STATION; return ApCli_Close(pAd, cfg80211_ctrl->dummy_p2p_net_dev); } else if ((newType == RT_CMD_80211_IFTYPE_STATION) && (oldType == RT_CMD_80211_IFTYPE_P2P_GO)) { DBGPRINT(RT_DEBUG_TRACE, ("GOi_Close\n")); wdev_bcn_buf_deinit(pAd, &pAd->ApCfg.MBSSID[apidx].bcn_buf); AsicSetBssid(pAd, pAd->cfg80211_ctrl.P2PCurrentAddress, 0x1); AsicSetBssid(pAd, pAd->CurrentAddress, 0x0); // rtmp_wdev_idx_unreg(pAd, Wdev); // Wdev->if_dev = NULL; } #endif /* RT_CFG80211_P2P_STATIC_CONCURRENT_DEVICE */ #ifdef RT_CFG80211_P2P_CONCURRENT_DEVICE #ifndef RT_CFG80211_P2P_STATIC_CONCURRENT_DEVICE /* After P2P NEGO phase, the device type may be change from GC to GO or no change. We remove the GC in VIF list if nego as GO case. */ if ((newType == RT_CMD_80211_IFTYPE_P2P_GO) && (oldType == RT_CMD_80211_IFTYPE_P2P_CLIENT)) { RTMP_CFG80211_VirtualIF_CancelP2pClient(pAd); } #endif /* RT_CFG80211_P2P_STATIC_CONCURRENT_DEVICE */ #endif /* RT_CFG80211_P2P_CONCURRENT_DEVICE */ #ifdef RT_CFG80211_P2P_SINGLE_DEVICE CFG80211DBG(RT_DEBUG_TRACE, ("80211> @@@ Change from %u to %u Mode\n",oldType,newType)); pCfg80211_ctrl->P2POpStatusFlags = CFG_P2P_DISABLE; if (newType == RT_CMD_80211_IFTYPE_P2P_CLIENT) { pCfg80211_ctrl->P2POpStatusFlags = CFG_P2P_CLI_UP; } else if (newType == RT_CMD_80211_IFTYPE_P2P_GO) { pCfg80211_ctrl->P2POpStatusFlags = CFG_P2P_GO_UP; } #endif /* RT_CFG80211_P2P_SINGLE_DEVICE */ /* Change Device Type */ #ifdef CONFIG_STA_SUPPORT if (newType == RT_CMD_80211_IFTYPE_ADHOC) { #ifdef DOT11_N_SUPPORT SetCommonHT(pAd); #endif /* DOT11_N_SUPPORT */ pAd->StaCfg.BssType = BSS_ADHOC; } else #endif /* CONFIG_STA_SUPPORT */ if ((newType == RT_CMD_80211_IFTYPE_STATION) || (newType == RT_CMD_80211_IFTYPE_P2P_CLIENT)) { CFG80211DBG(RT_DEBUG_TRACE, ("80211> Change the Interface to STA Mode\n")); #ifdef CONFIG_STA_SUPPORT if ((oldType == RT_CMD_80211_IFTYPE_ADHOC) && (newType == RT_CMD_80211_IFTYPE_STATION)) { /* DeviceType Change from adhoc to infra, only in StaCfg. CFG Todo: It should not bind by device. */ pAd->StaCfg.BssType = BSS_INFRA; } #endif /* CONFIG_STA_SUPPORT */ #ifdef CONFIG_AP_SUPPORT if (pAd->cfg80211_ctrl.isCfgInApMode == RT_CMD_80211_IFTYPE_AP) CFG80211DRV_DisableApInterface(pAd); #endif /* CONFIG_AP_SUPPORT */ pAd->cfg80211_ctrl.isCfgInApMode = RT_CMD_80211_IFTYPE_STATION; } else if ((newType == RT_CMD_80211_IFTYPE_AP) || (newType == RT_CMD_80211_IFTYPE_P2P_GO)) { CFG80211DBG(RT_DEBUG_TRACE, ("80211> Change the Interface to AP Mode\n")); pAd->cfg80211_ctrl.isCfgInApMode = RT_CMD_80211_IFTYPE_AP; } #ifdef CONFIG_STA_SUPPORT else if (newType == RT_CMD_80211_IFTYPE_MONITOR) { /* set packet filter */ Set_NetworkType_Proc(pAd, "Monitor"); if (pVifParm->MonFilterFlag != 0) { UINT32 Filter = 0; #ifndef MT_MAC if (pAd->chipCap.hif_type != HIF_MT) { RTMP_IO_READ32(pAd, RX_FILTR_CFG, &Filter); if ((pVifParm->MonFilterFlag & RT_CMD_80211_FILTER_FCSFAIL) == RT_CMD_80211_FILTER_FCSFAIL) { Filter = Filter & (~0x01); } else { Filter = Filter | 0x01; } if ((pVifParm->MonFilterFlag & RT_CMD_80211_FILTER_PLCPFAIL) == RT_CMD_80211_FILTER_PLCPFAIL) { Filter = Filter & (~0x02); } else { Filter = Filter | 0x02; } if ((pVifParm->MonFilterFlag & RT_CMD_80211_FILTER_CONTROL) == RT_CMD_80211_FILTER_CONTROL) { Filter = Filter & (~0xFF00); } else { Filter = Filter | 0xFF00; } if ((pVifParm->MonFilterFlag & RT_CMD_80211_FILTER_OTHER_BSS) == RT_CMD_80211_FILTER_OTHER_BSS) { Filter = Filter & (~0x08); } else { Filter = Filter | 0x08; } RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, Filter); } #endif /* MT_MAC */ pVifParm->MonFilterFlag = Filter; } } #endif /*CONFIG_STA_SUPPORT*/ if ((newType == RT_CMD_80211_IFTYPE_P2P_CLIENT) || (newType == RT_CMD_80211_IFTYPE_P2P_GO)) { COPY_MAC_ADDR(pAd->cfg80211_ctrl.P2PCurrentAddress, pVifParm->net_dev->dev_addr); } else { #ifdef RT_CFG80211_P2P_SUPPORT pCfg80211_ctrl->bP2pCliPmEnable = FALSE; pCfg80211_ctrl->bPreKeepSlient = FALSE; pCfg80211_ctrl->bKeepSlient = FALSE; pCfg80211_ctrl->NoAIndex = MAX_LEN_OF_MAC_TABLE; pCfg80211_ctrl->MyGOwcid = MAX_LEN_OF_MAC_TABLE; pCfg80211_ctrl->CTWindows= 0; /* CTWindows and OppPS parameter field */ #endif /* RT_CFG80211_P2P_SUPPORT */ } if(pCfg80211_ctrl == NULL) CFG80211DBG(RT_DEBUG_TRACE, ("(%s)pCfg80211_ctrl is null",__FUNCTION__)); return TRUE; }