Path: blob/master/ALFA-W1F1/RTL8814AU/hal/rtl8814a/usb/usb_ops_linux.c
1308 views
/******************************************************************************1*2* Copyright(c) 2007 - 2017 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13*****************************************************************************/14#define _HCI_OPS_OS_C_1516/* #include <drv_types.h> */17#include <rtl8814a_hal.h>1819#ifdef CONFIG_SUPPORT_USB_INT20void interrupt_handler_8814au(_adapter *padapter, u16 pkt_len, u8 *pbuf)21{22HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);23struct reportpwrstate_parm pwr_rpt;2425if (pkt_len != INTERRUPT_MSG_FORMAT_LEN) {26RTW_INFO("%s Invalid interrupt content length (%d)!\n", __FUNCTION__, pkt_len);27return ;28}2930/* HISR */31_rtw_memcpy(&(pHalData->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4);32_rtw_memcpy(&(pHalData->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4);3334#if 0 /* DBG */35{36u32 hisr = 0 , hisr_ex = 0;37_rtw_memcpy(&hisr, &(pHalData->IntArray[0]), 4);38hisr = le32_to_cpu(hisr);3940_rtw_memcpy(&hisr_ex, &(pHalData->IntArray[1]), 4);41hisr_ex = le32_to_cpu(hisr_ex);4243if ((hisr != 0) || (hisr_ex != 0))44RTW_INFO("===> %s hisr:0x%08x ,hisr_ex:0x%08x\n", __FUNCTION__, hisr, hisr_ex);45}46#endif474849#ifdef CONFIG_LPS_LCLK50if (pHalData->IntArray[0] & IMR_CPWM_88E) {51_rtw_memcpy(&pwr_rpt.state, &(pbuf[USB_INTR_CONTENT_CPWM1_OFFSET]), 1);52/* _rtw_memcpy(&pwr_rpt.state2, &(pbuf[USB_INTR_CONTENT_CPWM2_OFFSET]), 1); */5354/* 88e's cpwm value only change BIT0, so driver need to add PS_STATE_S2 for LPS flow. */55pwr_rpt.state |= PS_STATE_S2;56_set_workitem(&(adapter_to_pwrctl(padapter)->cpwm_event));57}58#endif/* CONFIG_LPS_LCLK */5960#ifdef CONFIG_INTERRUPT_BASED_TXBCN6162#ifdef CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT63if (pHalData->IntArray[0] & IMR_BCNDMAINT0_8814A)/*only for BCN_0*/64#endif65#ifdef CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR66if (pHalData->IntArray[0] & (IMR_TBDER_88E | IMR_TBDOK_88E))67#endif68{69#if 070if (pHalData->IntArray[0] & IMR_BCNDMAINT0_88E)71RTW_INFO("%s: HISR_BCNERLY_INT\n", __func__);72if (pHalData->IntArray[0] & IMR_TBDOK_88E)73RTW_INFO("%s: HISR_TXBCNOK\n", __func__);74if (pHalData->IntArray[0] & IMR_TBDER_88E)75RTW_INFO("%s: HISR_TXBCNERR\n", __func__);76#endif77rtw_mi_set_tx_beacon_cmd(padapter);78}79#endif /* CONFIG_INTERRUPT_BASED_TXBCN */8081828384#ifdef DBG_CONFIG_ERROR_DETECT_INT85if (pHalData->IntArray[1] & IMR_TXERR_88E)86RTW_INFO("===> %s Tx Error Flag Interrupt Status\n", __FUNCTION__);87if (pHalData->IntArray[1] & IMR_RXERR_88E)88RTW_INFO("===> %s Rx Error Flag INT Status\n", __FUNCTION__);89if (pHalData->IntArray[1] & IMR_TXFOVW_88E)90RTW_INFO("===> %s Transmit FIFO Overflow\n", __FUNCTION__);91if (pHalData->IntArray[1] & IMR_RXFOVW_88E)92RTW_INFO("===> %s Receive FIFO Overflow\n", __FUNCTION__);93#endif/* DBG_CONFIG_ERROR_DETECT_INT */9495#ifdef CONFIG_FW_C2H_REG96/* C2H Event */97if (pbuf[0] != 0)98usb_c2h_hisr_hdl(padapter, pbuf);99#endif100}101#endif /* CONFIG_SUPPORT_USB_INT */102103104int recvbuf2recvframe(PADAPTER padapter, void *ptr)105{106u8 *pbuf;107u8 pkt_cnt = 0;108u32 pkt_offset;109s32 transfer_len;110union recv_frame *precvframe = NULL;111struct rx_pkt_attrib *pattrib = NULL;112HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);113struct recv_priv *precvpriv = &padapter->recvpriv;114_queue *pfree_recv_queue = &precvpriv->free_recv_queue;115_pkt *pskb;116117#ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX118pskb = NULL;119transfer_len = (s32)((struct recv_buf *)ptr)->transfer_len;120pbuf = ((struct recv_buf *)ptr)->pbuf;121#else122pskb = (_pkt *)ptr;123transfer_len = (s32)pskb->len;124pbuf = pskb->data;125#endif/* CONFIG_USE_USB_BUFFER_ALLOC_RX */126127128#ifdef CONFIG_USB_RX_AGGREGATION129pkt_cnt = GET_RX_STATUS_DESC_DMA_AGG_NUM_8814A(pbuf);130#endif131132do {133precvframe = rtw_alloc_recvframe(pfree_recv_queue);134if (precvframe == NULL) {135RTW_INFO("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __FUNCTION__, __LINE__);136goto _exit_recvbuf2recvframe;137}138139_rtw_init_listhead(&precvframe->u.hdr.list);140precvframe->u.hdr.precvbuf = NULL; /* can't access the precvbuf for new arch. */141precvframe->u.hdr.len = 0;142143rtl8814_query_rx_desc_status(precvframe, pbuf);144145pattrib = &precvframe->u.hdr.attrib;146147if ((padapter->registrypriv.mp_mode == 0) && ((pattrib->crc_err) || (pattrib->icv_err))) {148RTW_INFO("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __FUNCTION__, pattrib->crc_err, pattrib->icv_err);149150rtw_free_recvframe(precvframe, pfree_recv_queue);151goto _exit_recvbuf2recvframe;152}153154pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len;155156if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) {157RTW_INFO("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfer_len\n", __FUNCTION__, __LINE__);158rtw_free_recvframe(precvframe, pfree_recv_queue);159goto _exit_recvbuf2recvframe;160}161162#ifdef CONFIG_RX_PACKET_APPEND_FCS163if (check_fwstate(&padapter->mlmepriv, WIFI_MONITOR_STATE) == _FALSE)164if ((pattrib->pkt_rpt_type == NORMAL_RX) && rtw_hal_rcr_check(padapter, RCR_APPFCS))165pattrib->pkt_len -= IEEE80211_FCS_LEN;166#endif167if (rtw_os_alloc_recvframe(padapter, precvframe,168(pbuf + pattrib->shift_sz + pattrib->drvinfo_sz + RXDESC_SIZE), pskb) == _FAIL) {169rtw_free_recvframe(precvframe, pfree_recv_queue);170171goto _exit_recvbuf2recvframe;172}173174recvframe_put(precvframe, pattrib->pkt_len);175/* recvframe_pull(precvframe, drvinfo_sz + RXDESC_SIZE); */176177if (pattrib->pkt_rpt_type == NORMAL_RX) /* Normal rx packet */178pre_recv_entry(precvframe, pattrib->physt ? (pbuf + RXDESC_OFFSET) : NULL);179else { /* pkt_rpt_type == TX_REPORT1-CCX, TX_REPORT2-TX RTP,HIS_REPORT-USB HISR RTP */180if (pattrib->pkt_rpt_type == C2H_PACKET) {181/* RTW_INFO("rx C2H_PACKET\n"); */182rtw_hal_c2h_pkt_pre_hdl(padapter, precvframe->u.hdr.rx_data, pattrib->pkt_len);183}184rtw_free_recvframe(precvframe, pfree_recv_queue);185}186187#ifdef CONFIG_USB_RX_AGGREGATION188/* jaguar 8-byte alignment */189pkt_offset = (u16)_RND8(pkt_offset);190pkt_cnt--;191pbuf += pkt_offset;192#endif193transfer_len -= pkt_offset;194precvframe = NULL;195196} while (transfer_len > 0);197198_exit_recvbuf2recvframe:199200return _SUCCESS;201}202203204void rtl8814au_xmit_tasklet(void *priv)205{206int ret = _FALSE;207_adapter *padapter = (_adapter *)priv;208struct xmit_priv *pxmitpriv = &padapter->xmitpriv;209210while (1) {211if (RTW_CANNOT_TX(padapter)) {212RTW_INFO("xmit_tasklet => bDriverStopped or bSurpriseRemoved or bWritePortCancel\n");213break;214}215216if (rtw_xmit_ac_blocked(padapter) == _TRUE)217break;218219ret = rtl8814au_xmitframe_complete(padapter, pxmitpriv, NULL);220221if (ret == _FALSE)222break;223224}225226}227228void rtl8814au_set_hw_type(struct dvobj_priv *pdvobj)229{230pdvobj->HardwareType = HARDWARE_TYPE_RTL8814AU;231RTW_INFO("CHIP TYPE: RTL8814\n");232}233234235