Home | History | Annotate | Download | only in pci
History log of /src/sys/dev/pci/if_vge.c
RevisionDateAuthorComments
 1.89  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.88  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.87  09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.86  24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.85  17-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.84  23-May-2022  rin Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.83  22-Jan-2022  martin Explicitly cast a __MASK(48) to bus_addr_t (for 32bit bus_addr_t archs)
 1.82  22-Jan-2022  skrll Ensure bus_dmatag_subregion is called with an inclusive max_addr
everywhere.
 1.81  24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.80  21-Mar-2020  thorpej branches: 1.80.8;
Use the 64-bit DMA tag, if available, with some constraints:
- The data buffers can come from anywhere in the 64-bit region, but
the upper 16 bits of the data buffer address is stored in a single
register, so just treat that as 0 and create a 48-bit restricted
DMA tag.
- The descriptor address registers share a single register for the
upper 32-bits, so enforce a 4G boundary when allocating memory
for the descriptors.
 1.79  30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.78  27-Dec-2019  msaitoh branches: 1.78.2;
s/opration/operation/
 1.77  21-Nov-2019  msaitoh - Set duplex correctly when user setting is not IFM_AUTO.
- When the link is up, set VGE_DIAGCTL not from user media setting but from
the current active link status.
 1.76  19-Nov-2019  msaitoh Fixes a bug that "ifmedia vge0 media 1000baseT-FDX" causes device timeout.

If the interface's media is NOT in the "best" mode (i.e. other than IFM_AUTO),
control VGE_DIAGCTL_GMII bit.
 1.75  08-Oct-2019  msaitoh Copy vge_clrwol() from FreeBSD and call it in vge_attach() to recover from
powerdown mode. Fixes PR kern/41525 reported by Aran Clauson.
 1.74  13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.73  09-Jul-2019  msaitoh branches: 1.73.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.72  28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.71  23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.70  23-May-2019  msaitoh -No functional change:
- Simplify struct ethercom's pointer near ETHER_FIRST_MULTI().
- Simplify MII structure initialization.
- u_int*_t -> uint*_t.
- KNF
 1.69  11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.68  05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.67  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.66  09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.65  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.64  18-Jul-2018  sevan Be consistent among ethernet drivers on the convention for printing ethernet
addresses.

NFC
 1.63  26-Jun-2018  msaitoh branches: 1.63.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.62  14-Jan-2018  maxv branches: 1.62.2;
Dedup. m_defrag is already a common function, no need to reimplement it
there. Meanwhile this should fix two bugs (that I couldn't investigate
more than that since I don't have this hardware): the mbuf passed to
vge_m_defrag was leaked, and the tags were not copied in the returned
mbuf.
 1.61  26-Sep-2017  knakahara 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.60  15-Dec-2016  ozaki-r branches: 1.60.8;
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.59  08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.58  10-Jun-2016  ozaki-r branches: 1.58.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.57  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.56  29-Mar-2014  christos branches: 1.56.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.55  13-Sep-2013  martin Remove unused variable
 1.54  30-Mar-2013  christos branches: 1.54.4;
remove trailing whitespace
 1.53  22-Jul-2012  matt branches: 1.53.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.52  30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.51  05-Apr-2010  joerg branches: 1.51.8; 1.51.12;
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.50  19-Jan-2010  pooka branches: 1.50.2; 1.50.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.49  07-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Tested on VT6122.
 1.48  16-May-2009  tsutsui Split device_t/softc split, tested on VT6212L.
 1.47  12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.46  06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.45  06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.44  09-Feb-2009  nonaka fix comment.
 1.43  26-Nov-2008  joerg branches: 1.43.4;
- ifconfig down support
- ALTQ support
 1.42  07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.41  10-Apr-2008  cegger branches: 1.41.4; 1.41.10; 1.41.12; 1.41.14;
use aprint_*_dev and device_xname
 1.40  07-Feb-2008  dyoung branches: 1.40.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.39  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.38  19-Oct-2007  ad branches: 1.38.2; 1.38.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.37  01-Sep-2007  dyoung branches: 1.37.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.36  09-Jul-2007  ad branches: 1.36.2; 1.36.6; 1.36.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.35  12-Jun-2007  tsutsui Fix one more bug I introduced in rev 1.21:
Clear sc->sc_rx_consumed before allocating RX mbufs by vge_newbuf()
in vge_intr() otherwise vge_newbuf() might get KASSERT() failure
on DIAGNOSTIC kernel when the interface is reinitialized during RX.
 1.34  04-Mar-2007  christos branches: 1.34.2; 1.34.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.33  01-Dec-2006  tsutsui branches: 1.33.2; 1.33.4; 1.33.8;
Free resouces on failure in vge_allocmem().
 1.32  01-Dec-2006  tsutsui - vge_probe() -> vge_match()
- KNF, unwrap lines
 1.31  26-Nov-2006  tsutsui Fix stupid bugs found on sparc64:
- checking if dmamap != NULL is not valid because dmamap is not cleared
in bus_dmamap_unload(9)
- no need check RX mbufs and call m_freem() and bus_dmamap_unload()
in vge_init() since it's done in prior vge_stop()

Now vge(4) works fine on Ultra5.
 1.30  26-Nov-2006  tsutsui Include <sys/device.h> for struct device.
 1.29  26-Nov-2006  tsutsui - prepare inline functions to set 48 bit DMA address which avoid 64 bit
arithmetic on ILP32 (sizeof(bus_addr_t) == 4, exactly) hosts
- prepare and use VGE_PREV_TXDESC() macro
- use VGE_[TR]XDESCSYNC() calls more efficiently
- wrap a sanity check against VGE_RDSTS_OWN in vge_newbuf()
with #ifdef DIAGNOSTIC since it should not happen
- use sc->sc_tx_free (number of free TX descs) to check if TX packets are
queued or sent
- call vge_start() only if the interupt is actually handled by this driver
- some misc cosmetics
 1.28  26-Nov-2006  tsutsui Introduce a new VGE_RX_BUFSIZE macro which represent default RX mbuf
length and define VGE_RX_PAD (which is 4 bytes) for ETHER_ALIGN (2 bytes)
padding only in !__NO_STRICT_ALIGNMENT case to avoid confusion.
As per comments from Murata Shuuichirou in PR kern/31323.
Tested on i386 and macppc.
 1.27  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.26  04-Nov-2006  tsutsui Rather than copying m_pkthdr.csum_flags in m_defrag() (which was
committed in rev 1.22), save it before calling m_defrag().

I haven't confirmed whether the m_pkthdr.csum_flags is preserved during
m_defrag(), but the previous way sometimes makes vge(4) chip mad...
 1.25  04-Nov-2006  tsutsui Return a proper error from vge_encap() if m_defrag() fails.
 1.24  01-Nov-2006  tsutsui Fix another botch in rev 1.14:
vge_encap() should bail out if there is not enough free
TX descriptor _OR_ TX descriptor is still owned by the chip.

Anyway, we already check if the TX descriptor already has an mbuf
to be sent in vge_start() so no need to bother to check sc_tx_free
and VGE_TDSTS_OWN in the descriptor in normal case, then make it use
KASSERT(9) or wrap with #ifdef DIAGNOSTIC.

XXX1: I don't know why original FreeBSD driver checks
if a number of free TX descriptors is more than two, not zero.
XXX2: Is it better to check a number of free descriptors in vge_start()
like other our drivers rather than mbuf chain for each descriptor?
 1.23  01-Nov-2006  tsutsui Remove a debug statement which was slipped in rev 1.21.
 1.22  01-Nov-2006  tsutsui Also copy csum_flags and csum_data in vge_m_defrag().
Fix checksum error problem on sending fragmented large packets,
which was introduced in rev 1.14.

BTW, should we have m_defrag() in MI for other drivers?
 1.21  31-Oct-2006  tsutsui Make vge(4) look a NetBSD native driver like pcn(4) or epic(4) etc:
- merge if_vgevar.h into if_vge.c since no other file refers it
- rename some macro (VGE_TX_DESC_CNT -> VGE_NTXDESC etc.) and structs
- change prefixes of structure members to represent parents
- put TX and RX descriptors into single struct vge_control_data and
allocate DMA memory at once
- no need to specify BUS_DMA_ALLOCNOW
- define appropriate macro for offsets and addresses of DMA descriptors
- define struct vge_txsoft and vge_rxsoft, and put common data for
each descriptor into them
- remove struct vge_list_data and move its members into struct vge_softc
- remove #ifdef DEVICE_POLLING code we don't support
- merge vge_[tr]x_list_init() functions into vge_init()
- use aprint_error() to print errors
- put splnet(9) where appropriate and remove unused VGE_{LOCK,UNLOCK}() macro
- clear TX timeout only if there is no pending descriptor
- check dm_nsegs properly otherwise padding short packets could fail
- prepare zero'ed DMA memory to pad short packets rather than putting
random data
- fix a wrong VGE_TXDESCSYNC() usage which should be VGE_TXFRAGSYNC()

Tested on my i386 which is my development machine.
(more bus_dmamap_sync(9) cleanup will be done later)
 1.20  21-Oct-2006  tsutsui Fix hardware VLAN tagging support on vge(4):

- On TX, vge(4) seems to assume that tags are written in little endian.
We already use htole32() to write values into descriptors,
so extra byteswap by htons() is not needed there.

- On RX, vge(4) seems to store tags in network byteorder.
We have to swap byteorder regardless of host's byteorder
(i.e. we have to use bswap16() rather than ntohs())
because we already use le32toh() to read values from descriptors.

Anyway, no need to use htons()/ntohs() because there is no stream data.

Tested on both i386 and macppc, and OK'ed by Pavel Cahyna.
 1.19  17-Oct-2006  tsutsui Fix a typo in comment.
 1.18  15-Oct-2006  tsutsui In vge_newbuf(), don't adjust packet length twice by m_adj(9)
in case of __NO_STRICT_ALIGNMENT. We can adjust m_data directly
since it's allocated by MCLGET(9) just above.
(though the length is not used anyway)
 1.17  15-Oct-2006  tsutsui Umm, remove a DELAY() added in previous. It seems to cause another problem.
 1.16  15-Oct-2006  tsutsui On sgimips (R5000 O2), it seems that the first EEPROM read data
right after vge_reset() could be corrupted. For workaround, add a
dummy EEPROM read in vge_reset() so that MAC address is properly
set on the machine.
While here, add a DELAY() in busy loop in vge_read_eeprom().
 1.15  14-Oct-2006  tsutsui - use MGETHDR() and MCLGET() rather than m_gethdr() and m_clget()
- KNF, ANSIfy, remove register decls
- some more cosmetics
 1.14  14-Oct-2006  tsutsui - call bus_dmamap_sync() properly (sigh)
- merge vge_dma_map_rx_desc() and vge_dma_map_tx_desc() into callers
- declare DMA descs volatile
- remove unused macro/declarations
- bzero -> memset
- some more cosmetics
 1.13  14-Oct-2006  tsutsui - use correct dmamap size for TX/RX DMA descriptors
- use __NO_STRICT_ALIGNMENT directly rather than local VGE_FIXUP_RX
- no need to use BUS_DMA_ALLOCNOW
- remove unneeded members from softc

XXX: Is vge_fixup_rx() really more efficient than memmove(9),
XXX: or allocating a new buffer and memcpy(9) into it?
XXX: Anyway, vge(4) is not recommended for non-x86 hosts at all
XXX: because it requires copying buffers by CPU on RX.
 1.12  14-Oct-2006  tsutsui Umm, set Ethernet address into softc properly.
 1.11  14-Oct-2006  tsutsui - fix eeprom read function so that MAC address can be read correctly
on big endian machines
- add some missed byteswap functions for DMA descriptors
 1.10  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.9  08-Mar-2006  lukem branches: 1.9.10; 1.9.12;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.8  24-Dec-2005  perry branches: 1.8.4; 1.8.6; 1.8.8; 1.8.10;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.7  21-Nov-2005  martin This driver does only access the bus_space_tag via bus_space_* functions,
so there is no need to map it linear. From Garrett D'Amore in
PR kern/32137.
 1.6  08-Sep-2005  christos branches: 1.6.6;
PR/31130: FUKAUMI Naoki: Fix vge(4) SIOC{ADD,DEL}MULTI handling
 1.5  02-May-2005  yamt branches: 1.5.2;
split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.4  05-Mar-2005  jdolecek branches: 1.4.2; 1.4.4; 1.4.6;
g/c debugging printf
 1.3  05-Mar-2005  jdolecek modify vge_m_defrag() to support > MCLBYTES chains, by allocating appropriate
number of mbuf clusters; also don't free the original mbuf chain

simplify vge_encap() and make error reporting more consistent

normalize vge_start() (including use of IFQ_* macros), and handle the case
when the input mbuf chain is defragmented

JUMBO packets seem to work fine now
 1.2  27-Feb-2005  perry branches: 1.2.2;
nuke trailing whitespace
 1.1  20-Feb-2005  jdolecek Add device driver support for the VIA Networking Technologies VT6122
gigabit ethernet chip and integrated 10/100/1000 copper PHY.

Obtained from: FreeBSD
 1.2.2.5  11-Dec-2005  christos Sync with head.
 1.2.2.4  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.3  08-Mar-2005  skrll Sync with HEAD.
 1.2.2.2  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.1  27-Feb-2005  skrll file if_vge.c was added on branch ktrace-lwp on 2005-03-04 16:45:19 +0000
 1.4.6.2  29-Apr-2005  kent sync with -current
 1.4.6.1  05-Mar-2005  kent file if_vge.c was added on branch kent-audio2 on 2005-04-29 11:29:06 +0000
 1.4.4.2  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.4.1  05-Mar-2005  yamt file if_vge.c was added on branch yamt-km on 2005-03-19 08:35:11 +0000
 1.4.2.1  11-Sep-2005  tron Pull up following revision(s) (requested by christos in ticket #756):
sys/dev/pci/if_vge.c: revision 1.6
PR/31130: FUKAUMI Naoki: Fix vge(4) SIOC{ADD,DEL}MULTI handling
 1.5.2.6  11-Feb-2008  yamt sync with head.
 1.5.2.5  21-Jan-2008  yamt sync with head
 1.5.2.4  27-Oct-2007  yamt sync with head.
 1.5.2.3  03-Sep-2007  yamt sync with head.
 1.5.2.2  30-Dec-2006  yamt sync with head.
 1.5.2.1  21-Jun-2006  yamt sync with head.
 1.6.6.1  22-Nov-2005  yamt sync with head.
 1.8.10.1  19-Apr-2006  elad sync with head.
 1.8.8.1  13-Mar-2006  yamt sync with head.
 1.8.6.1  22-Apr-2006  simonb Sync with head.
 1.8.4.1  09-Sep-2006  rpaulo sync with head
 1.9.12.2  10-Dec-2006  yamt sync with head.
 1.9.12.1  22-Oct-2006  yamt sync with head
 1.9.10.2  12-Jan-2007  ad Sync with head.
 1.9.10.1  18-Nov-2006  ad Sync with head.
 1.33.8.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.33.4.1  12-Mar-2007  rmind Sync with HEAD.
 1.33.2.1  18-Jun-2007  liamjfoy Pull up following revision(s) (requested by tsutsui in ticket #731):
sys/dev/pci/if_vge.c: revision 1.35
Fix one more bug I introduced in rev 1.21:
Clear sc->sc_rx_consumed before allocating RX mbufs by vge_newbuf()
in vge_intr() otherwise vge_newbuf() might get KASSERT() failure
on DIAGNOSTIC kernel when the interface is reinitialized during RX.
 1.34.4.1  11-Jul-2007  mjf Sync with head.
 1.34.2.4  23-Oct-2007  ad Sync with head.
 1.34.2.3  09-Oct-2007  ad Sync with head.
 1.34.2.2  15-Jul-2007  ad Sync with head.
 1.34.2.1  01-Jul-2007  ad Adapt to callout API change.
 1.36.8.2  23-Mar-2008  matt sync with HEAD
 1.36.8.1  06-Nov-2007  matt sync with HEAD
 1.36.6.2  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.36.6.1  03-Sep-2007  jmcneill Sync with HEAD.
 1.36.2.1  03-Sep-2007  skrll Sync with HEAD.
 1.37.4.1  25-Oct-2007  bouyer Sync with HEAD.
 1.38.8.1  20-Jan-2008  bouyer Sync with HEAD
 1.38.2.1  18-Feb-2008  mjf Sync with HEAD.
 1.40.6.2  17-Jan-2009  mjf Sync with HEAD.
 1.40.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.41.14.4  07-Dec-2008  bouyer Pull up following revision(s) (requested by joerg in ticket #143):
sys/dev/pci/if_vge.c: revision 1.43 via patch
- ifconfig down support
- ALTQ support
 1.41.14.3  30-Nov-2008  bouyer Back out ticket 143, it doesn't build.
 1.41.14.2  30-Nov-2008  bouyer Apply patch, requested by joerg in ticket 143:
Fix build failure, vge_stop() needs 2 arguments in netbsd-5.
 1.41.14.1  29-Nov-2008  bouyer Pull up following revision(s) (requested by joerg in ticket #143):
sys/dev/pci/if_vge.c: revision 1.43
- ifconfig down support
- ALTQ support
 1.41.12.2  03-Mar-2009  skrll Sync with HEAD.
 1.41.12.1  19-Jan-2009  skrll Sync with HEAD.
 1.41.10.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.41.4.5  11-Aug-2010  yamt sync with head.
 1.41.4.4  11-Mar-2010  yamt sync with head
 1.41.4.3  16-Sep-2009  yamt sync with head
 1.41.4.2  16-May-2009  yamt sync with head
 1.41.4.1  04-May-2009  yamt sync with head.
 1.43.4.2  23-Jul-2009  jym Sync with HEAD.
 1.43.4.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.50.4.1  30-May-2010  rmind sync with head
 1.50.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.51.12.1  18-Feb-2012  mrg merge to -current.
 1.51.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.51.8.2  30-Oct-2012  yamt sync with head
 1.51.8.1  17-Apr-2012  yamt sync with head
 1.53.2.3  03-Dec-2017  jdolecek update from HEAD
 1.53.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.53.2.1  23-Jun-2013  tls resync from head
 1.54.4.1  18-May-2014  rmind sync with head
 1.56.6.3  05-Feb-2017  skrll Sync with HEAD
 1.56.6.2  09-Jul-2016  skrll Sync with HEAD
 1.56.6.1  19-Mar-2016  skrll Sync with HEAD
 1.58.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.60.8.3  17-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1406):

sys/dev/pci/if_vgereg.h: revision 1.5
sys/dev/pci/if_vge.c: revision 1.75

Copy vge_clrwol() from FreeBSD and call it in vge_attach() to recover from
powerdown mode. Fixes PR kern/41525 reported by Aran Clauson.
 1.60.8.2  13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.60.8.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.62.2.4  26-Jan-2019  pgoyette Sync with HEAD
 1.62.2.3  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.62.2.2  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.62.2.1  28-Jul-2018  pgoyette Sync with HEAD
 1.63.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.63.2.1  10-Jun-2019  christos Sync with HEAD
 1.73.2.2  25-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #477):

sys/dev/pci/if_vge.c: revision 1.76
sys/dev/pci/if_vge.c: revision 1.77

Fixes a bug that "ifmedia vge0 media 1000baseT-FDX" causes device timeout.

If the interface's media is NOT in the "best" mode (i.e. other than IFM_AUTO),
control VGE_DIAGCTL_GMII bit.

- Set duplex correctly when user setting is not IFM_AUTO.
- When the link is up, set VGE_DIAGCTL not from user media setting but from
the current active link status.
 1.73.2.1  17-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #345):

sys/dev/pci/if_vgereg.h: revision 1.5
sys/dev/pci/if_vge.c: revision 1.75

Copy vge_clrwol() from FreeBSD and call it in vge_attach() to recover from
powerdown mode. Fixes PR kern/41525 reported by Aran Clauson.
 1.78.2.1  29-Feb-2020  ad Sync with head.
 1.80.8.1  01-Aug-2021  thorpej Sync with HEAD.

RSS XML Feed