1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
20 #define _RTL8188E_CMD_C_
22 #include <osdep_service.h>
23 #include <drv_types.h>
24 #include <recv_osdep.h>
25 #include <mlme_osdep.h>
26 #include <rtw_ioctl_set.h>
28 #include <rtl8188e_hal.h>
30 #define RTL88E_MAX_H2C_BOX_NUMS 4
31 #define RTL88E_MAX_CMD_LEN 7
32 #define RTL88E_MESSAGE_BOX_SIZE 4
33 #define RTL88E_EX_MESSAGE_BOX_SIZE 4
35 static u8 _is_fw_read_cmd_down(struct adapter *adapt, u8 msgbox_num)
43 valid = usb_read8(adapt, REG_HMETFR) & BIT(msgbox_num);
46 } while ((!read_down) && (retry_cnts--));
51 /*****************************************
54 *| 31 - 8 | 7-5 4 - 0 |
55 *| h2c_msg |Class_ID CMD_ID |
57 * Extend 0x1FF - 0x1F0
60 ******************************************/
61 static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer)
68 struct hal_data_8188e *haldata = GET_HAL_DATA(adapt);
69 u8 cmd_idx, ext_cmd_len;
75 if (!adapt->bFWReady) {
76 DBG_88E("FillH2CCmd_88E(): return H2C cmd because fw is not ready\n");
82 if (CmdLen > RTL88E_MAX_CMD_LEN)
84 if (adapt->bSurpriseRemoved)
87 /* pay attention to if race condition happened in H2C cmd setting. */
89 h2c_box_num = haldata->LastHMEBoxNum;
91 if (!_is_fw_read_cmd_down(adapt, h2c_box_num)) {
92 DBG_88E(" fw read cmd failed...\n");
96 *(u8 *)(&h2c_cmd) = ElementID;
99 memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, CmdLen);
101 memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, 3);
102 ext_cmd_len = CmdLen-3;
103 memcpy((u8 *)(&h2c_cmd_ex), pCmdBuffer+3, ext_cmd_len);
105 /* Write Ext command */
106 msgbox_ex_addr = REG_HMEBOX_EXT_0 + (h2c_box_num * RTL88E_EX_MESSAGE_BOX_SIZE);
107 for (cmd_idx = 0; cmd_idx < ext_cmd_len; cmd_idx++) {
108 usb_write8(adapt, msgbox_ex_addr+cmd_idx, *((u8 *)(&h2c_cmd_ex)+cmd_idx));
112 msgbox_addr = REG_HMEBOX_0 + (h2c_box_num * RTL88E_MESSAGE_BOX_SIZE);
113 for (cmd_idx = 0; cmd_idx < RTL88E_MESSAGE_BOX_SIZE; cmd_idx++) {
114 usb_write8(adapt, msgbox_addr+cmd_idx, *((u8 *)(&h2c_cmd)+cmd_idx));
118 haldata->LastHMEBoxNum = (h2c_box_num+1) % RTL88E_MAX_H2C_BOX_NUMS;
120 } while ((!bcmd_down) && (retry_cnts--));
130 u8 rtl8188e_set_rssi_cmd(struct adapter *adapt, u8 *param)
133 struct hal_data_8188e *haldata = GET_HAL_DATA(adapt);
135 if (haldata->fw_ractrl) {
138 DBG_88E("==>%s fw dont support RA\n", __func__);
146 u8 rtl8188e_set_raid_cmd(struct adapter *adapt, u32 mask)
150 struct hal_data_8188e *haldata = GET_HAL_DATA(adapt);
152 if (haldata->fw_ractrl) {
156 lmask = cpu_to_le32(mask);
157 memcpy(buf, &lmask, 3);
159 FillH2CCmd_88E(adapt, H2C_DM_MACID_CFG, 3, buf);
161 DBG_88E("==>%s fw dont support RA\n", __func__);
169 /* bitmap[0:27] = tx_rate_bitmap */
170 /* bitmap[28:31]= Rate Adaptive id */
171 /* arg[0:4] = macid */
172 /* arg[5] = Short GI */
173 void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi_level)
175 struct hal_data_8188e *haldata = GET_HAL_DATA(pAdapter);
177 u8 macid, init_rate, raid, shortGIrate = false;
181 raid = (bitmap>>28) & 0x0f;
182 bitmap &= 0x0fffffff;
184 if (rssi_level != DM_RATR_STA_INIT)
185 bitmap = ODM_Get_Rate_Bitmap(&haldata->odmpriv, macid, bitmap, rssi_level);
187 bitmap |= ((raid<<28)&0xf0000000);
189 init_rate = get_highest_rate_idx(bitmap&0x0fffffff)&0x3f;
191 shortGIrate = (arg&BIT(5)) ? true : false;
196 raid = (bitmap>>28) & 0x0f;
198 bitmap &= 0x0fffffff;
200 DBG_88E("%s=> mac_id:%d, raid:%d, ra_bitmap=0x%x, shortGIrate=0x%02x\n",
201 __func__, macid, raid, bitmap, shortGIrate);
203 ODM_RA_UpdateRateInfo_8188E(&(haldata->odmpriv), macid, raid, bitmap, shortGIrate);
206 void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode)
208 struct setpwrmode_parm H2CSetPwrMode;
209 struct pwrctrl_priv *pwrpriv = &adapt->pwrctrlpriv;
210 u8 RLBM = 0; /* 0:Min, 1:Max, 2:User define */
212 DBG_88E("%s: Mode=%d SmartPS=%d UAPSD=%d\n", __func__,
213 Mode, pwrpriv->smart_ps, adapt->registrypriv.uapsd_enable);
217 H2CSetPwrMode.Mode = 0;
220 H2CSetPwrMode.Mode = 1;
224 H2CSetPwrMode.Mode = 1;
228 H2CSetPwrMode.Mode = 1;
230 case PS_MODE_UAPSD_WMM:
231 H2CSetPwrMode.Mode = 2;
234 H2CSetPwrMode.Mode = 0;
238 H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps<<4)&0xf0) | (RLBM & 0x0f));
240 H2CSetPwrMode.AwakeInterval = 1;
242 H2CSetPwrMode.bAllQueueUAPSD = adapt->registrypriv.uapsd_enable;
245 H2CSetPwrMode.PwrState = 0x00;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */
247 H2CSetPwrMode.PwrState = 0x0C;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */
249 FillH2CCmd_88E(adapt, H2C_PS_PWR_MODE, sizeof(H2CSetPwrMode), (u8 *)&H2CSetPwrMode);
253 void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt)
256 u16 mst_rpt = le16_to_cpu(mstatus_rpt);
257 opmode = (u8) mst_rpt;
258 macid = (u8)(mst_rpt >> 8);
260 DBG_88E("### %s: MStatus=%x MACID=%d\n", __func__, opmode, macid);
261 FillH2CCmd_88E(adapt, H2C_COM_MEDIA_STATUS_RPT, sizeof(mst_rpt), (u8 *)&mst_rpt);
264 static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength)
266 struct rtw_ieee80211_hdr *pwlanhdr;
268 u32 rate_len, pktlen;
269 struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv);
270 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
271 struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
272 u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
274 pwlanhdr = (struct rtw_ieee80211_hdr *)pframe;
276 fctrl = &(pwlanhdr->frame_ctl);
279 memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN);
280 memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN);
281 memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN);
283 SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/);
284 SetFrameSubType(pframe, WIFI_BEACON);
286 pframe += sizeof(struct rtw_ieee80211_hdr_3addr);
287 pktlen = sizeof(struct rtw_ieee80211_hdr_3addr);
289 /* timestamp will be inserted by hardware */
293 /* beacon interval: 2 bytes */
294 memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2);
299 /* capability info: 2 bytes */
300 memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2);
305 if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) {
306 pktlen += cur_network->IELength - sizeof(struct ndis_802_11_fixed_ie);
307 memcpy(pframe, cur_network->IEs+sizeof(struct ndis_802_11_fixed_ie), pktlen);
309 goto _ConstructBeacon;
312 /* below for ad-hoc mode */
315 pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pktlen);
317 /* supported rates... */
318 rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
319 pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen);
321 /* DS parameter set */
322 pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen);
324 if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
326 /* IBSS Parameter Set... */
328 pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pktlen);
333 /* EXTERNDED SUPPORTED RATE */
335 pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen);
337 /* todo:HT for adhoc */
341 if ((pktlen + TXDESC_SIZE) > 512) {
342 DBG_88E("beacon frame too large\n");
349 static void ConstructPSPoll(struct adapter *adapt, u8 *pframe, u32 *pLength)
351 struct rtw_ieee80211_hdr *pwlanhdr;
352 struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv);
353 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
356 pwlanhdr = (struct rtw_ieee80211_hdr *)pframe;
359 fctrl = &(pwlanhdr->frame_ctl);
362 SetFrameSubType(pframe, WIFI_PSPOLL);
365 SetDuration(pframe, (pmlmeinfo->aid | 0xc000));
368 memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
371 memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN);
376 static void ConstructNullFunctionData(struct adapter *adapt, u8 *pframe,
384 struct rtw_ieee80211_hdr *pwlanhdr;
387 struct mlme_priv *pmlmepriv = &adapt->mlmepriv;
388 struct wlan_network *cur_network = &pmlmepriv->cur_network;
389 struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv);
390 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
392 pwlanhdr = (struct rtw_ieee80211_hdr *)pframe;
394 fctrl = &pwlanhdr->frame_ctl;
399 switch (cur_network->network.InfrastructureMode) {
400 case Ndis802_11Infrastructure:
402 memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
403 memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN);
404 memcpy(pwlanhdr->addr3, StaAddr, ETH_ALEN);
406 case Ndis802_11APMode:
408 memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN);
409 memcpy(pwlanhdr->addr2, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
410 memcpy(pwlanhdr->addr3, myid(&(adapt->eeprompriv)), ETH_ALEN);
414 memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN);
415 memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN);
416 memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
420 SetSeqNum(pwlanhdr, 0);
423 struct rtw_ieee80211_hdr_3addr_qos *pwlanqoshdr;
425 SetFrameSubType(pframe, WIFI_QOS_DATA_NULL);
427 pwlanqoshdr = (struct rtw_ieee80211_hdr_3addr_qos *)pframe;
428 SetPriority(&pwlanqoshdr->qc, AC);
429 SetEOSP(&pwlanqoshdr->qc, bEosp);
431 pktlen = sizeof(struct rtw_ieee80211_hdr_3addr_qos);
433 SetFrameSubType(pframe, WIFI_DATA_NULL);
435 pktlen = sizeof(struct rtw_ieee80211_hdr_3addr);
441 static void ConstructProbeRsp(struct adapter *adapt, u8 *pframe, u32 *pLength, u8 *StaAddr, bool bHideSSID)
443 struct rtw_ieee80211_hdr *pwlanhdr;
447 struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv);
448 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
449 struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
451 pwlanhdr = (struct rtw_ieee80211_hdr *)pframe;
453 mac = myid(&(adapt->eeprompriv));
454 bssid = cur_network->MacAddress;
456 fctrl = &(pwlanhdr->frame_ctl);
458 memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN);
459 memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
460 memcpy(pwlanhdr->addr3, bssid, ETH_ALEN);
462 SetSeqNum(pwlanhdr, 0);
463 SetFrameSubType(fctrl, WIFI_PROBERSP);
465 pktlen = sizeof(struct rtw_ieee80211_hdr_3addr);
468 if (cur_network->IELength > MAX_IE_SZ)
471 memcpy(pframe, cur_network->IEs, cur_network->IELength);
472 pframe += cur_network->IELength;
473 pktlen += cur_network->IELength;
479 /* Description: Fill the reserved packets that FW will use to RSVD page. */
480 /* Now we just send 4 types packet to rsvd page. */
481 /* (1)Beacon, (2)Ps-poll, (3)Null data, (4)ProbeRsp. */
483 /* bDLFinished - false: At the first time we will send all the packets as a large packet to Hw, */
484 /* so we need to set the packet length to total length. */
485 /* true: At the second time, we should send the first packet (default:beacon) */
486 /* to Hw again and set the length in descriptor to the real beacon length. */
487 /* 2009.10.15 by tynli. */
488 static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished)
490 struct hal_data_8188e *haldata;
491 struct xmit_frame *pmgntframe;
492 struct pkt_attrib *pattrib;
493 struct xmit_priv *pxmitpriv;
494 struct mlme_ext_priv *pmlmeext;
495 struct mlme_ext_info *pmlmeinfo;
496 u32 BeaconLength = 0, ProbeRspLength = 0, PSPollLength;
497 u32 NullDataLength, QosNullLength;
498 u8 *ReservedPagePacket;
499 u8 PageNum, PageNeed, TxDescLen;
502 struct rsvdpage_loc RsvdPageLoc;
504 DBG_88E("%s\n", __func__);
505 ReservedPagePacket = kzalloc(1000, GFP_KERNEL);
506 if (ReservedPagePacket == NULL) {
507 DBG_88E("%s: alloc ReservedPagePacket fail!\n", __func__);
511 haldata = GET_HAL_DATA(adapt);
512 pxmitpriv = &adapt->xmitpriv;
513 pmlmeext = &adapt->mlmeextpriv;
514 pmlmeinfo = &pmlmeext->mlmext_info;
516 TxDescLen = TXDESC_SIZE;
519 /* 3 (1) beacon * 2 pages */
520 BufIndex = TXDESC_OFFSET;
521 ConstructBeacon(adapt, &ReservedPagePacket[BufIndex], &BeaconLength);
523 /* When we count the first page size, we need to reserve description size for the RSVD */
524 /* packet, it will be filled in front of the packet in TXPKTBUF. */
525 PageNeed = (u8)PageNum_128(TxDescLen + BeaconLength);
526 /* To reserved 2 pages for beacon buffer. 2010.06.24. */
530 haldata->FwRsvdPageStartOffset = PageNum;
532 BufIndex += PageNeed*128;
534 /* 3 (2) ps-poll *1 page */
535 RsvdPageLoc.LocPsPoll = PageNum;
536 ConstructPSPoll(adapt, &ReservedPagePacket[BufIndex], &PSPollLength);
537 rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], PSPollLength, true, false);
539 PageNeed = (u8)PageNum_128(TxDescLen + PSPollLength);
542 BufIndex += PageNeed*128;
544 /* 3 (3) null data * 1 page */
545 RsvdPageLoc.LocNullData = PageNum;
546 ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex], &NullDataLength, get_my_bssid(&pmlmeinfo->network), false, 0, 0, false);
547 rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], NullDataLength, false, false);
549 PageNeed = (u8)PageNum_128(TxDescLen + NullDataLength);
552 BufIndex += PageNeed*128;
554 /* 3 (4) probe response * 1page */
555 RsvdPageLoc.LocProbeRsp = PageNum;
556 ConstructProbeRsp(adapt, &ReservedPagePacket[BufIndex], &ProbeRspLength, get_my_bssid(&pmlmeinfo->network), false);
557 rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], ProbeRspLength, false, false);
559 PageNeed = (u8)PageNum_128(TxDescLen + ProbeRspLength);
562 BufIndex += PageNeed*128;
564 /* 3 (5) Qos null data */
565 RsvdPageLoc.LocQosNull = PageNum;
566 ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex],
567 &QosNullLength, get_my_bssid(&pmlmeinfo->network), true, 0, 0, false);
568 rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], QosNullLength, false, false);
570 PageNeed = (u8)PageNum_128(TxDescLen + QosNullLength);
573 TotalPacketLen = BufIndex + QosNullLength;
574 pmgntframe = alloc_mgtxmitframe(pxmitpriv);
575 if (pmgntframe == NULL)
578 /* update attribute */
579 pattrib = &pmgntframe->attrib;
580 update_mgntframe_attrib(adapt, pattrib);
581 pattrib->qsel = 0x10;
582 pattrib->last_txcmdsz = TotalPacketLen - TXDESC_OFFSET;
583 pattrib->pktlen = pattrib->last_txcmdsz;
584 memcpy(pmgntframe->buf_addr, ReservedPagePacket, TotalPacketLen);
586 rtw_hal_mgnt_xmit(adapt, pmgntframe);
588 DBG_88E("%s: Set RSVD page location to Fw\n", __func__);
589 FillH2CCmd_88E(adapt, H2C_COM_RSVD_PAGE, sizeof(RsvdPageLoc), (u8 *)&RsvdPageLoc);
592 kfree(ReservedPagePacket);
595 void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus)
597 struct hal_data_8188e *haldata = GET_HAL_DATA(adapt);
598 struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv);
599 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
600 bool bSendBeacon = false;
601 bool bcn_valid = false;
606 DBG_88E("%s mstatus(%x)\n", __func__, mstatus);
609 /* We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C. */
610 /* Suggested by filen. Added by tynli. */
611 usb_write16(adapt, REG_BCN_PSR_RPT, (0xC000|pmlmeinfo->aid));
612 /* Do not set TSF again here or vWiFi beacon DMA INT will not work. */
614 /* Set REG_CR bit 8. DMA beacon by SW. */
615 haldata->RegCR_1 |= BIT0;
616 usb_write8(adapt, REG_CR+1, haldata->RegCR_1);
618 /* Disable Hw protection for a time which revserd for Hw sending beacon. */
619 /* Fix download reserved page packet fail that access collision with the protection time. */
620 /* 2010.05.11. Added by tynli. */
621 usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL)&(~BIT(3)));
622 usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL)|BIT(4));
624 if (haldata->RegFwHwTxQCtrl&BIT6) {
625 DBG_88E("HalDownloadRSVDPage(): There is an Adapter is sending beacon.\n");
629 /* Set FWHW_TXQ_CTRL 0x422[6]=0 to tell Hw the packet is not a real beacon frame. */
630 usb_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl&(~BIT6)));
631 haldata->RegFwHwTxQCtrl &= (~BIT6);
633 /* Clear beacon valid check bit. */
634 rtw_hal_set_hwreg(adapt, HW_VAR_BCN_VALID, NULL);
638 /* download rsvd page. */
639 SetFwRsvdPagePkt(adapt, false);
644 /* check rsvd page download OK. */
645 rtw_hal_get_hwreg(adapt, HW_VAR_BCN_VALID, (u8 *)(&bcn_valid));
647 } while (!bcn_valid && (poll%10) != 0 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped);
648 } while (!bcn_valid && DLBcnCount <= 100 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped);
650 if (adapt->bSurpriseRemoved || adapt->bDriverStopped)
653 DBG_88E("%s: 1 Download RSVD page failed! DLBcnCount:%u, poll:%u\n", __func__, DLBcnCount, poll);
655 DBG_88E("%s: 1 Download RSVD success! DLBcnCount:%u, poll:%u\n", __func__, DLBcnCount, poll);
657 /* We just can send the reserved page twice during the time that Tx thread is stopped (e.g. pnpsetpower) */
658 /* because we need to free the Tx BCN Desc which is used by the first reserved page packet. */
659 /* At run time, we cannot get the Tx Desc until it is released in TxHandleInterrupt() so we will return */
660 /* the beacon TCB in the following code. 2011.11.23. by tynli. */
664 usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL)|BIT(3));
665 usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL)&(~BIT(4)));
667 /* To make sure that if there exists an adapter which would like to send beacon. */
668 /* If exists, the origianl value of 0x422[6] will be 1, we should check this to */
669 /* prevent from setting 0x422[6] to 0 after download reserved page, or it will cause */
670 /* the beacon cannot be sent by HW. */
671 /* 2010.06.23. Added by tynli. */
673 usb_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl|BIT6));
674 haldata->RegFwHwTxQCtrl |= BIT6;
677 /* Update RSVD page location H2C to Fw. */
679 rtw_hal_set_hwreg(adapt, HW_VAR_BCN_VALID, NULL);
680 DBG_88E("Set RSVD page location to Fw.\n");
683 /* Do not enable HW DMA BCN or it will cause Pcie interface hang by timing issue. 2011.11.24. by tynli. */
684 /* Clear CR[8] or beacon packet will not be send to TxBuf anymore. */
685 haldata->RegCR_1 &= (~BIT0);
686 usb_write8(adapt, REG_CR+1, haldata->RegCR_1);