Commit Graph

176 Commits

Author SHA1 Message Date
Andre Oppermann
1038b3fbdc Back out rev. 1.152 as it was breaking vlan tag insertion when vlan tag
stripping was disabled due to being in promisc mode.  This is a hardware
bug.  Update comment to explicitly state the reason the manual vlan tag
insertion in this case.  See rev. 1.53 for further information as well.

Noticed by:	jhb
2006-09-29 21:38:12 +00:00
Andre Oppermann
bb2690b330 Small style and comment adjustments.
Reviewed by:	jfv
2006-09-29 13:54:04 +00:00
Andre Oppermann
7a6e967aa0 Remove manual vlan header insertion in em_encap(). It is unnecessary as the
generic vlan_start() takes care of it when vlan hardware insertion is disabled.

In em_set_promisc() add a note that BPF may also be enabled without going into
promisc mode.

Reviewed by:	jfv
2006-09-29 13:47:38 +00:00
Andre Oppermann
299b40dcd5 Change em_transmit_checksum_setup() to deal with already inserted vlan headers,
IP options and add skeleton IPv6 support.  The new code structure can also be
easily enhanced to support new/more protocols (SCTP) in the future.

Reviewed by:	jfv
2006-09-29 13:37:26 +00:00
Andre Oppermann
404138281a Change em_tso_setup() to deal with already inserted vlan headers, IP options
and add skeleton IPv6 support.  The new code structure can also be easily
enhanced to support new/more protocols (SCTP) and IP fragmentation in the
future.

In em_encap() only try to do TSO if 'dotso' is true.

Reviewed by:	jfv
2006-09-29 13:33:30 +00:00
Andre Oppermann
6c9d400d37 Only advertize IFCAP_TSO4 capabilities. IPv6 is not yet supported.
Reviewed by:	jfv
2006-09-29 13:17:16 +00:00
Andre Oppermann
5c335b1cc8 Handle all error cases from bus_dmamap_load_mbuf_sg(). Those are:
- EFBIG means the mbuf chain was too long and bus_dma ran out of segments.
   Defragment the mbuf chain and try again. (Already existed, not changed.)
 - ENOMEM means bus_dma could not obtain enough bounce buffers at this point
   in time.  Defer sending and try again later.
 - All other errors, in particular EINVAL, are fatal and prevent the mbuf
   chain from ever going through.  Drop it and report error.
 - Checking (nsegs == 0) is unnecessary as bus_dmamap_load_mbuf_sg() always
   reports an error if it is < 1.

This prevents broken packets from clogging the interface queue indefinately.

Discussed with:	scottl
Reviewed by:	jfv
2006-09-29 13:12:38 +00:00
Andre Oppermann
ba04adb0f9 Move the initialization of the hardware capabilities in em_init_locked()
before em_setup_transmit_structures() as it needs this information to
properly set up TSO parameters.

Reviewed by:	jfv
2006-09-21 19:14:51 +00:00
Andre Oppermann
9fd7a4e705 Don't forget to add curly braces when doing more than one line of actions
after a 'if' statement.

Pointy hat to:	andre
2006-09-18 23:44:12 +00:00
Andre Oppermann
78ba57b9e1 Move ethernet VLAN tags from mtags to its own mbuf packet header field
m_pkthdr.ether_vlan.  The presence of the M_VLANTAG flag on the mbuf
signifies the presence and validity of its content.

Drivers that support hardware VLAN tag stripping fill in the received
VLAN tag (containing both vlan and priority information) into the
ether_vtag mbuf packet header field:

	m->m_pkthdr.ether_vtag = vlan_id;	/* ntohs()? */
	m->m_flags |= M_VLANTAG;

to mark the packet m with the specified VLAN tag.

On output the driver should check the mbuf for the M_VLANTAG flag to
see if a VLAN tag is present and valid:

	if (m->m_flags & M_VLANTAG) {
		... = m->m_pkthdr.ether_vtag;	/* htons()? */
		... pass tag to hardware ...
	}

VLAN tags are stored in host byte order.  Byte swapping may be necessary.

(Note: This driver conversion was mechanic and did not add or remove any
byte swapping in the drivers.)

Remove zone_mtag_vlan UMA zone and MTAG_VLAN definition.  No more tag
memory allocation have to be done.

Reviewed by:	thompsa, yar
Sponsored by:	TCP/IP Optimization Fundraise 2005
2006-09-17 13:33:30 +00:00
Prafulla Deuskar
a21ff306d8 Fix issues found by Coverity (223392, 223393) due to TSO additions
Submitted by:	Matthew Jacob
2006-09-11 20:59:01 +00:00
Prafulla Deuskar
66387cee8f Fix style(9) issues in the TSO specific changes.
Pointed out by: jmallett
2006-09-10 19:23:27 +00:00
Prafulla Deuskar
d1215a3738 Second attempt at fixing module build
Pointyhat: pdeuskar
2006-09-09 20:05:24 +00:00
Prafulla Deuskar
f2449c9bcc Fix build breakage while compiling em as a module. 2006-09-09 19:55:13 +00:00
Prafulla Deuskar
87b18800d4 Add support for TSO. Thanks to Andre for adding support in the stack
and Jack Vogel for driver changes.

Submitted by: Jack Vogel
2006-09-09 06:19:20 +00:00
John-Mark Gurney
378f231e7d add a newbus method for obtaining the bus's bus_dma_tag_t... This is
required by arches like sparc64 (not yet implemented) and sun4v where there
are seperate IOMMU's for each PCI bus...  For all other arches, it will
end up returning NULL, which makes it a no-op...

Convert a few drivers (the ones we've been working w/ on sun4v) to the
new convection...  Eventually all drivers will need to replace the parent
tag of NULL, w/ bus_get_dma_tag(dev), though dev is usually different for
each driver, and will require hand inspection...

Reviewed by:	scottl (earlier version)
2006-09-03 00:27:42 +00:00
John Baldwin
7269aec456 Comment tweaks. 2006-09-01 16:11:50 +00:00
John Baldwin
acda5dd92a - Use pci_enable_busmaster() and pci_enable_io() to update the command
register.  This really shouldn't be using pci_enable_io() directly as
  bus_alloc_resource() does it already, but the cached copy of the
  command word needs to be correct so the enable/disable mwi functions
  work properly.
- Use pci bus accessors to read revision ID and subvendor IDs.

Reviewed by:	jvogel
2006-09-01 16:11:12 +00:00
John Baldwin
34de220dcf Add locking to the ifmedia callouts.
Reviewed by:	jvogel, yongari
2006-09-01 16:08:36 +00:00
Gleb Smirnoff
824d7cd2cc Fix my error in rev. 1.109.
Submitted by:	jhb
Pointy hat to:	glebius
2006-09-01 09:56:24 +00:00
John Baldwin
9555b0e2fc Just foward declare 'struct adapter' instead of declaring an actual
'adapter' structure.
2006-08-31 18:50:16 +00:00
John Baldwin
7f0875cc0f Compare the correct field against NULL when determining whether or not to
do bus_teardown_intr().
2006-08-31 18:49:41 +00:00
Pyun YongHyeon
c68ea28fe1 It seems that em(4) misses Tx completion interrupts under certain
conditions. The cause of missing Tx completion interrupts comes from
Tx interrupt moderation mechanism(delayed interrupts) or chipset bug.
If Tx interrupt moderation mechanism is the cause of false watchdog
timeout error we should have to fix all device drivers that have Tx
interrupt moderation capability. We may need more investigation
for this issue. Anyway, the fix is the same for both cases.

This should fix occasional watchdog timeout errors seen on a few
systems.

Reported by:	-net, Patrick M. Hausen < hausen AT punkt DOT de >
Tested by:	Patrick M. Hausen < hausen AT punkt DOT de >
2006-08-22 02:32:48 +00:00
Pyun YongHyeon
0c3e46f4eb Don't update Rx descriptor status in two different functions.
Suggested by:	pdeuskar
Reviewed by:	pdeuskar
2006-08-16 23:55:34 +00:00
Gleb Smirnoff
974067b161 Change hardcoded and incorrect number with correct define. This change is a
nop, since E1000_FDX_COLLISION_DISTANCE == E1000_HDX_COLLISION_DISTANCE.

PR:		kern/101000
Submitted by:	Doug Havir
2006-08-14 09:52:35 +00:00
Pyun YongHyeon
4f74b4e080 Make em(4) handle too many fragmented frame with m_defrag(9).
Previously em(4) requeued the failed mbuf chains from
bus_dmamap_load_mbuf_sg(9) failure to resend it later. However,
bus_dmamap_load_mbuf_sg(9) may never complete its request as the
fragmented frames can have more than EM_MAX_SCATTER segments.
To handle the above EFBIG case, defragment the frame with m_defrag(9)
and free the mbuf chain if it can't deframent the chain due to
resource shortage.

Reviewed by	glebius (with improvements)
2006-08-14 02:21:26 +00:00
Pyun YongHyeon
f1909c6f53 Overhaul Rx path to recover from mbuf cluster allocation failure.
o Create one more spare DMA map for Rx handler to recover from
   bus_dmamap_load_mbuf_sg(9) failure.
 o Make sure to update status bit in Rx descriptors even if we failed
   to allocate a new buffer. Previously it resulted in stuck condition
   and em_handle_rxtx task took up all available CPU cycles.
 o Don't blindly unload DMA map. Reuse loaded DMA map if received
   packet has errors. This would speed up Rx processing a bit under
   heavy load as it does not need to reload DMA map in case of error.
   (bus_dmamap_load_mbuf_sg(9) is the most expensive call in driver
    context.)
 o Update if_iqdrops counter if it can't allocate a mbuf cluster.
   With this change it's now possible to see queue dropped packets
   with netstat(1).
 o Update mbuf_cluster_failed counter if fixup code failed to
   allocate mbuf header.
 o Return ENOBUFS instead of ENOMEM in case of Rx fixup failure.
 o Make adapter->lmp NULL in case of Rx fixup failure. Strictly
   specking it's not necessary for correct operation but it makes
   the intention clear.
 o Remove now unused dropped_pkts member in softc.

With these changes em(4) should survive mbuf cluster allocation
failure on Rx path.

Reviewed by:	pdeuskar, glebius (with improvements)
2006-08-14 01:50:54 +00:00
Pyun YongHyeon
1ad7bca7e9 Apply alignment fixup only when programmed frame size is greater than
MCLBYTES - ETHER_ALIGN. Previously it applied the alignment fixup code
for oversized frames which would result in reduced performance on
strict alignment archs.
2006-08-14 00:36:53 +00:00
Gleb Smirnoff
0d2a3b0c47 Merge in new driver from Intel, version 6.1.4. It adds support for
82571EB quad port copper NIC and has few minor fixes.

Details:
  - if_em.c. Merged manually, viewing diff between new vendor
    driver and previous one.
  - if_em_hw.c. Dropped in from vendor, and then restored
    revision 1.15.
2006-08-11 10:58:24 +00:00
Prafulla Deuskar
c3b36c8f05 10/100 PHY shouldn't support gigabit media types.
Submitted by:	brad (brad@comstyle.com)
Obtained from:	OpenBSD
MFC after:	1 week
2006-08-09 20:10:35 +00:00
Yaroslav Tykhiy
776fc0e90e Commit the results of the typo hunt by Darren Pilgrim.
This change affects documentation and comments only,
no real code involved.

PR:		misc/101245
Submitted by:	Darren Pilgrim <darren pilgrim bitfreak org>
Tested by:	md5(1)
MFC after:	1 week
2006-08-04 07:56:35 +00:00
Prafulla Deuskar
219de4f9d8 Revert back changes to made in rev 1.109 of if_em.c which were unnecessary.
This makes it easier for us to get the changes into -current and to -stable quickly.
2006-08-03 19:05:04 +00:00
Gleb Smirnoff
66ebe2912f Merge in new driver from Intel, version 6.0.5. It adds support for
80003 NICs and NICs found on ICH8 mobos, and improves support for
already known chips.

Details:
  - if_em.c. Merged manually, viewing diff between new vendor
    driver and previous one. This was an easy task, because
    most changes between 5.1.5 and 6.0.5 are bugfixes taken
    from FreeBSD.
  - if_em_hw.h. Dropped in from vendor, and then restored
    revisions 1.16, 1.17, 1.18.
  - if_em_hw.c. Dropped in from vendor, and then restored
    revision 1.15.
  - if_em_osdep.h. Added new required macros from vendor file
    and add a hack against define namespace mangling in
    if_em_hw.h. Intel made another hack, but I prefer mine.
2006-08-03 09:20:11 +00:00
Pyun YongHyeon
aaef1f52af Prepending an mbuf after loading a DMA map results in unexpected
result. So, modify mbuf chains before loading a DMA map.
2006-07-27 00:43:34 +00:00
Pyun YongHyeon
68fb31fc2b Nuke invalid use of BUS_DMA_ALLOCNOW. 2006-07-27 00:29:44 +00:00
Pyun YongHyeon
c2044727ab Make sure to use the same DMA map in DMA map load/unload operations
by remembering a map used in bus_dmamap_load_mbuf_sg(9). I have
no idea how it could ever worked before.
This fixes a warning generated by a diagnostic check in sun4v
iommu driver.

Reported by:	jb
Tested by:	jb(sun4v)
2006-07-27 00:26:20 +00:00
Pyun YongHyeon
da84b3961f Since resetting hardware takes a very long time and results in link
renegotiation, we only initialize the hardware only when it is
absolutely required. Process SIOCGIFADDR ioctl in em(4) when we know
an IPv4 address is added. Handling SIOCGIFADDR in a driver is
layering violation but it seems that there is no easy way without
rewritting hardware initialization code to reduce settle time after
reset.

This should fix a long standing bug which didn't send ARP packet when
interface address is changed or an alias address is added. Another
effect of this fix is it doesn't need additional delays anymore when
adding an alias address to the interface.
While I'm here add a new if_flags into softc which remembers current
prgroammed interface flags and make use of it when we have to program
promiscuous mode.

Tested by:	Atanas <atanas AT asd DOT aplus DOT net>
Analyzed by:	rwatson
Discussed with:	-stable
2006-07-20 04:18:45 +00:00
Pyun YongHyeon
693d469eee Protect EEPROM access with the driver lock. 2006-07-20 04:01:54 +00:00
Pyun YongHyeon
fa799a4e7e Honor IFF_DRV_OACTIVE in em_start_locked(). 2006-07-20 03:57:58 +00:00
Gleb Smirnoff
9297f2a72e The procedure of raceless switching between polling mode and
taskqueued interrupt mode is going to be quite complex. Since
the polling mode is considered legacy feature for em(4) driver,
the decision is made to make polling and new interrupt handler
mutually exclusive, selected at compile time.

If kernel is compiled with DEVICE_POLLING, the fast taskqueued
interrupt handler code is disabled and the em_poll() and legacy
em_intr() functions are enabled. Otherwise, legacy functions
are disabled and only em_intr_fast() code is compiled.

Discussed with:		scottl
2006-06-06 08:03:49 +00:00
Gleb Smirnoff
86c9af6b69 Fix static array overrun.
(This will be also fixed in next vendor release.)

Coverity ID:	916
Reviewed by:	Jack Vogel
2006-05-17 07:38:58 +00:00
Olivier Houchard
5d1e6e68fc Bring back arm-specific workaround from rev 1.15:
Do not use the IO-mapping to issue the reset on the 82546 on arm. For some
reason, it results in corrupted descriptors.
2006-04-13 15:10:25 +00:00
Gleb Smirnoff
2a7d090a2e Restore accidentially removed rev. 1.3 2006-04-07 10:18:24 +00:00
Gleb Smirnoff
a80d10932e Merge in new driver from Intel, version 5.1.5. Adds support for some
new chips and improves support for already supported ones.

Some details, important for future merges:
  - if_em.c merged manually, viewing diff between new vendor
    driver and previous one.
  - if_em_hw.h dropped in from vendor, and then restored revisions
    1.16, 1.17, 1.18.
  - if_em_hw.c dropped in from vendor, and then two liner change made,
    that restores support for two rare chips.
2006-04-06 17:09:03 +00:00
Gleb Smirnoff
9cc9484cb5 Back out 1.112,1.113. I don't have enough resources to fix breakages
introduced by this change.
2006-02-22 14:11:16 +00:00
Gleb Smirnoff
37790e7f74 Fix fallout from last commit - we need to program the MAC address in em_init(). 2006-02-15 14:27:38 +00:00
Gleb Smirnoff
95c01e57d9 em_hardware_init() in em_init() is not needed, and leads to annoying
link flap.

Submitted by:	ru, Mike Tancsa
2006-02-15 13:45:02 +00:00
Gleb Smirnoff
1d66a76549 Set ifp->if_baudrate according to current speed. 2006-02-15 11:38:33 +00:00
Gleb Smirnoff
c47c580e83 - Rename em_print_link_status() to em_update_link_status().
- In em_attach() remove em_check_for_link(). Not needed here, since
  already done in em_hardware_init().
- In em_attach() replace the printing block with call to
  em_update_link_status().
- Remove modification of sc->link_state from em_hardware_init() and
  from em_media_status(). This makes em_update_link_status() a
  single point of change. Call em_update_link_status() where needed.
2006-02-15 10:51:11 +00:00
Gleb Smirnoff
eb0ec08982 - Second style(9) megacleanup.
- Rename "adapter" to "sc"/"softc", to be like other drivers.

  (-13 Kb less source code)
2006-02-15 08:39:50 +00:00