Print this page
    
2553 mac address should be a dladm link property
    
      
        | Split | Close | 
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/sys/mac.h
          +++ new/usr/src/uts/common/sys/mac.h
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   */
  25   25  
  26   26  #ifndef _SYS_MAC_H
  27   27  #define _SYS_MAC_H
  28   28  
  29   29  #include <sys/types.h>
  30   30  #ifdef  _KERNEL
  31   31  #include <sys/sunddi.h>
  32   32  #endif
  33   33  
  34   34  /*
  35   35   * MAC Services Module
  36   36   */
  37   37  
  38   38  #ifdef  __cplusplus
  39   39  extern "C" {
  40   40  #endif
  41   41  
  42   42  /*
  43   43   * MAC Information (text emitted by modinfo(1m))
  44   44   */
  45   45  #define MAC_INFO        "MAC Services"
  46   46  
  47   47  /*
  48   48   * MAC-Type version identifier.  This is used by mactype_alloc() and
  49   49   * mactype_register() to verify that incompatible MAC-Type plugins don't
  50   50   * register.
  51   51   */
  52   52  #define MACTYPE_VERSION 0x1
  53   53  
  54   54  /*
  55   55   * Opaque handle types
  56   56   */
  57   57  typedef struct __mac_handle             *mac_handle_t;
  58   58  typedef struct __mac_resource_handle    *mac_resource_handle_t;
  59   59  typedef struct __mac_notify_handle      *mac_notify_handle_t;
  60   60  typedef struct __mac_tx_notify_handle   *mac_tx_notify_handle_t;
  61   61  typedef struct __mac_intr_handle        *mac_intr_handle_t;
  62   62  typedef struct __mac_ring_handle        *mac_ring_handle_t;
  63   63  typedef struct __mac_group_handle       *mac_group_handle_t;
  64   64  
  65   65  #define DATALINK_INVALID_LINKID 0
  66   66  #define DATALINK_ALL_LINKID     0
  67   67  #define DATALINK_MAX_LINKID     0xffffffff
  68   68  
  69   69  typedef enum {
  70   70          LINK_STATE_UNKNOWN = -1,
  71   71          LINK_STATE_DOWN,
  72   72          LINK_STATE_UP
  73   73  } link_state_t;
  74   74  
  75   75  typedef enum {
  76   76          LINK_DUPLEX_UNKNOWN = 0,
  77   77          LINK_DUPLEX_HALF,
  78   78          LINK_DUPLEX_FULL
  79   79  } link_duplex_t;
  80   80  
  81   81  typedef enum {
  82   82          LINK_FLOWCTRL_NONE = 0,
  83   83          LINK_FLOWCTRL_RX,
  84   84          LINK_FLOWCTRL_TX,
  85   85          LINK_FLOWCTRL_BI
  86   86  } link_flowctrl_t;
  87   87  
  88   88  typedef enum {
  89   89          LINK_TAGMODE_VLANONLY = 0,
  90   90          LINK_TAGMODE_NORMAL
  91   91  } link_tagmode_t;
  92   92  
  93   93  /*
  94   94   * Defines range of uint32_t values
  95   95   */
  96   96  typedef struct mac_propval_uint32_range_s {
  97   97          uint32_t mpur_min;
  98   98          uint32_t mpur_max;
  99   99  } mac_propval_uint32_range_t;
 100  100  
 101  101  /*
 102  102   * Data type of property values.
 103  103   */
 104  104  typedef enum {
 105  105          MAC_PROPVAL_UINT8,
 106  106          MAC_PROPVAL_UINT32,
 107  107          MAC_PROPVAL_STR
 108  108  } mac_propval_type_t;
 109  109  
 110  110  /*
 111  111   * Captures possible values for a given property. A property can have
 112  112   * range of values (int32, int64, uint32, uint64, et al) or collection/
 113  113   * enumeration of values (strings).
 114  114   * Can be used as a value-result parameter.
 115  115   */
 116  116  typedef struct mac_propval_range_s {
 117  117          uint_t mpr_count;                       /* count of ranges */
 118  118          mac_propval_type_t mpr_type;            /* type of value */
 119  119          union {
 120  120                  mac_propval_uint32_range_t mpr_uint32[1];
 121  121          } u;
 122  122  } mac_propval_range_t;
 123  123  
 124  124  #define mpr_range_uint32        u.mpr_uint32
 125  125  
  
    | ↓ open down ↓ | 125 lines elided | ↑ open up ↑ | 
 126  126  /*
 127  127   * Maximum MAC address length
 128  128   */
 129  129  #define MAXMACADDRLEN           20
 130  130  
 131  131  typedef enum {
 132  132          MAC_LOGTYPE_LINK = 1,
 133  133          MAC_LOGTYPE_FLOW
 134  134  } mac_logtype_t;
 135  135  
      136 +typedef struct mac_addrprop_s {
      137 +        uint32_t        ma_len;
      138 +        uint8_t         ma_addr[MAXMACADDRLEN];
      139 +} mac_addrprop_t;
      140 +
 136  141  #define MAXLINKPROPNAME         256             /* max property name len */
 137  142  
 138  143  /*
 139  144   * Public properties.
 140  145   *
 141  146   * Note that there are 2 sets of parameters: the *_EN_* values are
 142  147   * those that the Administrator configures for autonegotiation. The
 143  148   * _ADV_* values are those that are currently exposed over the wire.
 144  149   */
 145  150  typedef enum {
 146  151          MAC_PROP_DUPLEX = 0x00000001,
 147  152          MAC_PROP_SPEED,
 148  153          MAC_PROP_STATUS,
 149  154          MAC_PROP_AUTONEG,
 150  155          MAC_PROP_EN_AUTONEG,
 151  156          MAC_PROP_MTU,
 152  157          MAC_PROP_ZONE,
 153  158          MAC_PROP_AUTOPUSH,
 154  159          MAC_PROP_FLOWCTRL,
 155  160          MAC_PROP_ADV_1000FDX_CAP,
 156  161          MAC_PROP_EN_1000FDX_CAP,
 157  162          MAC_PROP_ADV_1000HDX_CAP,
 158  163          MAC_PROP_EN_1000HDX_CAP,
 159  164          MAC_PROP_ADV_100FDX_CAP,
 160  165          MAC_PROP_EN_100FDX_CAP,
 161  166          MAC_PROP_ADV_100HDX_CAP,
 162  167          MAC_PROP_EN_100HDX_CAP,
 163  168          MAC_PROP_ADV_10FDX_CAP,
 164  169          MAC_PROP_EN_10FDX_CAP,
 165  170          MAC_PROP_ADV_10HDX_CAP,
 166  171          MAC_PROP_EN_10HDX_CAP,
 167  172          MAC_PROP_ADV_100T4_CAP,
 168  173          MAC_PROP_EN_100T4_CAP,
 169  174          MAC_PROP_IPTUN_HOPLIMIT,
 170  175          MAC_PROP_IPTUN_ENCAPLIMIT,
 171  176          MAC_PROP_WL_ESSID,
 172  177          MAC_PROP_WL_BSSID,
 173  178          MAC_PROP_WL_BSSTYPE,
 174  179          MAC_PROP_WL_LINKSTATUS,
 175  180          MAC_PROP_WL_DESIRED_RATES,
 176  181          MAC_PROP_WL_SUPPORTED_RATES,
 177  182          MAC_PROP_WL_AUTH_MODE,
 178  183          MAC_PROP_WL_ENCRYPTION,
 179  184          MAC_PROP_WL_RSSI,
 180  185          MAC_PROP_WL_PHY_CONFIG,
 181  186          MAC_PROP_WL_CAPABILITY,
 182  187          MAC_PROP_WL_WPA,
 183  188          MAC_PROP_WL_SCANRESULTS,
 184  189          MAC_PROP_WL_POWER_MODE,
 185  190          MAC_PROP_WL_RADIO,
 186  191          MAC_PROP_WL_ESS_LIST,
 187  192          MAC_PROP_WL_KEY_TAB,
 188  193          MAC_PROP_WL_CREATE_IBSS,
 189  194          MAC_PROP_WL_SETOPTIE,
 190  195          MAC_PROP_WL_DELKEY,
 191  196          MAC_PROP_WL_KEY,
 192  197          MAC_PROP_WL_MLME,
 193  198          MAC_PROP_TAGMODE,
 194  199          MAC_PROP_ADV_10GFDX_CAP,
 195  200          MAC_PROP_EN_10GFDX_CAP,
 196  201          MAC_PROP_PVID,
 197  202          MAC_PROP_LLIMIT,
  
    | ↓ open down ↓ | 52 lines elided | ↑ open up ↑ | 
 198  203          MAC_PROP_LDECAY,
 199  204          MAC_PROP_RESOURCE,
 200  205          MAC_PROP_RESOURCE_EFF,
 201  206          MAC_PROP_RXRINGSRANGE,
 202  207          MAC_PROP_TXRINGSRANGE,
 203  208          MAC_PROP_MAX_TX_RINGS_AVAIL,
 204  209          MAC_PROP_MAX_RX_RINGS_AVAIL,
 205  210          MAC_PROP_MAX_RXHWCLNT_AVAIL,
 206  211          MAC_PROP_MAX_TXHWCLNT_AVAIL,
 207  212          MAC_PROP_IB_LINKMODE,
      213 +        MAC_PROP_MACADDRESS,
 208  214          MAC_PROP_PRIVATE = -1
 209  215  } mac_prop_id_t;
 210  216  
 211  217  /*
 212  218   * Flags to figure out r/w status of legacy ndd props.
 213  219   */
 214  220  #define MAC_PROP_PERM_READ              0x0001
 215  221  #define MAC_PROP_PERM_WRITE             0x0010
 216  222  #define MAC_PROP_MAP_KSTAT              0x0100
 217  223  #define MAC_PROP_PERM_RW                (MAC_PROP_PERM_READ|MAC_PROP_PERM_WRITE)
 218  224  #define MAC_PROP_FLAGS_RK               (MAC_PROP_PERM_READ|MAC_PROP_MAP_KSTAT)
 219  225  
 220  226  #ifdef  _KERNEL
 221  227  
 222  228  /*
 223  229   * There are three ranges of statistics values.  0 to 1 - MAC_STAT_MIN are
 224  230   * interface statistics maintained by the mac module.  MAC_STAT_MIN to 1 -
 225  231   * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and
 226  232   * maintained by each driver.  MACTYPE_STAT_MIN and above are statistics
 227  233   * defined by MAC-Type plugins and maintained by each driver.
 228  234   */
 229  235  #define MAC_STAT_MIN            1000
 230  236  #define MACTYPE_STAT_MIN        2000
 231  237  
 232  238  #define IS_MAC_STAT(stat)       \
 233  239          (stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN)
 234  240  #define IS_MACTYPE_STAT(stat)   (stat >= MACTYPE_STAT_MIN)
 235  241  
 236  242  /*
 237  243   * Statistics maintained by the mac module, and possibly populated as link
 238  244   * statistics.
 239  245   */
 240  246  enum mac_mod_stat {
 241  247          MAC_STAT_LINK_STATE,
 242  248          MAC_STAT_LINK_UP,
 243  249          MAC_STAT_PROMISC,
 244  250          MAC_STAT_LOWLINK_STATE,
 245  251          MAC_STAT_HDROPS
 246  252  };
 247  253  
 248  254  /*
 249  255   * Do not reorder, and add only to the end of this list.
 250  256   */
 251  257  enum mac_driver_stat {
 252  258          /* MIB-II stats (RFC 1213 and RFC 1573) */
 253  259          MAC_STAT_IFSPEED = MAC_STAT_MIN,
 254  260          MAC_STAT_MULTIRCV,
 255  261          MAC_STAT_BRDCSTRCV,
 256  262          MAC_STAT_MULTIXMT,
 257  263          MAC_STAT_BRDCSTXMT,
 258  264          MAC_STAT_NORCVBUF,
 259  265          MAC_STAT_IERRORS,
 260  266          MAC_STAT_UNKNOWNS,
 261  267          MAC_STAT_NOXMTBUF,
 262  268          MAC_STAT_OERRORS,
 263  269          MAC_STAT_COLLISIONS,
 264  270          MAC_STAT_RBYTES,
 265  271          MAC_STAT_IPACKETS,
 266  272          MAC_STAT_OBYTES,
 267  273          MAC_STAT_OPACKETS,
 268  274          MAC_STAT_UNDERFLOWS,
 269  275          MAC_STAT_OVERFLOWS
 270  276  };
 271  277  
 272  278  #define MAC_NSTAT       (MAC_STAT_OVERFLOWS - MAC_STAT_IFSPEED + 1)
 273  279  
 274  280  #define MAC_STAT_ISACOUNTER(_stat) (            \
 275  281              (_stat) == MAC_STAT_MULTIRCV ||     \
 276  282              (_stat) == MAC_STAT_BRDCSTRCV ||    \
 277  283              (_stat) == MAC_STAT_MULTIXMT ||     \
 278  284              (_stat) == MAC_STAT_BRDCSTXMT ||    \
 279  285              (_stat) == MAC_STAT_NORCVBUF ||     \
 280  286              (_stat) == MAC_STAT_IERRORS ||      \
 281  287              (_stat) == MAC_STAT_UNKNOWNS ||     \
 282  288              (_stat) == MAC_STAT_NOXMTBUF ||     \
 283  289              (_stat) == MAC_STAT_OERRORS ||      \
 284  290              (_stat) == MAC_STAT_COLLISIONS ||   \
 285  291              (_stat) == MAC_STAT_RBYTES ||       \
 286  292              (_stat) == MAC_STAT_IPACKETS ||     \
 287  293              (_stat) == MAC_STAT_OBYTES ||       \
 288  294              (_stat) == MAC_STAT_OPACKETS ||     \
 289  295              (_stat) == MAC_STAT_UNDERFLOWS ||   \
 290  296              (_stat) == MAC_STAT_OVERFLOWS)
 291  297  
 292  298  /*
 293  299   * Immutable information. (This may not be modified after registration).
 294  300   */
 295  301  typedef struct mac_info_s {
 296  302          uint_t          mi_media;
 297  303          uint_t          mi_nativemedia;
 298  304          uint_t          mi_addr_length;
 299  305          uint8_t         *mi_unicst_addr;
 300  306          uint8_t         *mi_brdcst_addr;
 301  307  } mac_info_t;
 302  308  
 303  309  /*
 304  310   * When VNICs are created on top of the NIC, there are two levels
 305  311   * of MAC layer, a lower MAC, which is the MAC layer at the level of the
 306  312   * physical NIC, and an upper MAC, which is the MAC layer at the level
 307  313   * of the VNIC. Each VNIC maps to a MAC client at the lower MAC, and
 308  314   * the SRS and classification is done at the lower MAC level. The upper
 309  315   * MAC is therefore for the most part pass-through, and therefore
 310  316   * special processing needs to be done at the upper MAC layer when
 311  317   * dealing with a VNIC.
 312  318   *
 313  319   * This capability allows the MAC layer to detect when a VNIC is being
 314  320   * access, and implement the required shortcuts.
 315  321   */
 316  322  
 317  323  typedef void *(*mac_client_handle_fn_t)(void *);
 318  324  
 319  325  typedef struct mac_capab_vnic_s {
 320  326          void                    *mcv_arg;
 321  327          mac_client_handle_fn_t  mcv_mac_client_handle;
 322  328  } mac_capab_vnic_t;
 323  329  
 324  330  typedef void (*mac_rename_fn_t)(const char *, void *);
 325  331  typedef mblk_t *(*mac_tx_ring_fn_t)(void *, mblk_t *, uintptr_t,
 326  332      mac_ring_handle_t *);
 327  333  typedef struct mac_capab_aggr_s {
 328  334          mac_rename_fn_t mca_rename_fn;
 329  335          int (*mca_unicst)(void *, const uint8_t *);
 330  336          mac_tx_ring_fn_t mca_find_tx_ring_fn;
 331  337          void *mca_arg;
 332  338  } mac_capab_aggr_t;
 333  339  
 334  340  /* Bridge transmit and receive function signatures */
 335  341  typedef mblk_t *(*mac_bridge_tx_t)(mac_handle_t, mac_ring_handle_t, mblk_t *);
 336  342  typedef void (*mac_bridge_rx_t)(mac_handle_t, mac_resource_handle_t, mblk_t *);
 337  343  typedef void (*mac_bridge_ref_t)(mac_handle_t, boolean_t);
 338  344  typedef link_state_t (*mac_bridge_ls_t)(mac_handle_t, link_state_t);
 339  345  
 340  346  /* must change mac_notify_cb_list[] in mac_provider.c if this is changed */
 341  347  typedef enum {
 342  348          MAC_NOTE_LINK,
 343  349          MAC_NOTE_UNICST,
 344  350          MAC_NOTE_TX,
 345  351          MAC_NOTE_DEVPROMISC,
 346  352          MAC_NOTE_FASTPATH_FLUSH,
 347  353          MAC_NOTE_SDU_SIZE,
 348  354          MAC_NOTE_DEST,
 349  355          MAC_NOTE_MARGIN,
 350  356          MAC_NOTE_CAPAB_CHG,
 351  357          MAC_NOTE_LOWLINK,
 352  358          MAC_NOTE_ALLOWED_IPS,
 353  359          MAC_NNOTE       /* must be the last entry */
 354  360  } mac_notify_type_t;
 355  361  
 356  362  typedef void            (*mac_notify_t)(void *, mac_notify_type_t);
 357  363  typedef void            (*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *,
 358  364                              boolean_t);
 359  365  typedef mblk_t          *(*mac_receive_t)(void *, int);
 360  366  
 361  367  /*
 362  368   * MAC resource types
 363  369   */
 364  370  typedef enum {
 365  371          MAC_RX_FIFO = 1
 366  372  } mac_resource_type_t;
 367  373  
 368  374  typedef int     (*mac_intr_enable_t)(mac_intr_handle_t);
 369  375  typedef int     (*mac_intr_disable_t)(mac_intr_handle_t);
 370  376  
 371  377  typedef struct mac_intr_s {
 372  378          mac_intr_handle_t       mi_handle;
 373  379          mac_intr_enable_t       mi_enable;
 374  380          mac_intr_disable_t      mi_disable;
 375  381          ddi_intr_handle_t       mi_ddi_handle;
 376  382          boolean_t               mi_ddi_shared;
 377  383  } mac_intr_t;
 378  384  
 379  385  typedef struct mac_rx_fifo_s {
 380  386          mac_resource_type_t     mrf_type;       /* MAC_RX_FIFO */
 381  387          mac_intr_t              mrf_intr;
 382  388          mac_receive_t           mrf_receive;
 383  389          void                    *mrf_rx_arg;
 384  390          uint32_t                mrf_flow_priority;
 385  391          /*
 386  392           * The CPU this flow is to be processed on. With intrd and future
 387  393           * things, we should know which CPU the flow needs to be processed
 388  394           * and get a squeue assigned on that CPU.
 389  395           */
 390  396          uint_t                  mrf_cpu_id;
 391  397  } mac_rx_fifo_t;
 392  398  
 393  399  #define mrf_intr_handle         mrf_intr.mi_handle
 394  400  #define mrf_intr_enable         mrf_intr.mi_enable
 395  401  #define mrf_intr_disable        mrf_intr.mi_disable
 396  402  
 397  403  typedef union mac_resource_u {
 398  404          mac_resource_type_t     mr_type;
 399  405          mac_rx_fifo_t           mr_fifo;
 400  406  } mac_resource_t;
 401  407  
 402  408  typedef enum {
 403  409          MAC_ADDRTYPE_UNICAST,
 404  410          MAC_ADDRTYPE_MULTICAST,
 405  411          MAC_ADDRTYPE_BROADCAST
 406  412  } mac_addrtype_t;
 407  413  
 408  414  typedef struct mac_header_info_s {
 409  415          size_t          mhi_hdrsize;
 410  416          size_t          mhi_pktsize;
 411  417          const uint8_t   *mhi_daddr;
 412  418          const uint8_t   *mhi_saddr;
 413  419          uint32_t        mhi_origsap;
 414  420          uint32_t        mhi_bindsap;
 415  421          mac_addrtype_t  mhi_dsttype;
 416  422          uint16_t        mhi_tci;
 417  423          boolean_t       mhi_istagged;
 418  424          boolean_t       mhi_ispvid;
 419  425  } mac_header_info_t;
 420  426  
 421  427  /*
 422  428   * Function pointer to match dls client signature. Should be same as
 423  429   * dls_rx_t to allow a soft ring to bypass DLS layer and call a DLS
 424  430   * client directly.
 425  431   */
 426  432  typedef void            (*mac_direct_rx_t)(void *, mac_resource_handle_t,
 427  433                                  mblk_t *, mac_header_info_t *);
 428  434  
 429  435  typedef mac_resource_handle_t   (*mac_resource_add_t)(void *, mac_resource_t *);
 430  436  typedef int                     (*mac_resource_bind_t)(void *,
 431  437      mac_resource_handle_t, processorid_t);
 432  438  typedef void                    (*mac_resource_remove_t)(void *, void *);
 433  439  typedef void                    (*mac_resource_quiesce_t)(void *, void *);
 434  440  typedef void                    (*mac_resource_restart_t)(void *, void *);
 435  441  typedef int                     (*mac_resource_modify_t)(void *, void *,
 436  442                                      mac_resource_t *);
 437  443  typedef void                    (*mac_change_upcall_t)(void *, mac_direct_rx_t,
 438  444      void *);
 439  445  
 440  446  /*
 441  447   * MAC-Type plugin interfaces
 442  448   */
 443  449  
 444  450  typedef int             (*mtops_addr_verify_t)(const void *, void *);
 445  451  typedef boolean_t       (*mtops_sap_verify_t)(uint32_t, uint32_t *, void *);
 446  452  typedef mblk_t          *(*mtops_header_t)(const void *, const void *,
 447  453      uint32_t, void *, mblk_t *, size_t);
 448  454  typedef int             (*mtops_header_info_t)(mblk_t *, void *,
 449  455      mac_header_info_t *);
 450  456  typedef boolean_t       (*mtops_pdata_verify_t)(void *, size_t);
 451  457  typedef mblk_t          *(*mtops_header_modify_t)(mblk_t *, void *);
 452  458  typedef void            (*mtops_link_details_t)(char *, size_t, mac_handle_t,
 453  459      void *);
 454  460  
 455  461  typedef struct mactype_ops_s {
 456  462          uint_t                  mtops_ops;
 457  463          /*
 458  464           * mtops_unicst_verify() returns 0 if the given address is a valid
 459  465           * unicast address, or a non-zero errno otherwise.
 460  466           */
 461  467          mtops_addr_verify_t     mtops_unicst_verify;
 462  468          /*
 463  469           * mtops_multicst_verify() returns 0 if the given address is a
 464  470           * valid multicast address, or a non-zero errno otherwise.  If the
 465  471           * media doesn't support multicast, ENOTSUP should be returned (for
 466  472           * example).
 467  473           */
 468  474          mtops_addr_verify_t     mtops_multicst_verify;
 469  475          /*
 470  476           * mtops_sap_verify() returns B_TRUE if the given SAP is a valid
 471  477           * SAP value, or B_FALSE otherwise.
 472  478           */
 473  479          mtops_sap_verify_t      mtops_sap_verify;
 474  480          /*
 475  481           * mtops_header() is used to allocate and construct a MAC header.
 476  482           */
 477  483          mtops_header_t          mtops_header;
 478  484          /*
 479  485           * mtops_header_info() is used to gather information on a given MAC
 480  486           * header.
 481  487           */
 482  488          mtops_header_info_t     mtops_header_info;
 483  489          /*
 484  490           * mtops_pdata_verify() is used to verify the validity of MAC
 485  491           * plugin data.  It is called by mac_register() if the driver has
 486  492           * supplied MAC plugin data, and also by mac_pdata_update() when
 487  493           * drivers update the data.
 488  494           */
 489  495          mtops_pdata_verify_t    mtops_pdata_verify;
 490  496          /*
 491  497           * mtops_header_cook() is an optional callback that converts (or
 492  498           * "cooks") the given raw header (as sent by a raw DLPI consumer)
 493  499           * into one that is appropriate to send down to the MAC driver.
 494  500           * Following the example above, an Ethernet header sent down by a
 495  501           * DLPI consumer would be converted to whatever header the MAC
 496  502           * driver expects.
 497  503           */
 498  504          mtops_header_modify_t   mtops_header_cook;
 499  505          /*
 500  506           * mtops_header_uncook() is an optional callback that does the
 501  507           * opposite of mtops_header_cook().  It "uncooks" a given MAC
 502  508           * header (as received from the driver) for consumption by raw DLPI
 503  509           * consumers.  For example, for a non-Ethernet plugin that wants
 504  510           * raw DLPI consumers to be fooled into thinking that the device
 505  511           * provides Ethernet access, this callback would modify the given
 506  512           * mblk_t such that the MAC header is converted to an Ethernet
 507  513           * header.
 508  514           */
 509  515          mtops_header_modify_t   mtops_header_uncook;
 510  516          /*
 511  517           * mtops_link_details() is an optional callback that provides
 512  518           * extended information about the link state.  Its primary purpose
 513  519           * is to provide type-specific support for syslog contents on
 514  520           * link up events.  If no implementation is provided, then a default
 515  521           * implementation will be used.
 516  522           */
 517  523          mtops_link_details_t    mtops_link_details;
 518  524  } mactype_ops_t;
 519  525  
 520  526  /*
 521  527   * mtops_ops exists for the plugin to enumerate the optional callback
 522  528   * entrypoints it has defined.  This allows the mac module to define
 523  529   * additional plugin entrypoints in mactype_ops_t without breaking backward
 524  530   * compatibility with old plugins.
 525  531   */
 526  532  #define MTOPS_PDATA_VERIFY      0x001
 527  533  #define MTOPS_HEADER_COOK       0x002
 528  534  #define MTOPS_HEADER_UNCOOK     0x004
 529  535  #define MTOPS_LINK_DETAILS      0x008
 530  536  
 531  537  /*
 532  538   * Provide mapping for legacy ndd ioctls relevant to that mactype.
 533  539   * Note that the ndd ioctls are obsolete, and may be removed in a future
 534  540   * release of Solaris. The ndd ioctls are not typically used in legacy
 535  541   * ethernet drivers. New datalink drivers of all link-types should use
 536  542   * dladm(1m) interfaces for administering tunables and not have to provide
 537  543   * a mapping.
 538  544   */
 539  545  typedef struct mac_ndd_mapping_s {
 540  546          char            *mp_name;
 541  547          union {
 542  548                  mac_prop_id_t   u_id;
 543  549                  uint_t          u_kstat;
 544  550          } u_mp_id;
 545  551          long            mp_minval;
 546  552          long            mp_maxval;
 547  553          size_t          mp_valsize;
 548  554          int             mp_flags;
 549  555  } mac_ndd_mapping_t;
 550  556  
 551  557  #define mp_prop_id      u_mp_id.u_id
 552  558  #define mp_kstat        u_mp_id.u_kstat
 553  559  
 554  560  typedef struct mac_stat_info_s {
 555  561          uint_t          msi_stat;
 556  562          char            *msi_name;
 557  563          uint_t          msi_type;       /* as defined in kstat_named_init(9F) */
 558  564          uint64_t        msi_default;
 559  565  } mac_stat_info_t;
 560  566  
 561  567  typedef struct mactype_register_s {
 562  568          uint_t          mtr_version;    /* set by mactype_alloc() */
 563  569          const char      *mtr_ident;
 564  570          mactype_ops_t   *mtr_ops;
 565  571          uint_t          mtr_mactype;
 566  572          uint_t          mtr_nativetype;
 567  573          uint_t          mtr_addrlen;
 568  574          uint8_t         *mtr_brdcst_addr;
 569  575          mac_stat_info_t *mtr_stats;
 570  576          size_t          mtr_statcount;
 571  577          mac_ndd_mapping_t *mtr_mapping;
 572  578          size_t          mtr_mappingcount;
 573  579  } mactype_register_t;
 574  580  
 575  581  /*
 576  582   * Driver interface functions.
 577  583   */
 578  584  extern int                      mac_open_by_linkid(datalink_id_t,
 579  585                                      mac_handle_t *);
 580  586  extern int                      mac_open_by_linkname(const char *,
 581  587                                      mac_handle_t *);
 582  588  extern const char               *mac_name(mac_handle_t);
 583  589  extern minor_t                  mac_minor(mac_handle_t);
 584  590  extern minor_t                  mac_minor_hold(boolean_t);
 585  591  extern void                     mac_minor_rele(minor_t);
 586  592  extern void                     mac_sdu_get(mac_handle_t, uint_t *, uint_t *);
 587  593  extern void                     mac_sdu_get2(mac_handle_t, uint_t *, uint_t *,
 588  594                                      uint_t *);
 589  595  extern int                      mac_maxsdu_update(mac_handle_t, uint_t);
 590  596  extern int                      mac_maxsdu_update2(mac_handle_t, uint_t,
 591  597                                      uint_t);
 592  598  extern uint_t                   mac_addr_len(mac_handle_t);
 593  599  extern int                      mac_type(mac_handle_t);
 594  600  extern int                      mac_nativetype(mac_handle_t);
 595  601  
 596  602  extern void                     mac_unicst_update(mac_handle_t,
 597  603                                      const uint8_t *);
 598  604  extern void                     mac_capab_update(mac_handle_t);
 599  605  extern int                      mac_pdata_update(mac_handle_t, void *,
 600  606                                      size_t);
 601  607  extern boolean_t                mac_margin_update(mac_handle_t, uint32_t);
 602  608  extern void                     mac_margin_get(mac_handle_t, uint32_t *);
 603  609  extern int                      mac_margin_remove(mac_handle_t, uint32_t);
 604  610  extern int                      mac_margin_add(mac_handle_t, uint32_t *,
 605  611                                      boolean_t);
 606  612  extern int                      mac_fastpath_disable(mac_handle_t);
 607  613  extern void                     mac_fastpath_enable(mac_handle_t);
 608  614  extern void                     mac_no_active(mac_handle_t);
 609  615  
 610  616  extern mactype_register_t       *mactype_alloc(uint_t);
 611  617  extern void                     mactype_free(mactype_register_t *);
 612  618  extern int                      mactype_register(mactype_register_t *);
 613  619  extern int                      mactype_unregister(const char *);
 614  620  
 615  621  extern int                      mac_start_logusage(mac_logtype_t, uint_t);
 616  622  extern void                     mac_stop_logusage(mac_logtype_t);
 617  623  
 618  624  extern mac_handle_t             mac_get_lower_mac_handle(mac_handle_t);
 619  625  extern boolean_t                mac_is_vnic_primary(mac_handle_t);
 620  626  
 621  627  /*
 622  628   * Packet hashing for distribution to multiple ports and rings.
 623  629   */
 624  630  
 625  631  #define MAC_PKT_HASH_L2         0x01
 626  632  #define MAC_PKT_HASH_L3         0x02
 627  633  #define MAC_PKT_HASH_L4         0x04
 628  634  
 629  635  extern uint64_t                 mac_pkt_hash(uint_t, mblk_t *, uint8_t,
 630  636                                      boolean_t);
 631  637  
 632  638  /*
 633  639   * Bridging linkage
 634  640   */
 635  641  extern void                     mac_rx_common(mac_handle_t,
 636  642                                      mac_resource_handle_t, mblk_t *);
 637  643  extern int                      mac_bridge_set(mac_handle_t, mac_handle_t);
 638  644  extern void                     mac_bridge_clear(mac_handle_t, mac_handle_t);
 639  645  extern void                     mac_bridge_vectors(mac_bridge_tx_t,
 640  646                                      mac_bridge_rx_t, mac_bridge_ref_t,
 641  647                                      mac_bridge_ls_t);
 642  648  
 643  649  /* special case function for TRILL observability */
 644  650  extern void                     mac_trill_snoop(mac_handle_t, mblk_t *);
 645  651  
 646  652  #endif  /* _KERNEL */
 647  653  
 648  654  #ifdef  __cplusplus
 649  655  }
 650  656  #endif
 651  657  
 652  658  #endif /* _SYS_MAC_H */
  
    | ↓ open down ↓ | 435 lines elided | ↑ open up ↑ | 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX