summaryrefslogtreecommitdiff
path: root/usr/src/man/man9e/mgi_start.9e
blob: adae22a3bf6777619f1d43fcdb88993b628f941f (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
.\"
.\" This file and its contents are supplied under the terms of the
.\" Common Development and Distribution License ("CDDL"), version 1.0.
.\" You may only use this file in accordance with the terms of version
.\" 1.0 of the CDDL.
.\"
.\" A full copy of the text of the CDDL should have accompanied this
.\" source.  A copy of the CDDL is also available via the Internet at
.\" http://www.illumos.org/license/CDDL.
.\"
.\"
.\" Copyright (c) 2017, Joyent, Inc.
.\" Copyright 2022 Oxide computer Company
.\"
.Dd July 2, 2022
.Dt MGI_START 9E
.Os
.Sh NAME
.Nm mgi_start ,
.Nm mgi_stop ,
.Nm mri_start ,
.Nm mri_stop
.Nd MAC group and ring start and stop entry points
.Sh SYNOPSIS
.In sys/mac_provider.h
.Ft int
.Fo prefix_group_start
.Fa "mac_group_driver_t gh"
.Fc
.Ft void
.Fo prefix_group_stop
.Fa "mac_group_driver_t gh"
.Fc
.Ft int
.Fo prefix_ring_start
.Fa "mac_ring_driver_t rh"
.Fa "uint64_t mr_gen"
.Fc
.Ft void
.Fo prefix_ring_stop
.Fa "mac_ring_driver_t rh"
.Fc
.Sh INTERFACE LEVEL
.Sy Uncommitted -
This interface is still evolving.
API and ABI stability is not guaranteed.
.Sh PARAMETERS
.Bl -tag -width Fa
.It Fa driver
A pointer to the ring's private data that was passed in via the
.Vt mgi_driver
member of the
.Xr mac_group_info 9S
structure as part of the
.Xr mr_gget 9E
entry point.
.It Fa rh
A pointer to the ring's private data that was passed in via the
.Vt mri_driver
member of the
.Xr mac_ring_info 9S
structure as part of the
.Xr mr_rget 9E
entry point.
.It Fa mr_gen
A 64-bit generation number.
.El
.Sh DESCRIPTION
The
.Fn mgi_start ,
.Fn mgi_stop ,
.Fn mri_start ,
and
.Fn mri_stop
entry points are used to start and stop MAC rings and groups.
The group entry points are optional, while the ring entry points are
required.
The group start entry point will be called before any rings and
similarly, the ring stop entry point will be called for all rings before
the group stop entry point.
In the group case, the group is identified by
.Fa gh ,
while the ring entry points use
.Fa rh
to identify the specific ring.
These are opaque pointers to data that was set in the
.Xr mac_group_info 9S
and
.Xr mac_ring_info 9S
structures during the
.Xr mr_gget 9E
and
.Xr mr_rget 9E
entry points respectively.
.Pp
These entry points give the driver a chance to take action prior to
actually transmitting or receiving any data.
The amount of work that is required will vary based on the driver and
its design.
At a minimum, during the
.Fn mri_start
entry point, a driver is required to save the value of
.Fa mr_gen
for later use, in particular when calling
.Xr mac_rx_ring 9E .
This is used by the system to discriminate between generations of the
device's configuration and its operation.
The operating system will check that all received packets are called
with the value of
.Fa mr_gen
that it expects.
If they do not match, then they received packets will be dropped.
.Pp
In general, it is recommended that descriptor rings are allocated during
the driver's initial
.Xr attach 9E .
In contrast, allocating and freeing the actual memory associated with
the descriptor entries during ring start and stop can be a reasonable
way to try and reduce memory overhead of the driver.
For example, a receive ring generally needs to allocate one DMA buffer
for each entry in its receive ring that covers the maximum frame size
that the device can receive.
This is something that could be deferred to the
.Fn mri_start
entry point and then freed in the
.Fn mri_stop
entry point.
.Pp
It's worth noting that the
.Fn mrg_stop
and
.Fn mrg_stop
entry points purposefully return
.Ft void .
In particular, this means that the driver must be careful about doing
things which might fail, such as asynchronous communication to a device.
If that is necessary and such communication fails, the device should be
marked as faulted and attempt to recover via a reset or similar
mechanism in another context.
.Sh RETURN VALUES
Upon successful completion, the
.Fn mgi_start
and
.Fn mri_start
entry points should return
.Sy 0 .
Otherwise, they should return the appropriate error number.
.Sh SEE ALSO
.Xr mac 9E ,
.Xr mac_capab_rings 9E ,
.Xr mr_gget 9E ,
.Xr mac_group_info 9S