Commit Graph

22842 Commits

Author SHA1 Message Date
Adrian Chadd
9a842e8b59 Begin breaking apart the receive setup/stop path in preparation for more
"correct" handling of frames in the RX pending queue during interface
transitions.

* ath_stoprecv() doesn't blank out the descriptor list - that's what
  ath_startrecv() does. So, change a comment to reflect that.

* ath_stoprecv() does include a large (3ms) delay to let pending DMA
  complete. However, I'm under the impression that the stopdma hal
  method does check for a bit in the PCU to indicate DMA has stopped.
  So, to help with fast abort and restart, modify ath_stoprecv() to take
  a flag which indicates whether this is needed.

* Modify the uses of ath_stoprecv() to pass in a flag to support the
  existing behaviour (ie, do the delay.)

* Remove some duplicate PCU teardown code (which wasn't shutting down DMA,
  so it wasn't entirely correct..) and replace it with a call to
  ath_stoprecv(sc, 0) - which disables the DELAY call.

The upshoot of this is now channel change doesn't simply drop completed
frames on the floor, but instead it cleanly handles those frames.
It still discards pending TX frames in the software and hardware queues
as there's no (current) logic which forcibly recalculates the rate control
information (or whether they're appropriate to be on the TX queue after
a channel change), that'll come later.

This still doesn't stop all the sources of queue stalls but it does
tidy up some of the code duplication.

To be complete, queue stalls now occur during normal behaviour -
they only occur after some kind of broken behaviour causes an interface
or node flush, upsetting the TX/RX BAW. Subsequent commits will
incrementally fix these and other related issues.

Sponsored by:	Hobnob, Inc.
2011-11-19 21:05:31 +00:00
Rafal Jaworowski
8817e1bffe Initial version of cesa(4) driver for Marvell crypto engine and security
accelerator.

The following algorithms and schemes are supported:
 - 3DES, AES, DES
 - MD5, SHA1

Obtained from:	Semihalf
Written by:	Piotr Ziecik
2011-11-19 16:30:06 +00:00
Hans Petter Selasky
3ddd1777d5 Simplify the usb_pause_mtx() function by factoring out the generic parts
to the kernel's pause() function. The pause() function can now be used
when cold != 0. Also assert that the timeout in system ticks must be
positive.

Suggested by:	Bruce Evans
MFC after:	1 week
2011-11-19 11:17:27 +00:00
Hans Petter Selasky
11bcf702f4 Move the device_delete_all_children() function from usb_util.c
to kern/subr_bus.c. Simplify this function so that it no longer
depends on malloc() to execute. Identify a few other places where
it makes sense to use device_delete_all_children().

MFC after:	1 week
2011-11-19 10:11:50 +00:00
Philip Paeps
76a869385c sfxge: Remove interrupt self-test code
It's not currently used; it didn't build on 32-bit and the previous build fix
is incorrect.  If we really implement self-tests we can do this again
properly.

Submitted by:	Ben Hutchings <bwh -at- solarflare.com>
MFC after:	3 weeks
2011-11-19 09:16:52 +00:00
Philip Paeps
02602e0ebb sfxge: Fix if_baudrate reports
This field is supposed to be set to the interface bit rate, but for some
reason I thought it was denominated in kilobits.  Multiply the values up
accordingly, taking care to saturate rather than overflow on 32-bit
architectures.

Submitted by:	Ben Hutchings <bwh -at- solarflare.com>
MFC after:	3 weeks
2011-11-19 09:13:58 +00:00
Marius Strobl
dcf47c2ba5 There's no need export the device interface methods of miibus(4). 2011-11-18 22:58:13 +00:00
Marius Strobl
99172ab4b8 - Add a hint.miibus.X.phymask hint, allowing do individually exclude PHY
addresses from being probed and attaching something including ukphy(4)
  to it. This is mainly necessarily for PHY switches that create duplicate
  or fake PHYs on the bus that can corrupt the PHY state when accessed or
  simply cause problems when ukphy(4) isolates the additional instances.
- Change miibus(4) to be a hinted bus, allowing to add child devices via
  hints and to set their attach arguments (including for automatically
  probed PHYs). This is mainly needed for PHY switches that violate IEEE
  802.3 and don't even implement the basic register set so we can't probe
  them automatically. However, the ability to alter the attach arguments
  for automatically probed PHYs is also useful as for example it allows
  to test (or tell a user to test) new variant of a PHY with a specific
  driver by letting an existing driver attach to it via manipulating the
  IDs without the need to touch the source code or to limit a Gigabit
  Ethernet PHY to only announce up to Fast Ethernet in order to save
  energy  by limiting the capability mask. Generally, a driver has to
  be hinted via hint.phydrv.X.at="miibusY" and hint.phydrv.X.phyno="Z"
  (which already is sufficient to add phydrvX at miibusY at PHY address
  Z). Then optionally the following attach arguments additionally can
  be configured:
  hint.phydrv.X.id1
  hint.phydrv.X.id2
  hint.phydrv.X.capmask
- Some minor cleanup.

Reviewed by:	adrian, ray
2011-11-18 22:39:46 +00:00
Marius Strobl
bab10b961f There's no need to read DC_10BTSTAT twice in dcphy_status(). 2011-11-18 21:23:13 +00:00
Marius Strobl
166e31d988 - There's no need to ignore the return value of mii_attach(9) when attaching
dcphy(4) (CID 9283).
- In dc_detach(), check whether ifp is NULL as dc_attach() may call the
  former without ifp being allocated (CID 4288).

Found with:	Coverity Prevent(tm)
2011-11-18 21:22:43 +00:00
Pyun YongHyeon
89b2411bc3 Partially revert r218788. r218788 removed calling dc_setcfg() for
!DC_IS_ADMTEK in dc_miibus_statchg(). This change broke link
establishment of Intel 21143 with dcphy(4) where it stuck in
"ability detect" state without completing auto-negotiation.
Also nuke dc_if_media as it's not actually used.

Submitted by:	marius
2011-11-18 19:38:19 +00:00
Hans Petter Selasky
8c09f3a15f Make some XHCI command timeouts less strict.
Reported by:	Jan Henrik Sylvester
MFC after:	1 week
2011-11-18 08:31:24 +00:00
Peter Grehan
10b59a9b4a Import virtio base, PCI front-end, and net/block/balloon drivers.
Tested on Qemu/KVM, VirtualBox, and BHyVe.

Currently built as modules-only on i386/amd64. Man pages not yet hooked
up, pending review.

Submitted by:	Bryan Venteicher  bryanv at daemoninthecloset dot org
Reviewed by:	bz
MFC after:	4 weeks or so
2011-11-18 05:43:43 +00:00
Adrian Chadd
ef27340c5b Flesh out some slightly dirty reset/channel change serialisation code
for the ath(4) driver.

Currently, there's nothing stopping reset, channel change and general
TX/RX from overlapping with each other. This wasn't a big deal with
pre-11n traffic as it just results in some dropped frames.
It's possible this may have also caused some inconsistencies and
badly-setup hardware.

Since locks can't be held across all of this (the Linux solution)
due to LORs with the network stack locks, some state counter
variables are used to track what parts of the code the driver is
currently in.

When the hardware is being reset, it disables the taskqueue and
waits for pending interrupts, tx, rx and tx completion before
it begins the reset or channel change.

TX and RX both abort if called during an active reset or channel
change.

Finally, the reset path now doesn't flush frames if ATH_RESET_NOLOSS
is set. Instead, completed TX and RX frames are passed back up to
net80211 before the reset occurs.

This is not without problems:

* Raw frame xmit are just dropped, rather than placed on a queue.
  The net80211 stack should be the one which queues these frames
  rather than the driver.

* It's all very messy. It'd be better if these hardware operations
  were serialised on some kind of work queue, rather than hoping
  they can be run in parallel.

* The taskqueue block/unblock may occur in parallel with the
  newstate() function - which shuts down the taskqueue and restarts
  it once the new state is known. It's likely these operations should
  be refcounted so the taskqueue is restored once no other areas
  in the code wish to suspend operations.

* .. interrupt disable/enable should likely be refcounted as well.

With this work, the driver does not drop frames during stuck beacon
or fatal errors and thus 11n traffic continues to run correctly.
Default and full resets however do still drop frames and it's possible
this may occur, causing traffic loss and session stalls.

Sponsored by:	Hobnob, Inc.
2011-11-18 05:06:30 +00:00
Eitan Adler
5d0d7ea8df - be more precise about the unit of measurement
Approved by:	jhb
MFC after:	3 days
2011-11-17 23:04:43 +00:00
Marius Strobl
dc1788e8b0 Implement prefetch_read_{many,once}() for sparc64 and fix compilation on
other !x86 architectures.
2011-11-17 22:59:16 +00:00
Marius Strobl
fb8ccc7840 Fix compilation on ILP32. 2011-11-17 22:56:40 +00:00
Pyun YongHyeon
d467ffaa66 Add preliminary support for RTL8168/8111F PCIe Gigabit ethernet.
H/W donated by:	RealTek Semiconductor Corp.
2011-11-17 22:07:50 +00:00
Pyun YongHyeon
6b0a8e0476 Add preliminary support for second generation RTL8105E PCIe
FastEthernet.

H/W donated by:	RealTek Semiconductor Corp.
2011-11-17 21:24:56 +00:00
Alexander Motin
72a61203fc Change the way how "not implemented" AHCI channels handled. Instead of
completely skipping them, create ahcich devices for them to allocate unit
numbers, but mark them as disabled to prevent driver probe and attach.

Last time some BIOSes tend to report unused channels as "not implemented".
This change makes ahcichX devices numbering consistent, independently of
connected disks. It makes per-channel driver hints usable and CAM devices
wiring possible on such systems.
2011-11-17 20:46:51 +00:00
Eitan Adler
f28cf62d17 - be more precise about the unit of measurement
Submitted by:	Oliver Pinter <oliver.pntr@gmail.com>
Approved by:	jhb
MFC after:	3 days
2011-11-17 15:46:37 +00:00
Luigi Rizzo
68b8534bdf Bring in support for netmap, a framework for very efficient packet
I/O from userspace, capable of line rate at 10G, see

	http://info.iet.unipi.it/~luigi/netmap/

At this time I am bringing in only the generic code (sys/dev/netmap/
plus two headers under sys/net/), and some sample applications in
tools/tools/netmap. There is also a manpage in share/man/man4 [1]

In order to make use of the framework you need to build a kernel
with "device netmap", and patch individual drivers with the code
that you can find in

	sys/dev/netmap/head.diff

The file will go away as the relevant pieces are committed to
the various device drivers, which should happen in a few days
after talking to the driver maintainers.

Netmap support is available at the moment for Intel 10G and 1G
cards (ixgbe, em/lem/igb), and for the Realtek 1G card ("re").
I have partial patches for "bge" and am starting to work on "cxgbe".
Hopefully changes are trivial enough so interested third parties
can submit their patches. Interested people can contact me
for advice on how to add netmap support to specific devices.

CREDITS:
    Netmap has been developed by Luigi Rizzo and other collaborators
    at the Universita` di Pisa, and supported by EU project CHANGE
    (http://www.change-project.eu/)
    The code is distributed under a BSD Copyright.

[1] In my opinion is a bad idea to have all manpage in one directory.
  We should place kernel documentation in the same dir that contains
  the code, which would make it much simpler to keep doc and code
  in sync, reduce the clutter in share/man/ and incidentally is
  the policy used for all of userspace code.
  Makefiles and doc tools can be trivially adjusted to find the
  manpages in the relevant subdirs.
2011-11-17 12:17:39 +00:00
Hans Petter Selasky
b3f52c578b Quirk all of ALCOR's mass storage devices instead of
quirking individual devices.

Submitted by:	Dmitry Luhtionov
MFC after:	1 week
2011-11-17 10:46:51 +00:00
Pyun YongHyeon
017f1c8db9 Disable PCIe ASPM (Active State Power Management) for all
controllers.
More and more RealTek controllers started to implement EEE feature.
Vendor driver seems to load a kind of firmware for EEE with
additional PHY fixups.  It is known that the EEE feature may need
ASPM support.  Unfortunately there is no documentation for EEE of
the controller so enabling ASPM may cause more problems.
2011-11-16 23:29:27 +00:00
Pyun YongHyeon
600af6c29b Add missing driver lock in SIOCSIFCAP handler. 2011-11-16 22:09:14 +00:00
Pyun YongHyeon
d56f7f5284 Add preliminary support for RTL8411 PCIe Gigabit ethernet with
integrated card reader.

H/W donated by:	RealTek Semiconductor Corp.
2011-11-16 22:05:38 +00:00
Pyun YongHyeon
a9e3362a07 Add preliminary support for RTL8402 PCIe FastEthernet with
integrated card reader.

H/W donated by:	RealTek Semiconductor Corp.
2011-11-16 21:37:45 +00:00
Pyun YongHyeon
355a415e92 Enable 64bit DMA addressing support for all msk(4) controllers.
Unnecessarily complex LE format used on Marvell controller was
main reason not to enable 64bit DMA addressing in driver.  If high
32bit address of DMA address of TX/RX buffer is changed, driver has
to generate a new LE.  In TX path, driver will keep track of lastly
used high 32bit address of DMA address and generate a new LE
whenever it sees high address change in the DMA address. In RX path,
driver will always use two LEs to specify 64bit DMA address of RX
buffer.  If the high 32bit address of DMA address of RX buffer is
the same as previous DMA address of RX buffer, driver does not have
to use two LEs but driver will use two LEs for simplicity in RX
ring management.

One of draw back for switching to 64bit DMA addressing is that the
large amount of LEs are used to specify 64bit DMA address such that
number of available LEs for TX/RX buffers are considerably reduced.
To mitigate the issue, increase number of available LEs from 256 to
384 for TX and from 256 to 512 for RX. For 32bit architectures,
msk(4) does not use 64bit DMA addressing to save resources.

Tested by:	das
2011-11-16 19:25:26 +00:00
Konstantin Belousov
d185f187b4 The sys/sysctl.h header is needed when MFI_DEBUG is defined.
Nod from:	jhb
2011-11-16 18:42:39 +00:00
Philip Paeps
e948693ed7 Add the sfxge(4) device driver, providing support for 10Gb Ethernet adapters
based on Solarflare SFC9000 family controllers.  The driver supports jumbo
frames, transmit/receive checksum offload, TCP Segmentation Offload (TSO),
Large Receive Offload (LRO), VLAN checksum offload, VLAN TSO, and Receive Side
Scaling (RSS) using MSI-X interrupts.

This work was sponsored by Solarflare Communications, Inc.

My sincere thanks to Ben Hutchings for doing a lot of the hard work!

Sponsored by:	Solarflare Communications, Inc.
MFC after:	3 weeks
2011-11-16 17:11:13 +00:00
John Baldwin
d1c5fc763a Add single-message MSI support to mfi(4). It is disabled by default but
can be enabled via the hw.mfi.msi tunable.  Many mfi(4) controllers also
support MSI-X, but in testing it seems that many adapters do not work with
MSI-X but do work with MSI.

MFC after:	2 weeks
2011-11-16 15:39:27 +00:00
Matt Jacob
7d3cea3137 Was chasing down a failure to load f/w on a 2400. It turns out that the card
is actually broken, or needs a BIOS upgrade for 64 bit loads, but this uncovered
a couple of misplaced opcode definitions and some missing continual mbox command
cases, so might as well update them here.
2011-11-16 02:52:24 +00:00
Bjoern A. Zeeb
dcc20f4b7f The maximum TSO frame size should be:
maximum IP datagram size (65535 bytes) +
	Ethernet header size (14 bytes) +
	2 * VLAN tag size (4 bytes) [1].

[1] We need to multiply by 2 to account for the double VLAN tag
    provision added in IEEE 802.1ad.

Submitted by:	David Somayajulu (david.somayajulu qlogic.com)
MFC after:	4 days
2011-11-16 02:00:55 +00:00
Hans Petter Selasky
96ef942084 Some brands of XHCI controllers needs more time to reset.
Reported by:	Jan Henrik Sylvester
MFC after:	1 week
2011-11-15 20:48:57 +00:00
Marius Strobl
d7ecd801ed As it turns out, r186347 actually is insufficient to avoid the use of the
curthread-accessing part of mtx_{,un}lock(9) when using a r210623-style
curthread implementation on sparc64, crashing the kernel in its early
cycles as PCPU isn't set up, yet (and can't be set up as OFW is one of the
things we need for that, which leads to a chicken-and-egg problem). What
happens is that due to the fact that the idea of r210623 actually is to
allow the compiler to cache invocations of curthread, it factors out
obtaining curthread needed for both mtx_lock(9) and mtx_unlock(9) to
before the branch based on kobj_mutex_inited when compiling the kernel
without the debugging options. So change kobj_class_compile_static(9)
to just never acquire kobj_mtx, effectively restricting it to its
documented use, and add a kobj_init_static(9) for initializing objects
using a class compiled with the former and that also avoids using mutex(9)
(and malloc(9)). Also assert in both of these functions that they are
used in their intended way only.
While at it, inline kobj_register_method() and kobj_unregister_method()
as there wasn't much point for factoring them out in the first place
and so that a reader of the code has to figure out the locking for
fewer functions missing a KOBJ_ASSERT.
Tested on powerpc{,64} by andreast.

Reviewed by:	nwhitehorn (earlier version), jhb
MFC after:	3 days
2011-11-15 20:11:03 +00:00
Eitan Adler
64589ec83f - add support for Titan VScom PCIex-800H
PR:		kern/124128
Submitted by:	Maxim Frolov <maxim.frolov.07@gmail.com> (original)
Approved by:	jhb
MFC after:	1 week
2011-11-15 17:53:29 +00:00
Eitan Adler
68ece58f03 - add support for Broadcom 802.11bg/EDGE/GPRS CardBus (Serial)
- correct mislabeling of 0x432214e4 device

PR:		kern/119606
Submitted by:	Joe Greco <jgreco@ns.sol.net>
Approved by:	jhb
MFC after:	1 week
2011-11-15 17:15:09 +00:00
Pyun YongHyeon
b7c2632d6a Overhaul bus_dma(9) usage in driver:
- Don't use a single big DMA block for all rings. Create separate
   DMA area for each ring instead.  Currently the following DMA
   areas are created:
	Event ring, standard RX ring, jumbo RX ring, RX return ring,
	hardware MAC statistics and producer/consumer status area.
   For Tigon II, mini RX ring and TX ring are additionally created.
 - Added missing bus_dmamap_sync(9) in various TX/RX paths.
 - TX ring is no longer created for Tigon 1 such that it saves more
   resources on Tigon 1.
 - Data sheet is not clear about alignment requirement of each ring
   so use 32 bytes alignment for normal DMA area but use 64 bytes
   alignment for jumbo RX ring where the extended RX descriptor
   size is 64 bytes.
 - For each TX/RX buffers use separate DMA tag(e.g. the size of a
   DMA segment, total size of DMA segments etc).
 - Tigon allows separate DMA area for event producer, RX return
   producer and TX consumer which is really cool feature.  This
   means TX and RX path could be independently run in parallel.
   However ti(4) uses a single driver lock so it's meaningless
   to have separate DMA area for these producer/consumer such that
   this change creates a single status DMA area.
 - It seems Tigon has no limits on DMA address space and I also
   don't see any problem with that but old comments in driver
   indicates there could be issues on descriptors being located in
   64bit region.  Introduce a tunable, dev.ti.%d.dac, to disable
   using 64bit DMA in driver. The default is 0 which means it would
   use full 64bit DMA.  If there are DMA issues, users can disable
   it by setting the tunable to 0.
 - Do not increase watchdog timer in ti_txeof(). Previously driver
   increased the watchdog timer whenever there are queued TX frames.
 - When stat ticks is set to 0, skip processing ti_stats_update(),
   avoiding bus_dmamap_sync(9) and updating if_collisions counter.
 - MTU does not include FCS bytes, replace it with
   ETHER_VLAN_ENCAP_LEN.

With these changes, ti(4) should work on PAE environments.
Many thanks to Jay Borkenhagen for remote hardware access.
2011-11-14 20:38:14 +00:00
Pyun YongHyeon
e79b243289 Export sysctl node for various interrupt moderation parameters and
have administrators control them.  ti(4) provides a character
device to control various other features of driver via ioctls but
users had to write their own code to manipulate these parameters.
It seems some default values for these parameters are not optimal
on today's system but leave it as it was and let administrators
change them.  The following parameters could be changed:

dev.ti.%d.rx_coal_ticks
dev.ti.%d.rx_max_coal_bds
dev.ti.%d.tx_coal_ticks
dev.ti.%d.tx_max_coal_bds
dev.ti.%d.tx_buf_ratio
dev.ti.%d.stat_ticks

The interface has to be brought down and up again before a change
takes effect.

ti(4) controller supports hardware MAC counters with additional
DMA statistics.  So it's doable to export these counters via
sysctl interface.  Unfortunately, these counters are cumulative
such that driver have to either send an explicit clear command to
controller after extracting them or have to maintain internal
counters to get actual changes.  Neither look good to me so
counters were not exported via sysctl.
2011-11-14 19:10:20 +00:00
Pyun YongHyeon
9b81d5e37f It's bad idea to allocate large memory, 4KB, from stack.
Pre-allocate the memory in device attach time. While I'm here
remove unnecessary reassignment of error variable as it was already
initialized. Also added a missing driver lock in TIIOCSETTRACE
handler.
2011-11-14 18:40:04 +00:00
Robert Millan
ea4d9a14f1 Remove a few bits of FreeBSD 2.x compatibility code.
Approved by:	kib (mentor)
2011-11-14 18:21:27 +00:00
Adrian Chadd
a3909ec506 Disable writing to the extension CYCPWR1 register.
This seems to make ANI behave better on the AR5416/AR5418.

Sponsored by:	Hobnob, Inc.
2011-11-12 16:47:23 +00:00
Hans Petter Selasky
17c78d345c - This patch adds custom IOCTLs to read and write the 4 GPIO pins on the
cp2103 usb-to-serial chip.
- This patch also makes the line status polling asynchronous, to reduce
the time needed to change the GPIO pins.

Submitted by:	JD Louw
MFC after:	1 week
2011-11-12 08:40:52 +00:00
Hans Petter Selasky
2648cd35d8 Enable power save mode for the USB storage device driver.
MFC after:	1 week
2011-11-12 08:19:36 +00:00
Hans Petter Selasky
271ae033e9 Style change.
- Make it easier to port the USB code to other platforms by only using
one set of memory functions for clearing and copying memory. None of
the memory copies are overlapping. This means using bcopy() is not
required.
- Fix a compile warning when USB_HAVE_BUSDMA=0
- Add missing semicolon in avr32dci.
- Update some comments.

MFC after:	1 week
2011-11-12 08:16:45 +00:00
Brooks Davis
4b22573a89 In r191367 the need for if_free_type() was removed and a new member
if_alloctype was used to store the origional interface type.  Take
advantage of this change by removing all existing uses of if_free_type()
in favor of if_free().

MFC after:	1 Month
2011-11-11 22:57:52 +00:00
Eitan Adler
14517324d0 - add a missing "be" and "in"
- fix other errors introduced when committing r226436
- add 'function' to a sentence where it makes sense

Submitted by:	delphij
Submitted by:	dougb
Submitted by:	jhb
Approved by:	dougb
Approved by:	jhb
2011-11-11 22:27:09 +00:00
Eitan Adler
2c89ac5e81 - add support for CP-104EL-A and CP-104JU to puc
PR:		151365
Submitted by:	Joerg Niendorf <f5d10a@internode.on.net>
Approved by:	jhb
2011-11-11 22:24:16 +00:00
Pyun YongHyeon
e18783345a To send a frame, controller requires a prepended TX header and
the length of frame should be treated as multiple of 4. Actual
frame length is set in the TX header. The TX header position
should be aligned on 4 byte boundary and actual frame start
position should be aligned on 4 byte boundary as well. This means
we need 4(TX header length) + 3(frame length fixup) additional free
space in TX buffer in addition to actual frame length.
Make sure TX handler check these additional bytes.
ae_tx_avail_size() returns actual free space in TX buffer to ease
the calculation of available TX buffer space in caller. While I'm
here, replace magic number to appropriate sizeof operator to
enhance readability.

This change should fix controller lockup issue happened under
certain conditions but it still does not fix watchdog timeout. It
seems the watchdog timeout is side-effect of TxS and TxD
mismatches. The root cause of TxD/TxD mismatch is not known yet but
it looks like silicon bug. I guess driver may have to reinitialize
controller whenever it sees TxS and TxD mismatches but leave it as
it was at this moment.

PR:	kern/145918
2011-11-11 19:15:32 +00:00
Adrian Chadd
9ddf14906a Correct device id comments. 2011-11-11 00:48:41 +00:00