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