1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
.\" $OpenBSD: ifq_enqueue.9,v 1.1 2015/11/20 11:15:07 dlg Exp $
.\"
.\" Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" 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 20 2015 $
.Dt IFQ_ENQUEUE 9
.Os
.Sh NAME
.Nm ifq_enqueue ,
.Nm ifq_dequeue ,
.Nm ifq_deq_begin ,
.Nm ifq_deq_commit ,
.Nm ifq_deq_rollback ,
.Nm ifq_purge ,
.Nm ifq_len ,
.Nm ifq_empty
.Nd interface send queue API
.Sh SYNOPSIS
.In net/if_var.h
.Ft int
.Fn ifq_enqueue "struct ifqueue *ifq" "struct mbuf *m"
.Ft struft mbuf *
.Fn ifq_dequeue "struct ifqueue *ifq"
.Ft struft mbuf *
.Fn ifq_deq_begin "struct ifqueue *ifq"
.Ft void
.Fn ifq_deq_commit "struct ifqueue *ifq" "struct mbuf *m"
.Ft void
.Fn ifq_deq_rollback "struct ifqueue *ifq" "struct mbuf *m"
.Ft unsigned int
.Fn ifq_purge "struct ifqueue *ifq"
.Ft unsigned int
.Fn ifq_len "struct ifqueue *ifq"
.Ft unsigned int
.Fn ifq_empty "struct ifqueue *ifq"
.Sh DESCRIPTION
The ifqueue API provides implementions of data structures and
operations for the network stack to queue mbufs for a network driver
to dequeue from its start routine for transmission.
.Bl -tag -width Ds
.It Fn ifq_enqueue "struct ifqueue *ifq" "struct mbuf *m"
Enqueue mbuf
.Fa m
on the
.Fa ifq
interface send queue.
If the queue rejects the packet it will be freed with
.Xr m_freem 9
and counted as a drop.
.It Fn ifq_dequeue "struct ifqueue *ifq"
Dequeue the next mbuf to be transmitted from the
.Fa ifq
interface send queue.
.It Fn ifq_deq_begin "struct ifqueue *ifq"
Get a reference to the next mbuf to be transmitted from the
.Fa ifq
interface send queue.
If an mbuf is to be transmitted, also acquire a lock on the send queue
to exclude modification or freeing of the referenced mbuf.
The mbuf must not be freed, or have its length (m_pkthdr.len) or
cookie (m_pkthdr.ph_cookie) modified until it has been dequeued
completely with
.Fn ifq_deq_commit .
.It Fn ifq_deq_commit "struct ifqueue *ifq" "struct mbuf *m"
Dequeue the mbuf
.Fa m
that was referenced by a previous call to
.Fn ifq_deq_begin
and release the lock on
.Fa ifq .
.It Fn ifq_deq_rollback "struct ifqueue *ifq" "struct mbuf *m"
Release the lock on the interface send queue
.Fa ifq
that was acquired while a reference to
.Fa m
was being held.
.It Fn ifq_purge "struct ifqueue *ifq"
Free all the mbufs on the interface send queue
.Fa ifq .
Freed mbufs will be accounted as drops.
.It Fn ifq_len "struct ifqueue *ifq"
Return the number of mbufs on the interface send queue
.Fa ifq .
Note that while
.Fn ifq_len
may report that mbufs are on the queue, the current queue
discipline may not make them available for dequeueing with
.Fn ifq_dequeue
or
.Fn ifq_deq_begin .
.It Fn ifq_empty "struct ifqueue *ifq"
Return if the interface send queue
.Fa ifq
is empty.
.El
.Sh CONTEXT
.Fn ifq_enqueue ,
.Fn ifq_dequeue ,
.Fn ifq_deq_begin ,
.Fn ifq_deq_commit ,
.Fn ifq_deq_rollback ,
.Fn ifq_purge ,
.Fn ifq_len ,
and
.Fn ifq_empty
can be called during autoconf, from process context, or from interrupt context.
.Sh RETURN VALUES
.Fn ifq_enqueue
returns 0 if the mbuf was successfully queued, or non-zero if mbuf was freed.
.Pp
.Fn ifq_dequeue
and
.Fn ifq_deq_begin
return the next mbuf to be transmitted by the interface.
If no packet is available for transmission,
.Dv NULL
is returned.
.Pp
.Fn ifq_purge
returns the number of mbufs that were removed from the queue and freed.
.Pp
.Fn ifq_len
returns the number of mbufs on the queue.
.Pp
.Fn ifq_empty
returns a non-zero value if the queue is empty, otherwise 0.
.Sh SEE ALSO
.Xr m_freem 9
|