Home | History | Annotate | Download | only in ic
History log of /src/sys/dev/ic/rtl8169.c
RevisionDateAuthorComments
 1.179  12-Aug-2024  christos fix whitespace
 1.178  12-Aug-2024  christos PR/58588: Christos Zoulas: Avoid crashes when exiting promiscuous mode (^C
tcpdump) by disabling RX in re_stop. Also add some earlyoff stuff while here.
From FreeBSD.
 1.177  05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.176  29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.175  25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.174  01-Aug-2022  mlelstv Revert last accidental commits.
 1.173  01-Aug-2022  mlelstv Also fix shift values for SCT constants.
 1.172  25-Jun-2022  tsutsui Pass proper status values to rnd_add_uint32(9) as rnd(9) man page claims.
 1.171  24-May-2022  andvar fix various typos in comment, documentation and log messages.
 1.170  27-Jan-2022  jakllsch drop poorly phrased and redundant message about unsupported chip revisions
 1.169  31-Dec-2021  riastradh sys: Use if_init wrapper function.

Exception: Not in kern_pmf.c, for the kind of silly reason that it
avoids having kern_pmf.c refer to symbols defined only in net; this
avoids a pain in the rump.
 1.168  04-Sep-2021  jakllsch re(4): misc chip revision support changes
* remove impossible-to-match chip revision cases
* bring support for modern chips in line with FreeBSD and OpenBSD
* adds support for RTL8168GU

Addresses PR kern/56312.
 1.167  21-Sep-2020  msaitoh - Print chip revision. From OpenBSD.
- Rename RTK_HWREV_8168_SPIN[123] to RTK_HWREV_8168'B'_SPIN[123].
Same as other *BSDs.
- Rename RTK_HWREV_8168G_SPIN4 to RTK_HWREV_8411B. Same as other *BSDs.
- Add definition of RTK_HWREV_8169_8110SCE.
 1.166  13-Mar-2020  thorpej Use BUS_ADDR_{LO,HI}32().
 1.165  12-Mar-2020  thorpej Add support for MBUFTRACE.
 1.164  07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.163  04-Feb-2020  thorpej Use ifmedia_fini().
 1.162  29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.161  17-Dec-2019  msaitoh branches: 1.161.2;
Improve some chip revisions support:

- Add 8168FP, 8411, 8168G, 8401E, 8105E, 8105E_SPIN1, 8106E and 8402 from
{Free,Open}BSD.
- Renumber RTK_HWREV_8103E from 0x24C00000 to 0x34c00000. 0x24C00000 is newly
used as RTK_HWREV_8102EL_SPIN1. Same as {Free,Open}BSD.
 1.160  22-Sep-2019  ryo 8168H model didn't link up well. some models seems to require to enable TX/RX after configuration.
RTKQ_TXRXEN_LATER quirk flag added. it may be able to unify with RTKQ_RXDV_GATED flag?
 1.159  30-May-2019  msaitoh branches: 1.159.2;
Simplify MII structure initialization and reference. No functional change.
 1.158  05-Apr-2019  uwe RTK_CFG2_BUSFREQ is only 1 byte. Fixes panic on landisk.
 1.157  22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.156  10-Jan-2019  mlelstv Fix handling of RTKQ_IM_HW quirk, the check was inverted.

Found by tho@useless-ficus.net, thanks.
Fixes PR/53858.
 1.155  13-Nov-2018  mlelstv compute interrupt timer depending on bus clock.
 1.154  26-Jun-2018  msaitoh branches: 1.154.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.153  01-Jun-2018  maxv Use m_remove_pkthdr() instead of "&= ~M_PKTHDR", to ensure the tags get
freed. Several other drivers have this problem it seems...
 1.152  26-Sep-2017  knakahara branches: 1.152.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.151  16-May-2017  snj branches: 1.151.2;
fix inverted logic.

spotted by "sc dying" on current-users.
 1.150  19-Apr-2017  jmcneill branches: 1.150.2;
Performance improvements for PCIe and 8168 based devices:
- When using the countdown timer for interrupt moderation on PCIe devices,
use a timer rate value based on a 125MHz PCIe reference clock instead of
33 MHz.
- For 8168 based devices, ditch the countdown timer and instead use the
(undocumented) hardware interrupt moderation feature.
- Support TSOv4 on 8168D and later devices.
 1.149  20-Feb-2017  ozaki-r Fix assertion failure in bpf_mtap by applying deferred if_start to re(4)

Reported by maya@
 1.148  15-Dec-2016  ozaki-r branches: 1.148.2;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.147  10-Jun-2016  ozaki-r branches: 1.147.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.146  09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.145  28-Aug-2015  nonaka Add support for Realtek RTL8168H/8111H variant.
 1.144  13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.143  22-Nov-2014  joerg branches: 1.143.2;
Drop unnecessary-but-harmful casts.
 1.142  14-Oct-2014  uwe RealTek 8139C+ incorrectly identifies UDP checksum 0xffff as bad.
Force software recalculation of UDP checksum if bad checksum is
reported by the hardware.
 1.141  10-Oct-2014  christos PR/49259: J. Lorec: Add support for Realtek 8111G chipset into re(4)
 1.140  10-Aug-2014  tls branches: 1.140.2;
Merge tls-earlyentropy branch into HEAD.
 1.139  10-May-2013  tsutsui branches: 1.139.6;
Add RNG entropy collection support of rnd(9) to re(4).
Taken from rtk(4), and briefly checked by rndctl(8).
 1.138  10-May-2013  tsutsui Make re(4) driver always use IDR register values for its MAC address.

Some sandpoint NAS firmwares set MAC address per their
firmware settings and don't use re(4)'s EEPROM values.
Per rtl8169 manuals re(4) chip reads EEPROM automatically after
hardware reset and Linux driver also uses IDR registers,
so this change should not affect existing other boards
which actually have vaild EEPROM.

Per discussion in old tech-kern@ thread:
http://mail-index.netbsd.org/tech-kern/2012/12/01/msg014573.html
Note rtl81x9.c is still shared among rtk(4) only for a multicast function
(to avoid boring refactoring work).
 1.137  06-Apr-2013  khorben Added support for the Realtek 8168F variant in re(4).

From FreeBSD; not tested on real hardware unfortunately. The manual page was adjusted as well.

No objection from current-users@, "commit it" gdt@
 1.136  22-Jul-2012  matt branches: 1.136.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.135  02-Mar-2012  nonaka Added RTL8168E/8111E-VL support.
 1.134  22-Nov-2011  garbled branches: 1.134.2; 1.134.4;
Add support to recognize the 8168E model of this chip. Taken from FreeBSD
 1.133  28-Jul-2010  msaitoh branches: 1.133.8;
The ETHERCAP_VLAN_HWTAGGING flag is not a member of if_cap but ec_cap,
so fix it.
 1.132  27-Jul-2010  jakllsch Make the Realtek PCI network interfaces detachable.
Use __arraycount to avoid null table entries.
Miscellaneous other touch-ups in bus front-ends.
 1.131  09-Apr-2010  nonaka Added 8110SBL support.
 1.130  05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.129  19-Jan-2010  pooka branches: 1.129.2; 1.129.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.128  15-Sep-2009  dyoung Simplify activation routines: do not call mii_activate(), it is a
no-op. Do not block interrupts, if_deactivate() will take care of
that for us.
 1.127  05-Sep-2009  tsutsui Remove one more extra whitespace.
 1.126  05-Sep-2009  tsutsui Remove unnecessary whitespace.
 1.125  02-Sep-2009  tsutsui Move pmf(9) calls to MI re_attach() and re_detach() from each backend.
 1.124  31-Aug-2009  tsutsui Treat 8168DP as well as 8168C/CP/D. From FreeBSD.
 1.123  29-Aug-2009  tsutsui - no need to include "vlan.h" since no NVLAN reference
- whitespace in comment
 1.122  27-Aug-2009  tsutsui Remove an unnecessary assignment. No binary change.
 1.121  31-May-2009  tsutsui Two fixes for RX hwcsum on DESCV2 chips:
* On checking TCPv4/UDPv4 RX checksum on DESCV2 chips, also check
RE_RDESC_VLANCTL_IPV4 bit because those DESCV2 chips may also recognize
IPv6 packets and set RE_PROTOID_TCPIP or RE_PROTOID_UDPIP bits for
TCPv6/UDPv6 packets. This may fix PR kern/40605.
* According to Realtek's Linux driver, DESCV2 chips don't set RE_PROTOID_IP
for non-TCP/UDP IP packets (set only RE_RDESC_VLANCTL_IPV[46]) so
remove PROTOID check for IPv4 RX cheksum on DESCV2 chips.
 1.120  12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.119  11-May-2009  tsutsui - rename RTK_HWREV_8102EL_SPIN2 -> RTK_HWREV_8103E
- add a HWREV value for 8168DP
Per Realtek's Linux drivers.
 1.118  03-May-2009  tsutsui Remove unused sc_rev settings (all quirks are handled by sc_quirk)
and merge HWREV cases which have the same quirks.
 1.117  29-Apr-2009  tsutsui Pull some changes for newer chips from FreeBSD:
- pull MACSTAT and CMDSTOP quirks for 8168/8111 chips
- always set CPLUSCMD_PCI_MRW on reset
- set VLANSTRIP and RXCSUM_ENB bits on CPLUS register per if_capenable

Tested on 8111C and 8111D by several users, and
no bad side effect on my old 8169S.
 1.116  13-Apr-2009  tsutsui Assume an unknown HWREV chip has the same features with the latest one.
 1.115  13-Apr-2009  tsutsui Add HWREV of RTL8102EL variant. From FUKAUMI Naoki.
 1.114  13-Apr-2009  tsutsui Add HWREV values of RTL8168CP and RTL8168D. From FreeBSD.

XXX: needs more quirk handling after wakeup for newer chips.
 1.113  28-Mar-2009  tsutsui Fix another botch in hwcsum changes for PR kern/40955:
8168/8111/8168B/8111B doesn't have DESCV2.

Problem reported by Arto Huusko on current-users@.
 1.112  27-Mar-2009  tsutsui Check a correct bit for ip4csum-rx. Reported privately on PR kern/40955.
 1.111  21-Mar-2009  tsutsui Add another quirk flag which shows availability of EEPROM command register.

Now we can remove sc_rev which was intended to represent "MAC revision"
used in the Realtek driver.
 1.110  21-Mar-2009  tsutsui Add and use a new quirk flag to disable JUMBO MTU,
rather than checking sc_rev values.
 1.109  21-Mar-2009  tsutsui Add hardware checksum support for newer PCIe 8168/8111/8102 chips,
per device info taken from FreeBSD driver. Tested by snj@ on 8111C.

Should closes PR kern/40955.

Note on old 8169 chips IP hw csum must be enabled to use TCP/UDP hw csums,
but I'm not sure if these newer chips still have the same restriction.
 1.108  20-Mar-2009  tsutsui Access LDPS register in re_reset() only on 8169S single chip variants.
From OpenBSD and FreeBSD drivers via PR kern/41009, and
Realtek-supplied FreeBSD driver.
 1.107  03-Jan-2009  yamt branches: 1.107.2;
remove extra semicolons.
 1.106  08-Dec-2008  alc Add support for a 8168C/8111C revision

- also disable jumbo frame on this adapter following the FreeBSD driver
- merge redundant call to aprint_error_dev
 1.105  23-Aug-2008  tnn branches: 1.105.2; 1.105.4;
Add support for the Realtek 8102E/8102EL PCIe 10/100 Ethernet devices.
From FreeBSD.
 1.104  06-May-2008  tsutsui branches: 1.104.2; 1.104.6;
- use RTK_IDR[0-5] registers to get MAC address on RTL8168C
- change sc_rev numbers to match quirk numbers used in Realtek's driver
- tweak some register definitions
Taken from Realtek's FreeBSD driver.

Untested yet on 8168C, but no bad sideeffect on older chips.
 1.103  29-Apr-2008  tsutsui Fix a leakage on device_t/softc split. PR kern/38541 from HITOSHI OSADA.
 1.102  25-Apr-2008  tsutsui branches: 1.102.2;
Split device_t/softc for re(4) and rtk(4).
 1.101  18-Apr-2008  tsutsui - use aprint_*() variants only in functions called during autoconf(9)
- wrap long lines
 1.100  18-Apr-2008  joerg NetBSD has no such thing as DEVICE_POLLING, so remove it.
 1.99  08-Apr-2008  cegger branches: 1.99.2;
use aprint_*_dev and device_xname
 1.98  18-Mar-2008  tsutsui It looks vlan tag info must appear not only in the first descriptor
but in all descriptors of a multi-descriptor transmission attempt on re(4).

Problem was reported and fix was confirmed by Chris Brookes on tech-net.
Should also close PR kern/37959.
 1.97  14-Mar-2008  tsutsui Don't fetch DMA descriptor after BUS_DMASYNC_PREREAD op.
 1.96  07-Feb-2008  dyoung branches: 1.96.2; 1.96.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.95  04-Feb-2008  tsutsui FreeBSD says "16 bits" comment about RTK_GTXSTART was incorrect.
Use CSR_WRITE_1() for it. (though the previous code also worked)
 1.94  03-Feb-2008  tsutsui No need to preserve RE_NTXDESC_RSVD on re_start().
 1.93  19-Jan-2008  dyoung Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.92  08-Jan-2008  joerg Short-cut interrupt processing if device has been suspended.
uvm_fault reported by xtraeme.
 1.91  11-Dec-2007  lukem use __KERNEL_RCSID()
 1.90  09-Dec-2007  jmcneill branches: 1.90.2;
Merge jmcneill-pm branch.
 1.89  19-Oct-2007  ad branches: 1.89.2; 1.89.4; 1.89.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.88  27-Aug-2007  dyoung branches: 1.88.2; 1.88.6;
Constify: use CLLADDR() instead of LLADDR() wherever possible.
 1.87  19-Aug-2007  tsutsui FALSE -> false, TRUE -> true
 1.86  09-Jul-2007  ad branches: 1.86.2; 1.86.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.85  10-May-2007  tsutsui Pull a fix for PCIe variants from FreeBSD's if_re.c rev 1.71:

> - With the PCIe devices, it looks issuing a TX command while there's
> already a transmission in progress doesn't have any effect. In other
> words, if you send two packets in rapid succession, the second one may
> end up sitting in the TX DMA ring until another transmit command is
> issued later in the future. Basically, if re_txeof() sees that there
> are still descriptors outstanding, it needs to manually resume the
> TX DMA channel by issuing another TX command to make sure all
> transmissions are flushed out. (The PCI devices seem to keep the
> TX channel moving until all descriptors have been consumed. I'm not
> sure why the PCIe devices behave differently.)
 1.84  21-Mar-2007  tsutsui Cleanup handling of quikrs on each RealTek chip:
- replace rtk_type member in rtk_softc which has chip types
with new rtk_quirk that represents quirks on each chip:
- RTKQ_8129 doesn't have internal MII (used in rtk(4))
- RTKQ_8139CPLUS has different register layout (for re(4))
- RTKQ_8169NONS (original 8169) requires some settings on init
- RTKQ_PCIE requires different settings in setmulti
so that we don't have to check each hwrev values or types everywhere
and newer variants will also work without changes if they don't
have other quirks
(sc_rev is unchenged for now for reference to the Realtek's driver)
- don't check hwrev register in re_pci_match() but check
only PCI_VENDER(), PCI_PRODUCT() and PCI_REVISION()
so that we no longer have to map pci space there
- add a new HWREV value for another 8168 variant
- try to map PCI mem space more properly
- remove (probably unneeded) ifp->if_baudrate initialization

Tested on a newer 8168 variant by Dennis den Brok on tech-kern,
and also tested on 8139 and 8169C on macppc, and 8139C+ on landisk
by me.
 1.83  04-Mar-2007  christos branches: 1.83.2; 1.83.4; 1.83.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.82  21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.81  15-Feb-2007  tsutsui branches: 1.81.2;
Don't set RTK_CFG1_FULLDUPLEX bit in RTK_CFG1 register
since it's available only on RTL8129. From FreeBSD.

As defined in rtl81x9reg.h, bits of 0x80 and 0x40 in RTK_CFG1
seem to indicate LEDS0 and LEDS1 configuration initialized by
EEPROM settings, and they seem read only on my quick tests with
two 8169S based cards.
 1.80  15-Feb-2007  tsutsui Use new RTK_HWREV_8100E_SPIN2 macro. (missed in the previous)
 1.79  10-Feb-2007  tsutsui Clear IFF_OACTIVE in re_txeof() only if there are more than RE_TXDESC_RSVD
free TXDESCs. From FreeBSD, but I'm still wondering why we have to reserve
some free TXDESCs even on re_start().
 1.78  04-Feb-2007  tsutsui - check more hwrev and use HWREV_* macro. From Realtek driver
via Darrin B.Jewell.
XXX: maybe we should check this sc_rev on more place
- use RTK_TXCFG_HWREV (0x7cc00000) rather than 0x7c800000
to mask the hwrev value since bit 0x00400000 is used only by 8139D
which is not supported by this driver
- fix a tyop
 1.77  29-Jan-2007  tsutsui Fix EEPROM functions for RTL8169SC chips:

rtl81x9.c:
Increase delay on EEPROM access since EEPROM on RTL8169 based board
seems to require slower clock. Also use common EE_DELAY() macro.

rtl8169.c:
Use common rtk_read_eeprom() function to get Ethernet address on
8169 chips because EEMODE_AUTOLOAD command was a workaround on
original FreeBSD's driver and it doesn't work on 8169SC.

Problem reported and fix tested by Frank Lorenzen on current-users,
and also tested on 8139C with rtk(4) driver by me.
 1.76  26-Dec-2006  tsutsui Wrap a sanity check in re_newbuf() with #ifdef DIAGNOSTIC and
make it fatal on failure.
 1.75  26-Dec-2006  tsutsui Use __predict_false() in several conditionals.
 1.74  16-Dec-2006  tsutsui Fix and reenable HW VLAN tagging on re(4):
- clear re_vlanctl in DMA descriptors before starting TX and RX
to avoid stale tags
- use bswap16() rather than be16toh() or htons() on VLAN tag access
since we already use htole32()

Closes PR kern/32643 and also fixes HW VLAN tagging on big endian machines.
 1.73  06-Dec-2006  tsutsui No need to include PCI header files.
 1.72  29-Nov-2006  tsutsui branches: 1.72.2;
Remove mii_mediachg() call from re_init().
It causes a few second TRX stalls on each ioctls
(on ifconfig(8) or tcpdump(8) etc.) and PHY seems
initialized properly without it at least on RTL8169S
with internal rgephy(4) PHY. Closes PR kern/34517.

XXX: maybe we should also test this on the original RTL8169
with external makphy(4).
 1.71  25-Nov-2006  tsutsui - add RE_RX_DMAMEM_SZ macro to hide a bit confusing hack
(allocating TX padding buffer in RX DMA mem to save resouces)
and use it where appropriate
- add a comment about the hack in re_attach() too
- pass a correct size on bus_dmamem_unmap() for RX DMA mem
 1.70  24-Nov-2006  tsutsui Change RXFIFO, RXDMA and TXDMA configrations to values taken from
the Reaktek's driver, which are also used in FreeBSD.
Fixes RX FIFO overrun errors on my Duron 1300MHz PC.
(Note the configuration values for rtk(4) are not changed)

Also add some debug printf's in RX error case (disabled by default).
 1.69  22-Nov-2006  tsutsui Umm, fix typo.
 1.68  18-Nov-2006  tsutsui No need to check ifp->if_capenable on RX checksumming.
 1.67  18-Nov-2006  tsutsui Fix some comments.
 1.66  18-Nov-2006  tsutsui Replace magic numbers with macro.
 1.65  18-Nov-2006  tsutsui Use bitmask ops rather than modulo in RE_NEXT_*() macro since
we can assume each number of descriptors and TX queue is a power of two.
 1.64  17-Nov-2006  tsutsui Prepare and use an inline function which sets 64 bit DMA address into
struct re_desc to avoid unnecessary 64 bit arithmetic on ILP32 ports.
 1.63  17-Nov-2006  tsutsui Add a workaround for hardware ip4csum-tx bug on re(4) chips.

See discussion on tech-kern and tech-net for details:
http://mail-index.netbsd.org/tech-net/2006/10/21/0000.html
http://mail-index.netbsd.org/tech-net/2006/11/04/0003.html
http://mail-index.netbsd.org/tech-net/2006/11/07/0002.html
http://mail-index.netbsd.org/tech-net/2006/11/12/0000.html
etc.
 1.62  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.61  12-Nov-2006  tsutsui Replace RTK_ETHER_ALIGN with RE_ETHER_ALIGN, which I missed.
Pointed out by dieter roelants in PR kern/35041.
 1.60  12-Nov-2006  tsutsui Remove an extra semicolon.
 1.59  12-Nov-2006  tsutsui - merge re_encap() into re_start() so that we can handle each error case
more flexible
- account a number of free txq and use it to see if packets are queued or sent
- assume free TX descriptors are not owned by the chip in re_start() and
panic if there is any inconsistency on them #ifdef DIAGNOSTIC case.
- replace a magic number (reserved TX descs?) with macro
 1.58  11-Nov-2006  tsutsui Minor style tweaks in re_txeof().
 1.57  11-Nov-2006  tsutsui Some minor tweaks in re_intr():
- check status bits at once (I'm not sure how gcc optimized them though)
- no need to check (ifp->if_flags & IFF_UP) twice
(re_init() must be called at splnet() anyway)
- call re_start() only if the interrupt is actually handled here
- call re_start() directly rather than via (*ifp->if_start)()
 1.56  11-Nov-2006  tsutsui Clear a TX timeout only if all queued packets are handled.
 1.55  11-Nov-2006  tsutsui Remove a leftover comment.
(note bus_dmamap_sync(9) is still needed even if no changes are made to
DMA descriptors but once they are fetched into the CPU cache)
 1.54  11-Nov-2006  tsutsui - set descriptor DMA addresses before enabling TX and RX
- set RTK_EARLY_TX_THRESH before starting TX and RX
 1.53  10-Nov-2006  tsutsui Call re_reset() after re_stop() in re_init().
Without this, re(4) on my macppc sometimes falls into mangled state
and generates many errors after ifconfig(8) or tcpdump(8) etc.
 1.52  05-Nov-2006  tsutsui Rename prefixes of re(4) specific macro and structure members
from RTK_ or rtk_ to RE_ or re_ for maintainability of these sources.
Eventually we should split these files (and struct rtk_softc) into
three elements, rtk(4) specific one, re(4) specific one, and a common
(register definitions, eeprom and multicast functions etc) part.

While here, add a couple of comments around weird definitions.
 1.51  03-Nov-2006  tsutsui Pull a 8139C+ fix from FreeBSD if_re.c rev 1.73:
Ignore BMCR_LOOP and BMCR_ISO bits which have different meanings on 8139C+.

Tested by Brian A. Seklecki.
 1.50  28-Oct-2006  tsutsui Put common data for each RX DMA descriptor into a new rxsoft structure
for micro optimization.
 1.49  27-Oct-2006  tsutsui Remove redundant byteswap ops.
 1.48  24-Oct-2006  tsutsui Set RTK_RDESC_CMD_OWN in rtk_cmdstat of RX DMA descriptor after
all other descriptor data is written to avoid possible race condition.
 1.47  22-Oct-2006  tsutsui Rename RTK_[TR]X_DESC_INC() macro to RTK_NEXT_[TR]X_DESC() and
change them to return rvalues to avoid possible side effects.
Also define RTK_NEXT_TXQ() for rtk_txq index and use it as well.
 1.46  22-Oct-2006  tsutsui Rename a variable to clarify meaning of index.
 1.45  21-Oct-2006  tsutsui Tweak TX descriptor setup code in re_encap() to make it more readable a bit.
 1.44  21-Oct-2006  tsutsui Use aprint_error(9) to print error messages.
 1.43  21-Oct-2006  tsutsui Use CSR_WRITE_1() to write RTK_TXSTART register because it is localted
at an odd address (0xd9) and noted "8 bit" in rtl81x9reg.h.

XXX: FreeBSD and OpenBSD also use CSR_WRITE_1() to write RTK_GTXSTART
XXX: for 8169 even though there is a "16 bits" comment at GTXSTART macro.
XXX: Which is correct?
 1.42  20-Oct-2006  tsutsui In re_newbuf():
- adjust m_data and m_len directly rather than calling m_adj(9)
- more cosmetics
 1.41  20-Oct-2006  tsutsui KNF, remove register decls, TAB/space cosmetics etc.
 1.40  20-Oct-2006  tsutsui u_intNN_t -> uintNN_t
 1.39  20-Oct-2006  tsutsui Use BUS_DMA_COHERENT on mapping DMA memory for TX/RX descriptors.
I can't think of a good way to avoid race condition between writeback and
DMA write against descriptors if cachelinesize > sizeof(struct rtk_desc)...

Anyway, now re(4) is functional on O2 (and probably other mips ports).
 1.38  20-Oct-2006  tsutsui Try to avoid race condition between cache writeback from CPU and DMA write
from re(4) chip as much as possible.
 1.37  20-Oct-2006  tsutsui while (1) -> for (;;)
 1.36  20-Oct-2006  tsutsui - bcopy -> memcpy
- bcmp -> memcmp
 1.35  20-Oct-2006  tsutsui There is no particular reason to use BUS_DMA_ALLOCNOW on bus_dmamap_create(9).
 1.34  20-Oct-2006  tsutsui Tweak a for() loop a bit in re_rxeof().
 1.33  20-Oct-2006  tsutsui Sync RX mbufs before setting up RX DMA descriptor.
 1.32  20-Oct-2006  tsutsui - call bus_dmamap_sync(9) against DMA descriptors more properly
- make DMA descripter members volatile
Now re(4) works on sgimips O2.

XXX: Still re(4) sometimes stalls on NFS load on sgimips,
XXX: but I'm not sure it's sgimips specific or not.
 1.31  17-Oct-2006  tsutsui DMA memory for the TX ring should be aligned at RTK_RING_ALIGN,
not RTK_ETHER_ALIGN.
 1.30  17-Oct-2006  yamt re_diag: constify.
 1.29  13-Oct-2006  yamt re_start: fix tx stall.
 1.28  13-Oct-2006  yamt re_txeof: fix watchdog timeout.
 1.27  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.26  24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.25  18-Jun-2006  rpaulo branches: 1.25.4; 1.25.6;
Use IFQ_IS_EMPTY().
 1.24  26-May-2006  blymn branches: 1.24.2;
Clean up bogus whitespace
 1.23  16-May-2006  pavel branches: 1.23.2;
Disable hw VLAN tagging, in a similar way that it was done in OpenBSD
(src/sys/dev/ic/re.c rev. 1.15). The disabled VLAN stripping is mine.
(The OpenBSD driver forgot to do this.)

The reason is that untagged packets get sometimes tagged incorrectly.
PR 32643.

Approved by martin@.
 1.22  11-Dec-2005  christos branches: 1.22.4; 1.22.6; 1.22.8; 1.22.12;
merge ktrace-lwp.
 1.21  11-Jul-2005  yamt specify dma direction hints for bus_dmamap_load_mbuf.
 1.20  19-May-2005  briggs branches: 1.20.2;
BUS_DMASYNC_* routines are from the point of view of the memory controller,
so BUS_DMASYNC_POSTREAD should follow a device->memory transfer (like for
the rx packet data.
Also, it would be good to do a BUS_DMASYNC_PREWRITE to ensure that packet
data is flushed to memory before the chip tries to transmit data.
Tested on a PowerPC system.
 1.19  15-May-2005  yamt disable IFCAP_CSUM_IPv4_Tx and comment why.
 1.18  02-May-2005  yamt split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.17  30-Mar-2005  yamt - use IFQ_POLL/DEQUEUE rather than IF_DEQUEUE/PREPEND.
- handle tx queue full correctly.
 1.16  29-Mar-2005  yamt re_encap: set RTK_TDESC_CMD_IPCSUM if any of checksum offloading is requested.
otherwise, RTK_TDESC_CMD_TCPCSUM/UDPCSUM don't seem to make any effect.
 1.15  23-Mar-2005  yamt - restructure tx descriptor handling code to decouple
number of tx descriptors, number of rx descriptors, and number of mbufs.
- bump number of tx descriptors for rtl8169. 64 doesn't seem to be sufficient
when doing TSO.
 1.14  14-Mar-2005  yamt branches: 1.14.2;
move the code to drop packets in the previous version
from re_encap to re_start so that other rtk_tx_free checks are
also covered.
 1.13  12-Mar-2005  yamt re(4) driver:
- TSO support.
- fix some error handling.
- remove mysterious RTK_NTXSEGS and use more appropriate values
for bus_dmamap_create.
- if we need more than all of our tx descriptors in order to transmit a packet,
just drop it rather than retrying infinitely.
 1.12  27-Feb-2005  perry nuke trailing whitespace
 1.11  23-Feb-2005  yamt re_init: correct usage of bus_dma(9).
now re@pci works on my alpha, in the case of !RE_USEIOSPACE.
 1.10  23-Feb-2005  yamt remove unused macros.
 1.9  20-Feb-2005  jdolecek use VLAN_* macros for VLAN tag extraction/addition
 1.8  13-Feb-2005  jdolecek don't call re_rxeof a second time when we've already done the work
pull common code out from if and else clauses

from FreeBSD if_re.c rev. 1.33
 1.7  13-Feb-2005  jdolecek g/c debug printf
 1.6  13-Jan-2005  kanaoka branches: 1.6.2; 1.6.4; 1.6.6;
- Move re_diag() from bus independend code to PCI attachment code.

XXX: I tested cardbus device,but not PCI device.
 1.5  09-Jan-2005  kanaoka sys/dev/ic/rtl8169.c:
- re_attach(): Use bus_dma* directly instead of calling re_alloc().
- re_attach(): Free bus_dma* resources if attach fails.
- re_detach(): Free bus_dma* resources.
- re_newbuf(): Remove unnecessary error check.

sys/dev/ic/rtl81x9reg.h:
- Define RTK_NTXSEGS.

sys/dev/ic/rtl81x9var.h:
- Add new members to struct rtk_list_data for bus_dma*.
 1.4  09-Jan-2005  kanaoka - Use aprint_*.
- Remove unnecesarry code.
- Changes some cosmetic.
 1.3  26-Dec-2004  kanaoka - Use ether_ioctl().
- Remove unnecessary re_init() in re_attach().
- Remove notyet compile option.
 1.2  26-Dec-2004  kanaoka - Sync if_re.c(rev=1.6).

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.1  23-Dec-2004  jonathan Snapshot of incomplete-but-working split of re(4) driver into a
bus-independent backend, with PCI and CardBus attachment code.
The committed code has two serious bugs:

1. The driver makes no attempt to recover resources when a (Cardbus)
instance is removed; bus resources are leaked.

2. In testing with a NetGear GA-511, the Cardbus card never responded
to a reset/wakeup if the card is powered down after attachment.
So for now, leave cardbus instances powered up at attachment
(insertion, or at boot if a card is already present).

That aside, it acutally works on my GA-511. Committed as-is despite
the bugs, after repeated requests to make the code available for
further testing. Also requires sys/dev/mii/miidevs rev 1.54 -> 1.55,
and consequent regen of miidevs{,_data}.h.
 1.6.6.2  26-Mar-2005  yamt sync with head.
 1.6.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.4.6  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.4.5  01-Apr-2005  skrll Sync with HEAD.
 1.6.4.4  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.4.3  15-Feb-2005  skrll Sync with HEAD.
 1.6.4.2  17-Jan-2005  skrll Sync with HEAD.
 1.6.4.1  13-Jan-2005  skrll file rtl8169.c was added on branch ktrace-lwp on 2005-01-17 19:30:40 +0000
 1.6.2.1  29-Apr-2005  kent sync with -current
 1.14.2.7  04-Oct-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1852):
sys/dev/ic/rtl81x9var.h: revision 1.39
sys/dev/cardbus/if_re_cardbus.c: revision 1.13
sys/dev/pci/if_re_pci.c: revision 1.27 via patch
sys/dev/pci/if_rtk_pci.c: revision 1.32
sys/dev/cardbus/if_rtk_cardbus.c: revision 1.32
sys/dev/ic/rtl8169.c: revision 1.84, 1.85
sys/dev/ic/rtl81x9reg.h: revision 1.27
sys/dev/ic/rtl81x9.c: revision 1.72
Cleanup handling of quikrs on each RealTek chip:
Pull a fix for PCIe variants from FreeBSD
 1.14.2.6  03-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1673):
distrib/sets/lists/man/mi 1.844, 1.871
share/man/man4/Makefile 1.372, 1.379 via patch
share/man/man4/re.4 1.8, 1.9, 1.11, 1.12
share/man/man4/rgephy.4 1.1
share/man/man4/rlphy.4 1.1, 1.2
sys/arch/amd64/conf/GENERIC 1.79, 1.89
sys/arch/amd64/conf/INSTALL 1.45, 1.49
sys/arch/i386/conf/GENERIC 1.717, 1.747
sys/arch/i386/conf/GENERIC_LAPTOP 1.164
sys/arch/i386/conf/INSTALL 1.277, 1.283
sys/arch/i386/conf/INSTALL_LAPTOP 1.96, 1.98
sys/arch/i386/conf/XEN2_DOM0 1.22 via patch
sys/arch/macppc/conf/GENERIC 1.220, 1.246
sys/arch/macppc/conf/INSTALL 1.96, 1.100
sys/dev/cardbus/if_re_cardbus.c 1.10
sys/dev/cardbus/if_rtk_cardbus.c 1.29-1.31
sys/dev/ic/rtl8169.c 1.14, 1.20, 1.24, 1.25, 1.28-1.61, 1.63, 1.64-1.81 via patch
sys/dev/ic/rtl81x9.c 1.52, 1.54-1.63, 1.65, 1.67-1.70
sys/dev/ic/rtl81x9reg.h 1.15-1.26
sys/dev/ic/rtl81x9var.h 1.19, 1.21-1.37
sys/dev/mii/files.mii 1.38
sys/dev/mii/miidevs 1.62, 1.64
sys/dev/mii/rgephy.c 1.10, 1.13-1.16
sys/dev/mii/rlphy.c 1.1, 1.6, 1.7, 1.11 via patch
sys/dev/pci/if_re_pci.c 1.13, 1.15-1.17, 1.19-1.23
sys/dev/pci/if_rtk_pci.c 1.25, 1.28, 1.29, 1.31
sys/dev/pci/pcidevs 1.851, 1.852

on re(4):
- improve stability (I believe ;-)
- add a workaround for hardware ip4csum-tx bug
- support newer chips (8169SB/SC, PCIe based 8168 etc.)
- fix 8139C+ support
- enable hardware VLAN
- misc bus_dma(9) fix (which makes re(4) work on mips ports)

on rtk(4):
- fix kern/31348
- fix possible panic on dreamcast
 1.14.2.5  31-May-2006  tron Pull up following revision(s) (requested by pavel in ticket #1340):
sys/dev/ic/rtl8169.c: revision 1.23
Disable hw VLAN tagging, in a similar way that it was done in OpenBSD
(src/sys/dev/ic/re.c rev. 1.15). The disabled VLAN stripping is mine.
(The OpenBSD driver forgot to do this.)
The reason is that untagged packets get sometimes tagged incorrectly.
PR 32643.
Approved by martin@.
 1.14.2.4  18-Aug-2005  tron Pull up revision 1.21 (requested by yamt in ticket #674):
specify dma direction hints for bus_dmamap_load_mbuf.
 1.14.2.3  04-Apr-2005  tron Pull up revision 1.17 (requested by yamt in ticket #94):
- use IFQ_POLL/DEQUEUE rather than IF_DEQUEUE/PREPEND.
- handle tx queue full correctly.
 1.14.2.2  04-Apr-2005  tron Pull up revision 1.16 (requested by yamt in ticket #92):
re_encap: set RTK_TDESC_CMD_IPCSUM if any of checksum offloading is requested.
otherwise, RTK_TDESC_CMD_TCPCSUM/UDPCSUM don't seem to make any effect.
 1.14.2.1  04-Apr-2005  tron Pull up revision 1.15 (requested by yamt in ticket #91):
- restructure tx descriptor handling code to decouple
number of tx descriptors, number of rx descriptors, and number of mbufs.
- bump number of tx descriptors for rtl8169. 64 doesn't seem to be sufficient
when doing TSO.
 1.20.2.10  24-Mar-2008  yamt sync with head.
 1.20.2.9  17-Mar-2008  yamt sync with head.
 1.20.2.8  11-Feb-2008  yamt sync with head.
 1.20.2.7  04-Feb-2008  yamt sync with head.
 1.20.2.6  21-Jan-2008  yamt sync with head
 1.20.2.5  27-Oct-2007  yamt sync with head.
 1.20.2.4  03-Sep-2007  yamt sync with head.
 1.20.2.3  26-Feb-2007  yamt sync with head.
 1.20.2.2  30-Dec-2006  yamt sync with head.
 1.20.2.1  21-Jun-2006  yamt sync with head.
 1.22.12.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.22.8.2  26-Jun-2006  yamt sync with head.
 1.22.8.1  24-May-2006  yamt sync with head.
 1.22.6.1  01-Jun-2006  kardel Sync with head.
 1.22.4.1  09-Sep-2006  rpaulo sync with head
 1.23.2.1  19-Jun-2006  chap Sync with head.
 1.24.2.1  13-Jul-2006  gdamore Merge from HEAD.
 1.25.6.3  18-Dec-2006  yamt sync with head.
 1.25.6.2  10-Dec-2006  yamt sync with head.
 1.25.6.1  22-Oct-2006  yamt sync with head
 1.25.4.4  09-Feb-2007  ad Sync with HEAD.
 1.25.4.3  01-Feb-2007  ad Sync with head.
 1.25.4.2  12-Jan-2007  ad Sync with head.
 1.25.4.1  18-Nov-2006  ad Sync with head.
 1.72.2.11  18-Aug-2009  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1339):
sys/dev/ic/rtl8169.c: revisions 1.107, 1.114, 1.115, 1.116,
1.117 (via patch), 1.118 (via patch),
1.119, 1.121
sys/dev/ic/rtl81x9reg.h: revisions 1.36, 1.37, 1.38, 1.39
sys/dev/ic/rtl81x9var.h: revision 1.47
sys/dev/mii/rgephy.c: revisions 1.16, 1.18, 1.19, 1.27 (via patch)
sys/dev/mii/rgephyreg.h: revision 1.3
sys/dev/pci/if_re_pci.c: revision 1.36
- add support for RTL8211B(L) to rgephy(4)
- add a wakeup instruction for rgephy(4) on newer re(4) chips
- detect RTL8169CP, RTL8168D/8111D, and RTL8103E variants
- fix rgephy(4) problem on RTL8111D reported on current-users:
http://mail-index.NetBSD.org/current-users/2009/04/12/msg008977.html
http://mail-index.NetBSD.org/current-users/2009/04/19/msg009096.html
- pull more quirk handling from FreeBSD
- fix RX hwcksum for DESCV2 chips for PR kern/40605
- remove "B" suffix from RTL8168 device names in attach message
 1.72.2.10  31-Mar-2009  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1297):
src/sys/dev/ic/rtl8169.c 1.104 (via patch), 1.105 (via patch),
1.106 (via patch), 1.108, 1.109 (via patch),
1.110, 1.111, 1.112, 1.113
sys/dev/ic/rtl81x9reg.h: revision 1.30 - 1.35
sys/dev/ic/rtl81x9var.h: revision 1.42 - 1.45
sys/dev/pci/if_re_pci.c: revision 1.35
Add support for 8168C/8111C/8102E chips.
Fix MAC reset issue (PR kern/41009)
Add/fix HW checksum support (PR kern/40955)
 1.72.2.9  24-Mar-2008  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1105):
sys/dev/ic/rtl8169.c: revisions 1.94, 1.95, 1.97, 1.98
sys/dev/ic/rtl81x9reg.h: revision 1.28
No need to preserve RE_NTXDESC_RSVD on re_start().
FreeBSD says "16 bits" comment about RTK_GTXSTART was incorrect.
Use CSR_WRITE_1() for it. (though the previous code also worked)
Don't fetch DMA descriptor after BUS_DMASYNC_PREREAD op.
It looks vlan tag info must appear not only in the first descriptor
but in all descriptors of a multi-descriptor transmission attempt on re(4).
Problem was reported and fix was confirmed by Chris Brookes on tech-net.
Should also close PR kern/37959.
 1.72.2.8  16-May-2007  jdc Pull up revisions 1.84-1.85 (requested by tsutsui in ticket #640).

Cleanup handling of quikrs on each RealTek chip:
- replace rtk_type member in rtk_softc which has chip types
with new rtk_quirk that represents quirks on each chip:
- RTKQ_8129 doesn't have internal MII (used in rtk(4))
- RTKQ_8139CPLUS has different register layout (for re(4))
- RTKQ_8169NONS (original 8169) requires some settings on init
- RTKQ_PCIE requires different settings in setmulti
so that we don't have to check each hwrev values or types everywhere
and newer variants will also work without changes if they don't
have other quirks
(sc_rev is unchenged for now for reference to the Realtek's driver)
- don't check hwrev register in re_pci_match() but check
only PCI_VENDER(), PCI_PRODUCT() and PCI_REVISION()
so that we no longer have to map pci space there
- add a new HWREV value for another 8168 variant
- try to map PCI mem space more properly
- remove (probably unneeded) ifp->if_baudrate initialization

Tested on a newer 8168 variant by Dennis den Brok on tech-kern,
and also tested on 8139 and 8169C on macppc, and 8139C+ on landisk
by me.

Pull a fix for PCIe variants from FreeBSD's if_re.c rev 1.71:

> - With the PCIe devices, it looks issuing a TX command while there's
> already a transmission in progress doesn't have any effect. In other
> words, if you send two packets in rapid succession, the second one may
> end up sitting in the TX DMA ring until another transmit command is
> issued later in the future. Basically, if re_txeof() sees that there
> are still descriptors outstanding, it needs to manually resume the
> TX DMA channel by issuing another TX command to make sure all
> transmissions are flushed out. (The PCI devices seem to keep the
> TX channel moving until all descriptors have been consumed. I'm not
> sure why the PCIe devices behave differently.)
 1.72.2.7  24-Feb-2007  bouyer branches: 1.72.2.7.2;
Pull up following revision(s) (requested by tsutsui in ticket #462):
sys/dev/ic/rtl8169.c: revision 1.80 - 1.81
sys/dev/ic/rtl81x9.c: revision 1.70
Use new RTK_HWREV_8100E_SPIN2 macro. (missed in the previous)
Don't set RTK_CFG1_FULLDUPLEX bit in RTK_CFG1 register
since it's available only on RTL8129. From FreeBSD.
As defined in rtl81x9reg.h, bits of 0x80 and 0x40 in RTK_CFG1
seem to indicate LEDS0 and LEDS1 configuration initialized by
EEPROM settings, and they seem read only on my quick tests with
two 8169S based cards.
RTK_HWREV_8100E_SPIN2 is a PCIe device so also check it
in rtk_setmulti() to handle quirk. Noticed by OpenBSD.
 1.72.2.6  10-Feb-2007  tron Pull up following revision(s) (requested by tsutsui in ticket #437):
sys/dev/ic/rtl8169.c: revision 1.79
Clear IFF_OACTIVE in re_txeof() only if there are more than RE_TXDESC_RSVD
free TXDESCs. From FreeBSD, but I'm still wondering why we have to reserve
some free TXDESCs even on re_start().
 1.72.2.5  10-Feb-2007  tron Pull up following revision(s) (requested by tsutsui in ticket #437):
sys/dev/ic/rtl8169.c: revision 1.78
- check more hwrev and use HWREV_* macro. From Realtek driver
via Darrin B.Jewell.
XXX: maybe we should check this sc_rev on more place
- use RTK_TXCFG_HWREV (0x7cc00000) rather than 0x7c800000
to mask the hwrev value since bit 0x00400000 is used only by 8139D
which is not supported by this driver
- fix a tyop
 1.72.2.4  10-Feb-2007  tron Pull up following revision(s) (requested by tsutsui in ticket #437):
sys/dev/ic/rtl81x9.c: revision 1.67
sys/dev/ic/rtl8169.c: revision 1.77
Fix EEPROM functions for RTL8169SC chips:
rtl81x9.c:
Increase delay on EEPROM access since EEPROM on RTL8169 based board
seems to require slower clock. Also use common EE_DELAY() macro.
rtl8169.c:
Use common rtk_read_eeprom() function to get Ethernet address on
8169 chips because EEMODE_AUTOLOAD command was a workaround on
original FreeBSD's driver and it doesn't work on 8169SC.
Problem reported and fix tested by Frank Lorenzen on current-users,
and also tested on 8139C with rtk(4) driver by me.
 1.72.2.3  10-Feb-2007  tron Pull up following revision(s) (requested by tsutsui in ticket #437):
sys/dev/ic/rtl8169.c: revision 1.76
Wrap a sanity check in re_newbuf() with #ifdef DIAGNOSTIC and
make it fatal on failure.
 1.72.2.2  10-Feb-2007  tron Pull up following revision(s) (requested by tsutsui in ticket #437):
sys/dev/ic/rtl8169.c: revision 1.75
Use __predict_false() in several conditionals.
 1.72.2.1  20-Dec-2006  bouyer Pull up following revision(s) (requested by tsutsui in ticket #283):
share/man/man4/re.4: revision 1.11
sys/dev/ic/rtl8169.c: revision 1.74
Fix and reenable HW VLAN tagging on re(4).
Closes PR kern/32643 and also fixes HW VLAN tagging on big endian machines.
 1.72.2.7.2.2  03-Jun-2008  skrll Sync with netbsd-4.
 1.72.2.7.2.1  03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.81.2.4  17-May-2007  yamt sync with head.
 1.81.2.3  24-Mar-2007  yamt sync with head.
 1.81.2.2  12-Mar-2007  rmind Sync with HEAD.
 1.81.2.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.83.6.1  29-Mar-2007  reinoud Pullup to -current
 1.83.4.1  11-Jul-2007  mjf Sync with head.
 1.83.2.6  23-Oct-2007  ad Sync with head.
 1.83.2.5  09-Oct-2007  ad Sync with head.
 1.83.2.4  20-Aug-2007  ad Sync with HEAD.
 1.83.2.3  01-Jul-2007  ad Adapt to callout API change.
 1.83.2.2  27-May-2007  ad Sync with head.
 1.83.2.1  10-Apr-2007  ad Sync with head.
 1.86.6.3  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.86.6.2  05-Oct-2007  joerg Remove the power management nonsense in the PCI versions of
rtk(4) and re(4). It is not really likely to work anyway.
Use PNP power management for the cardbus attachment as well and
remove the power management handlers from the chipset code.
 1.86.6.1  03-Sep-2007  jmcneill Sync with HEAD.
 1.86.2.1  03-Sep-2007  skrll Sync with HEAD.
 1.88.6.1  25-Oct-2007  bouyer Sync with HEAD.
 1.88.2.3  23-Mar-2008  matt sync with HEAD
 1.88.2.2  09-Jan-2008  matt sync with HEAD
 1.88.2.1  06-Nov-2007  matt sync with HEAD
 1.89.6.1  11-Dec-2007  yamt sync with head.
 1.89.4.1  26-Dec-2007  ad Sync with head.
 1.89.2.1  18-Feb-2008  mjf Sync with HEAD.
 1.90.2.3  20-Jan-2008  bouyer Sync with HEAD
 1.90.2.2  08-Jan-2008  bouyer Sync with HEAD
 1.90.2.1  13-Dec-2007  bouyer Sync with HEAD
 1.96.6.4  17-Jan-2009  mjf Sync with HEAD.
 1.96.6.3  28-Sep-2008  mjf Sync with HEAD.
 1.96.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.96.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.96.2.1  24-Mar-2008  keiichi sync with head.
 1.99.2.1  18-May-2008  yamt sync with head.
 1.102.2.7  11-Aug-2010  yamt sync with head.
 1.102.2.6  11-Mar-2010  yamt sync with head
 1.102.2.5  16-Sep-2009  yamt sync with head
 1.102.2.4  20-Jun-2009  yamt sync with head
 1.102.2.3  16-May-2009  yamt sync with head
 1.102.2.2  04-May-2009  yamt sync with head.
 1.102.2.1  16-May-2008  yamt sync with head.
 1.104.6.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.104.6.1  19-Oct-2008  haad Sync with HEAD.
 1.104.2.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.105.4.10  21-Dec-2014  msaitoh Pull up following revision(s) (requested by uwe in ticket #1936):
sys/dev/ic/rtl8169.c: revision 1.142
RealTek 8139C+ incorrectly identifies UDP checksum 0xffff as bad.
Force software recalculation of UDP checksum if bad checksum is
reported by the hardware.
 1.105.4.9  25-Jan-2012  riz Pull up following revision(s) (requested by garbled in ticket #1698):
sys/dev/ic/rtl81x9var.h: revision 1.52
sys/dev/ic/rtl8169.c: revision 1.134
sys/dev/ic/rtl81x9reg.h: revision 1.42
Add support to recognize the 8168E model of this chip. Taken from FreeBSD
 1.105.4.8  19-Jun-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #821):
sys/dev/ic/rtl8169.c: revisions 1.107, 1.114-1.119, 1.121
sys/dev/ic/rtl81x9reg.h: revisions 1.36-1.39
sys/dev/ic/rtl81x9var.h: revision 1.47
sys/dev/mii/rgephy.c: revision 1.27 via patch
sys/dev/pci/if_re_pci.c: revision 1.36
remove extra semicolons.
--
Add HWREV values of RTL8168CP and RTL8168D. From FreeBSD.

XXX: needs more quirk handling after wakeup for newer chips.
--
Add HWREV of RTL8102EL variant. From FUKAUMI Naoki.
--
Assume an unknown HWREV chip has the same features with the latest one.
--
Remove suffix "B" from rtk_name of PCI_PRODUCT_REALTEK_RT8168 devices.
All 8168/8111 variants (8168/8168B/8168C/8168CP/8168D/8111B/8111C/8111CP)
have the same PCI device ID.
--
Remove magic reset sequence except wakeup for rev 2 chips which breaks 8111D.
Problem reported and fix confirmed by Thomas Bieg on current-users.

Also tested on 8111C (no bad side effect) by several users privately.
--
Pull some changes for newer chips from FreeBSD:
- pull MACSTAT and CMDSTOP quirks for 8168/8111 chips
- always set CPLUSCMD_PCI_MRW on reset
- set VLANSTRIP and RXCSUM_ENB bits on CPLUS register per if_capenable

Tested on 8111C and 8111D by several users, and
no bad side effect on my old 8169S.
--
Remove unused sc_rev settings (all quirks are handled by sc_quirk)
and merge HWREV cases which have the same quirks.
--
- rename RTK_HWREV_8102EL_SPIN2 -> RTK_HWREV_8103E
- add a HWREV value for 8168DP
Per Realtek's Linux drivers.
--
Two fixes for RX hwcsum on DESCV2 chips:
* On checking TCPv4/UDPv4 RX checksum on DESCV2 chips, also check
RE_RDESC_VLANCTL_IPV4 bit because those DESCV2 chips may also recognize
IPv6 packets and set RE_PROTOID_TCPIP or RE_PROTOID_UDPIP bits for
TCPv6/UDPv6 packets. This may fix PR kern/40605.
* According to Realtek's Linux driver, DESCV2 chips don't set RE_PROTOID_IP
for non-TCP/UDP IP packets (set only RE_RDESC_VLANCTL_IPV[46]) so
remove PROTOID check for IPv4 RX cheksum on DESCV2 chips.
 1.105.4.7  01-May-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #597):
sys/dev/ic/rtl8169.c: revision 1.113
Fix another botch in hwcsum changes for PR kern/40955:
8168/8111/8168B/8111B doesn't have DESCV2.
Problem reported by Arto Huusko on current-users@.
 1.105.4.6  01-May-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #597):
sys/dev/ic/rtl8169.c: revision 1.112
sys/dev/ic/rtl81x9reg.h: revision 1.35
Check a correct bit for ip4csum-rx. Reported privately on PR kern/40955.
 1.105.4.5  01-May-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #597):
sys/dev/ic/rtl8169.c: revision 1.111
sys/dev/ic/rtl81x9var.h: revision 1.45
Add another quirk flag which shows availability of EEPROM command register.
Now we can remove sc_rev which was intended to represent "MAC revision"
used in the Realtek driver.
 1.105.4.4  01-May-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #597):
sys/dev/ic/rtl8169.c: revision 1.110
sys/dev/ic/rtl81x9var.h: revision 1.44
Add and use a new quirk flag to disable JUMBO MTU,
rather than checking sc_rev values.
 1.105.4.3  01-May-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #597):
sys/dev/ic/rtl8169.c: revision 1.109
sys/dev/ic/rtl81x9reg.h: revision 1.34
sys/dev/ic/rtl81x9var.h: revision 1.43
Add hardware checksum support for newer PCIe 8168/8111/8102 chips,
per device info taken from FreeBSD driver. Tested by snj@ on 8111C.
Should closes PR kern/40955.
Note on old 8169 chips IP hw csum must be enabled to use TCP/UDP hw csums,
but I'm not sure if these newer chips still have the same restriction.
 1.105.4.2  26-Mar-2009  snj branches: 1.105.4.2.4;
Pull up following revision(s) (requested by tsutsui in ticket #597):
sys/dev/ic/rtl8169.c: revision 1.106
sys/dev/ic/rtl81x9reg.h: revision 1.33
Add support for a 8168C/8111C revision
- also disable jumbo frame on this adapter following the FreeBSD driver
- merge redundant call to aprint_error_dev
 1.105.4.1  24-Mar-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #596):
sys/dev/ic/rtl8169.c: revision 1.108
sys/dev/ic/rtl81x9var.h: revision 1.42
Access LDPS register in re_reset() only on 8169S single chip variants.
From OpenBSD and FreeBSD drivers via PR kern/41009, and
Realtek-supplied FreeBSD driver.
 1.105.4.2.4.1  21-Apr-2010  matt sync to netbsd-5
 1.105.2.2  28-Apr-2009  skrll Sync with HEAD.
 1.105.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.107.2.2  23-Jul-2009  jym Sync with HEAD.
 1.107.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.129.4.2  05-Mar-2011  rmind sync with head
 1.129.4.1  30-May-2010  rmind sync with head
 1.129.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.129.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.133.8.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.133.8.2  30-Oct-2012  yamt sync with head
 1.133.8.1  17-Apr-2012  yamt sync with head
 1.134.4.4  14-Dec-2014  martin Pull up following revision(s) (requested by uwe in ticket #1212):
sys/dev/ic/rtl8169.c: revision 1.142
RealTek 8139C+ incorrectly identifies UDP checksum 0xffff as bad.
Force software recalculation of UDP checksum if bad checksum is
reported by the hardware.
 1.134.4.3  18-Sep-2013  bouyer Pull up following revision(s) (requested by phx in ticket #946):
sys/arch/sandpoint/stand/altboot/rge.c: revision 1.7
sys/arch/sandpoint/stand/altboot/brdsetup.c: revision 1.32
sys/dev/ic/rtl8169.c: revision 1.138
QNAP V200 boards have no EEPROM for the MAC address, so all devices default
to the same address (00:e0:4c:69:20:01).
Now we read the real MAC address from the flash ROM. It is stored at the
beginning of a 512-byte block in ASCII format. Some QNAP's have a broken
ext2 file system, so we cannot look for the file ETH0.MAC_ADDR therein,
but have to search the whole flash in 512-byte steps for candidates...
Make re(4) driver always use IDR register values for its MAC address.
Some sandpoint NAS firmwares set MAC address per their
firmware settings and don't use re(4)'s EEPROM values.
Per rtl8169 manuals re(4) chip reads EEPROM automatically after
hardware reset and Linux driver also uses IDR registers,
so this change should not affect existing other boards
which actually have vaild EEPROM.
Per discussion in old tech-kern@ thread:
http://mail-index.netbsd.org/tech-kern/2012/12/01/msg014573.html
Note rtl81x9.c is still shared among rtk(4) only for a multicast function
(to avoid boring refactoring work).
 1.134.4.2  29-Jul-2013  msaitoh Pull up following revision(s) (requested by khorben in ticket #913):
sys/dev/ic/rtl8169.c: revision 1.137
sys/dev/ic/rtl81x9reg.h: revision 1.44
share/man/man4/re.4: revision 1.14
Added support for the Realtek 8168F variant in re(4).
From FreeBSD; not tested on real hardware unfortunately. The manual page
was adjusted as well.
No objection from current-users@, "commit it" gdt@
 1.134.4.1  05-Mar-2012  sborrill Pull up the following revisions(s) (requested by nonaka in ticket #83):
sys/dev/ic/rtl8169.c: revision 1.135
sys/dev/ic/rtl81x9reg.h: revision 1.43

Add RTL8168E/8111E-VL support.
 1.134.2.3  06-Mar-2012  mrg sync to -current
 1.134.2.2  06-Mar-2012  mrg sync to -current
 1.134.2.1  04-Mar-2012  mrg sync to latest -current.
 1.136.2.3  03-Dec-2017  jdolecek update from HEAD
 1.136.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.136.2.1  23-Jun-2013  tls resync from head
 1.139.6.1  07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.140.2.2  15-May-2015  snj Pull up following revision(s) (requested by joerg in ticket #772):
sys/arch/arm/amlogic/amlogic_genfb.c: revision 1.4
sys/arch/arm/arm/disassem.c: revision 1.25
sys/arch/arm/omap/am335x_cm_padconf.c: revision 1.3
sys/arch/arm/omap/sitara_cm.h: revision 1.2
sys/dev/ic/i82557var.h: revision 1.51
sys/dev/ic/rtl8169.c: revision 1.143
sys/dev/ieee1394/fwcrom.c: revision 1.17
sys/external/bsd/dwc2/dwc2.c: revision 1.32
dwc2_hubd appears to be unused so #if 0 it in order to appease clang
--
Preserve const.
--
No reason not to make the string const.
--
Drop unnecessary-but-harmful casts.
--
Replace void * cast with proper __UNVOLATILE.
--
Preserve const.
--
amlogic_genfb_hdmi_write_4 is currently unused, mark it as such.
 1.140.2.1  14-Dec-2014  martin Pull up following revision(s) (requested by uwe in ticket #324):
sys/dev/ic/rtl8169.c: revision 1.142
RealTek 8139C+ incorrectly identifies UDP checksum 0xffff as bad.
Force software recalculation of UDP checksum if bad checksum is
reported by the hardware.
 1.143.2.6  28-Aug-2017  skrll Sync with HEAD
 1.143.2.5  05-Feb-2017  skrll Sync with HEAD
 1.143.2.4  09-Jul-2016  skrll Sync with HEAD
 1.143.2.3  19-Mar-2016  skrll Sync with HEAD
 1.143.2.2  22-Sep-2015  skrll Sync with HEAD
 1.143.2.1  06-Jun-2015  skrll Sync with HEAD
 1.147.2.3  26-Apr-2017  pgoyette Sync with HEAD
 1.147.2.2  20-Mar-2017  pgoyette Sync with HEAD
 1.147.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.148.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.150.2.1  19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.151.2.1  24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.152.2.5  26-Jan-2019  pgoyette Sync with HEAD
 1.152.2.4  18-Jan-2019  pgoyette Synch with HEAD
 1.152.2.3  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.152.2.2  28-Jul-2018  pgoyette Sync with HEAD
 1.152.2.1  25-Jun-2018  pgoyette Sync with HEAD
 1.154.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.154.2.1  10-Jun-2019  christos Sync with HEAD
 1.159.2.2  04-Aug-2023  martin Pull up following revision(s) (requested by jakllsch in ticket #1705):

sys/dev/ic/rtl81x9var.h: revision 1.58
sys/dev/ic/rtl81x9reg.h: revision 1.54
sys/dev/ic/rtl8169.c: revision 1.167
sys/dev/ic/rtl8169.c: revision 1.168

re(4): misc chip revision support changes
* remove impossible-to-match chip revision cases
* bring support for modern chips in line with FreeBSD and OpenBSD
* adds support for RTL8168GU

Addresses PR kern/56312.

- Print chip revision. From OpenBSD.
- Rename RTK_HWREV_8168_SPIN[123] to RTK_HWREV_8168'B'_SPIN[123].
Same as other *BSDs.
- Rename RTK_HWREV_8168G_SPIN4 to RTK_HWREV_8411B. Same as other *BSDs.
- Add definition of RTK_HWREV_8169_8110SCE.
 1.159.2.1  28-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #667):

sys/dev/ic/rtl81x9var.h: revision 1.57
sys/dev/ic/rtl81x9.c: revision 1.107
sys/dev/ic/rtl81x9reg.h: revision 1.51
sys/dev/ic/rtl8169.c: revision 1.160
sys/dev/ic/rtl81x9reg.h: revision 1.52
sys/dev/ic/rtl8169.c: revision 1.161

Use unsigned in rtk_setmulti() to avoid undefined behavior. Found bk kUBSan.
8168H model didn't link up well. some models seems to require to enable TX/RX after configuration.
RTKQ_TXRXEN_LATER quirk flag added. it may be able to unify with RTKQ_RXDV_GATED flag?
Sort RTK_HWREV_* by value.

Improve some chip revisions support:
- Add 8168FP, 8411, 8168G, 8401E, 8105E, 8105E_SPIN1, 8106E and 8402 from
{Free,Open}BSD.
- Renumber RTK_HWREV_8103E from 0x24C00000 to 0x34c00000. 0x24C00000 is newly
used as RTK_HWREV_8102EL_SPIN1. Same as {Free,Open}BSD.
 1.161.2.1  29-Feb-2020  ad Sync with head.

RSS XML Feed