History log of /openbsd-current/sys/dev/pci/if_vte.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.28 24-May-2024 jsg

remove unneeded includes; ok miod@


Revision tags: OPENBSD_7_5_BASE
# 1.27 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_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.26 19-Apr-2022 kevlo

Restore original MDC speed control register value on vte_reset,
which is needed for at least Vortex86DX3 machines.

Patch from Andrius Varanavicius via bugs@

Special thanks to DMP for donating hardware which helped make this fix
possible.


Revision tags: OPENBSD_7_1_BASE
# 1.25 11-Mar-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.24 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.23 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.22 09-Nov-2018 claudio

M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers for
m_leadingspace() and m_trailingspace(). Convert all callers to call
directly the functions and remove the defines.
OK krw@, mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.21 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


# 1.20 19-Jul-2017 claudio

Fix possible double free in the TX dma ring handling. If the allocation of
the cluster fails in vte_init_tx_ring() the mbuf is removed but the slot
in the ring still holds the pointer. A possible call to vte_stop() would
then cause a double free. Again set pointer to NULL to prevent this.
Found by Ilja Van Sprundel
OK bluhm@


Revision tags: OPENBSD_6_1_BASE
# 1.19 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.18 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.17 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.16 24-Nov-2015 mpi

No need for "vlan.h" if you don't check for "#if NVLAN > 0".


# 1.15 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.14 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.13 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.12 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


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

unifdef INET


# 1.10 18-Nov-2014 tedu

move arc4random prototype to systm.h. more appropriate for most code
to include that than rdnvar.h. ok deraadt dlg


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.8 21-Nov-2013 mpi

Remove unneeded include.

ok deraadt@


# 1.7 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_3_BASE OPENBSD_5_4_BASE
# 1.6 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.5 28-May-2011 kevlo

Sync MCR0_BROADCAST register naming from FreeBSD now that its
known the register is to disable broadcast instead of enabling
broadcast packets.

From Brad


# 1.4 14-Mar-2011 kevlo

Accept broadcast frames so MCR0_BROADCAST bit must be zero;
from Anton Maksimenkov


Revision tags: OPENBSD_4_9_BASE
# 1.3 21-Jan-2011 kevlo

Get rid of the use of goto's within vte_iff funtion; from Brad


# 1.2 15-Jan-2011 kevlo

Fix multicast handling


# 1.1 15-Jan-2011 kevlo

Add drivers for the RDC R6040 Ethernet chipset
and RDC R6040 Ethernet PHY.

Written by Pyun YongHyeon for FreeBSD then
ported to OpenBSD by me.

Thanks once again to DMP for supplying hardware
which made this possible.

ok deraadt@


# 1.27 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_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.26 19-Apr-2022 kevlo

Restore original MDC speed control register value on vte_reset,
which is needed for at least Vortex86DX3 machines.

Patch from Andrius Varanavicius via bugs@

Special thanks to DMP for donating hardware which helped make this fix
possible.


Revision tags: OPENBSD_7_1_BASE
# 1.25 11-Mar-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.24 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.23 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.22 09-Nov-2018 claudio

M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers for
m_leadingspace() and m_trailingspace(). Convert all callers to call
directly the functions and remove the defines.
OK krw@, mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.21 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


# 1.20 19-Jul-2017 claudio

Fix possible double free in the TX dma ring handling. If the allocation of
the cluster fails in vte_init_tx_ring() the mbuf is removed but the slot
in the ring still holds the pointer. A possible call to vte_stop() would
then cause a double free. Again set pointer to NULL to prevent this.
Found by Ilja Van Sprundel
OK bluhm@


Revision tags: OPENBSD_6_1_BASE
# 1.19 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.18 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.17 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.16 24-Nov-2015 mpi

No need for "vlan.h" if you don't check for "#if NVLAN > 0".


# 1.15 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.14 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.13 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.12 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


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

unifdef INET


# 1.10 18-Nov-2014 tedu

move arc4random prototype to systm.h. more appropriate for most code
to include that than rdnvar.h. ok deraadt dlg


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.8 21-Nov-2013 mpi

Remove unneeded include.

ok deraadt@


# 1.7 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_3_BASE OPENBSD_5_4_BASE
# 1.6 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.5 28-May-2011 kevlo

Sync MCR0_BROADCAST register naming from FreeBSD now that its
known the register is to disable broadcast instead of enabling
broadcast packets.

From Brad


# 1.4 14-Mar-2011 kevlo

Accept broadcast frames so MCR0_BROADCAST bit must be zero;
from Anton Maksimenkov


Revision tags: OPENBSD_4_9_BASE
# 1.3 21-Jan-2011 kevlo

Get rid of the use of goto's within vte_iff funtion; from Brad


# 1.2 15-Jan-2011 kevlo

Fix multicast handling


# 1.1 15-Jan-2011 kevlo

Add drivers for the RDC R6040 Ethernet chipset
and RDC R6040 Ethernet PHY.

Written by Pyun YongHyeon for FreeBSD then
ported to OpenBSD by me.

Thanks once again to DMP for supplying hardware
which made this possible.

ok deraadt@


# 1.26 19-Apr-2022 kevlo

Restore original MDC speed control register value on vte_reset,
which is needed for at least Vortex86DX3 machines.

Patch from Andrius Varanavicius via bugs@

Special thanks to DMP for donating hardware which helped make this fix
possible.


Revision tags: OPENBSD_7_1_BASE
# 1.25 11-Mar-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.24 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.23 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.22 09-Nov-2018 claudio

M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers for
m_leadingspace() and m_trailingspace(). Convert all callers to call
directly the functions and remove the defines.
OK krw@, mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.21 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


# 1.20 19-Jul-2017 claudio

Fix possible double free in the TX dma ring handling. If the allocation of
the cluster fails in vte_init_tx_ring() the mbuf is removed but the slot
in the ring still holds the pointer. A possible call to vte_stop() would
then cause a double free. Again set pointer to NULL to prevent this.
Found by Ilja Van Sprundel
OK bluhm@


Revision tags: OPENBSD_6_1_BASE
# 1.19 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.18 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.17 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.16 24-Nov-2015 mpi

No need for "vlan.h" if you don't check for "#if NVLAN > 0".


# 1.15 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.14 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.13 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.12 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


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

unifdef INET


# 1.10 18-Nov-2014 tedu

move arc4random prototype to systm.h. more appropriate for most code
to include that than rdnvar.h. ok deraadt dlg


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.8 21-Nov-2013 mpi

Remove unneeded include.

ok deraadt@


# 1.7 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_3_BASE OPENBSD_5_4_BASE
# 1.6 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.5 28-May-2011 kevlo

Sync MCR0_BROADCAST register naming from FreeBSD now that its
known the register is to disable broadcast instead of enabling
broadcast packets.

From Brad


# 1.4 14-Mar-2011 kevlo

Accept broadcast frames so MCR0_BROADCAST bit must be zero;
from Anton Maksimenkov


Revision tags: OPENBSD_4_9_BASE
# 1.3 21-Jan-2011 kevlo

Get rid of the use of goto's within vte_iff funtion; from Brad


# 1.2 15-Jan-2011 kevlo

Fix multicast handling


# 1.1 15-Jan-2011 kevlo

Add drivers for the RDC R6040 Ethernet chipset
and RDC R6040 Ethernet PHY.

Written by Pyun YongHyeon for FreeBSD then
ported to OpenBSD by me.

Thanks once again to DMP for supplying hardware
which made this possible.

ok deraadt@


# 1.25 11-Mar-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.24 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.23 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.22 09-Nov-2018 claudio

M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers for
m_leadingspace() and m_trailingspace(). Convert all callers to call
directly the functions and remove the defines.
OK krw@, mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.21 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


# 1.20 19-Jul-2017 claudio

Fix possible double free in the TX dma ring handling. If the allocation of
the cluster fails in vte_init_tx_ring() the mbuf is removed but the slot
in the ring still holds the pointer. A possible call to vte_stop() would
then cause a double free. Again set pointer to NULL to prevent this.
Found by Ilja Van Sprundel
OK bluhm@


Revision tags: OPENBSD_6_1_BASE
# 1.19 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.18 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.17 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.16 24-Nov-2015 mpi

No need for "vlan.h" if you don't check for "#if NVLAN > 0".


# 1.15 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.14 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.13 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.12 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


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

unifdef INET


# 1.10 18-Nov-2014 tedu

move arc4random prototype to systm.h. more appropriate for most code
to include that than rdnvar.h. ok deraadt dlg


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.8 21-Nov-2013 mpi

Remove unneeded include.

ok deraadt@


# 1.7 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_3_BASE OPENBSD_5_4_BASE
# 1.6 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.5 28-May-2011 kevlo

Sync MCR0_BROADCAST register naming from FreeBSD now that its
known the register is to disable broadcast instead of enabling
broadcast packets.

From Brad


# 1.4 14-Mar-2011 kevlo

Accept broadcast frames so MCR0_BROADCAST bit must be zero;
from Anton Maksimenkov


Revision tags: OPENBSD_4_9_BASE
# 1.3 21-Jan-2011 kevlo

Get rid of the use of goto's within vte_iff funtion; from Brad


# 1.2 15-Jan-2011 kevlo

Fix multicast handling


# 1.1 15-Jan-2011 kevlo

Add drivers for the RDC R6040 Ethernet chipset
and RDC R6040 Ethernet PHY.

Written by Pyun YongHyeon for FreeBSD then
ported to OpenBSD by me.

Thanks once again to DMP for supplying hardware
which made this possible.

ok deraadt@


# 1.24 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.23 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.22 09-Nov-2018 claudio

M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers for
m_leadingspace() and m_trailingspace(). Convert all callers to call
directly the functions and remove the defines.
OK krw@, mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.21 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


# 1.20 19-Jul-2017 claudio

Fix possible double free in the TX dma ring handling. If the allocation of
the cluster fails in vte_init_tx_ring() the mbuf is removed but the slot
in the ring still holds the pointer. A possible call to vte_stop() would
then cause a double free. Again set pointer to NULL to prevent this.
Found by Ilja Van Sprundel
OK bluhm@


Revision tags: OPENBSD_6_1_BASE
# 1.19 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.18 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.17 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.16 24-Nov-2015 mpi

No need for "vlan.h" if you don't check for "#if NVLAN > 0".


# 1.15 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.14 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.13 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.12 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


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

unifdef INET


# 1.10 18-Nov-2014 tedu

move arc4random prototype to systm.h. more appropriate for most code
to include that than rdnvar.h. ok deraadt dlg


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.8 21-Nov-2013 mpi

Remove unneeded include.

ok deraadt@


# 1.7 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_3_BASE OPENBSD_5_4_BASE
# 1.6 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.5 28-May-2011 kevlo

Sync MCR0_BROADCAST register naming from FreeBSD now that its
known the register is to disable broadcast instead of enabling
broadcast packets.

From Brad


# 1.4 14-Mar-2011 kevlo

Accept broadcast frames so MCR0_BROADCAST bit must be zero;
from Anton Maksimenkov


Revision tags: OPENBSD_4_9_BASE
# 1.3 21-Jan-2011 kevlo

Get rid of the use of goto's within vte_iff funtion; from Brad


# 1.2 15-Jan-2011 kevlo

Fix multicast handling


# 1.1 15-Jan-2011 kevlo

Add drivers for the RDC R6040 Ethernet chipset
and RDC R6040 Ethernet PHY.

Written by Pyun YongHyeon for FreeBSD then
ported to OpenBSD by me.

Thanks once again to DMP for supplying hardware
which made this possible.

ok deraadt@


# 1.22 09-Nov-2018 claudio

M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers for
m_leadingspace() and m_trailingspace(). Convert all callers to call
directly the functions and remove the defines.
OK krw@, mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.21 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


# 1.20 19-Jul-2017 claudio

Fix possible double free in the TX dma ring handling. If the allocation of
the cluster fails in vte_init_tx_ring() the mbuf is removed but the slot
in the ring still holds the pointer. A possible call to vte_stop() would
then cause a double free. Again set pointer to NULL to prevent this.
Found by Ilja Van Sprundel
OK bluhm@


Revision tags: OPENBSD_6_1_BASE
# 1.19 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.18 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.17 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.16 24-Nov-2015 mpi

No need for "vlan.h" if you don't check for "#if NVLAN > 0".


# 1.15 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.14 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.13 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.12 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


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

unifdef INET


# 1.10 18-Nov-2014 tedu

move arc4random prototype to systm.h. more appropriate for most code
to include that than rdnvar.h. ok deraadt dlg


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.8 21-Nov-2013 mpi

Remove unneeded include.

ok deraadt@


# 1.7 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_3_BASE OPENBSD_5_4_BASE
# 1.6 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.5 28-May-2011 kevlo

Sync MCR0_BROADCAST register naming from FreeBSD now that its
known the register is to disable broadcast instead of enabling
broadcast packets.

From Brad


# 1.4 14-Mar-2011 kevlo

Accept broadcast frames so MCR0_BROADCAST bit must be zero;
from Anton Maksimenkov


Revision tags: OPENBSD_4_9_BASE
# 1.3 21-Jan-2011 kevlo

Get rid of the use of goto's within vte_iff funtion; from Brad


# 1.2 15-Jan-2011 kevlo

Fix multicast handling


# 1.1 15-Jan-2011 kevlo

Add drivers for the RDC R6040 Ethernet chipset
and RDC R6040 Ethernet PHY.

Written by Pyun YongHyeon for FreeBSD then
ported to OpenBSD by me.

Thanks once again to DMP for supplying hardware
which made this possible.

ok deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.21 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


# 1.20 19-Jul-2017 claudio

Fix possible double free in the TX dma ring handling. If the allocation of
the cluster fails in vte_init_tx_ring() the mbuf is removed but the slot
in the ring still holds the pointer. A possible call to vte_stop() would
then cause a double free. Again set pointer to NULL to prevent this.
Found by Ilja Van Sprundel
OK bluhm@


Revision tags: OPENBSD_6_1_BASE
# 1.19 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.18 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.17 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.16 24-Nov-2015 mpi

No need for "vlan.h" if you don't check for "#if NVLAN > 0".


# 1.15 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.14 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.13 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.12 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


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

unifdef INET


# 1.10 18-Nov-2014 tedu

move arc4random prototype to systm.h. more appropriate for most code
to include that than rdnvar.h. ok deraadt dlg


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.8 21-Nov-2013 mpi

Remove unneeded include.

ok deraadt@


# 1.7 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_3_BASE OPENBSD_5_4_BASE
# 1.6 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.5 28-May-2011 kevlo

Sync MCR0_BROADCAST register naming from FreeBSD now that its
known the register is to disable broadcast instead of enabling
broadcast packets.

From Brad


# 1.4 14-Mar-2011 kevlo

Accept broadcast frames so MCR0_BROADCAST bit must be zero;
from Anton Maksimenkov


Revision tags: OPENBSD_4_9_BASE
# 1.3 21-Jan-2011 kevlo

Get rid of the use of goto's within vte_iff funtion; from Brad


# 1.2 15-Jan-2011 kevlo

Fix multicast handling


# 1.1 15-Jan-2011 kevlo

Add drivers for the RDC R6040 Ethernet chipset
and RDC R6040 Ethernet PHY.

Written by Pyun YongHyeon for FreeBSD then
ported to OpenBSD by me.

Thanks once again to DMP for supplying hardware
which made this possible.

ok deraadt@