Commit Graph

47 Commits

Author SHA1 Message Date
Pyun YongHyeon
6ceb40baa9 Fix link state handling in bfe(4).
o conversion to callout(9) API.
 o add a missing driver lock in bfe_ifmedia_sts().
 o use our callout to drive watchdog timer.
 o restart Tx routine if pending queued packets are present in
   watchdog handler.
 o unarm watchdog timer only if there are no queued packets.
 o don't blindly reset phy and let phy driver handle link change
   request in bfe_init_locked().
 o return the status of mii_mediachg() to caller in
   bfe_ifmedia_upd(). Previously it always returned 0 to caller.
 o add check for IFF_DRV_RUNNING flag as well as IFF_DRV_OACTIVE
   in bfe_start_locked().
 o implement miibus_statchg method that keeps track of current
   link state changes as well as negotiated speed/duplex/
   flow-control configuration.
   Reprogram MAC to appropriate duplex state. Flow-control
   configuration was also implemented but commented out at the
   moment. The flow-control configuration will be enabled again
   after we have general flow-control framework in mii layer.

Reported by:	Yousif Hassan < yousif () alumni ! jmu ! edu >
Tesdted by:	Yousif Hassan < yousif () alumni ! jmu ! edu >
2008-01-29 02:15:11 +00:00
Pyun YongHyeon
6a087a8722 Fix function prototype for device_shutdown method. 2007-11-22 02:45:00 +00:00
Paolo Pisati
ef544f6312 o break newbus api: add a new argument of type driver_filter_t to
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@
2007-02-23 12:19:07 +00:00
John Baldwin
6daee769f4 Add suspend/resume support. Unlike many other NIC drivers,
bfe_init_locked() wasn't sufficient to bring the chip back to life, it also
required a call to bfe_chip_reset() during resume.

Tested by:	Stepan Zastupov +redchrom at gmail+
MFC after:	1 week
2006-11-20 23:30:07 +00:00
Mike Silbersack
3981b687c0 Back out the BUS_DMA_ALLOCNOW change from rev 1.39. Scottl informed me that
it's unnecessary, as the TX/RX lists are static allocations.
2006-05-28 20:35:39 +00:00
Mike Silbersack
f99da8e0d8 Re-revert back to rev 1.8:
- Reduce the number of RX and TX buffers bfe uses so that it does not use more
  bounce buffers than busdma is willing to allow it to use

See if_bfe.c for comments on why this is now safe to do.
2006-05-28 18:44:39 +00:00
Mike Silbersack
678d2a9a8c 1. Make sure that the TX and RX descriptor rings are 4096 byte aligned.
Also use BUS_DMA_ALLOCNOW to be on the safe side.

2.  Look for the Descriptor Error, and Descriptor Protocol Error flags from
    the card, and down the interface if we detect either.

#1 (along with fixes to busdma) makes sure that this card works in all
memory situations.  Prior to this change, it was just luck that 512 count
RX/TX lists were properly aligned.  Now we can use any size of RX/TX lists
and still have them properly aligned.

#2 ensures that we don't get into an endless interrupt storm if busdma fails
us.  Descriptor Protocol Error would occur if we misaligned the TX/RX rings,
and Descriptor Error would occur if we tried to give the card descriptors
or rings with addresses > 1G.  Trying to reinitialize the card isn't going
to fix these errors, hence we don't try.
2006-05-28 18:41:47 +00:00
Poul-Henning Kamp
c40da00ca3 Since DELAY() was moved, most <machine/clock.h> #includes have been
unnecessary.
2006-05-16 14:37:58 +00:00
Mike Silbersack
5c5ac08992 Revert if_bfereg.h rev 1.8; restore the RX and TX list sizes to 511.
Two users have reported problems due to the smaller list sizes.
2006-05-11 17:39:06 +00:00
Mike Silbersack
5511c4d6dc Fix three more bugs in bfe:
- Fix bfe_encap so that it will pass the address of the mbuf back up to its
  caller if/when it modifies it, as it does when doing a m_defrag on a mbuf chain.
- Make sure to unload the dmamap for ALL fragments of a packet, not just the first
- Use BUS_DMA_NOWAIT for all bus_dmamap_load calls so that the allocation of the
  map is not delayed - this driver is not set up to handle such delays.
- Reduce the number of RX and TX buffers bfe uses so that it does not use more
  bounce buffers than busdma is willing to allow it to use

With these changes, the driver now works properly for a user with a 2GB system,
and it also works on my system when the acceptable address range is lowered to 128MB.
Previously, both of these setups would act up after a few minutes of activity.
2006-05-04 07:41:01 +00:00
Mike Silbersack
981b2dea6b Tweak the DMA limit from rev 1.33, it was off by one byte.
Submitted by:	scottl
2006-04-28 05:38:12 +00:00
Mike Silbersack
cff1362221 Switch all bus_dmamap_sync calls that used PREREAD to PREWRITE and all
POSTWRITE to POSTREAD.

No guarantee that all busdma is usage is perfect, but this change (in
addition to scott's last two commits) makes if_bfe work with > 1GB of
memory in my laptop.
2006-04-28 05:27:27 +00:00
Scott Long
a6456c02ba The alignment parameter to busdma must be a power of two, while the if_bfe
driver was trying to use an arbitrary rx/tx ring size of the value.  Change
to using unrestricted values for alignment and boundary instead.
2006-04-27 23:03:00 +00:00
Scott Long
9171a12bcd Fix problem with having more than 1GM of RAM. Also fix a nearby busdma
problem.

Submitted by: silby
2006-04-27 14:02:58 +00:00
Pawel Jakub Dawidek
3d5e60cb6e Don't call bfe_release_resources() twice.
Found by:	Coverity Prevent analysis tool
CID:		600
MFC after:	1 week
2006-04-04 22:30:12 +00:00
Gleb Smirnoff
23033eebf4 Do not touch ifp->if_baudrate in miibus aware drivers. 2006-02-14 12:44:56 +00:00
Ruslan Ermilov
4a0d6638b3 - Store pointer to the link-level address right in "struct ifnet"
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.
2005-11-11 16:04:59 +00:00
Warner Losh
7b279558cc Replace FreeBSD 3.x syntax (controller miibus0) with 4.x syntax
(device miibus) in time for 7.0 :-)
2005-10-22 05:06:55 +00:00
Ruslan Ermilov
ad61f89618 Fix "struct ifnet" leaks when attach() fails in the middle. 2005-09-16 11:25:19 +00:00
Robert Watson
13f4c340ae Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
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
2005-08-09 10:20:02 +00:00
Robert Watson
13b203d0d7 Modify device drivers supporting multicast addresses to lock if_addr_mtx
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
2005-08-03 00:18:35 +00:00
Brooks Davis
fc74a9f93a Stop embedding struct ifnet at the top of driver softcs. Instead the
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
2005-06-10 16:49:24 +00:00
Warner Losh
4d3c2a319c Powerstate stuff now done in PCI bus driver 2005-06-05 22:48:15 +00:00
Yoshihiro Takahashi
d4fcf3cba5 Remove bus_{mem,p}io.h and related code for a micro-optimization on i386
and amd64.  The optimization is a trivial on recent machines.

Reviewed by:	-arch (imp, marcel, dfr)
2005-05-29 04:42:30 +00:00
Tai-hwa Liang
60c38bde75 Releasing TX/RX descriptor dmamaps during device detachment instead of
doing that in bfe_stop().

This should fix a panic recently reported on -current occuring when taking
device down then up.  In the original implementation, an "ifconfig bfe0 down"
triggers bfe_stop(), which also destroys all TX/RX descriptor dmamaps. Hence
the subsequent "ifconfig bfe0 up" would force the device to use those
already-released dmamap and thus panic the kernel.

PR:		kern/77804
Submitted by:	Frank Mayhar <frank at exit dot com>
Reviewed by:	dmlb, sam (mentor)
Tested by:	Phil <pcasidy at casidy dot com>, myself
MFC after:	1 week
2005-03-17 13:59:30 +00:00
Warner Losh
53ee71735f Use BUS_PROBE_DEFAULT for pci probe return value 2005-03-05 19:06:12 +00:00
Sam Leffler
b03eb9a092 correct direction for bus_dma sync of rx buffer
Submitted by:	Tai-hwa Liang
2005-01-09 19:57:55 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Mike Makonnen
f16b4811d2 Locking cleanups to remove the need for a recursive mutex
o Instead of locking and unlocking all over the place, use
	  lock assertions to make certain that the bfe lock is held
	  where necessary.
	o Create locked and unlocked versions of bfe_init and bfe_start. These
	  functions can be called from outside the module and by functions
	  within the bfe module. The calls from outside the module don't
	  hold the bfe lock so the unlocked versions called by these functions
	  simple obtain the bfe lock and call the locked version.

- Fix a typo (scp) in the locking macros that only worked because in all the
  instances in which it was called the softc pointer happened to be named 'sc'.

- Mark the interrupt MPSAFE

Tested by: matusita, Dario Freni <saturnero@gufi.org>
Silence from: -net, wpaul
2004-10-23 08:33:10 +00:00
Max Laier
22d0ab2ef8 Fix sis, bfe and ndis in the same way dc was fixed:
Do not tell the hardware to send when there were no packets enqueued.

Found and reviewed by:	green
MFC after:		1 days
2004-10-08 16:14:42 +00:00
Dag-Erling Smørgrav
037fc73d96 Add PCI ID for the BCM4401-B0.
Submitted by:	krion
MFC after:	3 days
2004-09-01 06:10:11 +00:00
Dag-Erling Smørgrav
27de24a734 The whitespace crusader strikes! 2004-08-07 20:55:53 +00:00
Max Laier
7929aa036c Bring in the first chunk of altq driver modifications. This covers the
following drivers: bfe(4), em(4), fxp(4), lnc(4), tun(4), de(4) rl(4),
sis(4) and xl(4)

More patches are pending on: http://peoples.freebsd.org/~mlaier/ Please take
a look and tell me if "your" driver is missing, so I can fix this.

Tested-by:	many
No-objection:	-current, -net
2004-07-02 12:16:02 +00:00
Poul-Henning Kamp
fe12f24bb0 Add missing <sys/module.h> includes 2004-05-30 20:08:47 +00:00
Dag-Erling Smørgrav
df7593b5a4 Set the IFCAP_VLAN_MTU bit in capenable as well.
Reminded by:	ru
2004-05-25 11:33:19 +00:00
Dag-Erling Smørgrav
912bf9d37c Set baudrate to 100 Mbps, and advertise our ability to handle extended
frames (802.1q).

Submitted by:	Steinar Haug <sthaug@nethelp.no>
2004-05-25 11:04:01 +00:00
Maxime Henrion
866a788cc2 We don't need to initialize if_output, ether_ifattach() does it
for us.
2004-05-23 16:11:53 +00:00
Duncan Barclay
62a9464c76 Apply fix for long timeouts on driver initialisation.
PR:		64656
Submitted by:	Jianqin Qu <jqu@its.brooklyn.cuny.edu>
Reviewed by:	dmlb
2004-05-23 08:35:07 +00:00
Wes Peters
be3d6f1dc5 Added BSD license, as requested by author.
Requested-by:	Stuart Walsh <stu@ipng.org.uk>
Message-ID:	<20040331190716.GB32835@deepfreeze.stu>
2004-04-04 06:13:56 +00:00
Nate Lawson
5f96beb9e0 Convert callers to the new bus_alloc_resource_any(9) API.
Submitted by:	Mark Santcroos <marks@ripe.net>
Reviewed by:	imp, dfr, bde
2004-03-17 17:50:55 +00:00
Matthew N. Dodd
e3bbbec2ca Announce ethernet MAC addresss in ether_ifattach(). 2004-03-14 07:12:25 +00:00
Julian Elischer
8fc8ef2efe When we get a packet error, move on, don't go into an infinite loop
looking at it.

fixes at least one cause of "hanging" due to this driver.
2004-03-02 05:43:42 +00:00
Julian Elischer
f2b1c1580a Whitespace changes to match rest of file.. 2004-03-02 01:46:34 +00:00
Sam Leffler
5120abbfb4 Drop the driver lock around calls to if_input to avoid a LOR when
the packets are immediately returned for sending (e.g.  when bridging
or packet forwarding).  There are more efficient ways to do this
but for now use the least intrusive approach.

Reviewed by:	imp, rwatson
2003-11-14 19:00:32 +00:00
Brooks Davis
9bf40ede4a Replace the if_name and if_unit members of struct ifnet with new members
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)
2003-10-31 18:32:15 +00:00
Bill Paul
af8512b863 Remove unnecessary #include of brgphyreg.h, left over from when Stuart used
the bge(4) driver as a template.
2003-09-09 18:21:17 +00:00
Bill Paul
b9f78d2b4a Add a device driver for the Broadcom BCM4401 ethernet controller,
written by Stuart Walsh and Duncan Barclay (with some kibbitzing by
me). I'm checking it in on Stuart's behalf.

The BCM4401 is built into several x86 laptop and desktop systems. For the
moment, I have only enabled it in the x86 kernel config because although
it's a PCI device, I haven't heard of any standalone NICs that use it. If
somebody knows of one, we can easily add it to the other arches.

This driver uses register/structure data gleaned from the Linux
driver released by Broadcom, but does not contain any of the code
from the Linux driver itself. It uses busdma.
2003-09-09 18:17:23 +00:00