Commit Graph

368 Commits

Author SHA1 Message Date
Pyun YongHyeon
8da9c50775 Export hardware MAC statistics through sysctl node. Previously
fxp(4) already used to extract most hardware MAC statistics but it
didn't show them. With this change, all MAC statistics counters
are exported. Because there are a couple of new counters for 82558
and 82559, enable extended MAC statistics functionality to get
these counters. Accoring to public data sheet, 82559 MAC statistics
return 24 DWORD counters(3 counters are unknown at this moment) so
increase MAC counter structure to meet the MAC statistics block size.
The completion of MAC counter dump is now checked against
FXP_STATS_DR_COMPLETE status code which is appended at the end of
status block. Previously fxp(4) ignored the status of the
FXP_SCB_COMMAND_CU_DUMPRESET command. fxp(4) does not wait for the
completion of pending command before issuing
FXP_SCB_COMMAND_CU_DUMPRESET. Instead it skips the command and try
it next time. This scheme may show better performance but there is
chance to loose updated counters after stopping controller. So make
sure to update MAC statistics in fxp_stop().
While I'm here move sysctl node creation to fxp_sysctl_node().

Tested by:	Larry Baird < lab <> gta dot com >
2010-05-09 22:16:15 +00:00
Pyun YongHyeon
7251782989 8255x configure command requires number of bytes of configuration
table. The default size of the configuration table was 22 bytes. To
use extended feature of 82550/82551 the configuration table size
was expanded to 32 bytes. The added configuration for 82550/82551
specifies VLAN hardware tagging and IPSec configuration as well as
TCO.
To make configuration easier fxp(4) used a configuration template
and the template was copied to configuration table. After that,
some parameters of the configuration table was changed depending on
controller type and operation mode. However the size of template
was 22 bytes so some configuration parameters were not properly
initialized on 82550/82551.
Fix this by increasing the template size. For 82557, 82558 and
82559 the size of the configuration is still 22 bytes.
2010-05-07 18:03:35 +00:00
Pyun YongHyeon
a026a25b1d It seems controller has two types of promiscuous control, one for
unicast and the other for multicast. To receive multicast frames
that host didn't join in promiscuous mode, driver have to set
promiscuous mode for multicast frames as well.
The Open Source Software Developer Manual for i8255x was not clear
how to handle promiscuous mode.

PR:		kern/145905
MFC after:	5 days
2010-05-07 16:43:00 +00:00
Pyun YongHyeon
6da6d0a9e3 With r206844, CSUM_TCP is also set for CSUM_TSO case. Modify
drivers to take into account for the change. Basically CSUM_TSO
should be checked before checking CSUM_TCP.
2010-04-19 22:10:40 +00:00
Pyun YongHyeon
829b278e5e It seems some 82559ER controllers do not support Rx checksum
offloading. Datasheet said nothing about the limitation of 82559ER
except WOL. Explicitly disable Rx checksum offloading for
controllers that is known to lack the capability.

PR:	kern/138135
Tested by:	Gooderum, Mark < mgooderum <> websense dot com >
2009-09-28 19:40:16 +00:00
Poul-Henning Kamp
6778431478 Revert previous commit and add myself to the list of people who should
know better than to commit with a cat in the area.
2009-09-08 13:19:05 +00:00
Poul-Henning Kamp
b34421bf9c Add necessary include. 2009-09-08 13:16:55 +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
b96ad4b205 For ICH based fxp(4) controllers treat them as 82559 compatibles.
To detect which controller is ICH based one, add a new member
variable ich to struct fxp_ident and move the struct to
if_fxpvar.h. Since I've faked controller revision, don't allow
microcode loading for ICH based controllers.
With this change all ICH based controllers will have WOL and Rx
checksum offload capability.

PR:		kern/135451
Tested by:	Alexey Shuvaev ( shuvaev <> physik dot uni-wuerzburg dot de ),
		pluknet ( pluknet <> gmail dot com ),
		Gary Jennejohn ( gary.jennejohn <> freenet dot de )
2009-06-21 07:34:12 +00:00
Pyun YongHyeon
6b24912cd9 Overhaul fxp(4) multicast filter programming. fxp(4) hardwares do
not allow multicast filter programming when controller is busy to
send/receive frames. So it used to mark need_mcsetup bit and defer
multicast filter programming until controller becomes idle state.
To detect when the controller is idle fxp(4) relied on Tx
completion interrupt with NOP command and fxp_start_body and
fxp_intr_body had to see whether pending multicast filter
programming was requested. This resulted in very complex logic and
sometimes it did not work as expected.
Since the controller should be in idle state before any multicast
filter modifications I changed it to reinitialize the controller
whenever multicast filter programming is required. This is the same
way what OpenBSD and NetBSD does. Also I added IFF_DRV_RUNNING
check in ioctl handler so controller would be reinitialized only if
it is absolutely needed.
With this change I guess we can remove fxp(4) DELAY hack in ifioctl
for IPv6 case.
2009-06-21 07:17:49 +00:00
Pyun YongHyeon
c109e385f6 Always check fxp(4) is running, see if it can accept frames from
upper stack in fxp_start_body().
fxp(4) drops driver lock in Rx path so check the fxp(4) is still
running after reacquiring driver lock in Rx path. Also don't
invoke fxp_intr_body if fxp(4) is not running. With this change
there is no need to set suspend bit in device attach phase.
2009-06-21 06:46:32 +00:00
Pyun YongHyeon
43d8b117e4 Don't blindly enable Rx lock-up workaround. Newer chips do not need
the Rx lock-up workaround.

Obtained from:	NetBSD
2009-06-21 06:27:35 +00:00
Pyun YongHyeon
a996f02399 Due to possible PCI bus lock-up issues fxp(4) didn't perform full
hardware reset in attach phase. Selective reset does not clear
configured parameters so I think full hardware reset is required.
To prevent PCI bus lock-up, do selective reset first which will get
off the controller from PCI bus and request software reset after
selective reset. Software reset will unmask interrupts so disable
it after the reset.
2009-06-21 06:18:19 +00:00
Pyun YongHyeon
a2057a72e9 Introduce Rx mbuf dma tag and use it in Rx path. Previously it used
common mbuf dma tag for both Tx and Rx path but Rx buffer should
have single DMA segment and maximum buffer size of the segment
should be less than MCLBYTES.
fxp(4) also have to check Tx completion status which was updated by
DMA so we need BUS_DMASYNC_PREREAD and BUS_DMASYNC_POSTWRITE
synchronization in Tx path. Fix all misuse of bus_dmamap_sync(9) in
fxp(4). I guess this change shall fix occasional driver breakage in
PAE environments.

While I'm here add error messages of dma tag/buffer creation and
correct messages.
2009-06-21 06:06:43 +00:00
Pyun YongHyeon
5986d0d274 Controller will dma SCB command status for a given command and
driver should read updated status back after issuing a SCB command.
To send a command to controller and read updated status back,
driver should synchronize both memory read and write operations
with device. Fix bus_dmamap_sync operation specifier used in
fxp_dma_wait() by adding both memory read and memory write
operations.
2009-06-10 01:15:30 +00:00
Attilio Rao
1abcdbd127 When user_frac in the polling subsystem is low it is going to busy the
CPU for too long period than necessary.  Additively, interfaces are kept
polled (in the tick) even if no more packets are available.
In order to avoid such situations a new generic mechanism can be
implemented in proactive way, keeping track of the time spent on any
packet and fragmenting the time for any tick, stopping the processing
as soon as possible.

In order to implement such mechanism, the polling handler needs to
change, returning the number of packets processed.
While the intended logic is not part of this patch, the polling KPI is
broken by this commit, adding an int return value and the new flag
IFCAP_POLLING_NOCOUNT (which will signal that the return value is
meaningless for the installed handler and checking should be skipped).

Bump __FreeBSD_version in order to signal such situation.

Reviewed by:	emaste
Sponsored by:	Sandvine Incorporated
2009-05-30 15:14:44 +00:00
Pyun YongHyeon
0685c824ca Don't blindly set IP packet length from interface MTU in TSO case.
Remote host can advertise smaller MSS than that of sender so upper
stack might have adjusted the MSS which in turn generates IP
packets that are less size than that of interface MTU.

Reported by:	Bjoern Koenig ( bkoenig <> alpha-tierchen dot de )
Tested by:	Bjoern Koenig ( bkoenig <> alpha-tierchen dot de )
MFC after:	3 days
2009-04-13 00:32:34 +00:00
Warner Losh
155a83e87a remove now-redunant cardbus attachment. 2009-03-09 13:23:54 +00:00
Warner Losh
16ec4b00e6 writereg returns an int. 2009-02-05 19:33:35 +00:00
Pyun YongHyeon
e2157cf706 Always check whether dma map is valid before unloading the map.
When fxp(4) intializes Rx buffers for the first time, there is no
loaded dma map so attempting to unload it is an invalid operation.
2009-01-08 04:26:44 +00:00
Pyun YongHyeon
68f4ab9aa3 It seems that we don't need to reserve a TBD to set total TCP
payload length in TSO case. Leaving unused TBD also seem to cause
SCB timeouts under certain conditions when TSO/non-TSO traffics
are active at the same time.
2008-12-18 01:36:46 +00:00
Pyun YongHyeon
6d7e1582a3 mutex.h is needed here. It got it by namespace pollution.
Pointed out by:	bde
2008-12-08 03:48:03 +00:00
Pyun YongHyeon
bd4fa9d9e7 Add VLAN hardware tag insertion/stripping support. Tx/Rx checksum
offload for VLAN frames are also supported. The VLAN hardware
assistance is available only on 82550/82551 based controllers.
While I'm here change the confusing name of bit1 in byte 22 of
configuration block to vlan_drop_en. The bit controls whether
hardware strips VLAN tagged frame or not. Special thanks to wpaul
who sent valuable VLAN related information to me.

Tested on:	i386, sparc64
2008-12-02 02:30:12 +00:00
Pyun YongHyeon
af75b654d2 Make sure to clear PMDR register by writing back power management
events. Just reading PMDR register was not enough to have fxp(4)
immuninize against received magic packets during system boot.

Tested by:	Alexey Shuvaev < shuvaev <> physik DOT uni-wuerzburg DOT de >
2008-12-02 02:12:34 +00:00
Pyun YongHyeon
7137cea0c7 Add basic WOL support for 82550/82551/82558 and 82559 based
controllers. ICH based controllers are treated as 82559. 82557,
earlier revision of 82558 and 82559ER have no WOL capability.
 o WOL support requires help of a firmware so add check whether
   hardware is capable of handling magic frames by reading EEPROM.
 o Enable accepting WOL frames only when hardware is about to
   suspend or shutdown. Previously fxp(4) used to allow receipt of
   magic frame under normal operation mode which could cause
   hardware hang if magic frame is received by hardware. Datasheet
   clearly states driver should not allow WOL frames under normal
   operation mode.
 o Disable WOL frame reception in device attach so have fxp(4)
   immunize against system hang which can be triggered by magic
   packets when the hardware is not in fully initialized state.
 o Don't reset all hardware configuration data in fxp_stop()
   otherwise important configuration data is lost and this would
   reset WOL configuration to default state which in turn cause
   hardware hang on receipt of magic frames. To fix the issue,
   preserve hardware configuration data by issuing a selective
   reset.
 o Explicitly disable interrupts after issuing selective reset as
   reset may unmask interrupts.

Tested by:	Alexey Shuvaev < shuvaev <> physik DOT uni-wuerzburg DOT de >
2008-11-27 01:57:23 +00:00
Pyun YongHyeon
c21e84e4db Implement TSO for 82550/82551 controllers.
o Configure controller to use dynamic TBD as TSO requires that
   operation mode.
 o Add a dummy TBD to tx_cb_u as TSO can access one more TBD in TSO
   operation.
 o Increase a DMA segment size to 4096 to hold a full IP segment
   with link layer header.
 o Unlike other TSO capable controllers, 82550/82551 does not
   modify the first IP packet in TSO operation so driver should
   create an IP packet with proper header. Subsequent IP packets
   are generated from the header information in the first IP packet
   header. Likewise pseudo checksum also should be computed by
   driver for the first packet.
 o TSO requires one more TBD to hold total TCP payload. To make
   code simple for TSO/non-TSO case, increase the index of the
   first available TBD array.
 o Remove KASSERT that checks the size of a DMA segment should be
   less than or equal to MCLBYTES as it's no longer valid in TSO.
 o Tx threshold and number of TBDs field is used to store MSS in
   TSO. So don't set the Tx threshold in TSO case.
2008-11-26 07:36:17 +00:00
Pyun YongHyeon
f13075af2d Implement Rx checksum offload for 82559 or later controllers.
82559 or later controllers added simple checksum calculation logic
in RU. For backward compatibility the computed checksum is appended
at the end of the data posted to Rx buffer. This type of simple
checksum calculation support had been used on several vendors such
as Sun HME/GEM, SysKonnect GENESIS and Marvell Yukon controllers.
Because this type of checksum offload support requires parsing of
received frame and pseudo checksum calculation with software
routine it still consumes more CPU cycles than that of full-fledged
checksum offload controller. But it's still better than software
checksum calculation.
2008-11-26 06:36:53 +00:00
Pyun YongHyeon
8505042178 o Introduce a new function, fxp_new_rfabuf which allocates a new
Rx buffer and loads DMA map. Also add a function
   fxp_discard_rfabuf that handles reusing Rx buffer/DMA map. With
   this change fxp_add_rfabuf just handles appending a new RFA to
   existing chain.
 o Initialize mbuf length in fxp_new_rfabuf.
 o Don't reset rnr and have fxp(4) handle received frames even if
   it couldn't allocate new Rx buffer. This will make fxp(4) reload
   updated RFA under rnr case. The rnr would still be reset to 0 if
   polling is active and fxp(4) processed number of allowed Rx
   events.
 o Update if_iqdrops if fxp(4) couldn't allocate Rx buffer.

Previously fxp(4) used to try to reuse Rx buffer when new buffer
allocation is failed. But fxp(4) didn't take into account loaded
DMA map such that the same DMA map was loaded again without
unloading the map. There is no reason to unload the loaded map and
reload the same map again, just reusing the map is enough. I
believe the spare DMA map in softc was introduced to implement this
behaviour. Also fxp(4) used to stop Rx processing if once Rx buffer
allocation or DMA map load fails which in turn resulted in losing
incoming frames under heavy network load. With this change fxp(4)
should survive from resource shortage condition.
2008-11-26 05:51:49 +00:00
Pyun YongHyeon
c583cc04ef Simplify Tx checksum offload configuration. Also clear CSUM_IP if
we've computed IP checksum with software method.
2008-11-25 04:33:02 +00:00
Pyun YongHyeon
4e53f83744 - Allow fxp_encap() enqueue failed transmissions and set
IFF_DRV_OACTIVE to note resource shortage to upper stack.
- Don't count number of mbuf chains. Default 32 DMA segments for a
  frame is enough for most cases. If bus_dmamap_mbuf_sg fails use
  m_collapse(9) to collapse the mbuf chain instead of relying on
  expensive m_defrag(9).
- Move bpf handling to fxp_start_body() which is supposed to be
  more appropriate place.
- Always arm watchdog timer whenever a new Tx request is made.
  Previously fxp(4) used to arm watchdog timer only when
  FXP_CXINT_THRESH-th Tx request is made. Because fxp(4) does not
  rely on Tx interrupt to reclaim transmitted mbufs it's better to
  arm watchdog timer to detect potential lockups.
- Add more aggresive Tx buffer reclaiming in fxp_start_body to make
  room for new Tx requests. Since fxp(4) does not request Tx
  completion interrupt for every frames it's necessary to clean
  TXCBs in advance to saturate link.
- Make fxp(4) try to start more packets transmitting regardless of
  interrupt type in fxp_intr_body.
2008-11-25 04:16:16 +00:00
Pyun YongHyeon
2593534403 Move unarming watchdog timer and pending multicast configuration
check to fxp_txeof(). While I'm here unarm watchdog timer only if
there are no pending queued Tx requests.
Previously the watchdog timer was unarmed whenever Tx interrupt is
raised. This could be resulted in hiding root cause of watchdog
timeouts.
2008-11-25 02:05:01 +00:00
Pyun YongHyeon
60bb79ebaa Fix Tx/Rx checksum offload ioctl handling and make Rx handler honor
checksum offload configuration. Now checksum offload can be
controlled by ifconfig(8).
While I'm here add an additional check for interface capabilities
before applying user's request.
2008-11-25 01:33:16 +00:00
Pyun YongHyeon
b23d6be952 Make fxp(4) build with FXP_IP_CSUM_WAR. 2008-11-25 01:01:48 +00:00
Pyun YongHyeon
8fae3bd4f1 Sort head files and removed ununsed header file. 2008-11-25 00:59:11 +00:00
Pyun YongHyeon
f56e7f7490 Whitespace fix. 2008-11-25 00:48:05 +00:00
Qing Li
c7a0fc800c Reuse the mbuf that was just retrieved from the receive ring if mbuf
exhaustion is encountered. There was a fix made previously for this
problem but the solution (breaking out of the receive loop) does not
seem to work. mbuf reuse strategy is already adopted by other drivers
such as if_bge.  The problem was recreated and the patch is also
verified in the same test environment.
2008-03-22 18:13:39 +00:00
Kevin Lo
f1928b0cc9 Remove the volatile qualifier to apply to fxp_miibus_readreg(). 2007-05-30 03:46:04 +00:00
Remko Lodder
847f53100a Add support for the 82562GX chip within if_fxp.
PR:		110251
Submitted by:	Vyacheslav Vovk
Approved by:	imp (mentor)
MFC After:	3 days
2007-03-28 18:10:50 +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
Ruslan Ermilov
16f1e614d9 Grammar nit. 2006-12-01 13:07:52 +00:00
Gleb Smirnoff
df79d5278f - Instead of if_watchdog/if_timer interface use our own timer
that piggybacks on fxp_tick() callout.
2006-11-30 14:58:01 +00:00
Rink Springer
597d4fe47d Added yet another extra fxp(4) PCI ID.
PR:		kern/104896
Submitted by:	Yoshihiko Sarumaru <mistral@imasy.or.jp>
Reviewed by:	imp (mentor), jfv
Approved by:	imp (mentor)
MFC after:	3 days
2006-11-14 18:54:31 +00:00
Rink Springer
42a4336a90 Added PCI ID's for:
- 0x1065: Intel 82562ET/EZ/GT/GZ PRO/100 VE Ethernet [1], as found on
  Tyan GS14 barebones.
- 0x1094: Intel Pro/100 946GZ (ICH7) Network Connection [2], as found on
  Intel 946GZis motherboards.

[1] Submitted by:	myself
[2] Submitted by:	Mike Tancsa <mike@sentex.net>
Reviewed by:		imp (mentor), jfv
Approved by:		imp (mentor)
MFC after:		3 days
2006-11-06 12:19:43 +00:00
John-Mark Gurney
5aa0cdf46d fix fxp so that it will reset the link when you change the speed... This
will fix a problem where you boot w/ the default of autoselect, but then
set the speed to 100/full, the switch will keep the autoselect/100/full
negotiation...  This will continue to work till someone resets the switch
or unplugs the cable resulting in the switch failing to autoneg and falling
back to 100/half, causing a hard to track down duplex mismatch..

Submitted by:	nCircle Network Security, Inc.
MFC after:	1 week
2006-10-06 20:53:01 +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
Matteo Riondato
1fe5a490ab Whitespace fix
Pointed out by: Nate Lawson
2006-04-14 17:26:04 +00:00
Matteo Riondato
c943ffcc29 Add device ID for Intel Pro/100 VE Network Connection card
PR:		kern/95729
Submitted by:	Nicky Bulthuis
MFC after:	1 day
2006-04-14 07:49:52 +00:00
Gleb Smirnoff
23033eebf4 Do not touch ifp->if_baudrate in miibus aware drivers. 2006-02-14 12:44:56 +00:00
Warner Losh
2b6fb51f02 Check for 10BaseT media correctly. Before we were confusing
ifm_status and ifm_active.  IFM_10_T gets set in the ifm_active field,
not in the ifm_status field, as far as I can tell.

Note: this was to enable a workaround that's rarely enabled.  I don't know
how to corrupt my eeprom to test it, and would rather not know...
2006-01-04 23:00:01 +00:00
Maxime Henrion
52dfd9cdad Add the device ID of fxp(4) NICs found in Sony Vaio VGN-TX1XP laptops.
PR:		kern/90024
Submitted by:	Thomas Hurst <tom@hur.st>
MFC after:	3 days
2005-12-12 14:30:13 +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
Ruslan Ermilov
f5071cacb1 Catch up with IFP2ENADDR() type change (array -> pointer). 2005-11-11 12:17:31 +00:00
Gleb Smirnoff
f0796cd26c - Don't pollute opt_global.h with DEVICE_POLLING and introduce
opt_device_polling.h
- Include opt_device_polling.h into appropriate files.
- Embrace with HAVE_KERNEL_OPTION_HEADERS the include in the files that
  can be compiled as loadable modules.

Reviewed by:	bde
2005-10-05 10:09:17 +00:00
Gleb Smirnoff
4092996774 Big polling(4) cleanup.
o Axe poll in trap.

o Axe IFF_POLLING flag from if_flags.

o Rework revision 1.21 (Giant removal), in such a way that
  poll_mtx is not dropped during call to polling handler.
  This fixes problem with idle polling.

o Make registration and deregistration from polling in a
  functional way, insted of next tick/interrupt.

o Obsolete kern.polling.enable. Polling is turned on/off
  with ifconfig.

Detailed kern_poll.c changes:
  - Remove polling handler flags, introduced in 1.21. The are not
    needed now.
  - Forget and do not check if_flags, if_capenable and if_drv_flags.
  - Call all registered polling handlers unconditionally.
  - Do not drop poll_mtx, when entering polling handlers.
  - In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
  - In netisr_poll() axe the block, where polling code asks drivers
    to unregister.
  - In netisr_poll() and ether_poll() do polling always, if any
    handlers are present.
  - In ether_poll_[de]register() remove a lot of error hiding code. Assert
    that arguments are correct, instead.
  - In ether_poll_[de]register() use standard return values in case of
    error or success.
  - Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
    poll_switch() goes through interface list and enabled/disables polling.
    A message that kern.polling.enable is deprecated is printed.

Detailed driver changes:
  - On attach driver announces IFCAP_POLLING in if_capabilities, but
    not in if_capenable.
  - On detach driver calls ether_poll_deregister() if polling is enabled.
  - In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
    flag. If there is no, then unlocks and returns.
  - In ioctl handler driver checks for IFCAP_POLLING flag requested to
    be set or cleared. Driver first calls ether_poll_[de]register(), then
    obtains driver lock and [dis/en]ables interrupts.
  - In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
    If present, then returns.This is important to protect from spurious
    interrupts.

Reviewed by:	ru, sam, jhb
2005-10-01 18:56:19 +00:00
Maxime Henrion
05bd8c224e Convert fxp(4) to use the new bus_alloc_resources() API, it simplifies
the resource allocation code significantly.
2005-09-27 09:01:11 +00:00
Marcel Moolenaar
3cf09dd123 Fix an unaligned I/O memory access in the event that a SCB times out.
The FXP_SCR_FLOWCONTROL registers is at offset 0x19, but 2 bytes wide.
It cannot be read as a word without causing a panic on architectures
that enforce strict alignment.

MFC after: 3 days
2005-09-21 04:36:40 +00:00
John Baldwin
9eda9d7ac5 Add callout_drain()'s to foo_detach() after calling foo_stop() to make sure
that if softclock is running on another CPU and is blocked on our driver
lock, we will wait until it has acquired the lock, seen that it was
cancelled, dropped the lock, and awakened us so that we can safely destroy
the mutex.

MFC after:	3 days
2005-08-17 17:44:32 +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
John Baldwin
3212724cc0 - Use callout_init_mtx() to close a small race between callout_stop() and
the timeout routine.
- Fix locking in detach.
- Add locking in shutdown.
- Don't mess with the PCI command register in resume, the PCI bus driver
  already does this for us.
- Add locking to the non-serial ifmedia routines.
- Fix locking in ioctl.
- Remove spls and support for 4.x.

MFC after:	1 week
2005-08-08 21:03:54 +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
86c8aacb07 Add a new PCI id for fxp(4) cards found on ICH7-based systems.
This commit is a RELENG_6 candidate.

Submitted by:	Martin Nilsson <martin@gneto.com>
2005-07-29 22:40:06 +00:00
Brooks Davis
7ba33d8222 Move if_alloc() up in fxp_attach() so there's an ifp before
mii_phy_probe() is called.

Committed via:	fxp0
2005-06-11 00:47:34 +00:00
Wes Peters
1026fbd360 Avoid deadlock in fxp driver when system runs out of mbufs.
MFC after:	1 week
Provided by:	Ernie Smallis <esmallis@stbernard.com>
2005-06-10 23:54:52 +00:00
Brooks Davis
1b5a39d368 Revert the unnecessicary addition of some braces in fxp_attach(). Don't
explicitly free the ifp in fxp_detach(), the call to fxp_release() takes
care of it.
2005-06-10 20:42:02 +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
67ba65663f Correct comment 2005-06-06 03:22:51 +00:00
Brooks Davis
e904a5aa62 Remove some variables the last commit stopped using so the code compiles. 2005-06-06 02:12:12 +00:00
Warner Losh
95af165d7f The PCI bus code saves/restores these config registers now. 2005-06-05 22:50:55 +00:00
Maxime Henrion
507feeafad Be more conservative when enabling extended features. There are fxp(4)
NICs out there that have an utterly bogus revision ID.

Reported by:	Denis Shaposhnikov <dsh@vlink.ru>
2005-04-22 13:05:53 +00:00
Maxime Henrion
de57160389 Add a microcode to implement receive bundling for 82551 chipsets with
a revision ID of 0x0f (D102 E-step).

MFC after:	2 weeks
Tested by:	pav
2005-04-21 19:34:57 +00:00
Maxime Henrion
647ec60cc7 Enable extended RFDs and TCBs, and thus checksum offloading, for
latest 82550 and 82551 chipsets (revision IDs 0x0e, 0x0f and 0x10).
We were only enabling it for revisions 0x0c and 0x0d, now it's
enabled for any 8255x NIC with a revision ID bigger than 0x0c.  It
should be safe, and this is what Intel does in their open source
driver.

MFC after:	2 weeks
Tested by:	Pavel Lobach lobach_pavel at mail dot ru
2005-04-21 13:27:38 +00:00
Maxime Henrion
c4bf1e9092 Unload and destroy the TX DMA maps before destroying the DMA tag
they're attached to, not after.

Spotted by:	Coverity via sam
2005-03-16 16:39:04 +00:00
Maxime Henrion
40c20505a8 - Encapsulate the code responsible for initializing a new TX descriptor
from an mbuf into the fxp_encap() function, as done in other drivers.
- Don't waste time calling bus_dmamap_load_mbuf() if we know the mbuf
  chain is too long to fit in a TX descriptor, call m_defrag() first.
- Convert fxp(4) to use bus_dmamap_load_mbuf_sg().
2005-03-07 13:20:49 +00:00
Maxime Henrion
74d1ed239b Cleanup: u_intXX_t -> uintX_t conversion. 2005-03-06 05:07:26 +00:00
Warner Losh
538565c4a5 Use BUS_PROBE_DEFAULT for pci probe return value 2005-03-05 18:30:12 +00:00
Maxime Henrion
29a8929dfa Add support for fxp(4) cards found in Sony FS570 laptops.
Submitted by:	Gavin Atkinson <gavin.atkinson@ury.york.ac.uk>
2005-03-05 13:52:28 +00:00
Maxime Henrion
6720ebcc9f Fix the panic recently reported on -current@ occuring when configuring
a vlan interface attached to a fxp(4) card when it has not been
initialized yet.  We now set the links from our internel TX descriptor
structure to the TX command blocks at attach time rather than at init
time.  While I'm here, slightly improve the style in fxp_attach().

PR:		kern/78112
Reported by:	Gavin Atkinson <gavin.atkinson@ury.york.ac.uk> and others
Tested by:	flz, Gavin Atkinson <gavin.atkinson@ury.york.ac.uk>
MFC after:	1 week
2005-03-03 00:22:59 +00:00
Maxime Henrion
93b6e2e6ff Fix a stupid bogon from myself, sc->revision wasn't initialized when
testing it to know whether we should enable the 82503 serial mode...
Move code to the right location and disallow the use of the 82503
serial mode if the sc->revision field is 0 again.  This makes fxp(4)
work correctly with ATMEL 350 93C46 cards (3 port 82559 based with a
82555 PHY), as well as with the older ATMEL 220 93C46 (same flavour)
and with the even older 10Mbps-only 82557 cards with the 82503 serial
interface.

Tested by:	Andre Albsmeier <andrer@albsmeier.net>, krion
MFC after:	2 weeks
2005-02-27 15:12:50 +00:00
Ruslan Ermilov
7b6fe3a4c2 Remove an outdated comment about ifnet not being locked.
OK'ed by:	njl, rwatson, sam
2005-02-15 17:47:57 +00:00
Robert Watson
03edfff39a Disable ethernet flow control in if_fxp by default, in order to prevent
unexpected surprises when a system panics or is left in the debugger.

Requested by:	kris
MFC after:	3 days
2005-01-29 23:13:20 +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
Maxime Henrion
778ee7be10 Allow fxp(4) cards with a revision id of 0 to use the 82503 serial
interface as well.  This is not an expected revision id per the
datasheet, but unfortunately there are such cards out there with
a 82557 chipset, and they want to use the 82503.

PR:		kern/75739
Reported by:	Andre Albsmeier <andre.albsmeier@siemens.com>
2005-01-04 19:30:14 +00:00
Maxime Henrion
4ed53076ed Only try to use the 82503 serial interface for the 82557 chipsets. The
datasheet says it is only valid for such chipsets and shouldn't be used
with others.  This fixes some 82559 based cards which otherwise only
work at 10Mbit.

MFC after:	5 days
Tested by:	krion
2004-12-20 10:18:21 +00:00
Pyun YongHyeon
94a4f968c1 Make interrupt coalescing work on big endian systems.
Also change struct ucode.length to be in number of elements (u_int32_t)
to help endian handling.

MFC after:	2 weeks
2004-11-17 04:25:10 +00:00
Maxime Henrion
048ca166ff Add support for the fxp(4) based card in ICH6 (i915) chipsets.
This is a RELENG_5 candidate.

Submitted by:	Mike Tancsa <mike@sentex.net>
2004-09-18 19:13:13 +00:00
Don Lewis
414ce15cb3 Deorbit the fxp tuning hint (hint.fxp.UNIT_NUMBER.ipcbxmit_disable)
introduced in if_fxp.c revision 1.180.  The bug fix committed in
revision 1.180 fixed the packet truncation problem.
2004-08-11 21:41:25 +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
Warner Losh
794950069f Remove the setting of the pci config variables on power state changes.
The bus does this now.
2004-06-28 20:26:21 +00:00
Maxime Henrion
67fc050f0c Abstract the locking in fxp(4) a bit more by using macros for
mtx_assert() and mtx_owned(), as it is done in other places,
for instance proc locking.
2004-06-02 22:59:57 +00:00
Maxime Henrion
0f1db1d60f Use the device sysctl tree instead of rolling our own. Some of the
sysctls were global (hw.fxp_rnr and hw.fxp_noflow), all of them are
now per-device.  Sample output of "sysctl dev.fxp0" with this patch,
with the standard %foo nodes removed :

dev.fxp0.int_delay: 1000
dev.fxp0.bundle_max: 6
dev.fxp0.rnr: 0
dev.fxp0.noflow: 0
2004-06-02 22:52:18 +00:00
Poul-Henning Kamp
fe12f24bb0 Add missing <sys/module.h> includes 2004-05-30 20:08:47 +00:00
Yaroslav Tykhiy
44e0bc11b9 POLA dictates that VLAN_MTU be enabled by default.
In particular, disabling it was likely to break configurations
involving ng_vlan(4) since the latter couldn't control
the parent's VLAN_MTU in the way vlan(4) did.

Pointed out by:	ru
2004-05-27 14:36:58 +00:00
Pawel Jakub Dawidek
50a33b6aaa Those sysctls shouldn't be writtable from inside a jail. 2004-05-26 23:03:27 +00:00
Yaroslav Tykhiy
8ef1f631f6 Teach fxp(4) to control VLAN_MTU in the hardware.
Now reception of extended frames can be toggled
through ioctl(SIOCSIFCAP).

The card will also receive extended frames when
in promiscuous mode.
2004-05-25 14:49:46 +00:00
Maxime Henrion
670f5d73a0 Change a if (...) panic() to a KASSERT(). 2004-05-24 18:31:56 +00:00
Yaroslav Tykhiy
25fbb2c38c A handler for ioctl(SIOCSIFCAP) should not alter a bit in
if_capenable unless the interface driver is actually able
to toggle the respective capability on and off.

Reviewed by:	ru
2004-05-23 21:05:08 +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
Yaroslav Tykhiy
5fe9116b72 Cosmetic:
Set capability bits in a consistent way.
Add a comment on why the VLAN_MTU stuff comes after ether_ifattach().
2004-05-21 20:34:04 +00:00
Yaroslav Tykhiy
21ce2bf290 The driver fxp(4) has reception of large frames enabled hardcodedly,
so let VLAN_MTU be marked in if_capenable from the beginning.
2004-05-21 18:11:38 +00:00