BOOL ADPbShutdown( PSAdapterInfo pAdapter ) { /* Stop chip */ if (!MACbSafeStop(pAdapter->dwIoBase, pAdapter->byRevId)) return FALSE; /* Stop ISR */ MACvIntDisable(pAdapter->dwIoBase, pAdapter->byRevId); /* Take off Interrupt Service Routine */ /* unset_irq_handlers(pAdapter->byIrqLevel); */ /* Disable Interrupt */ /* mask_interrupt(pAdapter->byIrqLevel); */ MacDump(MACDBG_INFO, ("[ADPbShutdown] - Take off ISR on IRQ%d\n", pAdapter->byIrqLevel)); /* Destroy RDR/TDR */ /* ALCvFreeRdrMemory(pAdapter); */ /* ALCvFreeTdrMemory(pAdapter); */ if (pAdapter->pbyTmpBuff != NULL) pAdapter->pbyTmpBuff = NULL; return TRUE; }
int mac_receive(void) { PSRxDesc pRD; int length = 0, tmp; DWORD isr_status; /* 1.store ISR */ MACvReadISR(sg_aAdapter->dwIoBase, sg_aAdapter->byRevId, &isr_status); /* 2.disable IMR */ MACvIntDisable(sg_aAdapter->dwIoBase, sg_aAdapter->byRevId); /* 3clear ISR */ MACvWriteISR(sg_aAdapter->dwIoBase, sg_aAdapter->byRevId, isr_status); /* 4.handle ISR */ /* 5.handle received packets until owner==chip */ /* printf("enter mac_receive\n"); */ while (TRUE) { pRD = sg_aAdapter->apRD[sg_aAdapter->idxRxCurDesc]; /* a.check RD status */ /* if owner==chip break; */ if (pRD->m_rd0RD0.f1Owner == B_OWNED_BY_CHIP) { /* printf("receive done \n"); */ break; } /* if ok, net_receive() */ if (pRD->m_rd0RD0.byRSR1&RSR1_RXOK) { NetReceive((volatile uchar *)pRD->m_dwRxBufferAddr, pRD->m_rd0RD0.f15FrameLen-4); length += (pRD->m_rd0RD0.f15FrameLen-4); #if MACDBG printf("receive ok\n"); #endif } else { /* else, error handling */ printf("receive error status:%02X %02X%\n", pRD->m_rd0RD0.byRSR1, pRD->m_rd0RD0.byRSR0); /* handler will do later */ } /* b.set own==chip */ pRD->m_rd0RD0.f1Owner = B_OWNED_BY_CHIP; /* c.increase to next RD */ tmp = (++sg_aAdapter->idxRxCurDesc); sg_aAdapter->idxRxCurDesc = tmp % sg_aAdapter->cbRD; #if MACDBG printf("jump to next RD =%d\n", sg_aAdapter->idxRxCurDesc); #endif } /* 6.enable IMR */ MACvIntEnable(sg_aAdapter->dwIoBase, sg_aAdapter->byRevId, IMR_MASK_VALUE); return length; }
BOOL GMACbShutdown(DWORD dwIoBase, BYTE byRevId) { /* disable MAC IMR */ MACvIntDisable(dwIoBase); /* disable MII auto-poll */ GMACvDisableMiiAutoPoll(dwIoBase); /* stop the adapter */ if (!GMACbSafeStop(dwIoBase, byRevId)) return FALSE; return TRUE; }
/* * Description: * Shut Down MAC * * Parameters: * In: * dwIoBase - Base Address for MAC * Out: * none * * Return Value: true if success; otherwise false * */ bool MACbShutdown(void __iomem *dwIoBase) { // disable MAC IMR MACvIntDisable(dwIoBase); MACvSetLoopbackMode(dwIoBase, MAC_LB_INTERNAL); // stop the adapter if (!MACbSafeStop(dwIoBase)) { MACvSetLoopbackMode(dwIoBase, MAC_LB_NONE); return false; } MACvSetLoopbackMode(dwIoBase, MAC_LB_NONE); return true; }
/* * Description: * Shut Down MAC * * Parameters: * In: * io_base - Base Address for MAC * Out: * none * * Return Value: true if success; otherwise false * */ bool MACbShutdown(struct vnt_private *priv) { void __iomem *io_base = priv->PortOffset; /* disable MAC IMR */ MACvIntDisable(io_base); MACvSetLoopbackMode(priv, MAC_LB_INTERNAL); /* stop the adapter */ if (!MACbSafeStop(priv)) { MACvSetLoopbackMode(priv, MAC_LB_NONE); return false; } MACvSetLoopbackMode(priv, MAC_LB_NONE); return true; }
static irqreturn_t device_intr(int irq, void *dev_instance) { struct vnt_private *pDevice = dev_instance; int max_count = 0; unsigned long dwMIBCounter = 0; unsigned char byOrgPageSel = 0; int handled = 0; unsigned long flags; MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); if (pDevice->dwIsr == 0) return IRQ_RETVAL(handled); if (pDevice->dwIsr == 0xffffffff) { pr_debug("dwIsr = 0xffff\n"); return IRQ_RETVAL(handled); } handled = 1; MACvIntDisable(pDevice->PortOffset); spin_lock_irqsave(&pDevice->lock, flags); //Make sure current page is 0 VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel); if (byOrgPageSel == 1) MACvSelectPage0(pDevice->PortOffset); else byOrgPageSel = 0; MACvReadMIBCounter(pDevice->PortOffset, &dwMIBCounter); // TBD.... // Must do this after doing rx/tx, cause ISR bit is slow // than RD/TD write back // update ISR counter STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic, dwMIBCounter); while (pDevice->dwIsr != 0) { STAvUpdateIsrStatCounter(&pDevice->scStatistic, pDevice->dwIsr); MACvWriteISR(pDevice->PortOffset, pDevice->dwIsr); if (pDevice->dwIsr & ISR_FETALERR) { pr_debug(" ISR_FETALERR\n"); VNSvOutPortB(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, 0); VNSvOutPortW(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI); device_error(pDevice, pDevice->dwIsr); } if (pDevice->dwIsr & ISR_TBTT) { if (pDevice->vif && pDevice->op_mode != NL80211_IFTYPE_ADHOC) vnt_check_bb_vga(pDevice); pDevice->bBeaconSent = false; if (pDevice->bEnablePSMode) PSbIsNextTBTTWakeUp((void *)pDevice); if ((pDevice->op_mode == NL80211_IFTYPE_AP || pDevice->op_mode == NL80211_IFTYPE_ADHOC) && pDevice->vif->bss_conf.enable_beacon) { MACvOneShotTimer1MicroSec(pDevice->PortOffset, (pDevice->vif->bss_conf.beacon_int - MAKE_BEACON_RESERVED) << 10); } /* TODO: adhoc PS mode */ } if (pDevice->dwIsr & ISR_BNTX) { if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) { pDevice->bIsBeaconBufReadySet = false; pDevice->cbBeaconBufReadySetCnt = 0; } pDevice->bBeaconSent = true; } if (pDevice->dwIsr & ISR_RXDMA0) max_count += device_rx_srv(pDevice, TYPE_RXDMA0); if (pDevice->dwIsr & ISR_RXDMA1) max_count += device_rx_srv(pDevice, TYPE_RXDMA1); if (pDevice->dwIsr & ISR_TXDMA0) max_count += device_tx_srv(pDevice, TYPE_TXDMA0); if (pDevice->dwIsr & ISR_AC0DMA) max_count += device_tx_srv(pDevice, TYPE_AC0DMA); if (pDevice->dwIsr & ISR_SOFTTIMER1) { if (pDevice->vif) { if (pDevice->vif->bss_conf.enable_beacon) vnt_beacon_make(pDevice, pDevice->vif); } } /* If both buffers available wake the queue */ if (pDevice->vif) { if (AVAIL_TD(pDevice, TYPE_TXDMA0) && AVAIL_TD(pDevice, TYPE_AC0DMA) && ieee80211_queue_stopped(pDevice->hw, 0)) ieee80211_wake_queues(pDevice->hw); } MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); MACvReceive0(pDevice->PortOffset); MACvReceive1(pDevice->PortOffset); if (max_count > pDevice->sOpts.int_works) break; } if (byOrgPageSel == 1) MACvSelectPage1(pDevice->PortOffset); spin_unlock_irqrestore(&pDevice->lock, flags); MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); return IRQ_RETVAL(handled); }
static void vnt_interrupt_process(struct vnt_private *priv) { struct ieee80211_low_level_stats *low_stats = &priv->low_stats; int max_count = 0; u32 mib_counter; u32 isr; unsigned long flags; MACvReadISR(priv->PortOffset, &isr); if (isr == 0) return; if (isr == 0xffffffff) { pr_debug("isr = 0xffff\n"); return; } MACvIntDisable(priv->PortOffset); spin_lock_irqsave(&priv->lock, flags); /* Read low level stats */ MACvReadMIBCounter(priv->PortOffset, &mib_counter); low_stats->dot11RTSSuccessCount += mib_counter & 0xff; low_stats->dot11RTSFailureCount += (mib_counter >> 8) & 0xff; low_stats->dot11ACKFailureCount += (mib_counter >> 16) & 0xff; low_stats->dot11FCSErrorCount += (mib_counter >> 24) & 0xff; /* * TBD.... * Must do this after doing rx/tx, cause ISR bit is slow * than RD/TD write back * update ISR counter */ while (isr && priv->vif) { MACvWriteISR(priv->PortOffset, isr); if (isr & ISR_FETALERR) { pr_debug(" ISR_FETALERR\n"); VNSvOutPortB(priv->PortOffset + MAC_REG_SOFTPWRCTL, 0); VNSvOutPortW(priv->PortOffset + MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI); device_error(priv, isr); } if (isr & ISR_TBTT) { if (priv->op_mode != NL80211_IFTYPE_ADHOC) vnt_check_bb_vga(priv); priv->bBeaconSent = false; if (priv->bEnablePSMode) PSbIsNextTBTTWakeUp((void *)priv); if ((priv->op_mode == NL80211_IFTYPE_AP || priv->op_mode == NL80211_IFTYPE_ADHOC) && priv->vif->bss_conf.enable_beacon) { MACvOneShotTimer1MicroSec(priv->PortOffset, (priv->vif->bss_conf.beacon_int - MAKE_BEACON_RESERVED) << 10); } /* TODO: adhoc PS mode */ } if (isr & ISR_BNTX) { if (priv->op_mode == NL80211_IFTYPE_ADHOC) { priv->bIsBeaconBufReadySet = false; priv->cbBeaconBufReadySetCnt = 0; } priv->bBeaconSent = true; } if (isr & ISR_RXDMA0) max_count += device_rx_srv(priv, TYPE_RXDMA0); if (isr & ISR_RXDMA1) max_count += device_rx_srv(priv, TYPE_RXDMA1); if (isr & ISR_TXDMA0) max_count += device_tx_srv(priv, TYPE_TXDMA0); if (isr & ISR_AC0DMA) max_count += device_tx_srv(priv, TYPE_AC0DMA); if (isr & ISR_SOFTTIMER1) { if (priv->vif->bss_conf.enable_beacon) vnt_beacon_make(priv, priv->vif); } /* If both buffers available wake the queue */ if (AVAIL_TD(priv, TYPE_TXDMA0) && AVAIL_TD(priv, TYPE_AC0DMA) && ieee80211_queue_stopped(priv->hw, 0)) ieee80211_wake_queues(priv->hw); MACvReadISR(priv->PortOffset, &isr); MACvReceive0(priv->PortOffset); MACvReceive1(priv->PortOffset); if (max_count > priv->sOpts.int_works) break; } spin_unlock_irqrestore(&priv->lock, flags); MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE); }
int private_ioctl(PSDevice pDevice, struct ifreq *rq) { PSCmdRequest pReq = (PSCmdRequest)rq; PSMgmtObject pMgmt = pDevice->pMgmt; int result = 0; PWLAN_IE_SSID pItemSSID; SCmdBSSJoin sJoinCmd; SCmdZoneTypeSet sZoneTypeCmd; SCmdScan sScanCmd; SCmdStartAP sStartAPCmd; SCmdSetWEP sWEPCmd; SCmdValue sValue; SBSSIDList sList; SNodeList sNodeList; PSBSSIDList pList; PSNodeList pNodeList; unsigned int cbListCount; PKnownBSS pBSS; PKnownNodeDB pNode; unsigned int ii, jj; SCmdLinkStatus sLinkStatus; unsigned char abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; unsigned long dwKeyIndex = 0; unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; long ldBm; pReq->wResult = 0; switch (pReq->wCmdCode) { case WLAN_CMD_BSS_SCAN: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n"); if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) { result = -EFAULT; break; } pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid; if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) return -EINVAL; if (pItemSSID->len != 0) { memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); } if (pDevice->bMACSuspend == true) { if (pDevice->bRadioOff == true) CARDbRadioPowerOn(pDevice); vMgrTimerInit(pDevice); MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); add_timer(&pMgmt->sTimerSecondCallback); pDevice->bMACSuspend = false; } spin_lock_irq(&pDevice->lock); if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0) BSSvClearBSSList((void *)pDevice, false); else BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); if (pItemSSID->len != 0) bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID); else bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); spin_unlock_irq(&pDevice->lock); break; case WLAN_CMD_ZONETYPE_SET: /* mike add :can't support. */ result = -EOPNOTSUPP; break; if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) { result = -EFAULT; break; } if (sZoneTypeCmd.bWrite == true) { /* write zonetype */ if (sZoneTypeCmd.ZoneType == ZoneType_USA) { /* set to USA */ printk("set_ZoneType:USA\n"); } else if (sZoneTypeCmd.ZoneType == ZoneType_Japan) { /* set to Japan */ printk("set_ZoneType:Japan\n"); } else if (sZoneTypeCmd.ZoneType == ZoneType_Europe) { /* set to Europe */ printk("set_ZoneType:Europe\n"); } } else { /* read zonetype */ unsigned char zonetype = 0; if (zonetype == 0x00) { /* USA */ sZoneTypeCmd.ZoneType = ZoneType_USA; } else if (zonetype == 0x01) { /* Japan */ sZoneTypeCmd.ZoneType = ZoneType_Japan; } else if (zonetype == 0x02) { /* Europe */ sZoneTypeCmd.ZoneType = ZoneType_Europe; } else { /* Unknown ZoneType */ printk("Error:ZoneType[%x] Unknown ???\n", zonetype); result = -EFAULT; break; } if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) { result = -EFAULT; break; } } break; case WLAN_CMD_BSS_JOIN: if (pDevice->bMACSuspend == true) { if (pDevice->bRadioOff == true) CARDbRadioPowerOn(pDevice); vMgrTimerInit(pDevice); MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); add_timer(&pMgmt->sTimerSecondCallback); pDevice->bMACSuspend = false; } if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) { result = -EFAULT; break; } pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid; if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) return -EINVAL; memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); if (sJoinCmd.wBSSType == ADHOC) { pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n"); } else { pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n"); } if (sJoinCmd.bPSEnable == true) { pDevice->ePSMode = WMAC_POWER_FAST; pMgmt->wListenInterval = 2; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n"); } else { pDevice->ePSMode = WMAC_POWER_CAM; pMgmt->wListenInterval = 1; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off\n"); } if (sJoinCmd.bShareKeyAuth == true) { pMgmt->bShareKeyAlgorithm = true; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n"); } else { pMgmt->bShareKeyAlgorithm = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n"); } pDevice->uChannel = sJoinCmd.uChannel; netif_stop_queue(pDevice->dev); spin_lock_irq(&pDevice->lock); pMgmt->eCurrState = WMAC_STATE_IDLE; bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); spin_unlock_irq(&pDevice->lock); break; case WLAN_CMD_SET_WEP: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key.\n"); memset(&sWEPCmd, 0, sizeof(SCmdSetWEP)); if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) { result = -EFAULT; break; } if (sWEPCmd.bEnableWep != true) { pDevice->bEncryptionEnable = false; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; MACvDisableDefaultKey(pDevice->PortOffset); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n"); break; } for (ii = 0; ii < WLAN_WEP_NKEYS; ii++) { if (sWEPCmd.bWepKeyAvailable[ii]) { if (ii == sWEPCmd.byKeyIndex) dwKeyIndex = ii | (1 << 31); else dwKeyIndex = ii; KeybSetDefaultKey(&(pDevice->sKey), dwKeyIndex, sWEPCmd.auWepKeyLength[ii], NULL, (unsigned char *)&sWEPCmd.abyWepKey[ii][0], KEY_CTL_WEP, pDevice->PortOffset, pDevice->byLocalID); } } pDevice->byKeyIndex = sWEPCmd.byKeyIndex; pDevice->bTransmitKey = true; pDevice->bEncryptionEnable = true; pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; break; case WLAN_CMD_GET_LINK: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status.\n"); memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1); if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) sLinkStatus.wBSSType = ADHOC; else sLinkStatus.wBSSType = INFRA; if (pMgmt->eCurrState == WMAC_STATE_JOINTED) sLinkStatus.byState = ADHOC_JOINTED; else sLinkStatus.byState = ADHOC_STARTED; sLinkStatus.uChannel = pMgmt->uCurrChannel; if (pDevice->bLinkPass == true) { sLinkStatus.bLink = true; pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len); memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success!\n"); } else { sLinkStatus.bLink = false; sLinkStatus.uLinkRate = 0; } if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) { result = -EFAULT; break; } break; case WLAN_CMD_GET_LISTLEN: cbListCount = 0; pBSS = &(pMgmt->sBSSList[0]); for (ii = 0; ii < MAX_BSS_NUM; ii++) { pBSS = &(pMgmt->sBSSList[ii]); if (!pBSS->bActive) continue; cbListCount++; } sList.uItem = cbListCount; if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) { result = -EFAULT; break; } pReq->wResult = 0; break; case WLAN_CMD_GET_LIST: if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) { result = -EFAULT; break; } if (sList.uItem > (ULONG_MAX - sizeof(SBSSIDList)) / sizeof(SBSSIDItem)) { result = -EINVAL; break; } pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC); if (pList == NULL) { result = -ENOMEM; break; } pList->uItem = sList.uItem; pBSS = &(pMgmt->sBSSList[0]); for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) { pBSS = &(pMgmt->sBSSList[jj]); if (pBSS->bActive) { pList->sBSSIDList[ii].uChannel = pBSS->uChannel; pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval; pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo; /* pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; */ RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm); pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm; memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN); pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1); memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len); if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) pList->sBSSIDList[ii].byNetType = INFRA; else pList->sBSSIDList[ii].byNetType = ADHOC; if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) pList->sBSSIDList[ii].bWEPOn = true; else pList->sBSSIDList[ii].bWEPOn = false; ii++; if (ii >= pList->uItem) break; } } if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) { result = -EFAULT; break; } kfree(pList); pReq->wResult = 0; break; case WLAN_CMD_GET_MIB: if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) { result = -EFAULT; break; } break; case WLAN_CMD_GET_STAT: if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) { result = -EFAULT; break; } break; case WLAN_CMD_STOP_MAC: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n"); netif_stop_queue(pDevice->dev); spin_lock_irq(&pDevice->lock); if (pDevice->bRadioOff == false) CARDbRadioPowerOff(pDevice); pDevice->bLinkPass = false; memset(pMgmt->abyCurrBSSID, 0, 6); pMgmt->eCurrState = WMAC_STATE_IDLE; del_timer(&pDevice->sTimerCommand); del_timer(&pMgmt->sTimerSecondCallback); pDevice->bCmdRunning = false; pDevice->bMACSuspend = true; MACvIntDisable(pDevice->PortOffset); spin_unlock_irq(&pDevice->lock); break; case WLAN_CMD_START_MAC: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n"); if (pDevice->bMACSuspend == true) { if (pDevice->bRadioOff == true) CARDbRadioPowerOn(pDevice); vMgrTimerInit(pDevice); MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); add_timer(&pMgmt->sTimerSecondCallback); pDevice->bMACSuspend = false; } break; case WLAN_CMD_SET_HOSTAPD: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n"); if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { result = -EFAULT; break; } if (sValue.dwValue == 1) { if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n"); } else { result = -EFAULT; break; } } else { vt6655_hostap_set_hostapd(pDevice, 0, 1); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n"); } break; case WLAN_CMD_SET_HOSTAPD_STA: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n"); break; case WLAN_CMD_SET_802_1X: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n"); if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { result = -EFAULT; break; } if (sValue.dwValue == 1) { pDevice->bEnable8021x = true; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n"); } else { pDevice->bEnable8021x = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n"); } break; case WLAN_CMD_SET_HOST_WEP: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n"); if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { result = -EFAULT; break; } if (sValue.dwValue == 1) { pDevice->bEnableHostWEP = true; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n"); } else { pDevice->bEnableHostWEP = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n"); } break; case WLAN_CMD_SET_WPA: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n"); if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { result = -EFAULT; break; } if (sValue.dwValue == 1) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n"); memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, ETH_ALEN); pDevice->bWPADEVUp = true; } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n"); pDevice->bWPADEVUp = false; } break; case WLAN_CMD_AP_START: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n"); if (pDevice->bRadioOff == true) { CARDbRadioPowerOn(pDevice); vMgrTimerInit(pDevice); MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); add_timer(&pMgmt->sTimerSecondCallback); } if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) { result = -EFAULT; break; } if (sStartAPCmd.wBSSType == AP) { pMgmt->eConfigMode = WMAC_CONFIG_AP; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n"); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n"); result = -EFAULT; break; } if (sStartAPCmd.wBBPType == PHY80211g) pMgmt->byAPBBType = PHY_TYPE_11G; else if (sStartAPCmd.wBBPType == PHY80211a) pMgmt->byAPBBType = PHY_TYPE_11A; else pMgmt->byAPBBType = PHY_TYPE_11B; pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid; if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) return -EINVAL; memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); if ((sStartAPCmd.uChannel > 0) && (sStartAPCmd.uChannel <= 14)) pDevice->uChannel = sStartAPCmd.uChannel; if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000)) pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt; else pMgmt->wIBSSBeaconPeriod = 100; if (sStartAPCmd.bShareKeyAuth == true) { pMgmt->bShareKeyAlgorithm = true; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n"); } else { pMgmt->bShareKeyAlgorithm = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n"); } memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6); if (sStartAPCmd.byBasicRate & BIT3) { pMgmt->abyIBSSSuppRates[2] |= BIT7; pMgmt->abyIBSSSuppRates[3] |= BIT7; pMgmt->abyIBSSSuppRates[4] |= BIT7; pMgmt->abyIBSSSuppRates[5] |= BIT7; } else if (sStartAPCmd.byBasicRate & BIT2) { pMgmt->abyIBSSSuppRates[2] |= BIT7; pMgmt->abyIBSSSuppRates[3] |= BIT7; pMgmt->abyIBSSSuppRates[4] |= BIT7; } else if (sStartAPCmd.byBasicRate & BIT1) { pMgmt->abyIBSSSuppRates[2] |= BIT7; pMgmt->abyIBSSSuppRates[3] |= BIT7; } else if (sStartAPCmd.byBasicRate & BIT1) { pMgmt->abyIBSSSuppRates[2] |= BIT7; } else { /* default 1,2M */ pMgmt->abyIBSSSuppRates[2] |= BIT7; pMgmt->abyIBSSSuppRates[3] |= BIT7; } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %*ph\n", 4, pMgmt->abyIBSSSuppRates + 2); netif_stop_queue(pDevice->dev); spin_lock_irq(&pDevice->lock); bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL); spin_unlock_irq(&pDevice->lock); break; case WLAN_CMD_GET_NODE_CNT: cbListCount = 0; pNode = &(pMgmt->sNodeDBTable[0]); for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { pNode = &(pMgmt->sNodeDBTable[ii]); if (!pNode->bActive) continue; cbListCount++; } sNodeList.uItem = cbListCount; if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) { result = -EFAULT; break; } pReq->wResult = 0; break; case WLAN_CMD_GET_NODE_LIST: if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) { result = -EFAULT; break; } if (sNodeList.uItem > (ULONG_MAX - sizeof(SNodeList)) / sizeof(SNodeItem)) { result = -EINVAL; break; } pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC); if (pNodeList == NULL) { result = -ENOMEM; break; } pNodeList->uItem = sNodeList.uItem; pNode = &(pMgmt->sNodeDBTable[0]); for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) { pNode = &(pMgmt->sNodeDBTable[ii]); if (pNode->bActive) { pNodeList->sNodeList[jj].wAID = pNode->wAID; memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN); pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate; pNodeList->sNodeList[jj].wInActiveCount = (unsigned short)pNode->uInActiveCount; pNodeList->sNodeList[jj].wEnQueueCnt = (unsigned short)pNode->wEnQueueCnt; pNodeList->sNodeList[jj].wFlags = (unsigned short)pNode->dwFlags; pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable; pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex; pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength; memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", pNodeList->sNodeList[jj].abyWepKey[0], pNodeList->sNodeList[jj].abyWepKey[1], pNodeList->sNodeList[jj].abyWepKey[2], pNodeList->sNodeList[jj].abyWepKey[3], pNodeList->sNodeList[jj].abyWepKey[4]); pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback; pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures; pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts; pNodeList->sNodeList[jj].wFailureRatio = (unsigned short)pNode->uFailureRatio; jj++; if (jj >= pNodeList->uItem) break; } } if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) { result = -EFAULT; break; } kfree(pNodeList); pReq->wResult = 0; break; #ifdef WPA_SM_Transtatus case 0xFF: memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname)); wpa_Result.proto = 0; wpa_Result.key_mgmt = 0; wpa_Result.eap_type = 0; wpa_Result.authenticated = false; pDevice->fWPA_Authened = false; if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) { result = -EFAULT; break; } if (wpa_Result.authenticated == true) { #ifdef SndEvt_ToAPI { union iwreq_data wrqu; pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG; wrqu.data.length = pItemSSID->len; wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID); } #endif pDevice->fWPA_Authened = true; /* is successful peer to wpa_Result.authenticated? */ } pReq->wResult = 0; break; #endif default: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n"); } return result; }