blob: 3c46294b8788cc2686ab6e62208969e1aab0a2d0 [file] [log] [blame]
Larry Fingerf7c92d22014-03-28 21:37:39 -05001/******************************************************************************
2 *
3 * Copyright(c) 2007 - 2012 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 ******************************************************************************/
15#define _RTL8723A_SRESET_C_
16
17#include <rtl8723a_sreset.h>
18#include <rtl8723a_hal.h>
Jes Sorensen050abc42014-05-16 10:05:08 +020019#include <usb_ops_linux.h>
Larry Fingerf7c92d22014-03-28 21:37:39 -050020
21void rtl8723a_sreset_xmit_status_check(struct rtw_adapter *padapter)
22{
23 struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
24 struct sreset_priv *psrtpriv = &pHalData->srestpriv;
25
26 unsigned long current_time;
27 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
28 unsigned int diff_time;
29 u32 txdma_status;
30
Jes Sorensen050abc42014-05-16 10:05:08 +020031 txdma_status = rtl8723au_read32(padapter, REG_TXDMA_STATUS);
Larry Fingerf7c92d22014-03-28 21:37:39 -050032 if (txdma_status != 0) {
33 DBG_8723A("%s REG_TXDMA_STATUS:0x%08x\n", __func__, txdma_status);
Jes Sorensenb7c19c22014-05-16 10:04:00 +020034 rtw_sreset_reset(padapter);
Larry Fingerf7c92d22014-03-28 21:37:39 -050035 }
36
37 current_time = jiffies;
38
39 if (0 == pxmitpriv->free_xmitbuf_cnt || 0 == pxmitpriv->free_xmit_extbuf_cnt) {
40
41 diff_time = jiffies_to_msecs(jiffies - psrtpriv->last_tx_time);
42
43 if (diff_time > 2000) {
44 if (psrtpriv->last_tx_complete_time == 0) {
45 psrtpriv->last_tx_complete_time = current_time;
46 } else {
47 diff_time = jiffies_to_msecs(jiffies - psrtpriv->last_tx_complete_time);
48 if (diff_time > 4000) {
Larry Fingerf7c92d22014-03-28 21:37:39 -050049 DBG_8723A("%s tx hang\n", __func__);
Jes Sorensenb7c19c22014-05-16 10:04:00 +020050 rtw_sreset_reset(padapter);
Larry Fingerf7c92d22014-03-28 21:37:39 -050051 }
52 }
53 }
54 }
Larry Fingerf7c92d22014-03-28 21:37:39 -050055}