2 * Copyright (c) 2000-2005 ZyDAS Technology Corporation
3 * Copyright (c) 2007-2008 Atheros Communications Inc.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 /* Module Name : ud.c */
21 /* This module contains USB descriptor functions. */
26 /************************************************************************/
27 #include "../80211core/cprecomp.h"
31 extern void zfwUsbCmd(zdev_t
* dev
, u8_t endpt
, u32_t
* cmd
, u16_t cmdLen
);
33 extern void zfIdlRsp(zdev_t
* dev
, u32_t
* rsp
, u16_t rspLen
);
34 extern u16_t
zfDelayWriteInternalReg(zdev_t
* dev
, u32_t addr
, u32_t val
);
35 extern u16_t
zfFlushDelayWrite(zdev_t
* dev
);
38 #define USB_ENDPOINT_TX_INDEX 1
39 #define USB_ENDPOINT_RX_INDEX 2
40 #define USB_ENDPOINT_INT_INDEX 3
41 #define USB_ENDPOINT_CMD_INDEX 4
43 void zfIdlCmd(zdev_t
* dev
, u32_t
* cmd
, u16_t cmdLen
)
45 #if ZM_SW_LOOP_BACK != 1
46 zfwUsbCmd(dev
, USB_ENDPOINT_CMD_INDEX
, cmd
, cmdLen
);
53 /* zfAdjustCtrlSetting: fit OUTS format */
54 /* convert MIMO2 to OUTS */
55 void zfAdjustCtrlSetting(zdev_t
* dev
, u16_t
* header
, zbuf_t
* buf
)
57 /* MIMO2 => OUTS FB-50 */
58 /* length not change, only modify format */
67 struct zsHpPriv
* hpPriv
;
69 zmw_get_wlan_dev(dev
);
75 oldPhyCtrl
= zmw_buf_readh(dev
, buf
, 4) | ((u32_t
)zmw_buf_readh(dev
, buf
, 6) << 16);
79 oldPhyCtrl
= header
[2] | ((u32_t
)header
[3] <<16);
86 oldMT
= oldPhyCtrl
&0x3;
88 if ( oldMT
== 0x3 ) /* DL-OFDM (Duplicate Legacy OFDM) */
92 /* PT : Bit[2] HT PT: 0 Mixed mode 1 Green field */
93 phyCtrl
|= (oldPhyCtrl
&0x4);
95 /* Bandwidth control : Bit[4~3] */
96 if ( oldPhyCtrl
&0x800000 ) /* Bit23 : 40M */
99 if (oldMT
== 0x3) /* DL-OFDM */
100 phyCtrl
|= (0x3<<3); /* 40M duplicate */
102 phyCtrl
|= (0x2<<3); /* 40M shared */
104 if (oldMT
== 0x2 && ((struct zsHpPriv
*)wd
->hpPrivate
)->hwBw40
)
106 phyCtrl
|= (0x2<<3); /* 40M shared */
111 oldPhyCtrl
&= ~0x80000000;
114 /* MCS : Bit[24~18] */
115 oldMCS
= (oldPhyCtrl
&0x7f0000)>>16; /* Bit[22~16] */
116 phyCtrl
|= (oldMCS
<<18);
118 /* Short GI : Bit[31]*/
119 phyCtrl
|= (oldPhyCtrl
&0x80000000);
121 /* AM : Antenna mask */
122 //if ((oldMT == 2) && (oldMCS > 7))
123 if (hpPriv
->halCapability
& ZM_HP_CAP_11N_ONE_TX_STREAM
)
125 phyCtrl
|= (0x1<<15);
130 /* OFDM 6M/9M/12M/18M/24M Tx 2 chain */
131 /* OFDM 36M/48M/54M/ Tx 1 chain */
133 if ((oldMT
== 2) || (oldMT
== 3))
135 phyCtrl
|= (0x5<<15);
139 if ((oldMCS
== 0xb) || (oldMCS
== 0xf) ||
140 (oldMCS
== 0xa) || (oldMCS
== 0xe) ||
141 (oldMCS
== 0x9)) //6M/9M/12M/18M/24M
143 phyCtrl
|= (0x5<<15);
147 phyCtrl
|= (0x1<<15);
152 phyCtrl
|= (0x5<<15);
156 // phyCtrl |= (0x1<<15);
159 /* TODO : accelerating these code */
160 if (hpPriv
->hwFrequency
< 3000)
165 tpc
= (hpPriv
->tPow2xCck
[oldMCS
]&0x3f);
172 tpc
= (hpPriv
->tPow2x2g
[3]&0x3f);
174 else if (oldMCS
== 0x8)
176 tpc
= (hpPriv
->tPow2x2g
[2]&0x3f);
178 else if (oldMCS
== 0xd)
180 tpc
= (hpPriv
->tPow2x2g
[1]&0x3f);
182 else if (oldMCS
== 0x9)
184 tpc
= ((hpPriv
->tPow2x2g
[0]-hpPriv
->tPow2x2g24HeavyClipOffset
)&0x3f);
188 tpc
= (hpPriv
->tPow2x2g
[0]&0x3f);
193 if ( oldPhyCtrl
&0x800000 ) /* Bit23 : 40M */
196 tpc
= (hpPriv
->tPow2x2gHt40
[oldMCS
&0x7]&0x3f);
201 tpc
= (hpPriv
->tPow2x2gHt20
[oldMCS
&0x7]&0x3f);
212 tpc
= (hpPriv
->tPow2x5g
[3]&0x3f);
214 else if (oldMCS
== 0x8)
216 tpc
= (hpPriv
->tPow2x5g
[2]&0x3f);
218 else if (oldMCS
== 0xd)
220 tpc
= (hpPriv
->tPow2x5g
[1]&0x3f);
224 tpc
= (hpPriv
->tPow2x5g
[0]&0x3f);
229 if ( oldPhyCtrl
&0x800000 ) /* Bit23 : 40M */
232 tpc
= (hpPriv
->tPow2x5gHt40
[oldMCS
&0x7]&0x3f);
237 tpc
= (hpPriv
->tPow2x5gHt20
[oldMCS
&0x7]&0x3f);
242 /* Tx power adjust for HT40 */
244 if ((oldMT
==2) && (oldPhyCtrl
&0x800000) )
250 /* Evl force tx TPC */
253 tpc
= (u16_t
)(wd
->forceTxTPC
& 0x3f);
256 if (hpPriv
->hwFrequency
< 3000) {
257 wd
->maxTxPower2
&= 0x3f;
258 tpc
= (tpc
> wd
->maxTxPower2
)? wd
->maxTxPower2
: tpc
;
260 wd
->maxTxPower5
&= 0x3f;
261 tpc
= (tpc
> wd
->maxTxPower5
)? wd
->maxTxPower5
: tpc
;
266 #define ZM_TPC_OFFSET 5
267 #define ZM_SIGNAL_THRESHOLD 56
268 if ((wd
->sta
.bScheduleScan
== FALSE
) && (wd
->sta
.bChannelScan
== FALSE
))
270 if (( wd
->wlanMode
== ZM_MODE_INFRASTRUCTURE
)
271 && (zfStaIsConnected(dev
))
272 && (wd
->SignalStrength
> ZM_SIGNAL_THRESHOLD
))
274 if (tpc
> ((ZM_MIN_TPC
+ZM_TPC_OFFSET
)*2))
276 tpc
-= (ZM_TPC_OFFSET
*2);
278 else if (tpc
> (ZM_MIN_TPC
*2))
280 tpc
= (ZM_MIN_TPC
*2);
286 #undef ZM_SIGNAL_THRESHOLD
288 #ifndef ZM_OTUS_LINUX_PHASE_2
289 phyCtrl
|= (tpc
& 0x3f) << 9;
292 /* Set bits[8:6]BF-MCS for heavy clip */
293 if ((phyCtrl
&0x3) == 2)
295 phyCtrl
|= ((phyCtrl
>> 12) & 0x1c0);
301 zmw_buf_writeh(dev
, buf
, 4, (u16_t
) (phyCtrl
&0xffff));
302 zmw_buf_writeh(dev
, buf
, 6, (u16_t
) (phyCtrl
>>16));
307 header
[2] = (u16_t
) (phyCtrl
&0xffff);
309 header
[3] = (u16_t
) (phyCtrl
>>16);
312 zm_msg2_tx(ZM_LV_2
, "old phy ctrl = ", oldPhyCtrl
);
313 zm_msg2_tx(ZM_LV_2
, "new phy ctrl = ", phyCtrl
);
314 //DbgPrint("old phy ctrl =%08x \n", oldPhyCtrl);
315 //DbgPrint("new phy ctrl =%08x \n", phyCtrl);
319 #define EXTRA_INFO_LEN 24 //RSSI(7) + EVM(12) + PHY(1) + MACStatus(4)
320 u16_t
zfHpSend(zdev_t
* dev
, u16_t
* header
, u16_t headerLen
,
321 u16_t
* snap
, u16_t snapLen
,
322 u16_t
* tail
, u16_t tailLen
, zbuf_t
* buf
, u16_t offset
,
323 u16_t bufType
, u8_t ac
, u8_t keyIdx
)
325 #if ZM_SW_LOOP_BACK == 1
333 #endif /* #if ZM_SW_LOOP_BACK == 1 */
334 struct zsHpPriv
* hpPriv
;
336 zmw_get_wlan_dev(dev
);
337 hpPriv
=wd
->hpPrivate
;
339 zm_msg1_tx(ZM_LV_1
, "zfHpSend(), len = ", 12 + headerLen
-8 + snapLen
+ zfwBufGetSize(dev
, buf
) + 4 + 8);
341 /* Adjust ctrl setting : 6N14 yjsung */
342 zfAdjustCtrlSetting(dev
, header
, buf
);
344 #if ZM_SW_LOOP_BACK != 1
345 hpPriv
->usbSendBytes
+= zfwBufGetSize(dev
, buf
);
346 hpPriv
->usbAcSendBytes
[ac
&0x3] += zfwBufGetSize(dev
, buf
);
348 /* Submit USB Out Urb */
349 zfwUsbSend(dev
, USB_ENDPOINT_TX_INDEX
, (u8_t
*)header
, headerLen
,
350 (u8_t
*)snap
, snapLen
, (u8_t
*)tail
, tailLen
, buf
, offset
);
353 #if ZM_SW_LOOP_BACK == 1
355 rxbuf
= zfwBufAllocate(dev
, plcplen
+ headerLen
-8 + snapLen
+ (zfwBufGetSize(dev
, buf
)-offset
) + 4 + EXTRA_INFO_LEN
);
356 pHdr
= (u8_t
*) header
+8;
357 psnap
= (u8_t
*) snap
;
359 zmw_enter_critical_section(dev
);
360 /* software loop back */
361 /* Copy WLAN header and packet buffer */
362 swlpOffset
= plcplen
;
364 for(i
= 0; i
< headerLen
-8; i
++)
366 zmw_rx_buf_writeb(dev
, rxbuf
, swlpOffset
+i
, pHdr
[i
]);
369 swlpOffset
+= headerLen
-8;
371 /* Copy SNAP header */
372 for(i
= 0; i
< snapLen
; i
++)
374 zmw_rx_buf_writeb(dev
, rxbuf
, swlpOffset
+i
, psnap
[i
]);
377 swlpOffset
+= snapLen
;
379 /* Copy body from tx buf to rxbuf */
380 for(i
= 0; i
< (zfwBufGetSize(dev
, buf
)-offset
); i
++)
382 u8_t value
= zmw_rx_buf_readb(dev
, buf
, i
+offset
);
383 zmw_rx_buf_writeb(dev
, rxbuf
, swlpOffset
+i
, value
);
386 /* total length = PLCP + MacHeader + Payload + FCS + RXstatus */
387 /* 12 + headerLen-8 + snapLen + buf length + 4 + 8 */
388 zfwSetBufSetSize(dev
, rxbuf
, swlpOffset
+ (zfwBufGetSize(dev
, buf
)-offset
) + 4 + EXTRA_INFO_LEN
);
390 zmw_leave_critical_section(dev
);
392 zfwBufFree(dev
, buf
, 0);
394 //zfwDumpBuf(dev, rxbuf);
395 //-------------------------------------------------
397 //zfCoreRecv(dev, rxbuf);
399 #endif /* #if ZM_SW_LOOP_BACK */
404 /* Report moniter Hal rx information about rssi, evm, bandwidth, SG etc */
405 void zfHpQueryMonHalRxInfo(zdev_t
* dev
, u8_t
*monHalRxInfo
)
407 zmw_get_wlan_dev(dev
);
408 zfMemoryCopy(monHalRxInfo
,
409 (u8_t
*)&(((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
),
410 sizeof(struct zsHalRxInfo
));
414 u8_t
zfIsDataFrame(zdev_t
* dev
, zbuf_t
* buf
)
419 mpduInd
= zmw_rx_buf_readb(dev
, buf
, zfwBufGetSize(dev
, buf
)-1);
421 /* sinlge or First */
422 if ((mpduInd
& 0x30) == 0x00 || (mpduInd
& 0x30) == 0x20)
424 frameType
= zmw_rx_buf_readb(dev
, buf
, 12);
428 frameType
= zmw_rx_buf_readb(dev
, buf
, 0);
431 if((frameType
& 0xf) == ZM_WLAN_DATA_FRAME
)
437 u32_t
zfcConvertRateOFDM(zdev_t
* dev
, zbuf_t
* buf
)
439 // What's the default value??
442 switch(zmw_rx_buf_readb(dev
, buf
, 0)& 0xf)
472 u16_t
zfHpGetPayloadLen(zdev_t
* dev
,
482 u8_t modulation
,mpduInd
;
483 u16_t low
, high
, msb
;
484 s16_t payloadLen
= 0;
486 zmw_get_wlan_dev(dev
);
488 mpduInd
= zmw_rx_buf_readb(dev
, buf
, len
-1);
489 modulation
= zmw_rx_buf_readb(dev
, buf
, (len
-1)) & 0x3;
492 //zm_debug_msg1(" modulation= ", modulation);
493 switch (modulation
) {
494 case 0: /* CCK Mode */
495 low
= zmw_rx_buf_readb(dev
, buf
, 2);
496 high
= zmw_rx_buf_readb(dev
, buf
, 3);
497 payloadLen
= (low
| high
<< 8) - 4;
498 if (wd
->enableHALDbgInfo
)
500 *rxMCS
= zmw_rx_buf_readb(dev
, buf
, 0);
505 case 1: /* Legacy-OFDM mode */
506 low
= zmw_rx_buf_readb(dev
, buf
, 0) >> 5;
507 high
= zmw_rx_buf_readb(dev
, buf
, 1);
508 msb
= zmw_rx_buf_readb(dev
, buf
, 2) & 0x1;
509 payloadLen
= (low
| (high
<< 3) | (msb
<< 11)) - 4;
510 if (wd
->enableHALDbgInfo
)
512 *rxMCS
= zfcConvertRateOFDM(dev
, buf
);
517 case 2: /* HT OFDM mode */
518 //zm_debug_msg1("aggregation= ", (zmw_rx_buf_readb(dev, buf, 6) >> 3) &0x1 );
519 if ((mpduInd
& 0x30) == 0x00 || (mpduInd
& 0x30) == 0x10) //single or last mpdu
520 payloadLen
= len
- 24 - 4 - plcpHdrLen
; // - rxStatus - fcs
522 payloadLen
= len
- 4 - 4 - plcpHdrLen
; // - rxStatus - fcs
523 //zm_debug_msg1("first or middle mpdu, plcpHdrLen= ", plcpHdrLen);
525 if (wd
->enableHALDbgInfo
)
527 *rxMCS
= zmw_rx_buf_readb(dev
, buf
, 3) & 0x7f;
528 *rxBW
= (zmw_rx_buf_readb(dev
, buf
, 3) >> 7) & 0x1;
529 *rxSG
= (zmw_rx_buf_readb(dev
, buf
, 6) >> 7) & 0x1;
536 /* return the payload length - FCS */
537 if (payloadLen
< 0) payloadLen
= 0;
541 /************************************************************************/
543 /* FUNCTION DESCRIPTION zfiUsbRecv */
544 /* Callback function for USB IN Transfer. */
547 /* dev: device pointer */
553 /* Yuan-Gu Wei ZyDAS Technology Corporation 2005.10 */
555 /************************************************************************/
556 #define ZM_INT_USE_EP2 1
557 #define ZM_INT_USE_EP2_HEADER_SIZE 12
559 #if ZM_INT_USE_EP2 == 1
560 void zfiUsbRegIn(zdev_t
* dev
, u32_t
* rsp
, u16_t rspLen
);
563 #ifdef ZM_OTUS_RX_STREAM_MODE
564 void zfiUsbRecvPerPkt(zdev_t
*dev
, zbuf_t
*buf
)
566 void zfiUsbRecv(zdev_t
*dev
, zbuf_t
*buf
)
571 #if ZM_FW_LOOP_BACK != 1
574 u16_t crcPlusRxStatusLen
;
575 u16_t len
, payloadLen
=0;
577 struct zsAdditionInfo addInfo
;
582 struct zsHpPriv
* hpPriv
;
584 zmw_get_wlan_dev(dev
);
585 hpPriv
=wd
->hpPrivate
;
587 //zm_msg0_rx(ZM_LV_0, "zfiUsbRecv()");
589 #if ZM_INT_USE_EP2 == 1
591 for (i
=0; i
<(ZM_INT_USE_EP2_HEADER_SIZE
>>1); i
++)
593 if (zmw_rx_buf_readh(dev
, buf
, i
*2) != 0xffff)
597 if (i
==(ZM_INT_USE_EP2_HEADER_SIZE
>>1))
599 u32_t rsp
[ZM_USB_MAX_EPINT_BUFFER
/4];
602 u8_t
* pdst
= (u8_t
*)rsp
;
605 rspLen
= (u16_t
) zfwBufGetSize(dev
, buf
)-ZM_INT_USE_EP2_HEADER_SIZE
;
609 zm_debug_msg1("Get error len by EP2 = \n", rspLen
);
611 zfwBufFree(dev
, buf
, 0);
615 for (rspi
=0; rspi
<rspLen
; rspi
++)
617 *pdst
= zmw_rx_buf_readb(dev
, buf
, rspi
+ZM_INT_USE_EP2_HEADER_SIZE
);
621 //if (adapter->zfcbUsbRegIn)
622 // adapter->zfcbUsbRegIn(adapter, rsp, rspLen);
623 zfiUsbRegIn(dev
, rsp
, rspLen
);
626 zfwBufFree(dev
, buf
, 0);
629 #endif /* end of #if ZM_INT_USE_EP2 == 1 */
631 ZM_PERFORMANCE_RX_MPDU(dev
, buf
);
635 /* airopeek: Report everything up */
636 if (wd
->zfcbRecv80211
!= NULL
)
638 wd
->zfcbRecv80211(dev
, buf
, NULL
);
642 /* Read the last byte */
643 len
= zfwBufGetSize(dev
, buf
);
644 mpduInd
= zmw_rx_buf_readb(dev
, buf
, len
-1);
647 if((mpduInd
& 0x30) == 0x20)
650 if (zmw_rx_buf_readb(dev
, buf
, 36) == 0) //AC = BE
652 duration
= zmw_rx_buf_readh(dev
, buf
, 14);
653 if (duration
> hpPriv
->aggMaxDurationBE
)
655 hpPriv
->aggMaxDurationBE
= duration
;
659 if (hpPriv
->aggMaxDurationBE
> 10)
661 hpPriv
->aggMaxDurationBE
--;
664 //DbgPrint("aggMaxDurationBE=%d", hpPriv->aggMaxDurationBE);
669 /* First MPDU or Single MPDU */
670 if(((mpduInd
& 0x30) == 0x00) || ((mpduInd
& 0x30) == 0x20))
671 //if ((mpduInd & 0x10) == 0x00)
673 plcpHdrLen
= 12; // PLCP header length
677 if (zmw_rx_buf_readh(dev
, buf
, 4) == wd
->macAddr
[0] &&
678 zmw_rx_buf_readh(dev
, buf
, 6) == wd
->macAddr
[1] &&
679 zmw_rx_buf_readh(dev
, buf
, 8) == wd
->macAddr
[2]) {
682 else if (zmw_rx_buf_readh(dev
, buf
, 16) == wd
->macAddr
[0] &&
683 zmw_rx_buf_readh(dev
, buf
, 18) == wd
->macAddr
[1] &&
684 zmw_rx_buf_readh(dev
, buf
, 20) == wd
->macAddr
[2]){
692 /* Last MPDU or Single MPDU */
693 if ((mpduInd
& 0x30) == 0x00 || (mpduInd
& 0x30) == 0x10)
695 crcPlusRxStatusLen
= EXTRA_INFO_LEN
+ 4; // Extra bytes + FCS
699 crcPlusRxStatusLen
= 4 + 4; // Extra 4 bytes + FCS
703 crcPlusRxStatusLen
= EXTRA_INFO_LEN
+ 4; // Extra bytes + FCS
706 if (len
< (plcpHdrLen
+10+crcPlusRxStatusLen
))
708 zm_msg1_rx(ZM_LV_0
, "Invalid Rx length=", len
);
709 //zfwDumpBuf(dev, buf);
711 zfwBufFree(dev
, buf
, 0);
715 /* display RSSI combined */
717 * ¢z¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢s¢w¢w¢w¢w¢w¢w¢w¢w¢s¢w¢w¢w¢w¢w¢w¢s¢w¢w¢w¢w¢w¢w¢s¢w¢w¢w¢w¢w¢w¢w¢w¢w¢s¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢{
718 * ¢x PLCP Header ¢x MPDU ¢x RSSI ¢x EVM ¢x PHY Err ¢x MAC Status ¢x
719 * ¢u¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢q¢w¢w¢w¢w¢w¢w¢w¢w¢q¢w¢w¢w¢w¢w¢w¢q¢w¢w¢w¢w¢w¢w¢q¢w¢w¢w¢w¢w¢w¢w¢w¢w¢q¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢t
720 * ¢x 12 ¢x n ¢x 7 ¢x 12 ¢x 1 ¢x 4 ¢x
721 * ¢|¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢r¢w¢w¢w¢w¢w¢w¢w¢w¢r¢w¢w¢w¢w¢w¢w¢r¢w¢w¢w¢w¢w¢w¢r¢w¢w¢w¢w¢w¢w¢w¢w¢w¢r¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢}
722 * RSSI filed (From BB and MAC just pass them to host)
723 * Byte1: RSSI for antenna 0.
724 * Byte2: RSSI for antenna 1.
725 * Byte3: RSSI for antenna 2.
726 * Byte4: RSSI for antenna 0 extension.
727 * Byte5: RSSI for antenna 1 extension.
728 * Byte6: RSSI for antenna 2 extension.
729 * Byte7: RSSI for antenna combined.
732 //zm_debug_msg1(" recv RSSI = ", zmw_rx_buf_readb(dev, buf, (len-1)-17));
734 payloadLen
= zfHpGetPayloadLen(dev
, buf
, len
, plcpHdrLen
, &rxMT
, &rxMCS
, &rxBW
, &rxSG
);
737 /* First MPDU or Single MPDU */
738 if(((mpduInd
& 0x30) == 0x00) || ((mpduInd
& 0x30) == 0x20))
740 if (wd
->enableHALDbgInfo
&& zfIsDataFrame(dev
, buf
))
742 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxDataMT
= rxMT
;
743 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxDataMCS
= rxMCS
;
744 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxDataBW
= rxBW
;
745 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxDataSG
= rxSG
;
749 if ((plcpHdrLen
+ payloadLen
) > len
) {
750 zm_msg1_rx(ZM_LV_0
, "Invalid payload length=", payloadLen
);
751 zfwBufFree(dev
, buf
, 0);
755 //Store Rx Tail Infomation before Remove--CWYang(+)
758 for (i
= 0; i
< crcPlusRxStatusLen
-4; i
++)
760 addInfo
.Tail
.Byte
[i
] =
761 zmw_rx_buf_readb(dev
, buf
, len
- crcPlusRxStatusLen
+ 4 + i
);
765 * Brief format of OUTS chip
766 * ¢z¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢s¢w¢w¢w¢w¢w¢w¢w¢w¢s¢w¢w¢w¢w¢w¢w¢s¢w¢w¢w¢w¢w¢w¢s¢w¢w¢w¢w¢w¢w¢w¢w¢w¢s¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢{
767 * ¢x PLCP Header ¢x MPDU ¢x RSSI ¢x EVM ¢x PHY Err ¢x MAC Status ¢x
768 * ¢u¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢q¢w¢w¢w¢w¢w¢w¢w¢w¢q¢w¢w¢w¢w¢w¢w¢q¢w¢w¢w¢w¢w¢w¢q¢w¢w¢w¢w¢w¢w¢w¢w¢w¢q¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢t
769 * ¢x 12 ¢x n ¢x 7 ¢x 12 ¢x 1 ¢x 4 ¢x
770 * ¢|¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢r¢w¢w¢w¢w¢w¢w¢w¢w¢r¢w¢w¢w¢w¢w¢w¢r¢w¢w¢w¢w¢w¢w¢r¢w¢w¢w¢w¢w¢w¢w¢w¢w¢r¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢}
775 * Byte 4 antenna 0 extension
776 * Byte 5 antenna 1 extension
777 * Byte 6 antenna 2 extension
778 * Byte 7 antenna combined
780 * Byte 1 Stream 0 pilot 0
781 * Byte 2 Stream 0 pilot 1
782 * Byte 3 Stream 0 pilot 2
783 * Byte 4 Stream 0 pilot 3
784 * Byte 5 Stream 0 pilot 4
785 * Byte 6 Stream 0 pilot 5
786 * Byte 7 Stream 1 pilot 0
787 * Byte 8 Stream 1 pilot 1
788 * Byte 9 Stream 1 pilot 2
789 * Byte 10 Stream 1 pilot 3
790 * Byte 11 Stream 1 pilot 4
791 * Byte 12 Stream 1 pilot 5
794 /* Fill the Tail information */
795 /* Last MPDU or Single MPDU */
796 if ((mpduInd
& 0x30) == 0x00 || (mpduInd
& 0x30) == 0x10)
798 #define ZM_RX_RSSI_COMPENSATION 27
799 u8_t zm_rx_rssi_compensation
= ZM_RX_RSSI_COMPENSATION
;
801 /* RSSI information */
802 addInfo
.Tail
.Data
.SignalStrength1
= zmw_rx_buf_readb(dev
, buf
,
803 (len
-1) - 17) + ((hpPriv
->rxStrongRSSI
== 1)?zm_rx_rssi_compensation
:0);
804 #undef ZM_RX_RSSI_COMPENSATION
808 /* TODO: for RD/BB debug message */
809 /* save current rx hw infomration, report to DrvCore/Application */
810 if (wd
->enableHALDbgInfo
&& zfIsDataFrame(dev
, buf
))
815 trssi
= zmw_rx_buf_readb(dev
, buf
, (len
-1) - 23 + i
);
818 trssi
= ((~((u8_t
)trssi
) & 0x7f) + 1) & 0x7f;
820 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRSSI
[i
] = trssi
;
828 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[i
] =
829 zmw_rx_buf_readb(dev
, buf
, (len
-1) - 16 + i
);
833 // for (i=0; i<4; i++)
834 // ((struct zsHpPriv*)wd->hpPrivate)->halRxInfo.currentRxEVM[i] =
835 // zmw_rx_buf_readb(dev, buf, (len-1) - 16 + i);
841 zm_dbg(("MT(%d) MCS(%d) BW(%d) SG(%d) RSSI:%d,%d,%d,%d,%d,%d,%d EVM:(%d,%d,%d,%d,%d,%d)(%d,%d,%d,%d,%d,%d)\n",
846 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRSSI
[0],
847 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRSSI
[1],
848 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRSSI
[2],
849 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRSSI
[3],
850 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRSSI
[4],
851 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRSSI
[5],
852 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRSSI
[6],
853 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[0],
854 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[1],
855 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[2],
856 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[3],
857 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[4],
858 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[5],
859 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[6],
860 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[7],
861 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[8],
862 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[9],
863 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[10],
864 ((struct zsHpPriv
*)wd
->hpPrivate
)->halRxInfo
.currentRxEVM
[11]
867 } /* if (wd->enableHALDbgInfo && zfIsDataFrame(dev, buf)) */
872 /* Mid or First aggregate frame without phy rx information */
873 addInfo
.Tail
.Data
.SignalStrength1
= 0;
876 addInfo
.Tail
.Data
.SignalStrength2
= 0;
877 addInfo
.Tail
.Data
.SignalStrength3
= 0;
878 addInfo
.Tail
.Data
.SignalQuality
= 0;
880 addInfo
.Tail
.Data
.SAIndex
= zmw_rx_buf_readb(dev
, buf
, len
- 4);
881 addInfo
.Tail
.Data
.DAIndex
= zmw_rx_buf_readb(dev
, buf
, len
- 3);
882 addInfo
.Tail
.Data
.ErrorIndication
= zmw_rx_buf_readb(dev
, buf
, len
- 2);
883 addInfo
.Tail
.Data
.RxMacStatus
= zmw_rx_buf_readb(dev
, buf
, len
- 1);
886 /* Remove CRC and Rx Status */
887 zfwBufSetSize(dev
, buf
, (len
-crcPlusRxStatusLen
));
888 //zfwBufSetSize(dev, buf, payloadLen + plcpHdrLen); /* payloadLen + PLCP 12 - FCS 4*/
890 //Store PLCP Header Infomation before Remove--CWYang(+)
893 for (i
= 0; i
< plcpHdrLen
; i
++)
895 addInfo
.PlcpHeader
[i
] = zmw_rx_buf_readb(dev
, buf
, i
);
900 addInfo
.PlcpHeader
[0] = 0;
902 /* Remove PLCP header */
903 zfwBufRemoveHead(dev
, buf
, plcpHdrLen
);
905 /* handle 802.11 frame */
906 zfCoreRecv(dev
, buf
, &addInfo
);
909 /* Firmware loopback: Rx frame = Tx frame */
910 /* convert Rx frame to fit receive frame format */
912 u8_t ctrl_offset
= 8;
918 /* Tx: | ctrl_setting | Mac hdr | data | */
921 /* Rx: | PLCP | Mac hdr | data | FCS | Rxstatus | */
924 /* new allocate a rx format size buf */
925 new_buf
= zfwBufAllocate(dev
, zfwBufGetSize(dev
, buf
)-8+12+4+EXTRA_INFO_LEN
);
927 for (i
=0; i
<zfwBufGetSize(dev
, buf
)-ctrl_offset
; i
++)
929 data
= zmw_rx_buf_readb(dev
, buf
, ctrl_offset
+i
);
930 zmw_rx_buf_writeb(dev
, new_buf
, PLCP_Len
+i
, data
);
933 zfwBufSetSize(dev
, new_buf
, zfwBufGetSize(dev
, buf
)-8+12+4+EXTRA_INFO_LEN
);
935 zfwBufFree(dev
, buf
, 0);
937 /* receive the new_buf */
938 //zfCoreRecv(dev, new_buf);
944 #ifdef ZM_OTUS_RX_STREAM_MODE
945 void zfiUsbRecv(zdev_t
*dev
, zbuf_t
*buf
)
952 zbuf_t
*rxBufPool
[8];
953 u16_t rxBufPoolIndex
= 0;
954 struct zsHpPriv
*halPriv
;
957 u16_t usbRxRemainLen
;
960 zmw_get_wlan_dev(dev
);
962 halPriv
= (struct zsHpPriv
*)wd
->hpPrivate
;
963 srcBufPtr
= zmw_buf_get_buffer(dev
, buf
);
965 bufferLength
= zfwBufGetSize(dev
, buf
);
967 /* Zero Length Transfer */
970 zfwBufFree(dev
, buf
, 0);
974 usbRxRemainLen
= halPriv
->usbRxRemainLen
;
975 usbRxPktLen
= halPriv
->usbRxTransferLen
;
977 /* Check whether there is any data in the last transfer */
978 if (usbRxRemainLen
!= 0 )
980 zbuf_t
*remainBufPtr
= halPriv
->remainBuf
;
983 if ( remainBufPtr
!= NULL
)
985 BufPtr
= zmw_buf_get_buffer(dev
, remainBufPtr
);
988 index
= usbRxRemainLen
;
989 usbRxRemainLen
-= halPriv
->usbRxPadLen
;
992 if ( BufPtr
!= NULL
)
994 zfwMemoryCopy(&(BufPtr
[usbRxPktLen
]), srcBufPtr
, usbRxRemainLen
);
997 usbRxPktLen
+= usbRxRemainLen
;
998 halPriv
->usbRxRemainLen
= 0;
1000 if ( remainBufPtr
!= NULL
)
1002 zfwBufSetSize(dev
, remainBufPtr
, usbRxPktLen
);
1003 rxBufPool
[rxBufPoolIndex
++] = remainBufPtr
;
1005 halPriv
->remainBuf
= NULL
;
1008 //zm_debug_msg1("length: %d\n", (int)pUsbRxTransfer->pRxUrb->UrbBulkOrInterruptTransfer.TransferBufferLength);
1010 bufferLength
= zfwBufGetSize(dev
, buf
);
1011 //printk("bufferLength %d\n", bufferLength);
1012 while(index
< bufferLength
)
1016 //u8_t *ptr = (u8_t*)((struct zsBuffer*)pUsbRxTransfer->buf)->data;
1017 u8_t
*ptr
= srcBufPtr
;
1019 /* Retrieve packet length and tag */
1020 pktLen
= ptr
[index
] + (ptr
[index
+1] << 8);
1021 pktTag
= ptr
[index
+2] + (ptr
[index
+3] << 8);
1023 if (pktTag
== ZM_USB_STREAM_MODE_TAG
)
1027 zm_assert(pktLen
< ZM_WLAN_MAX_RX_SIZE
);
1029 //printk("Get a packet, pktLen: 0x%04x\n", pktLen);
1032 for (ii
= index
; ii
< pkt_len
+4;)
1035 (zmw_rx_buf_readb(adapter
, pUsbRxTransfer
->buf
, ii
) & 0xff));
1037 if ((++ii
% 16) == 0)
1044 /* Calcuate the padding length, in the current design,
1045 the length should be padded to 4 byte boundray. */
1046 padLen
= ZM_USB_STREAM_MODE_TAG_LEN
- (pktLen
& 0x3);
1048 if(padLen
== ZM_USB_STREAM_MODE_TAG_LEN
)
1052 index
= index
+ ZM_USB_STREAM_MODE_TAG_LEN
+ pktLen
+ padLen
;
1054 if (chkIdx
> ZM_MAX_USB_IN_TRANSFER_SIZE
)
1056 zm_debug_msg1("chkIdx is too large, chkIdx: %d\n", chkIdx
);
1062 if (index
> ZM_MAX_USB_IN_TRANSFER_SIZE
)
1064 //struct zsBuffer* BufPtr;
1065 //struct zsBuffer* UsbBufPtr;
1069 halPriv
->usbRxRemainLen
= index
- ZM_MAX_USB_IN_TRANSFER_SIZE
; // - padLen;
1070 halPriv
->usbRxTransferLen
= ZM_MAX_USB_IN_TRANSFER_SIZE
-
1071 chkIdx
- ZM_USB_STREAM_MODE_TAG_LEN
;
1072 halPriv
->usbRxPadLen
= padLen
;
1073 //check_index = index;
1075 if (halPriv
->usbRxTransferLen
> ZM_WLAN_MAX_RX_SIZE
)
1077 zm_debug_msg1("check_len is too large, chk_len: %d\n",
1078 halPriv
->usbRxTransferLen
);
1083 /* Allocate a skb buffer */
1084 newBuf
= zfwBufAllocate(dev
, ZM_WLAN_MAX_RX_SIZE
);
1086 if ( newBuf
!= NULL
)
1088 BufPtr
= zmw_buf_get_buffer(dev
, newBuf
);
1089 UsbBufPtr
= srcBufPtr
;
1091 /* Copy the buffer */
1092 zfwMemoryCopy(BufPtr
, &(UsbBufPtr
[chkIdx
+ZM_USB_STREAM_MODE_TAG_LEN
]), halPriv
->usbRxTransferLen
);
1094 /* Record the buffer pointer */
1095 halPriv
->remainBuf
= newBuf
;
1103 /* Allocate a skb buffer */
1104 newBuf
= zfwBufAllocate(dev
, ZM_WLAN_MAX_RX_SIZE
);
1105 if ( newBuf
!= NULL
)
1107 BufPtr
= zmw_buf_get_buffer(dev
, newBuf
);
1108 UsbBufPtr
= srcBufPtr
;
1110 /* Copy the buffer */
1111 zfwMemoryCopy(BufPtr
, &(UsbBufPtr
[chkIdx
+ZM_USB_STREAM_MODE_TAG_LEN
]), pktLen
);
1113 zfwBufSetSize(dev
, newBuf
, pktLen
);
1114 rxBufPool
[rxBufPoolIndex
++] = newBuf
;
1122 DbgPrint("Can't find tag, pkt_len: 0x%04x, tag: 0x%04x\n",
1126 for(i
= 0; i
< 32; i
++)
1128 DbgPrint("%02x ", buf
->data
[index
-16+i
]);
1130 if ((i
& 0xf) == 0xf)
1140 //zfwBufFree(adapter, pUsbRxTransfer->buf, 0);
1141 zfwBufFree(dev
, buf
, 0);
1143 for(ii
= 0; ii
< rxBufPoolIndex
; ii
++)
1145 zfiUsbRecvPerPkt(dev
, rxBufPool
[ii
]);
1150 /************************************************************************/
1152 /* FUNCTION DESCRIPTION zfUsbInit */
1153 /* Initialize USB resource. */
1156 /* dev : device pointer */
1162 /* Stephen Chen ZyDAS Technology Corporation 2005.12 */
1164 /************************************************************************/
1165 void zfUsbInit(zdev_t
* dev
)
1167 /* Initialize Rx & INT endpoint for receiving data & interrupt */
1168 zfwUsbEnableRxEpt(dev
, USB_ENDPOINT_RX_INDEX
);
1169 zfwUsbEnableIntEpt(dev
, USB_ENDPOINT_INT_INDEX
);
1175 /************************************************************************/
1177 /* FUNCTION DESCRIPTION zfUsbFree */
1178 /* Free PCI resource. */
1181 /* dev : device pointer */
1187 /* Stephen Chen ZyDAS Technology Corporation 2005.12 */
1189 /************************************************************************/
1190 void zfUsbFree(zdev_t
* dev
)
1192 struct zsHpPriv
*halPriv
;
1194 zmw_get_wlan_dev(dev
);
1196 halPriv
= (struct zsHpPriv
*)wd
->hpPrivate
;
1198 #ifdef ZM_OTUS_RX_STREAM_MODE
1199 if ( halPriv
->remainBuf
!= NULL
)
1201 zfwBufFree(dev
, halPriv
->remainBuf
, 0);
1208 void zfHpSendBeacon(zdev_t
* dev
, zbuf_t
* buf
, u16_t len
)
1212 zmw_get_wlan_dev(dev
);
1214 /* Write to beacon buffer (ZM_BEACON_BUFFER_ADDRESS) */
1215 for (i
= 0; i
<len
; i
+=4)
1217 lw
= zmw_tx_buf_readh(dev
, buf
, i
);
1218 hw
= zmw_tx_buf_readh(dev
, buf
, i
+2);
1220 zfDelayWriteInternalReg(dev
, ZM_BEACON_BUFFER_ADDRESS
+i
, (hw
<<16)+lw
);
1223 /* Beacon PCLP header */
1224 if (((struct zsHpPriv
*)wd
->hpPrivate
)->hwFrequency
< 3000)
1226 zfDelayWriteInternalReg(dev
, ZM_MAC_REG_BCN_PLCP
, ((len
+4)<<(3+16))+0x0400);
1230 zfDelayWriteInternalReg(dev
, ZM_MAC_REG_BCN_PLCP
, ((len
+4)<<(16))+0x001b);
1233 /* Beacon length (include CRC32) */
1234 zfDelayWriteInternalReg(dev
, ZM_MAC_REG_BCN_LENGTH
, len
+4);
1237 zfDelayWriteInternalReg(dev
, ZM_MAC_REG_BCN_CTRL
, 1);
1238 zfFlushDelayWrite(dev
);
1240 /* Free beacon buf */
1241 zfwBufFree(dev
, buf
, 0);
1247 #define ZM_STATUS_TX_COMP 0x00
1248 #define ZM_STATUS_RETRY_COMP 0x01
1249 #define ZM_STATUS_TX_FAILED 0x02
1250 void zfiUsbRegIn(zdev_t
* dev
, u32_t
* rsp
, u16_t rspLen
)
1252 //u8_t len, type, i;
1257 zmw_get_wlan_dev(dev
);
1259 zm_msg0_mm(ZM_LV_3
, "zfiUsbRegIn()");
1261 u8rsp
= (u8_t
*)rsp
;
1268 /* Interrupt event */
1269 if ((type
& 0xC0) == 0xC0)
1273 zfCoreEvent(dev
, 0, u8rsp
);
1276 else if (type
== 0xC1)
1281 DbgPrint("rspLen=%d\n", rspLen
);
1282 for (i
=0; i
<(rspLen
/4); i
++)
1284 DbgPrint("rsp[%d]=0x%lx\n", i
, rsp
[i
]);
1288 status
= (u16_t
)(rsp
[3] >> 16);
1291 rsp
[8] = rsp
[8] >> 2 | (rsp
[9] & 0x1) << 6;
1294 case ZM_STATUS_RETRY_COMP
:
1295 zfCoreEvent(dev
, 1, u8rsp
);
1297 case ZM_STATUS_TX_FAILED
:
1298 zfCoreEvent(dev
, 2, u8rsp
);
1300 case ZM_STATUS_TX_COMP
:
1301 zfCoreEvent(dev
, 3, u8rsp
);
1305 else if (type
== 0xC2)
1307 zfBeaconCfgInterrupt(dev
, u8rsp
);
1309 else if (type
== 0xC3)
1311 zfEndOfAtimWindowInterrupt(dev
);
1313 else if (type
== 0xC4)
1318 DbgPrint("0xC2:rspLen=%d\n", rspLen
);
1319 for (i
=0; i
<(rspLen
/4); i
++)
1321 DbgPrint("0xC2:rsp[%d]=0x%lx\n", i
, rsp
[i
]);
1325 bitmap
= (rsp
[1] >> 16) + ((rsp
[2] & 0xFFFF) << 16 );
1326 //zfBawCore(dev, (u16_t)rsp[1] & 0xFFFF, bitmap, (u16_t)(rsp[2] >> 16) & 0xFF);
1328 else if (type
== 0xC5)
1333 for (i
=0; i
<(rspLen
/4); i
++) {
1334 DbgPrint("0xC5:rsp[%d]=0x%lx\n", i
, rsp
[i
]);
1337 for (i
=1; i
<(rspLen
/4); i
++) {
1338 u8rsp
= (u8_t
*)(rsp
+i
);
1339 //DbgPrint("0xC5:rsp[%d]=0x%lx\n", i, ((u32_t*)u8rsp)[0]);
1340 zfCoreEvent(dev
, 4, u8rsp
);
1343 else if (type
== 0xC6)
1345 zm_debug_msg0("\n\n WatchDog interrupt!!! : 0xC6 \n\n");
1346 if (wd
->zfcbHwWatchDogNotify
!= NULL
)
1348 wd
->zfcbHwWatchDogNotify(dev
);
1351 else if (type
== 0xC8)
1353 //PZSW_ADAPTER adapter;
1355 // for SPI flash program chk Flag
1356 zfwDbgProgrameFlashChkDone(dev
);
1358 else if (type
== 0xC9)
1360 struct zsHpPriv
* hpPriv
=wd
->hpPrivate
;
1362 zm_debug_msg0("##### Tx retransmission 5 times event #####");
1364 /* correct tx retransmission issue */
1365 hpPriv
->retransmissionEvent
= 1;
1370 zfIdlRsp(dev
, rsp
, rspLen
);
1375 #define ZM_PROGRAM_RAM_ADDR 0x200000 //0x1000 //0x700000
1376 #define FIRMWARE_DOWNLOAD 0x30
1377 #define FIRMWARE_DOWNLOAD_COMP 0x31
1378 #define FIRMWARE_CONFIRM 0x32
1380 u16_t
zfFirmwareDownload(zdev_t
* dev
, u32_t
* fw
, u32_t len
, u32_t offset
)
1382 u16_t ret
= ZM_SUCCESS
;
1383 u32_t uCodeOfst
= offset
;
1392 u32_t translen
= (len
> 4096) ? 4096 : len
;
1394 result
= zfwUsbSubmitControl(dev
, FIRMWARE_DOWNLOAD
,
1395 (u16_t
) (uCodeOfst
>> 8),
1396 0, image
, translen
);
1398 if (result
!= ZM_SUCCESS
)
1400 zm_msg0_init(ZM_LV_0
, "FIRMWARE_DOWNLOAD failed");
1407 uCodeOfst
+= translen
; // in Word (16 bit)
1412 /* If download firmware success, issue a command to firmware */
1415 result
= zfwUsbSubmitControl(dev
, FIRMWARE_DOWNLOAD_COMP
,
1418 if (result
!= ZM_SUCCESS
)
1420 zm_msg0_init(ZM_LV_0
, "FIRMWARE_DOWNLOAD_COMP failed");
1428 /* Wait for firmware ready */
1429 result
= zfwUsbSubmitControl(dev
, FIRMWARE_CONFIRM
, USB_DIR_IN
| 0x40,
1430 0, 0, &ret_value
, sizeof(ret_value
), HZ
);
1434 zm_msg0_init(ZM_LV_0
, "Can't receive firmware ready: ", result
);
1445 u16_t
zfFirmwareDownloadNotJump(zdev_t
* dev
, u32_t
* fw
, u32_t len
, u32_t offset
)
1447 u16_t ret
= ZM_SUCCESS
;
1448 u32_t uCodeOfst
= offset
;
1457 u32_t translen
= (len
> 4096) ? 4096 : len
;
1459 result
= zfwUsbSubmitControl(dev
, FIRMWARE_DOWNLOAD
,
1460 (u16_t
) (uCodeOfst
>> 8),
1461 0, image
, translen
);
1463 if (result
!= ZM_SUCCESS
)
1465 zm_msg0_init(ZM_LV_0
, "FIRMWARE_DOWNLOAD failed");
1472 uCodeOfst
+= translen
; // in Word (16 bit)
1483 /************************************************************************/
1485 /* FUNCTION DESCRIPTION zfIdlGetFreeTxdCount */
1486 /* Get free PCI PCI TxD count. */
1489 /* dev : device pointer */
1495 /* Stephen ZyDAS Technology Corporation 2006.6 */
1497 /************************************************************************/
1498 u32_t
zfHpGetFreeTxdCount(zdev_t
* dev
)
1500 return zfwUsbGetFreeTxQSize(dev
);
1503 u32_t
zfHpGetMaxTxdCount(zdev_t
* dev
)
1506 return zfwUsbGetMaxTxQSize(dev
);
1509 void zfiUsbRegOutComplete(zdev_t
* dev
)
1514 extern void zfPushVtxq(zdev_t
* dev
);
1516 void zfiUsbOutComplete(zdev_t
* dev
, zbuf_t
*buf
, u8_t status
, u8_t
*hdr
) {
1517 #ifndef ZM_ENABLE_AGGREGATION
1519 zfwBufFree(dev
, buf
, 0);
1522 #ifdef ZM_BYPASS_AGGR_SCHEDULING
1523 //Simply free the buf since BA retransmission is done in the firmware
1526 zfwBufFree(dev
, buf
, 0);
1530 zmw_get_wlan_dev(dev
);
1532 #ifdef ZM_ENABLE_FW_BA_RETRANSMISSION
1533 //Simply free the buf since BA retransmission is done in the firmware
1536 zfwBufFree(dev
, buf
, 0);
1543 zfwBufFree(dev
, buf
, 0);
1544 //zm_debug_msg0("buf Free due to hdr == NULL");
1549 frameType
= hdr
[8] & 0xf;
1550 agg
= (u8_t
)(hdr
[2] >> 5 ) & 0x1;
1551 //zm_debug_msg1("AGG=", agg);
1555 //delete buf in ba fail queue??
1559 zfwBufFree(dev
, buf
, 0);
1565 //zfwBufFree(dev, buf, 0);
1568 zfwBufFree(dev
, buf
, 0);
1574 if (wd
->state
!= ZM_WLAN_STATE_ENABLED
) {
1578 if( (wd
->wlanMode
== ZM_MODE_AP
) ||
1579 (wd
->wlanMode
== ZM_MODE_INFRASTRUCTURE
&& wd
->sta
.EnableHT
) ||
1580 (wd
->wlanMode
== ZM_MODE_PSEUDO
) ) {
1581 zfAggTxScheduler(dev
, 0);