Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/ALFA-W1F1/RTL8814AU/hal/rtl8814a/usb/usb_ops_linux.c
1308 views
1
/******************************************************************************
2
*
3
* Copyright(c) 2007 - 2017 Realtek Corporation.
4
*
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.
8
*
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
12
* more details.
13
*
14
*****************************************************************************/
15
#define _HCI_OPS_OS_C_
16
17
/* #include <drv_types.h> */
18
#include <rtl8814a_hal.h>
19
20
#ifdef CONFIG_SUPPORT_USB_INT
21
void interrupt_handler_8814au(_adapter *padapter, u16 pkt_len, u8 *pbuf)
22
{
23
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
24
struct reportpwrstate_parm pwr_rpt;
25
26
if (pkt_len != INTERRUPT_MSG_FORMAT_LEN) {
27
RTW_INFO("%s Invalid interrupt content length (%d)!\n", __FUNCTION__, pkt_len);
28
return ;
29
}
30
31
/* HISR */
32
_rtw_memcpy(&(pHalData->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4);
33
_rtw_memcpy(&(pHalData->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4);
34
35
#if 0 /* DBG */
36
{
37
u32 hisr = 0 , hisr_ex = 0;
38
_rtw_memcpy(&hisr, &(pHalData->IntArray[0]), 4);
39
hisr = le32_to_cpu(hisr);
40
41
_rtw_memcpy(&hisr_ex, &(pHalData->IntArray[1]), 4);
42
hisr_ex = le32_to_cpu(hisr_ex);
43
44
if ((hisr != 0) || (hisr_ex != 0))
45
RTW_INFO("===> %s hisr:0x%08x ,hisr_ex:0x%08x\n", __FUNCTION__, hisr, hisr_ex);
46
}
47
#endif
48
49
50
#ifdef CONFIG_LPS_LCLK
51
if (pHalData->IntArray[0] & IMR_CPWM_88E) {
52
_rtw_memcpy(&pwr_rpt.state, &(pbuf[USB_INTR_CONTENT_CPWM1_OFFSET]), 1);
53
/* _rtw_memcpy(&pwr_rpt.state2, &(pbuf[USB_INTR_CONTENT_CPWM2_OFFSET]), 1); */
54
55
/* 88e's cpwm value only change BIT0, so driver need to add PS_STATE_S2 for LPS flow. */
56
pwr_rpt.state |= PS_STATE_S2;
57
_set_workitem(&(adapter_to_pwrctl(padapter)->cpwm_event));
58
}
59
#endif/* CONFIG_LPS_LCLK */
60
61
#ifdef CONFIG_INTERRUPT_BASED_TXBCN
62
63
#ifdef CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT
64
if (pHalData->IntArray[0] & IMR_BCNDMAINT0_8814A)/*only for BCN_0*/
65
#endif
66
#ifdef CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR
67
if (pHalData->IntArray[0] & (IMR_TBDER_88E | IMR_TBDOK_88E))
68
#endif
69
{
70
#if 0
71
if (pHalData->IntArray[0] & IMR_BCNDMAINT0_88E)
72
RTW_INFO("%s: HISR_BCNERLY_INT\n", __func__);
73
if (pHalData->IntArray[0] & IMR_TBDOK_88E)
74
RTW_INFO("%s: HISR_TXBCNOK\n", __func__);
75
if (pHalData->IntArray[0] & IMR_TBDER_88E)
76
RTW_INFO("%s: HISR_TXBCNERR\n", __func__);
77
#endif
78
rtw_mi_set_tx_beacon_cmd(padapter);
79
}
80
#endif /* CONFIG_INTERRUPT_BASED_TXBCN */
81
82
83
84
85
#ifdef DBG_CONFIG_ERROR_DETECT_INT
86
if (pHalData->IntArray[1] & IMR_TXERR_88E)
87
RTW_INFO("===> %s Tx Error Flag Interrupt Status\n", __FUNCTION__);
88
if (pHalData->IntArray[1] & IMR_RXERR_88E)
89
RTW_INFO("===> %s Rx Error Flag INT Status\n", __FUNCTION__);
90
if (pHalData->IntArray[1] & IMR_TXFOVW_88E)
91
RTW_INFO("===> %s Transmit FIFO Overflow\n", __FUNCTION__);
92
if (pHalData->IntArray[1] & IMR_RXFOVW_88E)
93
RTW_INFO("===> %s Receive FIFO Overflow\n", __FUNCTION__);
94
#endif/* DBG_CONFIG_ERROR_DETECT_INT */
95
96
#ifdef CONFIG_FW_C2H_REG
97
/* C2H Event */
98
if (pbuf[0] != 0)
99
usb_c2h_hisr_hdl(padapter, pbuf);
100
#endif
101
}
102
#endif /* CONFIG_SUPPORT_USB_INT */
103
104
105
int recvbuf2recvframe(PADAPTER padapter, void *ptr)
106
{
107
u8 *pbuf;
108
u8 pkt_cnt = 0;
109
u32 pkt_offset;
110
s32 transfer_len;
111
union recv_frame *precvframe = NULL;
112
struct rx_pkt_attrib *pattrib = NULL;
113
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
114
struct recv_priv *precvpriv = &padapter->recvpriv;
115
_queue *pfree_recv_queue = &precvpriv->free_recv_queue;
116
_pkt *pskb;
117
118
#ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX
119
pskb = NULL;
120
transfer_len = (s32)((struct recv_buf *)ptr)->transfer_len;
121
pbuf = ((struct recv_buf *)ptr)->pbuf;
122
#else
123
pskb = (_pkt *)ptr;
124
transfer_len = (s32)pskb->len;
125
pbuf = pskb->data;
126
#endif/* CONFIG_USE_USB_BUFFER_ALLOC_RX */
127
128
129
#ifdef CONFIG_USB_RX_AGGREGATION
130
pkt_cnt = GET_RX_STATUS_DESC_DMA_AGG_NUM_8814A(pbuf);
131
#endif
132
133
do {
134
precvframe = rtw_alloc_recvframe(pfree_recv_queue);
135
if (precvframe == NULL) {
136
RTW_INFO("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __FUNCTION__, __LINE__);
137
goto _exit_recvbuf2recvframe;
138
}
139
140
_rtw_init_listhead(&precvframe->u.hdr.list);
141
precvframe->u.hdr.precvbuf = NULL; /* can't access the precvbuf for new arch. */
142
precvframe->u.hdr.len = 0;
143
144
rtl8814_query_rx_desc_status(precvframe, pbuf);
145
146
pattrib = &precvframe->u.hdr.attrib;
147
148
if ((padapter->registrypriv.mp_mode == 0) && ((pattrib->crc_err) || (pattrib->icv_err))) {
149
RTW_INFO("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __FUNCTION__, pattrib->crc_err, pattrib->icv_err);
150
151
rtw_free_recvframe(precvframe, pfree_recv_queue);
152
goto _exit_recvbuf2recvframe;
153
}
154
155
pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len;
156
157
if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) {
158
RTW_INFO("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfer_len\n", __FUNCTION__, __LINE__);
159
rtw_free_recvframe(precvframe, pfree_recv_queue);
160
goto _exit_recvbuf2recvframe;
161
}
162
163
#ifdef CONFIG_RX_PACKET_APPEND_FCS
164
if (check_fwstate(&padapter->mlmepriv, WIFI_MONITOR_STATE) == _FALSE)
165
if ((pattrib->pkt_rpt_type == NORMAL_RX) && rtw_hal_rcr_check(padapter, RCR_APPFCS))
166
pattrib->pkt_len -= IEEE80211_FCS_LEN;
167
#endif
168
if (rtw_os_alloc_recvframe(padapter, precvframe,
169
(pbuf + pattrib->shift_sz + pattrib->drvinfo_sz + RXDESC_SIZE), pskb) == _FAIL) {
170
rtw_free_recvframe(precvframe, pfree_recv_queue);
171
172
goto _exit_recvbuf2recvframe;
173
}
174
175
recvframe_put(precvframe, pattrib->pkt_len);
176
/* recvframe_pull(precvframe, drvinfo_sz + RXDESC_SIZE); */
177
178
if (pattrib->pkt_rpt_type == NORMAL_RX) /* Normal rx packet */
179
pre_recv_entry(precvframe, pattrib->physt ? (pbuf + RXDESC_OFFSET) : NULL);
180
else { /* pkt_rpt_type == TX_REPORT1-CCX, TX_REPORT2-TX RTP,HIS_REPORT-USB HISR RTP */
181
if (pattrib->pkt_rpt_type == C2H_PACKET) {
182
/* RTW_INFO("rx C2H_PACKET\n"); */
183
rtw_hal_c2h_pkt_pre_hdl(padapter, precvframe->u.hdr.rx_data, pattrib->pkt_len);
184
}
185
rtw_free_recvframe(precvframe, pfree_recv_queue);
186
}
187
188
#ifdef CONFIG_USB_RX_AGGREGATION
189
/* jaguar 8-byte alignment */
190
pkt_offset = (u16)_RND8(pkt_offset);
191
pkt_cnt--;
192
pbuf += pkt_offset;
193
#endif
194
transfer_len -= pkt_offset;
195
precvframe = NULL;
196
197
} while (transfer_len > 0);
198
199
_exit_recvbuf2recvframe:
200
201
return _SUCCESS;
202
}
203
204
205
void rtl8814au_xmit_tasklet(void *priv)
206
{
207
int ret = _FALSE;
208
_adapter *padapter = (_adapter *)priv;
209
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
210
211
while (1) {
212
if (RTW_CANNOT_TX(padapter)) {
213
RTW_INFO("xmit_tasklet => bDriverStopped or bSurpriseRemoved or bWritePortCancel\n");
214
break;
215
}
216
217
if (rtw_xmit_ac_blocked(padapter) == _TRUE)
218
break;
219
220
ret = rtl8814au_xmitframe_complete(padapter, pxmitpriv, NULL);
221
222
if (ret == _FALSE)
223
break;
224
225
}
226
227
}
228
229
void rtl8814au_set_hw_type(struct dvobj_priv *pdvobj)
230
{
231
pdvobj->HardwareType = HARDWARE_TYPE_RTL8814AU;
232
RTW_INFO("CHIP TYPE: RTL8814\n");
233
}
234
235