mds.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. #include "mds_f.h"
  2. #include "mto.h"
  3. #include "wbhal.h"
  4. #include "wb35tx_f.h"
  5. unsigned char
  6. Mds_initial(struct wbsoft_priv *adapter)
  7. {
  8. struct wb35_mds *pMds = &adapter->Mds;
  9. pMds->TxPause = false;
  10. pMds->TxRTSThreshold = DEFAULT_RTSThreshold;
  11. pMds->TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD;
  12. return hal_get_tx_buffer(&adapter->sHwData, &pMds->pTxBuffer);
  13. }
  14. static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *buffer)
  15. {
  16. struct T00_descriptor *pT00;
  17. struct T01_descriptor *pT01;
  18. u16 Duration, NextBodyLen, OffsetSize;
  19. u8 Rate, i;
  20. unsigned char CTS_on = false, RTS_on = false;
  21. struct T00_descriptor *pNextT00;
  22. u16 BodyLen = 0;
  23. unsigned char boGroupAddr = false;
  24. OffsetSize = pDes->FragmentThreshold + 32 + 3;
  25. OffsetSize &= ~0x03;
  26. Rate = pDes->TxRate >> 1;
  27. if (!Rate)
  28. Rate = 1;
  29. pT00 = (struct T00_descriptor *)buffer;
  30. pT01 = (struct T01_descriptor *)(buffer+4);
  31. pNextT00 = (struct T00_descriptor *)(buffer+OffsetSize);
  32. if (buffer[DOT_11_DA_OFFSET+8] & 0x1) /* +8 for USB hdr */
  33. boGroupAddr = true;
  34. /******************************************
  35. * Set RTS/CTS mechanism
  36. ******************************************/
  37. if (!boGroupAddr) {
  38. /* NOTE : If the protection mode is enabled and the MSDU will be fragmented,
  39. * the tx rates of MPDUs will all be DSSS rates. So it will not use
  40. * CTS-to-self in this case. CTS-To-self will only be used when without
  41. * fragmentation. -- 20050112 */
  42. BodyLen = (u16)pT00->T00_frame_length; /* include 802.11 header */
  43. BodyLen += 4; /* CRC */
  44. if (BodyLen >= CURRENT_RTS_THRESHOLD)
  45. RTS_on = true; /* Using RTS */
  46. else {
  47. if (pT01->T01_modulation_type) { /* Is using OFDM */
  48. if (CURRENT_PROTECT_MECHANISM) /* Is using protect */
  49. CTS_on = true; /* Using CTS */
  50. }
  51. }
  52. }
  53. if (RTS_on || CTS_on) {
  54. if (pT01->T01_modulation_type) { /* Is using OFDM */
  55. /* CTS duration
  56. * 2 SIFS + DATA transmit time + 1 ACK
  57. * ACK Rate : 24 Mega bps
  58. * ACK frame length = 14 bytes */
  59. Duration = 2*DEFAULT_SIFSTIME +
  60. 2*PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION +
  61. ((BodyLen*8 + 22 + Rate*4 - 1)/(Rate*4))*Tsym +
  62. ((112 + 22 + 95)/96)*Tsym;
  63. } else { /* DSSS */
  64. /* CTS duration
  65. * 2 SIFS + DATA transmit time + 1 ACK
  66. * Rate : ?? Mega bps
  67. * ACK frame length = 14 bytes */
  68. if (pT01->T01_plcp_header_length) /* long preamble */
  69. Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME*2;
  70. else
  71. Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME*2;
  72. Duration += (((BodyLen + 14)*8 + Rate-1) / Rate +
  73. DEFAULT_SIFSTIME*2);
  74. }
  75. if (RTS_on) {
  76. if (pT01->T01_modulation_type) { /* Is using OFDM */
  77. /* CTS + 1 SIFS + CTS duration
  78. * CTS Rate : 24 Mega bps
  79. * CTS frame length = 14 bytes */
  80. Duration += (DEFAULT_SIFSTIME +
  81. PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION +
  82. ((112 + 22 + 95)/96)*Tsym);
  83. } else {
  84. /* CTS + 1 SIFS + CTS duration
  85. * CTS Rate : ?? Mega bps
  86. * CTS frame length = 14 bytes */
  87. if (pT01->T01_plcp_header_length) /* long preamble */
  88. Duration += LONG_PREAMBLE_PLUS_PLCPHEADER_TIME;
  89. else
  90. Duration += SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME;
  91. Duration += (((112 + Rate-1) / Rate) + DEFAULT_SIFSTIME);
  92. }
  93. }
  94. /* Set the value into USB descriptor */
  95. pT01->T01_add_rts = RTS_on ? 1 : 0;
  96. pT01->T01_add_cts = CTS_on ? 1 : 0;
  97. pT01->T01_rts_cts_duration = Duration;
  98. }
  99. /******************************************
  100. * Fill the more fragment descriptor
  101. ******************************************/
  102. if (boGroupAddr)
  103. Duration = 0;
  104. else {
  105. for (i = pDes->FragmentCount-1; i > 0; i--) {
  106. NextBodyLen = (u16)pNextT00->T00_frame_length;
  107. NextBodyLen += 4; /* CRC */
  108. if (pT01->T01_modulation_type) {
  109. /* OFDM
  110. * data transmit time + 3 SIFS + 2 ACK
  111. * Rate : ??Mega bps
  112. * ACK frame length = 14 bytes, tx rate = 24M */
  113. Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION * 3;
  114. Duration += (((NextBodyLen*8 + 22 + Rate*4 - 1)/(Rate*4)) * Tsym +
  115. (((2*14)*8 + 22 + 95)/96)*Tsym +
  116. DEFAULT_SIFSTIME*3);
  117. } else {
  118. /* DSSS
  119. * data transmit time + 2 ACK + 3 SIFS
  120. * Rate : ??Mega bps
  121. * ACK frame length = 14 bytes
  122. * TODO : */
  123. if (pT01->T01_plcp_header_length) /* long preamble */
  124. Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME*3;
  125. else
  126. Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME*3;
  127. Duration += (((NextBodyLen + (2*14))*8 + Rate-1) / Rate +
  128. DEFAULT_SIFSTIME*3);
  129. }
  130. ((u16 *)buffer)[5] = cpu_to_le16(Duration); /* 4 USHOR for skip 8B USB, 2USHORT=FC + Duration */
  131. /* ----20061009 add by anson's endian */
  132. pNextT00->value = cpu_to_le32(pNextT00->value);
  133. pT01->value = cpu_to_le32(pT01->value);
  134. /* ----end 20061009 add by anson's endian */
  135. buffer += OffsetSize;
  136. pT01 = (struct T01_descriptor *)(buffer+4);
  137. if (i != 1) /* The last fragment will not have the next fragment */
  138. pNextT00 = (struct T00_descriptor *)(buffer+OffsetSize);
  139. }
  140. /*******************************************
  141. * Fill the last fragment descriptor
  142. *******************************************/
  143. if (pT01->T01_modulation_type) {
  144. /* OFDM
  145. * 1 SIFS + 1 ACK
  146. * Rate : 24 Mega bps
  147. * ACK frame length = 14 bytes */
  148. Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION;
  149. /* The Tx rate of ACK use 24M */
  150. Duration += (((112 + 22 + 95)/96)*Tsym + DEFAULT_SIFSTIME);
  151. } else {
  152. /* DSSS
  153. * 1 ACK + 1 SIFS
  154. * Rate : ?? Mega bps
  155. * ACK frame length = 14 bytes(112 bits) */
  156. if (pT01->T01_plcp_header_length) /* long preamble */
  157. Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME;
  158. else
  159. Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME;
  160. Duration += ((112 + Rate-1)/Rate + DEFAULT_SIFSTIME);
  161. }
  162. }
  163. ((u16 *)buffer)[5] = cpu_to_le16(Duration); /* 4 USHOR for skip 8B USB, 2USHORT=FC + Duration */
  164. pT00->value = cpu_to_le32(pT00->value);
  165. pT01->value = cpu_to_le32(pT01->value);
  166. /* --end 20061009 add */
  167. }
  168. /* The function return the 4n size of usb pk */
  169. static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer)
  170. {
  171. struct T00_descriptor *pT00;
  172. struct wb35_mds *pMds = &adapter->Mds;
  173. u8 *buffer;
  174. u8 *src_buffer;
  175. u8 *pctmp;
  176. u16 Size = 0;
  177. u16 SizeLeft, CopySize, CopyLeft, stmp;
  178. u8 buf_index, FragmentCount = 0;
  179. /* Copy fragment body */
  180. buffer = TargetBuffer; /* shift 8B usb + 24B 802.11 */
  181. SizeLeft = pDes->buffer_total_size;
  182. buf_index = pDes->buffer_start_index;
  183. pT00 = (struct T00_descriptor *)buffer;
  184. while (SizeLeft) {
  185. pT00 = (struct T00_descriptor *)buffer;
  186. CopySize = SizeLeft;
  187. if (SizeLeft > pDes->FragmentThreshold) {
  188. CopySize = pDes->FragmentThreshold;
  189. pT00->T00_frame_length = 24 + CopySize; /* Set USB length */
  190. } else
  191. pT00->T00_frame_length = 24 + SizeLeft; /* Set USB length */
  192. SizeLeft -= CopySize;
  193. /* 1 Byte operation */
  194. pctmp = (u8 *)(buffer + 8 + DOT_11_SEQUENCE_OFFSET);
  195. *pctmp &= 0xf0;
  196. *pctmp |= FragmentCount; /* 931130.5.m */
  197. if (!FragmentCount)
  198. pT00->T00_first_mpdu = 1;
  199. buffer += 32; /* 8B usb + 24B 802.11 header */
  200. Size += 32;
  201. /* Copy into buffer */
  202. stmp = CopySize + 3;
  203. stmp &= ~0x03; /* 4n Alignment */
  204. Size += stmp; /* Current 4n offset of mpdu */
  205. while (CopySize) {
  206. /* Copy body */
  207. src_buffer = pDes->buffer_address[buf_index];
  208. CopyLeft = CopySize;
  209. if (CopySize >= pDes->buffer_size[buf_index]) {
  210. CopyLeft = pDes->buffer_size[buf_index];
  211. /* Get the next buffer of descriptor */
  212. buf_index++;
  213. buf_index %= MAX_DESCRIPTOR_BUFFER_INDEX;
  214. } else {
  215. u8 *pctmp = pDes->buffer_address[buf_index];
  216. pctmp += CopySize;
  217. pDes->buffer_address[buf_index] = pctmp;
  218. pDes->buffer_size[buf_index] -= CopySize;
  219. }
  220. memcpy(buffer, src_buffer, CopyLeft);
  221. buffer += CopyLeft;
  222. CopySize -= CopyLeft;
  223. }
  224. /* 931130.5.n */
  225. if (pMds->MicAdd) {
  226. if (!SizeLeft) {
  227. pMds->MicWriteAddress[pMds->MicWriteIndex] = buffer - pMds->MicAdd;
  228. pMds->MicWriteSize[pMds->MicWriteIndex] = pMds->MicAdd;
  229. pMds->MicAdd = 0;
  230. } else if (SizeLeft < 8) { /* 931130.5.p */
  231. pMds->MicAdd = SizeLeft;
  232. pMds->MicWriteAddress[pMds->MicWriteIndex] = buffer - (8 - SizeLeft);
  233. pMds->MicWriteSize[pMds->MicWriteIndex] = 8 - SizeLeft;
  234. pMds->MicWriteIndex++;
  235. }
  236. }
  237. /* Does it need to generate the new header for next mpdu? */
  238. if (SizeLeft) {
  239. buffer = TargetBuffer + Size; /* Get the next 4n start address */
  240. memcpy(buffer, TargetBuffer, 32); /* Copy 8B USB +24B 802.11 */
  241. pT00 = (struct T00_descriptor *)buffer;
  242. pT00->T00_first_mpdu = 0;
  243. }
  244. FragmentCount++;
  245. }
  246. pT00->T00_last_mpdu = 1;
  247. pT00->T00_IsLastMpdu = 1;
  248. buffer = (u8 *)pT00 + 8; /* +8 for USB hdr */
  249. buffer[1] &= ~0x04; /* Clear more frag bit of 802.11 frame control */
  250. pDes->FragmentCount = FragmentCount; /* Update the correct fragment number */
  251. return Size;
  252. }
  253. static void Mds_HeaderCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer)
  254. {
  255. struct wb35_mds *pMds = &adapter->Mds;
  256. u8 *src_buffer = pDes->buffer_address[0]; /* 931130.5.g */
  257. struct T00_descriptor *pT00;
  258. struct T01_descriptor *pT01;
  259. u16 stmp;
  260. u8 i, ctmp1, ctmp2, ctmpf;
  261. u16 FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD;
  262. stmp = pDes->buffer_total_size;
  263. /*
  264. * Set USB header 8 byte
  265. */
  266. pT00 = (struct T00_descriptor *)TargetBuffer;
  267. TargetBuffer += 4;
  268. pT01 = (struct T01_descriptor *)TargetBuffer;
  269. TargetBuffer += 4;
  270. pT00->value = 0; /* Clear */
  271. pT01->value = 0; /* Clear */
  272. pT00->T00_tx_packet_id = pDes->Descriptor_ID; /* Set packet ID */
  273. pT00->T00_header_length = 24; /* Set header length */
  274. pT01->T01_retry_abort_ebable = 1; /* 921013 931130.5.h */
  275. /* Key ID setup */
  276. pT01->T01_wep_id = 0;
  277. FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; /* Do not fragment */
  278. /* Copy full data, the 1'st buffer contain all the data 931130.5.j */
  279. memcpy(TargetBuffer, src_buffer, DOT_11_MAC_HEADER_SIZE); /* Copy header */
  280. pDes->buffer_address[0] = src_buffer + DOT_11_MAC_HEADER_SIZE;
  281. pDes->buffer_total_size -= DOT_11_MAC_HEADER_SIZE;
  282. pDes->buffer_size[0] = pDes->buffer_total_size;
  283. /* Set fragment threshold */
  284. FragmentThreshold -= (DOT_11_MAC_HEADER_SIZE + 4);
  285. pDes->FragmentThreshold = FragmentThreshold;
  286. /* Set more frag bit */
  287. TargetBuffer[1] |= 0x04; /* Set more frag bit */
  288. /*
  289. * Set tx rate
  290. */
  291. stmp = *(u16 *)(TargetBuffer+30); /* 2n alignment address */
  292. /* Use basic rate */
  293. ctmp1 = ctmpf = CURRENT_TX_RATE_FOR_MNG;
  294. pDes->TxRate = ctmp1;
  295. pr_debug("Tx rate =%x\n", ctmp1);
  296. pT01->T01_modulation_type = (ctmp1%3) ? 0 : 1;
  297. for (i = 0; i < 2; i++) {
  298. if (i == 1)
  299. ctmp1 = ctmpf;
  300. pMds->TxRate[pDes->Descriptor_ID][i] = ctmp1; /* backup the ta rate and fall back rate */
  301. if (ctmp1 == 108)
  302. ctmp2 = 7;
  303. else if (ctmp1 == 96)
  304. ctmp2 = 6; /* Rate convert for USB */
  305. else if (ctmp1 == 72)
  306. ctmp2 = 5;
  307. else if (ctmp1 == 48)
  308. ctmp2 = 4;
  309. else if (ctmp1 == 36)
  310. ctmp2 = 3;
  311. else if (ctmp1 == 24)
  312. ctmp2 = 2;
  313. else if (ctmp1 == 18)
  314. ctmp2 = 1;
  315. else if (ctmp1 == 12)
  316. ctmp2 = 0;
  317. else if (ctmp1 == 22)
  318. ctmp2 = 3;
  319. else if (ctmp1 == 11)
  320. ctmp2 = 2;
  321. else if (ctmp1 == 4)
  322. ctmp2 = 1;
  323. else
  324. ctmp2 = 0; /* if( ctmp1 == 2 ) or default */
  325. if (i == 0)
  326. pT01->T01_transmit_rate = ctmp2;
  327. else
  328. pT01->T01_fall_back_rate = ctmp2;
  329. }
  330. /*
  331. * Set preamble type
  332. */
  333. if ((pT01->T01_modulation_type == 0) && (pT01->T01_transmit_rate == 0)) /* RATE_1M */
  334. pDes->PreambleMode = WLAN_PREAMBLE_TYPE_LONG;
  335. else
  336. pDes->PreambleMode = CURRENT_PREAMBLE_MODE;
  337. pT01->T01_plcp_header_length = pDes->PreambleMode; /* Set preamble */
  338. }
  339. static void MLME_GetNextPacket(struct wbsoft_priv *adapter, struct wb35_descriptor *desc)
  340. {
  341. desc->InternalUsed = desc->buffer_start_index + desc->buffer_number;
  342. desc->InternalUsed %= MAX_DESCRIPTOR_BUFFER_INDEX;
  343. desc->buffer_address[desc->InternalUsed] = adapter->sMlmeFrame.pMMPDU;
  344. desc->buffer_size[desc->InternalUsed] = adapter->sMlmeFrame.len;
  345. desc->buffer_total_size += adapter->sMlmeFrame.len;
  346. desc->buffer_number++;
  347. desc->Type = adapter->sMlmeFrame.DataType;
  348. }
  349. static void MLMEfreeMMPDUBuffer(struct wbsoft_priv *adapter, s8 *pData)
  350. {
  351. int i;
  352. /* Reclaim the data buffer */
  353. for (i = 0; i < MAX_NUM_TX_MMPDU; i++) {
  354. if (pData == (s8 *)&(adapter->sMlmeFrame.TxMMPDU[i]))
  355. break;
  356. }
  357. if (adapter->sMlmeFrame.TxMMPDUInUse[i])
  358. adapter->sMlmeFrame.TxMMPDUInUse[i] = false;
  359. else {
  360. /* Something wrong
  361. PD43 Add debug code here??? */
  362. }
  363. }
  364. static void MLME_SendComplete(struct wbsoft_priv *adapter, u8 PacketID, unsigned char SendOK)
  365. {
  366. /* Reclaim the data buffer */
  367. adapter->sMlmeFrame.len = 0;
  368. MLMEfreeMMPDUBuffer(adapter, adapter->sMlmeFrame.pMMPDU);
  369. /* Return resource */
  370. adapter->sMlmeFrame.IsInUsed = PACKET_FREE_TO_USE;
  371. }
  372. void
  373. Mds_Tx(struct wbsoft_priv *adapter)
  374. {
  375. struct hw_data *pHwData = &adapter->sHwData;
  376. struct wb35_mds *pMds = &adapter->Mds;
  377. struct wb35_descriptor TxDes;
  378. struct wb35_descriptor *pTxDes = &TxDes;
  379. u8 *XmitBufAddress;
  380. u16 XmitBufSize, PacketSize, stmp, CurrentSize, FragmentThreshold;
  381. u8 FillIndex, TxDesIndex, FragmentCount, FillCount;
  382. unsigned char BufferFilled = false;
  383. if (pMds->TxPause)
  384. return;
  385. if (!hal_driver_init_OK(pHwData))
  386. return;
  387. /* Only one thread can be run here */
  388. if (atomic_inc_return(&pMds->TxThreadCount) != 1)
  389. goto cleanup;
  390. /* Start to fill the data */
  391. do {
  392. FillIndex = pMds->TxFillIndex;
  393. if (pMds->TxOwner[FillIndex]) { /* Is owned by software 0:Yes 1:No */
  394. pr_debug("[Mds_Tx] Tx Owner is H/W.\n");
  395. break;
  396. }
  397. XmitBufAddress = pMds->pTxBuffer + (MAX_USB_TX_BUFFER * FillIndex); /* Get buffer */
  398. XmitBufSize = 0;
  399. FillCount = 0;
  400. do {
  401. PacketSize = adapter->sMlmeFrame.len;
  402. if (!PacketSize)
  403. break;
  404. /* For Check the buffer resource */
  405. FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD;
  406. /* 931130.5.b */
  407. FragmentCount = PacketSize/FragmentThreshold + 1;
  408. stmp = PacketSize + FragmentCount*32 + 8; /* 931130.5.c 8:MIC */
  409. if ((XmitBufSize + stmp) >= MAX_USB_TX_BUFFER) {
  410. printk("[Mds_Tx] Excess max tx buffer.\n");
  411. break; /* buffer is not enough */
  412. }
  413. /*
  414. * Start transmitting
  415. */
  416. BufferFilled = true;
  417. /* Leaves first u8 intact */
  418. memset((u8 *)pTxDes + 1, 0, sizeof(struct wb35_descriptor) - 1);
  419. TxDesIndex = pMds->TxDesIndex; /* Get the current ID */
  420. pTxDes->Descriptor_ID = TxDesIndex;
  421. pMds->TxDesFrom[TxDesIndex] = 2; /* Storing the information of source coming from */
  422. pMds->TxDesIndex++;
  423. pMds->TxDesIndex %= MAX_USB_TX_DESCRIPTOR;
  424. MLME_GetNextPacket(adapter, pTxDes);
  425. /* Copy header. 8byte USB + 24byte 802.11Hdr. Set TxRate, Preamble type */
  426. Mds_HeaderCopy(adapter, pTxDes, XmitBufAddress);
  427. /* For speed up Key setting */
  428. if (pTxDes->EapFix) {
  429. pr_debug("35: EPA 4th frame detected. Size = %d\n", PacketSize);
  430. pHwData->IsKeyPreSet = 1;
  431. }
  432. /* Copy (fragment) frame body, and set USB, 802.11 hdr flag */
  433. CurrentSize = Mds_BodyCopy(adapter, pTxDes, XmitBufAddress);
  434. /* Set RTS/CTS and Normal duration field into buffer */
  435. Mds_DurationSet(adapter, pTxDes, XmitBufAddress);
  436. /* Shift to the next address */
  437. XmitBufSize += CurrentSize;
  438. XmitBufAddress += CurrentSize;
  439. /* Get packet to transmit completed, 1:TESTSTA 2:MLME 3: Ndis data */
  440. MLME_SendComplete(adapter, 0, true);
  441. /* Software TSC count 20060214 */
  442. pMds->TxTsc++;
  443. if (pMds->TxTsc == 0)
  444. pMds->TxTsc_2++;
  445. FillCount++; /* 20060928 */
  446. } while (HAL_USB_MODE_BURST(pHwData)); /* End of multiple MSDU copy loop. false = single true = multiple sending */
  447. /* Move to the next one, if necessary */
  448. if (BufferFilled) {
  449. /* size setting */
  450. pMds->TxBufferSize[FillIndex] = XmitBufSize;
  451. /* 20060928 set Tx count */
  452. pMds->TxCountInBuffer[FillIndex] = FillCount;
  453. /* Set owner flag */
  454. pMds->TxOwner[FillIndex] = 1;
  455. pMds->TxFillIndex++;
  456. pMds->TxFillIndex %= MAX_USB_TX_BUFFER_NUMBER;
  457. BufferFilled = false;
  458. } else
  459. break;
  460. if (!PacketSize) /* No more pk for transmitting */
  461. break;
  462. } while (true);
  463. /*
  464. * Start to send by lower module
  465. */
  466. if (!pHwData->IsKeyPreSet)
  467. Wb35Tx_start(adapter);
  468. cleanup:
  469. atomic_dec(&pMds->TxThreadCount);
  470. }
  471. void
  472. Mds_SendComplete(struct wbsoft_priv *adapter, struct T02_descriptor *pT02)
  473. {
  474. struct wb35_mds *pMds = &adapter->Mds;
  475. struct hw_data *pHwData = &adapter->sHwData;
  476. u8 PacketId = (u8)pT02->T02_Tx_PktID;
  477. unsigned char SendOK = true;
  478. u8 RetryCount, TxRate;
  479. if (pT02->T02_IgnoreResult) /* Don't care the result */
  480. return;
  481. if (pT02->T02_IsLastMpdu) {
  482. /* TODO: DTO -- get the retry count and fragment count */
  483. /* Tx rate */
  484. TxRate = pMds->TxRate[PacketId][0];
  485. RetryCount = (u8)pT02->T02_MPDU_Cnt;
  486. if (pT02->value & FLAG_ERROR_TX_MASK) {
  487. SendOK = false;
  488. if (pT02->T02_transmit_abort || pT02->T02_out_of_MaxTxMSDULiftTime) {
  489. /* retry error */
  490. pHwData->dto_tx_retry_count += (RetryCount+1);
  491. /* [for tx debug] */
  492. if (RetryCount < 7)
  493. pHwData->tx_retry_count[RetryCount] += RetryCount;
  494. else
  495. pHwData->tx_retry_count[7] += RetryCount;
  496. pr_debug("dto_tx_retry_count =%d\n", pHwData->dto_tx_retry_count);
  497. MTO_SetTxCount(adapter, TxRate, RetryCount);
  498. }
  499. pHwData->dto_tx_frag_count += (RetryCount+1);
  500. /* [for tx debug] */
  501. if (pT02->T02_transmit_abort_due_to_TBTT)
  502. pHwData->tx_TBTT_start_count++;
  503. if (pT02->T02_transmit_without_encryption_due_to_wep_on_false)
  504. pHwData->tx_WepOn_false_count++;
  505. if (pT02->T02_discard_due_to_null_wep_key)
  506. pHwData->tx_Null_key_count++;
  507. } else {
  508. if (pT02->T02_effective_transmission_rate)
  509. pHwData->tx_ETR_count++;
  510. MTO_SetTxCount(adapter, TxRate, RetryCount);
  511. }
  512. /* Clear send result buffer */
  513. pMds->TxResult[PacketId] = 0;
  514. } else
  515. pMds->TxResult[PacketId] |= ((u16)(pT02->value & 0x0ffff));
  516. }