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