2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
12 .\" Copyright 2016 Joyent, Inc.
20 .Nd initialize and finalize driver support for the MAC framework
22 .In sys/mac_provider.h
25 .Fa "struct dev_ops *ops"
26 .Fa "const char *name"
30 .Fa "struct dev_ops *ops"
37 A pointer to the driver's
41 A pointer to a null-terminated string of ASCII characters that contains
42 the name of the driver.
49 functions are used to initialize and finalize support for a device
50 driver that implements the
52 networking device framework.
56 function should be called during the driver's
59 As described in more detail in the
60 .Sx Initializing MAC Support
63 this must be called before the driver calls
65 If this is not done, then the call to
71 entry point, after the call to
73 has succeeded, then the driver must call the
75 function to finalize support and finish releasing any resources.
78 fails, then the device driver should not call
80 and should fail the call to
83 In addition, if the call to
87 entry point fails, then the driver should also call
89 See the example below for how this should be structured.
93 function should only ever be called from the context of a driver's
99 function should only ever be called from the context of a driver's
109 functions will always succeed.
110 They do not have any kind of return value.
112 The following example shows how a driver would call
120 entry points of a driver.
122 #include <sys/modctl.h>
124 #include <sys/sunddi.h>
125 #include <sys/mac_provider.h>
128 * When using this, replace mydrv with the name of the actual device
129 * driver. In addition, the mydrv_ prefix that is used should be
130 * replaced with the name of the device driver
132 #define MYDRV_NAME "mydrv"
135 * The following dev_ops structure would need to be filled in by a
136 * proper device driver.
138 static struct dev_ops mydrv_dev_ops;
140 static struct modldrv mydrv_modldrv = {
146 static struct modlinkage mydrv_modlinkage = {
157 /* Perform other needed initialization */
159 mac_init_ops(&mydrv_devops, MYDRV_NAME);
161 ret = mod_install(&mydrv_modlinkage);
162 if (ret != DDI_SUCCESS) {
163 mac_fini_ops(&mydrv_devops);
164 /* Perform other needed finalization */
171 _info(struct modinfo *modinfop)
173 return (mod_info(&mydrv_modlinkage, modinfo));
181 ret = mod_remove(&mydrv_modlinkage);
182 if (ret == DDI_SUCCESS) {
183 mac_fini_ops(&mydrv_devops);
184 /* Perform other needed finalization */