Commit Graph

160 Commits

Author SHA1 Message Date
Robert Watson
6ad1954bcb Eliminate unnecessary checking for M_EXT on mbufs returned by m_getjcl().
Reviewed by:	bz, glebius, yongari
MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D938
2014-10-13 06:51:40 +00:00
Gleb Smirnoff
c8dfaf382f Mechanically convert to if_inc_counter(). 2014-09-19 03:51:26 +00:00
Gleb Smirnoff
1bffa9511f Use define from if_var.h to access a field inside struct if_data,
that resides in struct ifnet.

Sponsored by:	Nginx, Inc.
2014-08-30 19:55:54 +00:00
John Baldwin
068d8643ad Fix various NIC drivers to properly cleanup static DMA resources.
In particular, don't check the value of the bus_dma map against NULL
to determine if either bus_dmamem_alloc() or bus_dmamap_load() succeeded.
Instead, assume that bus_dmamap_load() succeeeded (and thus that
bus_dmamap_unload() should be called) if the bus address for a resource
is non-zero, and assume that bus_dmamem_alloc() succeeded (and thus
that bus_dmamem_free() should be called) if the virtual address for a
resource is not NULL.

In many cases these bugs could result in leaks when a driver was detached.

Reviewed by:	yongari
MFC after:	2 weeks
2014-06-11 14:53:58 +00:00
Christian Brueffer
73aa8b9a75 Remove some unused variables.
Found with:	Clang Static Analyzer
MFC after:	2 weeks
2014-05-16 21:19:17 +00:00
Dimitry Andric
5ddae1557d Remove superfluous old-style rcsid[] from if_sk.c. There is already an
__FBSDID() at the top of the file.

MFC after:	3 days
2013-12-28 21:04:17 +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
Marius Strobl
2dc26832f7 - Merge from r249476: Ensure that PCI bus BUS_GET_DMA_TAG() method sees
the actual PCI device which makes the request for DMA tag, instead of
  some descendant of the PCI device, by creating a pass-through trampoline.
- Sprinkle const on tables.
- Use NULL instead of 0 for pointers.
- Take advantage of nitems().

MFC after:	1 week
2013-05-30 12:16:55 +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
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
Marius Strobl
f8cb22fa6c Allocate the DMA memory shared between the host and the controller as
coherent.

MFC after:	2 weeks
2011-03-11 22:21:12 +00:00
Pyun YongHyeon
fec5229ac0 Fix a long standing bug in programming station address for Yukon
controllers. sk(4) never reprogrammed station address for Yukon
controllers so overriding station address with ifconfig(8) was not
possible.
Fix the bug by reprogramming all registers that control station
address, flow-control and virtual station address. Virtual station
address has no use at this moment since driver does not make use of
fail over feature.

Tested by:	"Mikhail T." <mi+thun <> aldan.algebra.com>
MFC after:	1 week
2010-11-06 22:07:22 +00:00
Pyun YongHyeon
adfe075ce0 If we got an invalid station address, generate random address. This
might be caused by broken BIOS.

Reported by:	"Mikhail T." <mi+thun <> aldan.algebra.com>
MFC after:	1 week
2010-11-06 21:54:32 +00:00
Marius Strobl
8e5d93dbb4 Convert the PHY drivers to honor the mii_flags passed down and convert
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
2010-10-15 14:52:11 +00:00
Pyun YongHyeon
2610dbf59b Some revision of Yukon controller generates corrupted frame when TX
checksum offloading is enabled.  The frame has a valid checksum
value so payload might be modified during TX checksum calculation.
Disable TX checksum offloading but give users chance to enable it
when they know their controller works without problems with TX
checksum offloading.

Reported by:	Andrzej Tobola <ato <> iem dot pw dot edu dot pl>
2010-07-09 21:21:08 +00:00
John Baldwin
e1b17582f4 Take a step towards removing if_watchdog/if_timer. Don't explicitly set
if_watchdog/if_timer to NULL/0 when initializing an ifnet.  if_alloc()
sets those members to NULL/0 already.
2009-11-06 14:55:01 +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
Pyun YongHyeon
59dffaa088 Separate multicast filtering of SysKonnect GENESIS and Marvell
Yukon from common multicast handling code. Yukon uses hash-based
multicast filtering(big endian form) but GENESIS uses perfect
multicast filtering as well as hash-based one(little endian form).
Due to the differences of multicast filtering there is no much
sense to have a common code.
 o Remove sk_setmulti() and introduce sk_rxfilter_yukon(),
   sk_rxfilter_yukon() that handles multicast filtering setup.
 o Have sk_rxfilter_{yukon, genesis} handle promiscuous mode and
   nuke sk_setpromisc(). This simplifies ioctl handler as well as
   giving a chance to check validity of Rx control register of
   Yukon.
 o Don't reinitialize controller when IFF_ALLMULTI flags is changed.
 o Nuke sk_gmchash(), it's not needed anymore.
 o Always reconfigure Rx control register whenever a new multicast
   filtering condition is changed. This fixes multicast filtering
   setup on Yukon.

PR:	kern/134051
2009-05-01 03:24:03 +00:00
Pyun YongHyeon
9fb59f5567 Prefer NULL over integer 0 for pointer type. 2008-02-14 01:25:01 +00:00
Pyun YongHyeon
cdca0fe8be Nuke local jumbo allocator and switch to use of UMA backed page
allocator for jumbo frame.
 o Removed unneeded jlist lock which was used to manage jumbo
   buffers.
 o Don't reinitialize hardware if MTU was not changed.
 o Added additional check for minimal MTU size.
 o Added a new tunable hw.skc.jumbo_disable to disable jumbo frame
   support for the driver. The tunable could be set for systems that
   do not need to use jumbo frames and it would save
   (9K * number of Rx descriptors) bytes kernel memory.
 o Jumbo buffer allocation failure is no longer critical error for
   the operation of sk(4). If sk(4) encounter the allocation failure
   it just disables jumbo frame support and continues to work without
   user intervention.

With these changes jumbo frame performance of sk(4) was slightly
increased and users should not encounter jumbo buffer allocation
failure. Previously sk(4) tried to allocate physically contiguous
memory, 3388KB for 256 Rx descriptors. Sometimes that amount of
contiguous memory region could not be available for running systems
which in turn resulted in failure of loading the driver.

Tested by:	Cy Schubert < Cy.Schubert () komquats dot com >
2008-02-14 01:10:48 +00:00
Poul-Henning Kamp
cf827063a9 Give MEXTADD() another argument to make both void pointers to the
free function controlable, instead of passing the KVA of the buffer
storage as the first argument.

Fix all conventional users of the API to pass the KVA of the buffer
as the first argument, to make this a no-op commit.

Likely break the only non-convetional user of the API, after informing
the relevant committer.

Update the mbuf(9) manual page, which was already out of sync on
this point.

Bump __FreeBSD_version to 800016 as there is no way to tell how
many arguments a CPP macro needs any other way.

This paves the way for giving sendfile(9) a way to wait for the
passed storage to have been accessed before returning.

This does not affect the memory layout or size of mbufs.

Parental oversight by:	sam and rwatson.

No MFC is anticipated.
2008-02-01 19:36:27 +00:00
Pyun YongHyeon
6a087a8722 Fix function prototype for device_shutdown method. 2007-11-22 02:45:00 +00:00
Robert Watson
e1e8f51b85 Universally adopt most conventional spelling of acquire. 2007-05-27 20:50:23 +00:00
Stephen McKay
5bdc94fa35 Make a missing or empty VPD non-fatal, as it was prior to rev 1.131.
With this change, my D-Link DGE-530T rev A1 is operational again.
2007-05-10 13:10:34 +00:00
Pyun YongHyeon
75a1d5a086 Use our own timer for watchdog instead of if_watchdog/if_timer
interface.
2007-04-02 04:43:41 +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
Marius Strobl
c2175ff5ca Change the remainder of the drivers for DMA'ing devices enabled in the
sparc64 GENERIC and the sound device drivers known working on sparc64
to use bus_get_dma_tag() to obtain the parent DMA tag so we can get rid
of the sparc64_root_dma_tag kludge eventually. Except for ath(4), sk(4),
stge(4) and ti(4) these changes are runtime tested (unless I booted up
the wrong kernels again...).
2007-01-21 19:32:51 +00:00
Pyun YongHyeon
e16d3854ae Remove incomplete Yukon II support code which was added in if_sk.c, rev 1.123.
Yukon II users should use msk(4).
2006-12-14 04:10:26 +00:00
John-Mark Gurney
667dc26e71 provide routines to access VPD data at the PCI layer...
remove sk's own implementation, and use the new calls to get the data...

Reviewed by:	-arch
2006-10-09 16:15:56 +00:00
Pyun YongHyeon
ff9c95a4d0 Fix invalid reference of mbuf chains.
Use proper pointer dereference to inform modified mbuf chains to
caller.

In collaboration with:	glebius
2006-08-12 01:24:37 +00:00
Pyun YongHyeon
3b234fcbab Fix incorrect busy check for PHY write operation.
While I'm here remove unnecessary return statement.
2006-08-02 02:36:59 +00:00
Pyun YongHyeon
7b4e72633e Add device ID for second generation D-Link DGE-530T.
PR:	kern/99903
2006-07-27 05:06:43 +00:00
Pyun YongHyeon
4425fc9453 Convert sk(4) to use the new bus_alloc_resources() API and
bus_{read,write}_* macros.

Submitted by:	Antoine Brodin <antoine.brodin AT laposte DOT net>
Reviewed by:	imp (initial version)
2006-07-19 04:12:59 +00:00
Pyun YongHyeon
a1e4f25700 Fix typo in comment.
Submitted by:	brad AT OpenBSD DOT org
2006-07-05 04:56:50 +00:00
Pyun YongHyeon
ad25ff2b43 Fix watchdog timeout errors seen on a few systems.
SK-NET GENESIS document says reading SK_ISSR should stop generating
further interrupts(Since we drop a driver lock before invoking
ifp->if_input handler we should disable interrupts in ISR in order
to protect integrity of softc from subsequent interrupts). But it
seems that there is possibility of loosing interrupts between
reading SK_ISSR and determining which interrupts are reported.
To cope with the situation we continuously read SK_ISSR register
until there are no interrupts. However, it seems that the above
work around doesn't fix all cases. To protect watchdog handler
from triggering false alarm add a work around code which try to
reclaim pending Tx descriptors before resetting hardware. This
should fix occasional watchdog timeout errors seen on this driver.

Reported by:	Frank Behrens <frank AT pinky dot sax dot de >
Tested by:	Frank Behrens <frank AT pinky dot sax dot de >
2006-06-07 09:05:20 +00:00
Pyun YongHyeon
fde45b415e Re-wrok PHY setup, media handling and dual-port detection.
With this change SysKonnect SK-9521 v2.0 and SK-9821 v2.0
adapter now works.

Obtained from:	OpenBSD
Reported by:	Ganbold ganbold ! micom ( mng $ net
Tested by:	Ganbold ganbold ! micom ( mng $ net
2006-05-15 04:50:33 +00:00
Maxim Sobolev
6cd0bab5d5 Don't attach to Marvell 88E805X (Yukon-II) by default, the driver is not
functional yet.

Requested by:	bz
2006-05-01 05:16:36 +00:00
Maxim Sobolev
8dcfaef0a0 Add some incomplete support for Marvell Yukon EC controllers based on
OpenBSD changes. With these changes, PHY part of the driver becomes
functional (it senses media changes and negotiates speed just fine),
previously it just hang with no PHY message, but no data goes through
interface (error message is "can not stop transfer of Tx/Rx descriptor).

Hopefully somebody with more clue/free time will be able to pick up
after me.
2006-04-28 03:17:37 +00:00
Pyun YongHyeon
919133a8ef Bring busdmafied sk(4) to all architectures.
- MPSAFE. No more recursive lock required.
- bus_dma(9) conversion. I think it should work on all architectures.
- optimized Rx handler for each normal and jumbo frames. Previously
  sk(4) used jumbo frame management code to handle normal sized
  frames. As the handler needs an additional lock to protect jumbo
  frame management structure from races, it used two lock operations
  for each received packet. Now sk(4) uses single lock operation for
  normal frame.(Jumbo frame still needs two lock operations as before.)
  The hardware supports DMA scatter operations for Rx descriptors such
  that it's possible to take advantagee of m_cljget(9) for jumbo frames.
  However, due to a unknown reasons it resulted in poor performance on
  sparc64. So I dropped m_cljget(9) approach. This should be revisited
  since it would reduce one lock operation for jumbo frame handling.
- Tx TCP/Rx IP checksum offload support. According to the data sheet
  of SK-NET GENESIS the hardware supports Rx IP/TCP/UDP offload.
  But I couldn't make it work on my Yukon hardware. So Rx TCP/UDP was
  disabled at the moment. It seems that newer Yukon chips can support
  Tx UDP checksum offload too. But I need more documentation first.
- Added more wait time in reading VPD data. It seems that ASUS LOM
  takes a very long time to respond VPD read signal.
- Added an additional lock for MII register access callbacks.
- Added more strict received packet validation routine. Previously it
  passed corrupted packets to upper layers under certain conditions.
- A new function sk_yukon_tick() to handle auto-negotiation properly.
- Interrupt handler now checks shared interrupt source and protects
  the interrupt handler from NULL pointer dereference which was caused
  by odd status word value. The status word can returns 0xffffffff if
  cable is unplugged while Rx/Tx/auto-negotiation is in progress.
- suspend/resume support(not tested).
- Added Rx/Tx FIFO flush routine for Yukon
- Activate Tx descriptor poll timer in order to protect possible loss
  of SK_TXBMU_TX_START command. Previously the driver continuously issued
  SK_TXBMU_TX_START when it notices pending Tx descriptors not processed
  yet in interrupt handler. That approach would add additional PCI
  write access overhead under high Tx load situations and it might fail
  if the first SK_TXBMU_TX_START was lost and no interrupt is generated
  from the first SK_TXBMU_TX_START command.
- s/printf/if_printf/, s/printf/device_printf/, Axe sk_unit in softc.
- Setting multicast/station address is now safe on strict-alignment
  architectures.
- Fix long standing bug in VLAN header length setup.
- Added/corrected register definitions for Yukon.
  (Register information from Linux skge driver.)
- Added Rx status definition for Marvell Yukon/XaQti XMAC.
  (Rx status register information from Linux skge driver.)
- Update if_oerrors if we encounter watchdog error.
- callout(9) conversion

Special thanks to jkim who let me know RX status differences between
Yukon and XaQti XMAC.
It seems that there is still occasional watchdog timeout error but I
couldn't reproduce it and need more information to analyze it from
users.

Tested by:	bz(amd64), me(i386, sparc64), current ML
		Frank Behrens frank ! pinky ( sax $ de
2006-04-27 05:59:09 +00:00
Pyun YongHyeon
b16affc0ac Correct DRIVER_MODULE declaration.
skc does attach to pci bus instead of sk.

Submitted by:	jmg
2006-04-27 04:39:58 +00:00
Pyun YongHyeon
288292463f The sk(4) driver has moved to /sys/dev/sk 2006-04-27 00:14:02 +00:00
Gleb Smirnoff
23033eebf4 Do not touch ifp->if_baudrate in miibus aware drivers. 2006-02-14 12:44:56 +00:00
Pyun YongHyeon
c57c874824 fix interrupt moderation timer frequencies for Yukon
Obtained from:	OpenBSD
2006-01-17 05:57:44 +00:00
Pyun YongHyeon
878793bc2f remove trailing spaces 2006-01-17 05:41:20 +00:00
Bjoern A. Zeeb
2166476ae9 Remove unused code.
Found with:	Coverity Prevent(tm)
2006-01-15 01:39:01 +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
John Baldwin
26390635de Only allow the sk(4) driver to attach to revision 2 of the LinkSys EG1032
cards and teach the re(4) driver to attach to revision 3 cards.

Submitted by:	Fredrik Lindberg fli+freebsd-current at shapeshifter dot se
MFC after:	2 weeks
Reviewed by:	imp, mdodd
2005-10-14 18:51:30 +00:00
Yaroslav Tykhiy
45c11f832a Mark sk(4) as capable of handling extended VLAN frames. NICs
based on XMAC II chip should be ready for this in their initial
mode of operation, and Yukon-based NICs are configured so by
the driver.

PR:		kern/79998
MFC after:	1 month
2005-10-11 22:55:16 +00:00