summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtl818x/rtl8180/dev.c
Commit message (Collapse)AuthorAgeFilesLines
* rtlwifi: rtl818x: Move drivers into new realtek directoryLarry Finger2015-10-141-1991/+0
| | | | | | | | | | | | Now that a new mac80211-based driver for Realtek devices has been submitted, it is time to reorganize the directories. Rather than having directories rtlwifi and rtl818x be in drivers/net/wireless/, they will now be in drivers/net/wireless/realtek/. This change simplifies the directory structure, but does not result in any configuration changes that are visable to the user. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mac80211: convert HW flags to unsigned long bitmapJohannes Berg2015-06-101-4/+5
| | | | | | | | | | | | | | | As we're running out of hardware capability flags pretty quickly, convert them to use the regular test_bit() style unsigned long bitmaps. This introduces a number of helper functions/macros to set and to test the bits, along with new debugfs code. The occurrences of an explicit __clear_bit() are intentional, the drivers were never supposed to change their supported bits on the fly. We should investigate changing this to be a per-frame flag. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
* rtl818x_pci: fix response rate may be incorrect.Andrea Merello2014-10-071-11/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the allowed "respose rate" set (rates for HW generated frames like ACKs) is the same as the basic rate set. The HW will use the higher allowed response rate that is lower than the rate of the received frame. This is more or less what IEEE80211 mandates, but I missed the fact that IEEE80211 also says that whenever it happens that for a modulation class there is no any rate in the basic rates set, then the response rate set shall include also all the mandatory rates for that modulation class. This patch adds mandatory OFDM rates to the allowed response rate set if no OFDM rate is included in the basic rate set. Depending by the AP, I faced cases in which this patch seems to cause a noticeable perfomance improvement. - With my usual test AP there is no particular perfomance difference. - With a prism54/hostapd AP this patch causes RX thoughput increase from about 5Mbps to about 20Mbps. Hopefully this patch may help people that faced performance regression wrt the old staging driver. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x_pci: add RSSI information for rtl8187SEandrea.merello2014-09-261-5/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes the driver to report signal strength information to mac80211 for rtl8187se boards. It differs from my previous RFT patch: http://marc.info/?l=linux-wireless&m=140155388332534&w=2 because: - I have now a working rtl8187se card, so I could serve my RFT by myself. :) - CCK measurement code has changed a bit, but it does basically the same things. - OFDM measurement method is changed because the older method reported incorrect measures, at least for signals stronger than -40dBm). CCK measurement seems quite good. OFDM seems less accurate, but this is the same as the "reference" staging driver dose. I wanted not to change things just to make measures of _one_ (my) card a bit more close to what _I_ (in my setup) expected.. IMHO results are still good enough to justify reporting signal in dBm rather than in "unspecified" units, so this is what this patch actually does. Results of my tests with a working rtl8187se card connected with coaxes and various RF attenuators to my AP are: Input (approx) | CCK meas | OFDM meas -------------------------------------- -30dBm | -32dBm | -31dBm -40dBm | -40dBm | -41dBm -50dBm | -50dBm | -55dBm -60dBm | -59dBm | -63dBm -70dBm | -69dBm | -73dBm -80dBm | -79dBm | -83dBm Also some real-field tests has been done (no coax, packets in the air) for the CCK measure method, and they resulted in reasonable values. Thanks-to: Bernhard Schiffner <bernhard@schiffner-limbach.de> [ for real-field tests] Signed-off-by: andrea.merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* PCI: Remove DEFINE_PCI_DEVICE_TABLE macro useBenoit Taine2014-08-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | We should prefer `struct pci_device_id` over `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines. This issue was reported by checkpatch. A simplified version of the semantic patch that makes this change is as follows (http://coccinelle.lip6.fr/): // <smpl> @@ identifier i; declarer name DEFINE_PCI_DEVICE_TABLE; initializer z; @@ - DEFINE_PCI_DEVICE_TABLE(i) + const struct pci_device_id i[] = z; // </smpl> [bhelgaas: add semantic patch] Signed-off-by: Benoit Taine <benoit.taine@lip6.fr> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
* rtl818x: use pci_zalloc_consistentJoe Perches2014-08-081-7/+4
| | | | | | | | | Remove the now unnecessary memset too. Signed-off-by: Joe Perches <joe@perches.com> Cc: "John W. Linville" <linville@tuxdriver.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* rtl818x_pci: fix pci probe returns success when it failsAndrea Merello2014-07-011-0/+4
| | | | | | | | | | | | | | There are several exit path from the PCI probe function. Some of them, that are taken in case of errors, forget to set the "err" variable, that is returned by the probe function. This can lead to the kernel thinking the probe function succeeds while it didn't, and this in turn causes extra calls to the "remove" function. This patch fix this problem by ensuring "err" variable is assigned to a proper non-zero value in each exit path. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x_pci: handle broken PIO mappingAndrea Merello2014-07-011-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All boards supported by this driver could work using PIO or MMIO for accessing registers. This driver tries to access HW by using MMIO, and, if this fails for somewhat reason, the driver tries to fall back to PIO mode. MMIO-mode is straightforward on all boards. PIO-mode is straightforward on rtl8180 only. On rtl8185 and rtl8187se boards not all registers are directly available in PIO mode (they are paged). On rtl8185 there are two pages and it is known how to switch page. PIO mode works, except for only one access to a register out of default page, recently added by me in the initialization code with patch: rtl818x_pci: Fix rtl8185 excessive IFS after CTS-to-self This can be easily fixed to work in both cases (MMIO and PIO). On rtl8187se, for a number of reasons, there is much more work to do to fix PIO access. PIO access is currently broken on rtl8187se, and it never worked. This patch fixes the said register write for rtl8185 and makes the driver to fail cleanly if PIO mode is attempted with rtl8187se boards. While doing this, I converted also a couple of printk(KERN_ERR) to dev_err(), in order to make checkpatch happy. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: disable buggy rate fallback mechanismAndrea Merello2014-07-011-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the driver configures mac80211 to provide two rates for each TX frame: One initial rate and one alternate fallback rate, each one with its retry count. HW does not support fully this: rtl8180 doesn't have support for rate scaling at all, and rtl8185/rtl8187SE supports it in a way that does not fit with mac80211: The HW does automatically fall back to the next lower rate, and only a lower limit can be specified, so the HW may TX also on rates in between the two rates specified by mac80211. Furthermore only the total TX retry count can be specified for each packet, while the number of TX attempts before scaling rate can be configured only globally (not per each packet). Currently the driver sets the HW auto rate fallback mechanism to quickly scale rate after a couple of retries, and it uses the alternate rate requested by mac80211 as fallback limit rate (and it does this even wrongly). The HW indeed will behave differently than what mac80211 mandates, that is probably undesirable, and the reported TX retry count may not refer to what mac80211 thinks, and this could fool mac80211. This patch makes the driver to declare to mac80211 to support only one rate configuration for each packet, and it does disable the HW auto rate fallback mechanism, relying only on SW and letting mac80211 to do all by itself. This should ensure correct operation and fairness respect to mac80211. Indeed here tests with iperf do not show significant performance differences. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: fix incorrect TX retry.Andrea Merello2014-07-011-1/+1
| | | | | | | | | | | | | HW is programmed with wrong retry count value for TX: Mac80211 passes to driver the number of times the TX should be attempted. The HW, instead, wants the number of time the TX should be retried if it fails the first time (assuming we have to TX it at least one time). This patch correct this. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x_pci: add comment pointing to the rtl8187se reference codeAndrea Merello2014-07-011-0/+1
| | | | | | | | | | | | | | | | | | Rtl8187se support has been added to the rtl818x_pci driver by extracting a lot of information from a rtl8187se Linux staging driver included in the kernel at the time rtl8187se support was added. The rtl818x_pci main file has a comment that advertises this. Recently this staging driver has been removed from the kernel, but I still feel it can be useful as "reference" code (in case of bugs, or to implement improvements in rtl818x_pci driver). This one-line patch adds a comment in rtl818x_pci driver to point people searching for that "reference code" to the last kernel version still containing it (3.14). Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x_pci: Fix rtl8185 excessive IFS after CTS-to-selfAndrea Merello2014-07-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Measuring time between _end_ of CTS-to-self and _end_ of datapacket (with a prism54 board and mac80211 hacked to let the MAC timestamp stay untouched in the radiotap header) resulted in about 300uS, while the datapacket itself should be by far shorter (less than 100uS) and IFS should be SIFS (10uS). This measure was confirmed whith a scope: about 250uS IFS has been seen between the two packets. This situation causes the CTS-to-self protection mechanism to work incorrectly due to the NAV expiring during, or even before beginning, the packet transmission, and it also causes the performances to be anyway reduced due to time waste. This problem has been seen at every packet TXed with CTS-to-self enabled on rtl8185 board. rtl8187se seems not affected (and rtl8180, being a 802.11b card, does not have CTS-to-self mechaninsm). This patch fixes this by adding a magic register write, making the board wait for correct SIFS after CTS-to-self packet. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x_pci: Fix BSSID register written incorrectlyAndrea Merello2014-07-011-3/+4
| | | | | | | | | | | | | | BSSID register was written with six byte-writes. It seems that, similarly to what happens with MAC registers, they needs to be written with one 16-bit and one 32-bit writes, otherwise the write does not work. The byte write didn't work only on my rtl8185, while it worked on rtl8180 and rtl8187se, BTW since there are probably a number of different ASIC revisions out of there, I let the change to affect all cards. It shouldn't hurt anyway. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x_pci: fix possible RX descriptor invalid data readAndrea Merello2014-06-191-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | RX descriptor data must be read only if the descriptor has been fully updated by HW. There is a "ownership" flag in the descriptor itself to test this. The driver code contains a read for the "ownership" flag and, after it, other read access for descriptor data. This is in DMA coherent memory, that is _not_ guaranteed to be immune to instruction reordering, thus it is possible that the descriptor data is read _before_ the "ownership" flag. This can theoretically lead to a DMA/CPU race that may end up with the driver reading the data when it is still not valid, and the "ownership" bit just after enough time that the HW make the whole descriptor valid. The driver will in this case believe the data is valid, but it will use the invalid data read earlier. In order to avoid this, this patch adds a rmb() to force the "ownership" bit read to be issued before other descriptor data reads are attempted. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x_pci: provide dBm signal information for rtl8185Andrea Merello2014-06-191-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes the driver report signal information for rtl8185 boards using dBm instead of unspecified unit. Rtl8180 remains untouched. I did some tests to confirm the correctness of the measure performed by the board and it seems reasonably correct. The test setup has been made by connecting an AP with coax and RF attenuators to the card antenna port. In order to get a reference measure I tried with several cards with different chipset I own. I found that many gave different results, and I finally selected two cards that gave me consistent results to use as reference: AR9271 and Prism54-usb (isl3887 with Frisbee radio). Using this references I compared the RSSI information with my rtl8185 and I repeated tests with three different attenuation values, increasing attenuation by 10dB each step. I made only relative measures, making NO assumption about source power. CCK measures seem very close to my references, OFDM are a little bit less precise but, considering that these cards are not measuring instrumentation, IMHO this is still fairly good. CCK measures (1Mbps beacons) ATTENUATOR 1 p54usb: -58dBm ath9k_htc: -59dBm rtl8185: -59dBm ATTENUATOR 2 p54usb: -67dBm ath9k_htc: -68dBm rtl8185: -70dBm ATTENUATOR 3 p54usb: -78dBm ath9k_htc: -79dBm rtl8185: -79dBm OFDM measures (54Mbps ping) ATTENUATOR 1 p54usb: -58dBm ath9k_htc: -57dBm rtl8185: -62dBm ATTENUATOR 2 p54usb: -68dBm rtl8185: -71dBm Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x_pci: make RSSI code more readableAndrea Merello2014-06-191-5/+8
| | | | | | | | remove the if-else chains and use switch-case to make code more readable and avoiding long lines that broke in several lines Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: make CTS-to-self protection workAndrea Merello2014-05-071-5/+10
| | | | | | | | | | | | CTS protection was not working properly because the HW still need RTS flag to be asserted, and it need also RTS rate field to be set with CTS-to-self rate and RTS duration field to be filled with CTS-to-self duration. This patch makes the driver to do this. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: report mac80211 short preamble RX flagAndrea Merello2014-05-071-0/+2
| | | | | | | | | | | | This patch make it possible to mac80211 to know whether a frame has been received with short preamble. It simply checks for the "splcp" flag in the RX status descriptor, and eventually set RX_FLAG_SHORTPRE in mac80211 rx status structure. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: be paranoid in stopping unused queues.Andrea Merello2014-04-221-1/+4
| | | | | | | | | | | | | | HW should never attempt to perform DMA for unused queues. For rtl8187se this is ensured by setting a dedicated register at init time, before enabling TX. In rtl8180/5 the register is only written at the first TX (because in rtl8180/5 it serves also to kick DMA for used queues). This should be enough, but it's worth to add a register write at init time, before enabling TX. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: fix enabled interrupt mask for rtl8187seAndrea Merello2014-04-221-3/+2
| | | | | | | | | | | | | | | | | | | | When preparing the bitfield to write to HW register, the high-priority queue error interrupt bit is set two times, and the beacon queue TX-OK interrupt is not enabled. Currently this have no functional impact because the high-priority queue is not used at all, and the beacon queue is not used yet. This patch removes high-priority queue bits and it adds the beacon queue missing bit. It removes also the management queue bits because it is not used. This was found by static code analyzer. Reported-by: Fengguang Wu <fengguang.wu@intel.com> Reported-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: enable rtl8187se supportAndrea Merello2014-03-271-4/+35
| | | | | | | | | Finally make rtl8187se works (hopefylly). This patch adds PCI ID for rtl8187, updates copyright notes and updates MODULE_DESCRIPTION. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: detect rtl8187se cardAndrea Merello2014-03-271-2/+15
| | | | | | | | Add case to detect the rtl8187se card and its RF frontend. In this case set also accordingly mac80211 queue number. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: add WMM parameters configuration for rtl8187seAndrea Merello2014-03-271-2/+60
| | | | | | | | | Introduce a new function to configure AC parameters for TX queues on rtl8187se cards, and hook it onto mac80211 in order to enable WMM support. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: make sure RTL818X_MSR_ENEDCA is set for rtl8187seAndrea Merello2014-03-271-0/+4
| | | | | | | | MSR register for rtl8187se must always have ENEDCA flag set. Write it accordingly when updated on BSS change. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: add ERP configuration for rtl8187seAndrea Merello2014-03-271-6/+10
| | | | | | | | | | This patch adds ERP configuration support for rtl8187se to the existing ERP configuration function. It needs a different register offset and it must not apply rtl8185 workaround. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: add rtl8187se HW initializationAndrea Merello2014-03-271-9/+159
| | | | | | | | | This patch adds few functions that initializes extra stuff that is present only in rtl8187se HW, and it modify the existing HW initialization function where necessary Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: add RF code for rtl8225 zebra v4Andrea Merello2014-03-271-0/+1
| | | | | | | | | | | This patch introduce new RF code for rtl8225 zebra v4 radio frontend. This code contains a lot of black magic and it can work probably only with the radio embdedded in the rtl8187se single-chip. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: introduce functions for setting ANAPARAM 2 and 3 paramsAndrea Merello2014-03-271-0/+40
| | | | | | | | | | | | rtl8180 has one register for analog converters setting ,rtl8185 has two and rtl8187se has three. Setting those registers require more than a simple write, and for one of them a function is already provided. This patch introduces functions for the other two. rtl8187se will use them. rtl8185 doesen't yet, but should Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: add rtl8187se params to eeprom readingAndrea Merello2014-03-271-1/+17
| | | | | | | | rtl8187se nees extra parameters to be read from the eeprom. This patch adds support for it Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: config carbus register for rtl8187seAndrea Merello2014-03-271-7/+21
| | | | | | | | | | configuration of carbus-related registers is different for rtl8187se. Introduce a dedicated function that does it for all cards in the proper way Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: add TX queue mapping and support for rtl8187seAndrea Merello2014-03-271-5/+79
| | | | | | | | | | This patch adds tx queue mapping for rtl8187se and a long comment block about their usages. It adapts the TX function to use that map and it sets properly the TX descriptor rtl8187se-only fields Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: don't write MAR registers for rtl8187seAndrea Merello2014-03-271-2/+7
| | | | | | | | MAR registers are not present in rtl8187se, and attempting to write to them must be avoided Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: introduce functions to enable/disable ints and add support for ↵Andrea Merello2014-03-271-3/+33
| | | | | | | | | | | rtl8187se This patch introduces two dedicated functions for enabling and disabling ints. Support for rtl8187se is also added to them Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: add ISR for rtl8187seAndrea Merello2014-03-271-1/+56
| | | | | | | | rtl8187se has more queues and different ISR flags. This patch adds a separated ISR handler for rtl8187se Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: support for rtl8187se RX descriptorsAndrea Merello2014-03-271-13/+39
| | | | | | | | | | | | | Currently RX status descriptor and RX command descriptor are represented using the same struct type. This patch splits this by introducing different types for rx status and command descriptor. Doing this make it possible to handle rtl8187se RX descriptors easier. This patch do also this by adding specific cases where needed. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: add basic rate configuration support for rtl8187seAndrea Merello2014-03-271-1/+5
| | | | | | | | | Basic rate configuration is a bit different for rtl8187se. Adding this also fixes the gcc warning introduced in last patch about unhandled case in switch. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: rationalize TX queuesAndrea Merello2014-03-271-15/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | On currently supported HW there are four TX queues (three for normal packets and one for beacons). The driver uses just one TX queue, and declare to mac80211 to support just one queue, but it allocates coherent memory for all queues. Furthermore the TX is code is written assumimg four queues exists, and even if we decide to enable more queues in future, its mapping rule to mac80211 is fixed. This means we have memory waste on rtl8180/rtl8185, and we have also not enough flexibility to add support for boards (rtl8187se) that will use more queues. This patch changes things in order to allocate coherent memory only for the queues effectively used and it make it possible to specify how to map hardware queues on mac80211 queues, that will be used by rtl8187se code as soon it will be merged. Note: even if the beacon queue is currently unused, this should change, so I kept it. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: fix DMA register are written two timesAndrea Merello2014-03-271-6/+0
| | | | | | | | | | | Hw DMA registers are written in rtl8180_init_hw function. They are also written again just after calling rtl8180_init_hw. There is no point in doing this twice. Remove those redundant register writes from rtl8180_start. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: move eeprom read stuff in a separate functionAndrea Merello2014-03-171-57/+71
| | | | | | | | | | | | Eeprom read operations are mixed in the probe function. Make the code more readable and clean by extracting this code and moving it in a dedicated function. The variable eeprom_cck_table_adr, now useless, is here because it will be needed for rtl8187se support, that I hope to add soon. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: make *IFS and CW tunable by mac80211, and set them in the proper placeAndrea Merello2014-03-171-2/+81
| | | | | | | | | | | | | | | | | | | SLOT, SIFS, DIFS, EIFS, CW and ACK-timeout registers are set in an RF-code callback and their values are fixed. This patch moves this off the rf-code, and introduce two new functions that calculate these values depending by slot time and CW values requested by mac80211. This seems to improve performances on my setup. Currently the ack and slot time values could be stored in a local variable, but this patch stores it in the driver "priv" structure because it will be useful for rtl8187se support that will be added (hopefully) soon. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: support for BSS_CHANGED_BASIC_RATESAndrea Merello2014-03-171-6/+45
| | | | | | | | | | | | | Basic rates setting is done with hardcoded register write with fixed settings. This patch introduces a new function that makes it possible to configure basic rates and it add a check for mac80211 BSS_CHANGED_BASIC_RATES flag in order to eventually invoke that function when needed. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl8180: prepare to handle more than two chip typesAndrea Merello2014-03-141-14/+23
| | | | | | | | | | | | | | | | | | | | | | Currently a "r8185" integer variable is used as a boolean flag to indicate whether the card is a rtl8185 or not. Since now the driver supports only rtl8185 and rtl8180 cards, if "r8185" variable is zero then the card is implicitly assumed to be a rtl8180. Now I'm preparing to add support for a third card type (rtl8187se). This patch changes the "r8185" flag with an enum variable to explicitly indicate which card type we have. I'm submitting this this patch now, even if I still have to submit other patches that not pertain with rtl8187se support, because IMHO it's not worth rebasing them on the current code, using r8185 flag, and then changing them back again nearly immediately. BTW if someone feels I really should do this, please tell me.. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x: make sure TX descriptor writes are done before kicking DMAandrea merello2014-03-041-0/+6
| | | | | | | | | | | | | | | The TX descriptors are consumed by the HW using DMA. Even if in the driver code the TX descriptor writes appears before the HW "dma kick" register writes, the CPU may reorder them. If this happens, the TX may not happen at all becase the "valid" descriptor flag may have not been set yet. This patch adds a write memory barrier to ensures the TX descriptor is written before writing to the HW "dma kick" register. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x: Make sure the TX descriptor "valid" flag is written by lastandrea merello2014-03-041-0/+5
| | | | | | | | | | | | | | | | | | | | The TX descriptors are consumed by the HW using DMA. Even if in the driver code the memory write that sets the "valid" flag appears after all other writes, the CPU may reorder writes, causing the HW to consider as valid a not-fully-written yet descriptor. This may cause HW incorrect behaviour. This can happen because (AFAIK) the HW may attempt DMA asynchronously without waiting to be kicked by the following register write. This patch adds a write memory barrier to enforce writes ordering. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x: add comments to explain few not obvious HW configs.andrea merello2014-02-281-0/+12
| | | | | | | | | | | | | | | Certain HW options (TX packet retry count, CW configuration and TX power configuration) can be specified in both the TX packet descriptor and also into HW "global" registers. The HW is thus configured to honour the global register or the TX descriptor field depending by the case. This patch adds few comments that hopefully clarify in which cases the driver uses one method and in which cases it uses the other. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x: make dev_alloc_skb() null pointer check to really workandrea merello2014-02-281-3/+4
| | | | | | | | | | | | | | | | | | | | During driver initialization, some skbs are preallocated for RX. Currenly if the allocation fails, the driver's allocation routine exits immediatly but it will return zero (success) anyway. In this way the driver will continue initialization with buggy pointers around. This patch makes the driver's allocation routine to return an error value and to print a complaint message when skb allocation fails. In this way its caller will not go further, avoinding the driver to successfully load, and preventing dereferencing buggy pointers. An hint is thus printed about why the driver failed. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x: check for pci_map_single() success when initializing RX ringandrea merello2014-02-281-0/+7
| | | | | | | | | | | | | During initialization a number of RX skbs are allocated and mapped for DMA. Currently if pci_map_single() fails, it will result in passing to the HW a wrong DMA address (to write to!). This patch adds check for this condition and eventually causes the driver not to initialize, avoiding at least dangerous DMAs. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x: pci_iomap() should pair with pci_iounmap()andrea merello2014-02-281-1/+1
| | | | | | | | | | | Currently the driver uses pci_iomap() but iounmap() is called in the error path Change to use pci_iounmap() instead. Reported-by: Huqiu Liu <liuhq11@mails.tsinghua.edu.cn> Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* rtl818x: Explicitly enable contetion windowandrea merello2014-02-281-0/+2
| | | | | | | | | | | | Currently the contention window enable/disable HW flag is not touched by the driver. This patch explicitly set it to the correct value to make sure contention window is enabled (AFAIK contention window must be enabled in most (if not all) cases. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* Merge branch 'master' of ↵John W. Linville2014-02-131-3/+20
|\ | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless