summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2017-11-17 03:51:32 +0000
committerdlg <dlg@openbsd.org>2017-11-17 03:51:32 +0000
commit2f18dd38c410486606b165cdecd39e98319aec5c (patch)
tree7974da673b6439bab7c8566fa6c8cdbb8f8aec29
parentthe COMPILER transition mechanism is gone (diff)
downloadwireguard-openbsd-2f18dd38c410486606b165cdecd39e98319aec5c.tar.xz
wireguard-openbsd-2f18dd38c410486606b165cdecd39e98319aec5c.zip
add if_rxr_livelocked so rxr users can request backpressure themselves.
right now the rx ring moderation code makes a decision globally that a machine is livelocked, and uses that to apply backpressure on all the rx rings. we're moving toward having the network stack run on multiple cpus, and fed from multiple rx rings. if_rxr_livelocked lets a driver apply backpressure explicitely if something tells it that whatever is consuming previous packets cannot keep up. while here expose the current ring watermark with if_rxr_cwm. tweaks and ok visa@
-rw-r--r--share/man/man9/if_rxr_init.921
-rw-r--r--sys/net/if.c15
-rw-r--r--sys/net/if_var.h4
3 files changed, 35 insertions, 5 deletions
diff --git a/share/man/man9/if_rxr_init.9 b/share/man/man9/if_rxr_init.9
index 033a2ab1156..223422bcd54 100644
--- a/share/man/man9/if_rxr_init.9
+++ b/share/man/man9/if_rxr_init.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: if_rxr_init.9,v 1.6 2017/11/15 01:41:20 dlg Exp $
+.\" $OpenBSD: if_rxr_init.9,v 1.7 2017/11/17 03:51:32 dlg Exp $
.\"
.\" Copyright (c) 2014 David Gwynne <dlg@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: November 15 2017 $
+.Dd $Mdocdate: November 17 2017 $
.Dt IF_RXR_INIT 9
.Os
.Sh NAME
@@ -33,8 +33,12 @@
.Fn if_rxr_get "struct if_rxring *rxr" "unsigned int max"
.Ft void
.Fn if_rxr_put "struct if_rxring *rxr" "unsigned int n"
+.Ft void
+.Fn if_rxr_livelocked "struct if_rxring *rxr"
.Ft unsigned int
.Fn if_rxr_inuse "struct if_rxring *rxr"
+.Ft unsigned int
+.Fn if_rxr_cwm "struct if_rxring *rxr"
.Ft int
.Fo if_rxr_ioctl
.Fa "struct if_rxrinfo *ifri"
@@ -81,10 +85,16 @@ returns
.Fa n
receive descriptor slots to the ring.
.Pp
+.Fn if_rxr_livelocked
+can signal that that receive ring is generating too much load.
+.Pp
.Fn if_rxr_inuse
can be used to determine how many descriptor slots have been allocated
on the ring.
.Pp
+.Fn if_rxr_cwm
+can be used to determine what the current watermark is for the ring.
+.Pp
The
.Fn if_rxr_ioctl
and
@@ -128,8 +138,10 @@ to fill them again.
.Fn if_rxr_init ,
.Fn if_rxr_get ,
.Fn if_rxr_put ,
+.Fn if_rxr_livelocked ,
+.Fn if_rxr_inuse ,
and
-.Fn if_rxr_inuse
+.Fn if_rxr_cwm
can be called during autoconf, from process context, or from interrupt context.
.Pp
.Fn if_rxr_ioctl
@@ -150,6 +162,9 @@ requested.
.Pp
.Fn if_rxr_inuse
returns the number of receive descriptor slots currently in use on the ring.
+.Pp
+.Fn if_rxr_cwm
+returns the currently allowed allocation watermark.
.Sh SEE ALSO
.Xr autoconf 9
.Sh HISTORY
diff --git a/sys/net/if.c b/sys/net/if.c
index 0a985222d8d..ebf7d3e8280 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.528 2017/11/14 16:01:55 tb Exp $ */
+/* $OpenBSD: if.c,v 1.529 2017/11/17 03:51:32 dlg Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -2834,6 +2834,19 @@ if_rxr_adjust_cwm(struct if_rxring *rxr)
rxr->rxr_adjusted = ticks;
}
+void
+if_rxr_livelocked(struct if_rxring *rxr)
+{
+ extern int ticks;
+
+ if (ticks - rxr->rxr_adjusted >= 1) {
+ if (rxr->rxr_cwm > rxr->rxr_lwm)
+ rxr->rxr_cwm--;
+
+ rxr->rxr_adjusted = ticks;
+ }
+}
+
u_int
if_rxr_get(struct if_rxring *rxr, u_int max)
{
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 4d65644cfee..bedb61bb81d 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_var.h,v 1.83 2017/10/31 22:05:12 sashan Exp $ */
+/* $OpenBSD: if_var.h,v 1.84 2017/11/17 03:51:32 dlg Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -333,11 +333,13 @@ void if_ih_insert(struct ifnet *, int (*)(struct ifnet *, struct mbuf *,
void if_ih_remove(struct ifnet *, int (*)(struct ifnet *, struct mbuf *,
void *), void *);
+void if_rxr_livelocked(struct if_rxring *);
void if_rxr_init(struct if_rxring *, u_int, u_int);
u_int if_rxr_get(struct if_rxring *, u_int);
#define if_rxr_put(_r, _c) do { (_r)->rxr_alive -= (_c); } while (0)
#define if_rxr_inuse(_r) ((_r)->rxr_alive)
+#define if_rxr_cwm(_r) ((_r)->rxr_cwm)
int if_rxr_info_ioctl(struct if_rxrinfo *, u_int, struct if_rxring_info *);
int if_rxr_ioctl(struct if_rxrinfo *, const char *, u_int,