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