diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2015-12-03 12:22:52 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2015-12-03 12:22:52 +0000 |
commit | bf1238a62fc939582179123c95fc26d7d76dc5f2 (patch) | |
tree | 1ac0c5adde30dc35ad8f81291dd2b946387e8c54 /sys/net/if.h | |
parent | 5d1cc1f2e49619d168b935c6595ad7107ec10136 (diff) |
rework if_start to allow nics to provide an mpsafe start routine.
existing start routines will still be called under the kernel lock
and at IPL_NET.
mpsafe start routines will be serialised so only one instance of
each interfaces function will be running in the kernel at any point
in time. this guarantees packets will be dequeued in order, and the
start routines dont have to lock against themselves because if_start
does it for them.
the code to do that is based on the scsi runqueue code.
this also provides an if_start_barrier() function that should wait
until any currently running instances of if_start have finished.
a driver can opt in to the mpsafe if_start call by doing the following:
1. setting ifp->if_xflags = IFXF_MPSAFE
2. only calling if_start() instead of its own start routine
3. clearing IFF_RUNNING before calling if_start_barrier() on its way down
4. only using IFQ_DEQUEUE (not ifq_deq_begin/commit/rollback)
to simplify the implementation the tx mitigation code has been removed.
tested by several
ok mpi@ jmatthew@
Diffstat (limited to 'sys/net/if.h')
-rw-r--r-- | sys/net/if.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/net/if.h b/sys/net/if.h index 711ea0c4194..de071729570 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.173 2015/11/20 12:27:42 mpi Exp $ */ +/* $OpenBSD: if.h,v 1.174 2015/12/03 12:22:51 dlg Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -206,14 +206,14 @@ struct if_status_description { (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI) -#define IFXF_TXREADY 0x1 /* interface is ready to tx */ +#define IFXF_MPSAFE 0x1 /* if_start is mpsafe */ #define IFXF_INET6_NOPRIVACY 0x4 /* don't autoconf privacy */ #define IFXF_MPLS 0x8 /* supports MPLS */ #define IFXF_WOL 0x10 /* wake on lan enabled */ #define IFXF_AUTOCONF6 0x20 /* v6 autoconf enabled */ #define IFXF_CANTCHANGE \ - (IFXF_TXREADY) + (IFXF_MPSAFE) /* * Some convenience macros used for setting ifi_baudrate. |