Lines Matching +full:tx +full:- +full:d +full:- +full:cal

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
5 * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
78 * BA stream -> queue ID mapping
98 pCmd = (type *)&mh->mh_cmdbuf[0]; \
100 pCmd->CmdHdr.Cmd = htole16(cmd); \
101 pCmd->CmdHdr.Length = htole16(sizeof(type)); \
106 pCmd->CmdHdr.MacId = vap->macid; \
136 #define MWLVAP(_vap) ((_vap)->mh)
139 * Per-device state. We allocate a single cmd buffer for
141 * buffer (and the f/w) are single-threaded. At present
162 #define MHF_CALDATA 0x0001 /* cal data retrieved */
175 uint32_t mh_RTSSuccesses;/* cumulative stats for read-on-clear */
199 mtx_lock(&mh->mh_mtx); in MWL_HAL_LOCK()
205 mtx_assert(&mh->mh_mtx, MA_OWNED); in MWL_HAL_LOCK_ASSERT()
211 mtx_unlock(&mh->mh_mtx); in MWL_HAL_UNLOCK()
217 return bus_space_read_4(mh->public.mh_iot, mh->public.mh_ioh, off); in RD4()
223 bus_space_write_4(mh->public.mh_iot, mh->public.mh_ioh, off, val); in WR4()
231 *paddr = segs->ds_addr; in mwl_hal_load_cb()
253 mh->mh_dev = dev; in mwl_hal_attach()
254 mh->public.mh_ioh = ioh; in mwl_hal_attach()
255 mh->public.mh_iot = iot; in mwl_hal_attach()
257 mh->mh_streams[i].public.txq = ba2qid[i]; in mwl_hal_attach()
258 mh->mh_streams[i].stream = i; in mwl_hal_attach()
259 /* construct back-mapping while we're at it */ in mwl_hal_attach()
260 if (mh->mh_streams[i].public.txq < MWL_BAQID_MAX) in mwl_hal_attach()
261 qid2ba[mh->mh_streams[i].public.txq] = i; in mwl_hal_attach()
263 device_printf(dev, "unexpected BA tx qid %d for " in mwl_hal_attach()
264 "stream %d\n", mh->mh_streams[i].public.txq, i); in mwl_hal_attach()
269 hvap = &mh->mh_vaps[i]; in mwl_hal_attach()
270 hvap->vap_type = MWL_HAL_AP; in mwl_hal_attach()
271 hvap->bss_type = htole16(WL_MAC_TYPE_PRIMARY_AP); in mwl_hal_attach()
272 hvap->macid = 0; in mwl_hal_attach()
274 hvap = &mh->mh_vaps[i]; in mwl_hal_attach()
275 hvap->vap_type = MWL_HAL_AP; in mwl_hal_attach()
276 hvap->bss_type = htole16(WL_MAC_TYPE_SECONDARY_AP); in mwl_hal_attach()
277 hvap->macid = i; in mwl_hal_attach()
279 hvap = &mh->mh_vaps[i]; in mwl_hal_attach()
280 hvap->vap_type = MWL_HAL_STA; in mwl_hal_attach()
281 hvap->bss_type = htole16(WL_MAC_TYPE_PRIMARY_CLIENT); in mwl_hal_attach()
282 hvap->macid = i; in mwl_hal_attach()
284 hvap = &mh->mh_vaps[i]; in mwl_hal_attach()
285 hvap->vap_type = MWL_HAL_STA; in mwl_hal_attach()
286 hvap->bss_type = htole16(WL_MAC_TYPE_SECONDARY_CLIENT); in mwl_hal_attach()
287 hvap->macid = i; in mwl_hal_attach()
289 mh->mh_revs.mh_devid = devid; in mwl_hal_attach()
290 snprintf(mh->mh_mtxname, sizeof(mh->mh_mtxname), in mwl_hal_attach()
292 mtx_init(&mh->mh_mtx, mh->mh_mtxname, NULL, MTX_DEF); in mwl_hal_attach()
310 &mh->mh_dmat); in mwl_hal_attach()
318 error = bus_dmamem_alloc(mh->mh_dmat, (void**) &mh->mh_cmdbuf, in mwl_hal_attach()
320 &mh->mh_dmamap); in mwl_hal_attach()
327 error = bus_dmamap_load(mh->mh_dmat, mh->mh_dmamap, in mwl_hal_attach()
328 mh->mh_cmdbuf, MWL_CMDBUF_SIZE, in mwl_hal_attach()
329 mwl_hal_load_cb, &mh->mh_cmdaddr, in mwl_hal_attach()
340 * When the SDRAMSIZE is non-zero we do that work in in mwl_hal_attach()
349 mh->mh_SDRAMSIZE_Addr = 0x40fe70b7; /* 8M SDRAM */ in mwl_hal_attach()
352 mh->mh_SDRAMSIZE_Addr = 0x40fc70b7; /* 16M SDRAM */ in mwl_hal_attach()
357 return &mh->public; in mwl_hal_attach()
359 bus_dmamem_free(mh->mh_dmat, mh->mh_cmdbuf, mh->mh_dmamap); in mwl_hal_attach()
361 bus_dma_tag_destroy(mh->mh_dmat); in mwl_hal_attach()
363 mtx_destroy(&mh->mh_mtx); in mwl_hal_attach()
373 bus_dmamem_free(mh->mh_dmat, mh->mh_cmdbuf, mh->mh_dmamap); in mwl_hal_detach()
374 bus_dma_tag_destroy(mh->mh_dmat); in mwl_hal_detach()
375 mtx_destroy(&mh->mh_mtx); in mwl_hal_detach()
388 mh->mh_bastreams = (1<<MWL_BASTREAMS_MAX)-1; in mwlResetHalState()
390 mh->mh_vaps[i].mh = NULL; in mwlResetHalState()
394 mh->mh_RTSSuccesses = 0; in mwlResetHalState()
395 mh->mh_RTSFailures = 0; in mwlResetHalState()
396 mh->mh_RxDuplicateFrames = 0; in mwlResetHalState()
397 mh->mh_FCSErrorCount = 0; in mwlResetHalState()
399 * Fetch cal data for later use. in mwlResetHalState()
403 if ((mh->mh_flags & MHF_CALDATA) == 0) in mwlResetHalState()
419 vap = &mh->mh_vaps[i]; in mwl_hal_newvap()
420 if (vap->vap_type == type && vap->mh == NULL) { in mwl_hal_newvap()
421 vap->mh = mh; in mwl_hal_newvap()
434 vap->mh = NULL; in mwl_hal_delvap()
446 MWLPRIV(mh)->mh_debug = debug; in mwl_hal_setdebug()
452 return MWLPRIV(mh)->mh_debug; in mwl_hal_getdebug()
458 MWLPRIV(mh)->mh_bastreams = mask & ((1<<MWL_BASTREAMS_MAX)-1); in mwl_hal_setbastreams()
464 return MWLPRIV(mh)->mh_bastreams; in mwl_hal_getbastreams()
470 return (MWLPRIV(mh)->mh_flags & MHF_MBSS) != 0; in mwl_hal_ismbsscapable()
487 device_printf(mh->mh_dev, "%s: cause 0x%x\n", __func__, cause);
492 cause &~ mh->public.mh_imask);
510 mh->public.mh_imask = mask; in mwl_hal_intrset()
518 * Kick the firmware to tell it there are new tx descriptors
544 if (mh->mh_debug & MWL_HAL_DEBUG_CMDDONE) { in mwl_hal_cmddone()
545 device_printf(mh->mh_dev, "cmd done interrupt:\n"); in mwl_hal_cmddone()
566 memset(&pCmd->PermanentAddr[0], 0xff, IEEE80211_ADDR_LEN); in mwl_hal_gethwspecs()
567 pCmd->ulFwAwakeCookie = htole32((unsigned int)mh->mh_cmdaddr+2048); in mwl_hal_gethwspecs()
571 IEEE80211_ADDR_COPY(hw->macAddr, pCmd->PermanentAddr); in mwl_hal_gethwspecs()
572 hw->wcbBase[0] = le32toh(pCmd->WcbBase0) & 0x0000ffff; in mwl_hal_gethwspecs()
573 hw->wcbBase[1] = le32toh(pCmd->WcbBase1[0]) & 0x0000ffff; in mwl_hal_gethwspecs()
574 hw->wcbBase[2] = le32toh(pCmd->WcbBase1[1]) & 0x0000ffff; in mwl_hal_gethwspecs()
575 hw->wcbBase[3] = le32toh(pCmd->WcbBase1[2]) & 0x0000ffff; in mwl_hal_gethwspecs()
576 hw->rxDescRead = le32toh(pCmd->RxPdRdPtr)& 0x0000ffff; in mwl_hal_gethwspecs()
577 hw->rxDescWrite = le32toh(pCmd->RxPdWrPtr)& 0x0000ffff; in mwl_hal_gethwspecs()
578 hw->regionCode = le16toh(pCmd->RegionCode) & 0x00ff; in mwl_hal_gethwspecs()
579 hw->fwReleaseNumber = le32toh(pCmd->FWReleaseNumber); in mwl_hal_gethwspecs()
580 hw->maxNumWCB = le16toh(pCmd->NumOfWCB); in mwl_hal_gethwspecs()
581 hw->maxNumMCAddr = le16toh(pCmd->NumOfMCastAddr); in mwl_hal_gethwspecs()
582 hw->numAntennas = le16toh(pCmd->NumberOfAntenna); in mwl_hal_gethwspecs()
583 hw->hwVersion = pCmd->Version; in mwl_hal_gethwspecs()
584 hw->hostInterface = pCmd->HostIf; in mwl_hal_gethwspecs()
586 mh->mh_revs.mh_macRev = hw->hwVersion; /* XXX */ in mwl_hal_gethwspecs()
587 mh->mh_revs.mh_phyRev = hw->hostInterface; /* XXX */ in mwl_hal_gethwspecs()
589 minrev = ((hw->fwReleaseNumber) >> 16) & 0xff; in mwl_hal_gethwspecs()
592 mh->mh_bastreams &= (1<<MWL_BASTREAMS_MAX)-1; in mwl_hal_gethwspecs()
594 mh->mh_bastreams &= (1<<2)-1; in mwl_hal_gethwspecs()
601 * Inform the f/w about location of the tx/rx dma data structures
614 pCmd->WcbBase[0] = htole32(dma->wcbBase[0]); in mwl_hal_sethwdma()
615 pCmd->WcbBase[1] = htole32(dma->wcbBase[1]); in mwl_hal_sethwdma()
616 pCmd->WcbBase[2] = htole32(dma->wcbBase[2]); in mwl_hal_sethwdma()
617 pCmd->WcbBase[3] = htole32(dma->wcbBase[3]); in mwl_hal_sethwdma()
618 pCmd->TxWcbNumPerQueue = htole32(dma->maxNumTxWcb); in mwl_hal_sethwdma()
619 pCmd->NumTxQueues = htole32(dma->maxNumWCB); in mwl_hal_sethwdma()
620 pCmd->TotalRxWcb = htole32(1); /* XXX */ in mwl_hal_sethwdma()
621 pCmd->RxPdWrPtr = htole32(dma->rxDescRead); in mwl_hal_sethwdma()
622 pCmd->Flags = htole32(SET_HW_SPEC_HOSTFORM_BEACON in mwl_hal_sethwdma()
627 /* disable multi-bss operation for A1-A4 parts */ in mwl_hal_sethwdma()
628 if (mh->mh_revs.mh_macRev < 5) in mwl_hal_sethwdma()
629 pCmd->Flags |= htole32(SET_HW_SPEC_DISABLEMBSS); in mwl_hal_sethwdma()
633 if (pCmd->Flags & htole32(SET_HW_SPEC_DISABLEMBSS)) in mwl_hal_sethwdma()
634 mh->mh_flags &= ~MHF_MBSS; in mwl_hal_sethwdma()
636 mh->mh_flags |= MHF_MBSS; in mwl_hal_sethwdma()
659 const uint32_t *sp = (const uint32_t *)&pCmd->TxRetrySuccesses; in mwl_hal_gethwstats()
660 uint32_t *dp = (uint32_t *)&stats->TxRetrySuccesses; in mwl_hal_gethwstats()
671 mh->mh_RTSSuccesses += RD4(mh, 0xa834); in mwl_hal_gethwstats()
672 mh->mh_RTSFailures += RD4(mh, 0xa830); in mwl_hal_gethwstats()
673 mh->mh_RxDuplicateFrames += RD4(mh, 0xa84c); in mwl_hal_gethwstats()
674 mh->mh_FCSErrorCount += RD4(mh, 0xa840); in mwl_hal_gethwstats()
678 stats->RTSSuccesses = mh->mh_RTSSuccesses; in mwl_hal_gethwstats()
679 stats->RTSFailures = mh->mh_RTSFailures; in mwl_hal_gethwstats()
680 stats->RxDuplicateFrames = mh->mh_RxDuplicateFrames; in mwl_hal_gethwstats()
681 stats->FCSErrorCount = mh->mh_FCSErrorCount; in mwl_hal_gethwstats()
699 pCmd->Action = htole32(HostCmd_ACT_GEN_SET); in mwl_hal_sethtgi()
702 pCmd->GIType = htole32(GI_TYPE_LONG); in mwl_hal_sethtgi()
704 pCmd->GIType = htole32(GI_TYPE_LONG | GI_TYPE_SHORT); in mwl_hal_sethtgi()
706 pCmd->GIType = htole32(GI_TYPE_LONG); in mwl_hal_sethtgi()
729 pCmd->Action = htole16(HostCmd_ACT_GEN_SET); in mwl_hal_setradio()
731 pCmd->Control = 0; in mwl_hal_setradio()
733 pCmd->Control = htole16(preamble); in mwl_hal_setradio()
734 pCmd->RadioOn = htole16(onoff); in mwl_hal_setradio()
744 * XXX tx antenna setting ignored
760 pCmd->Action = htole16(dirSet); in mwl_hal_setantenna()
763 pCmd->AntennaMode = htole16(ant); in mwl_hal_setantenna()
785 pCmd->Action = htole16(HostCmd_ACT_GEN_SET); in mwl_hal_setrtsthreshold()
786 pCmd->Threshold = htole16(threshold); in mwl_hal_setrtsthreshold()
794 * Enable sta-mode operation (disables beacon frame xmit).
825 pCmd->CmdHdr.Length = htole16(sizeof(HostCmd_802_11h_Detect_Radar)); in mwl_hal_setradardetection()
826 pCmd->Action = htole16(action); in mwl_hal_setradardetection()
827 if (mh->mh_regioncode == DOMAIN_CODE_ETSI_131) in mwl_hal_setradardetection()
828 pCmd->RadarTypeCode = htole16(131); in mwl_hal_setradardetection()
849 w = (chan->channelFlags.FreqBand == MWL_FREQ_BAND_2DOT4GHZ) ? in cvtChannelFlags()
851 switch (chan->channelFlags.ChnlWidth) { in cvtChannelFlags()
863 switch (chan->channelFlags.ExtChnlOffset) { in cvtChannelFlags()
894 pCmd->Next11hChannel = htole32(nextchan->channel); in mwl_hal_setchannelswitchie()
895 pCmd->Mode = htole32(mode); in mwl_hal_setchannelswitchie()
896 pCmd->InitialCount = htole32(count+1); in mwl_hal_setchannelswitchie()
897 pCmd->ChannelFlags = cvtChannelFlags(nextchan); in mwl_hal_setchannelswitchie()
917 /* XXX map pseudo-codes to fw codes */ in mwl_hal_setregioncode()
920 pCmd->regionCode = htole16(DOMAIN_CODE_ETSI); in mwl_hal_setregioncode()
923 pCmd->regionCode = htole16(regionCode); in mwl_hal_setregioncode()
929 mh->mh_regioncode = regionCode; in mwl_hal_setregioncode()
950 pCmd->MulticastRate = RATEVAL(rate->McastRate); in mwl_hal_settxrate()
951 pCmd->MultiRateTxType = RATETYPE(rate->McastRate); in mwl_hal_settxrate()
953 pCmd->ManagementRate = RATEVAL(rate->MgtRate); in mwl_hal_settxrate()
954 memset(pCmd->FixedRateTable, 0, sizeof(pCmd->FixedRateTable)); in mwl_hal_settxrate()
956 pCmd->Action = htole32(HostCmd_ACT_GEN_SET); in mwl_hal_settxrate()
957 pCmd->AllowRateDrop = htole32(FIXED_RATE_WITHOUT_AUTORATE_DROP); in mwl_hal_settxrate()
958 fp = pCmd->FixedRateTable; in mwl_hal_settxrate()
959 fp->FixedRate = in mwl_hal_settxrate()
960 htole32(RATEVAL(rate->RateSeries[0].Rate)); in mwl_hal_settxrate()
961 fp->FixRateTypeFlags.FixRateType = in mwl_hal_settxrate()
962 htole32(RATETYPE(rate->RateSeries[0].Rate)); in mwl_hal_settxrate()
963 pCmd->EntryCount = htole32(1); in mwl_hal_settxrate()
965 pCmd->Action = htole32(HostCmd_ACT_GEN_SET); in mwl_hal_settxrate()
966 pCmd->AllowRateDrop = htole32(FIXED_RATE_WITH_AUTO_RATE_DROP); in mwl_hal_settxrate()
968 fp = pCmd->FixedRateTable; in mwl_hal_settxrate()
970 if (rate->RateSeries[0].TryCount == 0) in mwl_hal_settxrate()
972 fp->FixRateTypeFlags.FixRateType = in mwl_hal_settxrate()
973 htole32(RATETYPE(rate->RateSeries[i].Rate)); in mwl_hal_settxrate()
974 fp->FixedRate = in mwl_hal_settxrate()
975 htole32(RATEVAL(rate->RateSeries[i].Rate)); in mwl_hal_settxrate()
976 fp->FixRateTypeFlags.RetryCountValid = in mwl_hal_settxrate()
978 fp->RetryCount = in mwl_hal_settxrate()
979 htole32(rate->RateSeries[i].TryCount-1); in mwl_hal_settxrate()
982 pCmd->EntryCount = htole32(n); in mwl_hal_settxrate()
984 pCmd->Action = htole32(HostCmd_ACT_NOT_USE_FIXED_RATE); in mwl_hal_settxrate()
1002 pCmd->MulticastRate = RATEVAL(rate->McastRate); in mwl_hal_settxrate_auto()
1003 pCmd->MultiRateTxType = RATETYPE(rate->McastRate); in mwl_hal_settxrate_auto()
1005 pCmd->ManagementRate = RATEVAL(rate->MgtRate); in mwl_hal_settxrate_auto()
1006 memset(pCmd->FixedRateTable, 0, sizeof(pCmd->FixedRateTable)); in mwl_hal_settxrate_auto()
1007 pCmd->Action = htole32(HostCmd_ACT_NOT_USE_FIXED_RATE); in mwl_hal_settxrate_auto()
1030 pCmd->Action = htole16(HostCmd_ACT_GEN_SET); in mwl_hal_setslottime()
1031 pCmd->Slot = (usecs == 9 ? 1 : 0); in mwl_hal_setslottime()
1048 pCmd->Action = htole16(HostCmd_ACT_GEN_SET); in mwl_hal_adjusttxpower()
1051 pCmd->SupportTxPowerLevel = htole16(WL_TX_POWERLEVEL_LOW); in mwl_hal_adjusttxpower()
1053 pCmd->SupportTxPowerLevel = htole16(WL_TX_POWERLEVEL_MEDIUM); in mwl_hal_adjusttxpower()
1055 pCmd->SupportTxPowerLevel = htole16(WL_TX_POWERLEVEL_HIGH); in mwl_hal_adjusttxpower()
1068 int chan = c->channel, i; in findchannel()
1070 if (c->channelFlags.FreqBand == MWL_FREQ_BAND_2DOT4GHZ) { in findchannel()
1071 i = chan - 1; in findchannel()
1072 if (c->channelFlags.ChnlWidth == MWL_CH_40_MHz_WIDTH) { in findchannel()
1073 ci = &mh->mh_40M; in findchannel()
1074 if (c->channelFlags.ExtChnlOffset == MWL_EXT_CH_BELOW_CTRL_CH) in findchannel()
1075 i -= 4; in findchannel()
1077 ci = &mh->mh_20M; in findchannel()
1079 hc = ((unsigned)i < ci->nchannels) ? &ci->channels[i] : NULL; in findchannel()
1080 } else if (c->channelFlags.FreqBand == MWL_FREQ_BAND_5GHZ) { in findchannel()
1081 if (c->channelFlags.ChnlWidth == MWL_CH_40_MHz_WIDTH) { in findchannel()
1082 ci = &mh->mh_40M_5G; in findchannel()
1083 if (c->channelFlags.ExtChnlOffset == MWL_EXT_CH_BELOW_CTRL_CH) in findchannel()
1084 chan -= 4; in findchannel()
1086 ci = &mh->mh_20M_5G; in findchannel()
1088 for (i = 0; i < ci->nchannels; i++) in findchannel()
1089 if (ci->channels[i].ieee == chan) in findchannel()
1091 hc = (i < ci->nchannels) ? &ci->channels[i] : NULL; in findchannel()
1108 device_printf(mh->mh_dev, in mwl_hal_settxpower()
1109 "%s: no cal data for channel %u band %u width %u ext %u\n", in mwl_hal_settxpower()
1110 __func__, c->channel, c->channelFlags.FreqBand, in mwl_hal_settxpower()
1111 c->channelFlags.ChnlWidth, c->channelFlags.ExtChnlOffset); in mwl_hal_settxpower()
1118 pCmd->Action = htole16(HostCmd_ACT_GEN_SET_LIST); in mwl_hal_settxpower()
1120 /* NB: 5Ghz cal data have the channel # in [0]; don't truncate */ in mwl_hal_settxpower()
1121 if (c->channelFlags.FreqBand == MWL_FREQ_BAND_5GHZ) in mwl_hal_settxpower()
1122 pCmd->PowerLevelList[i++] = htole16(hc->targetPowers[0]); in mwl_hal_settxpower()
1124 uint16_t pow = hc->targetPowers[i]; in mwl_hal_settxpower()
1127 pCmd->PowerLevelList[i] = htole16(pow); in mwl_hal_settxpower()
1142 *ci = (chw == MWL_CH_20_MHz_WIDTH) ? &mh->mh_20M : &mh->mh_40M; in mwl_hal_getchannelinfo()
1146 &mh->mh_20M_5G : &mh->mh_40M_5G; in mwl_hal_getchannelinfo()
1151 return ((*ci)->freqLow == (*ci)->freqHigh) ? EINVAL : 0; in mwl_hal_getchannelinfo()
1167 memcpy(pCmd->MACList, macs, nmc*IEEE80211_ADDR_LEN); in mwl_hal_setmcast()
1168 pCmd->NumOfAdrs = htole16(nmc); in mwl_hal_setmcast()
1169 pCmd->Action = htole16(0xffff); in mwl_hal_setmcast()
1187 if (kv->keyFlags & (KEY_FLAG_TXGROUPKEY|KEY_FLAG_RXGROUPKEY)) in mwl_hal_keyset()
1188 pCmd->ActionType = htole32(EncrActionTypeSetGroupKey); in mwl_hal_keyset()
1190 pCmd->ActionType = htole32(EncrActionTypeSetKey); in mwl_hal_keyset()
1191 pCmd->KeyParam.Length = htole16(sizeof(pCmd->KeyParam)); in mwl_hal_keyset()
1192 pCmd->KeyParam.KeyTypeId = htole16(kv->keyTypeId); in mwl_hal_keyset()
1193 pCmd->KeyParam.KeyInfo = htole32(kv->keyFlags); in mwl_hal_keyset()
1194 pCmd->KeyParam.KeyIndex = htole32(kv->keyIndex); in mwl_hal_keyset()
1196 memcpy(&pCmd->KeyParam.Key, &kv->key, kv->keyLen); in mwl_hal_keyset()
1197 switch (kv->keyTypeId) { in mwl_hal_keyset()
1199 pCmd->KeyParam.KeyLen = htole16(kv->keyLen); in mwl_hal_keyset()
1202 pCmd->KeyParam.KeyLen = htole16(sizeof(TKIP_TYPE_KEY)); in mwl_hal_keyset()
1203 pCmd->KeyParam.Key.TkipKey.TkipRsc.low = in mwl_hal_keyset()
1204 htole16(kv->key.tkip.rsc.low); in mwl_hal_keyset()
1205 pCmd->KeyParam.Key.TkipKey.TkipRsc.high = in mwl_hal_keyset()
1206 htole32(kv->key.tkip.rsc.high); in mwl_hal_keyset()
1207 pCmd->KeyParam.Key.TkipKey.TkipTsc.low = in mwl_hal_keyset()
1208 htole16(kv->key.tkip.tsc.low); in mwl_hal_keyset()
1209 pCmd->KeyParam.Key.TkipKey.TkipTsc.high = in mwl_hal_keyset()
1210 htole32(kv->key.tkip.tsc.high); in mwl_hal_keyset()
1213 pCmd->KeyParam.KeyLen = htole16(sizeof(AES_TYPE_KEY)); in mwl_hal_keyset()
1217 IEEE80211_ADDR_COPY(pCmd->KeyParam.Macaddr, mac); in mwl_hal_keyset()
1219 IEEE80211_ADDR_COPY(pCmd->Macaddr, mac); in mwl_hal_keyset()
1236 pCmd->ActionType = htole16(EncrActionTypeRemoveKey); in mwl_hal_keyreset()
1237 pCmd->KeyParam.Length = htole16(sizeof(pCmd->KeyParam)); in mwl_hal_keyreset()
1238 pCmd->KeyParam.KeyTypeId = htole16(kv->keyTypeId); in mwl_hal_keyreset()
1239 pCmd->KeyParam.KeyInfo = htole32(kv->keyFlags); in mwl_hal_keyreset()
1240 pCmd->KeyParam.KeyIndex = htole32(kv->keyIndex); in mwl_hal_keyreset()
1242 IEEE80211_ADDR_COPY(pCmd->KeyParam.Macaddr, mac); in mwl_hal_keyreset()
1244 IEEE80211_ADDR_COPY(pCmd->Macaddr, mac); in mwl_hal_keyreset()
1259 IEEE80211_ADDR_COPY(&pCmd->MacAddr[0], addr); in mwl_hal_setmac_locked()
1261 pCmd->MacType = vap->bss_type; /* NB: already byte swapped */ in mwl_hal_setmac_locked()
1262 IEEE80211_ADDR_COPY(vap->mac, addr); /* XXX do only if success */ in mwl_hal_setmac_locked()
1290 pCmd->CmdHdr.Length = htole16(sizeof(HostCmd_DS_SET_BEACON)-1+frameLen); in mwl_hal_setbeacon()
1291 pCmd->FrmBodyLen = htole16(frameLen); in mwl_hal_setbeacon()
1292 memcpy(pCmd->FrmBody, frame, frameLen); in mwl_hal_setbeacon()
1309 pCmd->NumberOfPowersave = nsta; in mwl_hal_setpowersave_bss()
1325 pCmd->Aid = htole16(aid); in mwl_hal_setpowersave_sta()
1326 pCmd->Set = htole32(ena); in mwl_hal_setpowersave_sta()
1338 HostCmd_FW_SET_AID *pCmd = (HostCmd_FW_SET_AID *) &mh->mh_cmdbuf[0]; in mwl_hal_setassocid()
1343 pCmd->AssocID = htole16(assocId); in mwl_hal_setassocid()
1344 IEEE80211_ADDR_COPY(&pCmd->MacAddr[0], bssId); in mwl_hal_setassocid()
1360 pCmd->Action = htole16(HostCmd_ACT_GEN_SET); in mwl_hal_setchannel()
1361 pCmd->CurrentChannel = chan->channel; in mwl_hal_setchannel()
1362 pCmd->ChannelFlags = cvtChannelFlags(chan); /* NB: byte-swapped */ in mwl_hal_setchannel()
1381 pCmd->ActionType = htole32(BaCheckCreateStream); in bastream_check_available()
1382 pCmd->BaInfo.CreateParams.BarThrs = htole32(63); in bastream_check_available()
1383 pCmd->BaInfo.CreateParams.WindowSize = htole32(64); in bastream_check_available()
1384 pCmd->BaInfo.CreateParams.IdleThrs = htole32(0x22000); in bastream_check_available()
1385 IEEE80211_ADDR_COPY(&pCmd->BaInfo.CreateParams.PeerMacAddr[0], Macaddr); in bastream_check_available()
1386 pCmd->BaInfo.CreateParams.DialogToken = 10; in bastream_check_available()
1387 pCmd->BaInfo.CreateParams.Tid = Tid; in bastream_check_available()
1388 pCmd->BaInfo.CreateParams.QueueId = qid; in bastream_check_available()
1389 pCmd->BaInfo.CreateParams.ParamInfo = (uint8_t) ParamInfo; in bastream_check_available()
1391 cvtBAFlags(&pCmd->BaInfo.CreateParams.Flags, sp->ba_policy, 0); in bastream_check_available()
1393 pCmd->BaInfo.CreateParams.Flags = in bastream_check_available()
1406 if (le16toh(pCmd->CmdHdr.Result) != HostCmd_RESULT_OK) in bastream_check_available()
1422 if (mh->mh_bastreams == 0) { in mwl_hal_bastream_alloc()
1427 for (s = 0; (mh->mh_bastreams & (1<<s)) == 0; s++) in mwl_hal_bastream_alloc()
1433 sp = &mh->mh_streams[s]; in mwl_hal_bastream_alloc()
1434 mh->mh_bastreams &= ~(1<<s); in mwl_hal_bastream_alloc()
1435 sp->public.data[0] = a1; in mwl_hal_bastream_alloc()
1436 sp->public.data[1] = a2; in mwl_hal_bastream_alloc()
1437 IEEE80211_ADDR_COPY(sp->macaddr, Macaddr); in mwl_hal_bastream_alloc()
1438 sp->tid = Tid; in mwl_hal_bastream_alloc()
1439 sp->paraminfo = ParamInfo; in mwl_hal_bastream_alloc()
1440 sp->setup = 0; in mwl_hal_bastream_alloc()
1441 sp->ba_policy = ba_policy; in mwl_hal_bastream_alloc()
1443 return &sp->public; in mwl_hal_bastream_alloc()
1453 if (mh->mh_bastreams & (1<<s)) in mwl_hal_bastream_lookup()
1455 return &mh->mh_streams[s].public; in mwl_hal_bastream_lookup()
1473 pCmd->ActionType = htole32(BaCreateStream); in mwl_hal_bastream_create()
1474 pCmd->BaInfo.CreateParams.BarThrs = htole32(BarThrs); in mwl_hal_bastream_create()
1475 pCmd->BaInfo.CreateParams.WindowSize = htole32(WindowSize); in mwl_hal_bastream_create()
1476 pCmd->BaInfo.CreateParams.IdleThrs = htole32(0x22000); in mwl_hal_bastream_create()
1477 IEEE80211_ADDR_COPY(&pCmd->BaInfo.CreateParams.PeerMacAddr[0], in mwl_hal_bastream_create()
1478 sp->macaddr); in mwl_hal_bastream_create()
1480 memset(&pCmd->BaInfo.CreateParams.StaSrcMacAddr, 0, IEEE80211_ADDR_LEN); in mwl_hal_bastream_create()
1482 pCmd->BaInfo.CreateParams.DialogToken = DialogToken; in mwl_hal_bastream_create()
1484 pCmd->BaInfo.CreateParams.DialogToken = 10; in mwl_hal_bastream_create()
1486 pCmd->BaInfo.CreateParams.Tid = sp->tid; in mwl_hal_bastream_create()
1487 pCmd->BaInfo.CreateParams.QueueId = sp->stream; in mwl_hal_bastream_create()
1488 pCmd->BaInfo.CreateParams.ParamInfo = sp->paraminfo; in mwl_hal_bastream_create()
1490 pCmd->BaInfo.CreateParams.StartSeqNo = htole16(seqno); in mwl_hal_bastream_create()
1492 cvtBAFlags(&pCmd->BaInfo.CreateParams.Flags, sp->ba_policy, 0); in mwl_hal_bastream_create()
1494 pCmd->BaInfo.CreateParams.Flags = in mwl_hal_bastream_create()
1507 if (le16toh(pCmd->CmdHdr.Result) != HostCmd_RESULT_OK) in mwl_hal_bastream_create()
1510 sp->setup = 1; in mwl_hal_bastream_create()
1524 if (sp->stream >= MWL_BASTREAMS_MAX) { in mwl_hal_bastream_destroy()
1529 if (sp->setup) { in mwl_hal_bastream_destroy()
1531 pCmd->ActionType = htole32(BaDestroyStream); in mwl_hal_bastream_destroy()
1532 pCmd->BaInfo.DestroyParams.FwBaContext.Context = in mwl_hal_bastream_destroy()
1533 htole32(sp->stream); in mwl_hal_bastream_destroy()
1539 mh->mh_bastreams |= 1<<sp->stream; in mwl_hal_bastream_destroy()
1540 sp->public.data[0] = NULL; in mwl_hal_bastream_destroy()
1541 sp->public.data[1] = NULL; in mwl_hal_bastream_destroy()
1542 sp->setup = 0; in mwl_hal_bastream_destroy()
1559 IEEE80211_ADDR_COPY(pCmd->MacAddr, Macaddr); in mwl_hal_bastream_get_seqno()
1560 pCmd->TID = sp->tid; in mwl_hal_bastream_get_seqno()
1564 *pseqno = le16toh(pCmd->SeqNo); in mwl_hal_bastream_get_seqno()
1582 bitmap[0] = pCmd->Watchdogbitmap; in mwl_hal_getwatchdogbitmap()
1604 pCmd->Action = htole16(1); in mwl_hal_setaggampduratemode()
1605 pCmd->Option = htole32(mode); in mwl_hal_setaggampduratemode()
1606 pCmd->Threshold = htole32(threshold); in mwl_hal_setaggampduratemode()
1623 pCmd->Action = htole16(0); in mwl_hal_getaggampduratemode()
1627 *mode = le32toh(pCmd->Option); in mwl_hal_getaggampduratemode()
1628 *threshold = le32toh(pCmd->Threshold); in mwl_hal_getaggampduratemode()
1645 pCmd->Enable = htole32(ena); in mwl_hal_setcfend()
1661 pCmd->Enable = htole32(ena); in mwl_hal_setdwds()
1670 to->LegacyRateBitMap = htole32(from->LegacyRateBitMap); in cvtPeerInfo()
1671 to->HTRateBitMap = htole32(from->HTRateBitMap); in cvtPeerInfo()
1672 to->CapInfo = htole16(from->CapInfo); in cvtPeerInfo()
1673 to->HTCapabilitiesInfo = htole16(from->HTCapabilitiesInfo); in cvtPeerInfo()
1674 to->MacHTParamInfo = from->MacHTParamInfo; in cvtPeerInfo()
1675 to->AddHtInfo.ControlChan = from->AddHtInfo.ControlChan; in cvtPeerInfo()
1676 to->AddHtInfo.AddChan = from->AddHtInfo.AddChan; in cvtPeerInfo()
1677 to->AddHtInfo.OpMode = htole16(from->AddHtInfo.OpMode); in cvtPeerInfo()
1678 to->AddHtInfo.stbc = htole16(from->AddHtInfo.stbc); in cvtPeerInfo()
1693 pCmd->AID = htole16(aid); in mwl_hal_newstation()
1694 pCmd->StnId = htole16(sid); in mwl_hal_newstation()
1695 pCmd->Action = htole16(0); /* SET */ in mwl_hal_newstation()
1698 cvtPeerInfo(&pCmd->PeerInfo, peer); in mwl_hal_newstation()
1700 IEEE80211_ADDR_COPY(&pCmd->MacAddr[0], addr); in mwl_hal_newstation()
1701 pCmd->Qosinfo = wmeInfo; in mwl_hal_newstation()
1702 pCmd->isQosSta = (isQosSta != 0); in mwl_hal_newstation()
1705 if (retval == 0 && IEEE80211_ADDR_EQ(vap->mac, addr)) in mwl_hal_newstation()
1706 vap->flags |= MVF_STATION; in mwl_hal_newstation()
1720 islocal = IEEE80211_ADDR_EQ(vap->mac, addr); in mwl_hal_delstation()
1721 if (!islocal || (vap->flags & MVF_STATION)) { in mwl_hal_delstation()
1724 pCmd->Action = htole16(2); /* REMOVE */ in mwl_hal_delstation()
1725 IEEE80211_ADDR_COPY(&pCmd->MacAddr[0], addr); in mwl_hal_delstation()
1728 vap->flags &= ~MVF_STATION; in mwl_hal_delstation()
1737 * save queues and reap frames on the tx aggregation q's.
1751 * a non-zero value is a noop. in mwl_hal_setkeepalive()
1753 pCmd->tick = 0; in mwl_hal_setkeepalive()
1771 pCmd->ApMode = ApMode; in mwl_hal_setapmode()
1786 if (vap->flags & MVF_RUNNING) { in mwl_hal_stop()
1789 pCmd->Enable = htole32(HostCmd_ACT_GEN_OFF); in mwl_hal_stop()
1794 vap->flags &= ~MVF_RUNNING; in mwl_hal_stop()
1808 pCmd->Enable = htole32(HostCmd_ACT_GEN_ON); in mwl_hal_start()
1812 vap->flags |= MVF_RUNNING; in mwl_hal_start()
1827 pCmd->GProtectFlag = htole32(prot); in mwl_hal_setgprot()
1844 pCmd->Action = htole16(onoff); in mwl_hal_setwmm()
1867 pCmd->Action = htole16(0xffff); /* NB: set everything */ in mwl_hal_setedcaparams()
1868 pCmd->TxOP = htole16(TXOPLimit); in mwl_hal_setedcaparams()
1869 pCmd->CWMax = htole32(CWmax); in mwl_hal_setedcaparams()
1870 pCmd->CWMin = htole32(CWmin); in mwl_hal_setedcaparams()
1871 pCmd->AIFSN = AIFSN; in mwl_hal_setedcaparams()
1872 pCmd->TxQNum = qnum; /* XXX check */ in mwl_hal_setedcaparams()
1890 pCmd->Action = htole16(HostCmd_ACT_GEN_SET); in mwl_hal_setrateadaptmode()
1891 pCmd->RateAdaptMode = htole16(mode); in mwl_hal_setrateadaptmode()
1908 pCmd->Action = htole16(HostCmd_ACT_GEN_SET); in mwl_hal_setcsmode()
1909 pCmd->CSMode = htole16(csmode); in mwl_hal_setcsmode()
1927 pCmd->NProtectFlag = htole32(mode); in mwl_hal_setnprot()
1944 pCmd->NProtectOpMode = mode; in mwl_hal_setnprotmode()
1961 pCmd->OptLevel = level; in mwl_hal_setoptimizationlevel()
1978 IEEE80211_ADDR_COPY(pCmd->Addr, addr); in mwl_hal_setmimops()
1979 pCmd->Enable = enable; in mwl_hal_setmimops()
1980 pCmd->Mode = mode; in mwl_hal_setmimops()
1996 pCmd->annex = annex; in mwlGetCalTable()
1997 pCmd->index = index; in mwlGetCalTable()
1998 memset(pCmd->calTbl, 0, sizeof(pCmd->calTbl)); in mwlGetCalTable()
2002 pCmd->calTbl[0] != annex && annex != 0 && annex != 255) in mwlGetCalTable()
2008 * Calculate the max tx power from the channel's cal data.
2013 hc->maxTxPow = hc->targetPowers[i]; in setmaxtxpow()
2015 if (hc->targetPowers[i] > hc->maxTxPow) in setmaxtxpow()
2016 hc->maxTxPow = hc->targetPowers[i]; in setmaxtxpow()
2020 * Construct channel info for 5GHz channels from cal data.
2040 hc = &ci->channels[j]; in get5Ghz()
2041 hc->freq = f; in get5Ghz()
2042 hc->ieee = table[i]; in get5Ghz()
2043 memcpy(hc->targetPowers, &table[i], 4); in get5Ghz()
2047 ci->nchannels = j; in get5Ghz()
2048 ci->freqLow = (l == 32000) ? 0 : l; in get5Ghz()
2049 ci->freqHigh = h; in get5Ghz()
2059 return 2512 + (chan-15)*20; in ieee2mhz()
2063 * Construct channel info for 2.4GHz channels from cal data.
2072 struct mwl_hal_channel *hc = &ci->channels[j]; in get2Ghz()
2073 hc->ieee = 1+j; in get2Ghz()
2074 hc->freq = ieee2mhz(1+j); in get2Ghz()
2075 memcpy(hc->targetPowers, &table[i], 4); in get2Ghz()
2079 ci->nchannels = j; in get2Ghz()
2080 ci->freqLow = ieee2mhz(1); in get2Ghz()
2081 ci->freqHigh = ieee2mhz(j); in get2Ghz()
2092 printf("[%2d] %3d %3d %3d %3d\n", i/4, table[i+0], table[i+1], table[i+2], table[i+3]); in dumpcaldata()
2105 data = ((const HostCmd_FW_GET_CALTABLE *) mh->mh_cmdbuf)->calTbl; in mwlGetPwrCalTable()
2107 len = (data[2] | (data[3] << 8)) - 12; in mwlGetPwrCalTable()
2113 get2Ghz(&mh->mh_20M, &data[12], len); in mwlGetPwrCalTable()
2116 len = (data[2] | (data[3] << 8)) - 12; in mwlGetPwrCalTable()
2122 ci = &mh->mh_40M; in mwlGetPwrCalTable()
2126 len = (data[2] | (data[3] << 8)) - 20; in mwlGetPwrCalTable()
2132 get5Ghz(&mh->mh_20M_5G, &data[20], len); in mwlGetPwrCalTable()
2135 len = (data[2] | (data[3] << 8)) - 20; in mwlGetPwrCalTable()
2141 ci = &mh->mh_40M_5G; in mwlGetPwrCalTable()
2144 mh->mh_flags |= MHF_CALDATA; in mwlGetPwrCalTable()
2159 (const HostCmd_FW_GET_CALTABLE *) mh->mh_cmdbuf; in mwl_hal_getregioncode()
2160 *countryCode = pCmd->calTbl[16]; in mwl_hal_getregioncode()
2200 pCmd->Bcnlen = htole16(0); in mwl_hal_GetBeacon()
2205 memcpy(pBcn, &pCmd->Bcn, pCmd->Bcnlen); in mwl_hal_GetBeacon()
2206 *pLen = pCmd->Bcnlen; in mwl_hal_GetBeacon()
2221 pCmd->QNum = QNum; in mwl_hal_SetRifs()
2240 pCmd->Offset = htole16(reg); in getRFReg()
2241 pCmd->Action = htole16(flag); in getRFReg()
2242 pCmd->Value = htole32(*val); in getRFReg()
2246 *val = pCmd->Value; in getRFReg()
2259 pCmd->Offset = htole16(reg); in getBBReg()
2260 pCmd->Action = htole16(flag); in getBBReg()
2261 pCmd->Value = htole32(*val); in getBBReg()
2265 *val = pCmd->Value; in getBBReg()
2281 space -= sizeof(uint32_t); in mwl_hal_getregdump()
2287 r - MWL_DIAG_BASE_BB, dp); in mwl_hal_getregdump()
2290 r - MWL_DIAG_BASE_RF, dp); in mwl_hal_getregdump()
2297 space -= sizeof(uint32_t); in mwl_hal_getregdump()
2300 return (char *) dp - (char *) dstbuf; in mwl_hal_getregdump()
2312 *result = &mh->mh_revs; in mwl_hal_getdiagstate()
2313 *resultsize = sizeof(mh->mh_revs); in mwl_hal_getdiagstate()
2319 FWCmdHdr *pCmd = (FWCmdHdr *) &mh->mh_cmdbuf[0]; in mwl_hal_getdiagstate()
2324 retval = mwlExecuteCmd(mh, le16toh(pCmd->Cmd)); in mwl_hal_getdiagstate()
2331 device_printf(mh->mh_dev, "problem loading fw image\n"); in mwl_hal_getdiagstate()
2347 bus_dmamap_sync(mh->mh_dmat, mh->mh_dmamap, in mwlSendCmd()
2350 WR4(mh, MACREG_REG_GEN_PTR, mh->mh_cmdaddr); in mwlSendCmd()
2363 if (mh->mh_cmdbuf[0] == le16toh(cmdCode)) in mwlWaitForCmdComplete()
2377 if ((mh->mh_flags & MHF_FWHANG) && in mwlExecuteCmd()
2378 (mh->mh_debug & MWL_HAL_DEBUG_IGNHANG) == 0) { in mwlExecuteCmd()
2380 device_printf(mh->mh_dev, "firmware hung, skipping cmd %s\n", in mwlExecuteCmd()
2383 device_printf(mh->mh_dev, "firmware hung, skipping cmd 0x%x\n", in mwlExecuteCmd()
2389 device_printf(mh->mh_dev, "%s: device not present!\n", in mwlExecuteCmd()
2394 if (mh->mh_debug & MWL_HAL_DEBUG_SENDCMD) in mwlExecuteCmd()
2400 device_printf(mh->mh_dev, in mwlExecuteCmd()
2403 device_printf(mh->mh_dev, in mwlExecuteCmd()
2406 mh->mh_flags |= MHF_FWHANG; in mwlExecuteCmd()
2409 bus_dmamap_sync(mh->mh_dmat, mh->mh_dmamap, in mwlExecuteCmd()
2412 if (mh->mh_debug & MWL_HAL_DEBUG_CMDDONE) in mwlExecuteCmd()
2435 device_printf(mh->mh_dev, "%s: device not present!\n", in mwlFwReset()
2440 mh->mh_flags &= ~MHF_FWHANG; in mwlFwReset()
2447 bus_dmamap_sync(mh->mh_dmat, mh->mh_dmamap, BUS_DMASYNC_PREWRITE); in mwlTriggerPciCmd()
2449 WR4(mh, MACREG_REG_GEN_PTR, mh->mh_cmdaddr); in mwlTriggerPciCmd()
2473 * Firmware block xmit when talking to the boot-rom.
2478 mh->mh_cmdbuf[0] = htole16(HostCmd_CMD_CODE_DNLD); in mwlSendBlock()
2479 mh->mh_cmdbuf[1] = htole16(bsize); in mwlSendBlock()
2480 memcpy(&mh->mh_cmdbuf[4], data , dsize); in mwlSendBlock()
2487 device_printf(mh->mh_dev, in mwlSendBlock()
2494 * Firmware block xmit when talking to the 1st-stage loader.
2499 memcpy(&mh->mh_cmdbuf[0], data, dsize); in mwlSendBlock2()
2505 device_printf(mh->mh_dev, in mwlSendBlock2()
2538 device_printf(mh->mh_dev, in mwl_hal_fwload()
2542 fmdata = fw->data; in mwl_hal_fwload()
2543 fmsize = fw->datasize; in mwl_hal_fwload()
2545 device_printf(mh->mh_dev, "firmware image %s too small\n", in mwl_hal_fwload()
2553 * 2-stage load, get the boot firmware. in mwl_hal_fwload()
2557 device_printf(mh->mh_dev, in mwl_hal_fwload()
2571 if (mh->mh_SDRAMSIZE_Addr != 0) { in mwl_hal_fwload()
2573 mwlPokeSdramController(mh, mh->mh_SDRAMSIZE_Addr); in mwl_hal_fwload()
2575 device_printf(mh->mh_dev, "load %s firmware image (%u bytes)\n", in mwl_hal_fwload()
2579 * Do 2-stage load. The 1st stage loader is setup in mwl_hal_fwload()
2588 if (!mwlSendBlock(mh, fwboot->datasize, fwboot->data, fwboot->datasize) || in mwl_hal_fwload()
2594 if (mh->mh_SDRAMSIZE_Addr != 0) { in mwl_hal_fwload()
2596 mwlPokeSdramController(mh, mh->mh_SDRAMSIZE_Addr); in mwl_hal_fwload()
2624 if (blocksize > ep - fp) { in mwl_hal_fwload()
2626 blocksize = ep - fp; in mwl_hal_fwload()
2636 nbytes = ep - fp; in mwl_hal_fwload()
2655 mh->mh_cmdbuf[1] = 0; in mwl_hal_fwload()
2744 const FWCmdHdr *h = (const FWCmdHdr *)mh->mh_cmdbuf; in dumpresult()
2748 len = le16toh(h->Length); in dumpresult()
2750 device_printf(mh->mh_dev, "Cmd %s Length %d SeqNum %d MacId %d", in dumpresult()
2751 mwlcmdname(le16toh(h->Cmd) &~ 0x8000), len, h->SeqNum, h->MacId); in dumpresult()
2753 device_printf(mh->mh_dev, "Cmd %s Length %d SeqNum %d", in dumpresult()
2754 mwlcmdname(le16toh(h->Cmd) &~ 0x8000), len, le16toh(h->SeqNum)); in dumpresult()
2760 int result = le16toh(h->Result); in dumpresult()
2765 printf(" Result %d", result); in dumpresult()