summaryrefslogtreecommitdiff
path: root/share/man/man9/ml_init.9
blob: c9a0ec95761a3c765f18231dd4005ba483d41f96 (plain)
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
.\"     $OpenBSD: ml_init.9,v 1.13 2016/04/15 05:05:21 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: April 15 2016 $
.Dt ML_INIT 9
.Os
.Sh NAME
.Nm ml_init ,
.Nm ml_enqueue ,
.Nm ml_dequeue ,
.Nm ml_enlist ,
.Nm ml_dechain ,
.Nm ml_len ,
.Nm ml_empty ,
.Nm ml_purge ,
.Nm MBUF_LIST_INITIALIZER ,
.Nm MBUF_LIST_FIRST ,
.Nm MBUF_LIST_NEXT ,
.Nm MBUF_LIST_FOREACH
.Nd mbuf list API
.Sh SYNOPSIS
.In sys/mbuf.h
.Ft void
.Fn ml_init "struct mbuf_list *ml"
.Ft void
.Fn ml_enqueue "struct mbuf_list *ml" "struct mbuf *m"
.Ft struct mbuf *
.Fn ml_dequeue "struct mbuf_list *ml"
.Ft void
.Fn ml_enlist "struct mbuf_list *ml" "struct mbuf_list *src"
.Ft struct mbuf *
.Fn ml_dechain "struct mbuf_list *ml"
.Ft unsigned int
.Fn ml_len "struct mbuf_list *ml"
.Ft int
.Fn ml_empty "struct mbuf_list *ml"
.Ft unsigned int
.Fn ml_purge "struct mbuf_list *ml"
.Ft struct mbuf_list
.Fn MBUF_LIST_INITIALIZER
.Ft struct mbuf *
.Fn MBUF_LIST_FIRST "struct mbuf_list *ml"
.Ft struct mbuf *
.Fn MBUF_LIST_NEXT "struct mbuf *m"
.Fn MBUF_LIST_FOREACH "struct mbuf_list *ml" "VARNAME"
.Sh DESCRIPTION
The mbuf list API provides implementations of data structures and operations
for managing lists of mbufs between contexts.
.Pp
mbuf_list structures support the following functionality:
.Pp
.Bl -enum -compact -offset indent
.It
Insertion of a new mbuf at the end of the list.
.It
Removal of an mbuf from the head of the list.
.El
.Bl -tag -width Ds
.It Fn ml_init "struct mbuf_list *ml"
Initialise the
.Fa ml
mbuf_list structure.
.It Fn MBUF_LIST_INITIALIZER
An initialiser for an mbuf_list structure declaration.
.It Fn ml_enqueue "struct mbuf_list *ml" "struct mbuf *m"
Enqueue mbuf
.Fa m
on the end of the
.Fa ml
mbuf list.
.It Fn ml_dequeue "struct mbuf_list *ml"
Dequeue an mbuf from the front of the
.Fa ml
mbuf list.
.It Fn ml_enlist "struct mbuf_list *ml" "struct mbuf_list *src"
Enqueue all the mbufs on the
.Fa src
mbuf list on to the end of the
.Fa ml
mbuf list.
.It Fn ml_dechain "struct mbuf_list *ml"
Dequeues all mbufs from the
.Fa ml
mbuf list.
.It Fn ml_len "struct mbuf_list *ml"
Return the number of mbufs on the
.Fa ml
mbuf list.
.It Fn ml_empty "struct mbuf_list *ml"
Return if the
.Fa ml
mbuf list is empty.
.It Fn ml_purge "struct mbuf_list *ml"
Free all the mbufs on the
.Fa ml
mbuf list.
.It Fn MBUF_LIST_FIRST "struct mbuf_list *ml"
Access the first mbuf in the
.Fa ml
mbuf list for traversal.
.It Fn MBUF_LIST_NEXT "struct mbuf *m"
Access the next mbuf in the mbuf list after
.Fa m .
.It Fn MBUF_LIST_FOREACH "struct mbuf_list *ml" "VARNAME"
A convenience macro that can be used to iterate over the contents of the
.Fa ml
mbuf list.
.Fa VARNAME
identifies the name (not the address) of an mbuf pointer that will
be set to each entry on the list.
Note that it is unsafe to modify the list while iterating over it.
.El
.Sh CONTEXT
.Fn ml_init ,
.Fn ml_enqueue ,
.Fn ml_dequeue ,
.Fn ml_enlist ,
.Fn ml_dechain ,
.Fn ml_len ,
.Fn ml_empty ,
.Fn ml_purge ,
.Fn MBUF_LIST_INITIALIZER ,
.Fn MBUF_LIST_FIRST ,
.Fn MBUF_LIST_NEXT ,
and
.Fn MBUF_LIST_FOREACH
can be called during autoconf, from process context, or from interrupt context.
.Sh RETURN VALUES
.Fn ml_dequeue
returns the mbuf that was at the head of its list.
If the list was empty,
.Dv NULL
is returned.
.Pp
.Fn ml_dechain
returns all the mbufs that were on the list via
a pointer to an mbuf with the chain accessible via m_nextpkt members.
If the list was empty,
.Dv NULL
is returned.
.Pp
.Fn ml_len
returns the number of mbufs on the list.
.Pp
.Fn ml_empty
return a non-zero value if the list is empty, otherwise 0.
.Pp
.Fn ml_purge
returns the number of mbufs that were freed.
.Pp
.Fn MBUF_LIST_FIRST
returns the first mbuf in the mbuf list, or
.Dv NULL
if the list is empty.
.Pp
.Fn MBUF_LIST_NEXT
returns the next mbuf in the mbuf list, or
.Dv NULL
if the end of the list has been reached.
.Sh SEE ALSO
.Xr mbuf 9