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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
.\"
.\" 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.
.\"
.Dd Feb 21, 2017
.Dt MAC_CAPAB_LED 9E
.Os
.Sh NAME
.Nm mac_capab_led ,
.Nm mcl_set
.Nd MAC LED capability
.Sh SYNOPSIS
.In sys/mac_provider.h
.Vt typedef struct mac_capab_led mac_capab_led_t;
.Vt typedef enum mac_led_mode mac_led_mode_t;
.Ft int
.Fo mcl_set
.Fa "void *driver"
.Fa "mac_led_mode_t mode"
.Fa "uint_t flags"
.Fc
.Sh INTERFACE LEVEL
.Sy Evolving -
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 driver's private data that was passed in via the
.Sy m_pdata
member of the
.Xr mac_register 9S
structure to the
.Xr mac_register 9F
function.
.It Fa mode
A value that indicates how the driver should drive the LEDs.
See the
.Sx LED MODES
section for a list of supported modes.
.It Fa flags
Reserved for future use.
.El
.Sh DESCRIPTION
The
.Sy MAC_CAPAB_LED
capability allows GLDv3 device drivers to expose an interface for
controlling the LEDs on the device.
This allows the system to control the LEDs to assist system
administrators in finding and identifying specific physical devices in
the system.
.Pp
Implementing this capability is optional.
For more information on how to handle capabilities and how to indicate
that a capability is not supported, see
.Xr mc_getcapab 9E .
.Pp
This capability should be implemented if the device in question provides
a way to manipulate its LEDs.
Generally the LEDs on a device default to indicating link status and
activity.
However, they can often be turned off or set to a specific pattern for
identification purposes.
.Ss LED MODES
The system has a notion of different LED modes.
Each LED mode suggests a different way that a device driver should drive
the indicator LEDs on the device.
While we generally want all such LED modes to be as uniform
as possible, there is a limit to such similarities due to the
capabilities of NICs.
Each mode is a member of the
.Vt mac_led_mode_t
enumeration.
The currently defined modes are:
.Bl -tag -width Dv -offset indent
.It Dv MAC_LED_DEFAULT
This mode indicates that the device's default behavior should be used.
This is usually some form of link status and activity.
It is device specific and usually is the default behavior after a device
is powered on.
.It Dv MAC_LED_OFF
This mode indicates that the device's LEDs should be turned off and not
emit any light.
.It Dv MAC_LED_ON
This mode indicates that the device's LEDs should be turned on and
remain solid.
.It Dv MAC_LED_IDENT
This mode indicates that the driver should emit some form of
identification pattern.
We suggest that devices indicate some form of solid blinking light that
is on and off at alternating units of time, for example, every 200
milliseconds.
If it is possible to use an alternate color from the normal link up and
activity lighting, that is recommended.
.El
.Ss MAC Capability Structure
When the device driver's
.Xr mc_getcapab 9E
function entry point is called with the capability set to
.Dv MAC_CAPAB_LED ,
then the value of the capability structure is the following structure:
.Bd -literal -offset indent
typedef struct mac_capab_led {
uint_t mcl_flags;
mac_led_mode_t mcl_modes;
int (*mcl_set)(void *driver, mac_led_mode_t mode,
uint_t flags);
} mac_capab_led_t;
.Ed
.Pp
If the driver supports the
.Dv MAC_CAPAB_LED
capability, it should fill in this structure, based on the following
rules:
.Bl -tag -width Vt
.It Fa mcl_flags
The
.Fa mcl_flags
member is used to negotiate extensions with the driver.
MAC will set the value of
.Fa mcl_flags
to include all of the currently known extensions.
The driver should intersect this list with the set that they actually
support.
At this time, no such features are defined and the driver should set the
member to
.Sy 0 .
.It Fa mcl_modes
The
.Fa mcl_modes
member represents the support modes of the device driver.
The device driver should set
.Vt mcl_modes
to the bitwise-inclusive-OR of the LED modes listed in
.Sx LED MODES .
.Pp
If the driver does not support anything other than the default behavior
of
.Dv MAC_LED_DEFAULT ,
then the device driver should not indicate that it supports this
capability.
.It Fa mcl_set
The
.Fa mcl_set
entry point will be called by the MAC framework when it needs the device
driver to change how it is driving its LEDs.
Each call will ask the driver to change the display mode to the
specified mode.
The driver does not have to multiplex requests for multiple modes or
keep track of what has been requested, that is taken care of by the
system itself.
.Pp
The driver should first validate that
.Fa mode
is a mode that it supports.
While the device reports the set of supported modes as a
bitwise-inclusive-OR, the driver should only receive a single value in
.Fa mode .
The value of the
.Fa flags
argument is reserved for future use.
Drivers must check that the value of flags is zero and if not, return
.Er EINVAL .
.Pp
When this entry point is first called on a driver, it should snapshot
its device registers such that it knows how to restore the default
behavior.
Because each method of programming the LEDs is different, it
is up to the driver itself to take care of this, the broader framework
cannot take care of it.
.Pp
If for some reason the driver is asked to program the same mode that it
is already driving, then it need not do anything and should simply
return success.
.Pp
Once the driver successfully changes the LED driving mode, it should
return
.Sy 0 .
Otherwise, it should return the appropriate error number.
For a full list of error numbers, see
.Xr Intro 2 .
Common values are:
.Bl -tag -width Er -offset width
.It Er EINVAL
.Fa flag
contains an unknown value.
.It Er ENOTSUP
.Fa mode
is unsupported.
.Fa flags
contains an unsupported or unknown value.
.It Er EIO
An I/O error occurred while trying to program the device's registers.
This could be because a command timed out or an FM-aware driver
encountered an error.
.El
.Pp
The broader framework will guarantee that only a single call to the
.Fa mcl_set
function is ongoing at any time.
If other parts of the driver refer to the data used by the
.Fa mcl_set
function, then the driver must ensure that it is performing sufficient
locking of its data.
.El
.Sh CONTEXT
The
.Ft mcl_set
entry point will only be called from
.Sy user
or
.Sy kernel
context.
It will never be called from interrupt context.
.Sh SEE ALSO
.Xr Intro 2 ,
.Xr mac 9E ,
.Xr mc_getcapab 9E ,
.Xr mac_register 9F
|