summaryrefslogtreecommitdiff
path: root/usr/src/man/man9f/mac_rx.9f
blob: efd7b2c0b9cd89cd476897da6cb31d5cda2c48ff (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
.\"
.\" 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 Compuer Company
.\"
.Dd July 2, 2022
.Dt MAC_RX 9F
.Os
.Sh NAME
.Nm mac_rx ,
.Nm mac_ring_rx
.Nd deliver frames from a driver to the system
.Sh SYNOPSIS
.In sys/mac_provider.h
.Ft void
.Fo mac_rx
.Fa "mac_handle_t mh"
.Fa "mac_resource_handle_t mrh"
.Fa "mblk_t *mp_chain"
.Fc
.Ft void
.Fo mac_rx_ring
.Fa "mac_handle_t mh"
.Fa "mac_ring_handle_t mring"
.Fa "mblk_t *mp_chain"
.Fa "uint64_t mr_gen"
.Fc
.Sh INTERFACE LEVEL
illumos DDI specific
.Pp
The
.Fn mac_rx_ring
function point is
.Sy Uncommitted -
API and ABI stability is not guaranteed.
.Sh PARAMETERS
.Bl -tag -width Fa
.It Fa mh
The MAC handle obtained from a call to
.Xr mac_register 9F .
.It Fa mrh
A reserved parameter that should be passed as
.Dv NULL .
.It Fa mring
A pointer to the ring handle that was passed to the driver in the
.Xr mr_rget 9E
entry point.
.It Fa mp_chain
A series of one or more
.Xr mblk 9S
structures chained together by their
.Sy b_next
member.
.It Fa mr_gen
The generation number for the current ring.
The generation comes from the
.Xr mri_start 9E
entry point.
.El
.Sh DESCRIPTION
The
.Fn mac_rx
function is used by device drivers to deliver frames that a device
driver has received to the rest of the operating system.
This will generally be called at the end of a device driver's interrupt handler
after it is has converted all of the incoming data into a chain of
.Xr mblk 9S
structures.
For a full description of the process that the device driver should take as part
of receiving data, see the
.Sx Receiving Data
section of
.Xr mac 9E .
.Pp
Device drivers should ensure that they are not holding any of their own
locks when they call the
.Fn mac_rx
function.
.Pp
Device drivers should not call the
.Fn mac_rx
function after each individual mblk_t is assembled.
Rather, the device driver should batch up as many frames as it is willing to
process in a given interrupt or are available.
.Pp
The
.Fn mac_rx_ring
function is similar to the
.Fa mac_rx
function; however, it should be called by device drivers that have
negotiated the
.Dv MAC_CAPAB_RINGS
capability and indicated that it supports receive groups.
Device drivers that have negotiated this capability must not call the
.Fn mac_rx
function, but use the
.Fn mac_rx_ring
function instead.
The driver should pass the ring handle in
.Fa mring
for the ring in question that it processed.
If more than one ring was processed during an interrupt, then the driver
must call
.Fn mac_ring_rx
once for each ring and ensure that the
.Fa mr_gen
argument matches what was passed to the driver during the
.Xr mri_start 9E
entry point for each ring.
If the value of
.Fa mr_gen
does not match what the operating system expects, all of the packets
will be dropped.
This is used to make sure that the system is receiving what it considers
valid data from the device driver.
.Pp
When a driver supporting the
.Dv MAC_CAPAB_RINGS
capability is asked to poll via their
.Xr mri_poll 9E
entry point, then the driver should not call the
.Fn mac_ring_rx
function to deliver packets and instead returns them during the
.Xr mri_poll 9E
call.
.Sh CONTEXT
The
.Fn mac_rx
function can be called from
.Sy user ,
.Sy kernel ,
or
.Sy interrupt
context.
.Sh SEE ALSO
.Xr mac 9E ,
.Xr mac_capab_rings 9E ,
.Xr mr_rget 9E ,
.Xr mri_poll 9E ,
.Xr mri_start 9E ,
.Xr mac_register 9F ,
.Xr mblk 9S