Commit Graph

201 Commits

Author SHA1 Message Date
Pedro F. Giffuni
453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Svatopluk Kraus
8ac1f62137 Fix build when KTR is defined but not KTR_TULIP.
Approved by:	kib (mentor)
2015-11-20 09:37:04 +00:00
Gleb Smirnoff
c8dfaf382f Mechanically convert to if_inc_counter(). 2014-09-19 03:51:26 +00:00
John Baldwin
a2677ff239 Don't bother clearing maps for static DMA allocations to NULL. Instead,
leave them as purely opaque values that are only set by bus_dmamem_alloc().
2014-06-17 18:10:06 +00:00
John Baldwin
5d00bfa3cd Fix a few more drivers that were explicitly destroying the bus_dma
map created by bus_dmamem_alloc().
2014-06-11 17:03:14 +00:00
Gleb Smirnoff
76039bc84f The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare
to this event, adding if_var.h to files that do need it. Also, include
all includes that now are included due to implicit pollution via if_var.h

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2013-10-26 17:58:36 +00:00
Gleb Smirnoff
c6499eccad Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags in sys/dev.
2012-12-04 09:32:43 +00:00
Scott Long
62ce43ccc8 More conversions of drivers to use the PCI parent DMA tag. 2012-03-12 18:15:08 +00:00
Ed Schouten
75da3c1a9b Replace inline static' by static inline'.
If I interpret the C standard correctly, the storage specifier should be
placed before the inline keyword. While at it, replace __inline by
inline in the files affected.
2011-12-13 14:06:01 +00:00
Martin Blapp
c2ede4b379 Remove extraneous semicolons, no functional changes.
Submitted by:	Marc Balmer <marc@msys.ch>
MFC after:	1 week
2010-01-07 21:01:37 +00:00
John Baldwin
12d54232b2 Use a private timer to run the statistics timer instead of (ab)using
if_watchdog and if_timer.

Tested by:	WATANABE Kazuhiro  CQG00620 of nifty.ne.jp
2009-11-17 14:13:30 +00:00
Pyun YongHyeon
42bd415090 Align Tx/Rx descriptors on 32 bytes boundary instead of PAGE_SIZE.
Also align setup descriptor on 32 bytes boundary. Tx buffer have no
alignment limitation so create dmamap without alignment
restriction[1]. Rx buffer still seems to require 4 bytes alignment
limitation but we can simply use MCLBYTES for size to map the
buffer instead of TULIP_DATA_PER_DESC as the buffer is allocated
with m_getcl(9).
de(4) supports up to TULIP_MAX_TXSEG segments for Tx buffers,
increase maximum dma segment size to TULIP_MAX_TXSEG * MCLBYTES.
While I'm here remove TULIP_DATA_PER_DESC as it is not used anymore.

This should fix de(4) breakage introduced after r176206.

Submitted by:	jhb [1]
Reported by:	WATANABE Kazuhiro < CQG00620 <> nifty dot ne dot jp >
Tested by:	WATANABE Kazuhiro < CQG00620 <> nifty dot ne dot jp >,
		Takahashi Yoshihiro < nyan <> jp dot freebsd dot org >
2009-09-24 17:53:00 +00:00
Pyun YongHyeon
f0ca781120 Destroy dmamap in dma cleanup. 2009-09-24 17:11:41 +00:00
Pyun YongHyeon
d0cf2f2116 Consistently use bus_addr_t. 2009-09-24 17:07:04 +00:00
Pyun YongHyeon
839dd22afd Use __NO_STRICT_ALIGNMENT to determine whether de(4) have to apply
alignment fixup code for received frames on strict alignment
architectures.
2009-09-24 16:57:35 +00:00
Robert Watson
eb956cd041 Use if_maddr_rlock()/if_maddr_runlock() rather than IF_ADDR_LOCK()/
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
2009-06-26 11:45:06 +00:00
Max Khon
7c9d6ad424 tulip_busdma_cleanup: pass correct vaddr (2nd arg) to bus_dmamem_free()
Found with:	Coverity Prevent(tm)
CID:		1998
2009-02-09 17:07:29 +00:00
John Baldwin
9c9191983b During attach on some de(4) adapters the driver sends out a test packet as
part of detecting the media.  Explicitly ensure that we don't send it to
bpf(4) as bpf(4) isn't setup yet.  This worked by accident before the bpf
interface stuff was reworked to avoid other races (bpf_peers_present, etc.)
but now it needs an explicit check to avoid a panic.

MFC after:	3 days
PR:		kern/120915
2008-04-05 17:24:44 +00:00
Pyun YongHyeon
78bec5fa2f The maxsegsz of a dma tag created in de(4) is TULIP_DATA_PER_DESC bytes.
In Rx path it allocates a new mbuf with m_getcl(9) so the length of
the mbuf is MCLBYTES which is greater than a segment size specified by
the dma tag. This segment size mismatch caused a voluntary panic.
Fix the panic by settting the mbuf length to TULIP_DATA_PER_DESC.

Reported by:	Arne H Juul <arnej AT yahoo-inc DOT com>
Tested by:	Arne H Juul <arnej AT yahoo-inc DOT com>
2007-06-07 00:28:47 +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
Gleb Smirnoff
6b9f5c941c - Consistently use if_printf() only in interface methods: if_start(),
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>
2006-09-15 15:16:12 +00:00
John Baldwin
73dbd3da73 Remove various bits of conditional Alpha code and fixup a few comments. 2006-05-12 05:04:46 +00:00
Warner Losh
6e5832cd99 Repo copy de driver to dev/de, and adjust. 2006-02-26 17:52:04 +00:00
John Baldwin
2a3d3a660b Use the copy of the card's MAC address saved in tulip_enaddr() in the softc
if we need a valid MAC address (for probing the media for example) before
ether_ifattach() has been called since IF_LLADDR() is NULL then.

Tested by:	tisco
2005-12-22 16:18:23 +00:00
Ruslan Ermilov
6a4cb6fd25 Fix the type of "eaddr" to guarantee the required alignment.
Suggested by:	marcel
2005-12-01 21:18:04 +00:00
Ruslan Ermilov
3faffd5dae Byte copy IF_LLADDR() on stack to align it to be safe for typecasts.
Tested by:	jhb
2005-11-30 17:48:23 +00:00
John Baldwin
f5e19c7342 Various fixes to make de(4) not panic after ru@'s IF_LLADDR() changes:
- Don't call tulip_addr_filter() to reset the RX address filter in
  tulip_reset() since that gets called before ether_ifattach().  Just
  call it in tulip_init_locked().
- Use be16dec() and le16dec() to parse MAC addresses when programming
  the RX filter.
- Let ether_ioctl() handle SIOCSIFMTU since we were doing the exact same
  thing with the added bonus that we leaked the driver lock if the MTU
  was > ETHERMTU in the homerolled version.  This part will be MFC'd.

Clue from:	wpaul (1)
Stolen from:	marcel (2 via patch for dc(4))
MFC after:	1 week
2005-11-21 21:50:07 +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
John Baldwin
dbc2a95f40 - Use m_defrag() instead of homerolling our own variant
tulip_mbuf_compress().  If we fail to allocate a new mbuf to copy the
  data into, put the mbuf back in the driver's send queue so that we can
  retry it later rather than throwing the packet away.
- Use m_devget() instead of doing it inline ourselves in the
  TULIP_COPY_RXDATA case.  If we fail to allocate an mbuf to copy the data
  into, don't forget about the original mbuf cluster.  The old code would
  lose the pointer and leak the cluster in that case.  Now it doesn't lose
  it but always sticks the original rx buffer back into the receive ring
  after trying to copy the data out and send it up the stack.  Also, if we
  fail to allocate a new mbuf to copy the data into, log an input error.
  Also, don't combine the priming case with the received-a-packet case to
  make the code flow a bit clearer and easier to follow.
2005-08-26 14:27:38 +00:00
John Baldwin
4faaaed479 - Remove non-bus-dma code.
- Remove form feed characters.
- Fixup style of function declarations.
- Assume that an mbuf cluster is big enough to hold an ethernet frame.
  (This should really be using m_defrag(), but this diff is just simple
  changes for now.)
2005-08-25 21:06:56 +00:00
John Baldwin
f8190d8dc8 Major rototill of this driver to add FreeBSD bus-dma support:
- Allocate arrays of metadata for the descriptors in the rx and tx rings
  and change the ring pointers to walk the metadata array rather than the
  actual descriptor rings.  Each metadata object contains a pointer to its
  descriptor, a pointer to any associated mbuf, and a pointer to the
  associated bus_dmamap_t in the bus_dma case.  The mbuf pointers replace
  the tulip_txq and tulip_rxq local ifqueue's in the softc.
- Add lots of KTR trace entries using a local KTR_TULIP level which
  defaults to 0, but can be changed to KTR_DEV at the top of the file
  when debugging.
- Rename tulip_init(), tulip_start(), tulip_ifinit(), and tulip_ifstart()
  to tulip_init_locked(), tulip_start_locked(), tulip_init(), and
  tulip_start(), respectively, to match the convention in other drivers.
- Add a TULIP_SP_MAC() macro to encode two bytes of the MAC address into
  the setup buffer and use that in place of lots of BYTE_ORDER #ifdef's.
  Also, remove an incorrect XXX comment I added earlier, the driver was
  correct (at least it does the same thing dc(4) does).  TULIP_SP_MAC
  was shamelessly copied from DC_SP_MAC() in dc(4).
- Remove the #ifdef'd NetBSD bus-dma code and replace it with FreeBSD
  bus-dma code that not only compiles but even works at runtime.
- Use callout_init_mtx() instead of just callout_init().
- Correct the various wrapper macros for bus_dmamap_sync() for the rx
  and tx buffers to only ask for the sync ops that they actually need.
- Tidy the #ifdef TULIP_COPY_RXDATA code by expanding an #ifdef a bit
  so it becomes easier to read at the expense of a couple of duplicated
  lines of code.  Also, use m_getcl() to get an mbuf cluster rather than
  MGETHDR() followed by MCLGET().
- Maintain the ring free (ri_free) count for the rx ring metadata since
  we no longer have tulip_rxq.ifq_len around to indicate how many mbuf's
  are currently in the rx ring.
- Add code to teardown bus_dma resources when attach fails and generally
  fixup attach to do a better job of cleaning up when it fails.  This
  gets us a good bit closer to possibly having a detach method someday
  and making this driver an unloadable module.
- Add some functions that can be called from ddb to dump the state of
  a descriptor ring and to dump the state of an individual descriptor.
- Various comment grammer and spelling fixes.

I have bus-dma turned on by default, but I've left the non-bus-dma code
around so that it can be turned off to aid in debugging should any problems
turn up later on.  I'll be removing the non-bus-dma code in a subsequent
commit.
2005-08-25 20:12:43 +00:00
John Baldwin
8a8573fdb2 - Use htole32() instead of using bswap32() conditional on #if BYTE_ORDER.
- Don't set IFF_ALLMULTI in our ifnet's if_flags if we end up allowing
  all multicast due to limits in the MAC receive filters in hardware.

Requested by:	rwatson (2)
2005-08-17 17:46:51 +00:00
John Baldwin
fcde23065f Call tulip_start() rather than tulip_ifstart() from the interrupt handler
to avoid recursing on the driver lock.  Not sure why my test box didn't
catch this earlier.

MFC after:	3 days
2005-08-09 21:53:26 +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
John Baldwin
d0e98e85f8 - Use callout_*() rather than timeout() to periodically poll the media.
- Add locking to protect the softc and mark this driver as MP safe.  There
  are still some edge cases with multiport cards that need more locking
  work.

MFC after:	1 week
Tested on:	alpha
2005-07-27 13:51:01 +00:00
John Baldwin
9cc8edda00 - Use the PCIR_BAR() macro rather than hardcoding rids.
- Use pci_enable_busmaster() rather than fiddling with the PCI command
  register directly.
2005-07-21 16:43:07 +00:00
John Baldwin
88519d6427 Don't set if_start to tulip_ifstart all over the place. It is already
set in tulip_attach() and its value is never changed, so all the extra sets
are redundant.  I'm guessing that at some point in time de(4) had an
alternate start routine, but that hasn't been true in recent history.
2005-07-21 16:42:21 +00:00
John Baldwin
fe0c8544ff Remove conditional code that has largely rotted that is also not on by
default:
- TULIP_NEED_FASTTIMEOUT - tulip_fasttimeout() wasn't called anywhere
- BIG_PACKET - only worked on i386 anyway
- TULIP_USE_SOFTINTR - doesn't compile and was never updated to handle
  new netisr registration
- non-FreeBSD code
2005-07-21 16:40:08 +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
d701c91325 Return BUS_PROBE_DEFAULT instead of 0. 2005-02-24 21:32:56 +00:00
Poul-Henning Kamp
6d6b7a18aa Hide link up/down/media printfs behind bootverbose 2004-11-08 19:21:57 +00:00
John-Mark Gurney
7a099cc936 fix (for me) the problems where if_de gets really slow after time
(usually taking 20 seconds to transmit a packet).. no longer fall back
to only transmitting one packet (instead of the entire queue) after we
have processed the entire send queue...  I have no idea why we didn't
start seeing this problem ~6 years ago when this code was introduced...
2004-10-18 23:06:12 +00:00
Robert Watson
09e54b95d3 Since the if_de driver doesn't contain locking, mark it as
IFF_NEEDSGIANT so that ifp->if_start won't be called without Giant
when running debug.mpsafenet=1.
2004-08-13 22:48:05 +00:00
Bruce M Simpson
892b9d7758 style(9) pass on prototypes. 2004-07-05 22:27:26 +00:00
Stefan Farfeleder
5908d366fb Consistently use __inline instead of __inline__ as the former is an empty macro
in <sys/cdefs.h> for compilers without support for inline.
2004-07-04 16:11:03 +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
Christian Weisgerber
0e939c0cea Replace handrolled CRC calculation with ether_crc32_[lb]e(). 2004-06-09 14:34:04 +00:00
Poul-Henning Kamp
f11d01c3bc Add missing <sys/module.h> includes 2004-05-30 20:00:41 +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