summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2014-10-27net: fec: try better napi packet processing algorithmfec-testingRussell King
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17RestRussell King
2014-10-17net:fec: move copying receive function out of lineRussell King
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: implement almost zero-copy receive pathRussell King
iMX6 SoCs have an IP accelerator which can pad and strip two bytes in the FIFO at the beginning of each packet. Since the FEC has alignment restrictions on the buffer addresses, this feature is particularly interesting for receive as it allows us to receive an appropriately aligned packet for IP. This allows us to reduce the CPU overhead by avoiding copying large packets - and in the spirit of all network drivers which use this trick, we provide a copybreak tunable which allows the packet size to be copied to be adjusted. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: move syncing of receive buffer back to device directly after copyRussell King
Move the syncing for the DMA buffer back to the device immediately after we've done with copying data from it. This means the logic in the receive path handing the copying of data is now located together. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: move final receive to separate functionRussell King
Move the final receive code sequence to a separate function. Performance tests show that having lots of code integrated into one big function can make the driver performance very dependent on compiler behaviour, and more reliable performance can be obtained by separating this out. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: simplify packet data copying and vlan tag removalRussell King
Implement this as two distinct code paths: this allows non-tagged traffic to be copied in one go, whereas tagged traffic needs to be copied in two separate chunks. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: extract and record vlan tag receive processing in one placeRussell King
Rather than having the vlan tag processing scattered in multiple different places, we can now localize the reading of the tag with storing the tag in the skb. Group this code together. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: move skb allocation earlierRussell King
Move the skb allocation before we sync the buffer for CPU access. In order to do this, we need to detect whether the packet contains a VLAN header so we can adjust the packet size appropriately. This allows us to tidy the code a little in the following patches. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: move quirks into fec_enet_private data structureRussell King
Move the quirks bitmap into the fec_enet_private data structure so we don't need to keep reading it via a chain of pointers. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: unsorted hacksRussell King
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: even larger ringsRussell King
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: remove unnecessary codeRussell King
fec_enet_bd_init() already frees the transmit skbuffs, so there's no need for fec_restart() to do this again. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: allocate descriptor rings at device open, and free on device closeRussell King
The driver has had a memory leak for quite some time: when the device is probed, we allocate a page for the descriptor rings, but we never free this. Rather than trying to free it on the various probe failure paths, move its allocation to device open time - we have to restart the FEC for this to take effect. This also means we can free the descriptor rings when we clean up in the device close function, which gives this a nice symmetry. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net:fec: convert scatter-gather supportRussell King
Add scatter-gather support for SKB transmission. This allows the driver to make use of GSO, which when enabled allows the iMX6Q to increase TCP transmission throughput from about 320 to 420Mbps, measured with iperf 2.0.5 We adjust the minimum transmit ring space according to whether SG support is enabled or not. This allows non-SG configurations to avoid the tx ring reservation necessary for SG, thereby making full use of their available ring (since non-SG requires just one tx ring entry per packet.) Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17Revert FEC commitsRussell King
This reverts commit d5e42c86e07935f3cab4dcfca787a733146d0c70 ("net: fec: Don't clear IPV6 header checksum field when IP accelerator enable"). This reverts commit 79f339125ea316e910220e5f5b4ad30370f4de85 ("net: fec: Add software TSO support"), as 96c50caa5148 ("net: fec: Enable IP header hardware checksum") causes a regression with IPv6 by overwriting the location where the IPv4 header checksum would be: - 0x0000: 6000 0000 0028 0640 fd8f 7570 feb6 0001 `....(.@..up.... + 0x0000: 6000 0000 0028 0640 fd8f 0000 feb6 0001 `....(.@........ This reverts commit 96c50caa5148e0e0a077672574785700885c6764 ("net: fec: Enable IP header hardware checksum"), as it causes a regression with IPv6 by overwriting the location where the IPv4 header checksum would be: - 0x0000: 6000 0000 0028 0640 fd8f 7570 feb6 0001 `....(.@..up.... + 0x0000: 6000 0000 0028 0640 fd8f 0000 feb6 0001 `....(.@........
2014-10-17net:fec: add ethtool support for tx/rx ring sizesRussell King
Add ethtool support to retrieve and set the transmit and receive ring sizes. This allows runtime tuning of these parameters, which can result in better throughput with gigabit parts. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: move removal of FCS from packet length to single locationRussell King
Rather than keep subtracting four off the packet length throughout the receive path, do it at the point we read the packet length from the descriptor. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: avoid checking more flags than necessary in rx pathRussell King
Avoid checking for the enhanced buffer descriptor flag and the receive checksumming/vlan flags - we now only set these feature flags if we already know that we have enhanced buffer descriptors. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: only enable CTAG_RX and IP checksumming if we have enhanced buffer ↵Russell King
descriptors Only set the vlan tag and ip checksumming options if we have enhanced buffer descriptors - enhanced descriptors are required for these features. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: move vlan receive flag into our private flagsRussell King
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: move receive checksum flags into new flags memberRussell King
The receive checksum flag is only changed upon ethtool configuration, so move it into the flags member. In any case, this is checked alongside the BUFDESC_EX flag. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: move bufdesc_ex flag into flagsRussell King
Add a new flags field to contain the mostly static driver configuration, the first of which is the bufdesc_ex flag. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: add locking for MDIO bus accessRussell King
Both fec_restart() and fec_stop() both perform a reset of the FEC. This reset can result in an in-process MDIO transfer being terminated, which can lead to the MDIO read/write functions timing out. Add some locking to prevent this occuring. We can't use a spinlock for this as the MDIO accessor functions use wait_for_completion_timeout(), which sleeps. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: consolidate common parts of mdio read/writeRussell King
There is a commonality to fec_enet_mdio_read() and fec_enet_mdio_write() which can be factored out. Factor that commonality out, since we need to add some locking to prevent resets interfering with MDIO accesses. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: adjust ring threshold according to SG settingRussell King
When SG is enabled, we must ensure that there are up to 1+MAX_SKB_FRAGS free entries in the ring. When SG is disabled, this can be reduced to one, and we can allow smaller rings. Adjust this setting according to the state of SG. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: better indexing for receive descriptor ringRussell King
Extend the previous commit to the receive descriptor ring as well. This gets rid of the two nextdesc/prevdesc functions, since we now just need to get the descriptor for an index instead. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: better indexing for transmit descriptor ringRussell King
Maintaining the transmit ring position via pointers is inefficient, especially when it involves complex pointer manipulation, and overlap with the receive descriptor logic. Re-implement this using indexes, and a single function which returns the descriptor (appropriate to the descriptor type). As an additional benefit, using a union allows cleaner access to the descriptor. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: use a union for the buffer descriptorsRussell King
Using a union gives clearer C code than the existing solution, and allows the removal of some odd code from the receive path whose purpose was to merely store the enhanced buffer descriptor. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: add barrier to receive path to ensure proper orderingRussell King
Just as we need a barrier in the transmit path, we also need a barrier in the receive path to ensure that we don't modify a handed over descriptor. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: add barrier to transmit path to ensure proper orderingRussell King
Ensure that the writes to the descriptor data is visible to the hardware before the descriptor is handed over to the hardware. Having discussed this with Will Deacon, we need a wmb() between writing the descriptor data and handing the descriptor over to the hardware. The corresponding rmb() is in the ethernet hardware. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: fix calculation of free packetsRussell King
The FEC maintains two pointers into the transmit ring: next - this is the insertion point in the ring, and points at a free entry which can be written to. dirty - this is the last dirty entry which we successfully cleaned, and is always incremented prior to cleaning an entry. The calculation used for the number of free packets is slightly buggy, which is: entries = dirty - next - 1 if (entries < 0) entries += size; Let's take some examples: At ring initialisation, dirty is set to size-1, and next is set to 0. This gives: entries = size-1 - 0 - 1 = size - 2 => size - 2 But hang on, we have no packets in the empty ring, so why "size - 2" ? Let's also check if we back the pointers up by one position - so dirty=size-2, next=size-1. entries = size-2 - size-1 - 1 = -2 - -1 - 1 = -2 => size - 2 Okay, so that's the same. Now, what about the "ring full" criteria. We can never completely fill the transmit ring, because a completely full ring is indistinguishable from a completely empty ring. We reserve one entry to permit us to keep a distinction. Hence, our "full" case is when both pointers are equal, so dirty=size-1, next=size-1. entries = size-1 - size-1 - 1 = -1 => size - 1 This is where things break down - in this case, the function is not returning the number of free entries in the ring, because it should be zero! Fix this by changing the calculation to something which reflects the actual ring behaviour: entries = dirty - next; if (entries < 0) entries += size; Plugging the above three cases into this gives: entries = size-1 - 0 = size - 1 => size - 1 entries = size-2 - size-1 = -1 => size - 1 entries = size-1 - size-1 = 0 => 0 Here, we have more correct behaviour (remembering that we have reserved one entry as described above). The perverse thing is that every test at this function's called site almost took account of the off-by-one error. Let's fix this to have saner semantics - returning the number of permissible free entries in the ring which can then be compared using expected tests against our required numbers of packets. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: move netif_wake_queue() out of transmit loopRussell King
It is wasteful to keep checking whether we're stopped, and the number of free packets to see whether we should restart the queue for each entry in the ring which we process. Move this to the end of the processing so we check once per ring clean. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: clean up fec_enet_get_free_txdesc_num() callsitesRussell King
Clean up the various callsites to this function; most callsites are using a temporary variable and immediately following it with a test. There is no need of a temporary variable for this. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: move transmit dma ring address calculation to fec_enet_init()Russell King
Move the calculation of the transmit DMA ring address to fec_enet_init() so the CPU and DMA ring address calculations are localised. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: increase receive ring sizeRussell King
Increasing the receive ring size allows more packets to be received before we run out of ring entries to store the packets. With 16 ring entries, this corresponds with a maximum of 16 * 1534 bytes, or just 24KiB. At gigabit speeds, this would take around 200us to fill. Increasing this to 512 entries gives us more scope when we have busy workloads, as it increases the ring to 767K, and around 6.3ms. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: add byte queue limits supportRussell King
Add support for byte queue limits, which allows the network schedulers to control packet latency and packet queues more accurately. Further information on this feature can be found at https://lwn.net/Articles/469652/ Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: improve UDP performanceRussell King
UDP performance is extremely poor. iperf reports UDP receive speeds in the range of 50Mbps with a high packet loss. The interface typically reports a few thousand overrun errors per iperf run. This is far from satisfactory. Adjust the receive FIFO thresholds to reduce the number of errors. Firstly, we decrease RAFL (receive almost full threshold) to the minimum value of 4, which gives us the maximum available space in the FIFO prior to indicating a FIFO overrun condition. Secondly, we adjust the RSEM value to send a XOFF pause frame early enough that an in-progress transmission can complete without overflowing the FIFO. Document these registers and the changes being made in the driver. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: improve flow control supportRussell King
The FEC hardware in iMX6 is capable of separate control of each flow control path: the receiver can be programmed via the receive control register to detect flow control frames, and the transmitter can be programmed via the receive FIFO thresholds to enable generation of pause frames. This means we can implement the full range of flow control: both symmetric and asymmetric flow control. We support ethtool configuring all options: forced manual mode, where each path can be controlled individually, and autonegotiation mode. In autonegotiation mode, the tx/rx enable bits can be used to influence the outcome, though they don't precisely define which paths will be enabled. One combination we don't support is "symmetric only" since we can always configure each path independently, a case which Linux seems to often get wrong. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: verify checksum offsetRussell King
Verify that the checksum offset is inside the packet header before we zero the entry. This ensures that we don't perform an out of bounds write. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: avoid hitting transmitter if it is still runningRussell King
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: ensure that we dma unmap the transmit descriptorsRussell King
On transmit timeout or close, dirty transmit descriptors were not being correctly cleaned: the only time that DMA mappings are cleaned is when scanning the TX ring after a transmit interrupt. Fix this. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-17net: fec: fix receive error handlingRussell King
The FEC receive error handling suffers from several problems: 1. When a FIFO overrun error occurs, the descriptor is closed and reception stops. The remainder of the packet is discarded by the MAC. The documentation states that other status bits are invalid, and they will be zero. However, practical experience on iMX6 shows this is not the case - the CR (crc error) bit will also be set. This leads to each FIFO overrun event incrementing both the fifo error count and the crc error count, which makes the error statistics less useful. Fix this by ignoring all other status bits of the FIFO overrun is set, and add a comment to that effect. 2. A late collision invalidates all but the overrun condition; the remaining error conditions must be ignored. 3. Despite accounting for errors, it continues to receive the errored packets and pass them into the network stack as if they were correctly received. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2014-10-05Linux 3.17Linus Torvalds
2014-10-05Merge tag 'scsi-fixes' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi Pull SCSI fixes from James Bottomley: "This is a set of two small fixes, both to code which went in during the merge window: cxgb4i has a scheduling in atomic bug in its new ipv6 code and uas fails to work properly with the new scsi-mq code" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: [SCSI] uas: disable use of blk-mq I/O path [SCSI] cxgb4i: avoid holding mutex in interrupt context
2014-10-04Merge tag 'tiny/kconfig-for-3.17' of ↵Linus Torvalds
https://git.kernel.org/pub/scm/linux/kernel/git/josh/linux Pull kconfig fixes for tiny setups from Josh Triplett: "Two Kconfig bugfixes for 3.17 related to tinification. These fixes make the Kconfig "General Setup" menu much more usable" * tag 'tiny/kconfig-for-3.17' of https://git.kernel.org/pub/scm/linux/kernel/git/josh/linux: init/Kconfig: Fix HAVE_FUTEX_CMPXCHG to not break up the EXPERT menu init/Kconfig: Hide printk log config if CONFIG_PRINTK=n
2014-10-03init/Kconfig: Fix HAVE_FUTEX_CMPXCHG to not break up the EXPERT menuJosh Triplett
commit 03b8c7b623c80af264c4c8d6111e5c6289933666 ("futex: Allow architectures to skip futex_atomic_cmpxchg_inatomic() test") added the HAVE_FUTEX_CMPXCHG symbol right below FUTEX. This placed it right in the middle of the options for the EXPERT menu. However, HAVE_FUTEX_CMPXCHG does not depend on EXPERT or FUTEX, so Kconfig stops placing items in the EXPERT menu, and displays the remaining several EXPERT items (starting with EPOLL) directly in the General Setup menu. Since both users of HAVE_FUTEX_CMPXCHG only select it "if FUTEX", make HAVE_FUTEX_CMPXCHG itself depend on FUTEX. With this change, the subsequent items display as part of the EXPERT menu again; the EMBEDDED menu now appears as the next top-level item in the General Setup menu, which makes General Setup much shorter and more usable. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Acked-by: Randy Dunlap <rdunlap@infradead.org> Cc: stable <stable@vger.kernel.org>
2014-10-03init/Kconfig: Hide printk log config if CONFIG_PRINTK=nJosh Triplett
The buffers sized by CONFIG_LOG_BUF_SHIFT and CONFIG_LOG_CPU_MAX_BUF_SHIFT do not exist if CONFIG_PRINTK=n, so don't ask about their size at all. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Acked-by: Randy Dunlap <rdunlap@infradead.org> Cc: stable <stable@vger.kernel.org>
2014-10-03Merge branch 'i2c/for-current' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux Pull i2c fixes from Wolfram Sang: "Two i2c driver bugfixes" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: qup: Fix order of runtime pm initialization i2c: rk3x: fix 0 length write transfers
2014-10-03Merge tag 'trace-fixes-v3.17-rc7' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace Pull trace ring buffer iterator fix from Steven Rostedt: "While testing some new changes for 3.18, I kept hitting a bug every so often in the ring buffer. At first I thought it had to do with some of the changes I was working on, but then testing something else I realized that the bug was in 3.17 itself. I ran several bisects as the bug was not very reproducible, and finally came up with the commit that I could reproduce easily within a few minutes, and without the change I could run the tests over an hour without issue. The change fit the bug and I figured out a fix. That bad commit was: Commit 651e22f2701b "ring-buffer: Always reset iterator to reader page" This commit fixed a bug, but in the process created another one. It used the wrong value as the cached value that is used to see if things changed while an iterator was in use. This made it look like a change always happened, and could cause the iterator to go into an infinite loop" * tag 'trace-fixes-v3.17-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: ring-buffer: Fix infinite spin in reading buffer