xref: /illumos-gate/usr/src/man/man9e/mac.9e (revision 72d3dbb9ab4481606cb93caca98ba3b3a8eb6ce2)
152d2369aSRobert Mustacchi.\"
252d2369aSRobert Mustacchi.\" This file and its contents are supplied under the terms of the
352d2369aSRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0.
452d2369aSRobert Mustacchi.\" You may only use this file in accordance with the terms of version
552d2369aSRobert Mustacchi.\" 1.0 of the CDDL.
652d2369aSRobert Mustacchi.\"
752d2369aSRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this
852d2369aSRobert Mustacchi.\" source.  A copy of the CDDL is also available via the Internet at
952d2369aSRobert Mustacchi.\" http://www.illumos.org/license/CDDL.
1052d2369aSRobert Mustacchi.\"
1152d2369aSRobert Mustacchi.\"
1252d2369aSRobert Mustacchi.\" Copyright 2016 Joyent, Inc.
1352d2369aSRobert Mustacchi.\"
14c71d194aSDillon Amburgey.Dd March 26, 2017
1552d2369aSRobert Mustacchi.Dt MAC 9E
1652d2369aSRobert Mustacchi.Os
1752d2369aSRobert Mustacchi.Sh NAME
1852d2369aSRobert Mustacchi.Nm mac ,
1952d2369aSRobert Mustacchi.Nm GLDv3
2052d2369aSRobert Mustacchi.Nd MAC networking device driver overview
2152d2369aSRobert Mustacchi.Sh SYNOPSIS
2252d2369aSRobert Mustacchi.In sys/mac_provider.h
2352d2369aSRobert Mustacchi.In sys/mac_ether.h
2452d2369aSRobert Mustacchi.Sh INTERFACE LEVEL
2552d2369aSRobert Mustacchiillumos DDI specific
2652d2369aSRobert Mustacchi.Sh DESCRIPTION
2752d2369aSRobert MustacchiThe
2852d2369aSRobert Mustacchi.Sy MAC
2952d2369aSRobert Mustacchiframework provides a means for implementing high-performance networking
30*72d3dbb9SYuri Pankovdevice drivers.
31*72d3dbb9SYuri PankovIt is the successor to the GLD interfaces and is sometimes referred to as the
32*72d3dbb9SYuri PankovGLDv3.
33*72d3dbb9SYuri PankovThe remainder of this manual introduces the aspects of writing devices drivers
34*72d3dbb9SYuri Pankovthat leverage the MAC framework.
35*72d3dbb9SYuri PankovWhile both the GLDv3 and MAC framework refer to the same thing, in this manual
36*72d3dbb9SYuri Pankovpage we use the term the
3752d2369aSRobert Mustacchi.Em MAC framework
3852d2369aSRobert Mustacchito refer to the device driver interface.
3952d2369aSRobert Mustacchi.Pp
40*72d3dbb9SYuri PankovMAC device drivers are character devices.
41*72d3dbb9SYuri PankovThey define the standard
4252d2369aSRobert Mustacchi.Xr _init 9E ,
4352d2369aSRobert Mustacchi.Xr _fini 9E ,
4452d2369aSRobert Mustacchiand
4552d2369aSRobert Mustacchi.Xr _info 9E
4652d2369aSRobert Mustacchientry points to initialize the module, as well as
4752d2369aSRobert Mustacchi.Xr dev_ops 9S
4852d2369aSRobert Mustacchiand
4952d2369aSRobert Mustacchi.Xr cb_ops 9S
5052d2369aSRobert Mustacchistructures.
5152d2369aSRobert Mustacchi.Pp
5252d2369aSRobert MustacchiThe main interface with MAC is through a series of callbacks defined in
5352d2369aSRobert Mustacchia
5452d2369aSRobert Mustacchi.Xr mac_callbacks 9S
55*72d3dbb9SYuri Pankovstructure.
56*72d3dbb9SYuri PankovThese callbacks control all the aspects of the device.
57*72d3dbb9SYuri PankovThey range from sending data, getting and setting of properties, controlling mac
58*72d3dbb9SYuri Pankovaddress filters, and also managing promiscuous mode.
5952d2369aSRobert Mustacchi.Pp
6052d2369aSRobert MustacchiThe MAC framework takes care of many aspects of the device driver's
61*72d3dbb9SYuri Pankovmanagement.
62*72d3dbb9SYuri PankovA device that uses the MAC framework does not have to worry about creating
63*72d3dbb9SYuri Pankovdevice nodes or implementing
6452d2369aSRobert Mustacchi.Xr open 9E
6552d2369aSRobert Mustacchior
6652d2369aSRobert Mustacchi.Xr close 9E
67*72d3dbb9SYuri Pankovroutines.
68*72d3dbb9SYuri PankovIn addition, all of the work to interact with
6952d2369aSRobert Mustacchi.Xr dlpi 7P
7052d2369aSRobert Mustacchiis taken care of automatically and transparently.
7152d2369aSRobert Mustacchi.Ss Initializing MAC Support
7252d2369aSRobert MustacchiFor a device to be used in the framework, it must register with the
7352d2369aSRobert Mustacchiframework and take specific actions during
7452d2369aSRobert Mustacchi.Xr _init 9E ,
7552d2369aSRobert Mustacchi.Xr attach 9E ,
7652d2369aSRobert Mustacchi.Xr detach 9E ,
7752d2369aSRobert Mustacchiand
7852d2369aSRobert Mustacchi.Xr _fini 9E .
7952d2369aSRobert Mustacchi.Pp
8052d2369aSRobert MustacchiAll device drivers have to define a
8152d2369aSRobert Mustacchi.Xr dev_ops 9S
8252d2369aSRobert Mustacchistructure which is pointed to by a
8352d2369aSRobert Mustacchi.Xr modldrv 9S
8452d2369aSRobert Mustacchistructure and the corresponding NULL-terminated
8552d2369aSRobert Mustacchi.Xr modlinkage 9S
86*72d3dbb9SYuri Pankovstructure.
87*72d3dbb9SYuri PankovThe
8852d2369aSRobert Mustacchi.Xr dev_ops 9S
8952d2369aSRobert Mustacchistructure should have a
9052d2369aSRobert Mustacchi.Xr cb_ops 9S
9152d2369aSRobert Mustacchistructure defined for it; however, it does not need to implement any of
9252d2369aSRobert Mustacchithe standard
9352d2369aSRobert Mustacchi.Xr cb_ops 9S
9452d2369aSRobert Mustacchientry points.
9552d2369aSRobert Mustacchi.Pp
9652d2369aSRobert MustacchiNormally, in a driver's
9752d2369aSRobert Mustacchi.Xr _init 9E
9852d2369aSRobert Mustacchientry point, it passes its
9952d2369aSRobert Mustacchi.Sy modlinkage
10052d2369aSRobert Mustacchistructure directly to
10152d2369aSRobert Mustacchi.Xr mod_install 9F .
10252d2369aSRobert MustacchiTo properly register with MAC, the driver must call
10352d2369aSRobert Mustacchi.Xr mac_init_ops 9F
10452d2369aSRobert Mustacchibefore it calls
10552d2369aSRobert Mustacchi.Xr mod_install 9F .
10652d2369aSRobert MustacchiIf for some reason the
10752d2369aSRobert Mustacchi.Xr mod_install 9F
10852d2369aSRobert Mustacchifunction fails, then the driver must be removed by a call to
10952d2369aSRobert Mustacchi.Xr mac_fini_ops 9F .
11052d2369aSRobert Mustacchi.Pp
11152d2369aSRobert MustacchiConversely, in the driver's
11252d2369aSRobert Mustacchi.Xr _fini 9F
11352d2369aSRobert Mustacchiroutine, it should call
11452d2369aSRobert Mustacchi.Xr mac_fini_ops 9F
11552d2369aSRobert Mustacchiafter it successfully calls
11652d2369aSRobert Mustacchi.Xr mod_remove 9F .
11752d2369aSRobert MustacchiFor an example of how to use the
11852d2369aSRobert Mustacchi.Xr mac_init_ops 9F
11952d2369aSRobert Mustacchiand
12052d2369aSRobert Mustacchi.Xr mac_fini_ops 9F
12152d2369aSRobert Mustacchifunctions, see the examples section in
12252d2369aSRobert Mustacchi.Xr mac_init_ops 9F .
12352d2369aSRobert Mustacchi.Ss Registering with MAC
12452d2369aSRobert MustacchiEvery instance of a device should register separately with MAC.
12552d2369aSRobert MustacchiTo register with MAC, a driver must allocate a
12652d2369aSRobert Mustacchi.Xr mac_register 9S
12752d2369aSRobert Mustacchistructure, fill it in, and then call
12852d2369aSRobert Mustacchi.Xr mac_register 9F .
12952d2369aSRobert MustacchiThe
13052d2369aSRobert Mustacchi.Sy mac_register_t
13152d2369aSRobert Mustacchistructure contains information about the device and all of the required
13252d2369aSRobert Mustacchifunction pointers that will be used as callbacks by the framework.
13352d2369aSRobert Mustacchi.Pp
13452d2369aSRobert MustacchiThese steps should all be taken during a device's
13552d2369aSRobert Mustacchi.Xr attach 9E
136*72d3dbb9SYuri Pankoventry point.
137*72d3dbb9SYuri PankovIt is recommended that the driver perform this sequence of steps after the
138*72d3dbb9SYuri Pankovdevice has finished its initialization of the chipset and interrupts, though
139*72d3dbb9SYuri Pankovinterrupts should not be enabled at that point.
14052d2369aSRobert MustacchiAfter it calls
14152d2369aSRobert Mustacchi.Xr mac_register 9F
14252d2369aSRobert Mustacchiit will start receiving callbacks from the MAC framework.
14352d2369aSRobert Mustacchi.Pp
14452d2369aSRobert MustacchiTo allocate the registration structure, the driver should call
14552d2369aSRobert Mustacchi.Xr mac_alloc 9F .
14652d2369aSRobert MustacchiDevice drivers should generally always pass the symbol
14752d2369aSRobert Mustacchi.Sy MAC_VERSION
14852d2369aSRobert Mustacchias the argument to
14952d2369aSRobert Mustacchi.Xr mac_alloc 9F .
15052d2369aSRobert MustacchiUpon successful completion, the driver will receive a
15152d2369aSRobert Mustacchi.Sy mac_register_t
152*72d3dbb9SYuri Pankovstructure which it should fill in.
153*72d3dbb9SYuri PankovThe structure and its members are documented in
15452d2369aSRobert Mustacchi.Xr mac_register 9S .
15552d2369aSRobert Mustacchi.Pp
15652d2369aSRobert MustacchiThe
15752d2369aSRobert Mustacchi.Xr mac_callbacks 9S
15852d2369aSRobert Mustacchistructure is not allocated as a part of the
15952d2369aSRobert Mustacchi.Xr mac_register 9S
160*72d3dbb9SYuri Pankovstructure.
161*72d3dbb9SYuri PankovIn general, device drivers declare this statically.
162*72d3dbb9SYuri PankovSee the
16352d2369aSRobert Mustacchi.Sx MAC Callbacks
16452d2369aSRobert Mustacchisection for more information on how to fill it out.
16552d2369aSRobert Mustacchi.Pp
16652d2369aSRobert MustacchiOnce the structure has been filled in, the driver should call
16752d2369aSRobert Mustacchi.Xr mac_register 9F
168*72d3dbb9SYuri Pankovto register itself with MAC.
169*72d3dbb9SYuri PankovThe handle that it uses to register with should be part of the driver's soft
170*72d3dbb9SYuri Pankovstate.
171*72d3dbb9SYuri PankovIt will be used in various other support functions and callbacks.
17252d2369aSRobert Mustacchi.Pp
17352d2369aSRobert MustacchiIf the call is successful, then the device driver
17452d2369aSRobert Mustacchishould enable interrupts and finish any other initialization required.
17552d2369aSRobert MustacchiIf the call to
17652d2369aSRobert Mustacchi.Xr mac_register 9F
17752d2369aSRobert Mustacchifailed, then it should unwind its initialization and should return
17852d2369aSRobert Mustacchi.Sy DDI_FAILURE
17952d2369aSRobert Mustacchifrom its
18052d2369aSRobert Mustacchi.Xr attach 9E
18152d2369aSRobert Mustacchiroutine.
18252d2369aSRobert Mustacchi.Ss MAC Callbacks
18352d2369aSRobert MustacchiThe MAC framework interacts with a device driver through a series of
184*72d3dbb9SYuri Pankovcallbacks.
185*72d3dbb9SYuri PankovThese callbacks are described in their individual manual pages and the
186*72d3dbb9SYuri Pankovcollection of callbacks is indicated in the
18752d2369aSRobert Mustacchi.Xr mac_callbacks 9S
188*72d3dbb9SYuri Pankovmanual page.
189*72d3dbb9SYuri PankovThis section does not focus on the specific functions, but rather on
190*72d3dbb9SYuri Pankovinteractions between them and the rest of the device driver framework.
19152d2369aSRobert Mustacchi.Pp
19252d2369aSRobert MustacchiA device driver should make no assumptions about when the various
19352d2369aSRobert Mustacchicallbacks will be called and whether or not they will be called
194*72d3dbb9SYuri Pankovsimultaneously.
195*72d3dbb9SYuri PankovFor example, a device driver may be asked to transmit data through a call to its
19652d2369aSRobert Mustacchi.Xr mc_tx 9F
19752d2369aSRobert Mustacchientry point while it is being asked to get a device property through a
19852d2369aSRobert Mustacchicall to its
19952d2369aSRobert Mustacchi.Xr mc_getprop 9F
200*72d3dbb9SYuri Pankoventry point.
201*72d3dbb9SYuri PankovAs such, while some calls may be serialized to the device, such as setting
202*72d3dbb9SYuri Pankovproperties, the device driver should always presume that all of its data needs
203*72d3dbb9SYuri Pankovto be protected with locks.
204*72d3dbb9SYuri PankovWhile the device is holding locks, it is safe for it call the following MAC
205*72d3dbb9SYuri Pankovroutines:
20652d2369aSRobert Mustacchi.Bl -bullet -offset indent -compact
20752d2369aSRobert Mustacchi.It
20852d2369aSRobert Mustacchi.Xr mac_hcksum_get 9F
20952d2369aSRobert Mustacchi.It
21052d2369aSRobert Mustacchi.Xr mac_hcksum_set 9F
21152d2369aSRobert Mustacchi.It
21252d2369aSRobert Mustacchi.Xr mac_lso_get 9F
21352d2369aSRobert Mustacchi.It
21452d2369aSRobert Mustacchi.Xr mac_maxsdu_update 9F
21552d2369aSRobert Mustacchi.It
21652d2369aSRobert Mustacchi.Xr mac_prop_info_set_default_link_flowctrl 9F
21752d2369aSRobert Mustacchi.It
21852d2369aSRobert Mustacchi.Xr mac_prop_info_set_default_str 9F
21952d2369aSRobert Mustacchi.It
22052d2369aSRobert Mustacchi.Xr mac_prop_info_set_default_uint8 9F
22152d2369aSRobert Mustacchi.It
22252d2369aSRobert Mustacchi.Xr mac_prop_info_set_default_uint32 9F
22352d2369aSRobert Mustacchi.It
22452d2369aSRobert Mustacchi.Xr mac_prop_info_set_default_uint64 9F
22552d2369aSRobert Mustacchi.It
22652d2369aSRobert Mustacchi.Xr mac_prop_info_set_perm 9F
22752d2369aSRobert Mustacchi.It
22852d2369aSRobert Mustacchi.Xr mac_prop_info_set_range_uint32 9F
22952d2369aSRobert Mustacchi.El
23052d2369aSRobert Mustacchi.Pp
23152d2369aSRobert MustacchiAny other MAC related routines should not be called with locks held,
23252d2369aSRobert Mustacchisuch as
23352d2369aSRobert Mustacchi.Xr mac_link_update 9F
23452d2369aSRobert Mustacchior
23552d2369aSRobert Mustacchi.Xr mac_rx 9F .
23652d2369aSRobert MustacchiOther routines in the DDI may be called while locks are held; however,
23752d2369aSRobert Mustacchidevice driver writers should be careful about calling blocking routines
23852d2369aSRobert Mustacchiwhile locks are held or in interrupt context, though it is generally
23952d2369aSRobert Mustacchilegal to do so.
24052d2369aSRobert Mustacchi.Ss Receiving Data
24152d2369aSRobert MustacchiA device driver will often receive data through the means of an
242*72d3dbb9SYuri Pankovinterrupt.
243*72d3dbb9SYuri PankovWhen that interrupt occurs, the device driver will receive one or more frames
244*72d3dbb9SYuri Pankovwith optional metadata.
245*72d3dbb9SYuri PankovOften each frame has a corresponding descriptor which has information about
246*72d3dbb9SYuri Pankovwhether or not there were errors or whether or not the device successfully
247*72d3dbb9SYuri Pankovchecksummed the packet.
24852d2369aSRobert Mustacchi.Pp
24952d2369aSRobert MustacchiDuring a single interrupt, a device driver should process a fixed number
250*72d3dbb9SYuri Pankovof frames.
251*72d3dbb9SYuri PankovFor each frame the device driver should:
25252d2369aSRobert Mustacchi.Bl -enum -offset indent
25352d2369aSRobert Mustacchi.It
254*72d3dbb9SYuri PankovFirst check whether or not the frame has errors.
255*72d3dbb9SYuri PankovIf errors were detected, then the frame should not be sent to the operating
256*72d3dbb9SYuri Pankovsystem.
257*72d3dbb9SYuri PankovIt is recommended that devices keep kstats (see
25852d2369aSRobert Mustacchi.Xr kstat_create 9S
25952d2369aSRobert Mustacchifor more information) and bump the counter whenever such an error is
260*72d3dbb9SYuri Pankovdetected.
261*72d3dbb9SYuri PankovIf the device distinguishes between the types of errors, then separate kstats
262*72d3dbb9SYuri Pankovfor each class of error are recommended.
263*72d3dbb9SYuri PankovSee the
26452d2369aSRobert Mustacchi.Sx STATISTICS
26552d2369aSRobert Mustacchisection for more information on the various error cases that should be
26652d2369aSRobert Mustacchiconsidered.
26752d2369aSRobert Mustacchi.It
26852d2369aSRobert MustacchiOnce the frame has been determined to be valid, the device driver should
26952d2369aSRobert Mustacchitransform the frame into a
27052d2369aSRobert Mustacchi.Xr mblk 9S .
27152d2369aSRobert MustacchiSee the section
27252d2369aSRobert Mustacchi.Sx MBLKS AND DMA
27352d2369aSRobert Mustacchifor more information on how to transform and prepare a message block.
27452d2369aSRobert Mustacchi.It
27552d2369aSRobert MustacchiIf the device supports hardware checksumming (see the
27652d2369aSRobert Mustacchi.Sx CAPABILITIES
27752d2369aSRobert Mustacchisection for more information on checksumming), then the device driver
27852d2369aSRobert Mustacchishould set the corresponding checksumming information with a call to
27952d2369aSRobert Mustacchi.Xr mac_hcksum_set 9F .
28052d2369aSRobert Mustacchi.It
28152d2369aSRobert MustacchiIt should then append this new message block to the
28252d2369aSRobert Mustacchi.Em end
28352d2369aSRobert Mustacchiof the message block chain, linking it to the
28452d2369aSRobert Mustacchi.Sy b_next
285*72d3dbb9SYuri Pankovpointer.
286*72d3dbb9SYuri PankovIt is vitally important that all the frames be chained in the order that they
287*72d3dbb9SYuri Pankovwere received.
288*72d3dbb9SYuri PankovIf the device driver mistakenly reorders frames, then it may cause performance
289*72d3dbb9SYuri Pankovimpacts in the TCP stack and potentially impact application correctness.
29052d2369aSRobert Mustacchi.El
29152d2369aSRobert Mustacchi.Pp
29252d2369aSRobert MustacchiOnce all the frames have been processed and assembled, the device driver
29352d2369aSRobert Mustacchishould deliver them to the rest of the operating system by calling
29452d2369aSRobert Mustacchi.Xr mac_rx 9F .
29552d2369aSRobert MustacchiThe device driver should try to give as many mblk_t structures to the
296*72d3dbb9SYuri Pankovsystem at once.
297*72d3dbb9SYuri PankovIt
29852d2369aSRobert Mustacchi.Em should not
29952d2369aSRobert Mustacchicall
30052d2369aSRobert Mustacchi.Xr mac_rx 9F
30152d2369aSRobert Mustacchionce for every assembled mblk_t.
30252d2369aSRobert Mustacchi.Pp
30352d2369aSRobert MustacchiThe device driver must not hold any locks across the call to
30452d2369aSRobert Mustacchi.Xr mac_rx 9F .
30552d2369aSRobert MustacchiWhen this function is called, received data will be pushed through the
30652d2369aSRobert Mustacchinetworking stack and some replies may be generated and given to the
30752d2369aSRobert Mustacchidriver to send out.
30852d2369aSRobert Mustacchi.Pp
30952d2369aSRobert MustacchiIt is not the device driver's responsibility to determine whether or not
310*72d3dbb9SYuri Pankovthe system can keep up with a driver's delivery rate of frames.
311*72d3dbb9SYuri PankovThe rest of the networking stack will handle issues related to keeping up
31252d2369aSRobert Mustacchiappropriately and ensure that kernel memory is not exhausted by packets
31352d2369aSRobert Mustacchithat are not being processed.
31452d2369aSRobert Mustacchi.Pp
31552d2369aSRobert MustacchiFinally, the device driver should make sure that any other housekeeping
31652d2369aSRobert Mustacchiactivities required for the ring are taken care of such that more data
31752d2369aSRobert Mustacchican be received.
31852d2369aSRobert Mustacchi.Ss Transmitting Data and Back Pressure
31952d2369aSRobert MustacchiA device driver will be asked to transmit a message block chain by
32052d2369aSRobert Mustacchihaving it's
32152d2369aSRobert Mustacchi.Xr mc_tx 9E
322*72d3dbb9SYuri Pankoventry point called.
323*72d3dbb9SYuri PankovWhile the driver is processing the message blocks, it may run out of resources.
324*72d3dbb9SYuri PankovFor example, a transmit descriptor ring may become full.
325*72d3dbb9SYuri PankovAt that point, the device driver should return the remaining unprocessed frames.
326*72d3dbb9SYuri PankovThe act of returning frames indicates that the device has asserted flow control.
32752d2369aSRobert MustacchiOnce this has been done, no additional calls will be made to the
32852d2369aSRobert Mustacchidriver's transmit entry point and the back pressure will be propagated
32952d2369aSRobert Mustacchithroughout the rest of the networking stack.
33052d2369aSRobert Mustacchi.Pp
33152d2369aSRobert MustacchiAt some point in the future when resources have become available again,
33252d2369aSRobert Mustacchifor example after an interrupt indicating that some portion of the
33352d2369aSRobert Mustacchitransmit ring has been sent, then the device driver must notify the
334*72d3dbb9SYuri Pankovsystem that it can continue transmission.
335*72d3dbb9SYuri PankovTo do this, the driver should call
33652d2369aSRobert Mustacchi.Xr mac_tx_update 9F .
33752d2369aSRobert MustacchiAfter that point, the driver will receive calls to its
33852d2369aSRobert Mustacchi.Xr mc_tx 9E
339*72d3dbb9SYuri Pankoventry point again.
340*72d3dbb9SYuri PankovAs mentioned in the section on callbacks, the device driver should avoid holding
341*72d3dbb9SYuri Pankovany particular locks across the call to
34252d2369aSRobert Mustacchi.Xr mac_tx_update 9F .
34352d2369aSRobert Mustacchi.Ss Interrupt Coalescing
34452d2369aSRobert MustacchiFor devices operating at higher data rates, interrupt coalescing is an
34552d2369aSRobert Mustacchiimportant part of a well functioning device and may impact the
346*72d3dbb9SYuri Pankovperformance of the device.
347*72d3dbb9SYuri PankovNot all devices support interrupt coalescing.
348*72d3dbb9SYuri PankovIf interrupt coalescing is supported on the device, it is recommended that
349*72d3dbb9SYuri Pankovdevice driver writers provide private properties for their device to control the
350*72d3dbb9SYuri Pankovinterrupt coalescing rate.
351*72d3dbb9SYuri PankovThis will make it much easier to perform experiments and observe the impact of
352*72d3dbb9SYuri Pankovdifferent interrupt rates on the rest of the system.
35352d2369aSRobert Mustacchi.Ss MAC Address Filter Management
35452d2369aSRobert MustacchiThe MAC framework will attempt to use as many MAC address filters as a
355*72d3dbb9SYuri Pankovdevice has.
356*72d3dbb9SYuri PankovTo program a multicast address filter, the driver's
35752d2369aSRobert Mustacchi.Xr mc_multicst 9E
358*72d3dbb9SYuri Pankoventry point will be called.
359*72d3dbb9SYuri PankovIf the device driver runs out of filters, it should not take any special action
360*72d3dbb9SYuri Pankovand just return the appropriate error as documented in the corresponding manual
361*72d3dbb9SYuri Pankovpages for the entry points.
36252d2369aSRobert MustacchiThe framework will ensure that the device is placed in promiscuous mode
36352d2369aSRobert Mustacchiif it needs to.
36452d2369aSRobert Mustacchi.Ss Link Updates
36552d2369aSRobert MustacchiIt is the responsibility of the device driver to keep track of the
366*72d3dbb9SYuri Pankovdata link's state.
367*72d3dbb9SYuri PankovMany devices provide a means of receiving an interrupt when the state of the
368*72d3dbb9SYuri Pankovlink changes.
369*72d3dbb9SYuri PankovWhen such a change happens, the driver should update its internal data
370*72d3dbb9SYuri Pankovstructures and then call
37152d2369aSRobert Mustacchi.Xr mac_link_update 9F
372*72d3dbb9SYuri Pankovto inform the MAC layer that this has occurred.
373*72d3dbb9SYuri PankovIf the device driver does not properly inform the system about link changes,
374*72d3dbb9SYuri Pankovthen various features like link aggregations and other mechanisms that leverage
375*72d3dbb9SYuri Pankovthe link state will not work correctly.
37652d2369aSRobert Mustacchi.Ss Link Speed and Auto-negotiation
37752d2369aSRobert MustacchiMany networking devices support more than one possible speed that they
378*72d3dbb9SYuri Pankovcan operate at.
379*72d3dbb9SYuri PankovThe selection of a speed is often performed through
38052d2369aSRobert Mustacchi.Em auto-negotiation ,
38152d2369aSRobert Mustacchithough some devices allow the user to control what speeds are advertised
38252d2369aSRobert Mustacchiand used.
38352d2369aSRobert Mustacchi.Pp
38452d2369aSRobert MustacchiLogically, there are two different sets of things that the device driver
38552d2369aSRobert Mustacchineeds to keep track of while it's operating:
38652d2369aSRobert Mustacchi.Bl -enum
38752d2369aSRobert Mustacchi.It
38852d2369aSRobert MustacchiThe supported speeds in hardware.
38952d2369aSRobert Mustacchi.It
39052d2369aSRobert MustacchiThe enabled speeds from the user.
39152d2369aSRobert Mustacchi.El
39252d2369aSRobert Mustacchi.Pp
39352d2369aSRobert MustacchiBy default, when a link first comes up, the device driver should
39452d2369aSRobert Mustacchigenerally configure the link to support the common set of speeds and
39552d2369aSRobert Mustacchiperform auto-negotiation.
39652d2369aSRobert Mustacchi.Pp
39752d2369aSRobert MustacchiA user can control what speeds a device advertises via auto-negotiation
39852d2369aSRobert Mustacchiand whether or not it performs auto-negotiation at all by using a series
39952d2369aSRobert Mustacchiof properties that have
40052d2369aSRobert Mustacchi.Sy _EN_
401*72d3dbb9SYuri Pankovin the name.
402*72d3dbb9SYuri PankovThese are read/write properties and there is one for each speed supported in the
403*72d3dbb9SYuri Pankovoperating system.
404*72d3dbb9SYuri PankovFor a full list of them, see the
40552d2369aSRobert Mustacchi.Sx PROPERTIES
40652d2369aSRobert Mustacchisection.
40752d2369aSRobert Mustacchi.Pp
40852d2369aSRobert MustacchiIn addition to these properties, there is a corresponding set of
40952d2369aSRobert Mustacchiproperties with
41052d2369aSRobert Mustacchi.Sy _ADV_
411*72d3dbb9SYuri Pankovin the name.
412*72d3dbb9SYuri PankovThese are similar to the
41352d2369aSRobert Mustacchi.Sy _EN_
41452d2369aSRobert Mustacchifamily of properties, but they are read-only and indicate what the
415*72d3dbb9SYuri Pankovdevice has actually negotiated.
416*72d3dbb9SYuri PankovWhile they are generally similar to the
41752d2369aSRobert Mustacchi.Sy _EN_
418*72d3dbb9SYuri Pankovfamily of properties, they may change depending on power settings.
419*72d3dbb9SYuri PankovSee the
42052d2369aSRobert Mustacchi.Sy Ethernet Link Properties
42152d2369aSRobert Mustacchisection in
42252d2369aSRobert Mustacchi.Xr dladm 1M
42352d2369aSRobert Mustacchifor more information.
42452d2369aSRobert Mustacchi.Pp
42552d2369aSRobert MustacchiIt's worth discussing how these different values get used throughout the
426*72d3dbb9SYuri Pankovdifferent entry points.
427*72d3dbb9SYuri PankovThe first entry point to consider is the
42852d2369aSRobert Mustacchi.Xr mc_propinfo 9E
429*72d3dbb9SYuri Pankoventry point.
430*72d3dbb9SYuri PankovFor a given speed, the driver should consult whether or not the hardware
431*72d3dbb9SYuri Pankovsupports this speed.
432*72d3dbb9SYuri PankovIf it does, it should fill in the default value that the hardware takes and
433*72d3dbb9SYuri Pankovwhether or not the property is writable.
434*72d3dbb9SYuri PankovThe properties should also be updated to indicate whether or not it is writable.
435*72d3dbb9SYuri PankovThis holds for both the
43652d2369aSRobert Mustacchi.Sy _EN_
43752d2369aSRobert Mustacchiand
43852d2369aSRobert Mustacchi.Sy _ADV_
43952d2369aSRobert Mustacchifamily of properties.
44052d2369aSRobert Mustacchi.Pp
44152d2369aSRobert MustacchiThe next entry point is
44252d2369aSRobert Mustacchi.Xr mc_getprop 9E .
44352d2369aSRobert MustacchiHere, the device should first consult whether the given speed is
444*72d3dbb9SYuri Pankovsupported.
445*72d3dbb9SYuri PankovIf it is not, then the driver should return
44652d2369aSRobert Mustacchi.Er ENOTSUP .
44752d2369aSRobert MustacchiIf it does, then it should return the current value of the property.
44852d2369aSRobert Mustacchi.Pp
44952d2369aSRobert MustacchiThe last property endpoint is the
45052d2369aSRobert Mustacchi.Xr mc_setprop 9E
451*72d3dbb9SYuri Pankoventry point.
452*72d3dbb9SYuri PankovHere, the same logic applies.
453*72d3dbb9SYuri PankovBefore the driver considers whether or not the property is writable, it should
454*72d3dbb9SYuri Pankovfirst check whether or not it's a supported property.
455*72d3dbb9SYuri PankovIf it's not, then it should return
45652d2369aSRobert Mustacchi.Er ENOTSUP .
45752d2369aSRobert MustacchiOtherwise, it should proceed to check whether the property is writable,
45852d2369aSRobert Mustacchiand if it is and a valid value, then it should update the property and
45952d2369aSRobert Mustacchirestart the link's negotiation.
46052d2369aSRobert Mustacchi.Pp
46152d2369aSRobert MustacchiFinally, there is the
46252d2369aSRobert Mustacchi.Xr mc_getstat 9E
463*72d3dbb9SYuri Pankoventry point.
464*72d3dbb9SYuri PankovSeveral of the statistics that are queried relate to auto-negotiation and
465*72d3dbb9SYuri Pankovhardware capabilities.
466*72d3dbb9SYuri PankovWhen a statistic relates to the hardware supporting a given speed, the
46752d2369aSRobert Mustacchi.Sy _EN_
468*72d3dbb9SYuri Pankovproperties should be ignored.
469*72d3dbb9SYuri PankovThe only thing that should be consulted is what the hardware itself supports.
470*72d3dbb9SYuri PankovOtherwise, the statistics should look at what is currently being advertised by
471*72d3dbb9SYuri Pankovthe device.
47252d2369aSRobert Mustacchi.Ss Unregistering from MAC
47352d2369aSRobert MustacchiDuring a driver's
47452d2369aSRobert Mustacchi.Xr detach 9E
47552d2369aSRobert Mustacchiroutine, it should unregister the device instance from MAC by calling
47652d2369aSRobert Mustacchi.Xr mac_unregister 9F
477*72d3dbb9SYuri Pankovon the handle that it originally called it on.
478*72d3dbb9SYuri PankovIf the call to
47952d2369aSRobert Mustacchi.Xr mac_unregister 9F
48052d2369aSRobert Mustacchifailed, then the device is likely still in use and the driver should
48152d2369aSRobert Mustacchifail the call to
48252d2369aSRobert Mustacchi.Xr detach 9E .
48352d2369aSRobert Mustacchi.Ss Interacting with Devices
48452d2369aSRobert MustacchiAdministrators always interact with devices through the
48552d2369aSRobert Mustacchi.Xr dladm 1M
486*72d3dbb9SYuri Pankovcommand line interface.
487*72d3dbb9SYuri PankovThe state of devices such as whether the link is considered
48852d2369aSRobert Mustacchi.Sy up
48952d2369aSRobert Mustacchior
49052d2369aSRobert Mustacchi.Sy down ,
49152d2369aSRobert Mustacchivarious link properties such as the
49252d2369aSRobert Mustacchi.Sy MTU ,
49352d2369aSRobert Mustacchi.Sy auto-negotiation
49452d2369aSRobert Mustacchistate,
49552d2369aSRobert Mustacchiand
49652d2369aSRobert Mustacchi.Sy flow control
49752d2369aSRobert Mustacchistate,
498*72d3dbb9SYuri Pankovare all exposed.
499*72d3dbb9SYuri PankovIt is also the preferred way that these properties are set and configured.
50052d2369aSRobert Mustacchi.Pp
50152d2369aSRobert MustacchiWhile device tunables may be presented in a
50252d2369aSRobert Mustacchi.Xr driver.conf 4
50352d2369aSRobert Mustacchifile, it is recommended instead to expose such things through
50452d2369aSRobert Mustacchi.Xr dladm 1M
50552d2369aSRobert Mustacchiprivate properties, whether explicitly documented or not.
50652d2369aSRobert Mustacchi.Sh CAPABILITIES
50752d2369aSRobert MustacchiCapabilities in the MAC Framework are optional features that a device
50852d2369aSRobert Mustacchisupports which indicate various hardware features that the device
509*72d3dbb9SYuri Pankovsupports.
510*72d3dbb9SYuri PankovThe two current capabilities that the system supports are related to being able
511*72d3dbb9SYuri Pankovto hardware perform large send offloads (LSO), often also known as TCP
512*72d3dbb9SYuri Pankovsegmentation and the ability for hardware to calculate and verify the checksums
513*72d3dbb9SYuri Pankovpresent in IPv4, IPV6, and protocol headers such as TCP and UDP.
51452d2369aSRobert Mustacchi.Pp
51552d2369aSRobert MustacchiThe MAC framework will query a device for support of a capability
51652d2369aSRobert Mustacchithrough the
51752d2369aSRobert Mustacchi.Xr mc_getcapab 9E
518*72d3dbb9SYuri Pankovfunction.
519*72d3dbb9SYuri PankovEach capability has its own constant and may have corresponding data that goes
520*72d3dbb9SYuri Pankovalong with it and a specific structure that the device is required to fill in.
521*72d3dbb9SYuri PankovNote, the set of capabilities changes over time and there are also private
522*72d3dbb9SYuri Pankovcapabilities in the system.
523*72d3dbb9SYuri PankovSeveral of the capabilities are used in the implementation of the MAC framework.
52452d2369aSRobert MustacchiOthers, like
525c71d194aSDillon Amburgey.Sy MAC_CAPAB_RINGS ,
526*72d3dbb9SYuri Pankovrepresent feature that have not been stabilized and thus both API and binary
527*72d3dbb9SYuri Pankovcompatibility for them is not guaranteed.
528*72d3dbb9SYuri PankovIt is important that the device driver handles unknown capabilities correctly.
529*72d3dbb9SYuri PankovFor more information, see
53052d2369aSRobert Mustacchi.Xr mc_getcapab 9E .
53152d2369aSRobert Mustacchi.Pp
53252d2369aSRobert MustacchiThe following capabilities are
53352d2369aSRobert Mustacchistable and defined in the system:
53452d2369aSRobert Mustacchi.Ss MAC_CAPAB_HCKSUM
53552d2369aSRobert MustacchiThe
53652d2369aSRobert Mustacchi.Sy MAC_CAPAB_HCKSUM
53752d2369aSRobert Mustacchicapability indicates to the system that the device driver supports some
538*72d3dbb9SYuri Pankovamount of checksumming.
539*72d3dbb9SYuri PankovThe specific data for this capability is a pointer to a
54052d2369aSRobert Mustacchi.Sy uint32_t .
54152d2369aSRobert MustacchiTo indicate no support for any kind of checksumming, the driver should
54252d2369aSRobert Mustacchieither set this value to zero or simply return that it doesn't support
54352d2369aSRobert Mustacchithe capability.
54452d2369aSRobert Mustacchi.Pp
54552d2369aSRobert MustacchiNote, the values that the driver declares in this capability indicate
546*72d3dbb9SYuri Pankovwhat it can do when it transmits data.
547*72d3dbb9SYuri PankovIf the driver can only verify checksums when receiving data, then it should not
548*72d3dbb9SYuri Pankovindicate that it supports this capability.
549*72d3dbb9SYuri PankovThe following set of flags may be combined through a bitwise inclusive OR:
55052d2369aSRobert Mustacchi.Bl -tag -width Ds
55152d2369aSRobert Mustacchi.It Sy HCKSUM_INET_PARTIAL
55252d2369aSRobert MustacchiThis indicates that the hardware can calculate a partial checksum for
55352d2369aSRobert Mustacchiboth IPv4 and IPv6; however, it requires the pseudo-header checksum be
554*72d3dbb9SYuri Pankovcalculated for it.
555*72d3dbb9SYuri PankovThe pseudo-header checksum will be available for the mblk_t when calling
55652d2369aSRobert Mustacchi.Xr mac_hcksum_get 9F .
55752d2369aSRobert MustacchiNote this does not imply that the hardware is capable of calculating the
558*72d3dbb9SYuri PankovIPv4 header checksum.
559*72d3dbb9SYuri PankovThat should be indicated with the
56052d2369aSRobert Mustacchi.Sy HCKSUM_IPHDRCKSUM flag.
56152d2369aSRobert Mustacchi.It Sy HCKSUM_INET_FULL_V4
56252d2369aSRobert MustacchiThis indicates that the hardware will fully calculate the L4 checksum
56352d2369aSRobert Mustacchifor outgoing IPv4 packets and does not require a pseudo-header checksum.
56452d2369aSRobert MustacchiNote this does not imply that the hardware is capable of calculating the
565*72d3dbb9SYuri PankovIPv4 header checksum.
566*72d3dbb9SYuri PankovThat should be indicated with the
56752d2369aSRobert Mustacchi.Sy HCKSUM_IPHDRCKSUM .
56852d2369aSRobert Mustacchi.It Sy HCKSUM_INET_FULL_V6
56952d2369aSRobert MustacchiThis indicates that the hardware will fully calculate the L4 checksum
57052d2369aSRobert Mustacchifor outgoing IPv6 packets and does not require a pseudo-header checksum.
57152d2369aSRobert Mustacchi.It Sy HCKSUM_IPHDRCKSUM
57252d2369aSRobert MustacchiThis indicates that the hardware supports calculating the checksum for
57352d2369aSRobert Mustacchithe IPv4 header itself.
57452d2369aSRobert Mustacchi.El
57552d2369aSRobert Mustacchi.Pp
57652d2369aSRobert MustacchiWhen in a driver's transmit function, the driver will be processing a
577*72d3dbb9SYuri Pankovsingle frame.
578*72d3dbb9SYuri PankovIt should call
57952d2369aSRobert Mustacchi.Xr mac_hcksum_get 9F
580*72d3dbb9SYuri Pankovto see what checksum flags are set on it.
581*72d3dbb9SYuri PankovNote that the flags that are set on it are different from the ones described
582*72d3dbb9SYuri Pankovabove and are documented in its manual page.
583*72d3dbb9SYuri PankovThese flags indicate how the driver is expected to program the hardware and what
584*72d3dbb9SYuri Pankovchecksumming is required.
585*72d3dbb9SYuri PankovNot all frames will require hardware checksumming or will ask the hardware to
586*72d3dbb9SYuri Pankovchecksum it.
58752d2369aSRobert Mustacchi.Pp
58852d2369aSRobert MustacchiIf a driver supports offloading the receive checksum and verification,
589*72d3dbb9SYuri Pankovit should check to see what the hardware indicated was verified.
590*72d3dbb9SYuri PankovThe driver should then call
59152d2369aSRobert Mustacchi.Xr mac_hcksum_set 9F .
59252d2369aSRobert MustacchiThe flags used are different from the ones above and are discussed in
59352d2369aSRobert Mustacchidetail in the
59452d2369aSRobert Mustacchi.Xr mac_hcksum_set 9F
595*72d3dbb9SYuri Pankovmanual page.
596*72d3dbb9SYuri PankovIf there is no checksum information available or the driver does not support
597*72d3dbb9SYuri Pankovchecksumming, then it should simply not call
59852d2369aSRobert Mustacchi.Xr mac_hcksum_set 9F .
59952d2369aSRobert Mustacchi.Pp
60052d2369aSRobert MustacchiNote that the checksum flags should be set on the first
601*72d3dbb9SYuri Pankovmblk_t that makes up a given message.
602*72d3dbb9SYuri PankovIn other words, if multiple mblk_t structures are linked together by the
60352d2369aSRobert Mustacchi.Sy b_cont
60452d2369aSRobert Mustacchimember to describe a single frame, then it should only be called on the
605*72d3dbb9SYuri Pankovfirst mblk_t of that set.
606*72d3dbb9SYuri PankovHowever, each distinct message should have the checksum bits set on it, if
607*72d3dbb9SYuri Pankovapplicable.
608*72d3dbb9SYuri PankovIn other words, each mblk_t that is linked together by the
60952d2369aSRobert Mustacchi.Sy b_next
61052d2369aSRobert Mustacchipointer may have checksum flags set.
61152d2369aSRobert Mustacchi.Pp
61252d2369aSRobert MustacchiIt is recommended that device drivers provide a private property or
61352d2369aSRobert Mustacchi.Xr driver.conf 4
61452d2369aSRobert Mustacchiproperty to control whether or not checksumming is enabled for both rx
61552d2369aSRobert Mustacchiand tx; however, the default disposition is recommended to be enabled
616*72d3dbb9SYuri Pankovfor both.
617*72d3dbb9SYuri PankovThis way if hardware bugs are found in the checksumming implementation, they can
618*72d3dbb9SYuri Pankovbe disabled without requiring software updates.
61952d2369aSRobert MustacchiThe transmit property should be checked when determining how to reply to
62052d2369aSRobert Mustacchi.Xr mc_getcapab 9E
62152d2369aSRobert Mustacchiand the receive property should be checked in the context of the receive
62252d2369aSRobert Mustacchifunction.
62352d2369aSRobert Mustacchi.Ss MAC_CAPAB_LSO
62452d2369aSRobert MustacchiThe
62552d2369aSRobert Mustacchi.Sy MAC_CAPAB_LSO
62652d2369aSRobert Mustacchicapability indicates that the driver supports various forms of large
627*72d3dbb9SYuri Pankovsend offload (LSO).
628*72d3dbb9SYuri PankovThe private data is a pointer to a
62952d2369aSRobert Mustacchi.Sy mac_capab_lso_t
630*72d3dbb9SYuri Pankovstructure.
631*72d3dbb9SYuri PankovAt the moment, LSO support is limited to TCP inside of IPv4.
63252d2369aSRobert MustacchiThis structure has the following members which are used to indicate
63352d2369aSRobert Mustacchivarious types of LSO support.
63452d2369aSRobert Mustacchi.Bd -literal -offset indent
63552d2369aSRobert Mustacchit_uscalar_t		lso_flags;
63652d2369aSRobert Mustacchilso_basic_tcp_ivr4_t	lso_basic_tcp_ipv4;
63752d2369aSRobert Mustacchi.Ed
63852d2369aSRobert Mustacchi.Pp
63952d2369aSRobert MustacchiThe
64052d2369aSRobert Mustacchi.Sy lso_flags
64152d2369aSRobert Mustacchimember is used to indicate which members are valid and should be
642*72d3dbb9SYuri Pankovconsidered.
643*72d3dbb9SYuri PankovEach flag represents a different form of LSO.
644*72d3dbb9SYuri PankovThe member should be set to the bitwise inclusive OR of the following values:
64552d2369aSRobert Mustacchi.Bl -tag -width Dv -offset indent
64652d2369aSRobert Mustacchi.It Sy LSO_TX_BASIC_TCP_IPV4
64752d2369aSRobert MustacchiThis indicates hardware support for performing TCP segmentation
648*72d3dbb9SYuri Pankovoffloading over IPv4.
649*72d3dbb9SYuri PankovWhen this flag is set, the
65052d2369aSRobert Mustacchi.Sy lso_basic_tcp_ipv4
65152d2369aSRobert Mustacchimember must be filled in.
65252d2369aSRobert Mustacchi.El
65352d2369aSRobert Mustacchi.Pp
65452d2369aSRobert MustacchiThe
65552d2369aSRobert Mustacchi.Sy lso_basic_tcp_ipv4
65652d2369aSRobert Mustacchimember is a structure with the following members:
65752d2369aSRobert Mustacchi.Bd -literal -offset indent
65852d2369aSRobert Mustacchit_uscalar_t	lso_max
65952d2369aSRobert Mustacchi.Ed
66052d2369aSRobert Mustacchi.Bd -filled -offset indent
66152d2369aSRobert MustacchiThe
66252d2369aSRobert Mustacchi.Sy lso_max
66352d2369aSRobert Mustacchimember should be set to the maximum size of the TCP data
66452d2369aSRobert Mustacchipayload that can be offloaded to the hardware.
66552d2369aSRobert Mustacchi.Ed
66652d2369aSRobert Mustacchi.Pp
66752d2369aSRobert MustacchiLike with checksumming, it is recommended that driver writers provide a
66852d2369aSRobert Mustacchimeans for disabling the support of LSO even if it is enabled by default.
66952d2369aSRobert MustacchiThis deals with the case where issues that pop up for LSO may be worked
67052d2369aSRobert Mustacchiaround without requiring additional driver work.
67152d2369aSRobert Mustacchi.Sh PROPERTIES
672*72d3dbb9SYuri PankovProperties in the MAC framework represent aspects of a link.
673*72d3dbb9SYuri PankovThese include things like the link's current state and MTU.
674*72d3dbb9SYuri PankovMany of the properties in the system are focused around auto-negotiation and
675*72d3dbb9SYuri Pankovcontrolling what link speeds are advertised.
676*72d3dbb9SYuri PankovInformation about properties is covered by three different device entry points.
677*72d3dbb9SYuri PankovThe
67852d2369aSRobert Mustacchi.Xr mc_propinfo 9E
679*72d3dbb9SYuri Pankoventry point obtains metadata about the property.
680*72d3dbb9SYuri PankovThe
68152d2369aSRobert Mustacchi.Xr mc_getprop 9E
682*72d3dbb9SYuri Pankoventry point obtains the property.
683*72d3dbb9SYuri PankovThe
68452d2369aSRobert Mustacchi.Xr mc_setprop 9E
68552d2369aSRobert Mustacchientry point updates the property to a new value.
68652d2369aSRobert Mustacchi.Pp
687*72d3dbb9SYuri PankovMany of the properties listed below are read-only.
688*72d3dbb9SYuri PankovEach property indicates whether it's read-only or it's read/write.
689*72d3dbb9SYuri PankovHowever, driver writers may not implement the ability to set all writable
690*72d3dbb9SYuri Pankovproperties.
691*72d3dbb9SYuri PankovMany of these depend on the card itself.
692*72d3dbb9SYuri PankovIn particular, all properties that relate to auto-negotiation and are read/write
693*72d3dbb9SYuri Pankovmay not be updated if the hardware in question does not support toggling what
694*72d3dbb9SYuri Pankovlink speeds are auto-negotiated.
695*72d3dbb9SYuri PankovWhile copper Ethernet often does not have this restriction, it often exists with
696*72d3dbb9SYuri Pankovvarious fiber standards and phys.
69752d2369aSRobert Mustacchi.Pp
69852d2369aSRobert MustacchiThe following properties are the subset of MAC framework properties that
699*72d3dbb9SYuri Pankovdriver writers should be aware of and handle.
700*72d3dbb9SYuri PankovWhile other properties exist in the system, driver writers should always return
701*72d3dbb9SYuri Pankovan error when a property not listed below is encountered.
702*72d3dbb9SYuri PankovSee
70352d2369aSRobert Mustacchi.Xr mc_getprop 9E
70452d2369aSRobert Mustacchiand
70552d2369aSRobert Mustacchi.Xr mc_setprop 9E
70652d2369aSRobert Mustacchifor more information on how to handle them.
70752d2369aSRobert Mustacchi.Bl -hang -width Ds
70852d2369aSRobert Mustacchi.It Sy MAC_PROP_DUPLEX
70952d2369aSRobert Mustacchi.Bd -filled -compact
71052d2369aSRobert MustacchiType:
71152d2369aSRobert Mustacchi.Sy link_duplex_t |
71252d2369aSRobert MustacchiPermissions:
71352d2369aSRobert Mustacchi.Sy Read-Only
71452d2369aSRobert Mustacchi.Ed
71552d2369aSRobert Mustacchi.Pp
71652d2369aSRobert MustacchiThe
71752d2369aSRobert Mustacchi.Sy MAC_PROP_DUPLEX
718*72d3dbb9SYuri Pankovproperty is used to indicate whether or not the link is duplex.
719*72d3dbb9SYuri PankovA duplex link may have traffic flowing in both directions at the same time.
720*72d3dbb9SYuri PankovThe
72152d2369aSRobert Mustacchi.Sy link_duplex_t
72252d2369aSRobert Mustacchiis an enumeration which may be set to any of the following values:
72352d2369aSRobert Mustacchi.Bl -tag -width Ds
72452d2369aSRobert Mustacchi.It Sy LINK_DUPLEX_UNKNOWN
725*72d3dbb9SYuri PankovThe current state of the link is unknown.
726*72d3dbb9SYuri PankovThis may be because the link has not negotiated to a specific speed or it is
727*72d3dbb9SYuri Pankovdown.
72852d2369aSRobert Mustacchi.It Sy LINK_DUPLEX_HALF
729*72d3dbb9SYuri PankovThe link is running at half duplex.
730*72d3dbb9SYuri PankovCommunication may travel in only one direction on the link at a given time.
73152d2369aSRobert Mustacchi.It Sy LINK_DUPLEX_FULL
732*72d3dbb9SYuri PankovThe link is running at full duplex.
733*72d3dbb9SYuri PankovCommunication may travel in both directions on the link simultaneously.
73452d2369aSRobert Mustacchi.El
73552d2369aSRobert Mustacchi.It Sy MAC_PROP_SPEED
73652d2369aSRobert Mustacchi.Bd -filled -compact
73752d2369aSRobert MustacchiType:
73852d2369aSRobert Mustacchi.Sy uint64_t |
73952d2369aSRobert MustacchiPermissions:
74052d2369aSRobert Mustacchi.Sy Read-Only
74152d2369aSRobert Mustacchi.Ed
74252d2369aSRobert Mustacchi.Pp
74352d2369aSRobert MustacchiThe
74452d2369aSRobert Mustacchi.Sy MAC_PROP_SPEED
745*72d3dbb9SYuri Pankovproperty stores the current link speed in bits per second.
746*72d3dbb9SYuri PankovA link that is running at 100 MBit/s would store the value 100000000ULL.
747*72d3dbb9SYuri PankovA link that is running at 40 Gbit/s would store the value 40000000000ULL.
74852d2369aSRobert Mustacchi.It Sy MAC_PROP_STATUS
74952d2369aSRobert Mustacchi.Bd -filled -compact
75052d2369aSRobert MustacchiType:
75152d2369aSRobert Mustacchi.Sy link_state_t |
75252d2369aSRobert MustacchiPermissions:
75352d2369aSRobert Mustacchi.Sy Read-Only
75452d2369aSRobert Mustacchi.Ed
75552d2369aSRobert Mustacchi.Pp
75652d2369aSRobert MustacchiThe
75752d2369aSRobert Mustacchi.Sy MAC_PROP_STATUS
758*72d3dbb9SYuri Pankovproperty is used to indicate the current state of the link.
759*72d3dbb9SYuri PankovIt indicates whether the link is up or down.
760*72d3dbb9SYuri PankovThe
76152d2369aSRobert Mustacchi.Sy link_state_t
76252d2369aSRobert Mustacchiis an enumeration which may be set to any of the following values:
76352d2369aSRobert Mustacchi.Bl -tag -width Ds
76452d2369aSRobert Mustacchi.It Sy LINK_STATE_UNKNOWN
765*72d3dbb9SYuri PankovThe current state of the link is unknown.
766*72d3dbb9SYuri PankovThis may be because the driver's
76752d2369aSRobert Mustacchi.Xr mc_start 9E
76852d2369aSRobert Mustacchiendpoint has not been called so it has not attempted to start the link.
76952d2369aSRobert Mustacchi.It Sy LINK_STATE_DOWN
770*72d3dbb9SYuri PankovThe link is down.
771*72d3dbb9SYuri PankovThis may be because of a negotiation problem, a cable problem, or some other
772*72d3dbb9SYuri Pankovdevice specific issue.
77352d2369aSRobert Mustacchi.It Sy LINK_STATE_UP
774*72d3dbb9SYuri PankovThe link is up.
775*72d3dbb9SYuri PankovIf auto-negotiation is in use, it should have completed.
77652d2369aSRobert MustacchiTraffic should be able to flow over the link, barring other issues.
77752d2369aSRobert Mustacchi.El
77852d2369aSRobert Mustacchi.It Sy MAC_PROP_AUTONEG
77952d2369aSRobert Mustacchi.Bd -filled -compact
78052d2369aSRobert MustacchiType:
78152d2369aSRobert Mustacchi.Sy uint8_t |
78252d2369aSRobert MustacchiPermissions:
78352d2369aSRobert Mustacchi.Sy Read/Write
78452d2369aSRobert Mustacchi.Ed
78552d2369aSRobert Mustacchi.Pp
78652d2369aSRobert MustacchiThe
78752d2369aSRobert Mustacchi.Sy MAC_PROP_AUTONEG
78852d2369aSRobert Mustacchiproperty indicates whether or not the device is currently configured to
789*72d3dbb9SYuri Pankovperform auto-negotiation.
790*72d3dbb9SYuri PankovA value of
79152d2369aSRobert Mustacchi.Sy 0
792*72d3dbb9SYuri Pankovindicates that auto-negotiation is disabled.
793*72d3dbb9SYuri PankovA
79452d2369aSRobert Mustacchi.Sy non-zero
795*72d3dbb9SYuri Pankovvalue indicates that auto-negotiation is enabled.
796*72d3dbb9SYuri PankovDevices should generally default to enabling auto-negotiation.
79752d2369aSRobert Mustacchi.Pp
79852d2369aSRobert MustacchiWhen getting this property, the device driver should return the current
799*72d3dbb9SYuri Pankovstate.
800*72d3dbb9SYuri PankovWhen setting this property, if the device supports operating in the requested
801*72d3dbb9SYuri Pankovmode, then the device driver should reset the link to negotiate to the new speed
802*72d3dbb9SYuri Pankovafter updating any internal registers.
80352d2369aSRobert Mustacchi.It Sy MAC_PROP_MTU
80452d2369aSRobert Mustacchi.Bd -filled -compact
80552d2369aSRobert MustacchiType:
80652d2369aSRobert Mustacchi.Sy uint32_t |
80752d2369aSRobert MustacchiPermissions:
80852d2369aSRobert Mustacchi.Sy Read/Write
80952d2369aSRobert Mustacchi.Ed
81052d2369aSRobert Mustacchi.Pp
81152d2369aSRobert MustacchiThe
81252d2369aSRobert Mustacchi.Sy MAC_PROP_MTU
813*72d3dbb9SYuri Pankovproperty determines the maximum transmission unit (MTU).
814*72d3dbb9SYuri PankovThis indicates the maximum size packet that the device can transmit, ignoring
815*72d3dbb9SYuri Pankovits own headers.
816*72d3dbb9SYuri PankovFor an Ethernet device, this would exclude the size of the Ethernet header and
817*72d3dbb9SYuri Pankovany VLAN headers that would be placed.
818*72d3dbb9SYuri PankovIt is up to the driver to ensure that any MTU values that it accepts when adding
819*72d3dbb9SYuri Pankovin its margin and header sizes does not exceed its maximum frame size.
82052d2369aSRobert Mustacchi.Pp
82152d2369aSRobert MustacchiBy default, drivers for Ethernet should initialize this value and the
82252d2369aSRobert MustacchiMTU to
82352d2369aSRobert Mustacchi.Sy 1500 .
82452d2369aSRobert MustacchiWhen getting this property, the driver should return its current
825*72d3dbb9SYuri Pankovrecorded MTU.
826*72d3dbb9SYuri PankovWhen setting this property, the driver should first validate that it is within
827*72d3dbb9SYuri Pankovthe device's valid range and then it must call
82852d2369aSRobert Mustacchi.Xr mac_maxsdu_update 9F .
829*72d3dbb9SYuri PankovNote that the call may fail.
830*72d3dbb9SYuri PankovIf the call completes successfully, the driver should update the hardware with
831*72d3dbb9SYuri Pankovthe new value of the MTU and perform any other work needed to handle it.
83252d2369aSRobert Mustacchi.Pp
83352d2369aSRobert MustacchiIf the device does not support changing the MTU after the device's
83452d2369aSRobert Mustacchi.Xr mc_start 9E
83552d2369aSRobert Mustacchientry point has been called, then driver writers should return
83652d2369aSRobert Mustacchi.Er EBUSY .
83752d2369aSRobert Mustacchi.It Sy MAC_PROP_FLOWCTRL
83852d2369aSRobert Mustacchi.Bd -filled -compact
83952d2369aSRobert MustacchiType:
84052d2369aSRobert Mustacchi.Sy link_flowctrl_t |
84152d2369aSRobert MustacchiPermissions:
84252d2369aSRobert Mustacchi.Sy Read/Write
84352d2369aSRobert Mustacchi.Ed
84452d2369aSRobert Mustacchi.Pp
84552d2369aSRobert MustacchiThe
84652d2369aSRobert Mustacchi.Sy MAC_PROP_FLOWCTRL
84752d2369aSRobert Mustacchiproperty manages the configuration of pause frames as part of Ethernet
848*72d3dbb9SYuri Pankovflow control.
849*72d3dbb9SYuri PankovNote, this only describes what this device will advertise.
85052d2369aSRobert MustacchiWhat is actually enabled may be different and is subject to the rules of
851*72d3dbb9SYuri Pankovauto-negotiation.
852*72d3dbb9SYuri PankovThe
85352d2369aSRobert Mustacchi.Sy link_flowctrl_t
85452d2369aSRobert Mustacchiis an enumeration that may be set to one of the following values:
85552d2369aSRobert Mustacchi.Bl -tag -width Ds
85652d2369aSRobert Mustacchi.It Sy LINK_FLOWCTRL_NONE
857*72d3dbb9SYuri PankovFlow control is disabled.
858*72d3dbb9SYuri PankovNo pause frames should be generated or honored.
85952d2369aSRobert Mustacchi.It Sy LINK_FLOWCTRL_RX
86052d2369aSRobert MustacchiThe device can receive pause frames; however, it should not generate
86152d2369aSRobert Mustacchithem.
86252d2369aSRobert Mustacchi.It Sy LINK_FLOWCTRL_TX
86352d2369aSRobert MustacchiThe device can generate pause frames; however, it does not support
86452d2369aSRobert Mustacchireceiving them.
86552d2369aSRobert Mustacchi.It Sy LINK_FLOWCTRL_BI
86652d2369aSRobert MustacchiThe device supports both sending and receiving pause frames.
86752d2369aSRobert Mustacchi.El
86852d2369aSRobert Mustacchi.Pp
86952d2369aSRobert MustacchiWhen getting this property, the device driver should return the way that
87052d2369aSRobert Mustacchiit has configured the device, not what the device has actually
871*72d3dbb9SYuri Pankovnegotiated.
872*72d3dbb9SYuri PankovWhen setting the property, it should update the hardware and allow the link to
873*72d3dbb9SYuri Pankovpotentially perform auto-negotiation again.
87452d2369aSRobert Mustacchi.El
87552d2369aSRobert Mustacchi.Pp
87652d2369aSRobert MustacchiThe remaining properties are all about various auto-negotiation link
877*72d3dbb9SYuri Pankovspeeds.
878*72d3dbb9SYuri PankovThey fall into two different buckets: properties with
87952d2369aSRobert Mustacchi.Sy _ADV_
88052d2369aSRobert Mustacchiin the name and properties with
88152d2369aSRobert Mustacchi.Sy _EN_
882*72d3dbb9SYuri Pankovin the name.
883*72d3dbb9SYuri PankovFor any given supported speed, there is one of each.
884*72d3dbb9SYuri PankovThe
88552d2369aSRobert Mustacchi.Sy _EN_
88652d2369aSRobert Mustacchiset of properties are read/write properties that control what should be
887*72d3dbb9SYuri Pankovadvertised by the device.
888*72d3dbb9SYuri PankovWhen these are retrieved, they should return the current value of the property.
889*72d3dbb9SYuri PankovWhen they are set, they should change how the hardware advertises the specific
890*72d3dbb9SYuri Pankovspeed and trigger any kind of link reset and auto-negotiation, if enabled, to
891*72d3dbb9SYuri Pankovoccur.
89252d2369aSRobert Mustacchi.Pp
89352d2369aSRobert MustacchiThe
89452d2369aSRobert Mustacchi.Sy _ADV_
895*72d3dbb9SYuri Pankovset of properties are read-only properties.
896*72d3dbb9SYuri PankovThey are meant to reflect what has actually been negotiated.
897*72d3dbb9SYuri PankovThese may be different from the
89852d2369aSRobert Mustacchi.Sy _EN_
89952d2369aSRobert Mustacchifamily of properties, especially when different power management
90052d2369aSRobert Mustacchisettings are at play.
90152d2369aSRobert Mustacchi.Pp
90252d2369aSRobert MustacchiSee the
90352d2369aSRobert Mustacchi.Sx Link Speed and Auto-negotiation
90452d2369aSRobert Mustacchisection for more information.
90552d2369aSRobert Mustacchi.Pp
90652d2369aSRobert MustacchiThe properties are ordered in increasing link speed:
90752d2369aSRobert Mustacchi.Bl -hang -width Ds
90852d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_10HDX_CAP
90952d2369aSRobert Mustacchi.Bd -filled -compact
91052d2369aSRobert MustacchiType:
91152d2369aSRobert Mustacchi.Sy uint8_t |
91252d2369aSRobert MustacchiPermissions:
91352d2369aSRobert Mustacchi.Sy Read-Only
91452d2369aSRobert Mustacchi.Ed
91552d2369aSRobert Mustacchi.Pp
91652d2369aSRobert MustacchiThe
91752d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_10HDX_CAP
91852d2369aSRobert Mustacchiproperty describes whether or not 10 Mbit/s half-duplex support is
91952d2369aSRobert Mustacchiadvertised.
92052d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_10HDX_CAP
92152d2369aSRobert Mustacchi.Bd -filled -compact
92252d2369aSRobert MustacchiType:
92352d2369aSRobert Mustacchi.Sy uint8_t |
92452d2369aSRobert MustacchiPermissions:
92552d2369aSRobert Mustacchi.Sy Read/Write
92652d2369aSRobert Mustacchi.Ed
92752d2369aSRobert Mustacchi.Pp
92852d2369aSRobert MustacchiThe
92952d2369aSRobert Mustacchi.Sy MAC_PROP_EN_10HDX_CAP
93052d2369aSRobert Mustacchiproperty describes whether or not 10 Mbit/s half-duplex support is
93152d2369aSRobert Mustacchienabled.
93252d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_10FDX_CAP
93352d2369aSRobert Mustacchi.Bd -filled -compact
93452d2369aSRobert MustacchiType:
93552d2369aSRobert Mustacchi.Sy uint8_t |
93652d2369aSRobert MustacchiPermissions:
93752d2369aSRobert Mustacchi.Sy Read-Only
93852d2369aSRobert Mustacchi.Ed
93952d2369aSRobert Mustacchi.Pp
94052d2369aSRobert MustacchiThe
94152d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_10FDX_CAP
94252d2369aSRobert Mustacchiproperty describes whether or not 10 Mbit/s full-duplex support is
94352d2369aSRobert Mustacchiadvertised.
94452d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_10FDX_CAP
94552d2369aSRobert Mustacchi.Bd -filled -compact
94652d2369aSRobert MustacchiType:
94752d2369aSRobert Mustacchi.Sy uint8_t |
94852d2369aSRobert MustacchiPermissions:
94952d2369aSRobert Mustacchi.Sy Read/Write
95052d2369aSRobert Mustacchi.Ed
95152d2369aSRobert Mustacchi.Pp
95252d2369aSRobert MustacchiThe
95352d2369aSRobert Mustacchi.Sy MAC_PROP_EN_10FDX_CAP
95452d2369aSRobert Mustacchiproperty describes whether or not 10 Mbit/s full-duplex support is
95552d2369aSRobert Mustacchienabled.
95652d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_100HDX_CAP
95752d2369aSRobert Mustacchi.Bd -filled -compact
95852d2369aSRobert MustacchiType:
95952d2369aSRobert Mustacchi.Sy uint8_t |
96052d2369aSRobert MustacchiPermissions:
96152d2369aSRobert Mustacchi.Sy Read-Only
96252d2369aSRobert Mustacchi.Ed
96352d2369aSRobert Mustacchi.Pp
96452d2369aSRobert MustacchiThe
96552d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_100HDX_CAP
96652d2369aSRobert Mustacchiproperty describes whether or not 100 Mbit/s half-duplex support is
96752d2369aSRobert Mustacchiadvertised.
96852d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_100HDX_CAP
96952d2369aSRobert Mustacchi.Bd -filled -compact
97052d2369aSRobert MustacchiType:
97152d2369aSRobert Mustacchi.Sy uint8_t |
97252d2369aSRobert MustacchiPermissions:
97352d2369aSRobert Mustacchi.Sy Read/Write
97452d2369aSRobert Mustacchi.Ed
97552d2369aSRobert Mustacchi.Pp
97652d2369aSRobert MustacchiThe
97752d2369aSRobert Mustacchi.Sy MAC_PROP_EN_100HDX_CAP
97852d2369aSRobert Mustacchiproperty describes whether or not 100 Mbit/s half-duplex support is
97952d2369aSRobert Mustacchienabled.
98052d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_100FDX_CAP
98152d2369aSRobert Mustacchi.Bd -filled -compact
98252d2369aSRobert MustacchiType:
98352d2369aSRobert Mustacchi.Sy uint8_t |
98452d2369aSRobert MustacchiPermissions:
98552d2369aSRobert Mustacchi.Sy Read-Only
98652d2369aSRobert Mustacchi.Ed
98752d2369aSRobert Mustacchi.Pp
98852d2369aSRobert MustacchiThe
98952d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_100FDX_CAP
99052d2369aSRobert Mustacchiproperty describes whether or not 100 Mbit/s full-duplex support is
99152d2369aSRobert Mustacchiadvertised.
99252d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_100FDX_CAP
99352d2369aSRobert Mustacchi.Bd -filled -compact
99452d2369aSRobert MustacchiType:
99552d2369aSRobert Mustacchi.Sy uint8_t |
99652d2369aSRobert MustacchiPermissions:
99752d2369aSRobert Mustacchi.Sy Read/Write
99852d2369aSRobert Mustacchi.Ed
99952d2369aSRobert Mustacchi.Pp
100052d2369aSRobert MustacchiThe
100152d2369aSRobert Mustacchi.Sy MAC_PROP_EN_100FDX_CAP
100252d2369aSRobert Mustacchiproperty describes whether or not 100 Mbit/s full-duplex support is
100352d2369aSRobert Mustacchienabled.
100452d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_100T4_CAP
100552d2369aSRobert Mustacchi.Bd -filled -compact
100652d2369aSRobert MustacchiType:
100752d2369aSRobert Mustacchi.Sy uint8_t |
100852d2369aSRobert MustacchiPermissions:
100952d2369aSRobert Mustacchi.Sy Read-Only
101052d2369aSRobert Mustacchi.Ed
101152d2369aSRobert Mustacchi.Pp
101252d2369aSRobert MustacchiThe
101352d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_100T4_CAP
101452d2369aSRobert Mustacchiproperty describes whether or not 100 Mbit/s Ethernet using the
101552d2369aSRobert Mustacchi100BASE-T4 standard is
101652d2369aSRobert Mustacchiadvertised.
101752d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_100T4_CAP
101852d2369aSRobert Mustacchi.Bd -filled -compact
101952d2369aSRobert MustacchiType:
102052d2369aSRobert Mustacchi.Sy uint8_t |
102152d2369aSRobert MustacchiPermissions:
102252d2369aSRobert Mustacchi.Sy Read/Write
102352d2369aSRobert Mustacchi.Ed
102452d2369aSRobert Mustacchi.Pp
102552d2369aSRobert MustacchiThe
102652d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_100T4_CAP
102752d2369aSRobert Mustacchiproperty describes whether or not 100 Mbit/s Ethernet using the
102852d2369aSRobert Mustacchi100BASE-T4 standard is
102952d2369aSRobert Mustacchienabled.
103052d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_1000HDX_CAP
103152d2369aSRobert Mustacchi.Bd -filled -compact
103252d2369aSRobert MustacchiType:
103352d2369aSRobert Mustacchi.Sy uint8_t |
103452d2369aSRobert MustacchiPermissions:
103552d2369aSRobert Mustacchi.Sy Read-Only
103652d2369aSRobert Mustacchi.Ed
103752d2369aSRobert Mustacchi.Pp
103852d2369aSRobert MustacchiThe
103952d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_1000HDX_CAP
104052d2369aSRobert Mustacchiproperty describes whether or not 1 Gbit/s half-duplex support is
104152d2369aSRobert Mustacchiadvertised.
104252d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_1000HDX_CAP
104352d2369aSRobert Mustacchi.Bd -filled -compact
104452d2369aSRobert MustacchiType:
104552d2369aSRobert Mustacchi.Sy uint8_t |
104652d2369aSRobert MustacchiPermissions:
104752d2369aSRobert Mustacchi.Sy Read/Write
104852d2369aSRobert Mustacchi.Ed
104952d2369aSRobert Mustacchi.Pp
105052d2369aSRobert MustacchiThe
105152d2369aSRobert Mustacchi.Sy MAC_PROP_EN_1000HDX_CAP
105252d2369aSRobert Mustacchiproperty describes whether or not 1 Gbit/s half-duplex support is
105352d2369aSRobert Mustacchienabled.
105452d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_1000FDX_CAP
105552d2369aSRobert Mustacchi.Bd -filled -compact
105652d2369aSRobert MustacchiType:
105752d2369aSRobert Mustacchi.Sy uint8_t |
105852d2369aSRobert MustacchiPermissions:
105952d2369aSRobert Mustacchi.Sy Read-Only
106052d2369aSRobert Mustacchi.Ed
106152d2369aSRobert Mustacchi.Pp
106252d2369aSRobert MustacchiThe
106352d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_1000FDX_CAP
106452d2369aSRobert Mustacchiproperty describes whether or not 1 Gbit/s full-duplex support is
106552d2369aSRobert Mustacchiadvertised.
106652d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_1000FDX_CAP
106752d2369aSRobert Mustacchi.Bd -filled -compact
106852d2369aSRobert MustacchiType:
106952d2369aSRobert Mustacchi.Sy uint8_t |
107052d2369aSRobert MustacchiPermissions:
107152d2369aSRobert Mustacchi.Sy Read/Write
107252d2369aSRobert Mustacchi.Ed
107352d2369aSRobert Mustacchi.Pp
107452d2369aSRobert MustacchiThe
107552d2369aSRobert Mustacchi.Sy MAC_PROP_EN_1000FDX_CAP
107652d2369aSRobert Mustacchiproperty describes whether or not 1 Gbit/s full-duplex support is
107752d2369aSRobert Mustacchienabled.
107852d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_2500FDX_CAP
107952d2369aSRobert Mustacchi.Bd -filled -compact
108052d2369aSRobert MustacchiType:
108152d2369aSRobert Mustacchi.Sy uint8_t |
108252d2369aSRobert MustacchiPermissions:
108352d2369aSRobert Mustacchi.Sy Read-Only
108452d2369aSRobert Mustacchi.Ed
108552d2369aSRobert Mustacchi.Pp
108652d2369aSRobert MustacchiThe
108752d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_2500FDX_CAP
108852d2369aSRobert Mustacchiproperty describes whether or not 2.5 Gbit/s full-duplex support is
108952d2369aSRobert Mustacchiadvertised.
109052d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_2500FDX_CAP
109152d2369aSRobert Mustacchi.Bd -filled -compact
109252d2369aSRobert MustacchiType:
109352d2369aSRobert Mustacchi.Sy uint8_t |
109452d2369aSRobert MustacchiPermissions:
109552d2369aSRobert Mustacchi.Sy Read/Write
109652d2369aSRobert Mustacchi.Ed
109752d2369aSRobert Mustacchi.Pp
109852d2369aSRobert MustacchiThe
109952d2369aSRobert Mustacchi.Sy MAC_PROP_EN_2500FDX_CAP
110052d2369aSRobert Mustacchiproperty describes whether or not 2.5 Gbit/s full-duplex support is
110152d2369aSRobert Mustacchienabled.
110252d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_5000FDX_CAP
110352d2369aSRobert Mustacchi.Bd -filled -compact
110452d2369aSRobert MustacchiType:
110552d2369aSRobert Mustacchi.Sy uint8_t |
110652d2369aSRobert MustacchiPermissions:
110752d2369aSRobert Mustacchi.Sy Read-Only
110852d2369aSRobert Mustacchi.Ed
110952d2369aSRobert Mustacchi.Pp
111052d2369aSRobert MustacchiThe
111152d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_5000FDX_CAP
111252d2369aSRobert Mustacchiproperty describes whether or not 5.0 Gbit/s full-duplex support is
111352d2369aSRobert Mustacchiadvertised.
111452d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_5000FDX_CAP
111552d2369aSRobert Mustacchi.Bd -filled -compact
111652d2369aSRobert MustacchiType:
111752d2369aSRobert Mustacchi.Sy uint8_t |
111852d2369aSRobert MustacchiPermissions:
111952d2369aSRobert Mustacchi.Sy Read/Write
112052d2369aSRobert Mustacchi.Ed
112152d2369aSRobert Mustacchi.Pp
112252d2369aSRobert MustacchiThe
112352d2369aSRobert Mustacchi.Sy MAC_PROP_EN_5000FDX_CAP
112452d2369aSRobert Mustacchiproperty describes whether or not 5.0 Gbit/s full-duplex support is
112552d2369aSRobert Mustacchienabled.
112652d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_10GFDX_CAP
112752d2369aSRobert Mustacchi.Bd -filled -compact
112852d2369aSRobert MustacchiType:
112952d2369aSRobert Mustacchi.Sy uint8_t |
113052d2369aSRobert MustacchiPermissions:
113152d2369aSRobert Mustacchi.Sy Read-Only
113252d2369aSRobert Mustacchi.Ed
113352d2369aSRobert Mustacchi.Pp
113452d2369aSRobert MustacchiThe
113552d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_10GFDX_CAP
113652d2369aSRobert Mustacchiproperty describes whether or not 10 Gbit/s full-duplex support is
113752d2369aSRobert Mustacchiadvertised.
113852d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_10GFDX_CAP
113952d2369aSRobert Mustacchi.Bd -filled -compact
114052d2369aSRobert MustacchiType:
114152d2369aSRobert Mustacchi.Sy uint8_t |
114252d2369aSRobert MustacchiPermissions:
114352d2369aSRobert Mustacchi.Sy Read/Write
114452d2369aSRobert Mustacchi.Ed
114552d2369aSRobert Mustacchi.Pp
114652d2369aSRobert MustacchiThe
114752d2369aSRobert Mustacchi.Sy MAC_PROP_EN_10GFDX_CAP
114852d2369aSRobert Mustacchiproperty describes whether or not 10 Gbit/s full-duplex support is
114952d2369aSRobert Mustacchienabled.
115052d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_40GFDX_CAP
115152d2369aSRobert Mustacchi.Bd -filled -compact
115252d2369aSRobert MustacchiType:
115352d2369aSRobert Mustacchi.Sy uint8_t |
115452d2369aSRobert MustacchiPermissions:
115552d2369aSRobert Mustacchi.Sy Read-Only
115652d2369aSRobert Mustacchi.Ed
115752d2369aSRobert Mustacchi.Pp
115852d2369aSRobert MustacchiThe
115952d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_40GFDX_CAP
116052d2369aSRobert Mustacchiproperty describes whether or not 40 Gbit/s full-duplex support is
116152d2369aSRobert Mustacchiadvertised.
116252d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_40GFDX_CAP
116352d2369aSRobert Mustacchi.Bd -filled -compact
116452d2369aSRobert MustacchiType:
116552d2369aSRobert Mustacchi.Sy uint8_t |
116652d2369aSRobert MustacchiPermissions:
116752d2369aSRobert Mustacchi.Sy Read/Write
116852d2369aSRobert Mustacchi.Ed
116952d2369aSRobert Mustacchi.Pp
117052d2369aSRobert MustacchiThe
117152d2369aSRobert Mustacchi.Sy MAC_PROP_EN_40GFDX_CAP
117252d2369aSRobert Mustacchiproperty describes whether or not 40 Gbit/s full-duplex support is
117352d2369aSRobert Mustacchienabled.
117452d2369aSRobert Mustacchi.It Sy MAC_PROP_ADV_100GFDX_CAP
117552d2369aSRobert Mustacchi.Bd -filled -compact
117652d2369aSRobert MustacchiType:
117752d2369aSRobert Mustacchi.Sy uint8_t |
117852d2369aSRobert MustacchiPermissions:
117952d2369aSRobert Mustacchi.Sy Read-Only
118052d2369aSRobert Mustacchi.Ed
118152d2369aSRobert Mustacchi.Pp
118252d2369aSRobert MustacchiThe
118352d2369aSRobert Mustacchi.Sy MAC_PROP_ADV_100GFDX_CAP
118452d2369aSRobert Mustacchiproperty describes whether or not 100 Gbit/s full-duplex support is
118552d2369aSRobert Mustacchiadvertised.
118652d2369aSRobert Mustacchi.It Sy MAC_PROP_EN_100GFDX_CAP
118752d2369aSRobert Mustacchi.Bd -filled -compact
118852d2369aSRobert MustacchiType:
118952d2369aSRobert Mustacchi.Sy uint8_t |
119052d2369aSRobert MustacchiPermissions:
119152d2369aSRobert Mustacchi.Sy Read/Write
119252d2369aSRobert Mustacchi.Ed
119352d2369aSRobert Mustacchi.Pp
119452d2369aSRobert MustacchiThe
119552d2369aSRobert Mustacchi.Sy MAC_PROP_EN_100GFDX_CAP
119652d2369aSRobert Mustacchiproperty describes whether or not 100 Gbit/s full-duplex support is
119752d2369aSRobert Mustacchienabled.
119852d2369aSRobert Mustacchi.El
119952d2369aSRobert Mustacchi.Ss Private Properties
120052d2369aSRobert MustacchiIn addition to the defined properties above, drivers are allowed to
1201*72d3dbb9SYuri Pankovdefine private properties.
1202*72d3dbb9SYuri PankovThese private properties are device-specific properties.
1203*72d3dbb9SYuri PankovAll private properties share the same constant,
120452d2369aSRobert Mustacchi.Sy MAC_PROP_PRIVATE .
1205*72d3dbb9SYuri PankovProperties are distinguished by a name, which is a character string.
1206*72d3dbb9SYuri PankovThe list of such private properties is defined when registering with mac in the
120752d2369aSRobert Mustacchi.Sy m_priv_props
120852d2369aSRobert Mustacchimember of the
120952d2369aSRobert Mustacchi.Xr mac_register 9S
121052d2369aSRobert Mustacchistructure.
121152d2369aSRobert Mustacchi.Pp
121252d2369aSRobert MustacchiThe driver may define whatever semantics it wants for these private
1213*72d3dbb9SYuri Pankovproperties.
1214*72d3dbb9SYuri PankovThey will not be listed when running
121552d2369aSRobert Mustacchi.Xr dladm 1M ,
1216*72d3dbb9SYuri Pankovunless explicitly requested by name.
1217*72d3dbb9SYuri PankovAll such properties should start with a leading underscore character and then
1218*72d3dbb9SYuri Pankovconsist of alphanumeric ASCII characters and additional underscores or hyphens.
121952d2369aSRobert Mustacchi.Pp
122052d2369aSRobert MustacchiProperties of type
122152d2369aSRobert Mustacchi.Sy MAC_PROP_PRIVATE
122252d2369aSRobert Mustacchimay show up in all three property related entry points:
122352d2369aSRobert Mustacchi.Xr mc_propinfo 9E ,
122452d2369aSRobert Mustacchi.Xr mc_getprop 9E ,
122552d2369aSRobert Mustacchiand
122652d2369aSRobert Mustacchi.Xr mc_setprop 9E .
122752d2369aSRobert MustacchiDevice drivers should tell the different properties apart by using the
122852d2369aSRobert Mustacchi.Xr strcmp 9F
122952d2369aSRobert Mustacchifunction to compare it to the set of properties that it knows about.
123052d2369aSRobert MustacchiWhen encountering properties that it doesn't know, it should treat them
123152d2369aSRobert Mustacchilike all other unknown properties.
123252d2369aSRobert Mustacchi.Sh STATISTICS
123352d2369aSRobert MustacchiThe MAC framework defines a couple different sets of statistics which
1234*72d3dbb9SYuri Pankovare based on various standards for devices to implement.
1235*72d3dbb9SYuri PankovStatistics are retrieved through the
123652d2369aSRobert Mustacchi.Xr mc_getstat 9E
1237*72d3dbb9SYuri Pankoventry point.
1238*72d3dbb9SYuri PankovThere are both statistics that are required for all devices and then there is a
1239*72d3dbb9SYuri Pankovseparate set of Ethernet specific statistics.
1240*72d3dbb9SYuri PankovNot all devices will support every statistic.
1241*72d3dbb9SYuri PankovIn many cases, several device registers will need to be combined to create the
1242*72d3dbb9SYuri Pankovproper stat.
124352d2369aSRobert Mustacchi.Pp
124452d2369aSRobert MustacchiIn general, if the device is not keeping track of these statistics, then
124552d2369aSRobert Mustacchiit is recommended that the driver store these values as a
124652d2369aSRobert Mustacchi.Sy uint64_t
124752d2369aSRobert Mustacchito ensure that overflow does not occur.
124852d2369aSRobert Mustacchi.Pp
124952d2369aSRobert MustacchiIf a device does not support a specific statistic, then it is fine to
1250*72d3dbb9SYuri Pankovreturn that it is not supported.
1251*72d3dbb9SYuri PankovThe same should be used for unrecognized statistics.
1252*72d3dbb9SYuri PankovSee
125352d2369aSRobert Mustacchi.Xr mc_getstat 9E
125452d2369aSRobert Mustacchifor more information on the proper way to handle these.
125552d2369aSRobert Mustacchi.Ss General Device Statistics
125652d2369aSRobert MustacchiThe following statistics are based on MIB-II statistics from both RFC
125752d2369aSRobert Mustacchi1213 and RFC 1573.
125852d2369aSRobert Mustacchi.Bl -tag -width Ds
125952d2369aSRobert Mustacchi.It Sy MAC_STAT_IFSPEED
126052d2369aSRobert MustacchiThe device's current speed in bits per second.
126152d2369aSRobert Mustacchi.It Sy MAC_STAT_MULTIRCV
126252d2369aSRobert MustacchiThe total number of received multicast packets.
126352d2369aSRobert Mustacchi.It Sy MAC_STAT_BRDCSTRCV
126452d2369aSRobert MustacchiThe total number of received broadcast packets.
126552d2369aSRobert Mustacchi.It Sy MAC_STAT_MULTIXMT
126652d2369aSRobert MustacchiThe total number of transmitted multicast packets.
126752d2369aSRobert Mustacchi.It Sy MAC_STAT_BRDCSTXMT
126852d2369aSRobert MustacchiThe total number of received broadcast packets.
126952d2369aSRobert Mustacchi.It Sy MAC_STAT_NORCVBUF
127052d2369aSRobert MustacchiThe total number of packets discarded by the hardware due to a lack of
127152d2369aSRobert Mustacchireceive buffers.
127252d2369aSRobert Mustacchi.It Sy MAC_STAT_IERRORS
127352d2369aSRobert MustacchiThe total number of errors detected on input.
127452d2369aSRobert Mustacchi.It Sy MAC_STAT_UNKNOWNS
127552d2369aSRobert MustacchiThe total number of received packets that were discarded because they
127652d2369aSRobert Mustacchiwere of an unknown protocol.
127752d2369aSRobert Mustacchi.It Sy MAC_STAT_NOXMTBUF
127852d2369aSRobert MustacchiThe total number of outgoing packets dropped due to a lack of transmit
127952d2369aSRobert Mustacchibuffers.
128052d2369aSRobert Mustacchi.It Sy MAC_STAT_OERRORS
128152d2369aSRobert MustacchiThe total number of outgoing packets that resulted in errors.
128252d2369aSRobert Mustacchi.It Sy MAC_STAT_COLLISIONS
128352d2369aSRobert MustacchiTotal number of collisions encountered by the transmitter.
128452d2369aSRobert Mustacchi.It Sy MAC_STAT_RBYTES
128552d2369aSRobert MustacchiThe total number of
128652d2369aSRobert Mustacchi.Sy bytes
128752d2369aSRobert Mustacchireceived by the device, regardless of packet type.
128852d2369aSRobert Mustacchi.It Sy MAC_STAT_IPACKETS
128952d2369aSRobert MustacchiThe total number of
129052d2369aSRobert Mustacchi.Sy packets
129152d2369aSRobert Mustacchireceived by the device, regardless of packet type.
129252d2369aSRobert Mustacchi.It Sy MAC_STAT_OBYTES
129352d2369aSRobert MustacchiThe total number of
129452d2369aSRobert Mustacchi.Sy bytes
129552d2369aSRobert Mustacchitransmitted by the device, regardless of packet type.
129652d2369aSRobert Mustacchi.It Sy MAC_STAT_OPACKETS
129752d2369aSRobert MustacchiThe total number of
129852d2369aSRobert Mustacchi.Sy packets
129952d2369aSRobert Mustacchisent by the device, regardless of packet type.
130052d2369aSRobert Mustacchi.It Sy MAC_STAT_UNDERFLOWS
130152d2369aSRobert MustacchiThe total number of packets that were smaller than the minimum sized
130252d2369aSRobert Mustacchipacket for the device and were therefore dropped.
130352d2369aSRobert Mustacchi.It Sy MAC_STAT_OVERFLOWS
130452d2369aSRobert MustacchiThe total number of packets that were larger than the maximum sized
130552d2369aSRobert Mustacchipacket for the device and were therefore dropped.
130652d2369aSRobert Mustacchi.El
130752d2369aSRobert Mustacchi.Ss Ethernet Specific Statistics
1308*72d3dbb9SYuri PankovThe following statistics are specific to Ethernet devices.
1309*72d3dbb9SYuri PankovThey refer to values from RFC 1643 and include various MII/GMII specific stats.
1310*72d3dbb9SYuri PankovMany of these are also defined in IEEE 802.3.
131152d2369aSRobert Mustacchi.Bl -tag -width Ds
131252d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_1000FDX
131352d2369aSRobert MustacchiIndicates that the device is advertising support for 1 Gbit/s
131452d2369aSRobert Mustacchifull-duplex operation.
131552d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_1000HDX
131652d2369aSRobert MustacchiIndicates that the device is advertising support for 1 Gbit/s
131752d2369aSRobert Mustacchihalf-duplex operation.
131852d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_100FDX
131952d2369aSRobert MustacchiIndicates that the device is advertising support for 100 Mbit/s
132052d2369aSRobert Mustacchifull-duplex operation.
132152d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_100GFDX
132252d2369aSRobert MustacchiIndicates that the device is advertising support for 100 Gbit/s
132352d2369aSRobert Mustacchifull-duplex operation.
132452d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_100HDX
132552d2369aSRobert MustacchiIndicates that the device is advertising support for 100 Mbit/s
132652d2369aSRobert Mustacchihalf-duplex operation.
132752d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_100T4
132852d2369aSRobert MustacchiIndicates that the device is advertising support for 100 Mbit/s
132952d2369aSRobert Mustacchi100BASE-T4 operation.
133052d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_10FDX
133152d2369aSRobert MustacchiIndicates that the device is advertising support for 10 Mbit/s
133252d2369aSRobert Mustacchifull-duplex operation.
133352d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_10GFDX
133452d2369aSRobert MustacchiIndicates that the device is advertising support for 10 Gbit/s
133552d2369aSRobert Mustacchifull-duplex operation.
133652d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_10HDX
133752d2369aSRobert MustacchiIndicates that the device is advertising support for 10 Mbit/s
133852d2369aSRobert Mustacchihalf-duplex operation.
133952d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_2500FDX
134052d2369aSRobert MustacchiIndicates that the device is advertising support for 2.5 Gbit/s
134152d2369aSRobert Mustacchifull-duplex operation.
134252d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_40GFDX
134352d2369aSRobert MustacchiIndicates that the device is advertising support for 40 Gbit/s
134452d2369aSRobert Mustacchifull-duplex operation.
134552d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_5000FDX
134652d2369aSRobert MustacchiIndicates that the device is advertising support for 5.0 Gbit/s
134752d2369aSRobert Mustacchifull-duplex operation.
134852d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_ASMPAUSE
134952d2369aSRobert MustacchiIndicates that the device is advertising support for receiving pause
135052d2369aSRobert Mustacchiframes.
135152d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_AUTONEG
135252d2369aSRobert MustacchiIndicates that the device is advertising support for auto-negotiation.
135352d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_CAP_PAUSE
135452d2369aSRobert MustacchiIndicates that the device is advertising support for generating pause
135552d2369aSRobert Mustacchiframes.
135652d2369aSRobert Mustacchi.It Sy ETHER_STAT_ADV_REMFAULT
135752d2369aSRobert MustacchiIndicates that the device is advertising support for detecting faults in
135852d2369aSRobert Mustacchithe remote link peer.
135952d2369aSRobert Mustacchi.It Sy ETHER_STAT_ALIGN_ERRORS
136052d2369aSRobert MustacchiIndicates the number of times an alignment error was generated by the
1361*72d3dbb9SYuri PankovEthernet device.
1362*72d3dbb9SYuri PankovThis is a count of packets that were not an integral number of octets and failed
1363*72d3dbb9SYuri Pankovthe FCS check.
136452d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_1000FDX
136552d2369aSRobert MustacchiIndicates the device supports 1 Gbit/s full-duplex operation.
136652d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_1000HDX
136752d2369aSRobert MustacchiIndicates the device supports 1 Gbit/s half-duplex operation.
136852d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_100FDX
136952d2369aSRobert MustacchiIndicates the device supports 100 Mbit/s full-duplex operation.
137052d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_100GFDX
137152d2369aSRobert MustacchiIndicates the device supports 100 Gbit/s full-duplex operation.
137252d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_100HDX
137352d2369aSRobert MustacchiIndicates the device supports 100 Mbit/s half-duplex operation.
137452d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_100T4
137552d2369aSRobert MustacchiIndicates the device supports 100 Mbit/s 100BASE-T4 operation.
137652d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_10FDX
137752d2369aSRobert MustacchiIndicates the device supports 10 Mbit/s full-duplex operation.
137852d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_10GFDX
137952d2369aSRobert MustacchiIndicates the device supports 10 Gbit/s full-duplex operation.
138052d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_10HDX
138152d2369aSRobert MustacchiIndicates the device supports 10 Mbit/s half-duplex operation.
138252d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_2500FDX
138352d2369aSRobert MustacchiIndicates the device supports 2.5 Gbit/s full-duplex operation.
138452d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_40GFDX
138552d2369aSRobert MustacchiIndicates the device supports 40 Gbit/s full-duplex operation.
138652d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_5000FDX
138752d2369aSRobert MustacchiIndicates the device supports 5.0 Gbit/s full-duplex operation.
138852d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_ASMPAUSE
138952d2369aSRobert MustacchiIndicates that the device supports the ability to receive pause frames.
139052d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_AUTONEG
139152d2369aSRobert MustacchiIndicates that the device supports the ability to perform link
139252d2369aSRobert Mustacchiauto-negotiation.
139352d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_PAUSE
139452d2369aSRobert MustacchiIndicates that the device supports the ability to transmit pause frames.
139552d2369aSRobert Mustacchi.It Sy ETHER_STAT_CAP_REMFAULT
139652d2369aSRobert MustacchiIndicates that the device supports the ability of detecting a remote
139752d2369aSRobert Mustacchifault in a link peer.
139852d2369aSRobert Mustacchi.It Sy ETHER_STAT_CARRIER_ERRORS
139952d2369aSRobert MustacchiIndicates the number of times that the Ethernet carrier sense condition
140052d2369aSRobert Mustacchiwas lost or not asserted.
140152d2369aSRobert Mustacchi.It Sy ETHER_STAT_DEFER_XMTS
140252d2369aSRobert MustacchiIndicates the number of frames for which the device was unable to
140352d2369aSRobert Mustacchitransmit the frame due to being busy and had to try again.
140452d2369aSRobert Mustacchi.It Sy ETHER_STAT_EX_COLLISIONS
140552d2369aSRobert MustacchiIndicates the number of frames that failed to send due to an excessive
140652d2369aSRobert Mustacchinumber of collisions.
140752d2369aSRobert Mustacchi.It Sy ETHER_STAT_FCS_ERRORS
140852d2369aSRobert MustacchiIndicates the number of times that a frame check sequence failed.
140952d2369aSRobert Mustacchi.It Sy ETHER_STAT_FIRST_COLLISIONS
141052d2369aSRobert MustacchiIndicates the number of times that a frame was eventually transmitted
141152d2369aSRobert Mustacchisuccessfully, but only after a single collision.
141252d2369aSRobert Mustacchi.It Sy ETHER_STAT_JABBER_ERRORS
141352d2369aSRobert MustacchiIndicates the number of frames that were received that were both larger
141452d2369aSRobert Mustacchithan the maximum packet size and failed the frame check sequence.
141552d2369aSRobert Mustacchi.It Sy ETHER_STAT_LINK_ASMPAUSE
141652d2369aSRobert MustacchiIndicates whether the link is currently configured to accept pause
141752d2369aSRobert Mustacchiframes.
141852d2369aSRobert Mustacchi.It Sy ETHER_STAT_LINK_AUTONEG
141952d2369aSRobert MustacchiIndicates whether the current link state is a result of
142052d2369aSRobert Mustacchiauto-negotiation.
142152d2369aSRobert Mustacchi.It Sy ETHER_STAT_LINK_DUPLEX
1422*72d3dbb9SYuri PankovIndicates the current duplex state of the link.
1423*72d3dbb9SYuri PankovThe values used here should be the same as documented for
142452d2369aSRobert Mustacchi.Sy MAC_PROP_DUPLEX .
142552d2369aSRobert Mustacchi.It Sy ETHER_STAT_LINK_PAUSE
142652d2369aSRobert MustacchiIndicates whether the link is currently configured to generate pause
142752d2369aSRobert Mustacchiframes.
142852d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_1000FDX
142952d2369aSRobert MustacchiIndicates the remote device supports 1 Gbit/s full-duplex operation.
143052d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_1000HDX
143152d2369aSRobert MustacchiIndicates the remote device supports 1 Gbit/s half-duplex operation.
143252d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_100FDX
143352d2369aSRobert MustacchiIndicates the remote device supports 100 Mbit/s full-duplex operation.
143452d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_100GFDX
143552d2369aSRobert MustacchiIndicates the remote device supports 100 Gbit/s full-duplex operation.
143652d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_100HDX
143752d2369aSRobert MustacchiIndicates the remote device supports 100 Mbit/s half-duplex operation.
143852d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_100T4
143952d2369aSRobert MustacchiIndicates the remote device supports 100 Mbit/s 100BASE-T4 operation.
144052d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_10FDX
144152d2369aSRobert MustacchiIndicates the remote device supports 10 Mbit/s full-duplex operation.
144252d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_10GFDX
144352d2369aSRobert MustacchiIndicates the remote device supports 10 Gbit/s full-duplex operation.
144452d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_10HDX
144552d2369aSRobert MustacchiIndicates the remote device supports 10 Mbit/s half-duplex operation.
144652d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_2500FDX
144752d2369aSRobert MustacchiIndicates the remote device supports 2.5 Gbit/s full-duplex operation.
144852d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_40GFDX
144952d2369aSRobert MustacchiIndicates the remote device supports 40 Gbit/s full-duplex operation.
145052d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_5000FDX
145152d2369aSRobert MustacchiIndicates the remote device supports 5.0 Gbit/s full-duplex operation.
145252d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_ASMPAUSE
145352d2369aSRobert MustacchiIndicates that the remote device supports the ability to receive pause
145452d2369aSRobert Mustacchiframes.
145552d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_AUTONEG
145652d2369aSRobert MustacchiIndicates that the remote device supports the ability to perform link
145752d2369aSRobert Mustacchiauto-negotiation.
145852d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_PAUSE
145952d2369aSRobert MustacchiIndicates that the remote device supports the ability to transmit pause
146052d2369aSRobert Mustacchiframes.
146152d2369aSRobert Mustacchi.It Sy ETHER_STAT_LP_CAP_REMFAULT
146252d2369aSRobert MustacchiIndicates that the remote device supports the ability of detecting a
146352d2369aSRobert Mustacchiremote fault in a link peer.
146452d2369aSRobert Mustacchi.It Sy ETHER_STAT_MACRCV_ERRORS
146552d2369aSRobert MustacchiIndicates the number of times that the internal MAC layer encountered an
146652d2369aSRobert Mustacchierror when attempting to receive and process a frame.
146752d2369aSRobert Mustacchi.It Sy ETHER_STAT_MACXMT_ERRORS
146852d2369aSRobert MustacchiIndicates the number of times that the internal MAC layer encountered an
146952d2369aSRobert Mustacchierror when attempting to process and transmit a frame.
147052d2369aSRobert Mustacchi.It Sy ETHER_STAT_MULTI_COLLISIONS
147152d2369aSRobert MustacchiIndicates the number of times that a frame was eventually transmitted
147252d2369aSRobert Mustacchisuccessfully, but only after more than one collision.
147352d2369aSRobert Mustacchi.It Sy ETHER_STAT_SQE_ERRORS
1474*72d3dbb9SYuri PankovIndicates the number of times that an SQE error occurred.
1475*72d3dbb9SYuri PankovThe specific conditions for this error are documented in IEEE 802.3.
147652d2369aSRobert Mustacchi.It Sy ETHER_STAT_TOOLONG_ERRORS
147752d2369aSRobert MustacchiIndicates the number of frames that were received that were longer than
147852d2369aSRobert Mustacchithe maximum frame size supported by the device.
147952d2369aSRobert Mustacchi.It Sy ETHER_STAT_TOOSHORT_ERRORS
148052d2369aSRobert MustacchiIndicates the number of frames that were received that were shorter than
148152d2369aSRobert Mustacchithe minimum frame size supported by the device.
148252d2369aSRobert Mustacchi.It Sy ETHER_STAT_TX_LATE_COLLISIONS
148352d2369aSRobert MustacchiIndicates the number of times a collision was detected late on the
148452d2369aSRobert Mustacchidevice.
148552d2369aSRobert Mustacchi.It Sy ETHER_STAT_XCVR_ADDR
148652d2369aSRobert MustacchiIndicates the address of the MII/GMII receiver address.
148752d2369aSRobert Mustacchi.It Sy ETHER_STAT_XCVR_ID
148852d2369aSRobert MustacchiIndicates the id of the MII/GMII receiver address.
148952d2369aSRobert Mustacchi.It Sy ETHER_STAT_XCVR_INUSE
1490*72d3dbb9SYuri PankovIndicates what kind of receiver is in use.
1491*72d3dbb9SYuri PankovThe following values may be used:
149252d2369aSRobert Mustacchi.Bl -tag -width Ds
149352d2369aSRobert Mustacchi.It Sy XCVR_UNDEFINED
149452d2369aSRobert MustacchiThe receiver type is undefined by the hardware.
149552d2369aSRobert Mustacchi.It Sy XCVR_NONE
149652d2369aSRobert MustacchiThere is no receiver in use by the hardware.
149752d2369aSRobert Mustacchi.It Sy XCVR_10
149852d2369aSRobert MustacchiThe receiver supports 10BASE-T operation.
149952d2369aSRobert Mustacchi.It Sy XCVR_100T4
150052d2369aSRobert MustacchiThe receiver supports 100BASE-T4 operation.
150152d2369aSRobert Mustacchi.It Sy XCVR_100X
150252d2369aSRobert MustacchiThe receiver supports 100BASE-TX operation.
150352d2369aSRobert Mustacchi.It Sy XCVR_100T2
150452d2369aSRobert MustacchiThe receiver supports 100BASE-T2 operation.
150552d2369aSRobert Mustacchi.It Sy XCVR_1000X
1506*72d3dbb9SYuri PankovThe receiver supports 1000BASE-X operation.
1507*72d3dbb9SYuri PankovThis is used for all fiber receivers.
150852d2369aSRobert Mustacchi.It Sy XCVR_1000T
1509*72d3dbb9SYuri PankovThe receiver supports 1000BASE-T operation.
1510*72d3dbb9SYuri PankovThis is used for all copper receivers.
151152d2369aSRobert Mustacchi.El
151252d2369aSRobert Mustacchi.El
151352d2369aSRobert Mustacchi.Ss Device Specific kstats
151452d2369aSRobert MustacchiIn addition to the defined statistics above, if the device driver
151552d2369aSRobert Mustacchimaintains additional statistics or the device provides additional
151652d2369aSRobert Mustacchistatistics, it should create its own kstats through the
151752d2369aSRobert Mustacchi.Xr kstat_create 9F
151852d2369aSRobert Mustacchifunction to allow operators to observe them.
151952d2369aSRobert Mustacchi.Sh TX STALL DETECTION, DEVICE RESETS, AND FAULT MANAGEMENT
152052d2369aSRobert MustacchiDevice drivers are the first line of defense for dealing with broken
1521*72d3dbb9SYuri Pankovdevices and bugs in their firmware.
1522*72d3dbb9SYuri PankovWhile most devices will rarely fail, it is important that when designing and
1523*72d3dbb9SYuri Pankovimplementing the device driver that particular attention is paid in the design
1524*72d3dbb9SYuri Pankovwith respect to RAS (Reliability, Availability, and Serviceability).
1525*72d3dbb9SYuri PankovWhile everything described in this section is optional, it is highly recommended
1526*72d3dbb9SYuri Pankovthat all new device drivers follow these guidelines.
152752d2369aSRobert Mustacchi.Pp
152852d2369aSRobert MustacchiThe Fault Management Architecture (FMA) provides facilities for
152952d2369aSRobert Mustacchidetecting and reporting various classes of defects and faults.
153052d2369aSRobert MustacchiSpecifically for networking device drivers, issues that should be
153152d2369aSRobert Mustacchidetected and reported include:
153252d2369aSRobert Mustacchi.Bl -bullet -offset indent
153352d2369aSRobert Mustacchi.It
153452d2369aSRobert MustacchiDevice internal uncorrectable errors
153552d2369aSRobert Mustacchi.It
153652d2369aSRobert MustacchiDevice internal correctable errors
153752d2369aSRobert Mustacchi.It
153852d2369aSRobert MustacchiPCI and PCI Express transport errors
153952d2369aSRobert Mustacchi.It
154052d2369aSRobert MustacchiDevice temperature alarms
154152d2369aSRobert Mustacchi.It
154252d2369aSRobert MustacchiDevice transmission stalls
154352d2369aSRobert Mustacchi.It
154452d2369aSRobert MustacchiDevice communication timeouts
154552d2369aSRobert Mustacchi.It
154652d2369aSRobert MustacchiHigh invalid interrupts
154752d2369aSRobert Mustacchi.El
154852d2369aSRobert Mustacchi.Pp
154952d2369aSRobert MustacchiAll such errors fall into three primary categories:
155052d2369aSRobert Mustacchi.Bl -enum -offset indent
155152d2369aSRobert Mustacchi.It
155252d2369aSRobert MustacchiErrors detected by the Fault Management Architecture
155352d2369aSRobert Mustacchi.It
155452d2369aSRobert MustacchiErrors detected by the device and indicated to the device driver
155552d2369aSRobert Mustacchi.It
155652d2369aSRobert MustacchiErrors detected by the device driver
155752d2369aSRobert Mustacchi.El
155852d2369aSRobert Mustacchi.Ss Fault Management Setup and Teardown
155952d2369aSRobert MustacchiDrivers should initialize support for the fault management framework by
156052d2369aSRobert Mustacchicalling
156152d2369aSRobert Mustacchi.Xr ddi_fm_init 9F
156252d2369aSRobert Mustacchifrom their
156352d2369aSRobert Mustacchi.Xr attach 9E
1564*72d3dbb9SYuri Pankovroutine.
1565*72d3dbb9SYuri PankovBy registering with the fault management framework, a device driver is given the
1566*72d3dbb9SYuri Pankovchance to detect and notice transport errors as well as report other errors that
1567*72d3dbb9SYuri Pankovexist.
1568*72d3dbb9SYuri PankovWhile a device driver does not need to indicate that it is capable of all such
1569*72d3dbb9SYuri Pankovcapabilities described in
157052d2369aSRobert Mustacchi.Xr ddi_fm_init 9F ,
157152d2369aSRobert Mustacchiwe suggest that device drivers at least register the
1572c71d194aSDillon Amburgey.Sy DDI_FM_EREPORT_CAPABLE
157352d2369aSRobert Mustacchiso as to allow the driver to report issues that it detects.
157452d2369aSRobert Mustacchi.Pp
157552d2369aSRobert MustacchiIf the driver registers with the fault management framework during its
157652d2369aSRobert Mustacchi.Xr attach 9E
157752d2369aSRobert Mustacchientry point, it must call
157852d2369aSRobert Mustacchi.Xr ddi_fm_fini 9E
157952d2369aSRobert Mustacchiduring its
158052d2369aSRobert Mustacchi.Xr detach 9E
158152d2369aSRobert Mustacchientry point.
158252d2369aSRobert Mustacchi.Ss Transport Errors
1583*72d3dbb9SYuri PankovMany modern networking devices leverage PCI or PCI Express.
1584*72d3dbb9SYuri PankovAs such, there are two primary ways that device drivers access data: they either
158552d2369aSRobert Mustacchimemory map device registers and use routines like
158652d2369aSRobert Mustacchi.Xr ddi_get8 9F
158752d2369aSRobert Mustacchiand
158852d2369aSRobert Mustacchi.Xr ddi_put8 9F
1589*72d3dbb9SYuri Pankovor they use direct memory access (DMA).
1590*72d3dbb9SYuri PankovNew device drivers should always enable checking of the transport layer by
1591*72d3dbb9SYuri Pankovmarking their support in the
159252d2369aSRobert Mustacchi.Xr ddi_device_acc_attr_t 9S
159352d2369aSRobert Mustacchistructure and using routines like
159452d2369aSRobert Mustacchi.Xr ddi_fm_acc_err_get 9F
159552d2369aSRobert Mustacchiand
159652d2369aSRobert Mustacchi.Xr ddi_fm_dma_err_get 9F
159752d2369aSRobert Mustacchito detect if errors have occurred.
159852d2369aSRobert Mustacchi.Ss Device Indicated Errors
159952d2369aSRobert MustacchiMany devices have capabilities to announce to a device driver that a
1600*72d3dbb9SYuri Pankovfatal correctable error or uncorrectable error has occurred.
1601*72d3dbb9SYuri PankovOther devices have the ability to indicate that various physical issues have
160252d2369aSRobert Mustacchioccurred such as a fan failing or a temperature sensor having fired.
160352d2369aSRobert Mustacchi.Pp
160452d2369aSRobert MustacchiDrivers should wire themselves to receive notifications when these
1605*72d3dbb9SYuri Pankovevents occur.
1606*72d3dbb9SYuri PankovThe means and capabilities will vary from device to device.
1607*72d3dbb9SYuri PankovFor example, some devices will generate information about these notifications
1608*72d3dbb9SYuri Pankovthrough special interrupts.
1609*72d3dbb9SYuri PankovOther devices may have a register that software can poll.
1610*72d3dbb9SYuri PankovIn the cases where polling is required, driver writers should try not to poll
1611*72d3dbb9SYuri Pankovtoo frequently and should generally only poll when the device is actively being
1612*72d3dbb9SYuri Pankovused, e.g. between calls to the
161352d2369aSRobert Mustacchi.Xr mc_start 9E
161452d2369aSRobert Mustacchiand
161552d2369aSRobert Mustacchi.Xr mc_stop 9E
161652d2369aSRobert Mustacchientry points.
161752d2369aSRobert Mustacchi.Ss Driver Transmit Stall Detection
161852d2369aSRobert MustacchiOne of the primary responsibilities of a hardened device driver is to
1619*72d3dbb9SYuri Pankovperform transmit stall detection.
1620*72d3dbb9SYuri PankovThe core idea behind tx stall detection is that the driver should record when
1621*72d3dbb9SYuri Pankovit's getting activity related to when data has been successfully transmitted.
1622*72d3dbb9SYuri PankovMost devices should be transmitting data on a regular basis as long as the link
1623*72d3dbb9SYuri Pankovis up.
1624*72d3dbb9SYuri PankovIf it is not, then this may indicate that the device is stuck and needs to be
1625*72d3dbb9SYuri Pankovreset.
1626*72d3dbb9SYuri PankovAt this time, the MAC framework does not provide any resources for performing
1627*72d3dbb9SYuri Pankovthese checks; however, polling on each individual transmit ring for the last
1628*72d3dbb9SYuri Pankovcompletion time while something is actively being transmitted through the use of
1629*72d3dbb9SYuri Pankovroutines such as
163052d2369aSRobert Mustacchi.Xr timeout 9F
163152d2369aSRobert Mustacchimay be a reasonable starting point.
163252d2369aSRobert Mustacchi.Ss Driver Command Timeout Detection
1633*72d3dbb9SYuri PankovEach device is programmed in different ways.
1634*72d3dbb9SYuri PankovSome devices are programmed through asynchronous commands while others are
1635*72d3dbb9SYuri Pankovprogrammed by writing directly to memory mapped registers.
1636*72d3dbb9SYuri PankovIf a device receives asynchronous replies to commands, then the device driver
1637*72d3dbb9SYuri Pankovshould set reasonable timeouts for all such commands and plan on detecting them.
1638*72d3dbb9SYuri PankovIf a timeout occurs, the driver should presume that there is an issue with the
163952d2369aSRobert Mustacchihardware and proceed to abort the command or reset the device.
164052d2369aSRobert Mustacchi.Pp
1641*72d3dbb9SYuri PankovMany devices do not have such a communication mechanism.
1642*72d3dbb9SYuri PankovHowever, whenever there is some activity where the device driver must wait, then
164352d2369aSRobert Mustacchiit should be prepared for the fact that the device may never get back to
164452d2369aSRobert Mustacchiit and react appropriately by performing some kind of device reset.
164552d2369aSRobert Mustacchi.Ss Reacting to Errors
164652d2369aSRobert MustacchiWhen any of the above categories of errors has been triggered, the
164752d2369aSRobert Mustacchibehavior that the device driver should take depends on the kind of
1648*72d3dbb9SYuri Pankoverror.
1649*72d3dbb9SYuri PankovIf a fatal error, for example, a transport error, a transmit stall was detected,
1650*72d3dbb9SYuri Pankovor the device indicated an uncorrectable error was detected, then it is
165152d2369aSRobert Mustacchiimportant that the driver take the following steps:
165252d2369aSRobert Mustacchi.Bl -enum -offset indent
165352d2369aSRobert Mustacchi.It
165452d2369aSRobert MustacchiSet a flag in the device driver's state that indicates that it has hit
1655*72d3dbb9SYuri Pankovan error condition.
1656*72d3dbb9SYuri PankovWhen this error condition flag is asserted, transmitted packets should be
1657*72d3dbb9SYuri Pankovaccepted and dropped and actions that would require writing to the device state
1658*72d3dbb9SYuri Pankovshould fail with an error.
1659*72d3dbb9SYuri PankovThis flag should remain until the device has been successfully restarted.
166052d2369aSRobert Mustacchi.It
166152d2369aSRobert MustacchiIf the error was not a transport error that was indicated by the fault
166252d2369aSRobert Mustacchimanagement architecture, e.g. a transport error that was detected, then
166352d2369aSRobert Mustacchithe device driver should post an
166452d2369aSRobert Mustacchi.Sy ereport
166552d2369aSRobert Mustacchiindicating what has occurred with the
166652d2369aSRobert Mustacchi.Xr ddi_fm_ereport_post 9F
166752d2369aSRobert Mustacchifunction.
166852d2369aSRobert Mustacchi.It
166952d2369aSRobert MustacchiThe device driver should indicate that the device's service was lost
167052d2369aSRobert Mustacchiwith a call to
167152d2369aSRobert Mustacchi.Xr ddi_fm_service_impact 9F
167252d2369aSRobert Mustacchiusing the symbol
167352d2369aSRobert Mustacchi.Sy DDI_SERVICE_LOST .
167452d2369aSRobert Mustacchi.It
167552d2369aSRobert MustacchiAt this point the device driver should issue a device reset through some
167652d2369aSRobert Mustacchidevice-specific means.
167752d2369aSRobert Mustacchi.It
167852d2369aSRobert MustacchiWhen the device reset has been completed, then the device driver should
1679*72d3dbb9SYuri Pankovrestore all of the programmed state to the device.
1680*72d3dbb9SYuri PankovThis includes things like the current MTU, advertised auto-negotiation speeds,
1681*72d3dbb9SYuri PankovMAC address filters, and more.
168252d2369aSRobert Mustacchi.It
168352d2369aSRobert MustacchiFinally, when service has been restored, the device driver should call
168452d2369aSRobert Mustacchi.Xr ddi_fm_service_impact 9F
168552d2369aSRobert Mustacchiusing the symbol
168652d2369aSRobert Mustacchi.Sy DDI_SERVICE_RESTORED .
168752d2369aSRobert Mustacchi.El
168852d2369aSRobert Mustacchi.Pp
168952d2369aSRobert MustacchiWhen a non-fatal error occurs, then the device driver should submit an
169052d2369aSRobert Mustacchiereport and should optionally mark the device degraded using
169152d2369aSRobert Mustacchi.Xr ddi_fm_service_impact 9F
169252d2369aSRobert Mustacchiwith the
169352d2369aSRobert Mustacchi.Sy DDI_SERVICE_DEGRADED
169452d2369aSRobert Mustacchivalue depending on the nature of the problem that has occurred.
169552d2369aSRobert Mustacchi.Pp
169652d2369aSRobert MustacchiDevice drivers should never make the decision to remove a device from
169752d2369aSRobert Mustacchiservice based on errors that have occurred nor should they panic the
1698*72d3dbb9SYuri Pankovsystem.
1699*72d3dbb9SYuri PankovRather, the device driver should always try to notify the operating system with
1700*72d3dbb9SYuri Pankovvarious ereports and allow its policy decisions to occur.
1701*72d3dbb9SYuri PankovThe decision to retire a device lies in the hands of the fault management
1702*72d3dbb9SYuri Pankovarchitecture.
1703*72d3dbb9SYuri PankovIt knows more about the operator's intent and the surrounding system's state
1704*72d3dbb9SYuri Pankovthan the device driver itself does and it will make the call to offline and
1705*72d3dbb9SYuri Pankovretire the device if it is required.
170652d2369aSRobert Mustacchi.Ss Device Resets
1707*72d3dbb9SYuri PankovWhen resetting a device, a device driver must exercise caution.
1708*72d3dbb9SYuri PankovIf a device driver has not been written to plan for a device reset, then it
1709*72d3dbb9SYuri Pankovmay not correctly restore the device's state after such a reset.
1710*72d3dbb9SYuri PankovSuch state should be stored in the instance's private state data as the MAC
171152d2369aSRobert Mustacchiframework does not know about device resets and will not inform the
171252d2369aSRobert Mustacchidevice again about the expected, programmed state.
171352d2369aSRobert Mustacchi.Pp
171452d2369aSRobert MustacchiOne wrinkle with device resets is that many networking cards show up as
171552d2369aSRobert Mustacchimultiple PCI functions on a single device, for example, each port may
171652d2369aSRobert Mustacchishow up as a separate function and thus have a separate instance of the
1717*72d3dbb9SYuri Pankovdevice driver attached.
1718*72d3dbb9SYuri PankovWhen resetting a function, device driver writers should carefully read the
1719*72d3dbb9SYuri Pankovdevice programming manuals and verify whether or not a reset impacts only the
1720*72d3dbb9SYuri Pankovstalled function or if it impacts all function across the device.
172152d2369aSRobert Mustacchi.Pp
172252d2369aSRobert MustacchiIf the only way to reset a given function is through the device, then
172352d2369aSRobert Mustacchithis may require more coordination and work on the part of the device
172452d2369aSRobert Mustacchidriver to ensure that all the other instances are correctly restored.
172552d2369aSRobert MustacchiIn cases where this occurs, some devices offer ways of injecting
172652d2369aSRobert Mustacchiinterrupts onto those other functions to notify them that this is
172752d2369aSRobert Mustacchioccurring.
172852d2369aSRobert Mustacchi.Sh MBLKS AND DMA
172952d2369aSRobert MustacchiThe networking stack manages framed data through the use of the
173052d2369aSRobert Mustacchi.Xr mblk 9S
1731*72d3dbb9SYuri Pankovstructure.
1732*72d3dbb9SYuri PankovThe mblk allows for a single message to be made up of individual blocks.
1733*72d3dbb9SYuri PankovEach part is linked together through its
173452d2369aSRobert Mustacchi.Sy b_cont
1735*72d3dbb9SYuri Pankovmember.
1736*72d3dbb9SYuri PankovHowever, it also allows for multiple messages to be chained together through the
1737*72d3dbb9SYuri Pankovuse of the
173852d2369aSRobert Mustacchi.Sy b_next
1739*72d3dbb9SYuri Pankovmember.
1740*72d3dbb9SYuri PankovWhile the networking stack works with these structures, device drivers generally
1741*72d3dbb9SYuri Pankovwork with DMA regions.
1742*72d3dbb9SYuri PankovThere are two different strategies that device drivers use for handling these
1743*72d3dbb9SYuri Pankovtwo different cases: copying and binding.
174452d2369aSRobert Mustacchi.Ss Copying Data
174552d2369aSRobert MustacchiThe first way that device drivers handle interfacing between the two is
1746*72d3dbb9SYuri Pankovby having two separate regions of memory.
1747*72d3dbb9SYuri PankovOne part is memory which has been allocated for DMA through a call to
174852d2369aSRobert Mustacchi.Xr ddi_dma_alloc 9F
174952d2369aSRobert Mustacchiand the other is memory associated with the memory block.
175052d2369aSRobert Mustacchi.Pp
175152d2369aSRobert MustacchiIn this case, a driver will use
175252d2369aSRobert Mustacchi.Xr bcopy 9F
1753*72d3dbb9SYuri Pankovto copy memory between the two distinct regions.
1754*72d3dbb9SYuri PankovWhen transmitting a packet, it will copy the memory from the mblk_t to the DMA
1755*72d3dbb9SYuri Pankovregion.
1756*72d3dbb9SYuri PankovWhen receiving memory, it will allocate a mblk_t through the
175752d2369aSRobert Mustacchi.Xr allocb 9F
175852d2369aSRobert Mustacchiroutine, copy the memory across with
175952d2369aSRobert Mustacchi.Xr bcopy 9F ,
176052d2369aSRobert Mustacchiand then increment the mblk_t's
176152d2369aSRobert Mustacchi.Sy w_ptr
176252d2369aSRobert Mustacchistructure.
176352d2369aSRobert Mustacchi.Pp
176452d2369aSRobert MustacchiIf, when receiving, memory is not available for a new message block,
1765*72d3dbb9SYuri Pankovthen the frame should be skipped and effectively dropped.
1766*72d3dbb9SYuri PankovA kstat should be bumped when such an occasion occurs.
176752d2369aSRobert Mustacchi.Ss Binding Data
1768*72d3dbb9SYuri PankovAn alternative approach to copying data is to use DMA binding.
1769*72d3dbb9SYuri PankovWhen using DMA binding, the OS takes care of mapping between DMA memory and
1770*72d3dbb9SYuri Pankovnormal device memory.
1771*72d3dbb9SYuri PankovThe exact process is a bit different between transmit and receive.
177252d2369aSRobert Mustacchi.Pp
177352d2369aSRobert MustacchiWhen transmitting a device driver has an mblk_t and needs to call the
177452d2369aSRobert Mustacchi.Xr ddi_dma_addr_bind_handle 9F
1775*72d3dbb9SYuri Pankovfunction to bind it to an already existing DMA handle.
1776*72d3dbb9SYuri PankovAt that point, it will receive various DMA cookies that it can use to obtain the
1777*72d3dbb9SYuri Pankovaddresses to program the device with for transmitting data.
1778*72d3dbb9SYuri PankovOnce the transmit is done, the driver must then make sure to call
177952d2369aSRobert Mustacchi.Xr freemsg 9F
1780*72d3dbb9SYuri Pankovto release the data.
1781*72d3dbb9SYuri PankovIt must not call
178252d2369aSRobert Mustacchi.Xr freemsg 9F
178352d2369aSRobert Mustacchibefore it receives an interrupt from the device indicating that the data
178452d2369aSRobert Mustacchihas been transmitted, otherwise it risks sending arbitrary kernel
178552d2369aSRobert Mustacchimemory.
178652d2369aSRobert Mustacchi.Pp
1787*72d3dbb9SYuri PankovWhen receiving data, the device can perform a similar operation.
1788*72d3dbb9SYuri PankovFirst, it must bind the DMA memory into the kernel's virtual memory address
178952d2369aSRobert Mustacchispace through a call to the
179052d2369aSRobert Mustacchi.Xr ddi_dma_addr_bind_handle 9F
1791*72d3dbb9SYuri Pankovfunction if it has not already.
1792*72d3dbb9SYuri PankovOnce it has, it must then call
179352d2369aSRobert Mustacchi.Xr desballoc 9F
1794*72d3dbb9SYuri Pankovto try and create a new mblk_t which leverages the associated memory.
1795*72d3dbb9SYuri PankovIt can then pass that mblk_t up to the stack.
179652d2369aSRobert Mustacchi.Ss Considerations
179752d2369aSRobert MustacchiWhen deciding which of these options to use, there are many different
1798*72d3dbb9SYuri Pankovconsiderations that must be made.
1799*72d3dbb9SYuri PankovThe answer as to whether to bind memory or to copy data is not always simpler.
180052d2369aSRobert Mustacchi.Pp
180152d2369aSRobert MustacchiThe first thing to remember is that DMA resources may be finite on a
1802*72d3dbb9SYuri Pankovgiven platform.
1803*72d3dbb9SYuri PankovConsider the case of receiving data.
1804*72d3dbb9SYuri PankovA device driver that binds one of its receive descriptors may not get it back
1805*72d3dbb9SYuri Pankovfor quite some time as it may be used by the kernel until an application
1806*72d3dbb9SYuri Pankovactually consumes it.
1807*72d3dbb9SYuri PankovDevice drivers that try to bind memory for receive, often work with the
1808*72d3dbb9SYuri Pankovconstraint that they must be able to replace that DMA memory with another DMA
1809*72d3dbb9SYuri Pankovdescriptor.
1810*72d3dbb9SYuri PankovIf they were not replaced, then eventually the device would not be able to
1811*72d3dbb9SYuri Pankovreceive additional data into the ring.
181252d2369aSRobert Mustacchi.Pp
181352d2369aSRobert MustacchiOn the other hand, particularly for larger frames, copying every packet
181452d2369aSRobert Mustacchifrom one buffer to another can be a source of additional latency and
1815*72d3dbb9SYuri Pankovmemory waste in the system.
1816*72d3dbb9SYuri PankovFor larger copies, the cost of copying may dwarf any potential cost of
1817*72d3dbb9SYuri Pankovperforming DMA binding.
181852d2369aSRobert Mustacchi.Pp
181952d2369aSRobert MustacchiFor device driver authors that are unsure of what to do, they should
182052d2369aSRobert Mustacchifirst employ the copying method to simplify the act of writing the
1821*72d3dbb9SYuri Pankovdevice driver.
1822*72d3dbb9SYuri PankovThe copying method is simpler and also allows the device driver author not to
1823*72d3dbb9SYuri Pankovworry about allocated DMA memory that is still outstanding when it is asked to
1824*72d3dbb9SYuri Pankovunload.
182552d2369aSRobert Mustacchi.Pp
182652d2369aSRobert MustacchiIf device driver writers are worried about the cost, it is recommended
182752d2369aSRobert Mustacchito make the decision as to whether or not to copy or bind DMA data
1828*72d3dbb9SYuri Pankova separate private property for both transmitting and receiving.
1829*72d3dbb9SYuri PankovThat private property should indicate the size of the received frame at which
1830*72d3dbb9SYuri Pankovto switch from one format to the other.
1831*72d3dbb9SYuri PankovThis way, data can be gathered to determine what the impact of each method is on
1832*72d3dbb9SYuri Pankova given platform.
183352d2369aSRobert Mustacchi.Sh SEE ALSO
183452d2369aSRobert Mustacchi.Xr dladm 1M ,
183552d2369aSRobert Mustacchi.Xr driver.conf 4 ,
183652d2369aSRobert Mustacchi.Xr ieee802.3 5 ,
183752d2369aSRobert Mustacchi.Xr dlpi 7P ,
183852d2369aSRobert Mustacchi.Xr _fini 9E ,
183952d2369aSRobert Mustacchi.Xr _info 9E ,
184052d2369aSRobert Mustacchi.Xr _init 9E ,
184152d2369aSRobert Mustacchi.Xr attach 9E ,
184252d2369aSRobert Mustacchi.Xr close 9E ,
184352d2369aSRobert Mustacchi.Xr detach 9E ,
184452d2369aSRobert Mustacchi.Xr mc_close 9E ,
184552d2369aSRobert Mustacchi.Xr mc_getcapab 9E ,
184652d2369aSRobert Mustacchi.Xr mc_getprop 9E ,
184752d2369aSRobert Mustacchi.Xr mc_getstat 9E ,
184852d2369aSRobert Mustacchi.Xr mc_multicst 9E  ,
184952d2369aSRobert Mustacchi.Xr mc_open 9E ,
185052d2369aSRobert Mustacchi.Xr mc_propinfo 9E  ,
185152d2369aSRobert Mustacchi.Xr mc_setpromisc 9E  ,
185252d2369aSRobert Mustacchi.Xr mc_setprop 9E ,
185352d2369aSRobert Mustacchi.Xr mc_start 9E ,
185452d2369aSRobert Mustacchi.Xr mc_stop 9E ,
185552d2369aSRobert Mustacchi.Xr mc_tx 9E ,
185652d2369aSRobert Mustacchi.Xr mc_unicst 9E  ,
185752d2369aSRobert Mustacchi.Xr open 9E ,
185852d2369aSRobert Mustacchi.Xr allocb 9F ,
185952d2369aSRobert Mustacchi.Xr bcopy 9F ,
186052d2369aSRobert Mustacchi.Xr ddi_dma_addr_bind_handle 9F ,
186152d2369aSRobert Mustacchi.Xr ddi_dma_alloc 9F ,
186252d2369aSRobert Mustacchi.Xr ddi_fm_acc_err_get 9F ,
186352d2369aSRobert Mustacchi.Xr ddi_fm_dma_err_get 9F ,
186452d2369aSRobert Mustacchi.Xr ddi_fm_ereport_post 9F ,
186552d2369aSRobert Mustacchi.Xr ddi_fm_fini 9F ,
186652d2369aSRobert Mustacchi.Xr ddi_fm_init 9F ,
186752d2369aSRobert Mustacchi.Xr ddi_fm_service_impact 9F ,
186852d2369aSRobert Mustacchi.Xr ddi_get8 9F ,
186952d2369aSRobert Mustacchi.Xr ddi_put8 9F ,
187052d2369aSRobert Mustacchi.Xr desballoc 9F ,
187152d2369aSRobert Mustacchi.Xr freemsg 9F ,
187252d2369aSRobert Mustacchi.Xr kstat_create 9F ,
187352d2369aSRobert Mustacchi.Xr mac_alloc 9F ,
187452d2369aSRobert Mustacchi.Xr mac_fini_ops 9F ,
187552d2369aSRobert Mustacchi.Xr mac_hcksum_get 9F ,
187652d2369aSRobert Mustacchi.Xr mac_hcksum_set 9F ,
187752d2369aSRobert Mustacchi.Xr mac_init_ops 9F ,
187852d2369aSRobert Mustacchi.Xr mac_link_update 9F ,
187952d2369aSRobert Mustacchi.Xr mac_lso_get 9F ,
188052d2369aSRobert Mustacchi.Xr mac_maxsdu_update 9F ,
188152d2369aSRobert Mustacchi.Xr mac_prop_info_set_default_link_flowctrl 9F ,
188252d2369aSRobert Mustacchi.Xr mac_prop_info_set_default_str 9F ,
188352d2369aSRobert Mustacchi.Xr mac_prop_info_set_default_uint32 9F ,
188452d2369aSRobert Mustacchi.Xr mac_prop_info_set_default_uint64 9F ,
188552d2369aSRobert Mustacchi.Xr mac_prop_info_set_default_uint8 9F ,
188652d2369aSRobert Mustacchi.Xr mac_prop_info_set_perm 9F ,
188752d2369aSRobert Mustacchi.Xr mac_prop_info_set_range_uint32 9F ,
188852d2369aSRobert Mustacchi.Xr mac_register 9F ,
188952d2369aSRobert Mustacchi.Xr mac_rx 9F ,
189052d2369aSRobert Mustacchi.Xr mac_unregister 9F ,
189152d2369aSRobert Mustacchi.Xr mc_getprop 9F ,
189252d2369aSRobert Mustacchi.Xr mc_tx 9F ,
189352d2369aSRobert Mustacchi.Xr mod_install 9F ,
189452d2369aSRobert Mustacchi.Xr mod_remove 9F ,
189552d2369aSRobert Mustacchi.Xr strcmp 9F ,
189652d2369aSRobert Mustacchi.Xr timeout 9F ,
189752d2369aSRobert Mustacchi.Xr cb_ops 9S ,
189852d2369aSRobert Mustacchi.Xr ddi_device_acc_attr_t 9S ,
189952d2369aSRobert Mustacchi.Xr dev_ops 9S ,
190052d2369aSRobert Mustacchi.Xr kstat_create 9S ,
190152d2369aSRobert Mustacchi.Xr mac_callbacks 9S ,
190252d2369aSRobert Mustacchi.Xr mac_register 9S ,
190352d2369aSRobert Mustacchi.Xr mblk 9S ,
190452d2369aSRobert Mustacchi.Xr modldrv 9S ,
190552d2369aSRobert Mustacchi.Xr modlinkage 9S
190652d2369aSRobert Mustacchi.Rs
190752d2369aSRobert Mustacchi.%A McCloghrie, K.
190852d2369aSRobert Mustacchi.%A Rose, M.
190952d2369aSRobert Mustacchi.%T RFC 1213 Management Information Base for Network Management of
191052d2369aSRobert Mustacchi.%T TCP/IP-based internets: MIB-II
191152d2369aSRobert Mustacchi.%D March 1991
191252d2369aSRobert Mustacchi.Re
191352d2369aSRobert Mustacchi.Rs
191452d2369aSRobert Mustacchi.%A McCloghrie, K.
191552d2369aSRobert Mustacchi.%A Kastenholz, F.
191652d2369aSRobert Mustacchi.%T RFC 1573 Evolution of the Interfaces Group of MIB-II
191752d2369aSRobert Mustacchi.%D January 1994
191852d2369aSRobert Mustacchi.Re
191952d2369aSRobert Mustacchi.Rs
192052d2369aSRobert Mustacchi.%A Kastenholz, F.
192152d2369aSRobert Mustacchi.%T RFC 1643 Definitions of Managed Objects for the Ethernet-like
192252d2369aSRobert Mustacchi.%T Interface Types
192352d2369aSRobert Mustacchi.Re
1924