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