Commit Graph

46 Commits

Author SHA1 Message Date
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
Dimitry Andric
cddb1ffae1 Fix all the inconsistent nve_os* function declarations and definitions
in nve(4).  The OS_API structure defined in os.h expects NV_API_CALL
attributes, effectively regparm(0), on its function pointers, but all
the functions were declared and defined without this attribute.

MFC after:	1 week
2012-11-10 16:02:12 +00:00
Gleb Smirnoff
9e7df38148 Don't redefine macros defined in if.h and ethernet.h. 2012-10-17 21:30:16 +00:00
Scott Long
62ce43ccc8 More conversions of drivers to use the PCI parent DMA tag. 2012-03-12 18:15:08 +00:00
Kevin Lo
5bbe0c5357 ether_ifattach() sets if_mtu to ETHERMTU, don't bother set it again
Reviewed by:	yongari
2012-01-07 09:41:57 +00:00
Marius Strobl
4b7ec27007 - There's no need to overwrite the default device method with the default
one. Interestingly, these are actually the default for quite some time
  (bus_generic_driver_added(9) since r52045 and bus_generic_print_child(9)
  since r52045) but even recently added device drivers do this unnecessarily.
  Discussed with: jhb, marcel
- While at it, use DEVMETHOD_END.
  Discussed with: jhb
- Also while at it, use __FBSDID.
2011-11-22 21:28:20 +00:00
Pyun YongHyeon
57c81d92ae Close a race where SIOCGIFMEDIA ioctl get inconsistent link status.
Because driver is accessing a common MII structure in
mii_pollstat(), updating user supplied structure should be done
before dropping a driver lock.

Reported by:	Karim (fodillemlinkarimi <> gmail dot com)
2011-10-17 19:49:00 +00:00
Marius Strobl
3fcb7a5365 - Remove attempts to implement setting of BMCR_LOOP/MIIF_NOLOOP
(reporting IFM_LOOP based on BMCR_LOOP is left in place though as
  it might provide useful for debugging). For most mii(4) drivers it
  was unclear whether the PHYs driven by them actually support
  loopback or not. Moreover, typically loopback mode also needs to
  be activated on the MAC, which none of the Ethernet drivers using
  mii(4) implements. Given that loopback media has no real use (and
  obviously hardly had a chance to actually work) besides for driver
  development (which just loopback mode should be sufficient for
  though, i.e one doesn't necessary need support for loopback media)
  support for it is just dropped as both NetBSD and OpenBSD already
  did quite some time ago.
- Let mii_phy_add_media() also announce the support of IFM_NONE.
- Restructure the PHY entry points to use a structure of entry points
  instead of discrete function pointers, and extend this to include
  a "reset" entry point. Make sure any PHY-specific reset routine is
  always used, and provide one for lxtphy(4) which disables MII
  interrupts (as is done for a few other PHYs we have drivers for).
  This includes changing NIC drivers which previously just called the
  generic mii_phy_reset() to now actually call the PHY-specific reset
  routine, which might be crucial in some cases. While at it, the
  redundant checks in these NIC drivers for mii->mii_instance not being
  zero before calling the reset routines were removed because as soon
  as one PHY driver attaches mii->mii_instance is incremented and we
  hardly can end up in their media change callbacks etc if no PHY driver
  has attached as mii_attach() would have failed in that case and not
  attach a miibus(4) instance.
  Consequently, NIC drivers now no longer should call mii_phy_reset()
  directly, so it was removed from EXPORT_SYMS.
- Add a mii_phy_dev_attach() as a companion helper to mii_phy_dev_probe().
  The purpose of that function is to perform the common steps to attach
  a PHY driver instance and to hook it up to the miibus(4) instance and to
  optionally also handle the probing, addition and initialization of the
  supported media. So all a PHY driver without any special requirements
  has to do in its bus attach method is to call mii_phy_dev_attach()
  along with PHY-specific MIIF_* flags, a pointer to its PHY functions
  and the add_media set to one. All PHY drivers were updated to take
  advantage of mii_phy_dev_attach() as appropriate. Along with these
  changes the capability mask was added to the mii_softc structure so
  PHY drivers taking advantage of mii_phy_dev_attach() but still
  handling media on their own do not need to fiddle with the MII attach
  arguments anyway.
- Keep track of the PHY offset in the mii_softc structure. This is done
  for compatibility with NetBSD/OpenBSD.
- Keep track of the PHY's OUI, model and revision in the mii_softc
  structure. Several PHY drivers require this information also after
  attaching and previously had to wrap their own softc around mii_softc.
  NetBSD/OpenBSD also keep track of the model and revision on their
  mii_softc structure. All PHY drivers were updated to take advantage
  as appropriate.
- Convert the mebers of the MII data structure to unsigned where
  appropriate. This is partly inspired by NetBSD/OpenBSD.
- According to IEEE 802.3-2002 the bits actually have to be reversed
  when mapping an OUI to the MII ID registers. All PHY drivers and
  miidevs where changed as necessary. Actually this now again allows to
  largely share miidevs with NetBSD, which fixed this problem already
  9 years ago. Consequently miidevs was synced as far as possible.
- Add MIIF_NOMANPAUSE and mii_phy_flowstatus() calls to drivers that
  weren't explicitly converted to support flow control before. It's
  unclear whether flow control actually works with these but typically
  it should and their net behavior should be more correct with these
  changes in place than without if the MAC driver sets MIIF_DOPAUSE.

Obtained from:	NetBSD (partially)
Reviewed by:	yongari (earlier version), silence on arch@ and net@
2011-05-03 19:51:29 +00:00
Marius Strobl
d6c65d276e Converted the remainder of the NIC drivers to use the mii_attach()
introduced in r213878 instead of mii_phy_probe(). Unlike r213893 these
are only straight forward conversions though.

Reviewed by:	yongari
2010-10-15 15:00:30 +00:00
John Baldwin
47a933e3df Initialize the ifnet before calling mii_phy_probe() as some phy drivers
(e.g. e1000phy(4)) expect if_dname to be valid when they are probed.

MFC after:	3 days
2010-01-27 14:43:28 +00:00
John Baldwin
e55bc0154d - Hook into the existing stat timer to drive the transmit watchdog instead
of using if_watchdog and if_timer.
- Reorder detach to call ether_ifdetach() before anything else in tl(4)
  and wb(4).
2009-11-19 22:14:23 +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
Robert Watson
530ee5c971 Two ifnet misuse fixes for if_nve:
(1) Don't manually configure if_output(), ether_ifattach() will do that
    for us as part of link-layer setup.

(2) Call if_detach() before stopping nve in order to prevent calls into
    the device driver after the driver has started shutting down.

Reviewed by:	jhb
MFC after:	2 weeks
2009-04-23 19:29:45 +00:00
Warner Losh
85a7cf04e7 writereg returns an int. 2009-02-05 19:33:20 +00:00
Remko Lodder
1388635ca5 Import rewritten nve device id's, which brings this more
inline with if_nfe.

PR:		110883
Submitted by:	Claudel <regis at claudel dot ch>
Approved by:	imp (mentor, implicit)
MFC after:	1 week
2008-05-31 14:17:36 +00:00
Pyun YongHyeon
6a087a8722 Fix function prototype for device_shutdown method. 2007-11-22 02:45:00 +00:00
Pyun YongHyeon
1464ddfac0 Allow nfe(4) override nve(4). 2007-06-12 02:21:02 +00:00
Doug White
d9306f7610 Don't cast the command argument to ether_ioctl() to an int since its not an
int anymore. This was causing all sorts of bad behavior when booting a system
with an nve interface present.
2007-06-08 22:00:56 +00:00
Yaroslav Tykhiy
e8ae99894a Finish VLAN_MTU support in nve(4). The interface appears to be able
to handle long frames in its default mode, so setting the respective
bit in if_capenable is enough.

Tested by:	yongari
2007-05-07 09:45:31 +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
81b6f8d5df Fix an off by one error in struct nve_tx_desc's frags[] array as a result
of the nvenet lib upgrade (the constant went from 63 (2^n - 1) to
32 (2^n)).  For reasons that are not obvious to me this fixes the driver
on at least some NICs.

MFC after:	3 days
2006-12-05 15:31:05 +00:00
Max Laier
7a569b90b5 ALTQ-ify nve(4).
Submitted by:	Chris Dionissopoulos
Tested by:	Chris Dionissopoulos
MFC after:	4 weeks
2006-05-20 21:08:09 +00:00
John Baldwin
f00d84860a - When setting up a packet for transmit, if we the tx ring is over half
full, kick the binary blob to force it to complete any pending tx
  completions.
- In the watchdog routine, only reset the chip if the blob doesn't complete
  any pending tx completions rather than requiring it to complete all of
  the pending tx completions.

Submitted by:	Nathan Whitehorn <nathanw@uchicago.edu>
MFC after:	2 weeks
2006-05-18 23:19:44 +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
John Baldwin
f088002825 The nvidia binary blob sometimes defers tx completion notification to the
OS dependent layer.  Thus, the watchdog timer can go off when the tx
engine is working fine but the OS dependent layer just hasn't been called
to cleanup finished tx transactions.  To workaround this, when the watchdog
fires, poke the binary blob to force it to flush any pending tx
completions.  If this drops the pending tx count to zero then just return
without logging a message or resetting the chip.

This reportedly fixes the 'device timeout()' errors with at least several
NF4 nve(4) parts.

Submitted by:	Nathan Alexander Whitehorn <nathanw@uchicago.edu> (code)
Submitted by:	dg (inspiration for comment and explanation)
MFC after:	1 week
2006-04-28 20:08:16 +00:00
Bjoern A. Zeeb
3e4212785c Make nve(4) work for people with nf3/nf4 who never got it
working at all and only saw "nve0: device timeout (N)" messages.

- Setup PHY before handing control to NVidia API setting
  speed, duplex, enabling interrupts, etc.
- Add restriction of MAXADDR_32BIT for high address to contigmalloc
  to make the driver work on machines with 4+GB of memory.

PR:        kern/85583, kern/88045
Tested by: scottl, others earlier version
MFC after: 10 days
2005-12-12 06:23:43 +00:00
David E. O'Brien
9da0c15871 Add support for the nVidia nForce MCP12 & MCP13 Networking Adapters. 2005-12-07 17:38:03 +00:00
David E. O'Brien
6e24020ff6 Catch up to the nvenetlib 1.0-0310 import. 2005-12-07 17:36:53 +00:00
John Baldwin
7e70788a5c Remove unused local variable misssed in previous commit. 2005-12-05 22:20:23 +00:00
John Baldwin
5714e9ea59 - Don't make the driver lock recursive, it shouldn't be recursively
acquired anywhere in the driver now.
- Axe the spin mutex used for the nve_oslock*() routines.  The driver lock
  already provides sufficient synchronization.
- Don't mess around with IFF_UP when the link state changes.  IFF_UP is
  an administrative flag, not a link status indicator.

MFC after:	1 week
2005-12-05 20:49:45 +00:00
John Baldwin
aed0e2071f Overhaul nve(4) locking to make it more like other ethernet drivers in
the tree.
- Add locked variants of nve_start(), nve_init(), and nve_ifmedia_upd().
- Use callout_* to manage callouts rather than timeout(9).
- Mark interrupt handler MPSAFE (IFF_NEEDGIANT was already clear).
- Lock the driver lock in driver entry points such as the interrupt
  handler, if_start, and if_init rather than locking the driver mutex
  in the various work functions called by the binary blob.  The spin lock
  used by the binary block can probably be stubbed out now.
- Use IFQ_DRV_IS_EMPTY() macro rather than doing it by hand.
- Fix locking in detach.
- Remove some unused fields from the softc.

Tested by:	cognet
MFC after:	2 weeks
2005-11-21 22:14:49 +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
David E. O'Brien
4a55b68732 Clear pending_txs when not "RUNNING".
Submitted by:	Q <q@onthenet.com.au>
2005-10-27 15:39:19 +00:00
Warner Losh
ad4f426ef6 Make sure that we call if_free(ifp) after bus_teardown_intr. Since we
could get an interrupt after we free the ifp, and the interrupt
handler depended on the ifp being still alive, this could, in theory,
cause a crash.  Eliminate this possibility by moving the if_free to
after the bus_teardown_intr() call.
2005-09-19 03:10:21 +00:00
Ruslan Ermilov
fead0681ed Fix "struct ifnet" leak if attach() fails in the middle. 2005-09-16 12:49:06 +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
Maxime Henrion
67685686ad Remove an erroneous m_freem() call. If m_defrag() returns a non-NULL
pointer, it has already freed the original mbuf chain, so we shouldn't
do it again.

This is an MFC candidate.
2005-07-25 22:21:11 +00:00
Brooks Davis
cd036ec193 Move if_alloc() up so it's before mii_phy_probe(). 2005-06-11 01:37:46 +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
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
Christian Brueffer
162bc322c8 Fix typo in a comment. 2005-05-08 08:54:23 +00:00
David E. O'Brien
34eea30cf1 I missed a s/nv/nve/.
Submitted by:	Tai-hwa Liang <avatar@mmlab.cse.yzu.edu.tw>
2005-04-26 16:07:50 +00:00
David E. O'Brien
53b1897c62 Support MCP versions 4-11. 2005-03-24 18:55:07 +00:00
David E. O'Brien
1b1a07ad8b FreeBSD consumer bits of the nForce MCP NIC binary blob.
Demanded by:	DES
Encouraged by:	scottl
Obtained from:	q@onthenet.com.au (partially)
KNF'ed by:	obrien
2005-03-12 00:29:30 +00:00