trx.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2014 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. * The full GNU General Public License is included in this distribution in the
  15. * file called LICENSE.
  16. *
  17. * Contact Information:
  18. * wlanfae <wlanfae@realtek.com>
  19. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20. * Hsinchu 300, Taiwan.
  21. *
  22. * Larry Finger <Larry.Finger@lwfinger.net>
  23. *
  24. *****************************************************************************/
  25. #include "../wifi.h"
  26. #include "../pci.h"
  27. #include "../base.h"
  28. #include "../stats.h"
  29. #include "reg.h"
  30. #include "def.h"
  31. #include "phy.h"
  32. #include "trx.h"
  33. #include "led.h"
  34. #include "dm.h"
  35. #include "fw.h"
  36. static u8 _rtl92ee_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
  37. {
  38. __le16 fc = rtl_get_fc(skb);
  39. if (unlikely(ieee80211_is_beacon(fc)))
  40. return QSLT_BEACON;
  41. if (ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc))
  42. return QSLT_MGNT;
  43. return skb->priority;
  44. }
  45. static void _rtl92ee_query_rxphystatus(struct ieee80211_hw *hw,
  46. struct rtl_stats *pstatus, u8 *pdesc,
  47. struct rx_fwinfo *p_drvinfo,
  48. bool bpacket_match_bssid,
  49. bool bpacket_toself,
  50. bool packet_beacon)
  51. {
  52. struct rtl_priv *rtlpriv = rtl_priv(hw);
  53. struct phy_status_rpt *p_phystrpt = (struct phy_status_rpt *)p_drvinfo;
  54. s8 rx_pwr_all = 0, rx_pwr[4];
  55. u8 rf_rx_num = 0, evm, pwdb_all;
  56. u8 i, max_spatial_stream;
  57. u32 rssi, total_rssi = 0;
  58. bool is_cck = pstatus->is_cck;
  59. u8 lan_idx, vga_idx;
  60. /* Record it for next packet processing */
  61. pstatus->packet_matchbssid = bpacket_match_bssid;
  62. pstatus->packet_toself = bpacket_toself;
  63. pstatus->packet_beacon = packet_beacon;
  64. pstatus->rx_mimo_signalquality[0] = -1;
  65. pstatus->rx_mimo_signalquality[1] = -1;
  66. if (is_cck) {
  67. u8 cck_highpwr;
  68. u8 cck_agc_rpt;
  69. /* CCK Driver info Structure is not the same as OFDM packet. */
  70. cck_agc_rpt = p_phystrpt->cck_agc_rpt_ofdm_cfosho_a;
  71. /* (1)Hardware does not provide RSSI for CCK
  72. * (2)PWDB, Average PWDB cacluated by
  73. * hardware (for rate adaptive)
  74. */
  75. cck_highpwr = (u8)rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2,
  76. BIT(9));
  77. lan_idx = ((cck_agc_rpt & 0xE0) >> 5);
  78. vga_idx = (cck_agc_rpt & 0x1f);
  79. switch (lan_idx) {
  80. case 7: /*VGA_idx = 27~2*/
  81. if (vga_idx <= 27)
  82. rx_pwr_all = -100 + 2 * (27 - vga_idx);
  83. else
  84. rx_pwr_all = -100;
  85. break;
  86. case 6: /*VGA_idx = 2~0*/
  87. rx_pwr_all = -48 + 2 * (2 - vga_idx);
  88. break;
  89. case 5: /*VGA_idx = 7~5*/
  90. rx_pwr_all = -42 + 2 * (7 - vga_idx);
  91. break;
  92. case 4: /*VGA_idx = 7~4*/
  93. rx_pwr_all = -36 + 2 * (7 - vga_idx);
  94. break;
  95. case 3: /*VGA_idx = 7~0*/
  96. rx_pwr_all = -24 + 2 * (7 - vga_idx);
  97. break;
  98. case 2: /*VGA_idx = 5~0*/
  99. if (cck_highpwr)
  100. rx_pwr_all = -12 + 2 * (5 - vga_idx);
  101. else
  102. rx_pwr_all = -6 + 2 * (5 - vga_idx);
  103. break;
  104. case 1:
  105. rx_pwr_all = 8 - 2 * vga_idx;
  106. break;
  107. case 0:
  108. rx_pwr_all = 14 - 2 * vga_idx;
  109. break;
  110. default:
  111. break;
  112. }
  113. rx_pwr_all += 16;
  114. pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
  115. if (!cck_highpwr) {
  116. if (pwdb_all >= 80)
  117. pwdb_all = ((pwdb_all - 80) << 1) +
  118. ((pwdb_all - 80) >> 1) + 80;
  119. else if ((pwdb_all <= 78) && (pwdb_all >= 20))
  120. pwdb_all += 3;
  121. if (pwdb_all > 100)
  122. pwdb_all = 100;
  123. }
  124. pstatus->rx_pwdb_all = pwdb_all;
  125. pstatus->bt_rx_rssi_percentage = pwdb_all;
  126. pstatus->recvsignalpower = rx_pwr_all;
  127. /* (3) Get Signal Quality (EVM) */
  128. if (bpacket_match_bssid) {
  129. u8 sq, sq_rpt;
  130. if (pstatus->rx_pwdb_all > 40) {
  131. sq = 100;
  132. } else {
  133. sq_rpt = p_phystrpt->cck_sig_qual_ofdm_pwdb_all;
  134. if (sq_rpt > 64)
  135. sq = 0;
  136. else if (sq_rpt < 20)
  137. sq = 100;
  138. else
  139. sq = ((64 - sq_rpt) * 100) / 44;
  140. }
  141. pstatus->signalquality = sq;
  142. pstatus->rx_mimo_signalquality[0] = sq;
  143. pstatus->rx_mimo_signalquality[1] = -1;
  144. }
  145. } else {
  146. /* (1)Get RSSI for HT rate */
  147. for (i = RF90_PATH_A; i < RF6052_MAX_PATH; i++) {
  148. /* we will judge RF RX path now. */
  149. if (rtlpriv->dm.rfpath_rxenable[i])
  150. rf_rx_num++;
  151. rx_pwr[i] = ((p_phystrpt->path_agc[i].gain & 0x3f) * 2)
  152. - 110;
  153. pstatus->rx_pwr[i] = rx_pwr[i];
  154. /* Translate DBM to percentage. */
  155. rssi = rtl_query_rxpwrpercentage(rx_pwr[i]);
  156. total_rssi += rssi;
  157. pstatus->rx_mimo_signalstrength[i] = (u8)rssi;
  158. }
  159. /* (2)PWDB, Average PWDB cacluated by
  160. * hardware (for rate adaptive)
  161. */
  162. rx_pwr_all = ((p_phystrpt->cck_sig_qual_ofdm_pwdb_all >> 1)
  163. & 0x7f) - 110;
  164. pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
  165. pstatus->rx_pwdb_all = pwdb_all;
  166. pstatus->bt_rx_rssi_percentage = pwdb_all;
  167. pstatus->rxpower = rx_pwr_all;
  168. pstatus->recvsignalpower = rx_pwr_all;
  169. /* (3)EVM of HT rate */
  170. if (pstatus->rate >= DESC_RATEMCS8 &&
  171. pstatus->rate <= DESC_RATEMCS15)
  172. max_spatial_stream = 2;
  173. else
  174. max_spatial_stream = 1;
  175. for (i = 0; i < max_spatial_stream; i++) {
  176. evm = rtl_evm_db_to_percentage(
  177. p_phystrpt->stream_rxevm[i]);
  178. if (bpacket_match_bssid) {
  179. /* Fill value in RFD, Get the first
  180. * spatial stream only
  181. */
  182. if (i == 0)
  183. pstatus->signalquality = (u8)(evm &
  184. 0xff);
  185. pstatus->rx_mimo_signalquality[i] = (u8)(evm &
  186. 0xff);
  187. }
  188. }
  189. if (bpacket_match_bssid) {
  190. for (i = RF90_PATH_A; i <= RF90_PATH_B; i++)
  191. rtl_priv(hw)->dm.cfo_tail[i] =
  192. (int)p_phystrpt->path_cfotail[i];
  193. if (rtl_priv(hw)->dm.packet_count == 0xffffffff)
  194. rtl_priv(hw)->dm.packet_count = 0;
  195. else
  196. rtl_priv(hw)->dm.packet_count++;
  197. }
  198. }
  199. /* UI BSS List signal strength(in percentage),
  200. * make it good looking, from 0~100.
  201. */
  202. if (is_cck)
  203. pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
  204. pwdb_all));
  205. else if (rf_rx_num != 0)
  206. pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
  207. total_rssi /= rf_rx_num));
  208. }
  209. static void _rtl92ee_translate_rx_signal_stuff(struct ieee80211_hw *hw,
  210. struct sk_buff *skb,
  211. struct rtl_stats *pstatus,
  212. u8 *pdesc,
  213. struct rx_fwinfo *p_drvinfo)
  214. {
  215. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  216. struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
  217. struct ieee80211_hdr *hdr;
  218. u8 *tmp_buf;
  219. u8 *praddr;
  220. u8 *psaddr;
  221. __le16 fc;
  222. bool packet_matchbssid, packet_toself, packet_beacon;
  223. tmp_buf = skb->data + pstatus->rx_drvinfo_size +
  224. pstatus->rx_bufshift + 24;
  225. hdr = (struct ieee80211_hdr *)tmp_buf;
  226. fc = hdr->frame_control;
  227. praddr = hdr->addr1;
  228. psaddr = ieee80211_get_SA(hdr);
  229. ether_addr_copy(pstatus->psaddr, psaddr);
  230. packet_matchbssid = (!ieee80211_is_ctl(fc) &&
  231. (ether_addr_equal(mac->bssid,
  232. ieee80211_has_tods(fc) ?
  233. hdr->addr1 :
  234. ieee80211_has_fromds(fc) ?
  235. hdr->addr2 : hdr->addr3)) &&
  236. (!pstatus->hwerror) && (!pstatus->crc) &&
  237. (!pstatus->icv));
  238. packet_toself = packet_matchbssid &&
  239. (ether_addr_equal(praddr, rtlefuse->dev_addr));
  240. if (ieee80211_is_beacon(fc))
  241. packet_beacon = true;
  242. else
  243. packet_beacon = false;
  244. if (packet_beacon && packet_matchbssid)
  245. rtl_priv(hw)->dm.dbginfo.num_qry_beacon_pkt++;
  246. if (packet_matchbssid && ieee80211_is_data_qos(hdr->frame_control) &&
  247. !is_multicast_ether_addr(ieee80211_get_DA(hdr))) {
  248. struct ieee80211_qos_hdr *hdr_qos =
  249. (struct ieee80211_qos_hdr *)tmp_buf;
  250. u16 tid = le16_to_cpu(hdr_qos->qos_ctrl) & 0xf;
  251. if (tid != 0 && tid != 3)
  252. rtl_priv(hw)->dm.dbginfo.num_non_be_pkt++;
  253. }
  254. _rtl92ee_query_rxphystatus(hw, pstatus, pdesc, p_drvinfo,
  255. packet_matchbssid, packet_toself,
  256. packet_beacon);
  257. rtl_process_phyinfo(hw, tmp_buf, pstatus);
  258. }
  259. static void _rtl92ee_insert_emcontent(struct rtl_tcb_desc *ptcb_desc,
  260. u8 *virtualaddress)
  261. {
  262. u32 dwtmp = 0;
  263. memset(virtualaddress, 0, 8);
  264. SET_EARLYMODE_PKTNUM(virtualaddress, ptcb_desc->empkt_num);
  265. if (ptcb_desc->empkt_num == 1) {
  266. dwtmp = ptcb_desc->empkt_len[0];
  267. } else {
  268. dwtmp = ptcb_desc->empkt_len[0];
  269. dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4;
  270. dwtmp += ptcb_desc->empkt_len[1];
  271. }
  272. SET_EARLYMODE_LEN0(virtualaddress, dwtmp);
  273. if (ptcb_desc->empkt_num <= 3) {
  274. dwtmp = ptcb_desc->empkt_len[2];
  275. } else {
  276. dwtmp = ptcb_desc->empkt_len[2];
  277. dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4;
  278. dwtmp += ptcb_desc->empkt_len[3];
  279. }
  280. SET_EARLYMODE_LEN1(virtualaddress, dwtmp);
  281. if (ptcb_desc->empkt_num <= 5) {
  282. dwtmp = ptcb_desc->empkt_len[4];
  283. } else {
  284. dwtmp = ptcb_desc->empkt_len[4];
  285. dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4;
  286. dwtmp += ptcb_desc->empkt_len[5];
  287. }
  288. SET_EARLYMODE_LEN2_1(virtualaddress, dwtmp & 0xF);
  289. SET_EARLYMODE_LEN2_2(virtualaddress, dwtmp >> 4);
  290. if (ptcb_desc->empkt_num <= 7) {
  291. dwtmp = ptcb_desc->empkt_len[6];
  292. } else {
  293. dwtmp = ptcb_desc->empkt_len[6];
  294. dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4;
  295. dwtmp += ptcb_desc->empkt_len[7];
  296. }
  297. SET_EARLYMODE_LEN3(virtualaddress, dwtmp);
  298. if (ptcb_desc->empkt_num <= 9) {
  299. dwtmp = ptcb_desc->empkt_len[8];
  300. } else {
  301. dwtmp = ptcb_desc->empkt_len[8];
  302. dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4;
  303. dwtmp += ptcb_desc->empkt_len[9];
  304. }
  305. SET_EARLYMODE_LEN4(virtualaddress, dwtmp);
  306. }
  307. bool rtl92ee_rx_query_desc(struct ieee80211_hw *hw,
  308. struct rtl_stats *status,
  309. struct ieee80211_rx_status *rx_status,
  310. u8 *pdesc, struct sk_buff *skb)
  311. {
  312. struct rtl_priv *rtlpriv = rtl_priv(hw);
  313. struct rx_fwinfo *p_drvinfo;
  314. struct ieee80211_hdr *hdr;
  315. u32 phystatus = GET_RX_DESC_PHYST(pdesc);
  316. if (GET_RX_STATUS_DESC_RPT_SEL(pdesc) == 0)
  317. status->packet_report_type = NORMAL_RX;
  318. else
  319. status->packet_report_type = C2H_PACKET;
  320. status->length = (u16)GET_RX_DESC_PKT_LEN(pdesc);
  321. status->rx_drvinfo_size = (u8)GET_RX_DESC_DRV_INFO_SIZE(pdesc) *
  322. RX_DRV_INFO_SIZE_UNIT;
  323. status->rx_bufshift = (u8)(GET_RX_DESC_SHIFT(pdesc) & 0x03);
  324. status->icv = (u16)GET_RX_DESC_ICV(pdesc);
  325. status->crc = (u16)GET_RX_DESC_CRC32(pdesc);
  326. status->hwerror = (status->crc | status->icv);
  327. status->decrypted = !GET_RX_DESC_SWDEC(pdesc);
  328. status->rate = (u8)GET_RX_DESC_RXMCS(pdesc);
  329. status->isampdu = (bool)(GET_RX_DESC_PAGGR(pdesc) == 1);
  330. status->timestamp_low = GET_RX_DESC_TSFL(pdesc);
  331. status->is_cck = RTL92EE_RX_HAL_IS_CCK_RATE(status->rate);
  332. status->macid = GET_RX_DESC_MACID(pdesc);
  333. if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc))
  334. status->wake_match = BIT(2);
  335. else if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc))
  336. status->wake_match = BIT(1);
  337. else if (GET_RX_STATUS_DESC_UNICAST_MATCH(pdesc))
  338. status->wake_match = BIT(0);
  339. else
  340. status->wake_match = 0;
  341. if (status->wake_match)
  342. RT_TRACE(rtlpriv, COMP_RXDESC, DBG_LOUD,
  343. "GGGGGGGGGGGGGet Wakeup Packet!! WakeMatch=%d\n",
  344. status->wake_match);
  345. rx_status->freq = hw->conf.chandef.chan->center_freq;
  346. rx_status->band = hw->conf.chandef.chan->band;
  347. hdr = (struct ieee80211_hdr *)(skb->data + status->rx_drvinfo_size +
  348. status->rx_bufshift + 24);
  349. if (status->crc)
  350. rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
  351. if (status->rx_is40Mhzpacket)
  352. rx_status->bw = RATE_INFO_BW_40;
  353. if (status->is_ht)
  354. rx_status->encoding = RX_ENC_HT;
  355. rx_status->flag |= RX_FLAG_MACTIME_START;
  356. /* hw will set status->decrypted true, if it finds the
  357. * frame is open data frame or mgmt frame.
  358. * So hw will not decryption robust managment frame
  359. * for IEEE80211w but still set status->decrypted
  360. * true, so here we should set it back to undecrypted
  361. * for IEEE80211w frame, and mac80211 sw will help
  362. * to decrypt it
  363. */
  364. if (status->decrypted) {
  365. if ((!_ieee80211_is_robust_mgmt_frame(hdr)) &&
  366. (ieee80211_has_protected(hdr->frame_control)))
  367. rx_status->flag |= RX_FLAG_DECRYPTED;
  368. else
  369. rx_status->flag &= ~RX_FLAG_DECRYPTED;
  370. }
  371. /* rate_idx: index of data rate into band's
  372. * supported rates or MCS index if HT rates
  373. * are use (RX_FLAG_HT)
  374. * Notice: this is diff with windows define
  375. */
  376. rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
  377. false, status->rate);
  378. rx_status->mactime = status->timestamp_low;
  379. if (phystatus) {
  380. p_drvinfo = (struct rx_fwinfo *)(skb->data +
  381. status->rx_bufshift + 24);
  382. _rtl92ee_translate_rx_signal_stuff(hw, skb, status, pdesc,
  383. p_drvinfo);
  384. }
  385. rx_status->signal = status->recvsignalpower + 10;
  386. if (status->packet_report_type == TX_REPORT2) {
  387. status->macid_valid_entry[0] =
  388. GET_RX_RPT2_DESC_MACID_VALID_1(pdesc);
  389. status->macid_valid_entry[1] =
  390. GET_RX_RPT2_DESC_MACID_VALID_2(pdesc);
  391. }
  392. return true;
  393. }
  394. /*in Windows, this == Rx_92EE_Interrupt*/
  395. void rtl92ee_rx_check_dma_ok(struct ieee80211_hw *hw, u8 *header_desc,
  396. u8 queue_index)
  397. {
  398. u8 first_seg = 0;
  399. u8 last_seg = 0;
  400. u16 total_len = 0;
  401. u16 read_cnt = 0;
  402. if (header_desc == NULL)
  403. return;
  404. total_len = (u16)GET_RX_BUFFER_DESC_TOTAL_LENGTH(header_desc);
  405. first_seg = (u8)GET_RX_BUFFER_DESC_FS(header_desc);
  406. last_seg = (u8)GET_RX_BUFFER_DESC_LS(header_desc);
  407. while (total_len == 0 && first_seg == 0 && last_seg == 0) {
  408. read_cnt++;
  409. total_len = (u16)GET_RX_BUFFER_DESC_TOTAL_LENGTH(header_desc);
  410. first_seg = (u8)GET_RX_BUFFER_DESC_FS(header_desc);
  411. last_seg = (u8)GET_RX_BUFFER_DESC_LS(header_desc);
  412. if (read_cnt > 20)
  413. break;
  414. }
  415. }
  416. u16 rtl92ee_rx_desc_buff_remained_cnt(struct ieee80211_hw *hw, u8 queue_index)
  417. {
  418. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  419. struct rtl_priv *rtlpriv = rtl_priv(hw);
  420. u16 read_point = 0, write_point = 0, remind_cnt = 0;
  421. u32 tmp_4byte = 0;
  422. static bool start_rx;
  423. tmp_4byte = rtl_read_dword(rtlpriv, REG_RXQ_TXBD_IDX);
  424. read_point = (u16)((tmp_4byte>>16) & 0x7ff);
  425. write_point = (u16)(tmp_4byte & 0x7ff);
  426. if (write_point != rtlpci->rx_ring[queue_index].next_rx_rp) {
  427. RT_TRACE(rtlpriv, COMP_RXDESC, DBG_DMESG,
  428. "!!!write point is 0x%x, reg 0x3B4 value is 0x%x\n",
  429. write_point, tmp_4byte);
  430. tmp_4byte = rtl_read_dword(rtlpriv, REG_RXQ_TXBD_IDX);
  431. read_point = (u16)((tmp_4byte>>16) & 0x7ff);
  432. write_point = (u16)(tmp_4byte & 0x7ff);
  433. }
  434. if (read_point > 0)
  435. start_rx = true;
  436. if (!start_rx)
  437. return 0;
  438. remind_cnt = calc_fifo_space(read_point, write_point,
  439. RTL_PCI_MAX_RX_COUNT);
  440. if (remind_cnt == 0)
  441. return 0;
  442. rtlpci->rx_ring[queue_index].next_rx_rp = write_point;
  443. return remind_cnt;
  444. }
  445. static u16 get_desc_addr_fr_q_idx(u16 queue_index)
  446. {
  447. u16 desc_address = REG_BEQ_TXBD_IDX;
  448. switch (queue_index) {
  449. case BK_QUEUE:
  450. desc_address = REG_BKQ_TXBD_IDX;
  451. break;
  452. case BE_QUEUE:
  453. desc_address = REG_BEQ_TXBD_IDX;
  454. break;
  455. case VI_QUEUE:
  456. desc_address = REG_VIQ_TXBD_IDX;
  457. break;
  458. case VO_QUEUE:
  459. desc_address = REG_VOQ_TXBD_IDX;
  460. break;
  461. case BEACON_QUEUE:
  462. desc_address = REG_BEQ_TXBD_IDX;
  463. break;
  464. case TXCMD_QUEUE:
  465. desc_address = REG_BEQ_TXBD_IDX;
  466. break;
  467. case MGNT_QUEUE:
  468. desc_address = REG_MGQ_TXBD_IDX;
  469. break;
  470. case HIGH_QUEUE:
  471. desc_address = REG_HI0Q_TXBD_IDX;
  472. break;
  473. case HCCA_QUEUE:
  474. desc_address = REG_BEQ_TXBD_IDX;
  475. break;
  476. default:
  477. break;
  478. }
  479. return desc_address;
  480. }
  481. u16 rtl92ee_get_available_desc(struct ieee80211_hw *hw, u8 q_idx)
  482. {
  483. struct rtl_priv *rtlpriv = rtl_priv(hw);
  484. u16 point_diff = 0;
  485. u16 current_tx_read_point = 0, current_tx_write_point = 0;
  486. u32 tmp_4byte;
  487. tmp_4byte = rtl_read_dword(rtlpriv,
  488. get_desc_addr_fr_q_idx(q_idx));
  489. current_tx_read_point = (u16)((tmp_4byte >> 16) & 0x0fff);
  490. current_tx_write_point = (u16)((tmp_4byte) & 0x0fff);
  491. point_diff = calc_fifo_space(current_tx_read_point,
  492. current_tx_write_point,
  493. TX_DESC_NUM_92E);
  494. return point_diff;
  495. }
  496. void rtl92ee_pre_fill_tx_bd_desc(struct ieee80211_hw *hw,
  497. u8 *tx_bd_desc, u8 *desc, u8 queue_index,
  498. struct sk_buff *skb, dma_addr_t addr)
  499. {
  500. struct rtl_priv *rtlpriv = rtl_priv(hw);
  501. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  502. u32 pkt_len = skb->len;
  503. u16 desc_size = 40; /*tx desc size*/
  504. u32 psblen = 0;
  505. u16 tx_page_size = 0;
  506. u32 total_packet_size = 0;
  507. u16 current_bd_desc;
  508. u8 i = 0;
  509. u16 real_desc_size = 0x28;
  510. u16 append_early_mode_size = 0;
  511. u8 segmentnum = 1 << (RTL8192EE_SEG_NUM + 1);
  512. dma_addr_t desc_dma_addr;
  513. bool dma64 = rtlpriv->cfg->mod_params->dma64;
  514. tx_page_size = 2;
  515. current_bd_desc = rtlpci->tx_ring[queue_index].cur_tx_wp;
  516. total_packet_size = desc_size+pkt_len;
  517. if (rtlpriv->rtlhal.earlymode_enable) {
  518. if (queue_index < BEACON_QUEUE) {
  519. append_early_mode_size = 8;
  520. total_packet_size += append_early_mode_size;
  521. }
  522. }
  523. if (tx_page_size > 0) {
  524. psblen = (pkt_len + real_desc_size + append_early_mode_size) /
  525. (tx_page_size * 128);
  526. if (psblen * (tx_page_size * 128) < total_packet_size)
  527. psblen += 1;
  528. }
  529. /* tx desc addr */
  530. desc_dma_addr = rtlpci->tx_ring[queue_index].dma +
  531. (current_bd_desc * TX_DESC_SIZE);
  532. /* Reset */
  533. SET_TX_BUFF_DESC_LEN_0(tx_bd_desc, 0);
  534. SET_TX_BUFF_DESC_PSB(tx_bd_desc, 0);
  535. SET_TX_BUFF_DESC_OWN(tx_bd_desc, 0);
  536. for (i = 1; i < segmentnum; i++) {
  537. SET_TXBUFFER_DESC_LEN_WITH_OFFSET(tx_bd_desc, i, 0);
  538. SET_TXBUFFER_DESC_AMSDU_WITH_OFFSET(tx_bd_desc, i, 0);
  539. SET_TXBUFFER_DESC_ADD_LOW_WITH_OFFSET(tx_bd_desc, i, 0);
  540. SET_TXBUFFER_DESC_ADD_HIGH_WITH_OFFSET(tx_bd_desc, i, 0, dma64);
  541. }
  542. /* Clear all status */
  543. CLEAR_PCI_TX_DESC_CONTENT(desc, TX_DESC_SIZE);
  544. if (rtlpriv->rtlhal.earlymode_enable) {
  545. if (queue_index < BEACON_QUEUE) {
  546. /* This if needs braces */
  547. SET_TX_BUFF_DESC_LEN_0(tx_bd_desc, desc_size + 8);
  548. } else {
  549. SET_TX_BUFF_DESC_LEN_0(tx_bd_desc, desc_size);
  550. }
  551. } else {
  552. SET_TX_BUFF_DESC_LEN_0(tx_bd_desc, desc_size);
  553. }
  554. SET_TX_BUFF_DESC_PSB(tx_bd_desc, psblen);
  555. SET_TX_BUFF_DESC_ADDR_LOW_0(tx_bd_desc, desc_dma_addr);
  556. SET_TX_BUFF_DESC_ADDR_HIGH_0(tx_bd_desc, ((u64)desc_dma_addr >> 32),
  557. dma64);
  558. SET_TXBUFFER_DESC_LEN_WITH_OFFSET(tx_bd_desc, 1, pkt_len);
  559. /* don't using extendsion mode. */
  560. SET_TXBUFFER_DESC_AMSDU_WITH_OFFSET(tx_bd_desc, 1, 0);
  561. SET_TXBUFFER_DESC_ADD_LOW_WITH_OFFSET(tx_bd_desc, 1, addr);
  562. SET_TXBUFFER_DESC_ADD_HIGH_WITH_OFFSET(tx_bd_desc, 1,
  563. ((u64)addr >> 32), dma64);
  564. SET_TX_DESC_PKT_SIZE(desc, (u16)(pkt_len));
  565. SET_TX_DESC_TX_BUFFER_SIZE(desc, (u16)(pkt_len));
  566. }
  567. void rtl92ee_tx_fill_desc(struct ieee80211_hw *hw,
  568. struct ieee80211_hdr *hdr, u8 *pdesc_tx,
  569. u8 *pbd_desc_tx,
  570. struct ieee80211_tx_info *info,
  571. struct ieee80211_sta *sta,
  572. struct sk_buff *skb,
  573. u8 hw_queue, struct rtl_tcb_desc *ptcb_desc)
  574. {
  575. struct rtl_priv *rtlpriv = rtl_priv(hw);
  576. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  577. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  578. struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
  579. struct rtlwifi_tx_info *tx_info = rtl_tx_skb_cb_info(skb);
  580. u8 *pdesc = (u8 *)pdesc_tx;
  581. u16 seq_number;
  582. __le16 fc = hdr->frame_control;
  583. unsigned int buf_len = 0;
  584. u8 fw_qsel = _rtl92ee_map_hwqueue_to_fwqueue(skb, hw_queue);
  585. bool firstseg = ((hdr->seq_ctrl &
  586. cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0);
  587. bool lastseg = ((hdr->frame_control &
  588. cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) == 0);
  589. dma_addr_t mapping;
  590. u8 bw_40 = 0;
  591. u8 short_gi = 0;
  592. if (mac->opmode == NL80211_IFTYPE_STATION) {
  593. bw_40 = mac->bw_40;
  594. } else if (mac->opmode == NL80211_IFTYPE_AP ||
  595. mac->opmode == NL80211_IFTYPE_ADHOC) {
  596. if (sta)
  597. bw_40 = sta->ht_cap.cap &
  598. IEEE80211_HT_CAP_SUP_WIDTH_20_40;
  599. }
  600. seq_number = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
  601. rtl_get_tcb_desc(hw, info, sta, skb, ptcb_desc);
  602. /* reserve 8 byte for AMPDU early mode */
  603. if (rtlhal->earlymode_enable) {
  604. skb_push(skb, EM_HDR_LEN);
  605. memset(skb->data, 0, EM_HDR_LEN);
  606. }
  607. buf_len = skb->len;
  608. mapping = pci_map_single(rtlpci->pdev, skb->data, skb->len,
  609. PCI_DMA_TODEVICE);
  610. if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
  611. RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
  612. "DMA mapping error\n");
  613. return;
  614. }
  615. if (pbd_desc_tx != NULL)
  616. rtl92ee_pre_fill_tx_bd_desc(hw, pbd_desc_tx, pdesc, hw_queue,
  617. skb, mapping);
  618. if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) {
  619. firstseg = true;
  620. lastseg = true;
  621. }
  622. if (firstseg) {
  623. if (rtlhal->earlymode_enable) {
  624. SET_TX_DESC_PKT_OFFSET(pdesc, 1);
  625. SET_TX_DESC_OFFSET(pdesc,
  626. USB_HWDESC_HEADER_LEN + EM_HDR_LEN);
  627. if (ptcb_desc->empkt_num) {
  628. RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
  629. "Insert 8 byte.pTcb->EMPktNum:%d\n",
  630. ptcb_desc->empkt_num);
  631. _rtl92ee_insert_emcontent(ptcb_desc,
  632. (u8 *)(skb->data));
  633. }
  634. } else {
  635. SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN);
  636. }
  637. SET_TX_DESC_TX_RATE(pdesc, ptcb_desc->hw_rate);
  638. if (ieee80211_is_mgmt(fc)) {
  639. ptcb_desc->use_driver_rate = true;
  640. } else {
  641. if (rtlpriv->ra.is_special_data) {
  642. ptcb_desc->use_driver_rate = true;
  643. SET_TX_DESC_TX_RATE(pdesc, DESC_RATE11M);
  644. } else {
  645. ptcb_desc->use_driver_rate = false;
  646. }
  647. }
  648. if (ptcb_desc->hw_rate > DESC_RATEMCS0)
  649. short_gi = (ptcb_desc->use_shortgi) ? 1 : 0;
  650. else
  651. short_gi = (ptcb_desc->use_shortpreamble) ? 1 : 0;
  652. if (info->flags & IEEE80211_TX_CTL_AMPDU) {
  653. SET_TX_DESC_AGG_ENABLE(pdesc, 1);
  654. SET_TX_DESC_MAX_AGG_NUM(pdesc, 0x14);
  655. }
  656. SET_TX_DESC_SEQ(pdesc, seq_number);
  657. SET_TX_DESC_RTS_ENABLE(pdesc,
  658. ((ptcb_desc->rts_enable &&
  659. !ptcb_desc->cts_enable) ? 1 : 0));
  660. SET_TX_DESC_HW_RTS_ENABLE(pdesc, 0);
  661. SET_TX_DESC_CTS2SELF(pdesc,
  662. ((ptcb_desc->cts_enable) ? 1 : 0));
  663. SET_TX_DESC_RTS_RATE(pdesc, ptcb_desc->rts_rate);
  664. SET_TX_DESC_RTS_SC(pdesc, ptcb_desc->rts_sc);
  665. SET_TX_DESC_RTS_SHORT(pdesc,
  666. ((ptcb_desc->rts_rate <= DESC_RATE54M) ?
  667. (ptcb_desc->rts_use_shortpreamble ? 1 : 0) :
  668. (ptcb_desc->rts_use_shortgi ? 1 : 0)));
  669. if (ptcb_desc->tx_enable_sw_calc_duration)
  670. SET_TX_DESC_NAV_USE_HDR(pdesc, 1);
  671. if (bw_40) {
  672. if (ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_20_40) {
  673. SET_TX_DESC_DATA_BW(pdesc, 1);
  674. SET_TX_DESC_TX_SUB_CARRIER(pdesc, 3);
  675. } else {
  676. SET_TX_DESC_DATA_BW(pdesc, 0);
  677. SET_TX_DESC_TX_SUB_CARRIER(pdesc,
  678. mac->cur_40_prime_sc);
  679. }
  680. } else {
  681. SET_TX_DESC_DATA_BW(pdesc, 0);
  682. SET_TX_DESC_TX_SUB_CARRIER(pdesc, 0);
  683. }
  684. SET_TX_DESC_LINIP(pdesc, 0);
  685. if (sta) {
  686. u8 ampdu_density = sta->ht_cap.ampdu_density;
  687. SET_TX_DESC_AMPDU_DENSITY(pdesc, ampdu_density);
  688. }
  689. if (info->control.hw_key) {
  690. struct ieee80211_key_conf *key = info->control.hw_key;
  691. switch (key->cipher) {
  692. case WLAN_CIPHER_SUITE_WEP40:
  693. case WLAN_CIPHER_SUITE_WEP104:
  694. case WLAN_CIPHER_SUITE_TKIP:
  695. SET_TX_DESC_SEC_TYPE(pdesc, 0x1);
  696. break;
  697. case WLAN_CIPHER_SUITE_CCMP:
  698. SET_TX_DESC_SEC_TYPE(pdesc, 0x3);
  699. break;
  700. default:
  701. SET_TX_DESC_SEC_TYPE(pdesc, 0x0);
  702. break;
  703. }
  704. }
  705. SET_TX_DESC_QUEUE_SEL(pdesc, fw_qsel);
  706. SET_TX_DESC_DATA_RATE_FB_LIMIT(pdesc, 0x1F);
  707. SET_TX_DESC_RTS_RATE_FB_LIMIT(pdesc, 0xF);
  708. SET_TX_DESC_DISABLE_FB(pdesc,
  709. ptcb_desc->disable_ratefallback ? 1 : 0);
  710. SET_TX_DESC_USE_RATE(pdesc, ptcb_desc->use_driver_rate ? 1 : 0);
  711. /*SET_TX_DESC_PWR_STATUS(pdesc, pwr_status);*/
  712. /* Set TxRate and RTSRate in TxDesc */
  713. /* This prevent Tx initial rate of new-coming packets */
  714. /* from being overwritten by retried packet rate.*/
  715. if (!ptcb_desc->use_driver_rate) {
  716. /*SET_TX_DESC_RTS_RATE(pdesc, 0x08); */
  717. /* SET_TX_DESC_TX_RATE(pdesc, 0x0b); */
  718. }
  719. if (ieee80211_is_data_qos(fc)) {
  720. if (mac->rdg_en) {
  721. RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
  722. "Enable RDG function.\n");
  723. SET_TX_DESC_RDG_ENABLE(pdesc, 1);
  724. SET_TX_DESC_HTC(pdesc, 1);
  725. }
  726. }
  727. /* tx report */
  728. rtl_set_tx_report(ptcb_desc, pdesc, hw, tx_info);
  729. }
  730. SET_TX_DESC_FIRST_SEG(pdesc, (firstseg ? 1 : 0));
  731. SET_TX_DESC_LAST_SEG(pdesc, (lastseg ? 1 : 0));
  732. SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping);
  733. if (rtlpriv->dm.useramask) {
  734. SET_TX_DESC_RATE_ID(pdesc, ptcb_desc->ratr_index);
  735. SET_TX_DESC_MACID(pdesc, ptcb_desc->mac_id);
  736. } else {
  737. SET_TX_DESC_RATE_ID(pdesc, 0xC + ptcb_desc->ratr_index);
  738. SET_TX_DESC_MACID(pdesc, ptcb_desc->ratr_index);
  739. }
  740. SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1));
  741. if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) ||
  742. is_broadcast_ether_addr(ieee80211_get_DA(hdr))) {
  743. SET_TX_DESC_BMC(pdesc, 1);
  744. }
  745. RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n");
  746. }
  747. void rtl92ee_tx_fill_cmddesc(struct ieee80211_hw *hw,
  748. u8 *pdesc, bool firstseg,
  749. bool lastseg, struct sk_buff *skb)
  750. {
  751. struct rtl_priv *rtlpriv = rtl_priv(hw);
  752. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  753. u8 fw_queue = QSLT_BEACON;
  754. dma_addr_t mapping = pci_map_single(rtlpci->pdev,
  755. skb->data, skb->len,
  756. PCI_DMA_TODEVICE);
  757. u8 txdesc_len = 40;
  758. if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
  759. RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
  760. "DMA mapping error\n");
  761. return;
  762. }
  763. CLEAR_PCI_TX_DESC_CONTENT(pdesc, txdesc_len);
  764. if (firstseg)
  765. SET_TX_DESC_OFFSET(pdesc, txdesc_len);
  766. SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
  767. SET_TX_DESC_SEQ(pdesc, 0);
  768. SET_TX_DESC_LINIP(pdesc, 0);
  769. SET_TX_DESC_QUEUE_SEL(pdesc, fw_queue);
  770. SET_TX_DESC_FIRST_SEG(pdesc, 1);
  771. SET_TX_DESC_LAST_SEG(pdesc, 1);
  772. SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16)(skb->len));
  773. SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping);
  774. SET_TX_DESC_RATE_ID(pdesc, 7);
  775. SET_TX_DESC_MACID(pdesc, 0);
  776. SET_TX_DESC_OWN(pdesc, 1);
  777. SET_TX_DESC_PKT_SIZE((u8 *)pdesc, (u16)(skb->len));
  778. SET_TX_DESC_FIRST_SEG(pdesc, 1);
  779. SET_TX_DESC_LAST_SEG(pdesc, 1);
  780. SET_TX_DESC_OFFSET(pdesc, 40);
  781. SET_TX_DESC_USE_RATE(pdesc, 1);
  782. RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD,
  783. "H2C Tx Cmd Content\n", pdesc, txdesc_len);
  784. }
  785. void rtl92ee_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
  786. u8 desc_name, u8 *val)
  787. {
  788. struct rtl_priv *rtlpriv = rtl_priv(hw);
  789. u8 q_idx = *val;
  790. bool dma64 = rtlpriv->cfg->mod_params->dma64;
  791. if (istx) {
  792. switch (desc_name) {
  793. case HW_DESC_TX_NEXTDESC_ADDR:
  794. SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *)val);
  795. break;
  796. case HW_DESC_OWN:{
  797. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  798. struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[q_idx];
  799. u16 max_tx_desc = ring->entries;
  800. if (q_idx == BEACON_QUEUE) {
  801. ring->cur_tx_wp = 0;
  802. ring->cur_tx_rp = 0;
  803. SET_TX_BUFF_DESC_OWN(pdesc, 1);
  804. return;
  805. }
  806. /* make sure tx desc is available by caller */
  807. ring->cur_tx_wp = ((ring->cur_tx_wp + 1) % max_tx_desc);
  808. rtl_write_word(rtlpriv,
  809. get_desc_addr_fr_q_idx(q_idx),
  810. ring->cur_tx_wp);
  811. }
  812. break;
  813. }
  814. } else {
  815. switch (desc_name) {
  816. case HW_DESC_RX_PREPARE:
  817. SET_RX_BUFFER_DESC_LS(pdesc, 0);
  818. SET_RX_BUFFER_DESC_FS(pdesc, 0);
  819. SET_RX_BUFFER_DESC_TOTAL_LENGTH(pdesc, 0);
  820. SET_RX_BUFFER_DESC_DATA_LENGTH(pdesc,
  821. MAX_RECEIVE_BUFFER_SIZE +
  822. RX_DESC_SIZE);
  823. SET_RX_BUFFER_PHYSICAL_LOW(pdesc, (*(dma_addr_t *)val) &
  824. DMA_BIT_MASK(32));
  825. SET_RX_BUFFER_PHYSICAL_HIGH(pdesc,
  826. ((u64)(*(dma_addr_t *)val)
  827. >> 32),
  828. dma64);
  829. break;
  830. case HW_DESC_RXERO:
  831. SET_RX_DESC_EOR(pdesc, 1);
  832. break;
  833. default:
  834. WARN_ONCE(true,
  835. "rtl8192ee: ERR rxdesc :%d not processed\n",
  836. desc_name);
  837. break;
  838. }
  839. }
  840. }
  841. u64 rtl92ee_get_desc(struct ieee80211_hw *hw,
  842. u8 *pdesc, bool istx, u8 desc_name)
  843. {
  844. struct rtl_priv *rtlpriv = rtl_priv(hw);
  845. u64 ret = 0;
  846. bool dma64 = rtlpriv->cfg->mod_params->dma64;
  847. if (istx) {
  848. switch (desc_name) {
  849. case HW_DESC_OWN:
  850. ret = GET_TX_DESC_OWN(pdesc);
  851. break;
  852. case HW_DESC_TXBUFF_ADDR:
  853. ret = GET_TXBUFFER_DESC_ADDR_LOW(pdesc, 1);
  854. ret |= (u64)GET_TXBUFFER_DESC_ADDR_HIGH(pdesc, 1,
  855. dma64) << 32;
  856. break;
  857. default:
  858. WARN_ONCE(true,
  859. "rtl8192ee: ERR txdesc :%d not processed\n",
  860. desc_name);
  861. break;
  862. }
  863. } else {
  864. switch (desc_name) {
  865. case HW_DESC_OWN:
  866. ret = GET_RX_DESC_OWN(pdesc);
  867. break;
  868. case HW_DESC_RXPKT_LEN:
  869. ret = GET_RX_DESC_PKT_LEN(pdesc);
  870. break;
  871. case HW_DESC_RXBUFF_ADDR:
  872. ret = GET_RX_DESC_BUFF_ADDR(pdesc);
  873. break;
  874. default:
  875. WARN_ONCE(true,
  876. "rtl8192ee: ERR rxdesc :%d not processed\n",
  877. desc_name);
  878. break;
  879. }
  880. }
  881. return ret;
  882. }
  883. bool rtl92ee_is_tx_desc_closed(struct ieee80211_hw *hw, u8 hw_queue, u16 index)
  884. {
  885. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  886. struct rtl_priv *rtlpriv = rtl_priv(hw);
  887. u16 read_point, write_point;
  888. bool ret = false;
  889. static u8 stop_report_cnt;
  890. struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
  891. {
  892. u16 cur_tx_rp, cur_tx_wp;
  893. u32 tmpu32 = 0;
  894. tmpu32 =
  895. rtl_read_dword(rtlpriv,
  896. get_desc_addr_fr_q_idx(hw_queue));
  897. cur_tx_rp = (u16)((tmpu32 >> 16) & 0x0fff);
  898. cur_tx_wp = (u16)(tmpu32 & 0x0fff);
  899. /* don't need to update ring->cur_tx_wp */
  900. ring->cur_tx_rp = cur_tx_rp;
  901. }
  902. read_point = ring->cur_tx_rp;
  903. write_point = ring->cur_tx_wp;
  904. if (write_point > read_point) {
  905. if (index < write_point && index >= read_point)
  906. ret = false;
  907. else
  908. ret = true;
  909. } else if (write_point < read_point) {
  910. if (index > write_point && index < read_point)
  911. ret = true;
  912. else
  913. ret = false;
  914. } else {
  915. if (index != read_point)
  916. ret = true;
  917. }
  918. if (hw_queue == BEACON_QUEUE)
  919. ret = true;
  920. if (rtlpriv->rtlhal.driver_is_goingto_unload ||
  921. rtlpriv->psc.rfoff_reason > RF_CHANGE_BY_PS)
  922. ret = true;
  923. if (hw_queue < BEACON_QUEUE) {
  924. if (!ret)
  925. stop_report_cnt++;
  926. else
  927. stop_report_cnt = 0;
  928. }
  929. return ret;
  930. }
  931. void rtl92ee_tx_polling(struct ieee80211_hw *hw, u8 hw_queue)
  932. {
  933. }