thread_return rtl8723bs_xmit_thread(thread_context context)
{
    s32 ret;
    PADAPTER padapter;
    struct xmit_priv *pxmitpriv;
    u8 thread_name[20] = "RTWHALXT";


    ret = _SUCCESS;
    padapter = (PADAPTER)context;
    pxmitpriv = &padapter->xmitpriv;

    rtw_sprintf(thread_name, 20, "%s-"ADPT_FMT, thread_name, ADPT_ARG(padapter));
    thread_enter(thread_name);

    DBG_871X("start "FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));

    // For now, no one would down sema to check thread is running,
    // so mark this temporary, Lucas@20130820
//	_rtw_up_sema(&pxmitpriv->SdioXmitTerminateSema);

    do {
        ret = rtl8723bs_xmit_handler(padapter);
        if (signal_pending(current)) {
            flush_signals(current);
        }
    } while (_SUCCESS == ret);

    _rtw_up_sema(&pxmitpriv->SdioXmitTerminateSema);

    RT_TRACE(_module_hal_xmit_c_, _drv_notice_, ("-%s\n", __FUNCTION__));

    thread_exit();
}
static u8 _rtw_mi_hal_dump_macaddr(_adapter *padapter, void *data)
{
    u8 mac_addr[ETH_ALEN] = {0};

    rtw_hal_get_macaddr_port(padapter, mac_addr);
    RTW_INFO(ADPT_FMT"MAC Address ="MAC_FMT"\n", ADPT_ARG(padapter), MAC_ARG(mac_addr));
    return _TRUE;
}
static u8 _rtw_mi_beacon_update(_adapter *padapter, void *data)
{
    struct mlme_ext_priv *mlmeext = &padapter->mlmeextpriv;

    if (mlmeext_msr(mlmeext) == WIFI_FW_AP_STATE
            && check_fwstate(&padapter->mlmepriv, _FW_LINKED) == _TRUE) {
        RTW_INFO(ADPT_FMT"-WIFI_FW_AP_STATE - update_beacon\n", ADPT_ARG(padapter));
        update_beacon(padapter, 0, NULL, _TRUE);
    }
    return _TRUE;
}
u8 rtw_mi_buddy_under_survey(_adapter *padapter)
{
    int i;
    u8 ret = 0;
    _adapter *iface = NULL;
    _irqL	irqL;
    struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);

#ifdef CONFIG_IOCTL_CFG80211
    struct rtw_wdev_priv *pwdev_priv = adapter_wdev_data(padapter);
#endif

    struct mlme_priv *pmlmepriv = &padapter->mlmepriv;

    struct mlme_priv *buddy_mlmepriv;
    struct rtw_wdev_priv *buddy_wdev_priv;

    for (i = 0; i < dvobj->iface_nums; i++) {
        iface = dvobj->padapters[i];
        if ((iface) && rtw_is_adapter_up(iface)) {

            if (iface == padapter)
                continue;

            buddy_mlmepriv = &iface->mlmepriv;
            if (check_fwstate(buddy_mlmepriv, _FW_UNDER_SURVEY)) {
                ret = UNDER_SURVEY_T1;

#ifdef CONFIG_IOCTL_CFG80211
                buddy_wdev_priv = adapter_wdev_data(iface);
                _enter_critical_bh(&pwdev_priv->scan_req_lock, &irqL);
                _enter_critical_bh(&buddy_wdev_priv->scan_req_lock, &irqL);
                if (buddy_wdev_priv->scan_request) {
                    pmlmepriv->scanning_via_buddy_intf = _TRUE;
                    _enter_critical_bh(&pmlmepriv->lock, &irqL);
                    set_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
                    _exit_critical_bh(&pmlmepriv->lock, &irqL);
                    ret = UNDER_SURVEY_T2;
                }
                _exit_critical_bh(&buddy_wdev_priv->scan_req_lock, &irqL);
                _exit_critical_bh(&pwdev_priv->scan_req_lock, &irqL);
#endif

                RTW_INFO(ADPT_FMT"_FW_UNDER_SURVEY\n", ADPT_ARG(iface));
                return ret;
            }
        }
    }
    return ret;
}
u8 _rtw_mi_busy_traffic_check(_adapter *padapter, void *data)
{
    u32 passtime;
    struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
    bool check_sc_interval = *(bool *)data;

    if (pmlmepriv->LinkDetectInfo.bBusyTraffic == _TRUE) {
        if (check_sc_interval) {
            /* Miracast can't do AP scan*/
            passtime = rtw_get_passing_time_ms(pmlmepriv->lastscantime);
            pmlmepriv->lastscantime = rtw_get_current_time();
            if (passtime > BUSY_TRAFFIC_SCAN_DENY_PERIOD) {
                RTW_INFO(ADPT_FMT" bBusyTraffic == _TRUE\n", ADPT_ARG(padapter));
                return _TRUE;
            }
        } else
            return _TRUE;
    }

    return _FALSE;
}
u8 rtw_mi_mp_mode_check(_adapter *padapter)
{
#ifdef CONFIG_CONCURRENT_MODE
    int i;
    struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
    _adapter *iface = NULL;

    for (i = 0; i < dvobj->iface_nums; i++) {
        iface = dvobj->padapters[i];

        if ((iface) && (iface->registrypriv.mp_mode == 1)) {
            RTW_INFO(ADPT_FMT "-MP mode enable\n", ADPT_ARG(iface));
            return _TRUE;
        }
    }
#else
    if (padapter->registrypriv.mp_mode == 1)
        return _TRUE;
#endif
    return _FALSE;
}
Beispiel #7
0
static void shutdown_card(void)
{
	u32 addr;
	u8 tmp8, cnt=0;

	if (NULL == g_test_adapter)
	{
		DBG_871X("%s: padapter==NULL\n", __FUNCTION__);
		return;
	}

#ifdef CONFIG_FWLPS_IN_IPS
	LeaveAllPowerSaveMode(g_test_adapter);
#endif // CONFIG_FWLPS_IN_IPS

	// Leave SDIO HCI Suspend
	addr = 0x10250086;
	rtw_write8(g_test_adapter, addr, 0);
	do {
		tmp8 = rtw_read8(g_test_adapter, addr);
		cnt++;
		DBG_871X(FUNC_ADPT_FMT ": polling SDIO_HSUS_CTRL(0x%x)=0x%x, cnt=%d\n",
			FUNC_ADPT_ARG(g_test_adapter), addr, tmp8, cnt);

		if (tmp8 & BIT(1))
			break;

		if (cnt >= 100)
		{
			DBG_871X(FUNC_ADPT_FMT ": polling 0x%x[1]==1 FAIL!!\n",
				FUNC_ADPT_ARG(g_test_adapter), addr);
			break;
		}

		rtw_mdelay_os(10);
	} while (1);

	// unlock register I/O
	rtw_write8(g_test_adapter, 0x1C, 0);

	// enable power down function
	// 0x04[4] = 1
	// 0x05[7] = 1
	addr = 0x04;
	tmp8 = rtw_read8(g_test_adapter, addr);
	tmp8 |= BIT(4);
	rtw_write8(g_test_adapter, addr, tmp8);
	DBG_871X(FUNC_ADPT_FMT ": read after write 0x%x=0x%x\n",
		FUNC_ADPT_ARG(g_test_adapter), addr, rtw_read8(g_test_adapter, addr));

	addr = 0x05;
	tmp8 = rtw_read8(g_test_adapter, addr);
	tmp8 |= BIT(7);
	rtw_write8(g_test_adapter, addr, tmp8);
	DBG_871X(FUNC_ADPT_FMT ": read after write 0x%x=0x%x\n",
		FUNC_ADPT_ARG(g_test_adapter), addr, rtw_read8(g_test_adapter, addr));

	// lock register page0 0x0~0xB read/write
	rtw_write8(g_test_adapter, 0x1C, 0x0E);

	g_test_adapter->bSurpriseRemoved = _TRUE;
	DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved=%d\n",
		FUNC_ADPT_ARG(g_test_adapter), g_test_adapter->bSurpriseRemoved);
#ifdef CONFIG_CONCURRENT_MODE
	if (g_test_adapter->pbuddy_adapter)
	{
		PADAPTER pbuddy;
		pbuddy = g_test_adapter->pbuddy_adapter;
		pbuddy->bSurpriseRemoved = _TRUE;
		DBG_871X(FUNC_ADPT_FMT ": buddy(" ADPT_FMT ") bSurpriseRemoved=%d\n",
			FUNC_ADPT_ARG(g_test_adapter), ADPT_ARG(pbuddy), pbuddy->bSurpriseRemoved);
	}
#endif // CONFIG_CONCURRENT_MODE
}
u8 rtw_mi_check_status(_adapter *adapter, u8 type)
{
    struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
    struct mi_state *iface_state = &dvobj->iface_state;
    u8 ret = _FALSE;

#ifdef DBG_IFACE_STATUS
    DBG_IFACE_STATUS_DUMP(adapter);
    RTW_INFO("%s-"ADPT_FMT" check type:%d\n", __func__, ADPT_ARG(adapter), type);
#endif

    switch (type) {
    case MI_LINKED:
        if (iface_state->ld_sta_num || iface_state->ap_num || iface_state->adhoc_num) /*check_fwstate(&iface->mlmepriv, _FW_LINKED)*/
            ret = _TRUE;
        break;
    case MI_ASSOC:
        if (iface_state->ld_sta_num || iface_state->ld_ap_num || iface_state->ld_adhoc_num)
            ret = _TRUE;
        break;
    case MI_UNDER_WPS:
        if (iface_state->uwps_num)
            ret = _TRUE;
        break;

    case MI_AP_MODE:
        if (iface_state->ap_num)
            ret = _TRUE;
        break;
    case MI_AP_ASSOC:
        if (iface_state->ld_ap_num)
            ret = _TRUE;
        break;

    case MI_ADHOC:
        if (iface_state->adhoc_num)
            ret = _TRUE;
        break;
    case MI_ADHOC_ASSOC:
        if (iface_state->ld_adhoc_num)
            ret = _TRUE;
        break;

    case MI_STA_NOLINK: /* this is misleading, but not used now */
        if (iface_state->sta_num && (!(iface_state->ld_sta_num || iface_state->lg_sta_num)))
            ret = _TRUE;
        break;
    case MI_STA_LINKED:
        if (iface_state->ld_sta_num)
            ret = _TRUE;
        break;
    case MI_STA_LINKING:
        if (iface_state->lg_sta_num)
            ret = _TRUE;
        break;

    default:
        break;
    }
    return ret;
}
void rtl8188e_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus)
{
	JOINBSSRPT_PARM_88E	JoinBssRptParm;
	HAL_DATA_TYPE	*pHalData = GET_HAL_DATA(padapter);
	struct mlme_ext_priv	*pmlmeext = &(padapter->mlmeextpriv);
	struct mlme_ext_info	*pmlmeinfo = &(pmlmeext->mlmext_info);
#ifdef CONFIG_WOWLAN
	struct mlme_priv	*pmlmepriv = &padapter->mlmepriv;
	struct sta_info *psta = NULL;
#endif
	BOOLEAN		bSendBeacon=_FALSE;
	BOOLEAN		bcn_valid = _FALSE;
	u8	DLBcnCount=0;
	u32 poll = 0;

_func_enter_;

	DBG_871X("%s mstatus(%x)\n", __FUNCTION__,mstatus);

	if(mstatus == 1)
	{
		// We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C.
		// Suggested by filen. Added by tynli.
		rtw_write16(padapter, REG_BCN_PSR_RPT, (0xC000|pmlmeinfo->aid));
		// Do not set TSF again here or vWiFi beacon DMA INT will not work.
		//correct_TSF(padapter, pmlmeext);
		// Hw sequende enable by dedault. 2010.06.23. by tynli.
		//rtw_write16(padapter, REG_NQOS_SEQ, ((pmlmeext->mgnt_seq+100)&0xFFF));
		//rtw_write8(padapter, REG_HWSEQ_CTRL, 0xFF);

		//Set REG_CR bit 8. DMA beacon by SW.
		pHalData->RegCR_1 |= BIT0;
		rtw_write8(padapter,  REG_CR+1, pHalData->RegCR_1);

		// Disable Hw protection for a time which revserd for Hw sending beacon.
		// Fix download reserved page packet fail that access collision with the protection time.
		// 2010.05.11. Added by tynli.
		//SetBcnCtrlReg(padapter, 0, BIT3);
		//SetBcnCtrlReg(padapter, BIT4, 0);
		rtw_write8(padapter, REG_BCN_CTRL, rtw_read8(padapter, REG_BCN_CTRL)&(~BIT(3)));
		rtw_write8(padapter, REG_BCN_CTRL, rtw_read8(padapter, REG_BCN_CTRL)|BIT(4));

		if(pHalData->RegFwHwTxQCtrl&BIT6)
		{
			DBG_871X("HalDownloadRSVDPage(): There is an Adapter is sending beacon.\n");
			bSendBeacon = _TRUE;
		}

		// Set FWHW_TXQ_CTRL 0x422[6]=0 to tell Hw the packet is not a real beacon frame.
		rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, (pHalData->RegFwHwTxQCtrl&(~BIT6)));
		pHalData->RegFwHwTxQCtrl &= (~BIT6);

		// Clear beacon valid check bit.
		rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL);
		DLBcnCount = 0;
		poll = 0;
		do
		{
			// download rsvd page.
			SetFwRsvdPagePkt(padapter, _FALSE);
			DLBcnCount++;
			do
			{
				rtw_yield_os();
				//rtw_mdelay_os(10);
				// check rsvd page download OK.
				rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8*)(&bcn_valid));
				poll++;
			} while(!bcn_valid && (poll%10)!=0 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped);

		}while(!bcn_valid && DLBcnCount<=100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped);

		//RT_ASSERT(bcn_valid, ("HalDownloadRSVDPage88ES(): 1 Download RSVD page failed!\n"));
		if(padapter->bSurpriseRemoved || padapter->bDriverStopped)
		{
		}
		else if(!bcn_valid)
			DBG_871X(ADPT_FMT": 1 DL RSVD page failed! DLBcnCount:%u, poll:%u\n",
				ADPT_ARG(padapter) ,DLBcnCount, poll);
		else {
			struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
			pwrctl->fw_psmode_iface_id = padapter->iface_id;
			DBG_871X(ADPT_FMT": 1 DL RSVD page success! DLBcnCount:%u, poll:%u\n",
				ADPT_ARG(padapter), DLBcnCount, poll);
		}
		//
		// We just can send the reserved page twice during the time that Tx thread is stopped (e.g. pnpsetpower)
		// becuase we need to free the Tx BCN Desc which is used by the first reserved page packet.
		// At run time, we cannot get the Tx Desc until it is released in TxHandleInterrupt() so we will return
		// the beacon TCB in the following code. 2011.11.23. by tynli.
		//
		//if(bcn_valid && padapter->bEnterPnpSleep)
		if(0)
		{
			if(bSendBeacon)
			{
				rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL);
				DLBcnCount = 0;
				poll = 0;
				do
				{
					SetFwRsvdPagePkt(padapter, _TRUE);
					DLBcnCount++;

					do
					{
						rtw_yield_os();
						//rtw_mdelay_os(10);
						// check rsvd page download OK.
						rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8*)(&bcn_valid));
						poll++;
					} while(!bcn_valid && (poll%10)!=0 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped);
				}while(!bcn_valid && DLBcnCount<=100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped);

				//RT_ASSERT(bcn_valid, ("HalDownloadRSVDPage(): 2 Download RSVD page failed!\n"));
				if(padapter->bSurpriseRemoved || padapter->bDriverStopped)
				{
				}
				else if(!bcn_valid)
					DBG_871X("%s: 2 Download RSVD page failed! DLBcnCount:%u, poll:%u\n", __FUNCTION__ ,DLBcnCount, poll);
				else
					DBG_871X("%s: 2 Download RSVD success! DLBcnCount:%u, poll:%u\n", __FUNCTION__, DLBcnCount, poll);
			}
		}

		// Enable Bcn
		//SetBcnCtrlReg(padapter, BIT3, 0);
		//SetBcnCtrlReg(padapter, 0, BIT4);
		rtw_write8(padapter, REG_BCN_CTRL, rtw_read8(padapter, REG_BCN_CTRL)|BIT(3));
		rtw_write8(padapter, REG_BCN_CTRL, rtw_read8(padapter, REG_BCN_CTRL)&(~BIT(4)));

		// To make sure that if there exists an adapter which would like to send beacon.
		// If exists, the origianl value of 0x422[6] will be 1, we should check this to
		// prevent from setting 0x422[6] to 0 after download reserved page, or it will cause
		// the beacon cannot be sent by HW.
		// 2010.06.23. Added by tynli.
		if(bSendBeacon)
		{
			rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, (pHalData->RegFwHwTxQCtrl|BIT6));
			pHalData->RegFwHwTxQCtrl |= BIT6;
		}

		//
		// Update RSVD page location H2C to Fw.
		//
		if(bcn_valid)
		{
			rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL);
			DBG_871X("Set RSVD page location to Fw.\n");
			//FillH2CCmd88E(Adapter, H2C_88E_RSVDPAGE, H2C_RSVDPAGE_LOC_LENGTH, pMgntInfo->u1RsvdPageLoc);
		}

		// Do not enable HW DMA BCN or it will cause Pcie interface hang by timing issue. 2011.11.24. by tynli.
		//if(!padapter->bEnterPnpSleep)
		{
			// Clear CR[8] or beacon packet will not be send to TxBuf anymore.
			pHalData->RegCR_1 &= (~BIT0);
			rtw_write8(padapter,  REG_CR+1, pHalData->RegCR_1);
		}
	}
#ifdef CONFIG_WOWLAN
	if (adapter_to_pwrctl(padapter)->wowlan_mode){
		JoinBssRptParm.OpMode = mstatus;
		psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(pmlmepriv));
		if (psta != NULL) {
			JoinBssRptParm.MacID = psta->mac_id;
		} else {
			JoinBssRptParm.MacID = 0;
		}
		FillH2CCmd_88E(padapter, H2C_COM_MEDIA_STATUS_RPT, sizeof(JoinBssRptParm), (u8 *)&JoinBssRptParm);
		DBG_871X_LEVEL(_drv_info_, "%s opmode:%d MacId:%d\n", __func__, JoinBssRptParm.OpMode, JoinBssRptParm.MacID);
	} else {
		DBG_871X_LEVEL(_drv_info_, "%s wowlan_mode is off\n", __func__);
	}
#endif //CONFIG_WOWLAN
_func_exit_;
}