Commit Graph

45 Commits

Author SHA1 Message Date
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
Andrew Gallatin
d91b1b4976 Initialization bugfixes and enhancements:
- Fix bug preventing adoption of running firmware
- Set PCIe max read request size to 4KB
- Read PCIe link width from config space
- Assume aligned completions from the southbridge ports
  of intel E5000 chips
- Use aligned firmware when link width is x4 or less
- Add hw.mxge.force_firmware tunable to allow user to force
  selection of aligned (or unaligned) firmware
2006-11-22 16:33:40 +00:00
Andrew Gallatin
dc8731d4d2 Added MSI support.
Sponsored by: Myricom Inc.
2006-11-21 15:55:01 +00:00
Andrew Gallatin
b4db900931 Fix a driver bug which could result in frames MHLEN or (MHLEN - 1) bytes
long being DMA'ed 2 (or 1) bytes past the end of the mbuf and corrupting
random kernel memory.  I had forgotten about the 2 bytes of implict
padding the firmware assumes.

Sponsored by: Myricom Inc.
2006-10-17 14:39:19 +00:00
Andrew Gallatin
0fa7f68197 - Updated to the latest myri10ge firmware
- Added support for multicast filtering, now that the firmware
  supports it.  Note that this is not yet tested, as multicast
  seems to panic -current (even w/o mxge loaded)
- Added workaround to cope with different irq data struct size on
  pre-multicast firmware which can found running on nics.
- Added Intel E5000 PCIe chipsets to list providing aligned completions.
- Replaced various magic constants with #defines, now that they are
  defined in the firmware headers.
2006-09-15 19:24:45 +00:00
Andrew Gallatin
aed8e389c1 - Added TSO support. This entailed increasing the number of send descriptors
in the transmit busdma tag, so I moved the segment list off the
stack.

- Fixed transmit routine to ensure it doesn't read past the end
of an mbuf when parsing headers.

- Corrected handling of odd length segments.  Setting MXGEFW_FLAGS_ALIGN_ODD
is required only when offloading the checksum of that frame.

Sponsored by: Myricom Inc.
2006-09-15 15:41:28 +00:00
Andrew Gallatin
7d542e2d80 Copy the link-layer address from our ifnet pointer at reset time
so that the mac address can be overridden.
2006-08-04 17:58:40 +00:00
Andrew Gallatin
091feecd12 - add read only sysctl to indicate if write-combining was enabled
- enable mxge_dummy_rdma() right after reset, and make sure to disable
  when detaching the driver.
2006-08-01 14:02:54 +00:00
Andrew Gallatin
4da0d523f9 Firmware loading improvements:
- Copy ethernet firmware down in small chunks so as to avoid bugs
  in early versions of the bootstrap firmware.
- Attempt to "adopt" the running firmware if we cannot load a suitable
  firmware image via firmware(9).
- Separate firmware validation into its own routine, and check the
  major/minor driver/firmware ABI version.
2006-07-17 22:17:05 +00:00
Andrew Gallatin
6d914a32ff Much to my surprise, IFQ_DRV_DEQUEUE() can return a null mbuf even if
!IFQ_DRV_IS_EMPTY().  Taking this into account,  I re-structured the
transmit routine so as to avoid adding another if/then in the
critical path.

Thanks to brueffer for showing my how to test with altq/pf.
2006-06-14 19:32:00 +00:00
Andrew Gallatin
76bb9c5edb Replace a sc->ifp->if_snd.ifq_drv_maxlen with IFQ_SET_MAXLEN(),
and call IFQ_SET_READY().

Submitted by: brueffer
2006-06-14 17:52:30 +00:00
Andrew Gallatin
5e7d85418b Update the mxge driver.
- Update the firmware to the latest released firmware
  (1.4.3), which corresponds to the firmware in the
  latest shipping drivers from Myricom.  This firmware
  fixes several bugs in the firmware's PCI-e implementation,
  and it also changes the driver/firmware interface:

  o TSO was added, and changed the format of the transmit
    descriptors.
  o The firmware no longer counts transmits descriptors,
    but frames.  So the driver needs to keep a count
    of the number of frames sent.
  o The weird interrupt strategy changed to a normal receive
    return ring.  This ring is much bigger, and we may be
    able to support DEVICE_POLLING.
  o Myricom's header files changed the name of firmware
    related #define's and enums (s/_MCP_/FW_).

- Stopped spamming the console with lots of printfs unless
  mxge_verbose (or bootverbose) is set.

- Made additional information available via sysctl, including
  the results of a PCI-e DMA benchmark run at device reset.

- Decreased the excessively long timeouts when sending commands
  from 2 seconds to 20ms.

Sponsored by: Myricom Inc.
2006-06-14 16:23:17 +00:00
Andrew Gallatin
6d87a65da4 - Complete the myri10ge -> mxge name change by doing a mechanical
s/myri10ge/mxge/g replacement in the myri10ge files.  A few contuation
  lines were joined because of the regained columns.
- Hook the mxge driver back to the build.
2006-06-13 13:53:52 +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
Andrew Gallatin
b2fc195e1b 10GbE mode driver and binary firmware for Myricom's PCI-express NICs.
More info regarding these nics can be found at http://www.myri.com.

Please note that the files
sys/dev/myri10ge/{mcp_gen_header.h,myri10ge_mcp.h} are internally
shared between all our drivers (solaris, macosx, windows, linux, etc).
I'd like to keep these files unchanged, so I can just import newer
versions of them when the firmware API/ABI changes.  This means I'm
stuck with some of the crazy-long #define names, and possibly
non-style(9) characteristics of these files.

Many thanks to mlaier for doing firmware(9) just as I
needed it, and to scottl for his helpful review.

Reviewed by: scottl, glebius
Sponsored by: Myricom Inc.
2006-02-19 22:39:19 +00:00