History log of /openbsd-current/sys/dev/ic/ti.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.30 10-Nov-2023 bluhm

Make ifq and ifiq interface MP safe.

Rename ifq_set_maxlen() to ifq_init_maxlen(). This function neither
uses WRITE_ONCE() nor a mutex and is called before the ifq mutex
is initialized. The new name expresses that it should be used only
during interface attach when there is no concurrency.

Protect ifq_len(), ifq_empty(), ifiq_len(), and ifiq_empty() with
READ_ONCE(). They can be used without lock as they only read a
single integer.

OK dlg@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.29 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.28 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


Revision tags: OPENBSD_6_8_BASE
# 1.27 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.26 25-Sep-2019 kevlo

Argument order fix for MCLGETI.

ok claudio@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.25 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.24 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.23 10-Mar-2016 mmcc

don't check stack-allocated arrays against NULL

ok mpi@


Revision tags: OPENBSD_5_9_BASE
# 1.22 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.21 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.20 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.19 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.18 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.17 09-Sep-2015 deraadt

sizes for free(); ok semarie


# 1.16 12-Aug-2015 semarie

removes two mem leaks in ti (in error path).

one leak reported by Maxime Villard
initial patch from Christian Schulte (with spelling corrections in comments)
second leak corrected by myself

ok kettenis@


Revision tags: OPENBSD_5_8_BASE
# 1.15 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.14 19-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.13 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.12 22-Dec-2014 tedu

unifdef INET


# 1.11 06-Dec-2014 krw

A few last 'easy' #include dedups.

ok tedu@


# 1.10 20-Aug-2014 dlg

replace the custom jumbo allocator with MCLGETI.

putting this in the tree to make it easier for people to test.


Revision tags: OPENBSD_5_6_BASE
# 1.9 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.8 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.7 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.6 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.5 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.4 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


Revision tags: OPENBSD_4_9_BASE
# 1.3 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.2 13-Dec-2009 kettenis

Cleanup promiscuous mode and multicast handling. From Brad.


# 1.1 29-Aug-2009 kettenis

Split the ti(4) driver into mostly bus-agnostic code and PCI-specific
attachment. Add SBus support to the bus-agnostic code.


# 1.29 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.28 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


Revision tags: OPENBSD_6_8_BASE
# 1.27 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.26 25-Sep-2019 kevlo

Argument order fix for MCLGETI.

ok claudio@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.25 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.24 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.23 10-Mar-2016 mmcc

don't check stack-allocated arrays against NULL

ok mpi@


Revision tags: OPENBSD_5_9_BASE
# 1.22 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.21 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.20 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.19 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.18 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.17 09-Sep-2015 deraadt

sizes for free(); ok semarie


# 1.16 12-Aug-2015 semarie

removes two mem leaks in ti (in error path).

one leak reported by Maxime Villard
initial patch from Christian Schulte (with spelling corrections in comments)
second leak corrected by myself

ok kettenis@


Revision tags: OPENBSD_5_8_BASE
# 1.15 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.14 19-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.13 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.12 22-Dec-2014 tedu

unifdef INET


# 1.11 06-Dec-2014 krw

A few last 'easy' #include dedups.

ok tedu@


# 1.10 20-Aug-2014 dlg

replace the custom jumbo allocator with MCLGETI.

putting this in the tree to make it easier for people to test.


Revision tags: OPENBSD_5_6_BASE
# 1.9 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.8 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.7 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.6 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.5 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.4 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


Revision tags: OPENBSD_4_9_BASE
# 1.3 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.2 13-Dec-2009 kettenis

Cleanup promiscuous mode and multicast handling. From Brad.


# 1.1 29-Aug-2009 kettenis

Split the ti(4) driver into mostly bus-agnostic code and PCI-specific
attachment. Add SBus support to the bus-agnostic code.


# 1.28 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


Revision tags: OPENBSD_6_8_BASE
# 1.27 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.26 25-Sep-2019 kevlo

Argument order fix for MCLGETI.

ok claudio@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.25 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.24 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.23 10-Mar-2016 mmcc

don't check stack-allocated arrays against NULL

ok mpi@


Revision tags: OPENBSD_5_9_BASE
# 1.22 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.21 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.20 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.19 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.18 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.17 09-Sep-2015 deraadt

sizes for free(); ok semarie


# 1.16 12-Aug-2015 semarie

removes two mem leaks in ti (in error path).

one leak reported by Maxime Villard
initial patch from Christian Schulte (with spelling corrections in comments)
second leak corrected by myself

ok kettenis@


Revision tags: OPENBSD_5_8_BASE
# 1.15 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.14 19-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.13 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.12 22-Dec-2014 tedu

unifdef INET


# 1.11 06-Dec-2014 krw

A few last 'easy' #include dedups.

ok tedu@


# 1.10 20-Aug-2014 dlg

replace the custom jumbo allocator with MCLGETI.

putting this in the tree to make it easier for people to test.


Revision tags: OPENBSD_5_6_BASE
# 1.9 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.8 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.7 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.6 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.5 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.4 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


Revision tags: OPENBSD_4_9_BASE
# 1.3 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.2 13-Dec-2009 kettenis

Cleanup promiscuous mode and multicast handling. From Brad.


# 1.1 29-Aug-2009 kettenis

Split the ti(4) driver into mostly bus-agnostic code and PCI-specific
attachment. Add SBus support to the bus-agnostic code.


# 1.27 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.26 25-Sep-2019 kevlo

Argument order fix for MCLGETI.

ok claudio@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.25 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.24 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.23 10-Mar-2016 mmcc

don't check stack-allocated arrays against NULL

ok mpi@


Revision tags: OPENBSD_5_9_BASE
# 1.22 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.21 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.20 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.19 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.18 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.17 09-Sep-2015 deraadt

sizes for free(); ok semarie


# 1.16 12-Aug-2015 semarie

removes two mem leaks in ti (in error path).

one leak reported by Maxime Villard
initial patch from Christian Schulte (with spelling corrections in comments)
second leak corrected by myself

ok kettenis@


Revision tags: OPENBSD_5_8_BASE
# 1.15 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.14 19-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.13 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.12 22-Dec-2014 tedu

unifdef INET


# 1.11 06-Dec-2014 krw

A few last 'easy' #include dedups.

ok tedu@


# 1.10 20-Aug-2014 dlg

replace the custom jumbo allocator with MCLGETI.

putting this in the tree to make it easier for people to test.


Revision tags: OPENBSD_5_6_BASE
# 1.9 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.8 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.7 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.6 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.5 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.4 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


Revision tags: OPENBSD_4_9_BASE
# 1.3 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.2 13-Dec-2009 kettenis

Cleanup promiscuous mode and multicast handling. From Brad.


# 1.1 29-Aug-2009 kettenis

Split the ti(4) driver into mostly bus-agnostic code and PCI-specific
attachment. Add SBus support to the bus-agnostic code.


# 1.26 25-Sep-2019 kevlo

Argument order fix for MCLGETI.

ok claudio@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.25 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.24 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.23 10-Mar-2016 mmcc

don't check stack-allocated arrays against NULL

ok mpi@


Revision tags: OPENBSD_5_9_BASE
# 1.22 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.21 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.20 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.19 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.18 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.17 09-Sep-2015 deraadt

sizes for free(); ok semarie


# 1.16 12-Aug-2015 semarie

removes two mem leaks in ti (in error path).

one leak reported by Maxime Villard
initial patch from Christian Schulte (with spelling corrections in comments)
second leak corrected by myself

ok kettenis@


Revision tags: OPENBSD_5_8_BASE
# 1.15 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.14 19-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.13 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.12 22-Dec-2014 tedu

unifdef INET


# 1.11 06-Dec-2014 krw

A few last 'easy' #include dedups.

ok tedu@


# 1.10 20-Aug-2014 dlg

replace the custom jumbo allocator with MCLGETI.

putting this in the tree to make it easier for people to test.


Revision tags: OPENBSD_5_6_BASE
# 1.9 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.8 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.7 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.6 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.5 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.4 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


Revision tags: OPENBSD_4_9_BASE
# 1.3 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.2 13-Dec-2009 kettenis

Cleanup promiscuous mode and multicast handling. From Brad.


# 1.1 29-Aug-2009 kettenis

Split the ti(4) driver into mostly bus-agnostic code and PCI-specific
attachment. Add SBus support to the bus-agnostic code.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.25 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.24 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.23 10-Mar-2016 mmcc

don't check stack-allocated arrays against NULL

ok mpi@


Revision tags: OPENBSD_5_9_BASE
# 1.22 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.21 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.20 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.19 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.18 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.17 09-Sep-2015 deraadt

sizes for free(); ok semarie


# 1.16 12-Aug-2015 semarie

removes two mem leaks in ti (in error path).

one leak reported by Maxime Villard
initial patch from Christian Schulte (with spelling corrections in comments)
second leak corrected by myself

ok kettenis@


Revision tags: OPENBSD_5_8_BASE
# 1.15 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.14 19-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.13 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.12 22-Dec-2014 tedu

unifdef INET


# 1.11 06-Dec-2014 krw

A few last 'easy' #include dedups.

ok tedu@


# 1.10 20-Aug-2014 dlg

replace the custom jumbo allocator with MCLGETI.

putting this in the tree to make it easier for people to test.


Revision tags: OPENBSD_5_6_BASE
# 1.9 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.8 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.7 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.6 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.5 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.4 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


Revision tags: OPENBSD_4_9_BASE
# 1.3 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.2 13-Dec-2009 kettenis

Cleanup promiscuous mode and multicast handling. From Brad.


# 1.1 29-Aug-2009 kettenis

Split the ti(4) driver into mostly bus-agnostic code and PCI-specific
attachment. Add SBus support to the bus-agnostic code.