summaryrefslogtreecommitdiffstats
path: root/sys/dev/gem
Commit message (Collapse)AuthorAgeFilesLines
* Fix a NULL pointer dereference in Tx checksum calculation.yongari2007-10-131-0/+5
| | | | Pointed out by: marius
* o Revert the part of if_gem.c rev. 1.35 which added a call to gem_stop()marius2007-09-264-417/+774
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to gem_attach() as the former access softc members not yet initialized at that time and gem_reset() actually is enough to stop the chip. [1] o Revise the use of gem_bitwait(); add bus_barrier() calls before calling gem_bitwait() to ensure the respective bit has been written before we starting polling on it and poll for the right bits to change, f.e. even though we only reset RX we have to actually wait for both GEM_RESET_RX and GEM_RESET_TX to clear. Add some additional gem_bitwait() calls in places we've been missing them according to the GEM documentation. Along with this some excessive DELAYs, which probably only were added because of bugs in gem_bitwait() and its use in the first place, as well as as have of an gem_bitwait() reimplementation in gem_reset_tx() were removed. o Add gem_reset_rxdma() and use it to deal with GEM_MAC_RX_OVERFLOW errors more gracefully as unlike gem_init_locked() it resets the RX DMA engine only, causing no link loss and the FIFOs not to be cleared. Also use it deal with GEM_INTR_RX_TAG_ERR errors, with previously were unhandled. This was based on information obtained from the Linux GEM and OpenSolaris ERI drivers. o Turn on workarounds for silicon bugs in the Apple GMAC variants. This was based on information obtained from the Darwin GMAC and Linux GEM drivers. o Turn on "infinite" (i.e. maximum 31 * 64 bytes in length) DMA bursts. This greatly improves especially RX performance. o Optimize the RX path, this consists of: - kicking the receiver as soon as we've a spare descriptor in gem_rint() again instead of just once after all the ready ones have been handled; - kicking the receiver the right way, i.e. as outlined in the GEM documentation in batches of 4 and by pointing it to the descriptor after the last valid one; - calling gem_rint() before gem_tint() in gem_intr() as gem_tint() may take quite a while; - doubling the size of the RX ring to 256 descriptors. Overall the RX performance of a GEM in a 1GHz Sun Fire V210 was improved from ~100Mbit/s to ~850Mbit/s. o In gem_add_rxbuf() don't assign the newly allocated mbuf to rxs_mbuf before calling bus_dmamap_load_mbuf_sg(), if bus_dmamap_load_mbuf_sg() fails we'll free the newly allocated mbuf, unable to recycle the previous one but a NULL pointer dereference instead. o In gem_init_locked() honor the return value of gem_meminit(). o Simplify gem_ringsize() and dont' return garbage in the default case. Based on OpenBSD. o Don't turn on MAC control, MIF and PCS interrupts unless GEM_DEBUG is defined as we don't need/use these interrupts for operation. o In gem_start_locked() sync the DMA maps of the descriptor rings before every kick of the transmitter and not just once after enqueuing all packets as the NIC might instantly start transmitting after we kicked it the first time. o Keep state of the link state and use it to enable or disable the MAC in gem_mii_statchg() accordingly as well as to return early from gem_start_locked() in case the link is down. [3] o Initialize the maximum frame size to a sane value. o In gem_mii_statchg() enable carrier extension if appropriate. o Increment if_ierrors in case of an GEM_MAC_RX_OVERFLOW error and in gem_eint(). [3] o Handle IFF_ALLMULTI correctly; don't set it if we've turned promiscuous group mode on and don't clear the flag if we've disabled promiscuous group mode (these were mostly NOPs though). [2] o Let gem_eint() also report GEM_INTR_PERR errors. o Move setting sc_variant from gem_pci_probe() to gem_pci_attach() as device probe methods are not supposed to touch the softc. o Collapse sc_inited and sc_pci into bits for sc_flags. o Add CTASSERTs ensuring that GEM_NRXDESC and GEM_NTXDESC are set to legal values. o Correctly set up for 802.3x flow control, though #ifdef out the code that actually enables it as this needs more testing and mainly a proper framework to support it. o Correct and add some conversions from hard-coded functions names to __func__ which were borked or forgotten in if_gem.c rev. 1.42. o Use PCIR_BAR instead of a homegrown macro. o Replace sc_enaddr[6] with sc_enaddr[ETHER_ADDR_LEN]. o In gem_pci_attach() in case attaching fails release the resources in the opposite order they were allocated. o Make gem_reset() static to if_gem.c as it's not needed outside that module. o Remove the GEM_GIGABIT flag and the associated code; GEM_GIGABIT was never set and the associated code was in the wrong place. o Remove sc_mif_config; it was only used to cache the contents of the respective register within gem_attach(). o Remove the #ifdef'ed out NetBSD/OpenBSD code for establishing a suspend hook as it will never be used on FreeBSD. o Also probe Apple Intrepid 2 GMAC and Apple Shasta GMAC, add support for Apple K2 GMAC. Based on OpenBSD. o Add support for Sun GBE/P cards, or in other words actually add support for cards based on GEM to gem(4). This mainly consists of adding support for the TBI of these chips. Along with this the PHY selection code was rewritten to hardcode the PHY number for certain configurations as for example the PHY of the on-board ERI of Blade 1000 shows up twice causing no link as the second incarnation is isolated. These changes were ported from OpenBSD with some additional improvements and modulo some bugs. o Add code to if_gem_pci.c allowing to read the MAC-address from the VPD on systems without Open Firmware. This is an improved version of my variant of the respective code in if_hme_pci.c o Now that gem(4) is MI enable it for all archs. Pointed out by: yongari [1] Suggested by: rwatson [2], yongari [3] Tested on: i386 (GEM), powerpc (GMACs by marcel and yongari), sparc64 (ERI and GEM) Reviewed by: yongari Approved by: re (kensmith)
* - In gem_bitwait() check that the bit clears/was set in the contentmarius2007-06-161-2/+2
| | | | | | | | of the register rather than in the offset describing the register. - In gem_reset_rx() let gem_bitwait() check for the Rx reset bit rather than the Tx reset bit to clear. Obtained from: OpenBSD (same/similar bugs being fixed)
* o Implemented Rx/Tx checksum offload. The simple checksum logic inyongari2007-06-043-224/+420
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GEMs is unable to discriminate UDP from TCP packets such that it can generate 0x0000 checksum value for the UDP datagram. So the UDP checksum offload was disabled by default. You can enable it by setting link0 flag with ifconfig(8). o bus_dma(9) clean up. It now correctly set number of required DMA segments/size and removed incorrect use of BUS_DMA_ALLOCNOW flag in static allocations done via bus_dmamem_alloc(9). o Implemented ALTQ(9) support. o Implemented Tx side bus_dmamap_load_mbuf_sg(9) which can remove several book keeping chores orginated from call-back mechanism. Therefore gem_txdma_callback() was removed and its functionality was reimplemented in gem_load_txmbuf(). o Don't set GEM_TD_START_OF_PACKET flag until all remaining mbuf chains are set. I think it was a long standing bug and it caused fluctuating interrupts/CPU usage patterns while netperf test is in progress. Previously it seems that we race with the device. Because I don't have a documentation for GEM I'm not sure this is correct but almost all other documentations I have stated this implications on setting SOP mark in descriptor ring(e.g. hme(4)). o Borrowed gem_defrag() from ath(4) which is supposed to be much faster than m_defrag(9) since it's not need to defrag all mbuf chains. o gem_load_txmbuf() was changed to allow passed mbuf chains to free. Caller of gem_load_txmbuf() correctly handles freed mbuf chains. o In gem_start_locked(), added checks for availability of Tx descriptors before trying to load DMA maps which could save CPU cycles when number of available descriptors are low. Also, simplyfy IFF_DRV_OACTIVE detection logic. o Removed hard-coded function names in CTR macros and replaced it with __func__. o Moved statistics counter register access to gem_tick() to reduce number of PCI bus accesses. There is no reason to update statistics counters in interrupt handler. o Removed unnecessary call of gem_start_locked() in gem_ioctl(). Reviewed by: grehan (initial version), marius (with improvements and suggestions) Tested by: grehan (ppc), marius(sparc64)
* Since if_gem is being touted as one of our more architecturallyphk2007-05-043-195/+141
| | | | | | | | | | | | | | | correct network drivers with respect to busmaster DMA, go over it with at duster to make other aspects of it a role model: Eliminate the pci specific softc, it serves no rational purpose. Use convenience resource allocation/deallocation functions to save code and errorhandling. Switch from bus_space_{read|write}_%u() to bus_{read|write}_%u() functions and forget about tags and handles, the resource will know about those, should they be needed. This also eliminates a number of inconsistently named local variables.
* o break newbus api: add a new argument of type driver_filter_t topiso2007-02-231-1/+1
| | | | | | | | | | | | | bus_setup_intr() o add an int return code to all fast handlers o retire INTR_FAST/IH_FAST For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current Reviewed by: many Approved by: re@
* - Use the gem_tick() callout instead of if_slowtimo() for drivingmarius2006-12-062-22/+25
| | | | | | | | gem_watchdog() in order to avoid races accessing if_timer. While at it relax the watchdog a bit by reloading it in gem_tint() if there are still packets enqueued. - Don't bother to set if_mtu to ETHERMTU, ether_ifattach() does that. - Fix inconsistencies in prototypes.
* add a newbus method for obtaining the bus's bus_dma_tag_t... This isjmg2006-09-031-3/+4
| | | | | | | | | | | | | required by arches like sparc64 (not yet implemented) and sun4v where there are seperate IOMMU's for each PCI bus... For all other arches, it will end up returning NULL, which makes it a no-op... Convert a few drivers (the ones we've been working w/ on sun4v) to the new convection... Eventually all drivers will need to replace the parent tag of NULL, w/ bus_get_dma_tag(dev), though dev is usually different for each driver, and will require hand inspection... Reviewed by: scottl (earlier version)
* add missed calls to bpf_peers_presentsam2006-06-021-2/+1
|
* Fix -Wundef warnings found when compiling i386 LINT, GENERIC andru2005-12-051-1/+1
| | | | custom kernels.
* - Store pointer to the link-level address right in "struct ifnet"ru2005-11-111-1/+1
| | | | | | | | | | rather than in ifindex_table[]; all (except one) accesses are through ifp anyway. IF_LLADDR() works faster, and all (except one) ifaddr_byindex() users were converted to use ifp->if_addr. - Stop storing a (pointer to) Ethernet address in "struct arpcom", and drop the IFP2ENADDR() macro; all users have been converted to use IF_LLADDR() instead.
* - In gem_ioctl() move the call to ether_ioctl() to the default case ofmarius2005-09-181-47/+29
| | | | | | | | | | | | | | | | | | | | | | | | | the switch statement in order to make this driver more like other Ethernet NIC drivers. - In gem_attach() call gem_stop() in addition to gem_reset() to make sure the chip actually is stopped and not just reset. - In gem_stop() also stop the gem_rint_timeout() callout in case the driver is compiled with GEM_RINT_TIMEOUT defined. Merge some locking improvements from hme(4): - Use callout_init_mtx() to close races between gem_stop() and gem_tick() as weel as gem_stop() and gem_rint() in case the driver is compiled with GEM_RINT_TIMEOUT defined. - Use the driver lock instead of Giant in a bus dma callback. - Lock the driver lock around mii operations. - Cleanup locking in gem_ioctl(). - Remove redundant assertions that the driver lock is not held in gem_attach() and gem_detach() since mtx_lock() will assert that already since the driver lock is not recursive. - Add callout_drain()'s to gem_detach() after calling gem_stop() to make sure that if softclock is running on another CPU and is blocked on our driver lock, we will wait until it has acquired the lock, seen that it was cancelled, dropped the lock, and awakened us so that we can safely destroy the mutex.
* - Allow for VLAN-sized frames and set IFCAP_VLAN_MTU.marius2005-08-281-8/+23
| | | | | | | | | | | | | - On resume all registers have to be initialized again like after power-on so reset sc_inited in gem_suspend() in order get all of the registers set next time gem_init_regs() is called. - On at least some ERI and GEM revisions GEM_MAC_RX_OVERFLOW happen often due to a silicon bug and re-initializing is all we can do about these errors so make handling them non-verbose. - Remove a superfluous memset(3) call in gem_meminit(), all elements are initialized to 0 anyway. MFC after: 1 week
* Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE andrwatson2005-08-091-8/+9
| | | | | | | | | | | | | | IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to ifnet.if_drv_flags. Device drivers are now responsible for synchronizing access to these flags, as they are in if_drv_flags. This helps prevent races between the network stack and device driver in maintaining the interface flags field. Many __FreeBSD__ and __FreeBSD_version checks maintained and continued; some less so. Reviewed by: pjd, bz MFC after: 7 days
* Modify device drivers supporting multicast addresses to lock if_addr_mtxrwatson2005-08-031-0/+2
| | | | | | | | over iteration of their multicast address lists when synchronizing the hardware address filter with the network stack-maintained list. Problem reported by: Ed Maste (emaste at phaedrus dot sandvine dot ca> MFC after: 1 week
* Remove NOP spl*() calls and add locking (making gem(4) MPSAFE).marius2005-07-243-35/+118
| | | | | | Based on: hme(4) Reviewed by: yongari Tested on: powerpc(grehan), sparc64
* - Wrap the handler and associated code for collecting completed RXmarius2005-07-241-31/+23
| | | | | | | | | | | | | | | | descriptors that are still marked owned in #ifdef GEM_RINT_TIMEOUT instead of #if 0 for convenience. - Remove stale code and comment about relying on the preset XIF config. - In case of a watchdog timeout call the init function instead of just the start function so the chip is properly reset. Merge from hme(4): - Convert to use bus_dmamap_load_mbuf_sg() for loading RX buffers. - Protect from a duplicate mbuf free panic in case the DMA engine hangs. Reviewed by: yongari Tested on: powerpc(grehan), sparc64 MFC after: 1 week
* Stop the interface before detaching and freeing it, rather than after.brooks2005-06-121-1/+1
| | | | Reported by: marius
* Stop embedding struct ifnet at the top of driver softcs. Instead thebrooks2005-06-103-15/+24
| | | | | | | | | | | | | | | | | | | | struct ifnet or the layer 2 common structure it was embedded in have been replaced with a struct ifnet pointer to be filled by a call to the new function, if_alloc(). The layer 2 common structure is also allocated via if_alloc() based on the interface type. It is hung off the new struct ifnet member, if_l2com. This change removes the size of these structures from the kernel ABI and will allow us to better manage them as interfaces come and go. Other changes of note: - Struct arpcom is no longer referenced in normal interface code. Instead the Ethernet address is accessed via the IFP2ENADDR() macro. To enforce this ac_enaddr has been renamed to _ac_enaddr. - The second argument to ether_ifattach is now always the mac address from driver private storage rather than sometimes being ac_enaddr. Reviewed by: sobomax, sam
* Use BUS_PROBE_DEFAULT for pci probe return valueimp2005-03-051-1/+1
|
* Start each of the license/copyright comments with /*-, minor shuffle of linesimp2005-01-063-3/+3
|
* Since if_gem doesn't contain locking or run with INTR_MPSAFE, markrwatson2004-08-131-1/+2
| | | | the interface as IFF_NEEDSGIANT so if_start is run holding Giant.
* - Remove a variable no longer used after the conversion to ether_crc32_le().marius2004-06-101-4/+2
| | | | | - While here, save on another one no longer really necessary after the conversion.
* Replace handrolled CRC calculation with ether_crc32_[lb]e().naddy2004-06-091-17/+1
|
* Add missing <sys/module.h> includes currently relying on nested includephk2004-06-032-0/+2
| | | | in <sys/kernel.h>
* We don't need to initialize if_output, ether_ifattach() does itmux2004-05-231-1/+0
| | | | for us.
* Clean up two printf()s that were on a line by themselves unintendedlytmm2004-04-231-2/+2
| | | | after the ethernet address printing was moved to common code.
* Let ether_ifattach() announce our MAC address.mdodd2004-03-201-5/+0
| | | | Submitted by: Marius Strobl <marius@alchemy.franken.de>
* Convert callers to the new bus_alloc_resource_any(9) API.njl2004-03-171-4/+4
| | | | | Submitted by: Mark Santcroos <marks@ripe.net> Reviewed by: imp, dfr, bde
* Add new Apple GEM PCI id.grehan2004-02-021-0/+1
|
* Properly initialize all members of the sentinel entry.obrien2003-12-261-1/+1
|
* Replace the if_name and if_unit members of struct ifnet with new membersbrooks2003-10-311-2/+2
| | | | | | | | | | | | | if_xname, if_dname, and if_dunit. if_xname is the name of the interface and if_dname/unit are the driver name and instance. This change paves the way for interface renaming and enhanced pseudo device creation and configuration symantics. Approved By: re (in principle) Reviewed By: njl, imp Tested On: i386, amd64, sparc64 Obtained From: NetBSD (if_xname)
* Preparatory commit to allow prototypes in ofw_machdep.h to containmarcel2003-09-021-0/+1
| | | | | | | both newbus types and OFW types. This involves either including <machine/bus.h> or <dev/ofw/openfirm.h>. Reviewed by: jake, jmg, tmm
* Use __FBSDID().obrien2003-08-242-4/+7
| | | | Also some minor style cleanups.
* s=gem/foo=dev/gem/foo=imp2003-08-231-2/+2
|
* Mega busdma API commit.scottl2003-07-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | Add two new arguments to bus_dma_tag_create(): lockfunc and lockfuncarg. Lockfunc allows a driver to provide a function for managing its locking semantics while using busdma. At the moment, this is used for the asynchronous busdma_swi and callback mechanism. Two lockfunc implementations are provided: busdma_lock_mutex() performs standard mutex operations on the mutex that is specified from lockfuncarg. dftl_lock() is a panic implementation and is defaulted to when NULL, NULL are passed to bus_dma_tag_create(). The only time that NULL, NULL should ever be used is when the driver ensures that bus_dmamap_load() will not be deferred. Drivers that do not provide their own locking can pass busdma_lock_mutex,&Giant args in order to preserve the former behaviour. sparc64 and powerpc do not provide real busdma_swi functions, so this is largely a noop on those platforms. The busdma_swi on is64 is not properly locked yet, so warnings will be emitted on this platform when busdma callback deferrals happen. If anyone gets panics or warnings from dflt_lock() being called, please let me know right away. Reviewed by: tmm, gibbs
* Some gem and hme hardware bogusly has the intpin register hardwired totmm2003-07-011-3/+6
| | | | | 0; detect this case and correct it. While being there, clean up nearby comments.
* Miscellaneous fixes:tmm2003-05-152-6/+59
| | | | | | | | | | | | | | | | | - Fix compilation without GEM_DEBUG. - Do not #define GEM_DEBUG by default; it adds overhead (due to bzero()ing RX space) and is not needed any more, since the driver is quite stable now. - Fix watchdog timeouts when failing to load TX packets. - Do not forcibly limit the number of descriptors used for a packet to GEM_NTXSEGS, by passing this number to bus_dma_tag_create(). There is no requirement for a limit any lower than the total number of available descriptors, and the present limit caused network problems due to mbuf chains requiring more descriptors. GEM_NTXSEGS is still used to estimate the interrupt window size, for which we just need an estimate. Approved by: re (rwatson)
* - Don't call pci_enable_io() in drivers (unless needed for resume).mdodd2003-04-161-1/+0
| | | | | - Don't test memory/port status and emit an error message; the PCI bus code will do this now.
* - Express hard dependencies on bus (pci, isa, pccard) andmdodd2003-04-151-1/+3
| | | | | | | | network layer (ether). - Don't abuse module names to facilitate ifconfig module loading; such abuse isn't really needed. (And if we do need type information associated with a module then we should make it explicit and not use hacks.)
* Back out M_* changes, per decision of the TRB.imp2003-02-191-1/+1
| | | | Approved by: trb
* Free resources when failing to set up the interrupt.tmm2003-01-211-0/+1
|
* bus_dmamap_sync() overhaul:tmm2003-01-212-22/+18
| | | | | | | | | | | - Remove NetBSD-style or-ed together BUS_DMASYNC operations, in some cases relaxing the (intended) syncing operation a bit. - Stop pretending that that we can sync part of a dmamap: replace the GEM_CDTXSYNC and GEM_CDRXSYNC macros with GEM_CDSYNC to sync the complete control map, and combine syncs wherever possible to avoid the overhead. - Sync all maps before unloading them. - Remove a few syncs which should be unnecessary.
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-1/+1
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Add detach, shutdown, suspend and resume methods. The latter two aretmm2003-01-083-42/+97
| | | | not really tested, but are derived from the original NetBSD version.
* - Convert to use bus_dmamap_load_mbuf().tmm2003-01-062-397/+155
| | | | | | - remove DPRINTF(), there is a CTR*() for any of them, and KTR is far more useful to debug this driver. - some cleanups; remove some unused code and definitions.
* Catch up with sam's changes to network interfaces.mux2002-11-151-2/+1
|
* network interface driver changes:sam2002-11-141-5/+3
| | | | | | | | | | | | | | o don't strip the Ethernet header from inbound packets; pass packets up the stack intact (required significant changes to some drivers) o reference common definitions in net/ethernet.h (e.g. ETHER_ALIGN) o track ether_ifattach/ether_ifdetach API changes o track bpf changes (use BPF_TAP and BPF_MTAP) o track vlan changes (ifnet capabilities, revised processing scheme, etc.) o use if_input to pass packets "up" o call ether_ioctl for default handling of ioctls Reviewed by: many Approved by: re
* Call bpf_mtap() on outgoing packets.tmm2002-10-261-3/+6
|
* Fix warning.jake2002-07-241-0/+4
|
OpenPOWER on IntegriCloud