Skip to content

Commit fc324b6

Browse files
lwfingergregkh
authored andcommitted
staging: r8188eu: Add files for new driver - part 15
This commit adds files hal/rtl8188e_rxdesc.c, hal/rtl8188e_sreset.c, and hal/rtl8188e_xmit.c. Signed-off-by: Larry Finger <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 615a4d1 commit fc324b6

File tree

3 files changed

+373
-0
lines changed

3 files changed

+373
-0
lines changed
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
/******************************************************************************
2+
*
3+
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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+
* 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
17+
*
18+
*
19+
******************************************************************************/
20+
#define _RTL8188E_REDESC_C_
21+
22+
#include <osdep_service.h>
23+
#include <drv_types.h>
24+
#include <rtl8188e_hal.h>
25+
26+
static void process_rssi(struct adapter *padapter, union recv_frame *prframe)
27+
{
28+
struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
29+
struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data;
30+
31+
if (signal_stat->update_req) {
32+
signal_stat->total_num = 0;
33+
signal_stat->total_val = 0;
34+
signal_stat->update_req = 0;
35+
}
36+
37+
signal_stat->total_num++;
38+
signal_stat->total_val += pattrib->phy_info.SignalStrength;
39+
signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num;
40+
} /* Process_UI_RSSI_8192C */
41+
42+
static void process_link_qual(struct adapter *padapter, union recv_frame *prframe)
43+
{
44+
struct rx_pkt_attrib *pattrib;
45+
struct signal_stat *signal_stat;
46+
47+
if (prframe == NULL || padapter == NULL)
48+
return;
49+
50+
pattrib = &prframe->u.hdr.attrib;
51+
signal_stat = &padapter->recvpriv.signal_qual_data;
52+
53+
if (signal_stat->update_req) {
54+
signal_stat->total_num = 0;
55+
signal_stat->total_val = 0;
56+
signal_stat->update_req = 0;
57+
}
58+
59+
signal_stat->total_num++;
60+
signal_stat->total_val += pattrib->phy_info.SignalQuality;
61+
signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num;
62+
}
63+
64+
void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe)
65+
{
66+
union recv_frame *precvframe = (union recv_frame *)prframe;
67+
68+
/* Check RSSI */
69+
process_rssi(padapter, precvframe);
70+
/* Check EVM */
71+
process_link_qual(padapter, precvframe);
72+
}
73+
74+
void update_recvframe_attrib_88e(union recv_frame *precvframe, struct recv_stat *prxstat)
75+
{
76+
struct rx_pkt_attrib *pattrib;
77+
struct recv_stat report;
78+
79+
report.rxdw0 = prxstat->rxdw0;
80+
report.rxdw1 = prxstat->rxdw1;
81+
report.rxdw2 = prxstat->rxdw2;
82+
report.rxdw3 = prxstat->rxdw3;
83+
report.rxdw4 = prxstat->rxdw4;
84+
report.rxdw5 = prxstat->rxdw5;
85+
86+
pattrib = &precvframe->u.hdr.attrib;
87+
_rtw_memset(pattrib, 0, sizeof(struct rx_pkt_attrib));
88+
89+
pattrib->crc_err = (u8)((le32_to_cpu(report.rxdw0) >> 14) & 0x1);;/* u8)prxreport->crc32; */
90+
91+
/* update rx report to recv_frame attribute */
92+
pattrib->pkt_rpt_type = (u8)((le32_to_cpu(report.rxdw3) >> 14) & 0x3);/* prxreport->rpt_sel; */
93+
94+
if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */
95+
pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);/* u16)prxreport->pktlen; */
96+
pattrib->drvinfo_sz = (u8)((le32_to_cpu(report.rxdw0) >> 16) & 0xf) * 8;/* u8)(prxreport->drvinfosize << 3); */
97+
98+
pattrib->physt = (u8)((le32_to_cpu(report.rxdw0) >> 26) & 0x1);/* u8)prxreport->physt; */
99+
100+
pattrib->bdecrypted = (le32_to_cpu(report.rxdw0) & BIT(27)) ? 0 : 1;/* u8)(prxreport->swdec ? 0 : 1); */
101+
pattrib->encrypt = (u8)((le32_to_cpu(report.rxdw0) >> 20) & 0x7);/* u8)prxreport->security; */
102+
103+
pattrib->qos = (u8)((le32_to_cpu(report.rxdw0) >> 23) & 0x1);/* u8)prxreport->qos; */
104+
pattrib->priority = (u8)((le32_to_cpu(report.rxdw1) >> 8) & 0xf);/* u8)prxreport->tid; */
105+
106+
pattrib->amsdu = (u8)((le32_to_cpu(report.rxdw1) >> 13) & 0x1);/* u8)prxreport->amsdu; */
107+
108+
pattrib->seq_num = (u16)(le32_to_cpu(report.rxdw2) & 0x00000fff);/* u16)prxreport->seq; */
109+
pattrib->frag_num = (u8)((le32_to_cpu(report.rxdw2) >> 12) & 0xf);/* u8)prxreport->frag; */
110+
pattrib->mfrag = (u8)((le32_to_cpu(report.rxdw1) >> 27) & 0x1);/* u8)prxreport->mf; */
111+
pattrib->mdata = (u8)((le32_to_cpu(report.rxdw1) >> 26) & 0x1);/* u8)prxreport->md; */
112+
113+
pattrib->mcs_rate = (u8)(le32_to_cpu(report.rxdw3) & 0x3f);/* u8)prxreport->rxmcs; */
114+
pattrib->rxht = (u8)((le32_to_cpu(report.rxdw3) >> 6) & 0x1);/* u8)prxreport->rxht; */
115+
116+
pattrib->icv_err = (u8)((le32_to_cpu(report.rxdw0) >> 15) & 0x1);/* u8)prxreport->icverr; */
117+
pattrib->shift_sz = (u8)((le32_to_cpu(report.rxdw0) >> 24) & 0x3);
118+
} else if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX */
119+
pattrib->pkt_len = TX_RPT1_PKT_LEN;
120+
pattrib->drvinfo_sz = 0;
121+
} else if (pattrib->pkt_rpt_type == TX_REPORT2) { /* TX RPT */
122+
pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x3FF);/* Rx length[9:0] */
123+
pattrib->drvinfo_sz = 0;
124+
125+
/* */
126+
/* Get TX report MAC ID valid. */
127+
/* */
128+
pattrib->MacIDValidEntry[0] = le32_to_cpu(report.rxdw4);
129+
pattrib->MacIDValidEntry[1] = le32_to_cpu(report.rxdw5);
130+
131+
} else if (pattrib->pkt_rpt_type == HIS_REPORT) { /* USB HISR RPT */
132+
pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);/* u16)prxreport->pktlen; */
133+
}
134+
}
135+
136+
/*
137+
* Notice:
138+
* Before calling this function,
139+
* precvframe->u.hdr.rx_data should be ready!
140+
*/
141+
void update_recvframe_phyinfo_88e(union recv_frame *precvframe, struct phy_stat *pphy_status)
142+
{
143+
struct adapter *padapter = precvframe->u.hdr.adapter;
144+
struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib;
145+
struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter);
146+
struct odm_phy_status_info *pPHYInfo = (struct odm_phy_status_info *)(&pattrib->phy_info);
147+
u8 *wlanhdr;
148+
struct odm_per_pkt_info pkt_info;
149+
u8 *sa = NULL;
150+
struct sta_priv *pstapriv;
151+
struct sta_info *psta;
152+
153+
pkt_info.bPacketMatchBSSID = false;
154+
pkt_info.bPacketToSelf = false;
155+
pkt_info.bPacketBeacon = false;
156+
157+
wlanhdr = get_recvframe_data(precvframe);
158+
159+
pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) &&
160+
!pattrib->icv_err && !pattrib->crc_err &&
161+
_rtw_memcmp(get_hdr_bssid(wlanhdr),
162+
get_bssid(&padapter->mlmepriv), ETH_ALEN));
163+
164+
pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID &&
165+
(_rtw_memcmp(get_da(wlanhdr),
166+
myid(&padapter->eeprompriv), ETH_ALEN));
167+
168+
pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID &&
169+
(GetFrameSubType(wlanhdr) == WIFI_BEACON);
170+
171+
if (pkt_info.bPacketBeacon) {
172+
if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE))
173+
sa = padapter->mlmepriv.cur_network.network.MacAddress;
174+
/* to do Ad-hoc */
175+
} else {
176+
sa = get_sa(wlanhdr);
177+
}
178+
179+
pstapriv = &padapter->stapriv;
180+
pkt_info.StationID = 0xFF;
181+
psta = rtw_get_stainfo(pstapriv, sa);
182+
if (psta)
183+
pkt_info.StationID = psta->mac_id;
184+
pkt_info.Rate = pattrib->mcs_rate;
185+
186+
ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info));
187+
188+
precvframe->u.hdr.psta = NULL;
189+
if (pkt_info.bPacketMatchBSSID &&
190+
(check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))) {
191+
if (psta) {
192+
precvframe->u.hdr.psta = psta;
193+
rtl8188e_process_phy_info(padapter, precvframe);
194+
}
195+
} else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) {
196+
if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) {
197+
if (psta)
198+
precvframe->u.hdr.psta = psta;
199+
}
200+
rtl8188e_process_phy_info(padapter, precvframe);
201+
}
202+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/******************************************************************************
2+
*
3+
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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+
* 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
17+
*
18+
*
19+
******************************************************************************/
20+
#define _RTL8188E_SRESET_C_
21+
22+
#include <rtl8188e_sreset.h>
23+
#include <rtl8188e_hal.h>
24+
25+
void rtl8188e_silentreset_for_specific_platform(struct adapter *padapter)
26+
{
27+
}
28+
29+
void rtl8188e_sreset_xmit_status_check(struct adapter *padapter)
30+
{
31+
struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter);
32+
struct sreset_priv *psrtpriv = &pHalData->srestpriv;
33+
34+
unsigned long current_time;
35+
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
36+
unsigned int diff_time;
37+
u32 txdma_status;
38+
39+
txdma_status = rtw_read32(padapter, REG_TXDMA_STATUS);
40+
if (txdma_status != 0x00) {
41+
DBG_88E("%s REG_TXDMA_STATUS:0x%08x\n", __func__, txdma_status);
42+
rtw_write32(padapter, REG_TXDMA_STATUS, txdma_status);
43+
rtl8188e_silentreset_for_specific_platform(padapter);
44+
}
45+
/* total xmit irp = 4 */
46+
current_time = rtw_get_current_time();
47+
if (0 == pxmitpriv->free_xmitbuf_cnt) {
48+
diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_time);
49+
50+
if (diff_time > 2000) {
51+
if (psrtpriv->last_tx_complete_time == 0) {
52+
psrtpriv->last_tx_complete_time = current_time;
53+
} else {
54+
diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_complete_time);
55+
if (diff_time > 4000) {
56+
DBG_88E("%s tx hang\n", __func__);
57+
rtl8188e_silentreset_for_specific_platform(padapter);
58+
}
59+
}
60+
}
61+
}
62+
}
63+
64+
void rtl8188e_sreset_linked_status_check(struct adapter *padapter)
65+
{
66+
u32 rx_dma_status = 0;
67+
u8 fw_status = 0;
68+
rx_dma_status = rtw_read32(padapter, REG_RXDMA_STATUS);
69+
if (rx_dma_status != 0x00) {
70+
DBG_88E("%s REG_RXDMA_STATUS:0x%08x\n", __func__, rx_dma_status);
71+
rtw_write32(padapter, REG_RXDMA_STATUS, rx_dma_status);
72+
}
73+
fw_status = rtw_read8(padapter, REG_FMETHR);
74+
if (fw_status != 0x00) {
75+
if (fw_status == 1)
76+
DBG_88E("%s REG_FW_STATUS (0x%02x), Read_Efuse_Fail !!\n", __func__, fw_status);
77+
else if (fw_status == 2)
78+
DBG_88E("%s REG_FW_STATUS (0x%02x), Condition_No_Match !!\n", __func__, fw_status);
79+
}
80+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/******************************************************************************
2+
*
3+
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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+
* 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
17+
*
18+
*
19+
******************************************************************************/
20+
#define _RTL8188E_XMIT_C_
21+
22+
#include <osdep_service.h>
23+
#include <drv_types.h>
24+
#include <rtl8188e_hal.h>
25+
26+
void dump_txrpt_ccx_88e(void *buf)
27+
{
28+
struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf;
29+
30+
DBG_88E("%s:\n"
31+
"tag1:%u, pkt_num:%u, txdma_underflow:%u, int_bt:%u, int_tri:%u, int_ccx:%u\n"
32+
"mac_id:%u, pkt_ok:%u, bmc:%u\n"
33+
"retry_cnt:%u, lifetime_over:%u, retry_over:%u\n"
34+
"ccx_qtime:%u\n"
35+
"final_data_rate:0x%02x\n"
36+
"qsel:%u, sw:0x%03x\n",
37+
__func__, txrpt_ccx->tag1, txrpt_ccx->pkt_num,
38+
txrpt_ccx->txdma_underflow, txrpt_ccx->int_bt,
39+
txrpt_ccx->int_tri, txrpt_ccx->int_ccx,
40+
txrpt_ccx->mac_id, txrpt_ccx->pkt_ok, txrpt_ccx->bmc,
41+
txrpt_ccx->retry_cnt, txrpt_ccx->lifetime_over,
42+
txrpt_ccx->retry_over, txrpt_ccx_qtime_88e(txrpt_ccx),
43+
txrpt_ccx->final_data_rate, txrpt_ccx->qsel,
44+
txrpt_ccx_sw_88e(txrpt_ccx)
45+
);
46+
}
47+
48+
void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf)
49+
{
50+
struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf;
51+
52+
if (txrpt_ccx->int_ccx) {
53+
if (txrpt_ccx->pkt_ok)
54+
rtw_ack_tx_done(&adapter->xmitpriv,
55+
RTW_SCTX_DONE_SUCCESS);
56+
else
57+
rtw_ack_tx_done(&adapter->xmitpriv,
58+
RTW_SCTX_DONE_CCX_PKT_FAIL);
59+
}
60+
}
61+
62+
void _dbg_dump_tx_info(struct adapter *padapter, int frame_tag,
63+
struct tx_desc *ptxdesc)
64+
{
65+
u8 dmp_txpkt;
66+
bool dump_txdesc = false;
67+
rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(dmp_txpkt));
68+
69+
if (dmp_txpkt == 1) {/* dump txdesc for data frame */
70+
DBG_88E("dump tx_desc for data frame\n");
71+
if ((frame_tag & 0x0f) == DATA_FRAMETAG)
72+
dump_txdesc = true;
73+
} else if (dmp_txpkt == 2) {/* dump txdesc for mgnt frame */
74+
DBG_88E("dump tx_desc for mgnt frame\n");
75+
if ((frame_tag & 0x0f) == MGNT_FRAMETAG)
76+
dump_txdesc = true;
77+
}
78+
79+
if (dump_txdesc) {
80+
DBG_88E("=====================================\n");
81+
DBG_88E("txdw0(0x%08x)\n", ptxdesc->txdw0);
82+
DBG_88E("txdw1(0x%08x)\n", ptxdesc->txdw1);
83+
DBG_88E("txdw2(0x%08x)\n", ptxdesc->txdw2);
84+
DBG_88E("txdw3(0x%08x)\n", ptxdesc->txdw3);
85+
DBG_88E("txdw4(0x%08x)\n", ptxdesc->txdw4);
86+
DBG_88E("txdw5(0x%08x)\n", ptxdesc->txdw5);
87+
DBG_88E("txdw6(0x%08x)\n", ptxdesc->txdw6);
88+
DBG_88E("txdw7(0x%08x)\n", ptxdesc->txdw7);
89+
DBG_88E("=====================================\n");
90+
}
91+
}

0 commit comments

Comments
 (0)