From: Oleksij Rempel Date: Thu, 10 Oct 2013 11:48:43 +0200 Subject: [ath9k-devel] ath9k_htc: status report Message-ID: <525677FB.3080005@rempel-privat.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ath9k-devel@lists.ath9k.org Hello all, After a lot (hopefully enough) of digging, i want share some information and patches. It looks like Atheros AR9271, AR7010 (ath9k_htc) and AR9170 (carl9170) have the same usb controller - FUSB200. They share same design and same problem. They have 3 OUT and 1 IN Bulk EPs for network traffic. 1 OUT and 1 IN Interrupt EP for WMI commands. Here is the layout: https://github.com/qca/open-ath9k-htc-firmware/wiki/usb-regs EP 1 OUT; Bulk; = LP (Low priority downstream); RX0; EP 2 IN; Bulk; = US (upstream) EP 3 IN; Interrupt; EP 4 OUT; Interrupt; EP 5 OUT; Bulk; = HP (High priority downstream); RX1; EP 6 OUT; Bulk; = MP (Medium priority downstream); RX2; the layout with FIFOs see in attachment. EPs 5 and 6 are not used by driver. They seems to be supported by hardware, but not handled by firmware. So, not important for now. EPs 1, 2, 5, 6 are handled by DMA with some previous buffering. === And here is the problem === EPs 3, 4 accessed directly. For some reasons, response time on this EPs on USB 2.0 is 2-4 ms. Same hardware on USB 3.0 has less delay - 0.2 ms. === Test 1. Using Bulk instead of Int === Previously ath9k_htc driver had workaround, by forcing Bulk traffic on EP3 and 4. (Actually, only EP4 is interesting for this issue) But it is not working with all hardware correctly. For example, on USB 3.0, the changes well be applied only after device reset. Before device reset, even if ath9k_htc driver was sending Bulk, usb driver converted it back to Interrupt. After reset, usb driver started sending bulk and was not able to work with too small FIFO size on FUSB200. EP4 is mapped to 64byte FIFO, but we need 512 byte for bulk transfer. According to product brief, FUSB200 can be flexible reconfigurable. Theoretically we should be able to map EP4 to 512 byte FIFO. I tried it, but no interrupt was generated. (some thing is wrong, i do not know what) According to product brief, if FUSB200 connected with DMA module, the FIFOs will be handled by DMA. It looks like FIFOs 0-13 can't be accessed same way like we do it with FIFO14 and 15 (EP3 and EP4). So it looks like we can't fix it correctly - by remaping interrupt EPs to bigger FIFOs and define it as Bulk. If there are some DMA mask registers, please tell me. === Test 2. Using other EPs (5, 6 or 1) === The DMA engine, which is connected with this EPs, has build in priority system. For example EP1 will need more packets or time until DMA will be triggered. EPs 5 and 6 need less time to react. Maybe we can use this EPs as better workaround. But right now, i do not know how to enable DMA at the beginning. After firmware upload, only EP3 and EP4 are working. Which use no DMA. I was not able to find on which stage and how DMA was enabled. I also have doubt. DMA buffer will probably add too big delay. Espesially on reg read. So, maybe this option wan't work too. === Other workarounds === Since we can't fix or untill we will be able to fix usb issue, we need to optimise IO operations. Small packets will waste usb bandwidth. For example, typical write or read IO is 8byte. We need at least 64 bytes to normally utilise USB bus. Here are changes which will increase performance: 1. do buffered write. - this is was already done before me. 2. TODO: read arrays. - currently driver will do one read per time. 3. TODO: optimised and buffered RMW operations. ath9k use intensively RMW, so it good field for optimisation. RMW is needed to change some bit of register. So we do read + chage + write. By mowing this command to Firmware, we will be able to do buffered RMW and dramatically reduce usb bus traffic. Here are links to my kernel and firmware branches with described optimisation: https://github.com/olerem/open-ath9k-htc-firmware/commits/speed https://github.com/olerem/linux-2.6/commits/wifi-perf2 With this patches i reduced scan time on ar9271 from 25 to ~15 seconds! Since this patchset will need to bump firmware version, i would like to include other changes which may brake the API. Are there any? Your suggestions, comments and critic are welcome. -- Regards, Oleksij -------------- next part -------------- A non-text attachment was scrubbed... Name: fusb.png Type: image/png Size: 229017 bytes Desc: not available Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20131010/e47e43bb/attachment-0001.png