summaryrefslogtreecommitdiffstats
path: root/sys/dev/dc
Commit message (Collapse)AuthorAgeFilesLines
* Revise r220046 by introducing dc_netcfg_wait() which waits the endyongari2011-03-281-51/+39
| | | | | | | | of active DMA cycle. dc_setcfg() also has to wait until the DMA engine is stopped so using a common function to handle the job is better than duplicating the code. No objection from: marius
* Wait until the DMA engine is stopped before unmapping buffers andmarius2011-03-261-1/+25
| | | | | | | descriptors, which fixes DMA errors seen on sparc64. Obtained from: OpenBSD MFC after: 1 week
* Remove too expensive bus_dmamap_sync(9) call in dc_rx_resync().yongari2011-03-161-10/+4
| | | | | | | | | | | | | | | | | With this change, driver may not notice updated descriptor status change when bounce buffers are active. However, rxeof() in next run will handle the synchronization. Change dc_rxeof() a bit to return the number of processed frames in RX descriptor ring. Previously it returned the number of frames that were successfully passed to upper stack which in turn means it ignored frames that were discarded due to errors. The number of processed frames in RX descriptor ring is used to detect whether driver is out of sync with controller's current descriptor pointer. Returning number of processed frames reduces unnecessary (probably wrong) re-synchronization. Reviewed by: marius
* Rearrange dc_tx_underrun() a bit to correctly set TX FIFO thresholdyongari2011-03-081-37/+43
| | | | | | | | | | | | | | | | | | | | | | | | | value. Controllers that always require "store and forward" mode( Davicom and PNIC 82C168) have no way to recover from TX underrun except completely reinitializing hardware. Previously only Davicom was reinitialized and the TX FIFO threshold was changed not to use "store and forward" mode after reinitialization since the default FIFO threshold value was 0. This effectively disabled Davicom controller's "store and forward" mode once it encountered TX underruns. In theory, this can cause watchodg timeouts. Intel 21143 controller requires TX MAC should be idle before changing TX FIFO threshold. So driver tried to disable TX MAC and checked whether it saw the idle state of TX MAC. Driver should perform full hardware reinitialization on failing to enter to idle state and it should not touch TX MAC again once it performed full reinitialization. While I'm here remove resetting TX FIFO threshold to 0 when interface is put into down state. If driver ever encountered TX underrun, it's likely to trigger TX underrun again whenever interface is brought to up again. Keeping old/learned TX FIFO threshold value shall reduce the chance of seeing TX underrns in next run.
* Remove unnecessary controller reinitialization which resulted inyongari2011-02-231-5/+13
| | | | | | link flips during alias address insertion or dhclient operation. While I'm here remove dc_reset() in DC_ISR_BUS_ERR case. Device is fully reinitialized again in dc_init_locked().
* s/u_intXX_t/uintXX_t/gyongari2011-02-192-93/+93
|
* Consistently use a tab character instead of space after #define.yongari2011-02-192-588/+588
| | | | No functional changes.
* Count how many frames driver lost in interrupt handler. Thisyongari2011-02-191-1/+6
| | | | | register is cleared on read so make sure to clear it in driver initialization phase.
* Split common TX/RX descriptor DMA tag to TX and RX DMA tagsyongari2011-02-192-276/+429
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | respectively and fix all bus_dma(9) issues seen when bounce buffers are used. o Setup frame handling had no bus_dmamap_sync(9) which prevented driver from configuring RX filter. Add missing bus_dmamap_sync(9) in both dc_setfilt_21143()/dc_setfilt_xircom() and dc_txeof(). o Use bus_addr_t for DMA segment instead of using u_int32_t. o Introduce dc_dma_alloc()/dc_dma_free() functions to allocate/free DMA'able memory. o Create two DMA descriptor list for each TX/RX lists. This change will minimize the size of bounce buffers that would be used in each TX/RX path. Previously driver had to copy both TX/RX lists when bounce buffer is active. o 21143 data sheet says descriptor list requires 4 bytes alignment. Remove PAGE_SIZE alignment restriction and use sizeof(struct dc_dec). o Setup frame requires 4 bytes alignment. Remove PAGE_SIZE alignment restriction and use sizeof(struct dc_dec). o Add missing DMA map unload for both setup frame and TX/RX descriptor list. o Overhaul RX handling logic such that make driver always allocate new RX buffer with dc_newbuf(). Previously driver allowed to copy received frame with m_devget(9) after passing the descriptor ownership to controller. This can lead to passing wrong frame to upper stack. o Introduce dc_discard_rxbuf() which will discard received frame and reuse loaded DMA map and RX mbuf. o Correct several wrong bus_dmamap_sync(9) usage in dc_rxeof and dc_txeof. The TX/RX descriptor lists are updated by both driver and HW so READ/WRITE semantics should be used. o If driver failed to allocate new RX buffer, update if_iqdrops counter instead of if_ierrors since driver received the frame without errors. o Make sure to unload loaded setup frame DMA map in dc_txeof and clear the mark of setup frame of the TX descriptor in dc_txeof(). o Add check for possible TX descriptor overruns in dc_encap() and move check for free buffer to caller, dc_start_locked(). o Swap the loaded DMA map and the last DMA map for multi-segmented frames. Since dc_txeof() assumes the last descriptor of the frame has the DMA map, driver should swap the first and the last DMA map in dc_encap(). Previously driver tried to unload not-yet-loaded DMA map such that the loaded DMA map was not unloaded at all for multi-segmented frames. o Rewrite DC_RXDESC/DC_TXDESC macro to simpler one. o Remove definition of ETHER_ALIGN, it's already defined in ethernet.h. With this changes, dc(4) works with bounce buffers and it shall also fix issues which might have shown in PAE environments. Tested by: marius
* Rearrange interrupt handler a bit and remove forever loop.yongari2011-02-191-22/+20
| | | | | | | | | | | | Previously dc(4) always checked whether there is pending interrupts and this consumed a lot of CPU cycles in interrupt handler. Limit the number of processing for TX/RX frames to 16. Also allow sending frames in the loop not to starve TX under high RX load. Reading DC_ISR register should be protected with driver lock, otherwise interrupt handler could be run(e.g. link state change) before the completion of dc_init_locked(). While I'm here remove unneeded code.
* Send frames only when there is a valid link and driver is runningyongari2011-02-191-4/+2
| | | | | | | | | as well as controller has enough free TX descriptors. Remove check for number of queued frames before attempting to transmit. I guess it was added to allow draining queued frames even if there is no link. I'm under the impression this type of check should be done in upper layer. No other drivers in tree do that.
* Fix a long standing bug where driver handed over RX descriptoryongari2011-02-181-1/+0
| | | | | | ownership to controller before completion of access to the descriptor. Driver is faking up status word so it should not give ownership to controller until it completes RX processing.
* There is no need to execute filter configuration when driver is notyongari2011-02-181-4/+2
| | | | | running. Remove wrong driver state change in dc_setfilt_xircom(). While I'm here nuke unnecessary assignments.
* Make sure to clear status word of TX descriptor in dc_list_tx_init().yongari2011-02-181-5/+5
| | | | Do not update if_opackets if the transmission had failed.
* For controllers that have TX interrupt moderation capability,yongari2011-02-182-1/+16
| | | | | | | | | | | | | | | | request TX completion interrupt for every 8-th frames. Previously dc(4) requested TX completion interrupt if number of queued TX descriptors is greater than 64. This caused a lot of TX completion interrupt under high TX load once driver queued more than 64 TX descriptors. It's quite normal to see more than 64 queued TX descriptors under high TX load. This change reduces the number of TX completion interrupts to be less than 17k under high TX load. Because this change does not generate TX completion interrupt for each frame, add reclaiming transmitted buffers in dc_tick not to generate false watchdog timeouts. While I'm here add check for queued descriptors in dc_txeof() since there is no more work to do when there is no pending descriptors.
* Remove use case of DC_TX_ONE. It was used to limit queue just 1 TXyongari2011-02-182-6/+0
| | | | | | frame in DM910x controllers. In r67595(more than 10 years ago) it was replaced to use "Store and Forward" mode and made controller generate TX completion interrupt for every frame.
* Apply special PHY initialization code for 21143 controllers beforeyongari2011-02-181-31/+42
| | | | | | | | | | | | | | | | | | | | | | | | any other media configuration. Otherwise some 21143 controller cannot establish a link. While I'm here remove the PHY initialization code in dc_setcfg(). Since dc_setcfg() is called whenever link state is changed, having the PHY initialization code in dc_setcfg() resulted in continuous link flips. After driver resets SIA, use default SIA transmit/receive configuration instead of disabling autosense/autonegotiation. Otherwise, controller fails to establish a link as well as losing auto-negotiation capability. For manual media configuration, always configure 21143 controller with specified media to ensure media change. This change makes ANA-6922 establish link with/without auto-negotiation. While I'm here be more strict on link UP/DOWN detection logic. Many thanks to marius who fixed several bugs in initial patch and even tested the patch on a couple of dc(4) controllers. PR: kern/79262 Reviewed by: marius Tested by: marius
* When driver have to use base softc due to lack of SROM on secondyongari2011-02-181-2/+37
| | | | | | | | | | | | | port, copy SROM information from base softc as well and run SROM parser again. This change is necessary for some dual port controllers to make dc(4) correctly detect PHY media based on first port configuration table. While I'm here add a check for validity of the base softc before duplicating SROM contents from base softc. If driver failed to attach to the first port it can access invalid area. PR: kern/79262 Reviewed by: marius
* Always check memory allocation failure. If driver encounter memoryyongari2011-02-182-21/+60
| | | | | | allocation error, do not attach driver. Reviewed by: marius
* - Even after masking the media with IFM_GMASK the result may have bitsmarius2011-01-142-29/+11
| | | | | | | | | | besides the duplex ones set so just comparing it with IFM_FDX may lead to false negatives. - Just let the default case handle all unsupported media types. - In pnphy_status() don't unnecessarily read a register twice. - Remove unnused macros. MFC after: 1 week
* Convert the PHY drivers to honor the mii_flags passed down and convertmarius2010-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | the NIC drivers as well as the PHY drivers to take advantage of the mii_attach() introduced in r213878 to get rid of certain hacks. For the most part these were: - Artificially limiting miibus_{read,write}reg methods to certain PHY addresses; we now let mii_attach() only probe the PHY at the desired address(es) instead. - PHY drivers setting MIIF_* flags based on the NIC driver they hang off from, partly even based on grabbing and using the softc of the parent; we now pass these flags down from the NIC to the PHY drivers via mii_attach(). This got us rid of all such hacks except those of brgphy() in combination with bce(4) and bge(4), which is way beyond what can be expressed with simple flags. While at it, I took the opportunity to change the NIC drivers to pass up the error returned by mii_attach() (previously by mii_phy_probe()) and unify the error message used in this case where and as appropriate as mii_attach() actually can fail for a number of reasons, not just because of no PHY(s) being present at the expected address(es). This file was missed in r213893.
* Convert the PHY drivers to honor the mii_flags passed down and convertmarius2010-10-152-37/+30
| | | | | | | | | | | | | | | | | | | | | | | the NIC drivers as well as the PHY drivers to take advantage of the mii_attach() introduced in r213878 to get rid of certain hacks. For the most part these were: - Artificially limiting miibus_{read,write}reg methods to certain PHY addresses; we now let mii_attach() only probe the PHY at the desired address(es) instead. - PHY drivers setting MIIF_* flags based on the NIC driver they hang off from, partly even based on grabbing and using the softc of the parent; we now pass these flags down from the NIC to the PHY drivers via mii_attach(). This got us rid of all such hacks except those of brgphy() in combination with bce(4) and bge(4), which is way beyond what can be expressed with simple flags. While at it, I took the opportunity to change the NIC drivers to pass up the error returned by mii_attach() (previously by mii_phy_probe()) and unify the error message used in this case where and as appropriate as mii_attach() actually can fail for a number of reasons, not just because of no PHY(s) being present at the expected address(es). Reviewed by: jhb, yongari
* It seems some multi-port dc(4) controllers shares SROM of the firstyongari2010-10-142-0/+47
| | | | | | | | | | | | port such that reading station address from second port always returned 0xFF:0xFF:0xFF:0xFF:0xFF:0xFF Unfortunately it seems there is no easy way to know whether SROM is shared or not. Workaround the issue by traversing dc(4) device list and see whether we're using second port and use station address of controller 0 as base station address of second port. PR: kern/79262 MFC after: 2 weeks
* Consistently always explicitly set IFM_HDX for half-duplex.marius2010-10-032-5/+9
| | | | Obtained from: OpenBSD (mostly)
* - In the spirit of previous simplifications factor out the checks for amarius2010-10-022-42/+2
| | | | | | | | | | | | | | | | | different PHY instance being selected and isolation out into the wrappers around the service methods rather than duplicating them over and over again (besides, a PHY driver shouldn't need to care about which instance it actually is). - Centralize the check for the need to isolate a non-zero PHY instance not supporting isolation in mii_mediachg() and just ignore it rather than panicing, which should sufficient given that a) things are likely to just work anyway if one doesn't plug in more than one port at a time and b) refusing to attach in this case just leaves us in a unknown but most likely also not exactly correct configuration (besides several drivers setting MIIF_NOISOLATE didn't care about these anyway, probably due to setting this flag for no real reason). - Minor fixes like removing unnecessary setting of sc->mii_anegticks, using sc->mii_anegticks instead of hardcoded values etc.
* Use the mii_data provided via mii_attach_args and mii_pdata respectivelymarius2010-09-272-2/+2
| | | | instead of reaching out for the softc of the parent.
* cardbus -> CardBusimp2010-01-031-1/+1
|
* Fix CardBus spelling.imp2010-01-031-3/+3
| | | | MFC after: 1 month
* Fix card/device names, no functional changembr2010-01-032-18/+19
| | | | | | | | The ADMtek AN985 is the cardbus variant of ADMtek AN983 The Netgear FA511 is just a relabled ADMtek AN985 PR: kern/50574 MFC after: 1 month
* Use if_maddr_rlock()/if_maddr_runlock() rather than IF_ADDR_LOCK()/rwatson2009-06-261-8/+8
| | | | | | | | | | | | | IF_ADDR_UNLOCK() across network device drivers when accessing the per-interface multicast address list, if_multiaddrs. This will allow us to change the locking strategy without affecting our driver programming interface or binary interface. For two wireless drivers, remove unnecessary locking, since they don't actually access the multicast address list. Approved by: re (kib) MFC after: 6 weeks
* When user_frac in the polling subsystem is low it is going to busy theattilio2009-05-301-8/+14
| | | | | | | | | | | | | | | | | | | | | CPU for too long period than necessary. Additively, interfaces are kept polled (in the tick) even if no more packets are available. In order to avoid such situations a new generic mechanism can be implemented in proactive way, keeping track of the time spent on any packet and fragmenting the time for any tick, stopping the processing as soon as possible. In order to implement such mechanism, the polling handler needs to change, returning the number of packets processed. While the intended logic is not part of this patch, the polling KPI is broken by this commit, adding an int return value and the new flag IFCAP_POLLING_NOCOUNT (which will signal that the return value is meaningless for the installed handler and checking should be skipped). Bump __FreeBSD_version in order to signal such situation. Reviewed by: emaste Sponsored by: Sandvine Incorporated
* - Set MIIF_NOLOOP and don't add IFM_LOOP as loopback apparently isn'tmarius2009-03-192-19/+12
| | | | | | | | supported with these pseudo-PHYs. The MIIF_NOLOOP flag currently triggers nothing but hopefully will be respected by mii_phy_setmedia() later on. - Don't add IFM_NONE as isolation isn't supported by these pseudo-PHYs. - Use mii_phy_add_media() instead of mii_add_media() so the latter can be eventually retired.
* remove now-redunant cardbus attachment.imp2009-03-091-1/+0
|
* - According to the corresponding Linux, NetBSD and OpenSolarismarius2008-12-072-36/+47
| | | | | | | | drivers, there should be a 1us delay after every write when bit-banging the MII. Also insert barriers in order to ensure the intended ordering. These changes hopefully will solve the bus wedging occasionally experienced with DM9102A since r182461. - Deobfuscate dc_mii_readreg() a bit.
* cosmetic changes and style fixesmarius2008-09-302-47/+33
|
* For chips with a broken DC_ISR_RX_STATE which f.e. never signalsmarius2008-08-292-5/+11
| | | | | | | | | | | | | | stopped nor the waiting state and also no other means to check whether the receiver is idle (see also r163774), we have no choice than to call mii_tick(9) unconditionally even in the case of the DC_REDUCED_MII_POLL handling as far as the RX side is concerned. This isn't necessarily worse than checking whether RX is idle though because unlike as with TX we're racing with the hardware, which might receive packets any time while we poll the MII, anyway. Reported and tested by: Jacob Owens Reviewed by: yongari MFC after: 3 days
* - Use m_collapse(9) instead of m_defrag(9) if possible. This resultsmarius2008-08-231-18/+27
| | | | | | | | | in a noticeable reduction in system time spent. - If bus_dmamap_load_mbuf_sg(9) fails with EFBIG and we already have defragmented the mbuf chain, don't bother to defragment and load it a second time just yet as it's likely to fail again anyway. MFC after: 3 days
* Ethernet hardware address stored in DC_AL_PAR0/DC_AL_PAR1 registeryongari2008-06-081-6/+14
| | | | | | | | | | | | is in little endian form. Likewise setting DC_AL_PAR0/DC_AL_PAR1 register expect the address to be in little endian form. For big endian architectures the address should be swapped to get correct one. Change setting/getting ethernet hardware address to big endian architecture frendly. Reported by: Robert Murillo ( billypilgrim782001 at yahoo dot com ) Tested by: Robert Murillo ( billypilgrim782001 at yahoo dot com )
* - Const'ify the dc_devs array.marius2008-03-242-85/+84
| | | | | | | | | | - Correct the maxsize parameter when creating the mbufs busdma tag to reflect the actual requirement of dc(4). - Move the KASSERT in dc_newbuf() to the right spot. - Also convert the TX side to take advantage of bus_dmamap_load_mbuf_sg(9). - Move the comment regarding dc_start_locked() to the right spot. MFC after: 2 weeks
* Fix function prototype for device_shutdown method.yongari2007-11-221-2/+4
|
* IEEE 802.3 Annex 28B.3 explicitly specifies the following relativeyongari2007-11-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | priorities of the technologies supported by 802.3 Selector Field value. 1000BASE-T full duplex 1000BASE-T 100BASE-T2 full duplex 100BASE-TX full duplex 100BASE-T2 100BASE-T4 100BASE-TX 10BASE-T full duplex 10BAST-T However PHY drivers didn't honor the order such that 100BASE-T4 had higher priority than 100BASE-TX full duplex. Fix that long standing bugs such that have PHY drivers choose the highest common denominator ability. Fix a bug in dcphy which inadvertently aceepts 100BASE-T4. PR: 92599
* o In order to reduce bug and code duplication fold handling of NICsmarius2007-08-052-69/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | requiring DC_TX_ALIGN or DC_TX_COALESCE, which was previously done in dc_start_locked(), into dc_encap(). o In dc_encap(): - If m_defrag() fails just drop the packet like other NIC drivers do. This should only happen when there's a mbuf shortage, in which case it was possible to end up with an IFQ full of packets which couldn't be processed as they couldn't be defragmented as they were taking up all the mbufs themselves. This includes adjusting dc_start_locked() to not trying to prepend the mbuf (chain) if dc_encap() has freed it. - Likewise, if bus_dmamap_load_mbuf() fails as dc_dma_map_txbuf() failed, free the mbuf possibly allocated by the above call to m_defrag() and drop the packet. o In dc_txeof(): - Don't clear IFF_DRV_OACTIVE unless there are at least 6 free TX descriptors. Further down the road dc_encap() will bail if there are only 5 or fewer free TX descriptors, causing dc_start_locked() to abort and prepend the dequeued mbuf again so it makes no sense to pretend we could process mbufs again when in fact we won't. While at it replace this magic 5 with a macro DC_TX_LIST_RSVD. - Just always assign idx to sc->dc_cdata.dc_tx_cons; it doesn't make much sense to exclude the idx == sc->dc_cdata.dc_tx_cons case. o In dc_dma_map_txbuf() there's no need to set sc->dc_cdata.dc_tx_err to error if the latter is != 0, bus_dmamap_load_mbuf() already returns the same error value in that case anyway. o For less overhead, convert to use bus_dmamap_load_mbuf_sg() for loading RX buffers. o Remove some banal and/or outdated comments. Approved by: re (kensmith) MFC after: 1 week
* 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@
* Fix a bug originally introduced in rev. 1.74; don't reloaded themarius2006-12-201-1/+2
| | | | | | | | | | watchdog timer in dc_txeof() in case there are still unhandled descriptors as dc_poll() invokes dc_poll() unconditionally. Otherwise this would result in the watchdog timer constantly being being reloaded and thus circumvent that the watchdog ever fires in the DEVICE_POLLING case. Pointed out by: bde
* - Use our own callout (the dc_tick() callout uses varying periodsmarius2006-12-062-27/+35
| | | | | | | | | depending on the NIC and isn't used at all with HomePNA links) instead of if_slowtimo() for driving dc_watchdog() in order to avoid races accessing if_timer. - Use bus_get_dma_tag() so dc(4) works on platforms requiring it. - Don't bother to set if_mtu to ETHERMTU, ether_ifattach() does that. - Remove an alpha remnant in dc_softc.
* Remove <sys/types.h>; including both <sys/param.h> and <sys/types.h>marius2006-11-021-1/+0
| | | | violates style(9).
* - Wrap code optimized for architectures without alignment constraintsmarius2006-10-291-16/+22
| | | | | | | | | | | | | | | | | | in #ifdef __NO_STRICT_ALIGNMENT rather than #ifdef __i386__. This means that amd64 now also uses the optimized code. [1] While at it, fix a nearby style(9) bug. - Remove the hw.dc_quick SYSCTL, which allowed to turn off the above mentioned optimization, as like the equivalent and already removed - In dc_setcfg() suppress printing a warning when forcing the receiver and transceiver to idle state times out for chips where the status bits in question just never change (observed in detail with DM9102A) and therefore the warning would be highly likely false positive. [2] - In dc_ifmedia_sts() add a missing DC_UNLOCK(). Tested by: Hans-Joerg Sirtl on amd64 [1] PR: 82681 [2] Obtained from: NetBSD tlp(4) [2] MFC after: 1 week
* - Consistently use if_printf() only in interface methods: if_start(),glebius2006-09-152-6/+8
| | | | | | | | if_watchdog, etc., or in functions used only in these methods. In all other functions in the driver use device_printf(). - Use __func__ instead of typing function name. Submitted by: Alex Lyashkov <umka sevcity.net>
* Replace hard-coded magic constants to system defined constantsyongari2006-08-022-2/+2
| | | | | | (BUS_PROBE_DEFAULT, BUS_PROBE_GENERIC etc). These pseudo PHY drivers were forgotten from the conversion due to the repo copy to dc driver location.
* Fix the last commit.glebius2006-06-082-3/+8
| | | | | Submitted by: jhb Pointy hat to: glebius
OpenPOWER on IntegriCloud