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