1*b142f83dSRobert Mustacchi.\" 2*b142f83dSRobert Mustacchi.\" This file and its contents are supplied under the terms of the 3*b142f83dSRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0. 4*b142f83dSRobert Mustacchi.\" You may only use this file in accordance with the terms of version 5*b142f83dSRobert Mustacchi.\" 1.0 of the CDDL. 6*b142f83dSRobert Mustacchi.\" 7*b142f83dSRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this 8*b142f83dSRobert Mustacchi.\" source. A copy of the CDDL is also available via the Internet at 9*b142f83dSRobert Mustacchi.\" http://www.illumos.org/license/CDDL. 10*b142f83dSRobert Mustacchi.\" 11*b142f83dSRobert Mustacchi.\" 12*b142f83dSRobert Mustacchi.\" Copyright (c) 2017, Joyent, Inc. 13*b142f83dSRobert Mustacchi.\" 14*b142f83dSRobert Mustacchi.Dd Feb 21, 2017 15*b142f83dSRobert Mustacchi.Dt MAC_CAPAB_LED 9E 16*b142f83dSRobert Mustacchi.Os 17*b142f83dSRobert Mustacchi.Sh NAME 18*b142f83dSRobert Mustacchi.Nm mac_capab_led , 19*b142f83dSRobert Mustacchi.Nm mcl_set 20*b142f83dSRobert Mustacchi.Nd MAC LED capability 21*b142f83dSRobert Mustacchi.Sh SYNOPSIS 22*b142f83dSRobert Mustacchi.In sys/mac_provider.h 23*b142f83dSRobert Mustacchi.Vt typedef struct mac_capab_led mac_capab_led_t; 24*b142f83dSRobert Mustacchi.Vt typedef enum mac_led_mode mac_led_mode_t; 25*b142f83dSRobert Mustacchi.Ft int 26*b142f83dSRobert Mustacchi.Fo mcl_set 27*b142f83dSRobert Mustacchi.Fa "void *driver" 28*b142f83dSRobert Mustacchi.Fa "mac_led_mode_t mode" 29*b142f83dSRobert Mustacchi.Fa "uint_t flags" 30*b142f83dSRobert Mustacchi.Fc 31*b142f83dSRobert Mustacchi.Sh INTERFACE LEVEL 32*b142f83dSRobert Mustacchi.Sy Evolving - 33*b142f83dSRobert MustacchiThis interface is still evolving. 34*b142f83dSRobert MustacchiAPI and ABI stability is not guaranteed. 35*b142f83dSRobert Mustacchi.Sh PARAMETERS 36*b142f83dSRobert Mustacchi.Bl -tag -width Fa 37*b142f83dSRobert Mustacchi.It Fa driver 38*b142f83dSRobert MustacchiA pointer to the driver's private data that was passed in via the 39*b142f83dSRobert Mustacchi.Sy m_pdata 40*b142f83dSRobert Mustacchimember of the 41*b142f83dSRobert Mustacchi.Xr mac_register 9S 42*b142f83dSRobert Mustacchistructure to the 43*b142f83dSRobert Mustacchi.Xr mac_register 9F 44*b142f83dSRobert Mustacchifunction. 45*b142f83dSRobert Mustacchi.It Fa mode 46*b142f83dSRobert MustacchiA value that indicates how the driver should drive the LEDs. 47*b142f83dSRobert MustacchiSee the 48*b142f83dSRobert Mustacchi.Sx LED MODES 49*b142f83dSRobert Mustacchisection for a list of supported modes. 50*b142f83dSRobert Mustacchi.It Fa flags 51*b142f83dSRobert MustacchiReserved for future use. 52*b142f83dSRobert Mustacchi.El 53*b142f83dSRobert Mustacchi.Sh DESCRIPTION 54*b142f83dSRobert MustacchiThe 55*b142f83dSRobert Mustacchi.Sy MAC_CAPAB_LED 56*b142f83dSRobert Mustacchicapability allows GLDv3 device drivers to expose an interface for 57*b142f83dSRobert Mustacchicontrolling the LEDs on the device. 58*b142f83dSRobert MustacchiThis allows the system to control the LEDs to assist system 59*b142f83dSRobert Mustacchiadministrators in finding and identifying specific physical devices in 60*b142f83dSRobert Mustacchithe system. 61*b142f83dSRobert Mustacchi.Pp 62*b142f83dSRobert MustacchiImplementing this capability is optional. 63*b142f83dSRobert MustacchiFor more information on how to handle capabilities and how to indicate 64*b142f83dSRobert Mustacchithat a capability is not supported, see 65*b142f83dSRobert Mustacchi.Xr mc_getcapab 9E . 66*b142f83dSRobert Mustacchi.Pp 67*b142f83dSRobert MustacchiThis capability should be implemented if the device in question provides 68*b142f83dSRobert Mustacchia way to manipulate its LEDs. 69*b142f83dSRobert MustacchiGenerally the LEDs on a device default to indicating link status and 70*b142f83dSRobert Mustacchiactivity. 71*b142f83dSRobert MustacchiHowever, they can often be turned off or set to a specific pattern for 72*b142f83dSRobert Mustacchiidentification purposes. 73*b142f83dSRobert Mustacchi.Ss LED MODES 74*b142f83dSRobert MustacchiThe system has a notion of different LED modes. 75*b142f83dSRobert MustacchiEach LED mode suggests a different way that a device driver should drive 76*b142f83dSRobert Mustacchithe indicator LEDs on the device. 77*b142f83dSRobert MustacchiWhile we generally want all such LED modes to be as uniform 78*b142f83dSRobert Mustacchias possible, there is a limit to such similarities due to the 79*b142f83dSRobert Mustacchicapabilities of NICs. 80*b142f83dSRobert MustacchiEach mode is a member of the 81*b142f83dSRobert Mustacchi.Vt mac_led_mode_t 82*b142f83dSRobert Mustacchienumeration. 83*b142f83dSRobert MustacchiThe currently defined modes are: 84*b142f83dSRobert Mustacchi.Bl -tag -width Dv -offset indent 85*b142f83dSRobert Mustacchi.It Dv MAC_LED_DEFAULT 86*b142f83dSRobert MustacchiThis mode indicates that the device's default behavior should be used. 87*b142f83dSRobert MustacchiThis is usually some form of link status and activity. 88*b142f83dSRobert MustacchiIt is device specific and usually is the default behavior after a device 89*b142f83dSRobert Mustacchiis powered on. 90*b142f83dSRobert Mustacchi.It Dv MAC_LED_OFF 91*b142f83dSRobert MustacchiThis mode indicates that the device's LEDs should be turned off and not 92*b142f83dSRobert Mustacchiemit any light. 93*b142f83dSRobert Mustacchi.It Dv MAC_LED_ON 94*b142f83dSRobert MustacchiThis mode indicates that the device's LEDs should be turned on and 95*b142f83dSRobert Mustacchiremain solid. 96*b142f83dSRobert Mustacchi.It Dv MAC_LED_IDENT 97*b142f83dSRobert MustacchiThis mode indicates that the driver should emit some form of 98*b142f83dSRobert Mustacchiidentification pattern. 99*b142f83dSRobert MustacchiWe suggest that devices indicate some form of solid blinking light that 100*b142f83dSRobert Mustacchiis on and off at alternating units of time, for example, every 200 101*b142f83dSRobert Mustacchimilliseconds. 102*b142f83dSRobert MustacchiIf it is possible to use an alternate color from the normal link up and 103*b142f83dSRobert Mustacchiactivity lighting, that is recommended. 104*b142f83dSRobert Mustacchi.El 105*b142f83dSRobert Mustacchi.Ss MAC Capability Structure 106*b142f83dSRobert MustacchiWhen the device driver's 107*b142f83dSRobert Mustacchi.Xr mc_getcapab 9E 108*b142f83dSRobert Mustacchifunction entry point is called with the capability set to 109*b142f83dSRobert Mustacchi.Dv MAC_CAPAB_LED , 110*b142f83dSRobert Mustacchithen the value of the capability structure is the following structure: 111*b142f83dSRobert Mustacchi.Bd -literal -offset indent 112*b142f83dSRobert Mustacchitypedef struct mac_capab_led { 113*b142f83dSRobert Mustacchi uint_t mcl_flags; 114*b142f83dSRobert Mustacchi mac_led_mode_t mcl_modes; 115*b142f83dSRobert Mustacchi int (*mcl_set)(void *driver, mac_led_mode_t mode, 116*b142f83dSRobert Mustacchi uint_t flags); 117*b142f83dSRobert Mustacchi} mac_capab_led_t; 118*b142f83dSRobert Mustacchi.Ed 119*b142f83dSRobert Mustacchi.Pp 120*b142f83dSRobert MustacchiIf the driver supports the 121*b142f83dSRobert Mustacchi.Dv MAC_CAPAB_LED 122*b142f83dSRobert Mustacchicapability, it should fill in this structure, based on the following 123*b142f83dSRobert Mustacchirules: 124*b142f83dSRobert Mustacchi.Bl -tag -width Vt 125*b142f83dSRobert Mustacchi.It Fa mcl_flags 126*b142f83dSRobert MustacchiThe 127*b142f83dSRobert Mustacchi.Fa mcl_flags 128*b142f83dSRobert Mustacchimember is used to negotiate extensions with the driver. 129*b142f83dSRobert MustacchiMAC will set the value of 130*b142f83dSRobert Mustacchi.Fa mcl_flags 131*b142f83dSRobert Mustacchito include all of the currently known extensions. 132*b142f83dSRobert MustacchiThe driver should intersect this list with the set that they actually 133*b142f83dSRobert Mustacchisupport. 134*b142f83dSRobert MustacchiAt this time, no such features are defined and the driver should set the 135*b142f83dSRobert Mustacchimember to 136*b142f83dSRobert Mustacchi.Sy 0 . 137*b142f83dSRobert Mustacchi.It Fa mcl_modes 138*b142f83dSRobert MustacchiThe 139*b142f83dSRobert Mustacchi.Fa mcl_modes 140*b142f83dSRobert Mustacchimember represents the support modes of the device driver. 141*b142f83dSRobert MustacchiThe device driver should set 142*b142f83dSRobert Mustacchi.Vt mcl_modes 143*b142f83dSRobert Mustacchito the bitwise-inclusive-OR of the LED modes listed in 144*b142f83dSRobert Mustacchi.Sx LED MODES . 145*b142f83dSRobert Mustacchi.Pp 146*b142f83dSRobert MustacchiIf the driver does not support anything other than the default behavior 147*b142f83dSRobert Mustacchiof 148*b142f83dSRobert Mustacchi.Dv MAC_LED_DEFAULT , 149*b142f83dSRobert Mustacchithen the device driver should not indicate that it supports this 150*b142f83dSRobert Mustacchicapability. 151*b142f83dSRobert Mustacchi.It Fa mcl_set 152*b142f83dSRobert MustacchiThe 153*b142f83dSRobert Mustacchi.Fa mcl_set 154*b142f83dSRobert Mustacchientry point will be called by the MAC framework when it needs the device 155*b142f83dSRobert Mustacchidriver to change how it is driving its LEDs. 156*b142f83dSRobert MustacchiEach call will ask the driver to change the display mode to the 157*b142f83dSRobert Mustacchispecified mode. 158*b142f83dSRobert MustacchiThe driver does not have to multiplex requests for multiple modes or 159*b142f83dSRobert Mustacchikeep track of what has been requested, that is taken care of by the 160*b142f83dSRobert Mustacchisystem itself. 161*b142f83dSRobert Mustacchi.Pp 162*b142f83dSRobert MustacchiThe driver should first validate that 163*b142f83dSRobert Mustacchi.Fa mode 164*b142f83dSRobert Mustacchiis a mode that it supports. 165*b142f83dSRobert MustacchiWhile the device reports the set of supported modes as a 166*b142f83dSRobert Mustacchibitwise-inclusive-OR, the driver should only receive a single value in 167*b142f83dSRobert Mustacchi.Fa mode . 168*b142f83dSRobert MustacchiThe value of the 169*b142f83dSRobert Mustacchi.Fa flags 170*b142f83dSRobert Mustacchiargument is reserved for future use. 171*b142f83dSRobert MustacchiDrivers must check that the value of flags is zero and if not, return 172*b142f83dSRobert Mustacchi.Er EINVAL . 173*b142f83dSRobert Mustacchi.Pp 174*b142f83dSRobert MustacchiWhen this entry point is first called on a driver, it should snapshot 175*b142f83dSRobert Mustacchiits device registers such that it knows how to restore the default 176*b142f83dSRobert Mustacchibehavior. 177*b142f83dSRobert MustacchiBecause each method of programming the LEDs is different, it 178*b142f83dSRobert Mustacchiis up to the driver itself to take care of this, the broader framework 179*b142f83dSRobert Mustacchicannot take care of it. 180*b142f83dSRobert Mustacchi.Pp 181*b142f83dSRobert MustacchiIf for some reason the driver is asked to program the same mode that it 182*b142f83dSRobert Mustacchiis already driving, then it need not do anything and should simply 183*b142f83dSRobert Mustacchireturn success. 184*b142f83dSRobert Mustacchi.Pp 185*b142f83dSRobert MustacchiOnce the driver successfully changes the LED driving mode, it should 186*b142f83dSRobert Mustacchireturn 187*b142f83dSRobert Mustacchi.Sy 0 . 188*b142f83dSRobert MustacchiOtherwise, it should return the appropriate error number. 189*b142f83dSRobert MustacchiFor a full list of error numbers, see 190*b142f83dSRobert Mustacchi.Xr Intro 2 . 191*b142f83dSRobert MustacchiCommon values are: 192*b142f83dSRobert Mustacchi.Bl -tag -width Er -offset width 193*b142f83dSRobert Mustacchi.It Er EINVAL 194*b142f83dSRobert Mustacchi.Fa flag 195*b142f83dSRobert Mustacchicontains an unknown value. 196*b142f83dSRobert Mustacchi.It Er ENOTSUP 197*b142f83dSRobert Mustacchi.Fa mode 198*b142f83dSRobert Mustacchiis unsupported. 199*b142f83dSRobert Mustacchi.Fa flags 200*b142f83dSRobert Mustacchicontains an unsupported or unknown value. 201*b142f83dSRobert Mustacchi.It Er EIO 202*b142f83dSRobert MustacchiAn I/O error occurred while trying to program the device's registers. 203*b142f83dSRobert MustacchiThis could be because a command timed out or an FM-aware driver 204*b142f83dSRobert Mustacchiencountered an error. 205*b142f83dSRobert Mustacchi.El 206*b142f83dSRobert Mustacchi.Pp 207*b142f83dSRobert MustacchiThe broader framework will guarantee that only a single call to the 208*b142f83dSRobert Mustacchi.Fa mcl_set 209*b142f83dSRobert Mustacchifunction is ongoing at any time. 210*b142f83dSRobert MustacchiIf other parts of the driver refer to the data used by the 211*b142f83dSRobert Mustacchi.Fa mcl_set 212*b142f83dSRobert Mustacchifunction, then the driver must ensure that it is performing sufficient 213*b142f83dSRobert Mustacchilocking of its data. 214*b142f83dSRobert Mustacchi.El 215*b142f83dSRobert Mustacchi.Sh CONTEXT 216*b142f83dSRobert MustacchiThe 217*b142f83dSRobert Mustacchi.Ft mcl_set 218*b142f83dSRobert Mustacchientry point will only be called from 219*b142f83dSRobert Mustacchi.Sy user 220*b142f83dSRobert Mustacchior 221*b142f83dSRobert Mustacchi.Sy kernel 222*b142f83dSRobert Mustacchicontext. 223*b142f83dSRobert MustacchiIt will never be called from interrupt context. 224*b142f83dSRobert Mustacchi.Sh SEE ALSO 225*b142f83dSRobert Mustacchi.Xr Intro 2 , 226*b142f83dSRobert Mustacchi.Xr mac 9E , 227*b142f83dSRobert Mustacchi.Xr mc_getcapab 9E , 228*b142f83dSRobert Mustacchi.Xr mac_register 9F 229