summaryrefslogtreecommitdiffstats
path: root/sys/pci/if_dc.c
Commit message (Collapse)AuthorAgeFilesLines
* Clean up locking and resource management for pci/if_*njl2003-03-311-33/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove locking of the softc in the attach method, instead depending on bus_setup_intr being at the end of attach (delaying interrupt enable until after ether_ifattach is called) - Call *_detach directly in the error case of attach, depending on checking in detach to only free resources that were allocated. This puts all resource freeing in one place, avoiding thinkos that lead to memory leaks. - Add bus_child_present check to calls to *_stop in the detach method to be sure hw is present before touching its registers. - Remove bzero softc calls since device_t should do this for us. - dc: move interrupt allocation back where it was before. It was unnecessary to move it. This reverts part of 1.88 - rl: move irq allocation before ether_ifattach. Problems might have been caused by allocating the irq after enabling interrupts on the card. - rl: call rl_stop before ether_ifdetach - sf: call sf_stop before ether_ifdetach - sis: add missed free of sis_tag - sis: check errors from tag creation - sis: move dmamem_alloc and dmamap_load to happen at same time as tag creation - sk: remove duplicate initialization of sk_dev - ste: add missed bus_generic_detach - ti: call ti_stop before ether_ifdetach - ti: add missed error setting in ti_rdata alloc failure - vr: add missed error setting in I/O, memory mapping cases - xl: add missed error setting in I/O, memory mapping cases - xl: remove multi-level goto on attach failure - xl: move dmamem_alloc and dmamap_load to happen at same time as tag creation - Calls to free(9) are unconditional because it is valid to call free with a null pointer. Reviewed by: imp, mdodd
* Update if_dc to use m_defrag, removing the semi-duplicate dc_coalsilby2003-03-291-35/+30
| | | | | | | | | | | function. Also, use m_defrag where appropriate to defrag long mbuf chains in the same fashion as was done in if_sis.c. Before this change, if_dc would blow up and take down the interface if fed a really long mbuf chain. MFC after: 2 weeks
* - Use if_broadcastaddr from struct ifnet rather than relying onmdodd2003-03-211-2/+2
| | | | | | | extern 'etherbroadcastaddr'. - Make 'etherbroadcastaddr' static. Reviewed by: imp
* Back out M_* changes, per decision of the TRB.imp2003-02-191-4/+4
| | | | Approved by: trb
* Minor correction to comment: PNIC and XIRCOM have eeprom, its justimp2003-02-121-1/+1
| | | | non-standard.
* Fix the breakage resulting from Rev. 1.80. Get the eeprom widthmbr2003-02-071-4/+5
| | | | | | | | | | | | | | | | | | | for all but two cards. This should fix broken cards like these: DM9102 (Davicom, DEVICE_ID: 0x9002) DM9009 (Davicom, DEVICE_ID: 0x9009) DM9100 (Davicom, DEVICE_ID: 0x9100) 98713/98713_CP (Macronix PMAC, DEVICE_ID: 0x0512) 98713_CP (Macronix PMAC, DEVICE_ID: 0x0512) 987x5 (Macronix PMAC, DEVICE_ID: 0x0531) 98727 (Macronix PMAC, DEVICE_ID: 0x0532) 82C115 (Lite-On PNIC II, DEVICE_ID: 0xc115) AX88140A (ASIX Dev_ID: DEVICE_ID: 0x1400) EN1217 (Accton EN1217, DEVICE_ID: 0x1217) Note that these cards sould still work in STABLE. Reviewed by: imp
* Add missing braces.mbr2003-02-071-1/+2
| | | | | Found by: FlexeLint (phk) Reviewed by: wpaul, phk
* Move the DC_SETBIT to the attach function.mbr2003-02-051-3/+7
| | | | Reviewed by: phk
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-4/+4
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Remove bogus locking from dc(4). Instead, move interrupt allocationnjl2003-01-141-42/+34
| | | | | | | | and ether_ifattach() to end. This fixes a "could sleep" case and simplifies error exit cases as well. Also be sure to set errno and clean up resources in !mac error case. Tested by: Ryan Beasley
* Add preliminary support for the Hawking PN672TX CardBus cards.imp2003-01-101-0/+3
| | | | | # Preliminary because there are some subtle things the NetBSD driver does # that we don't do yet. My card works for me w/o them.
* Add support for the Davicom DM9009 chipset.trhodes2003-01-091-0/+3
| | | | | | PR: 46859 Submitted by: Boaz Haberman <boaz@ool-182f8b09.dyn.optonline.net> Approved by: rwatson
* Xircom cards store the MAC address in the CIS, so get it from the newimp2002-11-271-2/+8
| | | | | | | | pci_get_ether accesor, which gets it from the CIS for cardbus cards (and from other pci-like buses via whatever mechanism is used there). Submitted by: sam Approved by: re (blanket)
* Fix handling of IFF_ALLMULTI. The same bug in various forms affectsluigi2002-11-251-9/+7
| | | | | | | | the following drivers: dc mn sf sk ste ti tl xl an bge em gem gx ie lge sr aue cue kue wi xe Approved by: re
* o track either_ifattach/ether_ifdetach API changessam2002-11-141-16/+6
| | | | | | | | | | | o use if_input for input packet processing o don't strip the Ethernet header for input packets o use BPF_* macros bpf tapping o call ether_ioctl to handle default ioctl case o track vlan changes Reviewed by: many Approved by: re
* Be consistent about functions being static.phk2002-10-161-6/+8
| | | | Spotted by: FlexeLint.
* Ooops. Need to free dc_srom on detach to not leak memory.imp2002-10-071-0/+1
| | | | Pointy Hat to: The Mad Redhead of Niwot
* Dynamically configure the width of the srom. This code comes fromimp2002-10-071-14/+104
| | | | | | | | | | | | | | OpenBSD who got the code (or the idea) from the NetBSD tlp driver. This gets some cardbus dc cards working (either completely or nearly so). It also appears to get additional pci cards working, without breaking working ones. # Maybe some additional work is needed here. Also, the cardbus attachment # might need to match on the CIS rather than on the vendor/device so we have # a finer level of detail as to what the card is. Technically, the # vendor/device fields are undefined for CardBus (even though most cards are # using common silicon with pci models).
* Fix the support for the AN985/983 chips, which do not set thembr2002-09-201-1/+2
| | | | | | | | | RXSTATE to STOPPED, but to WAIT. This should fix hangs which could only be solved by replugging the cable. Submitted by: jhb Reviewed by: phk MFC after: 2 weeks
* Enable the automatic TX underrun recovery for the ADMtek chips.mbr2002-09-201-0/+3
| | | | | | | | | This solves cvsup update on my laptop which aborts after a while without this patch. PR: 34236 Reviewed by: phk MFC after: 2 weeks
* Make consistent; turn spaces into tabs where there is a mixture.markm2002-09-041-21/+21
|
* style:alfred2002-08-231-58/+116
| | | | | put return values on a line by themselves. fix some paste issues where whitespace was used instead of tabs.
* Increase size of ifnet.if_flags from 16 bits (short) to 32 bits (int). To avoidsobomax2002-08-181-3/+3
| | | | | | | breaking application ABI use unused ifreq.ifru_flags[1] for upper 16 bits in SIOCSIFFLAGS and SIOCGIFFLAGS ioctl's. Reviewed by: -hackers, -net
* Fix if_timer logic to make sure that there is always a timeoutluigi2002-06-301-6/+6
| | | | | | pending if there are packets queued for transmission. MFC after: 3 days
* Add suspend/resume code mostly merged from fxp/rl driver.iwasaki2002-05-061-0/+81
| | | | | | | This is temporary hack, better and generalized solution probably should be implemented at lower layer(MII or PCI?). Tested by: shoko.araki@soliton.co.jp MFC after: 1 week
* Don't grab the lock until somewhat later in attach to avoid a lockphk2002-05-031-6/+7
| | | | reversal.
* Move us yet closer to IFM_* definitions in NetBSD.phk2002-04-291-6/+6
|
* Change callers of mtx_init() to pass in an appropriate lock type name. Injhb2002-04-041-1/+2
| | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64
* Remove __P.alfred2002-03-201-67/+62
|
* Add VLAN for the dc(4) driver (ie long frame). The patch is 2 parts.ambrisko2002-01-161-12/+26
| | | | | | | | | | | | | | | | One to notify the system that the MTU for VLAN can be 1500 so the vlan will automatically be configured with a 1500 MTU the other is to ignore the error case if the received frame is to long. The frame size notification came from code in the SIS driver, and the support for long frames derived from the NetBSD Tulip driver. Tested on: 4 port D-Link adapter DFE-570TX 4 Intel 21143 Netgear card with 82c169 PNIC 10/100BaseTX Reviewed by: ru (manpage), wpaul (not objected to), archie Approved by: imp Obtained from: NetBSD
* Fix the "conexant chips don't work in full duplexmode" problem. Accordingwpaul2001-12-191-4/+8
| | | | | | | | | | | | | to Phil Kernick: "The problem is that in full duplex mode, the Conexant chip always reports a carrier lost error, even when the frame is successfully sent. So, if we have a Conexant chip, then ignore carrier lost when in full duplex mode." Since the Xircom chips seem to have the same issue and since we already have a workaround for this, just expand the workaround test to also check for DC_IS_CONEXANT().
* Fix compiler warning in dc_intr(): if the only code that does a "goto"wpaul2001-12-191-0/+3
| | | | | | to a label is inside an #ifdef block, then the label should *also* be inside an #ifdef block. Hide the "done:" label which is only used if DEVICE_POLLING is enabled under #ifdef DEVICE_POLLING.
* Patch up some existing style bugs and some that crept in with thepeter2001-12-151-7/+7
| | | | DEVICE_POLLING stuff.
* Device Polling code for -current.luigi2001-12-141-0/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Non-SMP, i386-only, no polling in the idle loop at the moment. To use this code you must compile a kernel with options DEVICE_POLLING and at runtime enable polling with sysctl kern.polling.enable=1 The percentage of CPU reserved to userland can be set with sysctl kern.polling.user_frac=NN (default is 50) while the remainder is used by polling device drivers and netisr's. These are the only two variables that you should need to touch. There are a few more parameters in kern.polling but the default values are adequate for all purposes. See the code in kern_poll.c for more details on them. Polling in the idle loop will be implemented shortly by introducing a kernel thread which does the job. Until then, the amount of CPU dedicated to polling will never exceed (100-user_frac). The equivalent (actually, better) code for -stable is at http://info.iet.unipi.it/~luigi/polling/ and also supports polling in the idle loop. NOTE to Alpha developers: There is really nothing in this code that is i386-specific. If you move the 2 lines supporting the new option from sys/conf/{files,options}.i386 to sys/conf/{files,options} I am pretty sure that this should work on the Alpha as well, just that I do not have a suitable test box to try it. If someone feels like trying it, I would appreciate it. NOTE to other developers: sure some things could be done better, and as always I am open to constructive criticism, which a few of you have already given and I greatly appreciated. However, before proposing radical architectural changes, please take some time to possibly try out this code, or at the very least read the comments in kern_poll.c, especially re. the reason why I am using a soft netisr and cannot (I believe) replace it with a simple timeout. Quick description of files touched by this commit: sys/conf/files.i386 new file kern/kern_poll.c sys/conf/options.i386 new option sys/i386/i386/trap.c poll in trap (disabled by default) sys/kern/kern_clock.c initialization and hardclock hooks. sys/kern/kern_intr.c minor swi_net changes sys/kern/kern_poll.c the bulk of the code. sys/net/if.h new flag sys/net/if_var.h declaration for functions used in device drivers. sys/net/netisr.h NETISR_POLL sys/dev/fxp/if_fxp.c sys/dev/fxp/if_fxpvar.h sys/pci/if_dc.c sys/pci/if_dcreg.h sys/pci/if_sis.c sys/pci/if_sisreg.h device driver modifications
* Avoid an unnecessary copy of a packet if it is already in a single mbuf.luigi2001-12-111-2/+6
| | | | | | | | Introduce an additional device flag for those NICs which require the transmit buffers to be aligned to 32-bit boundaries. (the equivalen fix for STABLE is slightly simpler because there are no supported chips which require this alignment there.)
* MFS (merge from stable): rev 1.9.2.28, fix ordering of IFF_RUNNING mods.peter2001-12-071-2/+2
| | | | | | The reason we are required to commit to -current first is so that later MFC's do not risk the loss of existing bug fixes. Even if this was not strictly required in -current, it should still be fixed there too.
* Remove error messages on mbuf allocation failures, nowluigi2001-12-041-10/+2
| | | | | | this is done more safely in kern/subr_mbuf.c Two-days'-delay-thanks-to: @home shutting down service
* Per jlemon request, reintroduce some printf() when anluigi2001-11-291-3/+8
| | | | | | | | | | | | | | mbuf allocation fails, and fix (i hope) a couple of style bugs. I believe these printf() are extremely dangerous because now they can occur on every incoming packet and are not rate limited. They were meant to warn the sysadmin about lack of resources, but now they can become a nice way to panic your system under load. Other drivers (e.g. the fxp driver) have nothing like this. There is a pending discussion on putting this kind of warnings elsewhere, and I hope we can fix this soon.
* For i386 architecture, remove an expensive m_devget() (and theluigi2001-11-291-31/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | underlying unaligned bcopy) on incoming packets that are already available (albeit unaligned) in a buffer. The performance improvement varies, depending on CPU and memory speed, but can be quite large especially on slow CPUs. I have seen over 50% increase on forwarding speed on the sis driver for the 486/133 (embedded systems), which does exactly the same thing. The behaviour is controlled by a sysctl variable, hw.dc_quick which defaults to 1. Set it to 0 to restore the old behaviour. After running a few experiments (in userland, though) I am convinced that doing the m_devget() is detrimental to performance in almost all cases. Even if your CPU has degraded performance with misaligned data, the bcopy() in the driver has the same overhead due to misaligment as the one that you save in the uiomove(), plus you do one extra copy and pollute the cache. But more often than not, you do not even have to touch the payload, e.g. when you are forwarding packets, and even in the often-cited case of NFS, you often end up passing a pointer to the payload to the disk controller. In any case, you can play with the sysctl variable to toggle between the two behaviours, and see if it makes a difference. MFC-after: 3 days
* Remove ifnet.if_mpsafe for now. If this is needed, it won't be neededjhb2001-11-141-1/+0
| | | | | | until much later when the network stack locking is farther along. Approved by: jlemon
* Enable round-robin arbitration between transmit and receive unitluigi2001-10-271-0/+5
| | | | | | | | in the 21143, instead of giving priority to the receive unit. This gives a 10-15% performance improvement in the forwarding rate under heavy load. Reviewed-by: Bill Paul
* Do not call mii_pollstat() from within device tick routines; the statusjlemon2001-09-291-8/+5
| | | | | | information is updated by mii_tick(). Pointed out by: wpaul (a while back)
* Add support for Conexant LANfinity miniPCI controllers. People who havewpaul2001-09-041-3/+27
| | | | | | | | | | laptops with this chip should test this and report back as I don't have access to this hardware myself. People with -stable systems should try the patch at: http://www.freebsd.org/~wpaul/conexant.patch.gz Submitted by: Phil Kernick <Phil@Kernick.org>
* Deal with the condition where we lose link in the middle of transmittingwpaul2001-07-121-1/+1
| | | | | | | | | | | | | | | a bunch of frames. In this case, the dc_link flag is cleared, and dc_start() stops draining the if_snd send queue, which results in lots of 'no buffers available' errors being reported to applications. The whole idea behind not draining the send queue until the link comes up was to avoid having the gratuitous ARP being lost while we're waiting for autoneg to complete after the interface is first brought up. As an optimization, change the test in dc_start() so that we only bail if dc_link is not set _and_ there are less than 10 packets in the send queue. If the queue has many frames in it, we need to drain them. If the queue has a small number of frames in it, we can hold off on sending them until the link comes up. MFC after: 1 week
* Apply patch supplied by Jonathan Chen: use the correct arguments towpaul2001-07-091-2/+2
| | | | | pci_enable_io(). We need to use SYS_RES_IOPORT/SYS_RES_MEMORY instead of PCIM_CMD_PORTEN/PCIM_CMD_MEMEN.
* Change m_devget()'s outdated and unused `offset' argument to actually meanbmilekic2001-06-201-3/+2
| | | | | | | | | | | | | | | | | | | | something: offset into the first mbuf of the target chain before copying the source data over. Make drivers using m_devget() with a first argument "data - ETHER_ALIGN" to use the offset argument to pass ETHER_ALIGN in. The way it was previously done is potentially dangerous if the source data was at the top of a page and the offset caused the previous page to be copied (if the previous page has not yet been appropriately mapped). The old `offset' argument in m_devget() is not used anywhere (it's always 0) and dates back to ~1995 (and earlier?) when support for ethernet trailers existed. With that support gone, it was merely collecting dust. Tested on alpha by: jlemon Partially submitted by: jlemon Reviewed by: jlemon MFC after: 3 weeks
* Apply patch to allow TX underrun handling without issuing a completewpaul2001-02-221-26/+58
| | | | | | chip reset. Just temporarily turn off the transmitter instead. Submitted by: Stephen McKay <mckay@freebsd.org>
* Big round of minor updates:wpaul2001-02-211-3/+3
| | | | | | | | | | | | | | - Use pci_get_powerstate()/pci_set_powerstate() in all the other drivers that need them so we don't have to fiddle with the PCI power management registers directly. - Use pci_enable_busmaster()/pci_enable_io() to turn on busmastering and PIO/memory mapped accesses. - Add support to the RealTek driver for the D-Link DFE-530TX+ which has a RealTek 8139 with its own PCI ID. (Submitted by Jason Wright) - Have the SiS 900/National DP83815 driver be sure to disable PME mode in sis_reset(). This apparently fixes a problem on some motherboards where the DP83815 chip fails to receive packets. (Submitted by Chuck McCrobie <mccrobie@cablespeed.com>)
* Take luigi's suggestion and move the check for nothing to do to before theimp2001-02-201-5/+4
| | | | lock so we don't have lots of null lock/release pairs.
* Add DC_UNLOCK before first return. This caused returns when dc was onimp2001-02-201-1/+3
| | | | | | a shared interrupt. Pointed out by tegge.
OpenPOWER on IntegriCloud