Commit Graph

164 Commits

Author SHA1 Message Date
Gleb Smirnoff
60f2751670 Fix build. 2013-02-22 12:41:24 +00:00
Andrew Gallatin
26dd49c61d Improve mxge's receive performance for IPv6:
- Add support for IPv6 rx csum offload
- Finally switch mxge from using its own driver lro, to
	using tcp_lro

MFC after:	7 days
Sponsored by: Myricom Inc.
2013-02-21 21:28:33 +00:00
Andrew Gallatin
0a7a780eee Add support to mxge for IPv6 TX csum offload & IPv6 TSO.
Sponsored by: Myricom, Inc.
MFC after: 7 days
2013-02-19 21:33:21 +00:00
Sofian Brabez
61bfd86762 Use DEVMETHOD_END macro defined in sys/bus.h instead of {0, 0} sentinel on device_method_t arrays
Reviewed by:	cognet
Approved by:	cognet
2013-01-30 18:01:20 +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
Gleb Smirnoff
73b160cf5b Utilize new macro to initialize if_baudrate. 2012-10-18 13:57:28 +00:00
Kevin Lo
9823d52705 Revert previous commit...
Pointyhat to:	kevlo (myself)
2012-10-10 08:36:38 +00:00
Kevin Lo
a10cee30c9 Prefer NULL over 0 for pointers 2012-10-09 08:27:40 +00:00
Gleb Smirnoff
063efed28c The drbr(9) API appeared to be so unclear, that most drivers in
tree used it incorrectly, which lead to inaccurate overrated
if_obytes accounting. The drbr(9) used to update ifnet stats on
drbr_enqueue(), which is not accurate since enqueuing doesn't
imply successful processing by driver. Dequeuing neither mean
that. Most drivers also called drbr_stats_update() which did
accounting again, leading to doubled if_obytes statistics. And
in case of severe transmitting, when a packet could be several
times enqueued and dequeued it could have been accounted several
times.

o Thus, make drbr(9) API thinner. Now drbr(9) merely chooses between
  ALTQ queueing or buf_ring(9) queueing.
  - It doesn't touch the buf_ring stats any more.
  - It doesn't touch ifnet stats anymore.
  - drbr_stats_update() no longer exists.

o buf_ring(9) handles its stats itself:
  - It handles br_drops itself.
  - br_prod_bytes stats are dropped. Rationale: no one ever
    reads them but update of a common counter on every packet
    negatively affects performance due to excessive cache
    invalidation.
  - buf_ring_enqueue_bytes() reduced to buf_ring_enqueue(), since
    we no longer account bytes.

o Drivers handle their stats theirselves: if_obytes, if_omcasts.

o mlx4(4), igb(4), em(4), vxge(4), oce(4) and  ixv(4) no longer
  use drbr_stats_update(), and update ifnet stats theirselves.

o bxe(4) was the most correct driver, it didn't call
  drbr_stats_update(), thus it was the only driver accurate under
  moderate load. Now it also maintains stats itself.

o ixgbe(4) had already taken stats from hardware, so just
  - drop software stats updating.
  - take multicast packet count from hardware as well.

o mxge(4) just no longer needs NO_SLOW_STATS define.

o cxgb(4), cxgbe(4) need no change, since they obtain stats
  from hardware.

Reviewed by:	jfv, gnn
2012-09-28 18:28:27 +00:00
Andrew Gallatin
bebda077b1 Update mxge(4) firmware to the latest version available from
Myricom (1.4.55).

MFC after:	3 days
Sponored by: Myricom, Inc.
2012-05-29 00:53:51 +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
dc15eac046 Use strchr() and strrchr().
It seems strchr() and strrchr() are used more often than index() and
rindex(). Therefore, simply migrate all kernel code to use it.

For the XFS code, remove an empty line to make the code identical to
the code in the Linux kernel.
2012-01-02 12:12:10 +00:00
Andrew Gallatin
40eaac6360 Update mxge(4) firmware to the latest version available from
Myricom (1.4.53a).

MFC after:	7 days
Sponored by: Myricom, Inc.
2011-07-12 15:07:17 +00:00
Andrew Gallatin
30882b10fc Fix media reporting for dual port CX4 myri10ge NICs
MFC after: 7 days
Sponsored by: Myricom, Inc.
2011-07-12 14:43:49 +00:00
Andrew Gallatin
534e6f47c1 Fix a bug in mxge's LRO which can cause dup acks to
get aggregated & hence prevent TCP from entering
fast retransmit.

Pointed out by: jeff
Reviewed by: gnn
MFC after:	7 days
2011-04-07 13:49:44 +00:00
Andrew Gallatin
3cae73118e Implement mxge_init()
This fixes a long standing bug in mxge(4) where "ifconfig mxge0 $IP"
did not bring the interface into a RUNNING state, like it does on
most (all?) other FreeBSD NIC drivers.

Thanks to gnn for mentioning the bug, and yongari for pointing out that
ether_ioctl() invokes ifp->if_init() in SIOCSIFADDR.

MFC after: 7 days
2011-04-06 15:45:32 +00:00
John Baldwin
3b0a4aef96 Do a sweep of the tree replacing calls to pci_find_extcap() with calls to
pci_find_cap() instead.
2011-03-23 13:10:15 +00:00
John Baldwin
a4a75d679c Use a regular taskqueue rather than a fast taskqueue for mxge(4).
Reviewed by:	gallatin
2011-01-07 16:07:29 +00:00
Andrew Gallatin
4ed8ca8f25 Fix a TSO checksum bug on mxge(4):
The Myri10GE NIC will assume all TSO frames contain partial checksum,
and will emit TSO segments with bad TCP checksums if a TSO frame
contains a full checksum.  The mxge driver takes care to make sure
that TSO is disabled when checksum offload is disabled for this
reason.  However, modules that modify packet contents (like pf) may
end up completing a checksum on a TSO frame, leading to the NIC emitting
TSO segments with bad checksums.

To workaround this, restore the partial checksum in the mxge driver
when we're fed a TSO frame with a full checksum.

Reported by: Bob Healey

MFC after:	3 days
2010-11-22 16:43:05 +00:00
Andrew Gallatin
2108913743 Add interrupt descriptions for mxge's msi-x vectors 2010-05-21 15:57:24 +00:00
Andrew Gallatin
56b6785885 Correctly identify some twinax cables, which report
a media type of 1.
2010-05-19 20:00:15 +00:00
Andrew Gallatin
70020d8129 Update mxge firmware to latest available from Myricom. 2010-05-19 19:44:00 +00:00
Fabien Thomas
b92990ef88 Add a fastpath to allocate from packet zone when using m_getjcl.
This will add support for packet zone for at least igb and ixgbe
and will avoid to check for that in bce and mxge.

MFC after: 1 week
2010-05-07 22:09:17 +00:00
Andrew Gallatin
2a29e09f38 Add missing IFCAP_LINKSTATE to mxge
Submitted by: yongari
2010-04-15 14:26:52 +00:00
Andrew Gallatin
c406ad2ecc Cleanup if_media handling in mxge(4)
- Re-probe xfp / sfp+ socket on link events, in case user
    has changed transceiver
- correctly report current media to avoid confusing lagg (reported by Panasas)
- Report link speed  (submitted by yongari)

Reviewed by: yongari (earlier version)

MFC after: 7 days
2010-04-15 13:50:55 +00:00
Andrew Gallatin
2e08479882 Fix 2 bugs in mxge_attach()
- Don't leak slice resources when mxge_alloc_rings() fails

- Start taskq threads only after we know attach will succeed.  At
  boot time, taskqueue_terminate() will loop infinately, waiting
  for the threads to exit, and hang the system.

Submitted by: Panasas
MFC After: 3 days
2010-03-17 20:13:09 +00:00
Andrew Gallatin
0dce6781ae Update mxge to support IFCAP_VLAN_HWTSO.
Note: If/when FreeBSD supports TSO over IPv6, the minimal mxge fw
rev to enable IFCAP_VLAN_HWTSO will need to be increased to 1.4.37
2010-02-22 16:57:03 +00:00
Max Laier
193cbc4d24 Fix drbr and altq interaction:
- introduce drbr_needs_enqueue that returns whether the interface/br needs
   an enqueue operation: returns true if altq is enabled or there are
   already packets in the ring (as we need to maintain packet order)
 - update all drbr consumers
 - fix drbr_flush
 - avoid using the driver queue (IFQ_DRV_*) in the altq case as the
   multiqueue consumer does not provide enough protection, serialize altq
   interaction with the main queue lock
 - make drbr_dequeue_cond work with altq

Discussed with:		kmacy, yongari, jfv
MFC after:		4 weeks
2010-02-13 16:04:58 +00:00
Andrew Gallatin
5769c5efb0 Use better default RSS hash (src + dst, rather than just src port)
MFC after:3 days
2010-01-11 22:28:40 +00:00
Andrew Gallatin
669f23dee5 Update mxge(4) firmware to 1.4.48b (latest available) from Myricom.
Pertinant highlights from Myricom CHANGES file include:

- Make sure invalid external smbus activity cannot affect performance
- Fix to avoid a bug where the link could sometimes stay reported as
   up on after unplugging the cable.
- For 8B NIC, make smbus connection passive at init to avoid
   possible address conflicts
- Increase number of slices to 17 for multi-slice fw
- Fix a bug where packets dropped because of link_overflow could
     be occasionally reported as bad_crc32
- Add selectable failover strategy for dual-port chip: symmetric or primary/backup
- On failover, send RARP broadcast to make the change immediately
  known to the network
- Change endianess for PCI Device Serial Number
- For dual-port NICs, time to failover is now a few microsecs
    instead of a few millisecs.

MFC after:	3 days
2010-01-11 22:25:09 +00:00
Andrew Gallatin
51bc2092fe Fix reporting of 10G Twinax media
Reported by: mjacob
MFC after: 3 days
2010-01-11 22:08:59 +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
Andrew Gallatin
57e42c95a4 Don't take the driver mutex in mxge_tick(), as it
is run with the mutex held.

Submitted by: rwatson
MFC after:	3 days
2009-12-22 15:41:58 +00:00
Andrew Gallatin
6b484a49cd Make mxge do a better job recovering from NIC h/w faults
by checking PCI config space when the NIC is not
transmitting.  Previously, a h/w fault would not have been
detected if the NIC was down, or handling an RX only
workload.
2009-10-20 18:58:28 +00:00
Andrew Gallatin
72c042dfb5 Move mxge(4)'s NIC watchdog reset handler from
a callout to a taskqueue
2009-10-19 20:51:27 +00:00
Andrew Gallatin
83d54b590f Two more mxge watchdog fixes:
1) Restore the PCI Express control register after a watchdog
   reset.  This is required because the device will come out
   of watchdog reset with the pectl reg at its default state,
   and important BIOS configuration (like max payload size)
   could be lost.

2) Call mxge_start_locked() for every tx queue before dropping
   the lock in the watchdog handler.   This is required, as
   the queue's buf ring may have filled during the reset.
2009-09-30 14:42:06 +00:00
Andrew Gallatin
a393336b87 Improve mxge watchdog routine's ability to reliably reset a failed NIC:
- Mark the link as down, so if watchdog reset fails, link watching
    failover software can notice it
- Don't send MXGEFW_CMD_ETHERNET_DOWN if the NIC has been reset, it is
    not needed, and will fail on a freshly reset NIC.
- Ensure the transmit routines aren't attempting to PIO write to doorbells
    while the NIC is being reset.
- Download the correct f/w, rather than using the EEPROM f/w after reset.
- Export a count of the number of watchdog resets via sysctl
- Zero all f/w stats at reset.  This will lead to less confusing
    diagnostic output when investigating NIC failures.

MFC after:	3 days
2009-09-21 20:16:10 +00:00
Andrew Gallatin
65c690668b Add support for throttling transmit bandwidth. This is most commonly
used to reduce packet loss on high delay (WAN) paths with a
slow link.
2009-09-21 14:41:07 +00:00
Andrew Gallatin
94c7d993a3 mxge's tunable hw.mxge.rss_hash_type cannot be set from the
loader, because it uses a reserved suffix (_type).  Fix
this by removing the "_" and renaming the tunable to
hw.mxge.rss_hashtype.  The old (rss_hash_type) tunable is
still fetched, in case people load the driver via scripts.
When both are present in the kernel environment,
the new value (hw.mxge.rss_hashtype) overrides the old
value.

Approved by:	re (kib)
2009-07-22 11:57:34 +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
Andrew Gallatin
8c5d766cd7 Add a dying flag to prevent races at detach.
I tried re-ordering ether_ifdetach(), but this created a new race
where sometimes, when under heavy receive load (>1Mpps) and running
tcpdump, the machine would panic.  At panic, the ithread was still in
the original (not dead) if_input() path, and was accessing stale BPF
data structs.  By using a dying flag, I can close the interface prior
to if_detach() to be certain the interface cannot send packets up in
the middle of ether_ifdetach.
2009-06-24 21:09:56 +00:00
Andrew Gallatin
f945302517 Allow admin to specify the initial mtu upon driver load
for mxge.
2009-06-24 14:47:32 +00:00
Andrew Gallatin
bb8ddc66ea - Fix bug where device would loose promisc setting when reset.
- Allow all rss hash modes to be chosen
2009-06-23 20:22:34 +00:00
Andrew Gallatin
710328322a Revert most of 193311 so as to track mxge transmit stats
on a per-ring basis and avoid racy (and costly) updates
to the ifp stats via drbr by defining NO_SLOW_STATS

Discussed with: kmacy
2009-06-23 19:04:25 +00:00
Andrew Gallatin
f9298d3901 Update mxge firmware from 1.4.39 to 1.4.43. Changes include:
- Support for 10G-PCIE*-8B*-C (dual-port CX4)  NICs
- For dual-port NICs, f/w failover is now a few microsecs
    instead of a few millisecs.
-  On failover, f/w sends RARP broadcast to make the change
   immediately known to the network
- Fixed a bug observed on IBM X3 architecture where
   some spurious ecrc errors would be reported when OS enabled
   ecrc support.

Sponsored by: Myricom Inc.
2009-06-23 18:00:43 +00:00
Andrew Gallatin
eb6219e337 Implement minimal set of changes suggested by bz to make
mxge no longer depend on INET.
2009-06-23 17:42:06 +00:00
Andrew Gallatin
869c7348e5 Buf-ring fixes for mxge
- always maintain byte/mcast/drop stats via drbr
- move #define of IFNET_BUF_RING so that its picked
  up by all files in the driver
- conditionalize IFNET_BUF_RING on the FreeBSD_version
  bump just after it appeared in the tree.

Sponsored by: Myricom Inc.
2009-06-02 16:52:33 +00:00
Andrew Gallatin
4d9a5852aa Set an rx jumbo cluster to the correct size before
using bus_dmamap_load_mbuf_sg() on it. This
prevents data corruption when the mxge MTU is
between 4076 and 8172 on machines with 4KB
pages and MXGE_VIRT_JUMBOS is in use (which it
isn't, in -current or -stable)
2009-06-01 19:16:57 +00:00
Andrew Gallatin
950f22e38d Fix build: Make forgotten IFNET_MULTIQUEUE to IFNET_BUF_RING
ifdef change.
2009-04-27 17:24:47 +00:00
Andrew Gallatin
c6cb3e3fe8 Updates to mxge for multiple tx/rx rings:
- Update mxge to use if_transmit(), and the new buf_ring
  interfaces, so as to enable multiple transmit queues.
  Use of if_transmit() is conditional on IFNET_BUF_RING,
  and is enabled by default (as in if_em).

- Record a flow id on receive if receive hashing is active.
  I currently only record the rx ring id (0..8) rather than
  the 32-bit topelitz hash result, as doing the latter would
  require shifting the driver to use a larger rx return ring.

Sponsored by:  Myricom, Inc.
2009-04-27 15:45:54 +00:00
Andrew Gallatin
4ae3322f1a Fix cut/paste error in previous commit and use the
correct value for SFP+ reserved media type.

MFC after:  1 week
2009-02-17 22:25:19 +00:00
Andrew Gallatin
016385508f Better support for recent Myricom 10GbE NICs
- Update to firmware 1.4.39 for dual-chip NIC (10G-PCIE2-xxx)
  support, and SFP+ i2c support

- Identify newer "B" NICs (10G-PCIEx-8B-x) correctly, rather than
  mis-identifying them as "A" NICs (cosmetic only)

- Identify the IFM_10G_LRM ifmedia type, where applicable.

- Identify ifmedia types for SFP+ based NICs

- Update copyright

Sponsored by: Myricom
MFC after: 1 week
2009-02-17 22:15:58 +00:00
Roman Divacky
0d15110307 Remove obsolete C preprocessor assertions.
Approved by:    kib (mentor)
2009-02-12 18:33:56 +00:00
Andrew Gallatin
73c7c83f1e Restore sfence semantics in mxge after the introduction
of a global mfence based mb() in r185162
2008-11-24 19:00:57 +00:00
Kip Macy
db7f0b974f - bump __FreeBSD version to reflect added buf_ring, memory barriers,
and ifnet functions

- add memory barriers to <machine/atomic.h>
- update drivers to only conditionally define their own

- add lockless producer / consumer ring buffer
- remove ring buffer implementation from cxgb and update its callers

- add if_transmit(struct ifnet *ifp, struct mbuf *m) to ifnet to
  allow drivers to efficiently manage multiple hardware queues
  (i.e. not serialize all packets through one ifq)
- expose if_qflush to allow drivers to flush any driver managed queues

This work was supported by Bitgravity Inc. and Chelsio Inc.
2008-11-22 05:55:56 +00:00
Andrew Gallatin
9e6287bf10 Update to Myri10GE Firmware 1.4.36.
This update fixes a transmit bug in the multi-queue (MSI-X) firmware
which happens when RDMAs complete out of order, and provides
improved support for the new Myri10GE NIC models (10G-PCIE-8Bx)

Sponsored by: Myricom Inc.

MFC after:3 days
2008-10-23 20:07:08 +00:00
Andrew Gallatin
88843c5481 Update to Myri10GE firmware version 1.4.33 from 1.4.29. Relevant changes include:
- Support for Myricom 10G-PCIE-8B NICs

- multi-slice firmware: fix a bug when the presence of 32-bit or
 64-bit DMA addresses for interrupt queues and data is not uniform across
 slices.

- Improves automatic selection between ethp_z8e/eth_z8e

Sponsored by: Myricom Inc.
2008-10-01 16:23:35 +00:00
Andrew Gallatin
7b9f20ea8d Adapt mxge shims to detect phys contig jumbo frames
in RELENG_7

MFC after: 3 days
2008-08-21 16:35:34 +00:00
Andrew Gallatin
e749ef6bab Clean up mxge's use of callouts as pointed out by jhb,
and handle NIC hardware watchdog resets.

- remove buggy code at the top of mxge_tick() which tried
  to detect a race which is already detected in the kernel's
  callout code.

- move callout_stop() and callout_reset() into mxge_close()
  mxge_open() rather than doing the callout manipulation
  all over the place.

- use callout_drain(), rather than callout_stop() to prevent
  a potential race between mxge_tick() and mxge_detach()
  which could lead to softclock using a destroyed mutex

- restructure the mxge_tick() and mxge_watchdog_reset()
  routines to avoid resetting a callout, and then
  immediately stopping it if the watchdog reset routine
  is called, and fails.

- enable the driver to handle NIC hardware watchdog
  resets by restoring the NIC's PCI config space, which is
  lost when the NIC hardware watchdog triggers.

Reviewed by: jhb (previus version)
2008-07-17 15:46:35 +00:00
Andrew Gallatin
e5062938d1 Initialize if_baudrate using IF_Gbps() macro.
Note that if_baudrate is a long, and 32-bits isn't enough to properly
represent 10Gb/s.

Pointed out by: dwhite
2008-04-02 13:59:43 +00:00
Andrew Gallatin
47c2e9879b Remove dead code which makes a call to mem_range_attr_set().
This fixes a bug where mxge did not declare a dependancy on
mem(4), and failed to load with options nomem.

Pointed out by: antoine
2008-03-12 15:36:00 +00:00
Andrew Gallatin
91ed89132c Now that mxge supports MSI-X interrupts, reverse the logic and flag
legacy interrupts rather than MSI as a special case.  Prior to this
commit, the interrupt handler was doing the slow handshaking with
the device to ensure the legacy interrupt was lowered in both
the legacy and MSI-X case.  This handshaking was not
required for MSI-X.
2008-02-14 16:24:14 +00:00
Andrew Gallatin
37d89b0c5e Add minimally invasive shims to ease MFCs of mxge back as far
as RELENG_6

Sponsored by: Myricom, Inc.
2008-02-14 00:09:59 +00:00
Andrew Gallatin
615fc0983c Make the type of the firmware arrays match those
in the other eth*_z8e.h files.
2008-02-13 21:58:46 +00:00
Andrew Gallatin
10882804c9 Only reset driver state when a hardware error is detected.
Preserve warning but do not reset if we enter the routine
without seeing a hardware error.
2008-01-28 13:20:51 +00:00
Andrew Gallatin
b0f7b92207 Take advantage of the new physically contiguous 9K jumbos in 8. 2008-01-22 22:04:31 +00:00
Andrew Gallatin
1e413cf932 Add optional support to mxge for MSI-X interrupts and multiple receive
queues (which we call slices).  The NIC will steer traffic into up to
hw.mxge.max_slices different receive rings based on a configurable
hash type (hw.mxge.rss_hash_type).

Currently the driver defaults to using a single slice, so the default
behavior is unchanged.  Also, transmit from non-zero slices is
disabled currently.
2008-01-15 20:34:49 +00:00
Andrew Gallatin
93143d572a Fix accidental swap of "const" for "static" in mxge firmware byte arrays
caused by running my import script with the wrong args.
2008-01-15 15:04:40 +00:00
Andrew Gallatin
7e8305464a Update to firmware version 1.4.29 from 1.4.25. Relevant changes include:
- Fix a bug introduced in 1.4.20 where speculative read by the processor in the
   write-only doorbell region would cause a target-abort (as opposed to simply
   returning random data). This could manifest itself as NMI or machine freeze
   depending on how the BIOS/OS/chipset configuration handles target-abort.

- Add support for new revisions of -R cards (with AEL1002/AEL1010 xaui->xfi)

- Increase an internal timing (dispatch engine): fix possible spurious reset
  (seen on very few cards).
2008-01-15 13:29:32 +00:00
Andrew Gallatin
f15444982b Add support for a new device id (9). Mxge NICs with the new
device id support MSI-X.

Approved by: re (bmah)
2007-09-13 21:29:02 +00:00
Andrew Gallatin
c587e59f20 - Fix a bug which could cause a panic when enabling LRO
on an down mxge interface
- Fix a bug where mxge reported the link state as
   active when it wasn't (after ifconfig down).
- Prevent spurious watchdog resets when link partner is not consuming
- Add support for CX4 and popular XFP media detection
- Update the firmware and associated header files to 1.4.25

Approved by: re (kensmith)
2007-08-22 13:22:12 +00:00
Andrew Gallatin
f9ae02802f - Enable static building of mxge(4) and its firmware.
- Add custom .c wrappers for the firmware, rather than the standard
  firmware(9) generated firmware objects to work around toolchain
  problems on ia64 involving linking objects produced by
  ld -b -binary into the kernel.

- Move from using Myricom's ".dat" firmware blobs to using Myricom's
  zlib compressed ".h" firmware header files.  This is done to
  facilitate the custom wrappers, and saves a fair amount of wired
  memory in the case where the firmware is built in, or preloaded.

- Fix two compile issues in mxge which only appear on non-i386/amd64.

Reviewed by: mlaier, mav (earlier version with just zlib support)
Glanced at by: sam
Approved by: re (kensmith)
2007-07-19 16:16:00 +00:00
Andrew Gallatin
eb8e82f5fd Update the mxge(4) driver's copyright to 2007, and drop
the binary distribution clause.

Approved by: re (bmah)
2007-07-12 16:04:55 +00:00
Andrew Gallatin
4d69a9d061 Also mark writecombine as enabled when PAT is used to enable
it rather than MTRRs.
2007-06-17 00:09:51 +00:00
Andrew Gallatin
f616ebc73f correct some limits on interrupt proccessing so that
fast forwarding back out the same mxge interface works nicely.
2007-06-14 19:35:03 +00:00
Andrew Gallatin
f04b33f842 Use the new IFCAP_LRO to enable/disable LRO. 2007-06-12 19:15:16 +00:00
Andrew Gallatin
56b8f0b02d Back out the previous commit which added an M_LRO mbuf flag
to defeat the mtu check in ether_input.  Mbuf flags are too scarce.
Discussed with: sam
2007-06-11 18:26:25 +00:00
Andrew Gallatin
b6af0abdc4 Allow drivers, such as cxgb and mxge, which support LRO to bypass
the MTU check in ether_input() on LRO merged frames.

Discussed with: kmacy
2007-06-11 14:59:56 +00:00
Andrew Gallatin
276edd10ac Small LRO related fixes for mxge:
- Allow LRO to be enabled / disabled at runtime
- Fix a double-free at module unload time.
- Only update timestamp in lro merge when it is present in the frame
Sponsored by: Myricom
2007-06-11 14:01:10 +00:00
Andrew Gallatin
c2c14a696c Use pmap_change_attr() to setup a write combine attribute for our
device memory, rather than relying on the less reliable MTRR method
used by mem_range_attr_set().

Glanced at by: jhb
2007-06-05 15:02:14 +00:00
Andrew Gallatin
a0394e33a5 - Use m_getcl() rather than m_getjcl() when we're allocating 2KB
clusters.  This helps quite a bit on my low end machines (improves
performance by about 300Kpps when being blasted by a hardware
packet generator).
- Include one extended f/w counter forgotten in earlier commit

Sponsored by: Myricom Inc.
2007-05-25 19:38:32 +00:00
Andrew Gallatin
c792928f01 Add support for "hardware" vlan tag insertion & removal emulation
in the mxge driver so as to be able to do checksum offload
on vlans.  This is good enough to achieve 10GbE line rate on vlans.
2007-05-23 16:25:40 +00:00
Andrew Gallatin
adae7080fb mxge cleanups:
- Remove code to use the special wc_fifo.  It has been disabled by default
  in our other drivers as it actually slows down transmit by a small amount

- Dynamically determine the amount of space required for the rx_done
  ring rather than hardcoding it.

- Compute the number of tx descriptors we are willing to transmit per
  frame as the minimum of 128 or 1/4 the tx ring size.

- Fix a typo in the tx dma tag setup which could lead to unnecessary
  defragging of TSO packets (and potentially even dropping TSO packets
  due to EFBIG being returned).

- Add a counter to keep track of how many times we've needed to
  defragment a frame.  It should always be zero.

- Export new extended f/w counters via sysctl

Sponsored by: Myricom, Inc.
2007-05-22 15:57:49 +00:00
Andrew Gallatin
053e637f86 Improve mxge receive performance:
- Update to the latest (1.4.18) f/w.  This f/w introduces a new
  receive mode which allows us to use FreeBSD's physically discontinuous
  MJUM9BYTES clusters.

- Switch the driver from chaining MJUMPAGESIZE clusters to using
  MJUM9BYTES clusters to avoid mbuf chaining overheads.  Due to this
  change, people running obsolete f/w images will be limited to an MTU of
  PAGE_SIZE - 16.

- Add (disabled by default) support for Large Receive Offload.

Sponsored by: Myricom, Inc.
2007-05-21 18:32:27 +00:00
Andrew Gallatin
e0501fd040 - Add handling of MXGEFW_CMD_UNKNOWN in mxge_send_cmd().
- Convert mxge_send_cmd result handling to a switch rather
  than adding a new elseif for MXGEFW_CMD_UNKNOWN

Sponsored by: Myricom Inc.
2007-05-08 18:45:43 +00:00
Andrew Gallatin
8fe615ba76 Firmware update & improvements to firmware selection:
- Update to latest (1.4.17) firmware.

- Use the new MXGEFW_CMD_UNALIGNED_TEST (added in firmare 1.4.16) to
  have the firmware tell us if the PCIe chipset supports aligned PCIe
  completions.

- Hard to maintain, and frequently out of date whitelist of PCIe
  chipsets known to produce aligned completions removed, as it has been
  replaced in its role of selecting the correct firmware to run by the
  use of MXGEFW_CMD_UNALIGNED_TEST.

- Break the dma test out of mxge_reset() and into its own function
  (mxge_dma_test()) so it can be used by both the normal DMA test, and
  to run the unaligned test.

- Improved support for enabling ECRCs

Sponsored by: Myricom Inc.
2007-05-08 14:19:43 +00:00
Andrew Gallatin
9b03b0f3c0 -Fix an mbuf leak caused by a cut&paste bug where the small ring's mbufs
were never freed, but the big ring was freed twice.
-Don't supply rx hw csums for frames which are padded beyond the
 length specified in the ip header.  If the padding is non-zero,
 the hw csum will be incorrect for such frames.

Sponsored by: Myricom
2007-04-27 13:11:50 +00:00
Andrew Gallatin
e39a0a37cf - Fix a bug in the TSO transmit routine where frames which had
been defragged and had their headers in the same cluster as their
payload would be fed to the NIC in header-sized chunks, and would
likely exceed the number of available transmit descriptors.

- If a TSO frame exceeds the number of available transmit descriptors,
don't leak busdmma resources when freeing it.

Sponsored by: Myricom Inc.
2007-04-03 10:41:33 +00:00
John Baldwin
4e7f640dfb Optimize sx locks to use simple atomic operations for the common cases of
obtaining and releasing shared and exclusive locks.  The algorithms for
manipulating the lock cookie are very similar to that rwlocks.  This patch
also adds support for exclusive locks using the same algorithm as mutexes.

A new sx_init_flags() function has been added so that optional flags can be
specified to alter a given locks behavior.  The flags include SX_DUPOK,
SX_NOWITNESS, SX_NOPROFILE, and SX_QUITE which are all identical in nature
to the similar flags for mutexes.

Adaptive spinning on select locks may be enabled by enabling the
ADAPTIVE_SX kernel option.  Only locks initialized with the SX_ADAPTIVESPIN
flag via sx_init_flags() will adaptively spin.

The common cases for sx_slock(), sx_sunlock(), sx_xlock(), and sx_xunlock()
are now performed inline in non-debug kernels.  As a result, <sys/sx.h> now
requires <sys/lock.h> to be included prior to <sys/sx.h>.

The new kernel option SX_NOINLINE can be used to disable the aforementioned
inlining in non-debug kernels.

The size of struct sx has changed, so the kernel ABI is probably greatly
disturbed.

MFC after:	1 month
Submitted by:	attilio
Tested by:	kris, pjd
2007-03-31 23:23:42 +00:00
Andrew Gallatin
40385a5f33 Fix a bug which could lead to receive side lockup when WC is disabled.
When submitting rx buffers and not using WC fifo, always replace the
invalid DMA address with the real one, otherwise allocation failures
could lead to the invalid DMA address being given to the NIC, and
that would cause the receive side to lockup.
2007-03-27 15:55:32 +00:00
Andrew Gallatin
21b49cfcaa Update mxge's firmware from a fairly old version (1.4.6) to the most
recent version (1.4.12).

Firmware changelogs are available on Myricom's web site at:
http://www.myri.com/scs/CHANGES/CHANGES.myri10ge-firmware

Sponsored by: Myricom Inc.
2007-03-08 17:49:06 +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
Andrew Gallatin
b824b7d86a Work around a firmware bug where broadcast frames would be incorrectly
treated as multicast frames and filtered, but when only when "adopting"
running firmware.  By "adopting", I mean using pre-existing firmware
loaded from eeprom at PCI reset, rather than firmware loaded by the
driver.
2007-02-21 17:34:05 +00:00
Luigi Rizzo
33d5497079 Cleanup and document the implementation of firmware(9) based on
a version that i posted earlier on the -current mailing list,
and subsequent feedback received.

The core of the change is just in sys/firmware.h and kern/subr_firmware.c,
while other files are just adaptation of the clients to the ABI change
(const-ification of some parameters and hiding of internal info,
so this is fully compatible at the binary level).

In detail:
- reduce the amount of information exported to clients in struct firmware,
  and constify the pointer;

- internally, document and simplify the implementation of the various
  functions, and make sure error conditions are dealt with properly.

The diffs are large, but the code is really straightforward now (i hope).

Note also that there is a subtle issue with the implementation of
firmware_register(): currently, as in the previous version, we just
store a reference to the 'imagename' argument, but we should rather
copy it because there is no guarantee that this is a static string.
I realised this while testing this code, but i prefer to fix it in
a later commit -- there is no regression with respect to the past.

Note, too, that the version in RELENG_6 has various bugs including
missing locks around the module release calls, mishandling of modules
loaded by /boot/loader, and so on, so an MFC is absolutely necessary
there.  I was just postponing it until this cleanup to avoid doing
things twice.

MFC after: 1 week
2007-02-15 17:21:31 +00:00
Andrew Gallatin
dce01b9b27 - Add 99% of a callout based watchdog. The remaining 1% is waiting
for pci_cfg_restore() to be exported.  It was tested using a
  hackily accessed pci_cfg_restore().

- Add ifmedia_removeall() to mxge_detach() in order to stop leaking
  an ifaddr

- Fix a small acounting bug introduced by the locking code shuffle
  which could cause spurious watchdog resets now that we have a
  watchdog.

Sponsored by: Myricom
2007-01-31 19:53:36 +00:00
Andrew Gallatin
c265717682 destroy busdma maps even if they are NULL, so as to avoid leaking
busdma tags.
2007-01-31 15:47:44 +00:00
Andrew Gallatin
a98d6cd71c Abandon using sleepable locks in favor of mutexes for mxge's if_ioctl
locking in preparation for adding a watchdog handler (callouts must
not use sleepable locks).  This required shuffling memory and
interrupt allocation to the attach routine rather than if_ioctl so as
to avoid potential sleeps while bringing up the interface.
2007-01-31 15:29:31 +00:00
Andrew Gallatin
a82c2581b5 Minor updates:
- initialize ifq_drv_maxlen correctly
- mark the interface as jumbo capable
- keep stats on the number of times the hw transmit queue filled and
  was restarted.
2007-01-30 08:39:44 +00:00
Andrew Gallatin
a1480dfbad Fix mxge_submit_8rx() to behave like the comments says it does,
and ensure that it copies at most 32 bytes at a time.
2006-11-29 15:30:39 +00:00
Andrew Gallatin
a8ebcb1bc0 Fix transposition of width and value arguments to pci_config_write()
when setting up the read request size.

Pointed out by: kmacy
2006-11-22 18:47:24 +00:00