Commit | Line | Data |
---|---|---|
8fc8598e | 1 | /****************************************************************************** |
6df9f669 XR |
2 | * |
3 | * (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved. | |
4 | * | |
5 | * Module: r819xusb_cmdpkt.c | |
6 | * (RTL8190 TX/RX command packet handler Source C File) | |
7 | * | |
8 | * Note: The module is responsible for handling TX and RX command packet. | |
9 | * 1. TX : Send set and query configuration command packet. | |
10 | * 2. RX : Receive tx feedback, beacon state, query configuration | |
11 | * command packet. | |
12 | * | |
13 | * Function: | |
14 | * | |
15 | * Export: | |
16 | * | |
17 | * Abbrev: | |
18 | * | |
19 | * History: | |
20 | * | |
21 | * Date Who Remark | |
22 | * 05/06/2008 amy Create initial version porting from | |
23 | * windows driver. | |
24 | * | |
25 | ******************************************************************************/ | |
8fc8598e JC |
26 | #include "r8192U.h" |
27 | #include "r819xU_cmdpkt.h" | |
6df9f669 | 28 | |
fa6b108b | 29 | rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) |
8fc8598e | 30 | { |
8fc8598e JC |
31 | struct r8192_priv *priv = ieee80211_priv(dev); |
32 | struct sk_buff *skb; | |
33 | cb_desc *tcb_desc; | |
34 | unsigned char *ptr_buf; | |
8fc8598e | 35 | |
6df9f669 XR |
36 | /* Get TCB and local buffer from common pool. |
37 | (It is shared by CmdQ, MgntQ, and USB coalesce DataQ) */ | |
8fc8598e | 38 | skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + DataLen + 4); |
c3aed231 IP |
39 | if (!skb) |
40 | return RT_STATUS_FAILURE; | |
fa6b108b | 41 | memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); |
9772acad | 42 | tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); |
8fc8598e JC |
43 | tcb_desc->queue_index = TXCMD_QUEUE; |
44 | tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_NORMAL; | |
45 | tcb_desc->bLastIniPkt = 0; | |
46 | skb_reserve(skb, USB_HWDESC_HEADER_LEN); | |
47 | ptr_buf = skb_put(skb, DataLen); | |
fa6b108b XR |
48 | memcpy(ptr_buf, pData, DataLen); |
49 | tcb_desc->txbuf_size = (u16)DataLen; | |
8fc8598e | 50 | |
fa6b108b | 51 | if (!priv->ieee80211->check_nic_enough_desc(dev, tcb_desc->queue_index) || |
f70edb9f XR |
52 | (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) || |
53 | (priv->ieee80211->queue_stop)) { | |
54 | RT_TRACE(COMP_FIRMWARE, "=== NULL packet ======> tx full!\n"); | |
55 | skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); | |
56 | } else { | |
57 | priv->ieee80211->softmac_hard_start_xmit(skb, dev); | |
58 | } | |
8fc8598e | 59 | |
4764ca98 | 60 | return RT_STATUS_SUCCESS; |
8fc8598e JC |
61 | } |
62 | ||
8fc8598e JC |
63 | /*----------------------------------------------------------------------------- |
64 | * Function: cmpk_counttxstatistic() | |
65 | * | |
66 | * Overview: | |
67 | * | |
6df9f669 XR |
68 | * Input: PADAPTER pAdapter |
69 | * CMPK_TXFB_T *psTx_FB | |
8fc8598e JC |
70 | * |
71 | * Output: NONE | |
72 | * | |
73 | * Return: NONE | |
74 | * | |
75 | * Revised History: | |
6df9f669 XR |
76 | * When Who Remark |
77 | * 05/12/2008 amy Create Version 0 porting from windows code. | |
8fc8598e JC |
78 | * |
79 | *---------------------------------------------------------------------------*/ | |
fa6b108b | 80 | static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb) |
8fc8598e JC |
81 | { |
82 | struct r8192_priv *priv = ieee80211_priv(dev); | |
83 | #ifdef ENABLE_PS | |
84 | RT_RF_POWER_STATE rtState; | |
85 | ||
f70edb9f XR |
86 | pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, |
87 | (pu1Byte)(&rtState)); | |
8fc8598e | 88 | |
6df9f669 XR |
89 | /* When RF is off, we should not count the packet for hw/sw synchronize |
90 | reason, ie. there may be a duration while sw switch is changed and | |
91 | hw switch is being changed. */ | |
8fc8598e | 92 | if (rtState == eRfOff) |
8fc8598e | 93 | return; |
8fc8598e JC |
94 | #endif |
95 | ||
96 | #ifdef TODO | |
a71d7679 | 97 | if (pAdapter->bInHctTest) |
8fc8598e JC |
98 | return; |
99 | #endif | |
6df9f669 XR |
100 | /* We can not know the packet length and transmit type: |
101 | broadcast or uni or multicast. So the relative statistics | |
102 | must be collected in tx feedback info. */ | |
05cdf47a | 103 | if (pstx_fb->tok) { |
8fc8598e JC |
104 | priv->stats.txfeedbackok++; |
105 | priv->stats.txoktotal++; | |
106 | priv->stats.txokbytestotal += pstx_fb->pkt_length; | |
107 | priv->stats.txokinperiod++; | |
108 | ||
109 | /* We can not make sure broadcast/multicast or unicast mode. */ | |
05cdf47a | 110 | if (pstx_fb->pkt_type == PACKET_MULTICAST) { |
8fc8598e JC |
111 | priv->stats.txmulticast++; |
112 | priv->stats.txbytesmulticast += pstx_fb->pkt_length; | |
05cdf47a | 113 | } else if (pstx_fb->pkt_type == PACKET_BROADCAST) { |
8fc8598e JC |
114 | priv->stats.txbroadcast++; |
115 | priv->stats.txbytesbroadcast += pstx_fb->pkt_length; | |
05cdf47a | 116 | } else { |
8fc8598e JC |
117 | priv->stats.txunicast++; |
118 | priv->stats.txbytesunicast += pstx_fb->pkt_length; | |
119 | } | |
05cdf47a | 120 | } else { |
8fc8598e JC |
121 | priv->stats.txfeedbackfail++; |
122 | priv->stats.txerrtotal++; | |
123 | priv->stats.txerrbytestotal += pstx_fb->pkt_length; | |
124 | ||
125 | /* We can not make sure broadcast/multicast or unicast mode. */ | |
126 | if (pstx_fb->pkt_type == PACKET_MULTICAST) | |
8fc8598e | 127 | priv->stats.txerrmulticast++; |
8fc8598e | 128 | else if (pstx_fb->pkt_type == PACKET_BROADCAST) |
8fc8598e | 129 | priv->stats.txerrbroadcast++; |
8fc8598e | 130 | else |
8fc8598e | 131 | priv->stats.txerrunicast++; |
8fc8598e JC |
132 | } |
133 | ||
134 | priv->stats.txretrycount += pstx_fb->retry_cnt; | |
135 | priv->stats.txfeedbackretry += pstx_fb->retry_cnt; | |
136 | ||
6df9f669 | 137 | } |
8fc8598e JC |
138 | |
139 | ||
140 | ||
141 | /*----------------------------------------------------------------------------- | |
142 | * Function: cmpk_handle_tx_feedback() | |
143 | * | |
144 | * Overview: The function is responsible for extract the message inside TX | |
6df9f669 XR |
145 | * feedbck message from firmware. It will contain dedicated info in |
146 | * ws-06-0063-rtl8190-command-packet-specification. | |
147 | * Please refer to chapter "TX Feedback Element". | |
148 | * We have to read 20 bytes in the command packet. | |
8fc8598e | 149 | * |
6df9f669 XR |
150 | * Input: struct net_device *dev |
151 | * u8 *pmsg - Msg Ptr of the command packet. | |
8fc8598e JC |
152 | * |
153 | * Output: NONE | |
154 | * | |
155 | * Return: NONE | |
156 | * | |
157 | * Revised History: | |
6df9f669 XR |
158 | * When Who Remark |
159 | * 05/08/2008 amy Create Version 0 porting from windows code. | |
8fc8598e JC |
160 | * |
161 | *---------------------------------------------------------------------------*/ | |
fa6b108b | 162 | static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) |
8fc8598e JC |
163 | { |
164 | struct r8192_priv *priv = ieee80211_priv(dev); | |
6df9f669 | 165 | cmpk_txfb_t rx_tx_fb; |
8fc8598e JC |
166 | |
167 | priv->stats.txfeedback++; | |
168 | ||
8fc8598e JC |
169 | /* 1. Extract TX feedback info from RFD to temp structure buffer. */ |
170 | /* It seems that FW use big endian(MIPS) and DRV use little endian in | |
171 | windows OS. So we have to read the content byte by byte or transfer | |
172 | endian type before copy the message copy. */ | |
6df9f669 | 173 | /* Use pointer to transfer structure memory. */ |
9772acad | 174 | memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t)); |
8fc8598e JC |
175 | /* 2. Use tx feedback info to count TX statistics. */ |
176 | cmpk_count_txstatistic(dev, &rx_tx_fb); | |
6df9f669 | 177 | /* Comment previous method for TX statistic function. */ |
8fc8598e JC |
178 | /* Collect info TX feedback packet to fill TCB. */ |
179 | /* We can not know the packet length and transmit type: broadcast or uni | |
180 | or multicast. */ | |
8fc8598e | 181 | |
6df9f669 | 182 | } |
8fc8598e | 183 | |
9e93d7ad | 184 | static void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) |
8fc8598e JC |
185 | { |
186 | struct r8192_priv *priv = ieee80211_priv(dev); | |
187 | u16 tx_rate; | |
6df9f669 | 188 | /* 87B have to S/W beacon for DTM encryption_cmn. */ |
fa6b108b | 189 | if (priv->ieee80211->current_network.mode == IEEE_A || |
8fc8598e | 190 | priv->ieee80211->current_network.mode == IEEE_N_5G || |
f70edb9f XR |
191 | (priv->ieee80211->current_network.mode == IEEE_N_24G && |
192 | (!priv->ieee80211->pHTInfo->bCurSuppCCK))) { | |
8fc8598e JC |
193 | tx_rate = 60; |
194 | DMESG("send beacon frame tx rate is 6Mbpm\n"); | |
05cdf47a | 195 | } else { |
fa6b108b | 196 | tx_rate = 10; |
8fc8598e JC |
197 | DMESG("send beacon frame tx rate is 1Mbpm\n"); |
198 | } | |
199 | ||
6df9f669 | 200 | rtl819xusb_beacon_tx(dev, tx_rate); /* HW Beacon */ |
8fc8598e | 201 | |
8fc8598e JC |
202 | |
203 | } | |
204 | ||
205 | ||
206 | ||
207 | ||
208 | /*----------------------------------------------------------------------------- | |
209 | * Function: cmpk_handle_interrupt_status() | |
210 | * | |
211 | * Overview: The function is responsible for extract the message from | |
6df9f669 XR |
212 | * firmware. It will contain dedicated info in |
213 | * ws-07-0063-v06-rtl819x-command-packet-specification-070315.doc. | |
214 | * Please refer to chapter "Interrupt Status Element". | |
8fc8598e | 215 | * |
6df9f669 XR |
216 | * Input: struct net_device *dev |
217 | * u8 *pmsg - Message Pointer of the command packet. | |
8fc8598e JC |
218 | * |
219 | * Output: NONE | |
220 | * | |
221 | * Return: NONE | |
222 | * | |
223 | * Revised History: | |
6df9f669 XR |
224 | * When Who Remark |
225 | * 05/12/2008 amy Add this for rtl8192 porting from windows code. | |
8fc8598e JC |
226 | * |
227 | *---------------------------------------------------------------------------*/ | |
fa6b108b | 228 | static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) |
8fc8598e JC |
229 | { |
230 | cmpk_intr_sta_t rx_intr_status; /* */ | |
231 | struct r8192_priv *priv = ieee80211_priv(dev); | |
232 | ||
233 | DMESG("---> cmpk_Handle_Interrupt_Status()\n"); | |
234 | ||
8fc8598e JC |
235 | /* 1. Extract TX feedback info from RFD to temp structure buffer. */ |
236 | /* It seems that FW use big endian(MIPS) and DRV use little endian in | |
237 | windows OS. So we have to read the content byte by byte or transfer | |
238 | endian type before copy the message copy. */ | |
8fc8598e | 239 | rx_intr_status.length = pmsg[1]; |
05cdf47a | 240 | if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) { |
8fc8598e JC |
241 | DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n"); |
242 | return; | |
243 | } | |
244 | ||
245 | ||
6df9f669 | 246 | /* Statistics of beacon for ad-hoc mode. */ |
fa6b108b | 247 | if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) { |
6df9f669 | 248 | /* 2 maybe need endian transform? */ |
8fc8598e | 249 | rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); |
8fc8598e | 250 | |
f70edb9f XR |
251 | DMESG("interrupt status = 0x%x\n", |
252 | rx_intr_status.interrupt_status); | |
8fc8598e | 253 | |
05cdf47a | 254 | if (rx_intr_status.interrupt_status & ISR_TxBcnOk) { |
8fc8598e JC |
255 | priv->ieee80211->bibsscoordinator = true; |
256 | priv->stats.txbeaconokint++; | |
05cdf47a | 257 | } else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) { |
8fc8598e JC |
258 | priv->ieee80211->bibsscoordinator = false; |
259 | priv->stats.txbeaconerr++; | |
260 | } | |
261 | ||
262 | if (rx_intr_status.interrupt_status & ISR_BcnTimerIntr) | |
8fc8598e | 263 | cmdpkt_beacontimerinterrupt_819xusb(dev); |
8fc8598e JC |
264 | |
265 | } | |
266 | ||
6df9f669 | 267 | /* Other informations in interrupt status we need? */ |
8fc8598e JC |
268 | |
269 | ||
270 | DMESG("<---- cmpk_handle_interrupt_status()\n"); | |
271 | ||
6df9f669 | 272 | } |
8fc8598e JC |
273 | |
274 | ||
275 | /*----------------------------------------------------------------------------- | |
276 | * Function: cmpk_handle_query_config_rx() | |
277 | * | |
278 | * Overview: The function is responsible for extract the message from | |
6df9f669 XR |
279 | * firmware. It will contain dedicated info in |
280 | * ws-06-0063-rtl8190-command-packet-specification. Please | |
281 | * refer to chapter "Beacon State Element". | |
8fc8598e | 282 | * |
6df9f669 | 283 | * Input: u8 *pmsg - Message Pointer of the command packet. |
8fc8598e JC |
284 | * |
285 | * Output: NONE | |
286 | * | |
287 | * Return: NONE | |
288 | * | |
289 | * Revised History: | |
6df9f669 XR |
290 | * When Who Remark |
291 | * 05/12/2008 amy Create Version 0 porting from windows code. | |
8fc8598e JC |
292 | * |
293 | *---------------------------------------------------------------------------*/ | |
fa6b108b | 294 | static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg) |
8fc8598e | 295 | { |
6df9f669 | 296 | cmpk_query_cfg_t rx_query_cfg; |
8fc8598e | 297 | |
8fc8598e JC |
298 | |
299 | /* 1. Extract TX feedback info from RFD to temp structure buffer. */ | |
300 | /* It seems that FW use big endian(MIPS) and DRV use little endian in | |
301 | windows OS. So we have to read the content byte by byte or transfer | |
302 | endian type before copy the message copy. */ | |
fa6b108b | 303 | rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000) >> 31; |
35997ff0 SH |
304 | rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; |
305 | rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; | |
306 | rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; | |
fa6b108b XR |
307 | rx_query_cfg.cfg_offset = pmsg[7]; |
308 | rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | | |
309 | (pmsg[10] << 8) | (pmsg[11] << 0); | |
310 | rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | | |
311 | (pmsg[14] << 8) | (pmsg[15] << 0); | |
8fc8598e | 312 | |
6df9f669 | 313 | } |
8fc8598e JC |
314 | |
315 | ||
316 | /*----------------------------------------------------------------------------- | |
317 | * Function: cmpk_count_tx_status() | |
318 | * | |
319 | * Overview: Count aggregated tx status from firmwar of one type rx command | |
6df9f669 | 320 | * packet element id = RX_TX_STATUS. |
8fc8598e | 321 | * |
6df9f669 | 322 | * Input: NONE |
8fc8598e | 323 | * |
6df9f669 | 324 | * Output: NONE |
8fc8598e | 325 | * |
6df9f669 | 326 | * Return: NONE |
8fc8598e JC |
327 | * |
328 | * Revised History: | |
6df9f669 XR |
329 | * When Who Remark |
330 | * 05/12/2008 amy Create Version 0 porting from windows code. | |
8fc8598e JC |
331 | * |
332 | *---------------------------------------------------------------------------*/ | |
fa6b108b XR |
333 | static void cmpk_count_tx_status(struct net_device *dev, |
334 | cmpk_tx_status_t *pstx_status) | |
8fc8598e JC |
335 | { |
336 | struct r8192_priv *priv = ieee80211_priv(dev); | |
337 | ||
338 | #ifdef ENABLE_PS | |
339 | ||
340 | RT_RF_POWER_STATE rtstate; | |
341 | ||
f70edb9f XR |
342 | pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, |
343 | (pu1Byte)(&rtState)); | |
8fc8598e | 344 | |
6df9f669 XR |
345 | /* When RF is off, we should not count the packet for hw/sw synchronize |
346 | reason, ie. there may be a duration while sw switch is changed and | |
347 | hw switch is being changed. */ | |
8fc8598e | 348 | if (rtState == eRfOff) |
8fc8598e | 349 | return; |
8fc8598e JC |
350 | #endif |
351 | ||
352 | priv->stats.txfeedbackok += pstx_status->txok; | |
353 | priv->stats.txoktotal += pstx_status->txok; | |
354 | ||
355 | priv->stats.txfeedbackfail += pstx_status->txfail; | |
356 | priv->stats.txerrtotal += pstx_status->txfail; | |
357 | ||
fa6b108b | 358 | priv->stats.txretrycount += pstx_status->txretry; |
8fc8598e JC |
359 | priv->stats.txfeedbackretry += pstx_status->txretry; |
360 | ||
8fc8598e | 361 | |
fa6b108b XR |
362 | priv->stats.txmulticast += pstx_status->txmcok; |
363 | priv->stats.txbroadcast += pstx_status->txbcok; | |
8fc8598e JC |
364 | priv->stats.txunicast += pstx_status->txucok; |
365 | ||
366 | priv->stats.txerrmulticast += pstx_status->txmcfail; | |
367 | priv->stats.txerrbroadcast += pstx_status->txbcfail; | |
368 | priv->stats.txerrunicast += pstx_status->txucfail; | |
369 | ||
370 | priv->stats.txbytesmulticast += pstx_status->txmclength; | |
371 | priv->stats.txbytesbroadcast += pstx_status->txbclength; | |
fa6b108b | 372 | priv->stats.txbytesunicast += pstx_status->txuclength; |
8fc8598e | 373 | |
fa6b108b | 374 | priv->stats.last_packet_rate = pstx_status->rate; |
6df9f669 | 375 | } |
8fc8598e JC |
376 | |
377 | ||
378 | ||
379 | /*----------------------------------------------------------------------------- | |
380 | * Function: cmpk_handle_tx_status() | |
381 | * | |
382 | * Overview: Firmware add a new tx feedback status to reduce rx command | |
6df9f669 | 383 | * packet buffer operation load. |
8fc8598e JC |
384 | * |
385 | * Input: NONE | |
386 | * | |
387 | * Output: NONE | |
388 | * | |
389 | * Return: NONE | |
390 | * | |
391 | * Revised History: | |
6df9f669 XR |
392 | * When Who Remark |
393 | * 05/12/2008 amy Create Version 0 porting from windows code. | |
8fc8598e JC |
394 | * |
395 | *---------------------------------------------------------------------------*/ | |
fa6b108b | 396 | static void cmpk_handle_tx_status(struct net_device *dev, u8 *pmsg) |
8fc8598e | 397 | { |
6df9f669 | 398 | cmpk_tx_status_t rx_tx_sts; |
8fc8598e | 399 | |
9772acad | 400 | memcpy((void *)&rx_tx_sts, (void *)pmsg, sizeof(cmpk_tx_status_t)); |
8fc8598e JC |
401 | /* 2. Use tx feedback info to count TX statistics. */ |
402 | cmpk_count_tx_status(dev, &rx_tx_sts); | |
403 | ||
6df9f669 | 404 | } |
8fc8598e JC |
405 | |
406 | ||
407 | /*----------------------------------------------------------------------------- | |
408 | * Function: cmpk_handle_tx_rate_history() | |
409 | * | |
410 | * Overview: Firmware add a new tx rate history | |
411 | * | |
412 | * Input: NONE | |
413 | * | |
414 | * Output: NONE | |
415 | * | |
416 | * Return: NONE | |
417 | * | |
418 | * Revised History: | |
6df9f669 XR |
419 | * When Who Remark |
420 | * 05/12/2008 amy Create Version 0 porting from windows code. | |
8fc8598e JC |
421 | * |
422 | *---------------------------------------------------------------------------*/ | |
fa6b108b | 423 | static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) |
8fc8598e JC |
424 | { |
425 | cmpk_tx_rahis_t *ptxrate; | |
fa6b108b XR |
426 | u8 i, j; |
427 | u16 length = sizeof(cmpk_tx_rahis_t); | |
428 | u32 *ptemp; | |
8fc8598e JC |
429 | struct r8192_priv *priv = ieee80211_priv(dev); |
430 | ||
431 | ||
432 | #ifdef ENABLE_PS | |
f70edb9f XR |
433 | pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, |
434 | (pu1Byte)(&rtState)); | |
8fc8598e | 435 | |
6df9f669 XR |
436 | /* When RF is off, we should not count the packet for hw/sw synchronize |
437 | reason, ie. there may be a duration while sw switch is changed and | |
438 | hw switch is being changed. */ | |
8fc8598e | 439 | if (rtState == eRfOff) |
8fc8598e | 440 | return; |
8fc8598e JC |
441 | #endif |
442 | ||
443 | ptemp = (u32 *)pmsg; | |
444 | ||
6df9f669 XR |
445 | /* Do endian transfer to word alignment(16 bits) for windows system. |
446 | You must do different endian transfer for linux and MAC OS */ | |
05cdf47a | 447 | for (i = 0; i < (length/4); i++) { |
8fc8598e JC |
448 | u16 temp1, temp2; |
449 | ||
fa6b108b XR |
450 | temp1 = ptemp[i] & 0x0000FFFF; |
451 | temp2 = ptemp[i] >> 16; | |
452 | ptemp[i] = (temp1 << 16) | temp2; | |
8fc8598e JC |
453 | } |
454 | ||
455 | ptxrate = (cmpk_tx_rahis_t *)pmsg; | |
456 | ||
fa6b108b | 457 | if (ptxrate == NULL) |
8fc8598e | 458 | return; |
8fc8598e | 459 | |
05cdf47a | 460 | for (i = 0; i < 16; i++) { |
6df9f669 | 461 | /* Collect CCK rate packet num */ |
8fc8598e JC |
462 | if (i < 4) |
463 | priv->stats.txrate.cck[i] += ptxrate->cck[i]; | |
464 | ||
6df9f669 | 465 | /* Collect OFDM rate packet num */ |
fa6b108b | 466 | if (i < 8) |
8fc8598e JC |
467 | priv->stats.txrate.ofdm[i] += ptxrate->ofdm[i]; |
468 | ||
469 | for (j = 0; j < 4; j++) | |
470 | priv->stats.txrate.ht_mcs[j][i] += ptxrate->ht_mcs[j][i]; | |
471 | } | |
472 | ||
6df9f669 | 473 | } |
8fc8598e JC |
474 | |
475 | ||
476 | /*----------------------------------------------------------------------------- | |
477 | * Function: cmpk_message_handle_rx() | |
478 | * | |
479 | * Overview: In the function, we will capture different RX command packet | |
6df9f669 XR |
480 | * info. Every RX command packet element has different message |
481 | * length and meaning in content. We only support three type of RX | |
482 | * command packet now. Please refer to document | |
483 | * ws-06-0063-rtl8190-command-packet-specification. | |
8fc8598e JC |
484 | * |
485 | * Input: NONE | |
486 | * | |
487 | * Output: NONE | |
488 | * | |
489 | * Return: NONE | |
490 | * | |
491 | * Revised History: | |
6df9f669 XR |
492 | * When Who Remark |
493 | * 05/06/2008 amy Create Version 0 porting from windows code. | |
8fc8598e JC |
494 | * |
495 | *---------------------------------------------------------------------------*/ | |
a115ee41 TB |
496 | u32 cmpk_message_handle_rx(struct net_device *dev, |
497 | struct ieee80211_rx_stats *pstats) | |
8fc8598e | 498 | { |
8fc8598e JC |
499 | int total_length; |
500 | u8 cmd_length, exe_cnt = 0; | |
501 | u8 element_id; | |
502 | u8 *pcmd_buff; | |
503 | ||
6df9f669 XR |
504 | /* 0. Check inpt arguments. If is is a command queue message or |
505 | pointer is null. */ | |
fa6b108b | 506 | if (pstats == NULL) |
8fc8598e | 507 | return 0; /* This is not a command packet. */ |
8fc8598e JC |
508 | |
509 | /* 1. Read received command packet message length from RFD. */ | |
510 | total_length = pstats->Length; | |
511 | ||
512 | /* 2. Read virtual address from RFD. */ | |
513 | pcmd_buff = pstats->virtual_address; | |
514 | ||
589b3d06 | 515 | /* 3. Read command packet element id and length. */ |
8fc8598e | 516 | element_id = pcmd_buff[0]; |
8fc8598e | 517 | |
589b3d06 | 518 | /* 4. Check every received command packet content according to different |
6df9f669 XR |
519 | element type. Because FW may aggregate RX command packet to |
520 | minimize transmit time between DRV and FW.*/ | |
521 | /* Add a counter to prevent the lock in the loop from being held too | |
522 | long */ | |
05cdf47a | 523 | while (total_length > 0 && exe_cnt++ < 100) { |
6df9f669 | 524 | /* We support aggregation of different cmd in the same packet */ |
8fc8598e JC |
525 | element_id = pcmd_buff[0]; |
526 | ||
05cdf47a | 527 | switch (element_id) { |
f70edb9f XR |
528 | case RX_TX_FEEDBACK: |
529 | cmpk_handle_tx_feedback(dev, pcmd_buff); | |
530 | cmd_length = CMPK_RX_TX_FB_SIZE; | |
531 | break; | |
532 | ||
533 | case RX_INTERRUPT_STATUS: | |
534 | cmpk_handle_interrupt_status(dev, pcmd_buff); | |
535 | cmd_length = sizeof(cmpk_intr_sta_t); | |
536 | break; | |
537 | ||
538 | case BOTH_QUERY_CONFIG: | |
539 | cmpk_handle_query_config_rx(dev, pcmd_buff); | |
540 | cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; | |
541 | break; | |
542 | ||
543 | case RX_TX_STATUS: | |
544 | cmpk_handle_tx_status(dev, pcmd_buff); | |
545 | cmd_length = CMPK_RX_TX_STS_SIZE; | |
546 | break; | |
547 | ||
548 | case RX_TX_PER_PKT_FEEDBACK: | |
549 | /* You must at lease add a switch case element here, | |
550 | Otherwise, we will jump to default case. */ | |
551 | cmd_length = CMPK_RX_TX_FB_SIZE; | |
552 | break; | |
553 | ||
554 | case RX_TX_RATE_HISTORY: | |
555 | cmpk_handle_tx_rate_history(dev, pcmd_buff); | |
556 | cmd_length = CMPK_TX_RAHIS_SIZE; | |
557 | break; | |
558 | ||
559 | default: | |
560 | ||
561 | RT_TRACE(COMP_ERR, "---->%s():unknown CMD Element\n", | |
562 | __func__); | |
563 | return 1; /* This is a command packet. */ | |
8fc8598e | 564 | } |
8fc8598e | 565 | |
8fc8598e JC |
566 | total_length -= cmd_length; |
567 | pcmd_buff += cmd_length; | |
f2a04351 | 568 | } |
8fc8598e JC |
569 | return 1; /* This is a command packet. */ |
570 | ||
6df9f669 | 571 | } |