/**************************************************************************** * cmdBld_CfgArpIpFilter() **************************************************************************** * DESCRIPTION: Enable\Disable the ARP filter * * OUTPUT: None * * RETURNS: TI_OK or TI_NOK ****************************************************************************/ TI_STATUS cmdBld_CfgArpIpFilter (TI_HANDLE hCmdBld, TIpAddr tIpAddr, void *fCb, TI_HANDLE hCb) { /* no support for IPV6 */ IP_COPY (DB_WLAN(hCmdBld).arp_IP_addr, tIpAddr); return cmdBld_CfgIeArpIpFilter (hCmdBld, tIpAddr, DB_WLAN(hCmdBld).arpFilterType, fCb, hCb); }
/**************************************************************************** * cmdBld_CfgArpIpAddrTable() **************************************************************************** * DESCRIPTION: Sets the ARP IP table according to the given configuration. * * OUTPUT: None * * RETURNS: TI_OK or TI_NOK ****************************************************************************/ TI_STATUS cmdBld_CfgArpIpAddrTable (TI_HANDLE hCmdBld, TIpAddr tIpAddr, TI_UINT8 bEnabled, EIpVer eIpVer, void *fCb, TI_HANDLE hCb) { DB_WLAN(hCmdBld).arp_IP_ver = eIpVer; /* no support for IPV6 */ if (eIpVer == IP_VER_4) { IP_COPY (DB_WLAN(hCmdBld).arp_IP_addr, tIpAddr); } DB_WLAN(hCmdBld).arpFilterType = (EArpFilterType)bEnabled; /* Set the new ip with the current state (e/d) */ return cmdBld_CfgIeArpIpFilter (hCmdBld, tIpAddr, (EArpFilterType)bEnabled, fCb, hCb); }
/************************************************************************ * buildArpRspTemplate * ************************************************************************ DESCRIPTION: This function builds an ARP Response template to set to the HAL when joining an infrastructure network. The function's steps: - It builds the template & set the template len. - If QoS is inactive, it discards the QoS Control Field. ** The template type is set in the site mgr. INPUT: pSiteMgr - Handle to site manager. pTemplate - Pointer to the template structure. OUTPUT: RETURN: TI_OK ************************************************************************/ TI_STATUS buildArpRspTemplate(siteMgr_t * pSiteMgr, TSetTemplate * pTemplate, TIpAddr staIp) { siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite; ArpRspTemplate_t *pBuffer = (ArpRspTemplate_t *) pTemplate->ptr; TI_UINT8 *ptr = (TI_UINT8 *) pBuffer; paramInfo_t param; /* To get Site and QoS params */ TI_UINT16 fc; /* Frame Control field in MAC header */ TI_UINT16 macAddrItr; TI_BOOL privacyInvoked; TI_UINT8 encryptionFieldSize, copyPayloadOffset, lenToCopy; /* Reset the buffer */ os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(ArpRspTemplate_t)); /* Turn on the To_DS bit in the Frame Control field */ fc = (1 << DOT11_FC_TO_DS_SHIFT); /* Set MAC header address fields: ----------------------------- Since To_DS is on and From_DS is off the address meaning is as follows: Address1 - BSSID Address2 - Source Address Address3 - Destination Address Address4 - Not present */ /* - Set BSSID */ if (pPrimarySite) { MAC_COPY(pBuffer->hdr.address1, pPrimarySite->bssid); } else { TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "No Primary site so cannot fill QosNullData template.\n"); } /* - Set Source Address */ param.paramType = CTRL_DATA_MAC_ADDRESS; ctrlData_getParam(pSiteMgr->hCtrlData, ¶m); MAC_COPY(pBuffer->hdr.address2, param.content.ctrlDataDeviceMacAddress); /* - Set Destination Address: ARP response should be sent with broadcast DA - Set accordingly */ for (macAddrItr = 0; macAddrItr < MAC_ADDR_LEN; macAddrItr++) { pBuffer->hdr.address3[macAddrItr] = 0xFF; } pBuffer->LLC.DSAP = 0xaa; pBuffer->LLC.SSAP = 0xaa; pBuffer->LLC.Control = 0x03; /* pBuffer->LLC.Control.OUI these 3 bytes are zeroed already */ pBuffer->LLC.Type = WLANTOHS((TI_UINT16) 0x806); pBuffer->hardType = WLANTOHS((TI_UINT16) 1); pBuffer->protType = WLANTOHS((TI_UINT16) 0x800); pBuffer->hardSize = 6; pBuffer->protSize = 4; pBuffer->op = WLANTOHS((TI_UINT16) 2); /*filled as for ARP-RSP, not for RARP_RSP */ MAC_COPY(pBuffer->StaMac, pBuffer->hdr.address2); IP_COPY(pBuffer->StaIp, staIp); pTemplate->len = sizeof(ArpRspTemplate_t); /* Get encryption status */ txCtrlParams_getCurrentEncryptionInfo(pSiteMgr->hTxCtrl, &privacyInvoked, &encryptionFieldSize); /* If no encryption is used, encryptionFieldSize has garbage value */ encryptionFieldSize = privacyInvoked ? encryptionFieldSize : 0; /* Set the subtype field of fc with WEP_BIT */ fc |= (privacyInvoked << DOT11_FC_WEP_SHIFT); /* Get QoS type to check if QoS is active */ param.paramType = QOS_MNGR_ACTIVE_PROTOCOL; qosMngr_getParams(pSiteMgr->hQosMngr, ¶m); if (param.content.qosSiteProtocol == QOS_NONE) { /* QoS is not active */ copyPayloadOffset = sizeof(pBuffer->hdr.qosControl) + AES_AFTER_HEADER_FIELD_SIZE - encryptionFieldSize; /* Set the subtype field of fc with DATA value (non Qos) */ fc |= DOT11_FC_DATA; } else { /* QoS is active */ copyPayloadOffset = AES_AFTER_HEADER_FIELD_SIZE - encryptionFieldSize; /* Set the subtype field of fc with DATA_QOS */ fc |= DOT11_FC_DATA_QOS; } /* Need to copy backward to overwrite security or QoS offset */ if (copyPayloadOffset > 0) { ptr = (TI_UINT8 *) & pBuffer->LLC.DSAP; /* Copy back the actual payload without header & security */ lenToCopy = sizeof(ArpRspTemplate_t) - sizeof(dot11_header_t) - AES_AFTER_HEADER_FIELD_SIZE; os_memoryCopy(pSiteMgr->hOs, ptr - copyPayloadOffset, ptr, lenToCopy); pTemplate->len -= copyPayloadOffset; } COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */ return TI_OK; }
TI_STATUS TWD_SetDefaults (TI_HANDLE hTWD, TTwdInitParams *pInitParams) { TTwd *pTWD = (TTwd *)hTWD; TWlanParams *pWlanParams = &DB_WLAN(pTWD->hCmdBld); TKeepAliveList *pKlvParams = &DB_KLV(pTWD->hCmdBld); IniFileRadioParam *pRadioParams = &DB_RADIO(pTWD->hCmdBld); IniFileGeneralParam *pGenParams = &DB_GEN(pTWD->hCmdBld); TRateMngParams *pRateMngParams = &DB_RM(pTWD->hCmdBld); TDmaParams *pDmaParams = &DB_DMA(pTWD->hCmdBld); TI_UINT32 k, uIndex; int iParam; pTWD->bRecoveryEnabled = pInitParams->tGeneral.halCtrlRecoveryEnable; pWlanParams->PacketDetectionThreshold = pInitParams->tGeneral.packetDetectionThreshold; pWlanParams->qosNullDataTemplateSize = pInitParams->tGeneral.qosNullDataTemplateSize; pWlanParams->PsPollTemplateSize = pInitParams->tGeneral.PsPollTemplateSize; pWlanParams->probeResponseTemplateSize = pInitParams->tGeneral.probeResponseTemplateSize; pWlanParams->probeRequestTemplateSize = pInitParams->tGeneral.probeRequestTemplateSize; pWlanParams->beaconTemplateSize = pInitParams->tGeneral.beaconTemplateSize; pWlanParams->nullTemplateSize = pInitParams->tGeneral.nullTemplateSize; pWlanParams->disconnTemplateSize = pInitParams->tGeneral.disconnTemplateSize; pWlanParams->ArpRspTemplateSize = pInitParams->tGeneral.ArpRspTemplateSize; /* Beacon broadcast options */ pWlanParams->BcnBrcOptions.BeaconRxTimeout = pInitParams->tGeneral.BeaconRxTimeout; pWlanParams->BcnBrcOptions.BroadcastRxTimeout = pInitParams->tGeneral.BroadcastRxTimeout; pWlanParams->BcnBrcOptions.RxBroadcastInPs = pInitParams->tGeneral.RxBroadcastInPs; pWlanParams->ConsecutivePsPollDeliveryFailureThreshold = pInitParams->tGeneral.ConsecutivePsPollDeliveryFailureThreshold; pWlanParams->RxDisableBroadcast = pInitParams->tGeneral.halCtrlRxDisableBroadcast; pWlanParams->calibrationChannel2_4 = pInitParams->tGeneral.halCtrlCalibrationChannel2_4; pWlanParams->calibrationChannel5_0 = pInitParams->tGeneral.halCtrlCalibrationChannel5_0; /* Not used but need by Palau */ pWlanParams->RtsThreshold = pInitParams->tGeneral.halCtrlRtsThreshold; pWlanParams->CtsToSelf = CTS_TO_SELF_DISABLE; pWlanParams->WiFiWmmPS = pInitParams->tGeneral.WiFiWmmPS; pWlanParams->MaxTxMsduLifetime = pInitParams->tGeneral.halCtrlMaxTxMsduLifetime; pWlanParams->MaxRxMsduLifetime = pInitParams->tGeneral.halCtrlMaxRxMsduLifetime; pWlanParams->rxTimeOut.psPoll = pInitParams->tGeneral.rxTimeOut.psPoll; pWlanParams->rxTimeOut.UPSD = pInitParams->tGeneral.rxTimeOut.UPSD; /* RSSI/SNR Weights for Average calculations */ pWlanParams->tRssiSnrWeights.rssiBeaconAverageWeight = pInitParams->tGeneral.uRssiBeaconAverageWeight; pWlanParams->tRssiSnrWeights.rssiPacketAverageWeight = pInitParams->tGeneral.uRssiPacketAverageWeight; pWlanParams->tRssiSnrWeights.snrBeaconAverageWeight = pInitParams->tGeneral.uSnrBeaconAverageWeight ; pWlanParams->tRssiSnrWeights.snrPacketAverageWeight = pInitParams->tGeneral.uSnrPacketAverageWeight ; /* PM config params */ pWlanParams->uHostClkSettlingTime = pInitParams->tGeneral.uHostClkSettlingTime; pWlanParams->uHostFastWakeupSupport = pInitParams->tGeneral.uHostFastWakeupSupport; /* No used */ pWlanParams->FragmentThreshold = pInitParams->tGeneral.halCtrlFragThreshold; pWlanParams->ListenInterval = (TI_UINT8)pInitParams->tGeneral.halCtrlListenInterval; pWlanParams->RateFallback = pInitParams->tGeneral.halCtrlRateFallbackRetry; pWlanParams->MacClock = pInitParams->tGeneral.halCtrlMacClock; pWlanParams->ArmClock = pInitParams->tGeneral.halCtrlArmClock; /* Data interrupts pacing */ pWlanParams->TxCompletePacingThreshold = pInitParams->tGeneral.TxCompletePacingThreshold; pWlanParams->TxCompletePacingTimeout = pInitParams->tGeneral.TxCompletePacingTimeout; pWlanParams->RxIntrPacingThreshold = pInitParams->tGeneral.RxIntrPacingThreshold; pWlanParams->RxIntrPacingTimeout = pInitParams->tGeneral.RxIntrPacingTimeout; /* Number of Rx mem-blocks to allocate in FW */ pDmaParams->NumRxBlocks = pInitParams->tGeneral.uRxMemBlksNum; /* Configure ARP IP */ pWlanParams->arpFilterType = pInitParams->tArpIpFilter.filterType; IP_COPY (pWlanParams->arp_IP_addr, pInitParams->tArpIpFilter.addr); /* Configure address group */ pWlanParams->numGroupAddrs = pInitParams->tMacAddrFilter.numOfMacAddresses; pWlanParams->isMacAddrFilteringnabled = pInitParams->tMacAddrFilter.isFilterEnabled; for (k = 0; k < pWlanParams->numGroupAddrs; k++) { MAC_COPY (pWlanParams->aGroupAddr[k], pInitParams->tMacAddrFilter.macAddrTable[k]); } /* CoexActivity Table */ pWlanParams->tWlanParamsCoexActivityTable.numOfElements = 0; for (iParam=0; iParam < (int)pInitParams->tGeneral.halCoexActivityTable.numOfElements; iParam++) { TCoexActivity *pSaveCoex = &pWlanParams->tWlanParamsCoexActivityTable.entry[0]; TCoexActivity *pParmCoex = &pInitParams->tGeneral.halCoexActivityTable.entry[0]; int i, saveIndex; /* Check if to overwrite existing entry or put on last index */ for (i=0; i<iParam; i++) { if ((pSaveCoex[i].activityId == pParmCoex[iParam].activityId) && (pSaveCoex[i].coexIp == pParmCoex[iParam].coexIp)) { break; } } if (i == iParam) { /* new entry */ saveIndex = pWlanParams->tWlanParamsCoexActivityTable.numOfElements; pWlanParams->tWlanParamsCoexActivityTable.numOfElements++; } else { /* overwrite existing */ saveIndex = i; } pSaveCoex[saveIndex].coexIp = pParmCoex[iParam].coexIp; pSaveCoex[saveIndex].activityId = pParmCoex[iParam].activityId; pSaveCoex[saveIndex].defaultPriority = pParmCoex[iParam].defaultPriority; pSaveCoex[saveIndex].raisedPriority = pParmCoex[iParam].raisedPriority; pSaveCoex[saveIndex].minService = pParmCoex[iParam].minService; pSaveCoex[saveIndex].maxService = pParmCoex[iParam].maxService; } /* configure keep-alive default mode to enabled */ pKlvParams->enaDisFlag = TI_TRUE; for (uIndex = 0; uIndex < KLV_MAX_TMPL_NUM; uIndex++) { pKlvParams->keepAliveParams[ uIndex ].enaDisFlag = TI_FALSE; } /* Configure the TWD modules */ rxXfer_SetDefaults (pTWD->hRxXfer, pInitParams); txXfer_SetDefaults (pTWD->hTxXfer, pInitParams); txHwQueue_Config (pTWD->hTxHwQueue, pInitParams); MacServices_config (pTWD->hMacServices, pInitParams); /* * 802.11n */ pWlanParams->tTwdHtCapabilities.b11nEnable = pInitParams->tGeneral.b11nEnable; /* Configure HT capabilities setting */ pWlanParams->tTwdHtCapabilities.uChannelWidth = CHANNEL_WIDTH_20MHZ; pWlanParams->tTwdHtCapabilities.uRxSTBC = RXSTBC_SUPPORTED_ONE_SPATIAL_STREAM; pWlanParams->tTwdHtCapabilities.uMaxAMSDU = MAX_MSDU_3839_OCTETS; pWlanParams->tTwdHtCapabilities.uMaxAMPDU = MAX_MPDU_8191_OCTETS; pWlanParams->tTwdHtCapabilities.uAMPDUSpacing = AMPDU_SPC_8_MICROSECONDS; pWlanParams->tTwdHtCapabilities.aRxMCS[0] = (MCS_SUPPORT_MCS_0 | MCS_SUPPORT_MCS_1 | MCS_SUPPORT_MCS_2 | MCS_SUPPORT_MCS_3 | MCS_SUPPORT_MCS_4 | MCS_SUPPORT_MCS_5 | MCS_SUPPORT_MCS_6 | MCS_SUPPORT_MCS_7); os_memoryZero (pTWD->hOs, pWlanParams->tTwdHtCapabilities.aRxMCS + 1, RX_TX_MCS_BITMASK_SIZE - 1); pWlanParams->tTwdHtCapabilities.aTxMCS[0] = (MCS_SUPPORT_MCS_0 | MCS_SUPPORT_MCS_1 | MCS_SUPPORT_MCS_2 | MCS_SUPPORT_MCS_3 | MCS_SUPPORT_MCS_4 | MCS_SUPPORT_MCS_5 | MCS_SUPPORT_MCS_6 | MCS_SUPPORT_MCS_7); os_memoryZero (pTWD->hOs, pWlanParams->tTwdHtCapabilities.aTxMCS + 1, RX_TX_MCS_BITMASK_SIZE - 1); pWlanParams->tTwdHtCapabilities.uRxMaxDataRate = MCS_HIGHEST_SUPPORTED_RECEPTION_DATA_RATE_IN_MBIT_S; pWlanParams->tTwdHtCapabilities.uPCOTransTime = PCO_TRANS_TIME_NO_TRANSITION; pWlanParams->tTwdHtCapabilities.uHTCapabilitiesBitMask = (CAP_BIT_MASK_GREENFIELD_FRAME_FORMAT | CAP_BIT_MASK_SHORT_GI_FOR_20MHZ_PACKETS); pWlanParams->tTwdHtCapabilities.uMCSFeedback = MCS_FEEDBACK_NO; os_memoryCopy(pTWD->hOs, (void*)pRadioParams, (void*)&pInitParams->tIniFileRadioParams, sizeof(IniFileRadioParam)); os_memoryCopy(pTWD->hOs, (void*)pGenParams, (void*)&pInitParams->tPlatformGenParams, sizeof(IniFileGeneralParam)); os_memoryCopy (pTWD->hOs, (void*)&(pWlanParams->tFmCoexParams), (void*)&(pInitParams->tGeneral.tFmCoexParams), sizeof(TFmCoexParams)); /* Rate management params */ pRateMngParams->rateMngParams.InverseCuriosityFactor = pInitParams->tRateMngParams.InverseCuriosityFactor; pRateMngParams->rateMngParams.MaxPer = pInitParams->tRateMngParams.MaxPer; pRateMngParams->rateMngParams.PerAdd = pInitParams->tRateMngParams.PerAdd; pRateMngParams->rateMngParams.PerAddShift = pInitParams->tRateMngParams.PerAddShift; pRateMngParams->rateMngParams.PerAlphaShift = pInitParams->tRateMngParams.PerAlphaShift; pRateMngParams->rateMngParams.PerBeta1Shift = pInitParams->tRateMngParams.PerBeta1Shift; pRateMngParams->rateMngParams.PerBeta2Shift = pInitParams->tRateMngParams.PerBeta2Shift; pRateMngParams->rateMngParams.PerTh1 = pInitParams->tRateMngParams.PerTh1; pRateMngParams->rateMngParams.PerTh2 = pInitParams->tRateMngParams.PerTh2; pRateMngParams->rateMngParams.RateCheckDown = pInitParams->tRateMngParams.RateCheckDown; pRateMngParams->rateMngParams.RateCheckUp = pInitParams->tRateMngParams.RateCheckUp; pRateMngParams->rateMngParams.RateRetryScore = pInitParams->tRateMngParams.RateRetryScore; pRateMngParams->rateMngParams.TxFailHighTh = pInitParams->tRateMngParams.TxFailHighTh; pRateMngParams->rateMngParams.TxFailLowTh = pInitParams->tRateMngParams.TxFailLowTh; /* RATE_MNG_MAX_RETRY_POLICY_PARAMS_LEN */ for (uIndex = 0; uIndex < 13; uIndex++) { pRateMngParams->rateMngParams.RateRetryPolicy[uIndex] = pInitParams->tRateMngParams.RateRetryPolicy[uIndex]; } /* DCO Itrim params */ pWlanParams->dcoItrimEnabled = pInitParams->tDcoItrimParams.enable; pWlanParams->dcoItrimModerationTimeoutUsec = pInitParams->tDcoItrimParams.moderationTimeoutUsec; return TI_OK; }
TI_STATUS TWD_WriteMib (TI_HANDLE hTWD, TMib *pMib) { TTwd *pTWD = (TTwd *)hTWD; if (NULL == pMib) { return PARAM_VALUE_NOT_VALID; } switch (pMib->aMib) { case MIB_dot11MaxReceiveLifetime: return cmdBld_CfgRxMsduLifeTime (pTWD->hCmdBld, pMib->aData.MaxReceiveLifeTime * 1024, (void *)NULL, (void *)NULL); case MIB_ctsToSelf: return cmdBld_CfgCtsProtection (pTWD->hCmdBld, (TI_UINT8)pMib->aData.CTSToSelfEnable, (void *)NULL, (TI_HANDLE)NULL); case MIB_dot11GroupAddressesTable: { if (NULL == pMib->aData.GroupAddressTable.aGroupTable) { return PARAM_VALUE_NOT_VALID; } return TWD_CfgGroupAddressTable (hTWD, pMib->aData.GroupAddressTable.nNumberOfAddresses, pMib->aData.GroupAddressTable.aGroupTable, pMib->aData.GroupAddressTable.bFilteringEnable); } case MIB_arpIpAddressesTable: { TIpAddr IpAddress; IP_COPY (IpAddress, pMib->aData.ArpIpAddressesTable.addr); return cmdBld_CfgArpIpAddrTable (pTWD->hCmdBld, IpAddress, (TI_BOOL)pMib->aData.ArpIpAddressesTable.FilteringEnable, IP_VER_4, NULL, NULL); } case MIB_templateFrame: return TWD_WriteMibTemplateFrame (hTWD, pMib); case MIB_beaconFilterIETable: return TWD_WriteMibBeaconFilterIETable (hTWD, pMib); case MIB_rxFilter: { TI_UINT32 uRxFilter = 0; TI_UINT8 uMibRxFilter = pMib->aData.RxFilter; if (uMibRxFilter & MIB_RX_FILTER_PROMISCOUS_SET) { uRxFilter = RX_CFG_ENABLE_ANY_DEST_MAC; } else { uRxFilter = RX_CFG_ENABLE_ONLY_MY_DEST_MAC; } if ((uMibRxFilter & MIB_RX_FILTER_BSSID_SET) != 0) { uRxFilter = uRxFilter | RX_CFG_ENABLE_ONLY_MY_BSSID; } else { uRxFilter = uRxFilter | RX_CFG_ENABLE_ANY_BSSID; } /* * Activates the TWD_setRxFilters function */ return TWD_CfgRx (hTWD, uRxFilter, RX_FILTER_OPTION_DEF); } case MIB_txRatePolicy: return TWD_WriteMibTxRatePolicy (hTWD, pMib); default: {} return TI_NOK; } /* switch */ }