Home | History | Annotate | Download | only in ic
History log of /src/sys/dev/ic/i82596.c
RevisionDateAuthorComments
 1.48  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.47  06-Jul-2022  andvar s/ponters/pointers/
 1.46  29-May-2022  rin Audit unload/unmap v.s. free against DMA buffer for sys/dev;
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

For some drivers, resource leaks for error paths are fixed at
the same time.

XXX XXX XXX
Compile test only (at least one arch per driver).
 1.45  10-Nov-2021  msaitoh s/endianess/endianness/
 1.44  04-Feb-2020  thorpej Use ifmedia_fini().
 1.43  29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.42  29-May-2019  msaitoh branches: 1.42.4;
Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.41  28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.40  26-Apr-2019  msaitoh No functional change:
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.39  09-Apr-2019  msaitoh KNF. No functional change.
 1.38  26-Jun-2018  msaitoh branches: 1.38.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.37  29-Jul-2017  riastradh branches: 1.37.2;
Null out sc_rx_mbuf[i] after m_freem to avoid double-free later.

From Ilja Van Sprundel.

Also null out sc_tx_mbuf[i] after m_freem, out of paranoia.

XXX Not entirely clear to how tx mbufs are freed, but no way to test
this since it's ews4800mips- and hp700-only, so not keen to make any
more elaborate changes...
 1.36  20-Feb-2017  ozaki-r branches: 1.36.6;
Apply deferred if_start to more drivers
 1.35  15-Dec-2016  ozaki-r branches: 1.35.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.34  10-Jun-2016  ozaki-r branches: 1.34.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.33  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.32  21-Feb-2015  martin Fix multicast handling (and while there a bogus memcpy).
Fixes PR kern/49472, patch from Nick Hudson.
 1.31  24-Feb-2014  skrll branches: 1.31.4; 1.31.6;
Rename NetBSD/hp700 to NetBSD/hppa.

Unfortunately our VCS isn't very helpful here.
 1.30  09-Dec-2013  wiz Fix typo ("then" instead of "than")
 1.29  05-Apr-2010  joerg branches: 1.29.8; 1.29.14; 1.29.18; 1.29.20; 1.29.22; 1.29.28;
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.28  19-Jan-2010  pooka branches: 1.28.2; 1.28.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.27  13-May-2009  tsutsui Pass correct size (after padding) to bus_dmamap_sync(9) for RX mbufs
in iee_intr(). Fixes panic on DIAGNOSTIC kernel reported by skrll@.
 1.26  10-May-2009  tsutsui - adjust comments for the previous change
- wrap a long comment
- remove a trailing whitespace
 1.25  10-May-2009  tsutsui Misc bus_dma(9) related cleanup:
- calculate each descriptor sizes and offsets in iee_attach() and store them
into softc, rather than re-calculating them everywhere via macros
- prepare macros to sync DMA shmem per each descriptor
- sync only necessary descriptors in iee_intr() and iee_start()
- make sure SCB_FOO macros take softc as an arg properly
- use bus_dmamap_load_mbuf(9) for RX mbufs
- put 2 byte alignments to RX mbufs

XXX: still slower than ie(4) in i82586 compat mode on HP9000 735/125.
 1.24  09-May-2009  tsutsui Fix more pasto botch.
 1.23  09-May-2009  tsutsui Remove (wrong) function names by pasto from attach failure messages.
 1.22  09-May-2009  tsutsui Also check if cache line alignment is power of two in KASSERT().
 1.21  09-May-2009  tsutsui Move allocation of DMA shared memory with bus_dma(9) ops
from MD attachments to MI iee_attach().
Tested on HP9000 735/125. Compile test only on ews4800mips.

XXX: more strict bus_dmamap_sync(9) calls are required in various places.
 1.20  05-May-2009  tsutsui Add support for i82596 Rev A chip which doesn't have the enhanced 32 bit
big endian mode:
- add IEE_REV_A flag to indicate if chip support the 32 bit BE mode or not
- add IEE_SWAPA32() macro and use it on necessary 32 bit DMA pointers
- rename IEE_SWAP() macro for the SCP address pointer and statistics
counters which require word swap even on Rev B/C chips to IEE_SWAP32()
for clarification
- add comments about these BE mode quirks

Tested on HP9000 735/125 by me and also tested on 715/50 by skrll@
with netbsd-5 branch, and fixes MI part of PR port-hp700/35531.
 1.19  04-Apr-2008  tsutsui branches: 1.19.4; 1.19.18;
Split device_t/softc for iee(4), with misc cosmetic changes.
 1.18  19-Oct-2007  ad branches: 1.18.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.17  26-Aug-2007  dyoung branches: 1.17.2; 1.17.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).
 1.16  17-Apr-2007  skrll branches: 1.16.2; 1.16.6;
Remove bogus if_drain. If an attempt to reclaim mbufs was made the
interface was marked down.

Should fix PR 31540.
 1.15  04-Mar-2007  christos branches: 1.15.2; 1.15.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14  12-Jul-2006  skrll branches: 1.14.8; 1.14.10;
Note this driver is for the i82596CA and i82596DX/SX chips and provide
links to documentation on developers.intel.com
 1.13  08-Jul-2006  skrll KNF some comments and whitespace.
 1.12  08-Jul-2006  skrll Spelling in comments. No functional change.
 1.11  11-Dec-2005  christos branches: 1.11.4; 1.11.8; 1.11.16;
merge ktrace-lwp.
 1.10  07-Jun-2005  skrll branches: 1.10.2;
Fix typo.
 1.9  02-Jun-2005  he Adapt to -Wcast-qual by adding a const and using __UNVOLATILE() in
a couple of places where memcpy() is used.
 1.8  27-Feb-2005  perry nuke trailing whitespace
 1.7  18-Feb-2005  tsutsui u_intNN_t -> uintNN_t
 1.6  17-Feb-2005  tsutsui Account ifp->if_opackets and ifp->if_collisions.
 1.5  17-Feb-2005  tsutsui Remove unneeded includes.
 1.4  30-Oct-2004  thorpej branches: 1.4.4; 1.4.6;
iee_ioctl(): Make this look like other drivers, fixing a missing "splx(s)"
as a side-effect. Don't bother handling IFF_PROMISC here, because
ether_ioctl() already calls (*if_init)() to handle flags changes.

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

Fixes kern/27678.
 1.3  30-Oct-2004  thorpej When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.2  26-Aug-2004  jkunz Remove race conditions caused by the CPU cache of PA7100 CPUs.
 1.1  12-Mar-2004  jkunz branches: 1.1.4; 1.1.6;
Import MI part of new Intel i82596 Ethernet driver.
 1.1.6.2  30-Jan-2005  he Pull up revision 1.4 (requested by thorpej in ticket #943):
Make iee_ioctl() look more like other drivers, and fix a
missing splx(s) as a side-effect. Don't bother handling
IFF_PROMISC here, because ether_ioctl() already calls
(*if_init)() to handle flag changes.
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.1.6.1  24-Jan-2005  he Pull up revision 1.3 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.1.4.8  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.7  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.6  02-Nov-2004  skrll Sync with HEAD.
 1.1.4.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.4  18-Sep-2004  skrll Sync with HEAD.
 1.1.4.3  03-Sep-2004  skrll Sync with HEAD
 1.1.4.2  03-Aug-2004  skrll Sync with HEAD
 1.1.4.1  12-Mar-2004  skrll file i82596.c was added on branch ktrace-lwp on 2004-08-03 10:46:15 +0000
 1.4.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.4.1  29-Apr-2005  kent sync with -current
 1.10.2.3  27-Oct-2007  yamt sync with head.
 1.10.2.2  03-Sep-2007  yamt sync with head.
 1.10.2.1  30-Dec-2006  yamt sync with head.
 1.11.16.1  13-Jul-2006  gdamore Merge from HEAD.
 1.11.8.1  11-Aug-2006  yamt sync with head
 1.11.4.1  09-Sep-2006  rpaulo sync with head
 1.14.10.2  07-May-2007  yamt sync with head.
 1.14.10.1  12-Mar-2007  rmind Sync with HEAD.
 1.14.8.1  20-Apr-2007  bouyer Pull up following revision(s) (requested by skrll in ticket #580):
sys/dev/ic/i82596.c: revision 1.16
Remove bogus if_drain. If an attempt to reclaim mbufs was made the
interface was marked down. Should fix PR 31540.
 1.15.4.1  11-Jul-2007  mjf Sync with head.
 1.15.2.3  23-Oct-2007  ad Sync with head.
 1.15.2.2  09-Oct-2007  ad Sync with head.
 1.15.2.1  27-May-2007  ad Sync with head.
 1.16.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.16.6.1  03-Sep-2007  jmcneill Sync with HEAD.
 1.16.2.1  03-Sep-2007  skrll Sync with HEAD.
 1.17.6.1  25-Oct-2007  bouyer Sync with HEAD.
 1.17.2.1  06-Nov-2007  matt sync with HEAD
 1.18.16.1  02-Jun-2008  mjf Sync with HEAD.
 1.19.18.2  23-Jul-2009  jym Sync with HEAD.
 1.19.18.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.4.3  11-Aug-2010  yamt sync with head.
 1.19.4.2  11-Mar-2010  yamt sync with head
 1.19.4.1  16-May-2009  yamt sync with head
 1.28.4.1  30-May-2010  rmind sync with head
 1.28.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.29.28.1  18-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1475):
sys/dev/ic/i82596.c: revision 1.37
Null out sc_rx_mbuf[i] after m_freem to avoid double-free later.
From Ilja Van Sprundel.
Also null out sc_tx_mbuf[i] after m_freem, out of paranoia.
XXX Not entirely clear to how tx mbufs are freed, but no way to test
this since it's ews4800mips- and hp700-only, so not keen to make any
more elaborate changes...
 1.29.22.1  18-May-2014  rmind sync with head
 1.29.20.1  18-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1475):
sys/dev/ic/i82596.c: revision 1.37
Null out sc_rx_mbuf[i] after m_freem to avoid double-free later.
From Ilja Van Sprundel.
Also null out sc_tx_mbuf[i] after m_freem, out of paranoia.
XXX Not entirely clear to how tx mbufs are freed, but no way to test
this since it's ews4800mips- and hp700-only, so not keen to make any
more elaborate changes...
 1.29.18.2  03-Dec-2017  jdolecek update from HEAD
 1.29.18.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.14.1  18-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1475):
sys/dev/ic/i82596.c: revision 1.37
Null out sc_rx_mbuf[i] after m_freem to avoid double-free later.
From Ilja Van Sprundel.
Also null out sc_tx_mbuf[i] after m_freem, out of paranoia.
XXX Not entirely clear to how tx mbufs are freed, but no way to test
this since it's ews4800mips- and hp700-only, so not keen to make any
more elaborate changes...
 1.29.8.1  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.31.6.5  28-Aug-2017  skrll Sync with HEAD
 1.31.6.4  05-Feb-2017  skrll Sync with HEAD
 1.31.6.3  09-Jul-2016  skrll Sync with HEAD
 1.31.6.2  19-Mar-2016  skrll Sync with HEAD
 1.31.6.1  06-Apr-2015  skrll Sync with HEAD
 1.31.4.2  12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1471):
sys/dev/ic/i82596.c: revision 1.37
Null out sc_rx_mbuf[i] after m_freem to avoid double-free later.
From Ilja Van Sprundel.
Also null out sc_tx_mbuf[i] after m_freem, out of paranoia.
XXX Not entirely clear to how tx mbufs are freed, but no way to test
this since it's ews4800mips- and hp700-only, so not keen to make any
more elaborate changes...
 1.31.4.1  21-Feb-2015  martin branches: 1.31.4.1.2; 1.31.4.1.6;
Pull up following revision(s) (requested by skrll in ticket #540):
sys/dev/ic/i82596.c: revision 1.32
Fix multicast handling.
Fixes PR kern/49472, patch from Nick Hudson.
 1.31.4.1.6.1  12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1471):
sys/dev/ic/i82596.c: revision 1.37
Null out sc_rx_mbuf[i] after m_freem to avoid double-free later.
From Ilja Van Sprundel.
Also null out sc_tx_mbuf[i] after m_freem, out of paranoia.
XXX Not entirely clear to how tx mbufs are freed, but no way to test
this since it's ews4800mips- and hp700-only, so not keen to make any
more elaborate changes...
 1.31.4.1.2.1  12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1471):
sys/dev/ic/i82596.c: revision 1.37
Null out sc_rx_mbuf[i] after m_freem to avoid double-free later.
From Ilja Van Sprundel.
Also null out sc_tx_mbuf[i] after m_freem, out of paranoia.
XXX Not entirely clear to how tx mbufs are freed, but no way to test
this since it's ews4800mips- and hp700-only, so not keen to make any
more elaborate changes...
 1.34.2.2  20-Mar-2017  pgoyette Sync with HEAD
 1.34.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.35.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.36.6.1  05-Aug-2017  snj Pull up following revision(s) (requested by spz in ticket #184):
sys/dev/ic/i82596.c: revision 1.37
Null out sc_rx_mbuf[i] after m_freem to avoid double-free later.
From Ilja Van Sprundel.
Also null out sc_tx_mbuf[i] after m_freem, out of paranoia.
XXX Not entirely clear to how tx mbufs are freed, but no way to test
this since it's ews4800mips- and hp700-only, so not keen to make any
more elaborate changes...
 1.37.2.1  28-Jul-2018  pgoyette Sync with HEAD
 1.38.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.38.2.1  10-Jun-2019  christos Sync with HEAD
 1.42.4.1  29-Feb-2020  ad Sync with head.

RSS XML Feed