Print this page
12309 errors in section 9e of the manual
   1 .\"
   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
   5 .\" 1.0 of the CDDL.
   6 .\"
   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.
  10 .\"
  11 .\"
  12 .\" Copyright (c) 2017, Joyent, Inc.
  13 .\"
  14 .Dd September 22, 2017
  15 .Dt MAC_REGISTER 9F
  16 .Os
  17 .Sh NAME
  18 .Nm mac_register ,
  19 .Nm mac_unregister
  20 .Nd register and unregister a device driver from the MAC framework
  21 .Sh SYNOPSIS
  22 .In sys/mac_provider.h
  23 .Ft int
  24 .Fo mac_register
  25 .Fa "mac_register_t *mregp"
  26 .Fa "mac_handle_t *mhp"
  27 .Fc
  28 .Ft int
  29 .Fo mac_unregister
  30 .Fa "mac_handle_t mh"
  31 .Fc
  32 .Sh INTERFACE LEVEL
  33 illumos DDI specific
  34 .Sh PARAMETERS


 153 #include <sys/mac_provider.h>
 154 #include <sys/mac_ether.h>
 155 
 156 /*
 157  * The call to mac_register(9F) generally comes from the context of
 158  * attach(9E). This function encapsulates setting up and initializing
 159  * the mac_register_t structure and should be assumed to be called from
 160  * attach.
 161  *
 162  * The exact set of callbacks and private properties will vary based
 163  * upon the driver.
 164  */
 165 
 166 static char *example_priv_props[] = {
 167         "_rx_intr_throttle",
 168         "_tx_intr_throttle",
 169         NULL
 170 };
 171 
 172 static mac_callbacks_t example_m_callbacks = {
 173         .mc_callbacsk = MC_GETCAPAB | MC_SETPROP | MC_GETPROP | MC_PROPINFO |
 174             MC_IOCTL,
 175         .mc_start = example_m_start,
 176         .mc_stop = example_m_stop,
 177         .mc_setpromisc = example_m_setpromisc,
 178         .mc_multicst = example_m_multicst,
 179         .mc_unicst = example_m_unicst,
 180         .mc_tx = example_m_tx,
 181         .mc_ioctl = example_m_ioctl,
 182         .mc_getcapab = example_m_getcapab,
 183         .mc_getprop = example_m_getprop,
 184         .mc_setprop = example_m_setprop,
 185         .mc_propinfo = example_m_propinfo
 186 };
 187 
 188 static boolean_t
 189 example_register_mac(example_t *ep)
 190 {
 191         int status;
 192         mac_register_t *mac;
 193 
 194         mac = mac_alloc(MAC_VERSION);
 195         if (mac == NULL)
 196                 return (B_FALSE);
 197 
 198         mac->m_type_ident = MAC_PLUGIN_IDENT_ETHER;
 199         mac->m_driver = ep;
 200         mac->m_dip = ep->ep_dev_info;
 201         mac->m_src_addr = ep->ep_mac_addr;
 202         mac->m_callbacks = &example_m_callbacks;
 203         mac->m_min_sdu = 0;
 204         mac->m_max_sdu = ep->ep_sdu;
 205         mac->m_margin = VLAN_TAGSZ;
 206         mac->m_priv_props = exmple_priv_props;
 207 
 208         status = mac_register(mac, &ep->ep_mac_hdl);
 209         mac_free(mac);
 210 
 211         return (status == 0);
 212 }
 213 .Ed
 214 .Sh ERRORS
 215 The
 216 .Fn mac_register
 217 function may fail if:
 218 .Bl -tag -width Er
 219 .It EEXIST
 220 A driver with the same name and instance already exists.
 221 .It EINVAL
 222 There was something invalid with the device's registration information.
 223 Some of the following reasons may apply, this list is not exhaustive:
 224 .Bl -bullet
 225 .It
 226 The


   1 .\"
   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
   5 .\" 1.0 of the CDDL.
   6 .\"
   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.
  10 .\"
  11 .\"
  12 .\" Copyright (c) 2017, Joyent, Inc.
  13 .\"
  14 .Dd February 15, 2020
  15 .Dt MAC_REGISTER 9F
  16 .Os
  17 .Sh NAME
  18 .Nm mac_register ,
  19 .Nm mac_unregister
  20 .Nd register and unregister a device driver from the MAC framework
  21 .Sh SYNOPSIS
  22 .In sys/mac_provider.h
  23 .Ft int
  24 .Fo mac_register
  25 .Fa "mac_register_t *mregp"
  26 .Fa "mac_handle_t *mhp"
  27 .Fc
  28 .Ft int
  29 .Fo mac_unregister
  30 .Fa "mac_handle_t mh"
  31 .Fc
  32 .Sh INTERFACE LEVEL
  33 illumos DDI specific
  34 .Sh PARAMETERS


 153 #include <sys/mac_provider.h>
 154 #include <sys/mac_ether.h>
 155 
 156 /*
 157  * The call to mac_register(9F) generally comes from the context of
 158  * attach(9E). This function encapsulates setting up and initializing
 159  * the mac_register_t structure and should be assumed to be called from
 160  * attach.
 161  *
 162  * The exact set of callbacks and private properties will vary based
 163  * upon the driver.
 164  */
 165 
 166 static char *example_priv_props[] = {
 167         "_rx_intr_throttle",
 168         "_tx_intr_throttle",
 169         NULL
 170 };
 171 
 172 static mac_callbacks_t example_m_callbacks = {
 173         .mc_callbacks = MC_GETCAPAB | MC_SETPROP | MC_GETPROP | MC_PROPINFO |
 174             MC_IOCTL,
 175         .mc_start = example_m_start,
 176         .mc_stop = example_m_stop,
 177         .mc_setpromisc = example_m_setpromisc,
 178         .mc_multicst = example_m_multicst,
 179         .mc_unicst = example_m_unicst,
 180         .mc_tx = example_m_tx,
 181         .mc_ioctl = example_m_ioctl,
 182         .mc_getcapab = example_m_getcapab,
 183         .mc_getprop = example_m_getprop,
 184         .mc_setprop = example_m_setprop,
 185         .mc_propinfo = example_m_propinfo
 186 };
 187 
 188 static boolean_t
 189 example_register_mac(example_t *ep)
 190 {
 191         int status;
 192         mac_register_t *mac;
 193 
 194         mac = mac_alloc(MAC_VERSION);
 195         if (mac == NULL)
 196                 return (B_FALSE);
 197 
 198         mac->m_type_ident = MAC_PLUGIN_IDENT_ETHER;
 199         mac->m_driver = ep;
 200         mac->m_dip = ep->ep_dev_info;
 201         mac->m_src_addr = ep->ep_mac_addr;
 202         mac->m_callbacks = &example_m_callbacks;
 203         mac->m_min_sdu = 0;
 204         mac->m_max_sdu = ep->ep_sdu;
 205         mac->m_margin = VLAN_TAGSZ;
 206         mac->m_priv_props = example_priv_props;
 207 
 208         status = mac_register(mac, &ep->ep_mac_hdl);
 209         mac_free(mac);
 210 
 211         return (status == 0);
 212 }
 213 .Ed
 214 .Sh ERRORS
 215 The
 216 .Fn mac_register
 217 function may fail if:
 218 .Bl -tag -width Er
 219 .It EEXIST
 220 A driver with the same name and instance already exists.
 221 .It EINVAL
 222 There was something invalid with the device's registration information.
 223 Some of the following reasons may apply, this list is not exhaustive:
 224 .Bl -bullet
 225 .It
 226 The