freebsd-dev/sys/pci
Bill Paul d1b5b058f7 This commit adds a software workaround for a hardware bug in certain PNIC
chip revisions. (A buggy taiwanese chip? I'm just shocked; shocked I tell
you.) So far I have only observed the anomalous behavior on board with
PCI revision 33 chips. At the moment, this seems to include only the
Netgear FA310-TX rev D1 boards with chips labeled NGMC169B. (Possibly this
means it's an 82c169B part from Lite-On.)

The bug only manifests itself in promiscuous mode, and usually only at
10Mbps half-duplex. (I have not observed the problem in full-duplex mode,
and I don't think it ever happens at 100Mbps.) The bug appears to be in
the receiver DMA engine. Normally, the chip is programmed with a linked
list of receiver descriptors, each with a receive buffer capable of holding
a complete full-sized ethernet frame. During periods of heavy traffic
(i.e. ping -c 100 -f 8100 <otherhost>), the receiver will sometimes appear
to upload its entire FIFO memory contents instead of just uploading the
desired received frame. The uploaded data will span several receive
buffers, in spite of the fact that the chip has been told to only use
one descriptor per frame, and appears to consist of previously transmitted
frames with the correct received frame appended to the end.

Unfortunately, there is no way to determine exactly how much data is
uploaded when this happens; the chip doesn't tell you anything except the
size of the desired received frame, and the amount of bogus data varies.
Sometimes, the desired frame is also split across multiple buffers.

The workaround is ugly and nasty. The driver assembles all of the data
from the bogus frames into a single buffer. The receive buffers are always
zeroed out, and we program the chip to always include the receive CRC
at the end of each frame. We therefore know that we can start from the
end of the buffer and scan back until we encounter a non-zero data byte,
and say conclusively that this is the end of the desired frame. We can
then subtract the frame length from this address to determine the real
start of the frame, and copy it into an mbuf and pass it on.

This is kludgy and time consuming, but it's better than dropping frames.
It's not too bad since the problem only happens at 10Mbps.

The workaround is only enabled for chips with PCI revision == 33. The
LinkSys LNE100TX and Matrox FastNIC 10/100 cards use a revision 32 chip
and work fine in promiscuous mode. Netgear support has confirmed that
they "have some previous knowledge of problems in promiscuous mode" but
didn't have a workaround. The people at Lite-On who would be able to
suggest a possible fix are on vacation. So, I decided to implement a
workaround of my own until I hear from them. I suppose this problem made
it through Netgear's QA department since Windows doesn't normally use
promiscuous mode, and if Windows doesn't need the feature than it can't
possibly be important, right? Grrr.
1998-12-31 17:19:21 +00:00
..
adv_pci.c Staticize the overrun buffer so that they are not shared between 1998-12-22 18:14:15 +00:00
adw_pci.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
ahc_pci.c Pull in new ccb_hdr list types. 1998-12-15 08:24:45 +00:00
brktree_reg.h Brooktree driver ported to the new I2C framework. See iicbus(4) for more info. 1998-10-31 11:26:38 +00:00
brooktree848.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
bt848_i2c.c Return to previous check_for_i2c_devices() behaviour. 1998-11-07 14:30:48 +00:00
bt848_i2c.h Brooktree driver ported to the new I2C framework. See iicbus(4) for more info. 1998-10-31 11:26:38 +00:00
bt_pci.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
cy_pci.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
cy_pcireg.h
dc21040reg.h
dpt_pci.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
dpt_pci.h
es1370_reg.h Add Joachim Kuebart's ES1370 driver. With my Shuttle HOT-255 card, 1998-12-31 08:14:27 +00:00
es1370.c Add Joachim Kuebart's ES1370 driver. With my Shuttle HOT-255 card, 1998-12-31 08:14:27 +00:00
ide_pci.c Check for DMA capbility is against unit,not controller. 1998-12-21 08:55:56 +00:00
ide_pcireg.h
if_de.c Silence -Wtrigraph. 1998-12-30 00:37:44 +00:00
if_devar.h If this is going to have checks for kernel versions, it might as well 1998-11-06 02:13:14 +00:00
if_ed_p.c pci_device pd_probe function changed from returning char * to returning 1998-12-14 05:47:29 +00:00
if_en_pci.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
if_fpa.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
if_fxp.c pci_device pd_probe function changed from returning char * to returning 1998-12-14 05:47:29 +00:00
if_fxpreg.h
if_fxpvar.h
if_lnc_p.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
if_mx.c One more time: another case where we need to trim the CRC manually. 1998-12-24 19:10:05 +00:00
if_mxreg.h Put back some missing chip identification code that got lost somehow 1998-12-04 21:48:12 +00:00
if_pn.c This commit adds a software workaround for a hardware bug in certain PNIC 1998-12-31 17:19:21 +00:00
if_pnreg.h This commit adds a software workaround for a hardware bug in certain PNIC 1998-12-31 17:19:21 +00:00
if_rl.c Grrrr... The RealTek 8139 is yet another chip that includes the ethernet 1998-12-24 18:39:48 +00:00
if_rlreg.h if_rl.c: make a small tweak to properly handle the Accton MPX 5030/5038 1998-12-07 00:35:06 +00:00
if_sr_p.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
if_tl.c Fix the tl_start() routine; sometimes the tl_tx_tail pointer was not 1998-12-29 15:39:35 +00:00
if_tlreg.h Increase the size of the tx and rx rings from 10 to 20 descriptors 1998-10-31 17:23:48 +00:00
if_tx.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
if_txvar.h Ported to OpenBSD. sys/pci/smc83c170.h renamed to sys/pci/if_txvar.h to be 1998-11-01 07:44:33 +00:00
if_vr.c The VIA Rhine appears to be yet another chip that always includes the 1998-12-24 18:03:17 +00:00
if_vrreg.h An early Christmas present: add driver support for a whole bunch of 1998-12-04 18:01:24 +00:00
if_vx_pci.c vxalloc() can return NULL. Deal with it. 1998-12-16 00:38:57 +00:00
if_wb.c Trim the ethernet CRC from received frames manually in wb_rxeof(). 1998-12-19 04:19:44 +00:00
if_wbreg.h An early Christmas present: add driver support for a whole bunch of 1998-12-04 18:01:24 +00:00
if_xl.c Fix a small bug in xl_start(): when queuing a packet onto the end of 1998-12-24 17:50:34 +00:00
if_xlreg.h Close PR #8384: 1998-10-22 15:52:25 +00:00
isp_pci.c clarify headers;ansify 1998-12-28 19:24:23 +00:00
locate.pl
meteor_reg.h
meteor.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
ncr.c Silence -Wtrigraph. 1998-12-30 00:37:44 +00:00
ncrreg.h
pci_compat.c pci_device pd_probe function changed from returning char * to returning 1998-12-14 05:47:29 +00:00
pci_ioctl.h
pci.c s/%#p/%p/ to fix a warning. This looks like a leftover of once being 1998-11-09 08:08:06 +00:00
pcic_p.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
pcic_p.h
pcireg.h
pcisupport.c Turn the VIA chipset ,<<IDE/USB>> controller probing off. 1998-12-27 07:59:25 +00:00
pcivar.h pci_device pd_probe function changed from returning char * to returning 1998-12-14 05:47:29 +00:00
README.bt848
scsiiom.c
simos.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
simos.h
wdc_p.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00
xrpu.c probe function changed from returning char * to const char *. 1998-12-14 06:37:37 +00:00

-------------------------------------------------------------------------------
Recent versions of 3.0-current have the bktr driver built in.  Older versions
of 3.0 and all versions of 2.2 need to have the driver files installed by hand:

cp ioctl_bt848.h /sys/i386/include/
cp brktree_reg.h brooktree848.c /sys/pci/

In /sys/conf/files add:
pci/brooktree848.c        optional bktr device-driver

-------------------------------------------------------------------------------
In all cases you will need to add the driver to your kernel:

In your kernel configuration file:
controller      pci0     #if you already have this line don't add it.
device          bktr0    

There is no need to specify DMA channels nor interrupts for this
driver.

-------------------------------------------------------------------------------
Finally you need to create nodes for the driver:

Create a video device:
mknod /dev/bktr0 c 92 0

Create a tuner device:
mknod /dev/tuner0 c 92 16

-------------------------------------------------------------------------------
The code attempts to auto-probe code to detect card/tuner types.
The detected card is printed in the dmesg as the driver is loaded.  If
this fails to detect the proper card you can override it in brooktree848.c:

#define OVERRIDE_CARD	<card type>

where <card type> is one of:
	CARD_UNKNOWN
	CARD_MIRO
	CARD_HAUPPAUGE
	CARD_STB
	CARD_INTEL

-------------------------------------------------------------------------------
This model now separates the "tuner control" items into a minor device:

minor device layout:  xxxxxxxx xxxT UUUU

 UUUU:   the card (ie UNIT) identifier, 0 thru 15
 T == 0: video device
 T == 1: tuner device

Access your tuner ioctl thru your tuner device handle and anything
which controls the video capture process thru the video device handle.

Certain ioctl()s such as video source are available thru both devices.

-------------------------------------------------------------------------------
If your tuner does not work properly or is not recognized properly
try setting the tuner type via or card type:
sysctl -w hw.bt848.card=<integer> current valid values are 0 to 5 inclusive
sysctl -w hw.bt848.tuner=<integer> where integer is a value from 1 to 10
systcl -w hw.bt848.reverse_mute=<1 | 0> to reverse the mute function in the
                                driver set variable to 1.
The exact format of the sysctl bt848 variable is:
unit << 8 | value

unit identifies the pci bt848 board to be affected 0 is the first bt848 
board, 1 is the second bt848 board.
value denotes the integer value for tuners is a value from 0 to 10 for
reversing the mute function of the tuner the value is 1 or 0.

to find out all the bt848 variables:
sysctl hw.bt848



-------------------------------------------------------------------------------
The bt848 driver consists of:

src/sys/i386/include/ioctl_bt848.h
src/sys/pci/brktree_reg.h
src/sys/pci/brooktree848.c